about summary refs log tree commit diff
path: root/.config/zsh/title.zsh
blob: f5083474f018ddaa1faf4932ab54dd2ad3e073b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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