From 381d115998625f7d41b204705456f8eba0d11a1f Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Thu, 22 Feb 2024 23:21:56 +0530 Subject: [PATCH] Detect infinite loop on Fish --- templates/fish.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/templates/fish.txt b/templates/fish.txt index 1db92b0..9a51f6d 100644 --- a/templates/fish.txt +++ b/templates/fish.txt @@ -28,10 +28,16 @@ end # cd + custom logic based on the value of _ZO_ECHO. function __zoxide_cd + if set -q __zoxide_loop + builtin echo "zoxide: infinite loop detected" + builtin echo "Avoid aliasing `cd` to `z` directly, use `zoxide init --cmd=cd fish` instead" + return 1 + end + {%- if cfg!(windows) %} - __zoxide_cd_internal (cygpath -u $argv) + __zoxide_loop=1 __zoxide_cd_internal (cygpath -u $argv) {%- else %} - __zoxide_cd_internal $argv + __zoxide_loop=1 __zoxide_cd_internal $argv {%- endif %} {%- if echo %} and __zoxide_pwd