diff options
author | Starfall <us@starfall.systems> | 2022-11-29 16:47:56 -0600 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2022-11-29 16:47:56 -0600 |
commit | 9d3ecf9849305839740938f699f040027910ffa9 (patch) | |
tree | e9bda6a804b46bc6fc34ca1e118198c0c3950a72 /.config | |
parent | f58e953488db98c32972df2802cf631f9d4dd21e (diff) |
zsh: set title automatically (probably doesn't work properly on screen/tmux)
Diffstat (limited to '.config')
-rw-r--r-- | .config/zsh/title.zsh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/.config/zsh/title.zsh b/.config/zsh/title.zsh new file mode 100644 index 0000000..f508347 --- /dev/null +++ b/.config/zsh/title.zsh @@ -0,0 +1,31 @@ +DISABLE_AUTO_TITLE="true" + +function precmd_set_title { + title="" + if [[ -n "$SSH_CLIENT" || "$USER" == "root" ]]; then + title+="$USER@$HOST:" + fi + + location="${PWD/#"$HOME"/~}" + title+="$location" + + echo -ne "\e]2;$title\a" +} + +function preexec_set_title { + title="" + if [[ -n "$SSH_CLIENT" || "$USER" == "root" ]]; then + title+="$USER@$HOST:" + fi + + title+="$2 - " + + location="${PWD/#"$HOME"/~}" + title+="$location" + + echo -ne "\e]2;$title\a" +} + +autoload -Uz add-zsh-hook +add-zsh-hook precmd precmd_set_title +add-zsh-hook preexec preexec_set_title |