Last active
October 12, 2022 11:19
-
-
Save bignimbus/1da46a18416da4119778 to your computer and use it in GitHub Desktop.
Set iTerm2 title to current buffer in vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Set the title of the Terminal to the currently open file | |
function! SetTerminalTitle() | |
let titleString = expand('%:t') | |
if len(titleString) > 0 | |
let &titlestring = expand('%:t') | |
" this is the format iTerm2 expects when setting the window title | |
let args = "\033];".&titlestring."\007" | |
let cmd = 'silent !echo -e "'.args.'"' | |
execute cmd | |
redraw! | |
endif | |
endfunction | |
autocmd BufEnter * call SetTerminalTitle() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, this saved me a bunch of time tinkering with it myself and made life a little bit easier!