I regularly ssh into a Linux cluster from an OS X (El Capitan) Terminal, sometimes with multiple Terminal tabs. I use bash and vim.
I'd like to do the following:
- while ssh'd, set the Terminal tab title to the current working directory using
PROMPT_COMMAND='printf "\e]1;"`basename $PWD`"\a"'
- while using vim, set the Terminal tab title to "vim — FILENAME"
Here are my problems:
- If I do
let &titlestring = "vim — " . expand("%:t")
andset title
in .vimrc, it changes the Terminal window title, not the tab title. If I do not separately set the tab title (parameter 1), the tab title mirrors the window title (parameter 2), but as soon as I set the tab title, it "decouples" from the window title. - If I run an external command in .vimrc with
:!
, I get a "Press ENTER" dialog that's annoying. - If I use
:silent !
in .vimrc, my Terminal prompt ends up at the bottom of the screen after exiting vim. I really don't want to muck around with saving the prompt position and resetting it every time I want to use vim. If I define in my .bashrc the following function:
function vim { printf "\e]1;"`basename "$1"`"\a" vim "$1" }
then my terminal crashes upon calling
vim
from the command line. Calling the functionvvim
instead works, but I don't want to typevvim
forever. I want to aliasvim
.
So I seem stuck. Any advice would be much appreciated. Thank you in advance!
vim
calls the functionvim
calls the functionvim
, etc. Replacevim "$1"
withcommand vim "$1"
to avoid this loop.