diff --git a/dotfiles/tmux.conf b/dotfiles/tmux.conf index 613c98c..d3afd92 100644 --- a/dotfiles/tmux.conf +++ b/dotfiles/tmux.conf @@ -19,7 +19,7 @@ set -g pane-base-index 1 # Terminal emulator window title set -g set-titles on -set -g set-titles-string '#h:#S:#I.#P #W' +set -g set-titles-string '#h:#S:#I.#P #W#{?pane_title, (#{pane_title}),}' # Set keybindings set -g mode-keys vi @@ -43,8 +43,8 @@ source-file ~/.tmux/tmux-solarized-256.conf set -g window-status-current-style fg=colour235,bg=colour33,bold set -g status-interval 60 set -g status-left-length 30 -set -g status-left '/#S/ ' -set -g status-right '#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=colour166]%H:%M#[default]' +set -g status-left '/#h: #S/ ' +set -g status-right '#{?pane_title,/#{pane_title}/ ,}#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=colour166]%H:%M#[default]' # Advanced mouse mode from http://tangledhelix.com/blog/2012/07/16/tmux-and-mouse-mode/ # Toggle mouse on diff --git a/dotfiles/zshrc b/dotfiles/zshrc index b6d8340..4ef0621 100755 --- a/dotfiles/zshrc +++ b/dotfiles/zshrc @@ -53,8 +53,35 @@ ulimit -c unlimited DIRSTACKSIZE=16 # Set terminal title case $TERM in - xterm*) - precmd () {print -Pn "\e]0;%n@%m: %~\a"} + xterm*|screen*) + autoload -U add-zsh-hook + _term_precmd() { + emulate -L zsh + if test -n "${TMUX}" ; then + print -Pn "\e]2;%16<..<%~\e\\" + else + # this will also work in tmux but is not what we want + print -Pn "\e]0;%n@%m: %~\a" + fi + } + _term_preexec() { + emulate -L zsh + setopt LOCAL_OPTIONS + setopt EXTENDED_GLOB + # extract the first word of the command that is not a match for the + # pattern + # (w) = match word + # (r) = subscript value, not index + local cmd=${1[(wr)^(*=*|sudo|ssh|mosh|-*)]:gs/%/%%} + if test -n "${TMUX}" ; then + print -Pn "\e]2;${cmd}\e\\" + else + # this will also work in tmux but is not what we want + print -Pn "\e]0;%n@%m: %~ ($cmd)\a" + fi + } + add-zsh-hook precmd _term_precmd + add-zsh-hook preexec _term_preexec ;; esac