From b589b735cb2235830525083e07e0fb6046d76c21 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Thu, 1 Aug 2019 16:14:38 +0200 Subject: [PATCH] 11_terminal: Set "icon/tab title", not the "window" title Don't set the "window title" at all (and reset it before showing the new prompt), and set the "icon title" ("tab title") instead: this gives a much better experience when using tabs in Terminal.app and iTerm2.app, especially when mixing tabbed and non-tabbed windows. --- core/11_terminal/11_terminal.zshrc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/core/11_terminal/11_terminal.zshrc b/core/11_terminal/11_terminal.zshrc index 3a2099e..7b1214c 100644 --- a/core/11_terminal/11_terminal.zshrc +++ b/core/11_terminal/11_terminal.zshrc @@ -82,14 +82,14 @@ function axzsh_terminal_set_window_title { # Update terminal titles befor echoing the shell prompt function axzsh_terminal_title_precmd { axzsh_is_modern_terminal || return - axzsh_terminal_set_icon_title 'zsh' + axzsh_terminal_set_window_title '' if [[ "$TERM_PROGRAM" == "Apple_Terminal" && "$TERM" != "screen"* ]]; then - axzsh_terminal_set_window_title "$LOGNAME@$SHORT_HOST" + axzsh_terminal_set_icon_title "$LOGNAME@$SHORT_HOST" # Update CWD in Terminal.app local url=$(echo "file://$HOSTNAME$PWD" | sed -e 's| |%20|g') printf '\e]7;%s\a' "$url" else - axzsh_terminal_set_window_title "$LOGNAME@$SHORT_HOST:$PWD" + axzsh_terminal_set_icon_title "$LOGNAME@$SHORT_HOST:$PWD" fi } @@ -114,17 +114,16 @@ function axzsh_terminal_title_preexec { printf '\e]7;%s\a' '' fi fi - if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then - # iTerm.app ... - [[ -n "$cmd" ]] && TITLE_ADD=" – $cmd" - fi - axzsh_terminal_set_icon_title "$cmd" + if [[ -n "$cmd" ]]; then + # Add the command to the title + TITLE_ADD=" – $cmd" + fi if [[ -z "$remote" ]]; then - axzsh_terminal_set_window_title "$LOGNAME@$SHORT_HOST$TITLE_ADD" + axzsh_terminal_set_icon_title "$LOGNAME@$SHORT_HOST$TITLE_ADD" else - axzsh_terminal_set_window_title "$1" + axzsh_terminal_set_icon_title "$1" fi } -- 2.39.2