From 9d3ecf9849305839740938f699f040027910ffa9 Mon Sep 17 00:00:00 2001 From: Starfall Date: Tue, 29 Nov 2022 16:47:56 -0600 Subject: zsh: set title automatically (probably doesn't work properly on screen/tmux) --- .config/zsh/title.zsh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .config/zsh/title.zsh 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 -- cgit