about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.config/zsh/title.zsh31
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