Based on the existing "cargo" plugin.master
parent
f6a9a0a498
commit
647537f15b
2 changed files with 96 additions and 0 deletions
@ -0,0 +1,13 @@ |
|||||||
|
# fd |
||||||
|
|
||||||
|
This plugin adds completion for the file search tool [`fd`](https://github.com/sharkdp/fd), also known as `fd-find`. |
||||||
|
|
||||||
|
To use it, add `fd` to the plugins array in your zshrc file: |
||||||
|
|
||||||
|
```zsh |
||||||
|
plugins=(... fd) |
||||||
|
``` |
||||||
|
|
||||||
|
Completion is taken from the fd release [`7.3.0`](https://github.com/sharkdp/fd/releases/tag/v7.3.0). |
||||||
|
|
||||||
|
Updated on Febrary 13th, 2019. |
||||||
@ -0,0 +1,83 @@ |
|||||||
|
#compdef fd |
||||||
|
|
||||||
|
autoload -U is-at-least |
||||||
|
|
||||||
|
_fd() { |
||||||
|
typeset -A opt_args |
||||||
|
typeset -a _arguments_options |
||||||
|
local ret=1 |
||||||
|
|
||||||
|
if is-at-least 5.2; then |
||||||
|
_arguments_options=(-s -S -C) |
||||||
|
else |
||||||
|
_arguments_options=(-s -C) |
||||||
|
fi |
||||||
|
|
||||||
|
local context curcontext="$curcontext" state line |
||||||
|
_arguments "${_arguments_options[@]}" \ |
||||||
|
'-d+[Set maximum search depth (default: none)]' \ |
||||||
|
'--max-depth=[Set maximum search depth (default: none)]' \ |
||||||
|
'--maxdepth=[See --max-depth]' \ |
||||||
|
'*-t+[Filter by type: file (f), directory (d), symlink (l), |
||||||
|
executable (x), empty (e)]: :(f file d directory l symlink x executable e empty)' \ |
||||||
|
'*--type=[Filter by type: file (f), directory (d), symlink (l), |
||||||
|
executable (x), empty (e)]: :(f file d directory l symlink x executable e empty)' \ |
||||||
|
'*-e+[Filter by file extension]' \ |
||||||
|
'*--extension=[Filter by file extension]' \ |
||||||
|
'-x+[Execute a command for each search result]' \ |
||||||
|
'--exec=[Execute a command for each search result]' \ |
||||||
|
'(-x --exec)-X+[Execute a command with all search results at once]' \ |
||||||
|
'(-x --exec)--exec-batch=[Execute a command with all search results at once]' \ |
||||||
|
'*-E+[Exclude entries that match the given glob pattern]' \ |
||||||
|
'*--exclude=[Exclude entries that match the given glob pattern]' \ |
||||||
|
'*--ignore-file=[Add a custom ignore-file in .gitignore format]' \ |
||||||
|
'-c+[When to use colors: never, *auto*, always]: :(never auto always)' \ |
||||||
|
'--color=[When to use colors: never, *auto*, always]: :(never auto always)' \ |
||||||
|
'-j+[Set number of threads to use for searching & executing]' \ |
||||||
|
'--threads=[Set number of threads to use for searching & executing]' \ |
||||||
|
'*-S+[Limit results based on the size of files.]' \ |
||||||
|
'*--size=[Limit results based on the size of files.]' \ |
||||||
|
'--max-buffer-time=[the time (in ms) to buffer, before streaming to the console]' \ |
||||||
|
'--changed-within=[Filter by file modification time (newer than)]' \ |
||||||
|
'--changed-before=[Filter by file modification time (older than)]' \ |
||||||
|
'*--search-path=[(hidden)]' \ |
||||||
|
'-H[Search hidden files and directories]' \ |
||||||
|
'--hidden[Search hidden files and directories]' \ |
||||||
|
'-I[Do not respect .(git|fd)ignore files]' \ |
||||||
|
'--no-ignore[Do not respect .(git|fd)ignore files]' \ |
||||||
|
'--no-ignore-vcs[Do not respect .gitignore files]' \ |
||||||
|
'*-u[Alias for no-ignore and/or hidden]' \ |
||||||
|
'-s[Case-sensitive search (default: smart case)]' \ |
||||||
|
'--case-sensitive[Case-sensitive search (default: smart case)]' \ |
||||||
|
'-i[Case-insensitive search (default: smart case)]' \ |
||||||
|
'--ignore-case[Case-insensitive search (default: smart case)]' \ |
||||||
|
'-F[Treat the pattern as a literal string]' \ |
||||||
|
'--fixed-strings[Treat the pattern as a literal string]' \ |
||||||
|
'-a[Show absolute instead of relative paths]' \ |
||||||
|
'--absolute-path[Show absolute instead of relative paths]' \ |
||||||
|
'-L[Follow symbolic links]' \ |
||||||
|
'--follow[Follow symbolic links]' \ |
||||||
|
'-p[Search full path (default: file-/dirname only)]' \ |
||||||
|
'--full-path[Search full path (default: file-/dirname only)]' \ |
||||||
|
'-0[Separate results by the null character]' \ |
||||||
|
'--print0[Separate results by the null character]' \ |
||||||
|
'--show-errors[Enable display of filesystem errors]' \ |
||||||
|
'-h[Prints help information]' \ |
||||||
|
'--help[Prints help information]' \ |
||||||
|
'-V[Prints version information]' \ |
||||||
|
'--version[Prints version information]' \ |
||||||
|
'::pattern -- the search pattern, a regular expression (optional):_files' \ |
||||||
|
'::path -- the root directory for the filesystem search (optional):_files' \ |
||||||
|
&& ret=0 |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
(( $+functions[_fd_commands] )) || |
||||||
|
_fd_commands() { |
||||||
|
local commands; commands=( |
||||||
|
|
||||||
|
) |
||||||
|
_describe -t commands 'fd commands' commands "$@" |
||||||
|
} |
||||||
|
|
||||||
|
_fd "$@" |
||||||
Loading…
Reference in new issue