home/.zsh/functions.d/murx.sh

24 lines
804 B
Bash
Raw Normal View History

2026-11-16 05:40:41 +01:00
if [[ -o interactive && ( -n $SSH_CONNECTION || $TERM == screen-256color ) ]]; then
2026-11-15 01:19:17 +01:00
autoload -Uz add-zsh-hook
2026-11-17 03:13:23 +01:00
murx_ssh_title() {
2026-11-15 01:19:17 +01:00
local program=${1:t}
printf '\033]2;%s:%s\007' "${HOST%%.*}" "$program"
2026-11-16 00:13:23 +01:00
local directory=$PWD
if [[ $directory == "$HOME" ]]; then
directory='~'
elif [[ $directory == "$HOME/"* ]]; then
directory="~/${directory#"$HOME/"}"
fi
2026-11-17 03:13:23 +01:00
printf '\033]777;murx-cwd;%s\007' "$directory"
printf '\033]777;murx-root;%s\007' "$((EUID == 0))"
2026-11-15 01:19:17 +01:00
}
2026-11-17 03:13:23 +01:00
murx_ssh_preexec() {
2026-11-16 05:40:41 +01:00
local -a words
words=(${(z)1})
2026-11-17 03:13:23 +01:00
murx_ssh_title "${(Q)words[1]}"
2026-11-15 01:19:17 +01:00
}
2026-11-17 03:13:23 +01:00
murx_ssh_precmd() { murx_ssh_title zsh; }
add-zsh-hook preexec murx_ssh_preexec
add-zsh-hook precmd murx_ssh_precmd
2026-11-15 01:19:17 +01:00
fi
2026-11-16 05:40:41 +01:00