mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Add missing file for vi completions that is needed to complete files selectively based on mime types. Also use it to improve emacs completions, in order to balance my GNU karma.
darcs-hash:20070222214555-ac50b-60aa6a3e4cea77451c51d40d2a574d145f3de4fe.gz
This commit is contained in:
parent
58755fc579
commit
e50f43416b
3 changed files with 35 additions and 1 deletions
|
@ -1,6 +1,10 @@
|
|||
#
|
||||
# These completions are uncomplete
|
||||
#
|
||||
|
||||
# Primarily complete text files
|
||||
complete -c emacs -x -a "(__fish_complete_mime 'text/*')"
|
||||
|
||||
complete -c emacs -s q --description "Do not load init files"
|
||||
complete -c emacs -s u --description "Load users init file" -xa "(__fish_complete_users)"
|
||||
complete -c emacs -s t --description "Use file as terminal" -r
|
||||
|
|
30
share/functions/__fish_complete_mime.fish
Normal file
30
share/functions/__fish_complete_mime.fish
Normal file
|
@ -0,0 +1,30 @@
|
|||
|
||||
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
|
||||
|
|
@ -7,7 +7,7 @@ function __fish_complete_vi -d "Compleletions for vi and its aliases"
|
|||
|
||||
set -l cmds -c $argv
|
||||
|
||||
complete $cmds -x -a "(__fish_complete_text)"
|
||||
complete $cmds -x -a "(__fish_complete_mime 'text/*')"
|
||||
|
||||
# vim
|
||||
if test -n "$is_vim"
|
||||
|
|
Loading…
Reference in a new issue