From e2d85d381b0a3e827e9bf37dd6c527d6b08044d6 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 15 Dec 2016 16:45:27 +0100 Subject: zsh: Set or unset window title according to host --- tag-zsh/config/zsh/zshrc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tag-zsh/config/zsh/zshrc b/tag-zsh/config/zsh/zshrc index 7b3d332..e1f5555 100644 --- a/tag-zsh/config/zsh/zshrc +++ b/tag-zsh/config/zsh/zshrc @@ -217,6 +217,18 @@ else # Run once to get initial cwd set update_terminalapp_cwd fi + + function set_window_title { printf '\e]2;%s\a' "$1" } + + function update_window_title { + if [[ -n "$SSH_CONNECTION" || $UID -eq 0 ]] + then + set_window_title "$USER@$HOST" + else + set_window_title "" + fi + } + precmd_functions+=(update_window_title) fi if zplug check clvv/fasd -- cgit 1.4.1