summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAjeet D'Souza <98ajeet@gmail.com>2024-02-24 04:00:38 +0530
committerGitHub <noreply@github.com>2024-02-24 04:00:38 +0530
commit012c67de635826af2b671f9d3ec82d9303224b36 (patch)
tree53f56a1c32c85bec8cabf6f389d81d8846c56bd7
parent65941f60a4b1cafda421f08dce9e92c6509665a3 (diff)
Detect infinite loop on Fish (#732)
-rw-r--r--CHANGELOG.md6
-rw-r--r--templates/fish.txt10
2 files changed, 14 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 12340d7..95e7b78 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## Unreleased
+
+### Fixed
+
+- fish: detect infinite loop when using `alias cd=z`.
+
## [0.9.4] - 2024-02-21
### Changed
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