m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-18 08:13:40 -05:00

fix fdr function for relative and non-existent paths

Andy Weidenbaum
2015-12-10 21:12:29 -08:00
parent ce31da53b5
commit 85ec5c4fcf

@@ -67,16 +67,15 @@ fda() {
fdr() {
local declare dirs=()
get_parent_dirs() {
dirs+=("$1")
if [[ ${1} == '/' ]]; then
for _dir in ${dirs[@]}; do
echo $_dir
done
if [[ -d "${1}" ]]; then dirs+=("$1"); else return; fi
if [[ "${1}" == '/' ]]; then
for _dir in "${dirs[@]}"; do echo $_dir; done
else
get_parent_dirs $(dirname $1)
get_parent_dirs $(dirname "$1")
fi
}
DIR=$(get_parent_dirs ${1:-$(pwd)} | fzf-tmux --tac) && cd "$DIR"
local DIR=$(get_parent_dirs $(realpath "${1:-$(pwd)}") | fzf-tmux --tac)
cd "$DIR"
}
```