Skip to content

zshrc: unify terminal multiplexer detection #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions etc/zsh/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -2368,6 +2368,14 @@ setopt transient_rprompt

# Terminal-title wizardry

function inside_multiplexer () {
case "$TERM" in
screen|screen-*) return 0 ;;
tmux|tmux-*) return 0 ;;
esac
return 1
}

function ESC_print () {
info_print $'\ek' $'\e\\' "$@"
}
Expand Down Expand Up @@ -2397,7 +2405,7 @@ function grml_reset_screen_title () {
}

function grml_vcs_to_screen_title () {
if [[ $TERM == screen* ]] ; then
if inside_multiplexer ; then
if [[ -n ${vcs_info_msg_1_} ]] ; then
ESC_print ${vcs_info_msg_1_}
else
Expand All @@ -2407,9 +2415,9 @@ function grml_vcs_to_screen_title () {
}

function grml_cmd_to_screen_title () {
# get the name of the currently running program to set screen window title
# if running in a screen.
if [[ "$TERM" == screen* ]] ; then
# get the name of the currently running program to set multiplexer window title
# if running in a terminal multiplexer (screen/tmux).
if inside_multiplexer ; then
local CMD="${1[(wr)^(*=*|sudo|ssh|-*)]}"
ESC_print ${CMD}
fi
Expand Down Expand Up @@ -2573,7 +2581,8 @@ the zsh yet. :)
"NOCOR=1 zsh" => deactivate automatic correction
"NOMENU=1 zsh" => do not use auto menu completion
(note: use ctrl-d for completion instead!)
"NOPRECMD=1 zsh" => disable the precmd + preexec commands (set GNU screen title)
"NOPRECMD=1 zsh" => disable the precmd + preexec commands
(would set GNU screen/tmux title)
"NOTITLE=1 zsh" => disable setting the title of xterms without disabling
preexec() and precmd() completely
"GRML_DISPLAY_BATTERY=1 zsh"
Expand Down