我可以通过这样做来获得在我的窗口上显示的vim标题:
let &titlestring = expand("%:t") . " @ " . hostname()
if &term == "screen"
set t_ts=^[k
set t_fs=^[\
endif
if &term == "screen" || &term == "xterm"
set title
endif
但标签会显示“默认”。
从命令行我可以这样做:
echo -ne "\e]1;hello world\a"
那将在我的标签中显示“Hello World”。
有没有办法让vim将这些内容写入我的标签而不是标题呢?
答案 0 :(得分:4)
我没有iTerm,所以我无法对此进行测试,但请尝试将其添加到your .vimrc
:
set t_ts=^[]1;
set t_fs=^G
为CTRL-V Escape
键入^[
,为CTRL-V CTRL-G
键入^G
。
答案 1 :(得分:1)
这对我有用:
" 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()