mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 21:33:09 +00:00
11a60c8374
I hate doing this but I am tired of touching a fish script as part of some change and having `make style` radically change it. Which makes editing fish scripts more painful than it needs to be. It is time to do a wholesale reformatting of these scripts to conform to the documented style as implemented by the `fish_indent` program.
53 lines
1.1 KiB
Fish
53 lines
1.1 KiB
Fish
#
|
|
# Find files that complete $argv[1], has the suffix $argv[2], and
|
|
# output them as completions with the optional description $argv[3] Both
|
|
# $argv[1] and $argv[3] are optional, if only one is specified, it is
|
|
# assumed to be the argument to complete.
|
|
#
|
|
|
|
function __fish_complete_suffix -d "Complete using files"
|
|
|
|
# Variable declarations
|
|
|
|
set -l comp
|
|
set -l suff
|
|
set -l desc
|
|
set -l files
|
|
|
|
switch (count $argv)
|
|
|
|
case 1
|
|
set comp (commandline -ct)
|
|
set suff $argv
|
|
set desc ""
|
|
|
|
case 2
|
|
set comp $argv[1]
|
|
set suff $argv[2]
|
|
set desc ""
|
|
|
|
case 3
|
|
set comp $argv[1]
|
|
set suff $argv[2]
|
|
set desc $argv[3]
|
|
|
|
end
|
|
|
|
# Perform the completion
|
|
|
|
set base (echo $comp |sed -e 's/\.[a-zA-Z0-9]*$//')
|
|
eval "set files $base*$suff"
|
|
|
|
if test $files[1]
|
|
printf "%s\t$desc\n" $files
|
|
end
|
|
|
|
#
|
|
# Also do directory completion, since there might be files
|
|
# with the correct suffix in a subdirectory
|
|
# No need to describe directories (#279)
|
|
#
|
|
|
|
__fish_complete_directories $comp ""
|
|
|
|
end
|