4

Was wondering if it'd be possible to somehow show the current file I'm editing in the tabs of my screen

enter image description here

Because it'd be way easier to know what I'm switching between.

2 Answers 2

0

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.

2
  • That seemed to just add the current filename at the bottom row when I'm viewing the file, but not specifically in the screen tabs themselves.
    – bob_cobb
    Sep 4, 2012 at 17:42
  • I couldn't get this to work either (nor anything listed here). cychoi's answer worked for me, though. To any readers, also be mindful not to copy-paste the ^[ 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.
    – xikkub
    Feb 25, 2020 at 23:51
1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .