From efa22f644a835c01213f68a6cede15742bc3a620 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Tue, 30 Jun 2026 12:09:25 +0530 Subject: [PATCH] tcsh: preserve any existing `precmd` alias --- CHANGELOG.md | 1 + templates/tcsh.txt | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4142a7..a6cfa05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Zsh: avoid inserting a trailing space when cancelling interactive Space-Tab completions. - Bash: avoid blanking the prompt when cancelling interactive Space-Tab completions. - Bash/Fish/Zsh: avoid drawing a new line when Space-Tab completion finds no matches. +- Tcsh: preserve any existing `precmd` alias instead of overwriting it. ## [0.9.9] - 2026-01-31 diff --git a/templates/tcsh.txt b/templates/tcsh.txt index fa00390..e892670 100644 --- a/templates/tcsh.txt +++ b/templates/tcsh.txt @@ -23,7 +23,15 @@ alias __zoxide_hook 'set __zoxide_pwd_tmp = "`{{ pwd_cmd }}`"; test "$__zoxide_p {%- endif %} # Initialize hook. -alias precmd ';__zoxide_hook' +set __zoxide_precmd = "`alias precmd`" +if ( "$__zoxide_precmd" !~ *__zoxide_hook* ) then + if ( "$__zoxide_precmd" == "" ) then + alias precmd '__zoxide_hook' + else + alias precmd "$__zoxide_precmd"';__zoxide_hook' + endif +endif +unset __zoxide_precmd {%- endif %}