home/.zsh/functions.d/moerx.sh

25 lines
807 B
Bash
Raw Normal View History

2026-11-15 01:19:17 +01:00
if [[ -n $SSH_CONNECTION ]]; then
autoload -Uz add-zsh-hook
moerx_ssh_title() {
2026-11-16 00:20:05 +01:00
emulate -L zsh
setopt typesetsilent
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
printf '\033]777;moerx-cwd;%s\007' "$directory"
2026-11-15 01:19:17 +01:00
}
moerx_ssh_preexec() {
2026-11-16 00:20:05 +01:00
emulate -L zsh
setopt typesetsilent
local -a command_words=(${(z)1})
moerx_ssh_title "${(Q)command_words[1]}"
2026-11-15 01:19:17 +01:00
}
moerx_ssh_precmd() { moerx_ssh_title zsh; }
add-zsh-hook preexec moerx_ssh_preexec
add-zsh-hook precmd moerx_ssh_precmd
fi