fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
13bc514aa
master
1# localization: skip(private) 2# 3# Find directories that complete $argv[1], output them as completions 4# with description $argv[2] if defined, otherwise use 'Directory'. 5# If no arguments are provided, attempts to complete current commandline token. 6# 7function __fish_complete_directories -d"Complete directory prefixes" --argument-names comp desc 8if not set -q desc[ 1 ] 9set desc Directory 10end 11 12if not set -q comp[ 1 ] 13# No token given, so we use the current commandline token. 14# If we have a --name=val option, we need to remove it, 15# or the complete -C below would keep it, and then whatever complete 16# called us would add it again (assuming it's in the current token) 17set comp( commandline -ct| string replace -r --'^-[^=]*=' '' ) 18end 19 20# HACK: We call into the file completions by using an empty command 21# If we used e.g. `ls`, we'd run the risk of completing its options or another kind of argument. 22# But since we default to file completions, if something doesn't have another completion... 23# (really this should have an actual complete option) 24set -l dirs( complete -C"'' $comp " | string match -r'.*/$' ) 25 26if set -q dirs[ 1 ] 27printf "%s\n" $dirs \t" $desc " 28end 29end