Update titles

This commit is contained in:
David Tomaschik
2025-05-07 14:25:03 -07:00
parent e227b65d6d
commit 5658c61627
2 changed files with 32 additions and 5 deletions

View File

@@ -19,7 +19,7 @@ set -g pane-base-index 1
# Terminal emulator window title # Terminal emulator window title
set -g set-titles on 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 keybindings
set -g mode-keys vi 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 window-status-current-style fg=colour235,bg=colour33,bold
set -g status-interval 60 set -g status-interval 60
set -g status-left-length 30 set -g status-left-length 30
set -g status-left '/#S/ ' set -g status-left '/#h: #S/ '
set -g status-right '#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=colour166]%H:%M#[default]' 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/ # Advanced mouse mode from http://tangledhelix.com/blog/2012/07/16/tmux-and-mouse-mode/
# Toggle mouse on # Toggle mouse on

View File

@@ -53,8 +53,35 @@ ulimit -c unlimited
DIRSTACKSIZE=16 DIRSTACKSIZE=16
# Set terminal title # Set terminal title
case $TERM in case $TERM in
xterm*) xterm*|screen*)
precmd () {print -Pn "\e]0;%n@%m: %~\a"} 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 esac