Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
364 views
in Technique[技术] by (71.8m points)

tmux tabs with name of file open in vim

I'm new to tmux and am trying to figure out how to edit the configuration so that windows with vim open show up in the taskbar not as #:vim but as whatever the name of the file open in vim is
(ie "#:filename.php"). Seems like it should be a common thing, but my search - foo is failing.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Here's a partial answer. It can be improved, but I don't have time to work it out right now.

Put the following in your .vimrc:

autocmd BufReadPost,FileReadPost,BufNewFile * call system("tmux rename-window " . expand("%"))

There are other events (see :help autocmd-events in Vim) that may be used to handle as well. One thing I haven't figured out is how to change the window name if you have an instance of vim open in each of two panes, and you switch from one pane to the other. vim is unaware of the activity in tmux, so no vim events are triggered.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...