647537f15bb31f8a50699db239e9a98343d5d280

Author
Jonathan <jonathan.klimt@rwth-aachen.de>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Added a new plugin which adds completion for fd (fd-find)

Based on the existing "cargo" plugin.

Diff

  1diff --git a/plugins/fd/README.md b/plugins/fd/README.md
  2new file mode 100644
  3index 0000000000000000000000000000000000000000..aabd624b8d63d6a1204773045fefc1ff12c8297e
  4--- /dev/null
  5+++ b/plugins/fd/README.md
  6@@ -0,0 +1,13 @@
  7+# fd
  8+
  9+This plugin adds completion for the file search tool [`fd`](https://github.com/sharkdp/fd), also known as `fd-find`.
 10+
 11+To use it, add `fd` to the plugins array in your zshrc file:
 12+
 13+```zsh
 14+plugins=(... fd)
 15+```
 16+
 17+Completion is taken from the fd release [`7.3.0`](https://github.com/sharkdp/fd/releases/tag/v7.3.0).
 18+
 19+Updated on Febrary 13th, 2019.
 20diff --git a/plugins/fd/_fd b/plugins/fd/_fd
 21new file mode 100644
 22index 0000000000000000000000000000000000000000..7d65c7856978695a27e33bf2cad350e08d6180bb
 23--- /dev/null
 24+++ b/plugins/fd/_fd
 25@@ -0,0 +1,83 @@
 26+#compdef fd
 27+
 28+autoload -U is-at-least
 29+
 30+_fd() {
 31+    typeset -A opt_args
 32+    typeset -a _arguments_options
 33+    local ret=1
 34+
 35+    if is-at-least 5.2; then
 36+        _arguments_options=(-s -S -C)
 37+    else
 38+        _arguments_options=(-s -C)
 39+    fi
 40+
 41+    local context curcontext="$curcontext" state line
 42+    _arguments "${_arguments_options[@]}" \
 43+'-d+[Set maximum search depth (default: none)]' \
 44+'--max-depth=[Set maximum search depth (default: none)]' \
 45+'--maxdepth=[See --max-depth]' \
 46+'*-t+[Filter by type: file (f), directory (d), symlink (l),
 47+executable (x), empty (e)]: :(f file d directory l symlink x executable e empty)' \
 48+'*--type=[Filter by type: file (f), directory (d), symlink (l),
 49+executable (x), empty (e)]: :(f file d directory l symlink x executable e empty)' \
 50+'*-e+[Filter by file extension]' \
 51+'*--extension=[Filter by file extension]' \
 52+'-x+[Execute a command for each search result]' \
 53+'--exec=[Execute a command for each search result]' \
 54+'(-x --exec)-X+[Execute a command with all search results at once]' \
 55+'(-x --exec)--exec-batch=[Execute a command with all search results at once]' \
 56+'*-E+[Exclude entries that match the given glob pattern]' \
 57+'*--exclude=[Exclude entries that match the given glob pattern]' \
 58+'*--ignore-file=[Add a custom ignore-file in .gitignore format]' \
 59+'-c+[When to use colors: never, *auto*, always]: :(never auto always)' \
 60+'--color=[When to use colors: never, *auto*, always]: :(never auto always)' \
 61+'-j+[Set number of threads to use for searching & executing]' \
 62+'--threads=[Set number of threads to use for searching & executing]' \
 63+'*-S+[Limit results based on the size of files.]' \
 64+'*--size=[Limit results based on the size of files.]' \
 65+'--max-buffer-time=[the time (in ms) to buffer, before streaming to the console]' \
 66+'--changed-within=[Filter by file modification time (newer than)]' \
 67+'--changed-before=[Filter by file modification time (older than)]' \
 68+'*--search-path=[(hidden)]' \
 69+'-H[Search hidden files and directories]' \
 70+'--hidden[Search hidden files and directories]' \
 71+'-I[Do not respect .(git|fd)ignore files]' \
 72+'--no-ignore[Do not respect .(git|fd)ignore files]' \
 73+'--no-ignore-vcs[Do not respect .gitignore files]' \
 74+'*-u[Alias for no-ignore and/or hidden]' \
 75+'-s[Case-sensitive search (default: smart case)]' \
 76+'--case-sensitive[Case-sensitive search (default: smart case)]' \
 77+'-i[Case-insensitive search (default: smart case)]' \
 78+'--ignore-case[Case-insensitive search (default: smart case)]' \
 79+'-F[Treat the pattern as a literal string]' \
 80+'--fixed-strings[Treat the pattern as a literal string]' \
 81+'-a[Show absolute instead of relative paths]' \
 82+'--absolute-path[Show absolute instead of relative paths]' \
 83+'-L[Follow symbolic links]' \
 84+'--follow[Follow symbolic links]' \
 85+'-p[Search full path (default: file-/dirname only)]' \
 86+'--full-path[Search full path (default: file-/dirname only)]' \
 87+'-0[Separate results by the null character]' \
 88+'--print0[Separate results by the null character]' \
 89+'--show-errors[Enable display of filesystem errors]' \
 90+'-h[Prints help information]' \
 91+'--help[Prints help information]' \
 92+'-V[Prints version information]' \
 93+'--version[Prints version information]' \
 94+'::pattern -- the search pattern, a regular expression (optional):_files' \
 95+'::path -- the root directory for the filesystem search (optional):_files' \
 96+&& ret=0
 97+
 98+}
 99+
100+(( $+functions[_fd_commands] )) ||
101+_fd_commands() {
102+    local commands; commands=(
103+
104+    )
105+    _describe -t commands 'fd commands' commands "$@"
106+}
107+
108+_fd "$@"