File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ function __enhancd_install --on-event enhancd_install
2222
2323 set -Ux ENHANCD_COMPLETION_KEYBIND " ^I"
2424
25- set -Ux _ENHANCD_VERSION " 2.3.0 "
25+ set -Ux _ENHANCD_VERSION " 2.3.1 "
2626
2727 # Set the filters if empty
2828 set -Ux ENHANCD_FILTER " fzy:fzf:peco:percol:sk:zf:gof:selecta"
Original file line number Diff line number Diff line change 11function _enhancd_filepath_walk
2- if not set -q argv[1]
3- set argv[1] $PWD
4- end
2+ set -a dirs ($PWD _enhancd_filepath_get_parent_dirs)
53
6- command find " $argv [1]" -maxdepth 1 -type d \
7- | _enhancd_command_grep -v " \/\."
4+ for dir in $dirs
5+ command find " $dir " -maxdepth 1 -type d -name ' \ .*' -prune -o -type d -print
6+ end
87end
Original file line number Diff line number Diff line change 1+ function _enhancd_history_exists
2+ if not set -q argv[1]
3+ return 1
4+ else
5+ set dir $argv [1]
6+ end
7+
8+ _enhancd_history_open | _enhancd_command_grep " $dir " ^ /dev/null > /dev/null
9+ end
Original file line number Diff line number Diff line change 11function _enhancd_history_update
22 function sub
3- _enhancd_filepath_get_parent_dirs | _enhancd_filter_reverse
4- _enhancd_filepath_walk
3+ _enhancd_history_exists; or _enhancd_filepath_walk
54 _enhancd_history_open
65 echo " $HOME "
76 end
@@ -10,4 +9,4 @@ function _enhancd_history_update
109 | _enhancd_filter_unique \
1110 | _enhancd_filter_reverse
1211 _enhancd_filepath_current_dir
13- end
12+ end
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ export ENHANCD_COMPLETION_DEFAULT
1717export ENHANCD_COMPLETION_KEYBIND=" ${ENHANCD_COMPLETION_KEYBIND:- ^I} "
1818export ENHANCD_COMPLETION_BEHAVIOR=" ${ENHANCD_COMPLETION_BEHAVIOR:- default} "
1919
20- export _ENHANCD_VERSION=" 2.3.0 "
20+ export _ENHANCD_VERSION=" 2.3.1 "
2121
2222if [[ -n ${BASH_VERSION} ]]; then
2323 # BASH
Original file line number Diff line number Diff line change @@ -23,36 +23,42 @@ __enhancd::cd()
2323 " ${ENHANCD_HYPHEN_ARG} " )
2424 # If a hyphen is passed as the argument,
2525 # searchs from the last 10 directory items in the log
26- args+=( " $( __enhancd::sources::mru " ${2} " | __enhancd::filter::interactive) " )
26+ args+=( " $( __enhancd::sources::mru | __enhancd::filter::interactive) " )
2727 code=${?}
28+ break
2829 ;;
2930 " -" )
3031 # When $ENHANCD_HYPHEN_ARG is configured,
3132 # this behaves like `cd -`
3233 args+=( " ${OLDPWD} " )
34+ break
3335 ;;
3436 " ${ENHANCD_DOT_ARG} " )
3537 # If a double-dot is passed as the argument,
3638 # it behaves like a zsh-bd plugin
3739 # In short, you can jump back to a specific directory,
3840 # without doing `cd ../../..`
39- args+=( " $( __enhancd::sources::parent_dirs " ${2} " | __enhancd::filter::interactive) " )
41+ args+=( " $( __enhancd::sources::parent_dirs | __enhancd::filter::interactive) " )
4042 code=${?}
43+ break
4144 ;;
4245 " .." )
4346 # When $ENHANCD_DOT_ARG is configured,
4447 # ".." is passed to builtin cd
4548 args+=( " .." )
49+ break
4650 ;;
4751 " ${ENHANCD_HOME_ARG} " )
4852 args+=( " $( __enhancd::sources::home | __enhancd::filter::interactive) " )
4953 code=${?}
54+ break
5055 ;;
5156 --)
5257 opts+=( " ${1} " )
5358 shift
5459 args+=( " $( __enhancd::sources::history " ${1} " | __enhancd::filter::interactive) " )
5560 code=${?}
61+ break
5662 ;;
5763 -* | --* )
5864 if __enhancd::helper::is_default_flag " ${1} " ; then
Original file line number Diff line number Diff line change 11# Currently this is not used
22__enhancd::filepath::split ()
33{
4- __enhancd::command::awk -f " $ENHANCD_ROOT /functions/enhancd/lib/split.awk" -v arg=" ${1:- $PWD } "
4+ __enhancd::command::awk -f " ${ ENHANCD_ROOT} /functions/enhancd/lib/split.awk" -v arg=" ${1:- $PWD } "
55}
66
77__enhancd::filepath::get_parent_dirs ()
88{
9- __enhancd::command::awk -f " $ENHANCD_ROOT /functions/enhancd/lib/step_by_step.awk" -v dir=" ${1:- $PWD } "
9+ __enhancd::command::awk -f " ${ ENHANCD_ROOT} /functions/enhancd/lib/step_by_step.awk" -v dir=" ${1:- $PWD } "
1010}
1111
1212__enhancd::filepath::walk ()
1313{
14- command find " ${1:- $PWD } " -maxdepth 1 -type d -name ' \.*' -prune -o -type d -print
14+ local -a dirs
15+
16+ # __enhancd::filepath::get_parent_dirs does not return $PWD itself
17+ # so add it to array expressly
18+ dirs=( " ${PWD} " $( __enhancd::filepath::get_parent_dirs " ${1:- ${PWD} } " ) )
19+
20+ for dir in " ${dirs[@]} "
21+ do
22+ command find " ${dir} " -maxdepth 1 -type d -name ' \.*' -prune -o -type d -print
23+ done
1524}
1625
1726__enhancd::filepath::current_dir ()
Original file line number Diff line number Diff line change @@ -7,6 +7,16 @@ __enhancd::history::open()
77 return 1
88}
99
10+ __enhancd::history::exists ()
11+ {
12+ local dir=" ${1} "
13+ if [[ -z ${dir} ]]; then
14+ return 1
15+ fi
16+
17+ __enhancd::history::open | __enhancd::command::grep " ${dir} " & > /dev/null
18+ }
19+
1020__enhancd::history::list ()
1121{
1222 __enhancd::history::open \
@@ -20,8 +30,7 @@ __enhancd::history::list()
2030__enhancd::history::update ()
2131{
2232 {
23- __enhancd::filepath::get_parent_dirs | __enhancd::filter::reverse
24- __enhancd::filepath::walk
33+ __enhancd::history::exists " ${PWD} " || __enhancd::filepath::walk
2534 __enhancd::history::open
2635 echo " ${HOME} "
2736 } | __enhancd::filter::reverse | __enhancd::filter::unique | __enhancd::filter::reverse
You can’t perform that action at this time.
0 commit comments