summary refs log tree commit diff stats
path: root/tag-zsh/config/zsh
diff options
context:
space:
mode:
authorAlan Pearce2016-12-15 16:45:27 +0100
committerAlan Pearce2016-12-15 16:45:27 +0100
commite2d85d381b0a3e827e9bf37dd6c527d6b08044d6 (patch)
treea6481bc29a2a8d228593410dc806f80e8fd703a2 /tag-zsh/config/zsh
parent10c8548d14e2349ff9bdcf0aa2f26b2e8eadd012 (diff)
downloadnixfiles-e2d85d381b0a3e827e9bf37dd6c527d6b08044d6.tar.lz
nixfiles-e2d85d381b0a3e827e9bf37dd6c527d6b08044d6.tar.zst
nixfiles-e2d85d381b0a3e827e9bf37dd6c527d6b08044d6.zip
zsh: Set or unset window title according to host
Diffstat (limited to 'tag-zsh/config/zsh')
-rw-r--r--tag-zsh/config/zsh/zshrc12
1 files changed, 12 insertions, 0 deletions
diff --git a/tag-zsh/config/zsh/zshrc b/tag-zsh/config/zsh/zshrc
index 7b3d332f..e1f5555f 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