fish-shell/share/functions/__fish_complete_directories.fish
Kurtis Rader da09a915f2 improve __fish_complete_directories function
Reviewing a PR for a completion script caused me to look at the
implementation for the `__fish_complete_directories` function. Which in
turn lead me to create this change to improve its implementation and add
unit tests for the function.
2017-04-11 13:45:53 -07:00

15 lines
390 B
Fish

#
# Find directories that complete $argv[1], output them as completions
# with description $argv[2] if defined, otherwise use 'Directory'
#
function __fish_complete_directories -d "Complete directory prefixes" --argument comp desc
if not set -q desc[1]
set desc (_ Directory)
end
set -l dirs $comp*/
if set -q dirs[1]
printf "%s\t$desc\n" $dirs
end
end