mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 21:33:09 +00:00
e50f43416b
darcs-hash:20070222214555-ac50b-60aa6a3e4cea77451c51d40d2a574d145f3de4fe.gz
30 lines
701 B
Fish
30 lines
701 B
Fish
|
|
function __fish_complete_mime -d "Complete using text files"
|
|
# Find all possible file completions
|
|
set -l all
|
|
set -l comp (commandline -ct)
|
|
set -l base (echo $comp | sed -e 's/\.[a-zA-Z0-9]*$//')
|
|
set -l mimetype $argv[1]
|
|
eval "set all $base*"
|
|
|
|
# Select text files only
|
|
set -l files (__fish_filter_mime $mimetype $all)
|
|
|
|
# Get descriptions for files
|
|
set desc (mimedb -d $files)
|
|
|
|
# Format completions and descriptions
|
|
set -l res
|
|
for i in (seq (count $files))
|
|
set res $res $files[$i]\t$desc[$i]
|
|
end
|
|
|
|
if test $res[1]
|
|
printf "%s\n" $res
|
|
end
|
|
|
|
# Also do directory completion, since there might be files
|
|
# with the correct suffix in a subdirectory
|
|
__fish_complete_directories $comp
|
|
end
|
|
|