From cffe29e95512bbae172a20b6c663f626aa25590b Mon Sep 17 00:00:00 2001 From: Wu Zhenyu Date: Sat, 21 Jan 2023 14:31:34 +0800 Subject: [PATCH] :art: Format code Add .editorconfig Update .pre-commit-config.yaml Add install methods and optional dependencies to fix #3 Fix some syntax errors --- .editorconfig | 15 +++++++++++++++ .pre-commit-config.yaml | 7 ++++--- README.md | 38 ++++++++++++++++++++++++++++++++------ functions/helper.zsh | 8 +++++--- sources/-command-.zsh | 24 ++++++++++++------------ sources/adb.zsh | 14 +++++++------- sources/bat.zsh | 12 ++++++------ sources/bindkey.zsh | 6 +++--- sources/cowsay.zsh | 6 +++--- sources/dpkg.zsh | 12 ++++++------ sources/flatpak.zsh | 6 +++--- sources/gdu.zsh | 2 +- sources/gio.zsh | 4 ++-- sources/git-blame.zsh | 6 +++--- sources/git-checkout.zsh | 21 ++++++++++++--------- sources/git-diff.zsh | 12 ++++++------ sources/git-log.zsh | 3 ++- sources/git-push.zsh | 18 +++++++++--------- sources/git-reflog.zsh | 14 ++++++++------ sources/git-show.zsh | 12 ++++++------ sources/groff.zsh | 4 ++-- sources/has.zsh | 6 +++--- sources/help2man.zsh | 6 +++--- sources/ip.zsh | 6 +++--- sources/journalctl.zsh | 18 +++++++++--------- sources/jq.zsh | 2 +- sources/kitty.zsh | 12 ++++++------ sources/libreoffice.zsh | 4 ++-- sources/make.zsh | 18 +++++++++--------- sources/mutt.zsh | 12 ++++++------ sources/pacman.zsh | 18 +++++++++--------- sources/pandoc.zsh | 6 +++--- sources/pass.zsh | 9 +++++++++ sources/pkg-config.zsh | 12 ++++++------ sources/poetry.zsh | 6 +++--- sources/ps.zsh | 4 ++-- sources/pydoc.zsh | 9 +++++++-- sources/pygmentize.zsh | 12 ++++++------ sources/python.zsh | 2 ++ sources/read.zsh | 6 +++--- sources/scp.zsh | 18 +++++++++--------- sources/snap.zsh | 12 ++++++------ sources/sqlite3.zsh | 6 +++--- sources/systemctl-help.zsh | 2 +- sources/tmux.zsh | 30 +++++++++++++++--------------- sources/ydcv.zsh | 6 ------ sources/zinit.zsh | 6 +++--- sources/zipdetails.zsh | 2 ++ 48 files changed, 278 insertions(+), 216 deletions(-) create mode 100644 .editorconfig create mode 100644 sources/pass.zsh create mode 100644 sources/python.zsh delete mode 100644 sources/ydcv.zsh create mode 100644 sources/zipdetails.zsh diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0043429 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[LICENSE] +indent_size = unset + +[Makefile] +indent_style = tab diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c8ec87d..6c0f492 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,7 +31,7 @@ repos: additional_dependencies: - tomli - repo: https://github.com/jorisroovers/gitlint - rev: v0.18.0 + rev: v0.19.0dev hooks: - id: gitlint args: @@ -45,7 +45,7 @@ repos: hooks: - id: check-mailmap - repo: https://github.com/adrienverge/yamllint - rev: v1.28.0 + rev: v1.29.0 hooks: - id: yamllint - repo: https://github.com/executablebooks/mdformat @@ -55,6 +55,7 @@ repos: args: - --number additional_dependencies: + - mdformat-gfm - mdformat-myst - mdformat-toc - mdformat-deflist @@ -62,7 +63,7 @@ repos: - mdformat-black - mdformat-config - repo: https://github.com/DavidAnson/markdownlint-cli2 - rev: v0.5.1 + rev: v0.6.0 hooks: - id: markdownlint-cli2 additional_dependencies: diff --git a/README.md b/README.md index 932de03..0307474 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ [![github/last-commit](https://shields.io/github/last-commit/Freed-Wu/fzf-tab-source)](https://github.com/Freed-Wu/fzf-tab-source/commits) [![github/release-date](https://shields.io/github/release-date/Freed-Wu/fzf-tab-source)](https://github.com/Freed-Wu/fzf-tab-source/releases/latest) -[![github/license](https://shields.io/github/license/Freed-Wu/fzf-tab-source)](https://github.com/Freed-Wu/fzf-tab-source/blob/master/LICENSE) +[![github/license](https://shields.io/github/license/Freed-Wu/fzf-tab-source)](https://github.com/Freed-Wu/fzf-tab-source/blob/main/LICENSE) ![github/languages](https://shields.io/github/languages/count/Freed-Wu/fzf-tab-source) ![github/languages/top](https://shields.io/github/languages/top/Freed-Wu/fzf-tab-source) ![github/directory-file-count](https://shields.io/github/directory-file-count/Freed-Wu/fzf-tab-source) @@ -27,7 +27,23 @@ ![github/v](https://shields.io/github/v/release/Freed-Wu/fzf-tab-source) This zsh plugin is a collection of -. Please read the wiki first. +[fzf-tab](https://github.com/Aloxaf/fzf-tab)'s sources. Please read +[the wiki](https://github.com/Aloxaf/fzf-tab/wiki/Preview) first. + +## Install + +This plugin respects +[zsh plugin standard](https://github.com/zdharma-continuum/Zsh-100-Commits-Club/blob/master/Zsh-Plugin-Standard.adoc), +so if you use any plugin manager and follow the instructions of your plugin +manager, it can be installed correctly. + +If you don't use any plugin manager, just add the following code to `~/.zshrc`: + +```zsh +source /the/directory/of/this/plugin/*.plugin.zsh +``` + +## Customize You can use your customized fzf-tab sources to override the default, such as: @@ -35,8 +51,20 @@ You can use your customized fzf-tab sources to override the default, such as: zstyle ':fzf-tab:sources' config-directory /the/directory/containing/your/source.zsh ``` -**NOTE: You need to install [lesspipe](https://github.com/wofr06/lesspipe) to -preview directory, text, image, etc better.** +## Optional Dependencies + +- [some programs](functions/helper.zsh). +- [lesspipe](https://github.com/wofr06/lesspipe): preview directory, text, + image, etc better. You need to write your `~/.lessfilter` to customize + `lesspipe`. My + [~/.lessfilter](https://github.com/Freed-Wu/my-dotfiles/blob/main/.lessfilter) + can be a reference. +- [gitmoji-cli](https://github.com/carloscuesta/gitmoji-cli): `gitmoji -u` to + download `~/.gitmoji` +- [pinyin-completion](https://github.com/petronny/pinyin-completion): complete + pinyin in your zsh. + +## Preview ![dir](https://user-images.githubusercontent.com/32936898/195973421-24f28667-3754-46f2-9dd4-42523285aec2.png) @@ -44,8 +72,6 @@ preview directory, text, image, etc better.** ![image](https://user-images.githubusercontent.com/32936898/195970442-1ca8db87-fcb2-469e-8578-163ea73a19ff.png) -**NOTE: You need to install [pinyin-completion](https://github.com/petronny/pinyin-completion).** - ![user-expand](https://user-images.githubusercontent.com/32936898/195970438-1282c11b-c2e4-455e-8a6a-76c7446ecf8b.png) ![-parameter-](https://user-images.githubusercontent.com/32936898/195970440-98a83556-e664-42e6-9adb-918b865053f3.png) diff --git a/functions/helper.zsh b/functions/helper.zsh index a77ceb0..3b10804 100644 --- a/functions/helper.zsh +++ b/functions/helper.zsh @@ -1,3 +1,4 @@ +# define some functions to avoid any error that these programs don't exist (($+commands[bat])) || bat() {cat} (($+commands[pygmentize])) || pygmentize() {cat} (($+commands[delta])) || delta() {cat} @@ -5,9 +6,10 @@ (($+commands[finger])) || finger() {(($+commands[pinky])) && pinky $@ || whoami} (($+commands[pandoc])) || pandoc() {cat ${@[-1]}} (($+commands[grc])) || grc() {eval ${@[2,-1]}} - -# dictionary $ZINIT cannot be passed -PLUGINS_DIR=${ZINIT[PLUGINS_DIR]} +(($+commands[jq])) || jq() {echo ';'} mkdir -p ~/.gitmoji touch ~/.gitmoji/gitmojis.json + +# dictionary $ZINIT cannot be passed +PLUGINS_DIR=${ZINIT[PLUGINS_DIR]} diff --git a/sources/-command-.zsh b/sources/-command-.zsh index b6bd12c..1cbe381 100644 --- a/sources/-command-.zsh +++ b/sources/-command-.zsh @@ -1,15 +1,15 @@ # :fzf-tab:complete:(-command-:|command:option-(v|V)-rest) case $group in - 'external command') - less =$word - ;; - 'executable file') - less ${realpath#--*=} - ;; - 'builtin command') - run-help $word | bat --color=always -plman - ;; - parameter) - echo ${(P)word} - ;; +'external command') + less =$word + ;; +'executable file') + less ${realpath#--*=} + ;; +'builtin command') + run-help $word | bat --color=always -plman + ;; +parameter) + echo ${(P)word} + ;; esac diff --git a/sources/adb.zsh b/sources/adb.zsh index 554bf69..4d90a2a 100644 --- a/sources/adb.zsh +++ b/sources/adb.zsh @@ -1,10 +1,10 @@ # :fzf-tab:complete:(\\|*/|)adb-(push|pull|shell):argument-rest case $group in - 'file/folder on device') - # https://github.com/Aloxaf/fzf-tab/issues/325 - adb shell 'type=$(file -L '"$ctxt[hpre]$word"' | cut -d: -f2) && test -z "${type/ASCII text/}" && cat '"$ctxt[hpre]$word"' || ls -l --color '$ctxt[hpre]$word - ;; - 'local file/folder') - less $realpath - ;; +'file/folder on device') + # https://github.com/Aloxaf/fzf-tab/issues/325 + adb shell 'type=$(file -L '"$ctxt[hpre]$word"' | cut -d: -f2) && test -z "${type/ASCII text/}" && cat '"$ctxt[hpre]$word"' || ls -l --color '$ctxt[hpre]$word + ;; +'local file/folder') + less $realpath + ;; esac diff --git a/sources/bat.zsh b/sources/bat.zsh index 7ed3b46..8062d43 100644 --- a/sources/bat.zsh +++ b/sources/bat.zsh @@ -1,9 +1,9 @@ # :fzf-tab:complete:(\\|*/|)bat:argument-rest case $group in - subcommand) - bat cache --help | bat --color=always -plhelp - ;; - *) - [[ -f ${realpath#--*=} ]] && bat ${realpath#--*=} || less ${realpath#--*=} - ;; +subcommand) + bat cache --help | bat --color=always -plhelp + ;; +*) + [[ -f ${realpath#--*=} ]] && bat ${realpath#--*=} || less ${realpath#--*=} + ;; esac diff --git a/sources/bindkey.zsh b/sources/bindkey.zsh index 0a3f1c3..d17894b 100644 --- a/sources/bindkey.zsh +++ b/sources/bindkey.zsh @@ -1,6 +1,6 @@ # :fzf-tab:complete:(\\|)bindkey:option-M-1 case $group in - keymap) - bindkey -M$word | bat --color=always -pltsv - ;; +keymap) + bindkey -M$word | bat --color=always -pltsv + ;; esac diff --git a/sources/cowsay.zsh b/sources/cowsay.zsh index f1cccd5..ce52384 100644 --- a/sources/cowsay.zsh +++ b/sources/cowsay.zsh @@ -1,6 +1,6 @@ # :fzf-tab:complete:(\\|*/|)cowsay: case $group in - 'cow file') - cowsay -f $word hello - ;; +'cow file') + cowsay -f $word hello + ;; esac diff --git a/sources/dpkg.zsh b/sources/dpkg.zsh index 7689ce2..3c2dd21 100644 --- a/sources/dpkg.zsh +++ b/sources/dpkg.zsh @@ -1,9 +1,9 @@ # :fzf-tab:complete:(\\|*/|)dpkg:argument-rest case $group in - file) - dpkg -S $word - ;; - package) - dpkg -L $word - ;; +file) + dpkg -S $word + ;; +package) + dpkg -L $word + ;; esac diff --git a/sources/flatpak.zsh b/sources/flatpak.zsh index 63b94e5..7cf0183 100644 --- a/sources/flatpak.zsh +++ b/sources/flatpak.zsh @@ -1,6 +1,6 @@ # :fzf-tab:complete:(\\|*/|)flatpak: case $group in - argument) - flatpak $word --help | bat --color=always -plhelp - ;; +argument) + flatpak $word --help | bat --color=always -plhelp + ;; esac diff --git a/sources/gdu.zsh b/sources/gdu.zsh index debcdb6..473659b 100644 --- a/sources/gdu.zsh +++ b/sources/gdu.zsh @@ -1,2 +1,2 @@ # :fzf-tab:complete:(\\|*/|)gdu:argument-rest - [ -d $realpath ] && gdu -n $realpath || grc --colour=on du -sh $realpath +[ -d $realpath ] && gdu -n $realpath || grc --colour=on du -sh $realpath diff --git a/sources/gio.zsh b/sources/gio.zsh index ba4ba75..1294109 100644 --- a/sources/gio.zsh +++ b/sources/gio.zsh @@ -1,3 +1,3 @@ # :fzf-tab:complete:(\\|*/|)gio: -[[ -f $realpath ]] && less $realpath \ - || gio help $word 2>&1 | bat --color=always -plhelp +[[ -f $realpath ]] && less $realpath || + gio help $word 2>&1 | bat --color=always -plhelp diff --git a/sources/git-blame.zsh b/sources/git-blame.zsh index 2aa2be8..87aed03 100644 --- a/sources/git-blame.zsh +++ b/sources/git-blame.zsh @@ -1,6 +1,6 @@ # :fzf-tab:complete:git-blame:argument-2 case $group in - 'cached file') - git blame $word | delta - ;; +'cached file') + git blame $word | delta + ;; esac diff --git a/sources/git-checkout.zsh b/sources/git-checkout.zsh index 8793362..0853630 100644 --- a/sources/git-checkout.zsh +++ b/sources/git-checkout.zsh @@ -1,12 +1,15 @@ # :fzf-tab:complete:git-checkout:argument-rest case $group in - 'modified file') - git diff $word | delta - ;; - 'recent commit object name') - git log --color=always $word | perl -pe$(jq -j '.[] as $i | "s=" + $i.code + "=" + $i.emoji + "=g;"' ~/.gitmoji/gitmojis.json) | delta - ;; - *) - git log --color=always $word | perl -pe$(jq -j '.[] as $i | "s=" + $i.code + "=" + $i.emoji + "=g;"' ~/.gitmoji/gitmojis.json) - ;; +'modified file') + git diff $word | delta + ;; +'recent commit object name') + git log --color=always $word | + perl -pe$(jq -j '.[] | "s=\(.code)=\(.emoji)=g;"' ~/.gitmoji/gitmojis.json) | + delta + ;; +*) + git log --color=always $word | + perl -pe$(jq -j '.[] | "s=\(.code)=\(.emoji)=g;"' ~/.gitmoji/gitmojis.json) + ;; esac diff --git a/sources/git-diff.zsh b/sources/git-diff.zsh index c24a553..bb737e6 100644 --- a/sources/git-diff.zsh +++ b/sources/git-diff.zsh @@ -1,9 +1,9 @@ # :fzf-tab:complete:git-(diff|cherry-pick):argument-rest case $group in - 'tree file') - less ${realpath#--*=} - ;; - *) - git diff $word | delta - ;; +'tree file') + less ${realpath#--*=} + ;; +*) + git diff $word | delta + ;; esac diff --git a/sources/git-log.zsh b/sources/git-log.zsh index 58650fe..c671e96 100644 --- a/sources/git-log.zsh +++ b/sources/git-log.zsh @@ -1,2 +1,3 @@ # :fzf-tab:complete:git-log:argument-1 -git log --color=always $word | perl -pe$(jq -j '.[] as $i | "s=" + $i.code + "=" + $i.emoji + "=g;"' ~/.gitmoji/gitmojis.json) +git log --color=always $word | + perl -pe$(jq -j '.[] | "s=\(.code)=\(.emoji)=g;"' ~/.gitmoji/gitmojis.json) diff --git a/sources/git-push.zsh b/sources/git-push.zsh index f7e8d14..b636ca8 100644 --- a/sources/git-push.zsh +++ b/sources/git-push.zsh @@ -1,12 +1,12 @@ # :fzf-tab:complete:git-((push|pull):argument-1|fetch:argument-rest) case $group in - 'local repository') - less ${realpath#--*=} - ;; - remote) - git remote show $word - ;; - *host*) - grc --colour=on ping -c1 $word - ;; +'local repository') + less ${realpath#--*=} + ;; +remote) + git remote show $word + ;; +*host*) + grc --colour=on ping -c1 $word + ;; esac diff --git a/sources/git-reflog.zsh b/sources/git-reflog.zsh index 77831cf..6e8dcd6 100644 --- a/sources/git-reflog.zsh +++ b/sources/git-reflog.zsh @@ -1,9 +1,11 @@ # :fzf-tab:complete:git-reflog(|-*):argument-1 case $group in - command) - git reflog --color=always show | perl -pe$(jq -j '.[] as $i | "s=" + $i.code + "=" + $i.emoji + "=g;"' ~/.gitmoji/gitmojis.json) - ;; - reference) - git reflog --color=always $word | perl -pe$(jq -j '.[] as $i | "s=" + $i.code + "=" + $i.emoji + "=g;"' ~/.gitmoji/gitmojis.json) - ;; +command) + git reflog --color=always show | + perl -pe$(jq -j '.[] | "s=\(.code)=\(.emoji)=g;"' ~/.gitmoji/gitmojis.json) + ;; +reference) + git reflog --color=always $word | + perl -pe$(jq -j '.[] | "s=\(.code)=\(.emoji)=g;"' ~/.gitmoji/gitmojis.json) + ;; esac diff --git a/sources/git-show.zsh b/sources/git-show.zsh index f9ee0d1..8dc3172 100644 --- a/sources/git-show.zsh +++ b/sources/git-show.zsh @@ -1,9 +1,9 @@ # :fzf-tab:complete:git-show:argument-rest case $group in - 'commit tag') - git show --color=always $word - ;; - *) - git show --color=always $word | delta - ;; +'commit tag') + git show --color=always $word + ;; +*) + git show --color=always $word | delta + ;; esac diff --git a/sources/groff.zsh b/sources/groff.zsh index e3fc307..db1559f 100644 --- a/sources/groff.zsh +++ b/sources/groff.zsh @@ -1,3 +1,3 @@ # :fzf-tab:complete:(\\|*/|)groff:argument-1 -[[ -f $realpath ]] && groff $realpath | pygmentize -l postscript \ - || less $realpath +[[ -f $realpath ]] && groff $realpath | pygmentize -l postscript || + less $realpath diff --git a/sources/has.zsh b/sources/has.zsh index 78ba6ea..32a297b 100644 --- a/sources/has.zsh +++ b/sources/has.zsh @@ -1,6 +1,6 @@ # :fzf-tab:complete:(\\|*/|)has:argument-rest case $group in - 'external command') - has $word - ;; +'external command') + has $word + ;; esac diff --git a/sources/help2man.zsh b/sources/help2man.zsh index 959ba6d..43db79f 100644 --- a/sources/help2man.zsh +++ b/sources/help2man.zsh @@ -1,4 +1,4 @@ # :fzf-tab:complete:(\\|*/|)help2man: -[[ -f $realpath ]] \ - && help2man $realpath | man --local-file - | bat --color=always -plman \ - || less $realpath +[[ -f $realpath ]] && + help2man $realpath | man --local-file - | bat --color=always -plman || + less $realpath diff --git a/sources/ip.zsh b/sources/ip.zsh index ae8b423..cd0ab5d 100644 --- a/sources/ip.zsh +++ b/sources/ip.zsh @@ -1,6 +1,6 @@ # :fzf-tab:complete:(\\|*/|)ip: case $group in - 'ip command') - ip $word help 2>&1 | bat --color=always -plhelp - ;; +'ip command') + ip $word help 2>&1 | bat --color=always -plhelp + ;; esac diff --git a/sources/journalctl.zsh b/sources/journalctl.zsh index 0253e92..08b0c03 100644 --- a/sources/journalctl.zsh +++ b/sources/journalctl.zsh @@ -1,12 +1,12 @@ # :fzf-tab:complete:(\\|*/|)journalctl:values case $group in - 'boot '*) - journalctl -b $word | bat --color=always -pllog - ;; - '/dev files') - journalctl -b /dev/$word | bat --color=always -pllog - ;; - commands) - journalctl $word | bat --color=always -pllog - ;; +'boot '*) + journalctl -b $word | bat --color=always -pllog + ;; +'/dev files') + journalctl -b /dev/$word | bat --color=always -pllog + ;; +commands) + journalctl $word | bat --color=always -pllog + ;; esac diff --git a/sources/jq.zsh b/sources/jq.zsh index a641179..26d4a5b 100644 --- a/sources/jq.zsh +++ b/sources/jq.zsh @@ -1,2 +1,2 @@ # :fzf-tab:complete:(\\|*/|)jq:argument-rest -[[ -f $realpath ]] && jq -Cr . $realpath 2> /dev/null || less $realpath +[[ -f $realpath ]] && jq -Cr . $realpath 2>/dev/null || less $realpath diff --git a/sources/kitty.zsh b/sources/kitty.zsh index 6439ab2..8e68d65 100644 --- a/sources/kitty.zsh +++ b/sources/kitty.zsh @@ -1,9 +1,9 @@ # :fzf-tab:complete:(\\|*/|)kitty: case $group in - 'external command') - less =$word - ;; - '%BEntry points%b') - kitty $word --help | bat --color=always -plhelp - ;; +'external command') + less =$word + ;; +'%BEntry points%b') + kitty $word --help | bat --color=always -plhelp + ;; esac diff --git a/sources/libreoffice.zsh b/sources/libreoffice.zsh index cae907c..32b86c2 100644 --- a/sources/libreoffice.zsh +++ b/sources/libreoffice.zsh @@ -1,8 +1,8 @@ # :fzf-tab:complete:(\\|*/|)(libre|s)office: if [[ -f $realpath && ${realpath:e} == xls* ]]; then libreoffice --headless --convert-to html --outdir /tmp $realpath \ - 2>&1 > /dev/null && pandoc -t markdown -o - /tmp/${realpath:t:r}.html \ - | bat --color=always -plmarkdown && rm /tmp/${realpath:t:r}.html + 2>&1 >/dev/null && pandoc -t markdown -o - /tmp/${realpath:t:r}.html | + bat --color=always -plmarkdown && rm /tmp/${realpath:t:r}.html elif [[ -f $realpath ]]; then libreoffice --headless --cat $realpath else diff --git a/sources/make.zsh b/sources/make.zsh index 55d7c1d..d1f90ec 100644 --- a/sources/make.zsh +++ b/sources/make.zsh @@ -1,12 +1,12 @@ # :fzf-tab:complete:(\\|*/|)(g|b|d|p|freebsd-|)make: case $group in - 'make target') - make -n $word | bat --color=always -plsh - ;; - 'make variable') - make -pq | rg -Ns "^$word = " | bat --color=always -plsh - ;; - file) - less ${realpath#--*=} - ;; +'make target') + make -n $word | bat --color=always -plsh + ;; +'make variable') + make -pq | rg -Ns "^$word = " | bat --color=always -plsh + ;; +file) + less ${realpath#--*=} + ;; esac diff --git a/sources/mutt.zsh b/sources/mutt.zsh index 5ab8ae5..362c888 100644 --- a/sources/mutt.zsh +++ b/sources/mutt.zsh @@ -1,9 +1,9 @@ # :fzf-tab:complete:(\\|*/|)(|neo)mutt:(argument-1|option-(b|c)-1) case $group in - 'file attachment') - less ${realpath#--*=} - ;; - *' recipient') - finger $word - ;; +'file attachment') + less ${realpath#--*=} + ;; +*' recipient') + finger $word + ;; esac diff --git a/sources/pacman.zsh b/sources/pacman.zsh index 71ad777..6045270 100644 --- a/sources/pacman.zsh +++ b/sources/pacman.zsh @@ -1,12 +1,12 @@ # :fzf-tab:complete:(\\|*/|)(pacman|yay):(argument-(rest|1)|option-l-1) case $group in - 'package file') - less $realpath - ;; - (('installed '|)package|'local packages')) - pacman -Qi $word | bat --color=always -plyaml - ;; - packages) - pacman -Si $word | bat --color=always -plyaml - ;; +'package file') + less $realpath + ;; +(('installed '|)package|'local packages')) + pacman -Qi $word | bat --color=always -plyaml + ;; +packages) + pacman -Si $word | bat --color=always -plyaml + ;; esac diff --git a/sources/pandoc.zsh b/sources/pandoc.zsh index b8669bd..0a55ffd 100644 --- a/sources/pandoc.zsh +++ b/sources/pandoc.zsh @@ -1,4 +1,4 @@ # :fzf-tab:complete:(\\|*/|)pandoc:argument-rest -[[ $group == file && -f $realpath ]] \ - && pandoc -tmarkdown $realpath | bat --color=always -plmarkdown \ - || less $realpath +[[ $group == file && -f $realpath ]] && + pandoc -tmarkdown $realpath | bat --color=always -plmarkdown || + less $realpath diff --git a/sources/pass.zsh b/sources/pass.zsh new file mode 100644 index 0000000..a39b419 --- /dev/null +++ b/sources/pass.zsh @@ -0,0 +1,9 @@ +# :fzf-tab:complete:(\\|*/|)pass:* +case $group in +passwords) + pass ls $word + ;; +pass) + pass help $word + ;; +esac diff --git a/sources/pkg-config.zsh b/sources/pkg-config.zsh index 46a28cf..45c806a 100644 --- a/sources/pkg-config.zsh +++ b/sources/pkg-config.zsh @@ -1,9 +1,9 @@ # :fzf-tab:complete:(\\|*/|)pkg-config:argument-rest case $group in - package) - less /usr/(lib|share)/pkgconfig/$word.pc - ;; - 'package file') - less ${realpath#--*=} - ;; +package) + less /usr/(lib|share)/pkgconfig/$word.pc + ;; +'package file') + less ${realpath#--*=} + ;; esac diff --git a/sources/poetry.zsh b/sources/poetry.zsh index f3589c4..2538380 100644 --- a/sources/poetry.zsh +++ b/sources/poetry.zsh @@ -1,6 +1,6 @@ # :fzf-tab:complete:(\\|*/|)poetry: case $group in - command) - poetry $word --help | bat --color=always -plhelp - ;; +command) + poetry $word --help | bat --color=always -plhelp + ;; esac diff --git a/sources/ps.zsh b/sources/ps.zsh index d2bdfee..cb9b9bf 100644 --- a/sources/ps.zsh +++ b/sources/ps.zsh @@ -1,3 +1,3 @@ # :fzf-tab:complete:(\\|*/|)(kill|ps):argument-rest --preview-window=down:3:wrap -[[ $group == 'process ID' ]] \ - && ps -p$word -wocmd --no-headers | bat --color=always -plsh +[[ $group == 'process ID' ]] && + ps -p$word -wocmd --no-headers | bat --color=always -plsh diff --git a/sources/pydoc.zsh b/sources/pydoc.zsh index dbde660..78659d8 100644 --- a/sources/pydoc.zsh +++ b/sources/pydoc.zsh @@ -1,2 +1,7 @@ -# :fzf-tab:complete:(\\|*/|)(pydoc|python):* -[[ $word != -* ]] && pydoc $word | bat --color=always -plman +# :fzf-tab:complete:(\\|*/|)pydoc:argument-rest +case $group in +option) ;; +*) + pydoc $word | bat --color=always -plman + ;; +esac diff --git a/sources/pygmentize.zsh b/sources/pygmentize.zsh index 6d3386a..27abdf4 100644 --- a/sources/pygmentize.zsh +++ b/sources/pygmentize.zsh @@ -1,9 +1,9 @@ # :fzf-tab:complete:(\\|*/|)pygmentize:* case $group in - L) - pygmentize -L $word | bat --color=always -plrst - ;; - *) - [[ -f ${realpath#--*=} ]] && pygmentize ${realpath#--*=} || less ${realpath#--*=} - ;; +L) + pygmentize -L $word | bat --color=always -plrst + ;; +*) + [[ -f ${realpath#--*=} ]] && pygmentize ${realpath#--*=} || less ${realpath#--*=} + ;; esac diff --git a/sources/python.zsh b/sources/python.zsh new file mode 100644 index 0000000..b059fe9 --- /dev/null +++ b/sources/python.zsh @@ -0,0 +1,2 @@ +# :fzf-tab:complete:(\\|*/|)python:option-m-1 +pydoc $word | bat --color=always -plman diff --git a/sources/read.zsh b/sources/read.zsh index 8dc5b8c..b9c9aa5 100644 --- a/sources/read.zsh +++ b/sources/read.zsh @@ -1,6 +1,6 @@ # :fzf-tab:complete:(\\|)read:argument-1 case $group in - varprompt) - echo ${(P)word} - ;; +varprompt) + echo ${(P)word} + ;; esac diff --git a/sources/scp.zsh b/sources/scp.zsh index 99fe2f3..777e089 100644 --- a/sources/scp.zsh +++ b/sources/scp.zsh @@ -1,12 +1,12 @@ # :fzf-tab:complete:(\\|*/|)(scp|rsync):argument-rest case $group in - file) - less ${realpath#--*=} - ;; - user) - finger $word - ;; - *host*) - grc --colour=on ping -c1 $word - ;; +file) + less ${realpath#--*=} + ;; +user) + finger $word + ;; +*host*) + grc --colour=on ping -c1 $word + ;; esac diff --git a/sources/snap.zsh b/sources/snap.zsh index c1f2efe..00a61b4 100644 --- a/sources/snap.zsh +++ b/sources/snap.zsh @@ -1,9 +1,9 @@ # :fzf-tab:complete:(\\|*/|)snap: case $group in - option) - snap help $word | bat --color=always -plhelp - ;; - argument) - snap list $word 2> /dev/null - ;; +option) + snap help $word | bat --color=always -plhelp + ;; +argument) + snap list $word 2>/dev/null + ;; esac diff --git a/sources/sqlite3.zsh b/sources/sqlite3.zsh index a0cafea..97fb3d0 100644 --- a/sources/sqlite3.zsh +++ b/sources/sqlite3.zsh @@ -1,4 +1,4 @@ # :fzf-tab:complete:(\\|*/|)sqlite3:argument-1 -[[ -f $realpath ]] \ - && yes .q | sqlite3 $realpath | bat --color=always -plsql \ - || less $realpath +[[ -f $realpath ]] && + yes .q | sqlite3 $realpath | bat --color=always -plsql || + less $realpath diff --git a/sources/systemctl-help.zsh b/sources/systemctl-help.zsh index a371ab0..7324624 100644 --- a/sources/systemctl-help.zsh +++ b/sources/systemctl-help.zsh @@ -1,2 +1,2 @@ # :fzf-tab:complete:systemctl-help:* -systemctl help $word 2> /dev/null | bat --color=always -plhelp +systemctl help $word 2>/dev/null | bat --color=always -plhelp diff --git a/sources/tmux.zsh b/sources/tmux.zsh index c424870..826b582 100644 --- a/sources/tmux.zsh +++ b/sources/tmux.zsh @@ -1,18 +1,18 @@ # :fzf-tab:complete:tmux:argument-rest case $word in - (show|set)(env|-environment)) - tmux ${word/set/show} -g | bat --color=always -plsh - ;; - (show|set)(-hook?|(-window)-option?|w|)) - tmux ${word/set/show} -g | bat --color=always -pltsv - ;; - (show|set)(msgs|-message?)) - tmux ${word/set/show} | bat --color=always -pllog - ;; - (show|set)(b|-buffer)) - tmux ${word/set/show} - ;; - (ls|list-)*) - tmux $word - ;; +(show|set)(env|-environment)) + tmux ${word/set/show} -g | bat --color=always -plsh + ;; +(show|set)(-hook?|(-window)-option?|w|)) + tmux ${word/set/show} -g | bat --color=always -pltsv + ;; +(show|set)(msgs|-message?)) + tmux ${word/set/show} | bat --color=always -pllog + ;; +(show|set)(b|-buffer)) + tmux ${word/set/show} + ;; +(ls|list-)*) + tmux $word + ;; esac diff --git a/sources/ydcv.zsh b/sources/ydcv.zsh deleted file mode 100644 index df39d10..0000000 --- a/sources/ydcv.zsh +++ /dev/null @@ -1,6 +0,0 @@ -# :fzf-tab:complete:(\\|*/|)ydcv:argument-rest -case $group in - word) - ydcv --color=always --history=/dev/null $word - ;; -esac diff --git a/sources/zinit.zsh b/sources/zinit.zsh index 3add553..a486a89 100644 --- a/sources/zinit.zsh +++ b/sources/zinit.zsh @@ -1,6 +1,6 @@ # :fzf-tab:complete:(\\|)zinit-* case $group in - '-- Plugin --') - less $PLUGINS_DIR/$word/README* - ;; +'-- Plugin --') + less $PLUGINS_DIR/$word/README* + ;; esac diff --git a/sources/zipdetails.zsh b/sources/zipdetails.zsh new file mode 100644 index 0000000..567c1db --- /dev/null +++ b/sources/zipdetails.zsh @@ -0,0 +1,2 @@ +# :fzf-tab:complete:(\\|*/|)zipdetails: +zipdetails $realpath 2>/dev/null || less $realpath