如何获取我在vim中打开的文件以显示在我的iTerm选项卡中

时间:2010-01-20 23:32:37

标签: vim tabs iterm

我可以通过这样做来获得在我的窗口上显示的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将这些内容写入我的标签而不是标题呢?

2 个答案:

答案 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()

来源:https://gist.github.com/bignimbus/1da46a18416da4119778