diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e5936ba..5cbcfd7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,7 +45,7 @@ repos: hooks: - id: check-mailmap - repo: https://github.com/adrienverge/yamllint - rev: v1.29.0 + rev: v1.30.0 hooks: - id: yamllint - repo: https://github.com/executablebooks/mdformat diff --git a/bin/nix-env.jq b/bin/nix-env.jq new file mode 100755 index 0000000..f27800e --- /dev/null +++ b/bin/nix-env.jq @@ -0,0 +1,8 @@ +#!/usr/bin/env -S jq -rf +.[] as $root | $root.meta | "# \(.name) +<\(.homepage)> *\(.license.spdxId)* +\(.description) + +\(.longDescription) +\($root.outputs.out) +\(.position)" diff --git a/functions/helper.zsh b/functions/main.zsh similarity index 92% rename from functions/helper.zsh rename to functions/main.zsh index 3b10804..c76a9a2 100644 --- a/functions/helper.zsh +++ b/functions/main.zsh @@ -1,5 +1,6 @@ # define some functions to avoid any error that these programs don't exist (($+commands[bat])) || bat() {cat} +(($+commands[mdcat])) || mdcat() {bat} (($+commands[pygmentize])) || pygmentize() {cat} (($+commands[delta])) || delta() {cat} (($+commands[less])) || less() {ls -l} @@ -13,3 +14,5 @@ touch ~/.gitmoji/gitmojis.json # dictionary $ZINIT cannot be passed PLUGINS_DIR=${ZINIT[PLUGINS_DIR]} + +. $src diff --git a/fzf-tab-source.plugin.zsh b/fzf-tab-source.plugin.zsh old mode 100644 new mode 100755 index 3cca45b..44f3c19 --- a/fzf-tab-source.plugin.zsh +++ b/fzf-tab-source.plugin.zsh @@ -21,7 +21,7 @@ for src in $dir/sources/*.zsh $sources; do break fi done < $src - zstyle $ctx fzf-preview ". $dir/functions/helper.zsh && . $src" + zstyle $ctx fzf-preview "src="\""$src"\"" . "\""$dir"\""/functions/main.zsh" flags=${arr[2]} if [[ -n $flags ]]; then zstyle $ctx fzf-flags $flags diff --git a/sources/_complete.zsh b/sources/--complete.zsh similarity index 81% rename from sources/_complete.zsh rename to sources/--complete.zsh index acea466..e93421e 100644 --- a/sources/_complete.zsh +++ b/sources/--complete.zsh @@ -1,3 +1,3 @@ # :fzf-tab:complete:* # `${realpath#--*=}` aims to handle `--long-option=/the/path/of/a/file` -less ${realpath#--*=} +less ${realpath#-*=} diff --git a/sources/_user-expand.zsh b/sources/--user-expand.zsh similarity index 100% rename from sources/_user-expand.zsh rename to sources/--user-expand.zsh diff --git a/sources/checkmk.zsh b/sources/checkmk.zsh new file mode 100644 index 0000000..9371e84 --- /dev/null +++ b/sources/checkmk.zsh @@ -0,0 +1,3 @@ +# :fzf-tab:complete:(\\|*/|)checkmk: +[[ -f $realpath ]] && checkmk $realpath | bat --color=always -plc || + less $realpath diff --git a/sources/gcov.zsh b/sources/gcov.zsh new file mode 100644 index 0000000..29b1f8d --- /dev/null +++ b/sources/gcov.zsh @@ -0,0 +1,2 @@ +# :fzf-tab:complete:(\\|*/|)gcov: +[[ -f $realpath ]] && gcov $realpath || less $realpath diff --git a/sources/ifnames.zsh b/sources/ifnames.zsh new file mode 100644 index 0000000..48bb32f --- /dev/null +++ b/sources/ifnames.zsh @@ -0,0 +1,2 @@ +# :fzf-tab:complete:(\\|*/|)ifnames: +[[ -f $realpath ]] && ifnames $realpath || less $realpath diff --git a/sources/ninja.zsh b/sources/ninja.zsh new file mode 100644 index 0000000..6bcd7de --- /dev/null +++ b/sources/ninja.zsh @@ -0,0 +1,6 @@ +# :fzf-tab:complete:(\\|*/|)ninja:argument-rest +case $group in +targets) + ninja -n $word + ;; +esac diff --git a/sources/nix-env.zsh b/sources/nix-env.zsh new file mode 100644 index 0000000..2304323 --- /dev/null +++ b/sources/nix-env.zsh @@ -0,0 +1,13 @@ +# :fzf-tab:complete:(\\|*/|)nix-env:* +case $group in +'Attribute path') + nix-env -qa --out-path --json --meta -A $ctxt[hpre]$word | + ${src:h:h}/bin/nix-env.jq | mdcat + ;; +'Installed package'*) + nix-env -q --out-path --json --meta $word | ${src:h:h}/bin/nix-env.jq | mdcat + ;; +'Local file') + less $realpath + ;; +esac diff --git a/sources/nix-hash.zsh b/sources/nix-hash.zsh new file mode 100644 index 0000000..48bd73e --- /dev/null +++ b/sources/nix-hash.zsh @@ -0,0 +1,2 @@ +# :fzf-tab:complete:(\\|*/|)nix-hash:argument-rest +nix-hash $realpath diff --git a/sources/nix-instantiate.zsh b/sources/nix-instantiate.zsh new file mode 100644 index 0000000..94d5cc7 --- /dev/null +++ b/sources/nix-instantiate.zsh @@ -0,0 +1,6 @@ +# :fzf-tab:complete:(\\|*/|)nix-instantiate:* +case $group in +(shortcuts|'Local file')) + nix-instantiate --eval $word | bat --color=always -plnix + ;; +esac diff --git a/sources/nix-store.zsh b/sources/nix-store.zsh index 0ae1fce..32a86d9 100644 --- a/sources/nix-store.zsh +++ b/sources/nix-store.zsh @@ -1,2 +1,6 @@ -# :fzf-tab:complete:(\\|*/|)nix-build:option-A-1 -nix-build --no-out-link '' -A $word +# :fzf-tab:complete:(\\|*/|)nix-store:* +case $group in +'Store Paths') + nix-store -q --tree $realpath + ;; +esac