From b9bd6c2dc32a9e3847ddc3d67077cbd3f908834b Mon Sep 17 00:00:00 2001 From: hanez Date: Sat, 21 Nov 2026 13:30:17 +0100 Subject: [PATCH] Zsh fix. --- .zshrc | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.zshrc b/.zshrc index 99aee432..a871faab 100644 --- a/.zshrc +++ b/.zshrc @@ -1,6 +1,9 @@ # Source some global/public stuff. source ~/.env +# Disable Oh My Zsh auto-title; custom title handling is defined below. +DISABLE_AUTO_TITLE="true" + # Load Oh-my-Zsh. source ~/.zsh/oh-my-zsh.sh @@ -8,18 +11,23 @@ source ~/.zsh/oh-my-zsh.sh case $TERM in linux*) export TERM=linux - precmd () {print -Pn "\e]0;%n@%m: %~\a"} + _hanez_precmd_title() { print -Pn "\e]0;%n@%m: %~\a" } ;; xterm*) export TERM=xterm-256color - precmd () {print -Pn "\e]0;%n@%m: %~\a"} + _hanez_precmd_title() { print -Pn "\e]0;%n@%m: %~\a" } ;; screen*) export TERM=screen-256color - precmd () {print -Pn "\e]0;%n@%m: %~\a"} + _hanez_precmd_title() { print -Pn "\e]0;%n@%m: %~\a" } ;; esac +if (( ${+functions[_hanez_precmd_title]} )); then + autoload -Uz add-zsh-hook + add-zsh-hook precmd _hanez_precmd_title +fi + # Source some functions for function in ~/.zsh/functions.d/*.sh; do source $function @@ -29,13 +37,16 @@ home up # Update tmux window title to the current running command. if [ -n "$TMUX" ]; then - function preexec() { + autoload -Uz add-zsh-hook + function _hanez_tmux_preexec() { local cmd=${1[(wr)^(*=*|sudo|su|command)]} print -Pn "\e]2;${cmd%% *}\a" } - function precmd() { + function _hanez_tmux_precmd() { print -Pn "\e]2;zsh\a" } + add-zsh-hook preexec _hanez_tmux_preexec + add-zsh-hook precmd _hanez_tmux_precmd fi # Source some private stuff or custom things that are different on my