mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
Make the first and last argument to __fish_complete_suffix optional. Use mimedb to look up descriptions if not supplied.
darcs-hash:20070130152631-ac50b-24f1c947d88ce3ad20f31a17b58adfe02cf002e2.gz
This commit is contained in:
parent
76d9051605
commit
418192b312
@ -1,13 +1,39 @@
|
|||||||
#
|
#
|
||||||
# Find files that complete $argv[1], has the suffix $argv[2], and
|
# Find files that complete $argv[1], has the suffix $argv[2], and
|
||||||
# output them as completions with description $argv[3]
|
# output them as completions with the 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"
|
function __fish_complete_suffix -d "Complete using files"
|
||||||
|
|
||||||
set comp $argv[1]
|
# Variable declarations
|
||||||
set suff $argv[2]
|
|
||||||
set desc $argv[3]
|
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 (mimedb -d $suff)
|
||||||
|
|
||||||
|
case 2
|
||||||
|
set comp $argv[1]
|
||||||
|
set suff $argv[2]
|
||||||
|
set desc (mimedb -d $suff)
|
||||||
|
|
||||||
|
case 2
|
||||||
|
set comp $argv[1]
|
||||||
|
set suff $argv[2]
|
||||||
|
set desc $argv[2]
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Perform the completion
|
||||||
|
|
||||||
set base (echo $comp |sed -e 's/\.[a-zA-Z0-9]*$//')
|
set base (echo $comp |sed -e 's/\.[a-zA-Z0-9]*$//')
|
||||||
eval "set files $base*$suff"
|
eval "set files $base*$suff"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user