mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Update vi/vim completions. Add __fish_complete_text function that completes using any text file, and __fish_filter_mime that filters a file list based on mimetype. This update was written by Velko Hristov with some suggestions and updates by me.
darcs-hash:20070204151809-ac50b-b7f3b44ac528f9e994bf0f842ee2e008866fb620.gz
This commit is contained in:
parent
766482d90e
commit
25082b6528
4 changed files with 145 additions and 74 deletions
3
share/completions/vi.fish
Normal file
3
share/completions/vi.fish
Normal file
|
@ -0,0 +1,3 @@
|
|||
# completion for vi
|
||||
|
||||
__fish_complete_vi vi
|
|
@ -1,75 +1,3 @@
|
|||
#completion for vim
|
||||
# completion for vim
|
||||
|
||||
|
||||
|
||||
# todo
|
||||
# +[num] : Position the cursor on line number
|
||||
# +/{pat} : Position the cursor on the first occurence of {pat}
|
||||
# +{command} : Execute Ex command after the first file has been read
|
||||
|
||||
complete -c vim -n '__fish_test_arg "-"' -a - --description 'The file to edit is read from stdin. Commands are read from stderr, which should be a tty'
|
||||
|
||||
complete -r -c vim -s c --description 'Execute Ex command after the first file has been read'
|
||||
complete -r -c vim -s S --description 'Source file after the first file has been read'
|
||||
complete -r -c vim -l cmd --description 'Execute Ex command before loading any vimrc'
|
||||
complete -r -c vim -s d --description 'Use device as terminal (Amiga only)'
|
||||
complete -r -c vim -s i --description 'Set the viminfo file location'
|
||||
complete -r -c vim -s o --description 'Open stacked windows for each file'
|
||||
complete -r -c vim -s O --description 'Open side by side windows for each file'
|
||||
complete -r -c vim -s p --description 'Open tab pages for each file'
|
||||
complete -r -c vim -s q --description 'Start in quickFix mode'
|
||||
complete -r -c vim -s r --description 'Use swap files for recovery'
|
||||
complete -r -c vim -s s --description 'Source and execute script file'
|
||||
complete -r -c vim -s t --description 'Set the cursor to tag'
|
||||
complete -r -c vim -s T --description 'Termninal name'
|
||||
complete -r -c vim -s u --description 'Use alternative vimrc'
|
||||
complete -r -c vim -s U --description 'Use alternative vimrc in GUI mode'
|
||||
complete -r -c vim -s w --description 'Record all typed characters'
|
||||
complete -r -c vim -s W --description 'Record all typed characters (overwrite file)'
|
||||
|
||||
complete -c vim -s A --description 'Start in Arabic mode'
|
||||
complete -c vim -s b --description 'Start in binary mode'
|
||||
complete -c vim -s C --description 'Behave mostly like vi'
|
||||
complete -c vim -s d --description 'Start in diff mode'
|
||||
complete -c vim -s D --description 'Debugging mode'
|
||||
complete -c vim -s e --description 'Start in Ex mode'
|
||||
complete -c vim -s E --description 'Start in improved Ex mode'
|
||||
complete -c vim -s f --description 'Start in foreground mode'
|
||||
complete -c vim -s F --description 'Start in Farsi mode'
|
||||
complete -c vim -s g --description 'Start in GUI mode'
|
||||
complete -c vim -s h --description 'Print help message and exit'
|
||||
complete -c vim -s H --description 'Start in Hebrew mode'
|
||||
complete -c vim -s L --description 'List swap files'
|
||||
complete -c vim -s l --description 'Start in lisp mode'
|
||||
complete -c vim -s m --description 'Disable file modification'
|
||||
complete -c vim -s M --description 'Disallow file modification'
|
||||
complete -c vim -s N --description 'Reset compatibility mode'
|
||||
complete -c vim -s n --description 'Don\'t use swap files'
|
||||
complete -c vim -s R --description 'Read only mode'
|
||||
complete -c vim -s r --description 'List swap files'
|
||||
complete -c vim -s s --description 'Start in silent mode'
|
||||
complete -c vim -s V --description 'Start in verbose mode'
|
||||
complete -c vim -s v --description 'Start in vi mode'
|
||||
complete -c vim -s x --description 'Use encription when writing files'
|
||||
complete -c vim -s X --description 'Don\'t connect to X server'
|
||||
complete -c vim -s y --description 'Start in easy mode'
|
||||
complete -c vim -s Z --description 'Start in restricted mode'
|
||||
|
||||
complete -c vim -o nb --description 'Become an editor server for NetBeans'
|
||||
|
||||
complete -c vim -l no-fork --description 'Start in foreground mode'
|
||||
complete -c vim -l echo-wid --description 'Echo the Window ID on stdout (GTK GUI only)'
|
||||
complete -c vim -l help --description 'Print help message and exit'
|
||||
complete -c vim -l literal --description 'Do not expand wildcards'
|
||||
complete -c vim -l noplugin --description 'Skip loading plugins'
|
||||
complete -c vim -l remote --description 'Edit files on Vim server'
|
||||
complete -c vim -l remote-expr --description 'Evaluate expr on Vim server'
|
||||
complete -c vim -l remote-send --description 'Send keys to Vim server'
|
||||
complete -c vim -l remote-silent --description 'Edit files on Vim server'
|
||||
complete -c vim -l remote-wait --description 'Edit files on Vim server'
|
||||
complete -c vim -l remote-wait-silent --description 'Edit files on Vim server'
|
||||
complete -c vim -l serverlist --description 'List all Vim servers that can be found'
|
||||
complete -c vim -l servername --description 'Set server name'
|
||||
complete -c vim -l version --description 'Print version information and exit'
|
||||
|
||||
complete -r -c vim -l socketid --description 'Run gvim in another window (GTK GUI only)'
|
||||
__fish_complete_vi vim
|
||||
|
|
117
share/functions/__fish_complete_vi.fish
Normal file
117
share/functions/__fish_complete_vi.fish
Normal file
|
@ -0,0 +1,117 @@
|
|||
#completion for vi/vim
|
||||
|
||||
function __fish_complete_vi -d "Compleletions for vi and its aliases"
|
||||
|
||||
set -l is_vim
|
||||
command vi --version >/dev/null ^/dev/null; and set is_vim vim
|
||||
|
||||
set -l cmds -c $argv
|
||||
|
||||
complete $cmds -x -a "(__fish_complete_text)"
|
||||
|
||||
# vim
|
||||
if test -n "$is_vim"
|
||||
|
||||
|
||||
# these don't work
|
||||
#complete $cmds -a - --description 'The file to edit is read from stdin. Commands are read from stderr, which should be a tty'
|
||||
|
||||
# todo
|
||||
# +[num] : Position the cursor on line number
|
||||
# +/{pat} : Position the cursor on the first occurence of {pat}
|
||||
# +{command} : Execute Ex command after the first file has been read
|
||||
|
||||
# Complete gzip-compressed files
|
||||
complete $cmds -x -a "(__fish_complete_suffix .gz)"
|
||||
|
||||
complete $cmds -s c -r --description 'Execute Ex command after the first file has been read'
|
||||
complete $cmds -s S -r --description 'Source file after the first file has been read'
|
||||
complete $cmds -l cmd -r --description 'Execute Ex command before loading any vimrc'
|
||||
complete $cmds -s d -r --description 'Use device as terminal (Amiga only)'
|
||||
complete $cmds -s i -r --description 'Set the viminfo file location'
|
||||
complete $cmds -s o -r --description 'Open stacked windows for each file'
|
||||
complete $cmds -s O -r --description 'Open side by side windows for each file'
|
||||
complete $cmds -s p -r --description 'Open tab pages for each file'
|
||||
complete $cmds -s q -r --description 'Start in quickFix mode'
|
||||
complete $cmds -s r -r --description 'Use swap files for recovery'
|
||||
complete $cmds -s s -r --description 'Source and execute script file'
|
||||
complete $cmds -s t -r --description 'Set the cursor to tag'
|
||||
complete $cmds -s T -r --description 'Termninal name'
|
||||
complete $cmds -s u -r --description 'Use alternative vimrc'
|
||||
complete $cmds -s U -r --description 'Use alternative vimrc in GUI mode'
|
||||
complete $cmds -s w -r --description 'Record all typed characters'
|
||||
complete $cmds -s W -r --description 'Record all typed characters (overwrite file)'
|
||||
|
||||
complete $cmds -s A --description 'Start in Arabic mode'
|
||||
complete $cmds -s b --description 'Start in binary mode'
|
||||
complete $cmds -s C --description 'Behave mostly like vi'
|
||||
complete $cmds -s d --description 'Start in diff mode'
|
||||
complete $cmds -s D --description 'Debugging mode'
|
||||
complete $cmds -s e --description 'Start in Ex mode'
|
||||
complete $cmds -s E --description 'Start in improved Ex mode'
|
||||
complete $cmds -s f --description 'Start in foreground mode'
|
||||
complete $cmds -s F --description 'Start in Farsi mode'
|
||||
complete $cmds -s g --description 'Start in GUI mode'
|
||||
complete $cmds -s h --description 'Print help message and exit'
|
||||
complete $cmds -s H --description 'Start in Hebrew mode'
|
||||
complete $cmds -s L --description 'List swap files'
|
||||
complete $cmds -s l --description 'Start in lisp mode'
|
||||
complete $cmds -s m --description 'Disable file modification'
|
||||
complete $cmds -s M --description 'Disallow file modification'
|
||||
complete $cmds -s N --description 'Reset compatibility mode'
|
||||
complete $cmds -s n --description 'Don\'t use swap files'
|
||||
complete $cmds -s R --description 'Read only mode'
|
||||
complete $cmds -s r --description 'List swap files'
|
||||
complete $cmds -s s --description 'Start in silent mode'
|
||||
complete $cmds -s V --description 'Start in verbose mode'
|
||||
complete $cmds -s v --description 'Start in vi mode'
|
||||
complete $cmds -s x --description 'Use encription when writing files'
|
||||
complete $cmds -s X --description 'Don\'t connect to X server'
|
||||
complete $cmds -s y --description 'Start in easy mode'
|
||||
complete $cmds -s Z --description 'Start in restricted mode'
|
||||
|
||||
complete $cmds -o nb --description 'Become an editor server for NetBeans'
|
||||
|
||||
complete $cmds -l no-fork --description 'Start in foreground mode'
|
||||
complete $cmds -l echo-wid --description 'Echo the Window ID on stdout (GTK GUI only)'
|
||||
complete $cmds -l help --description 'Print help message and exit'
|
||||
complete $cmds -l literal --description 'Do not expand wildcards'
|
||||
complete $cmds -l noplugin --description 'Skip loading plugins'
|
||||
complete $cmds -l remote --description 'Edit files on Vim server'
|
||||
complete $cmds -l remote-expr --description 'Evaluate expr on Vim server'
|
||||
complete $cmds -l remote-send --description 'Send keys to Vim server'
|
||||
complete $cmds -l remote-silent --description 'Edit files on Vim server'
|
||||
complete $cmds -l remote-wait --description 'Edit files on Vim server'
|
||||
complete $cmds -l remote-wait-silent --description 'Edit files on Vim server'
|
||||
complete $cmds -l serverlist --description 'List all Vim servers that can be found'
|
||||
complete $cmds -l servername --description 'Set server name'
|
||||
complete $cmds -l version --description 'Print version information and exit'
|
||||
|
||||
complete $cmds -l socketid -r --description 'Run gvim in another window (GTK GUI only)'
|
||||
|
||||
# plain vi (as bundled with SunOS 5.8)
|
||||
else
|
||||
|
||||
# todo:
|
||||
# -wn : Set the default window size to n
|
||||
# +command : same as -c command
|
||||
|
||||
complete $cmds -s s --description 'Suppress all interactive user feedback'
|
||||
complete $cmds -s C --description 'Encrypt/decrypt text'
|
||||
complete $cmds -s l --description 'Set up for editing LISP programs'
|
||||
complete $cmds -s L --description 'List saved file names after crash'
|
||||
complete $cmds -s R --description 'Readonly mode'
|
||||
complete $cmds -s S --description 'Use linear search for tags if tag file not sorted'
|
||||
complete $cmds -s v --description 'Start in display editing state'
|
||||
complete $cmds -s V --description 'Verbose mode'
|
||||
complete $cmds -s x --description 'Encrypt/decrypt text'
|
||||
|
||||
complete $cmds -r -s r --description 'Recover file after crash'
|
||||
complete $cmds -r -s t --description 'Edit the file containing a tag'
|
||||
complete $cmds -r -c t --description 'Begin editing by executing the specified editor command'
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
23
share/functions/__fish_filter_mime.fish
Normal file
23
share/functions/__fish_filter_mime.fish
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
#
|
||||
# $argv[1] is a mimetype. The mimetype may contain wildcards. All
|
||||
# following arguments are filenames. Filenames matching the mimetype
|
||||
# are returned.
|
||||
#
|
||||
|
||||
function __fish_filter_mime -d "Select files with a specific mimetype"
|
||||
|
||||
set -l mime_search $argv[1]
|
||||
set -e argv[1]
|
||||
|
||||
set -l mime (mimedb -f $argv)
|
||||
set -l res
|
||||
|
||||
for i in (seq (count $argv))
|
||||
switch $mime[$i]
|
||||
case $mime_search
|
||||
set res $res $argv[$i]
|
||||
end
|
||||
end
|
||||
printf "%s\n" $res
|
||||
end
|
Loading…
Reference in a new issue