]> arthur.barton.de Git - ax-zsh.git/commitdiff
11_terminal: Set "icon/tab title", not the "window" title
authorAlexander Barton <alex@barton.de>
Thu, 1 Aug 2019 14:14:38 +0000 (16:14 +0200)
committerAlexander Barton <alex@barton.de>
Thu, 1 Aug 2019 14:14:38 +0000 (16:14 +0200)
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

index 3a2099e2166cdf2f9ea9202d57a8f8cdb8fcc023..7b1214ca7a7191a7bbab02b4d9fbdafa9cbeebef 100644 (file)
@@ -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
 }