Skip to content

Commit ca06988

Browse files
committed
refactor(cd): generate cdable_vars in the completion function
1 parent ed0ae10 commit ca06988

File tree

1 file changed

+9
-5
lines changed
  • completions

1 file changed

+9
-5
lines changed

completions/cd

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# cd(1) completion -*- shell-script -*-
22

3+
_comp_cmd_cd__compgen_cdable_vars()
4+
{
5+
shopt -q cdable_vars || return 1
6+
7+
_comp_compgen -- -v
8+
}
9+
310
# This generator function observes the CDPATH variable, to additionally
411
# complete directories under those specified in CDPATH.
512
_comp_cmd_cd__compgen_cdpath()
@@ -53,11 +60,8 @@ _comp_cmd_cd()
5360
fi
5461

5562
compopt -o filenames
63+
_comp_cmd_cd__compgen_cdable_vars
5664
_comp_cmd_cd__compgen_cdpath
5765
_comp_compgen -a filedir -d
5866
}
59-
if shopt -q cdable_vars; then
60-
complete -v -F _comp_cmd_cd -o nospace cd pushd
61-
else
62-
complete -F _comp_cmd_cd -o nospace cd pushd
63-
fi
67+
complete -F _comp_cmd_cd -o nospace cd pushd

0 commit comments

Comments
 (0)