Was wondering if it'd be possible to somehow show the current file I'm editing in the tabs of my screen
Because it'd be way easier to know what I'm switching between.
I have this (indirectly) in my ~/.vimrc
:
let &titlestring = "Editing: " . expand("%:p")
if &term == "screen"
set t_ts=^[k
set t_fs=^[\
endif
if &term == "screen" || &term == "xterm"
set title
endif
It changes my terminal tab, and I assume from reading it (and the screen(1)
man page) that it should work with screen as well.
^[
character (it's special and cannot be copied directly). A better alternative is to use <Esc>
as in: set t_ts="\<Esc>k"
. Also check your $TERM
variable because this solution only works if your term is set to screen
(mine is set to screen.xterm-256color
, so I had to change the conditional). See cychoi's answer for a more flexible version if necessary.
I implemented this to change both the xterm's (or sisters and brothers such as PuTTY) window title and GNU screen's window title.
Put in your vimrc
:
if has('title')
if &term =~# '\v^(screen|xterm|putty).*'
set title
endif
if &title
" xterm OSC for changing window title and icon name
let &t_ts="\<Esc>]0;"
let &t_fs="\<C-G>"
" if inside GNU screen, change screen's window title and
" xterm's window title on BufEnter event
if $STY
augroup cy.title
autocmd!
autocmd BufEnter * let &t_ts="\<Esc>k" . expand('%:t') . "\<Esc>\\\<Esc>]0;"
augroup END
endif
endif
endif