On Wed, Aug 08, 2012 at 11:21:19PM -0700, John Magolske wrote: > * John Magolske <listm...@b79.net> [120805 23:40]: > > > * John Magolske <listm...@b79.net> [120801 09:15]: > > > > I'm trying to get the title of the active pane in the status line to > > > > display $PWD when no command is active, and the current command when > > > > a command is active. So, for example, if I cd to ~/Mail in the active > > > > pane of window 7 the status line would be simply: 7*Mail > > > > > > > > Then if I invoke the vifm file browser: 7*vifm > > > > [...] > > > > ~/.zshrc : > > preexec () { > > local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} > > [[ "$TERM" == tmux* ]] && printf "\033]2;$CMD\033\\" > > } > > precmd () { > > [[ "$TERM" == tmux* ]] && printf "\033]2;`basename ${PWD}`\033\\" > > } > > > > ~/.tmux.conf : > > setw -g window-status-current-format '#I#F#T ' > > setw -g window-status-format '#I#F#T ' > > > > This works fairly well, but I'm not finding a way to set the title > > of windows created using the "new-window" command. ... does not allow > > for the more customized titles with Vim using "set titlestring=..." > > in ~/.vimrc (just shows "vim" as the window title). > > Taking a closer look at the NAMES AND TITLES section of the tmux > manpage, I see there are different escape sequences for window names > and pane titles. So now, doing this: > > ~/.zshrc : > preexec () { > local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} > [[ "$TERM" == tmux* ]] && printf "\033k$CMD\033\\" > } > precmd () { > [[ "$TERM" == tmux* ]] && printf "\033k`basename ${PWD}`\033\\" > }
IIRC there is no equivalent of preexec for bash, but precmd is probably the equivalent for PROMPT_COMMAND. If I'm right you probably can simplify this even further, instead of echo'ing this string using the precmd() hook, you can probably define your PS1 at the shell startup to do this for you: e.g.: ~/.bashrc [[ "$TERM" == tmux* ]] && PS1='\u@\h\[\033k\w\033\\\] \$ ' -> with \[ ... \] is the bash way of saying this is non-printing characters, don't count them for the prompt length -> you probably also have the \W escape available which you can find usefull -> this way you don't fork (`command`) at every prompt:) I'm sure you can adapt it for zsh:) > > ~/.tmux.conf : > setw -g window-status-current-format '#I#F#W ' > setw -g window-status-format '#I#F#W ' > > Makes everything works perfectly. > > John > > -- > John Magolske > http://B79.net/contact > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > tmux-users mailing list > tmux-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/tmux-users ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users