2006-02-08 09:20:05 +00:00
|
|
|
#
|
|
|
|
# Find directories that complete $argv[1], output them as completions
|
2018-05-12 19:04:49 +00:00
|
|
|
# with description $argv[2] if defined, otherwise use 'Directory'.
|
|
|
|
# If no arguments are provided, attempts to complete current commandline token.
|
2006-02-08 09:20:05 +00:00
|
|
|
#
|
2017-04-11 03:40:25 +00:00
|
|
|
function __fish_complete_directories -d "Complete directory prefixes" --argument comp desc
|
|
|
|
if not set -q desc[1]
|
2017-06-03 03:40:58 +00:00
|
|
|
set desc (_ "Directory")
|
2016-11-28 05:27:22 +00:00
|
|
|
end
|
2006-02-08 09:20:05 +00:00
|
|
|
|
2018-05-12 19:04:49 +00:00
|
|
|
if not set -q comp[1]
|
|
|
|
set comp (commandline -ct)
|
|
|
|
end
|
|
|
|
|
2018-05-20 17:30:07 +00:00
|
|
|
# Inherit support for completing expansions from __fish_complete_suffix
|
|
|
|
# Supports completing expressions like ~/foo or x$bar, etc.
|
|
|
|
set -l dirs (__fish_complete_suffix $comp /)
|
|
|
|
|
2017-04-11 03:40:25 +00:00
|
|
|
if set -q dirs[1]
|
2016-11-28 05:27:22 +00:00
|
|
|
printf "%s\t$desc\n" $dirs
|
|
|
|
end
|
2006-02-08 09:20:05 +00:00
|
|
|
end
|