summaryrefslogtreecommitdiff
path: root/mac/.config/zsh/scripts.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'mac/.config/zsh/scripts.zsh')
-rw-r--r--mac/.config/zsh/scripts.zsh14
1 files changed, 6 insertions, 8 deletions
diff --git a/mac/.config/zsh/scripts.zsh b/mac/.config/zsh/scripts.zsh
index a90bca5..5443b4c 100644
--- a/mac/.config/zsh/scripts.zsh
+++ b/mac/.config/zsh/scripts.zsh
@@ -870,12 +870,10 @@ function delete_venv() {
###########################################################################################
### --- YAZI --- ###
# open yazi and cd to the file path
-function yazicd () {
- tmp="$(mktemp -uq)"
- trap 'rm -f $tmp >/dev/null 2>&1 && trap - HUP INT QUIT TERM EXIT' HUP INT QUIT TERM EXIT
- yazi --cwd-file="$tmp" "$@"
- if [ -f "$tmp" ]; then
- dir="$(cat "$tmp")"
- [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
- fi
+function yazicd() {
+ local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
+ yazi "$@" --cwd-file="$tmp"
+ IFS= read -r -d '' cwd < "$tmp"
+ [ -n "$cwd" ] && [ "$cwd" != "$PWD" ] && builtin cd -- "$cwd"
+ rm -f -- "$tmp"
}