[zsh] improve viscd

This commit is contained in:
Dmytro Meleshko 2019-10-29 00:13:40 +02:00
parent 30c90cdfb6
commit 0f082b90a1
1 changed files with 2 additions and 2 deletions

View File

@ -8,9 +8,9 @@ mkcd() { mkdir -p "$@" && cd "${@[-1]}"; }
viscd() { viscd() {
local temp_file chosen_dir local temp_file chosen_dir
temp_file="$(mktemp)" temp_file="$(mktemp -t ranger_cd.XXXXXXXXXX)"
ranger --choosedir="$temp_file" -- "${@:-$PWD}" 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" cd -- "$chosen_dir"
fi fi
rm -f -- "$temp_file" rm -f -- "$temp_file"