From 0f082b90a19179801afd8230074d513166a10fd6 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Tue, 29 Oct 2019 00:13:40 +0200 Subject: [PATCH] [zsh] improve viscd --- zsh/functions.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zsh/functions.zsh b/zsh/functions.zsh index b858c13..3c2df69 100644 --- a/zsh/functions.zsh +++ b/zsh/functions.zsh @@ -8,9 +8,9 @@ mkcd() { mkdir -p "$@" && cd "${@[-1]}"; } viscd() { local temp_file chosen_dir - temp_file="$(mktemp)" + temp_file="$(mktemp -t ranger_cd.XXXXXXXXXX)" ranger --choosedir="$temp_file" -- "${@:-$PWD}" - if chosen_dir="$(<"$temp_file")" && [[ -n "$chosen_dir" ]]; then + if chosen_dir="$(<"$temp_file")" && [[ -n "$chosen_dir" && "$chosen_dir" != "$PWD" ]]; then cd -- "$chosen_dir" fi rm -f -- "$temp_file"