2

Whenever I start screen, it changes the title of the terminal window to 'screen'. Can I prevent that and have the window title remain what it would be if I hadn't run my command under screen?

More specifically, I'd like gnome-terminal to display the name of the buffer I'm editing in vim. I can do this by adding set title to my .vimrc. Now when I run vim, the buffer name (along with some other information), shows up in the title of gnome-terminal. When I start screen and run vim, the title changes to 'screen'.

I've looked at the following page:

http://beautifulpixels.blogspot.co.at/2012/01/automatic-screen-window-titles-in-bash.html

But the suggested solution places the window title in the screen status line. I also tried adding this:

case $TERM in
    screen*)
        # http://dtfm.tumblr.com/post/7193076007/the-sweetest-screenrc-hack-ever
        SCREENTITLE='\[\ek\e\\\]\[\ek\W\e\\\]'
        ;;
    *)
        SCREENTITLE=''
        ;;
esac

TITLEBAR='\[\e]0;\a\]'

export PS1="${SCREENTITLE}${TITLEBAR}[\u@\h \W]\$ "

To my .bashrc, but this only sets the window title to the current directory. Even if I run vim, the window title remains the current working directory. This is not the case if I run it outside of screen.

Any ideas?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
juniper-
  • 6,262
  • 10
  • 37
  • 65
  • not sure if this question has something to do with the tag `vim`. if you `s/vim/nano/g` your question doesn't have a different meaning. It is a screen conf problem, not vim. so I am gonna remove the `vim` tag. if I am wrong, you could explain a bit and add it back. – Kent May 22 '13 at 09:45
  • No, you're absolutely right. – juniper- May 22 '13 at 09:46
  • 1
    You might want to check out `tmux`. It has a lot of newer features compared to `screen`, and can do things like this. – demure May 22 '13 at 12:56

1 Answers1

1

Although I didn't exactly solve it, demure's comment enticed me to check out tmux. Using that I was able to put the following line:

autocmd BufReadPost,FileReadPost,BufNewFile * call system("tmux rename-window '" . expand("%:p:~") . " - VIM'")

In my .vimrc file and I get the effect I wanted in the first place (except, of course, now I'm using tmux).

References:

tmux tabs with name of file open in vim

How can I expand the full path of the current file to pass to a command in Vim?

Community
  • 1
  • 1
juniper-
  • 6,262
  • 10
  • 37
  • 65