dave1010 / clipea

📎🟢 Like Clippy but for the CLI. A blazing fast AI helper for your command line
MIT License
299 stars 12 forks source link

clipea.zsh: use `builtin` to invoke `which` #18

Closed garyo closed 7 months ago

garyo commented 7 months ago

I've aliased which in my zsh to type -a for my convenience. This breaks the use of it in clipea.zsh. Here's a patch to fix that:

diff --git a/clipea/clipea.zsh b/clipea/clipea.zsh
index c48542b..f883b68 100755
--- a/clipea/clipea.zsh
+++ b/clipea/clipea.zsh
@@ -14,12 +14,12 @@ CLIPEA_SCRIPT_DIR=$(dirname $(readlink -f ${(%):-%x}))

 CLIPEA_PYTHON=

-CLIPEA_PATH=$(which clipea)
+CLIPEA_PATH=$(builtin which clipea)

 # Run clipea from the current dir if possible
 if [[ -f $CLIPEA_SCRIPT_DIR/__main__.py ]]; then
     CLIPEA_PATH=$CLIPEA_SCRIPT_DIR
-    CLIPEA_PYTHON="$(which python3 || which python)"
+    CLIPEA_PYTHON="$(builtin which python3 || builtin which python)"
 fi

 # Execute clipea with an environment variable

Or alternatively you could use whence but still protect it with builtin.

dave1010 commented 7 months ago

Nice catch. Thanks for the diff.

Fixed in d16f0312e885ddb5af2eee9102e6075303cd762f

dave1010 commented 7 months ago

@all-contributors please add @garyo for code

allcontributors[bot] commented 7 months ago

@dave1010

I've put up a pull request to add @garyo! :tada: