Skip to content

Commit

Permalink
🚚 Rename sources/_* to stop zinit treating them as completions
Browse files Browse the repository at this point in the history
Add ifnames, nix-env, nix-hash, nix-instantiate, nix-store, checkmk, gcov
Fix `cmake -DCMAKE_INSTALL_PREFIX=`
  • Loading branch information
Freed-Wu committed Apr 27, 2023
1 parent da36f03 commit 2937334
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions bin/nix-env.jq
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env -S jq -rf
.[] as $root | $root.meta | "# \(.name)
<\(.homepage)> *\(.license.spdxId)*
\(.description)
\(.longDescription)
\($root.outputs.out)
\(.position)"
3 changes: 3 additions & 0 deletions functions/helper.zsh → functions/main.zsh
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -13,3 +14,5 @@ touch ~/.gitmoji/gitmojis.json

# dictionary $ZINIT cannot be passed
PLUGINS_DIR=${ZINIT[PLUGINS_DIR]}

. $src
2 changes: 1 addition & 1 deletion fzf-tab-source.plugin.zsh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sources/_complete.zsh → sources/--complete.zsh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# :fzf-tab:complete:*
# `${realpath#--*=}` aims to handle `--long-option=/the/path/of/a/file`
less ${realpath#--*=}
less ${realpath#-*=}
File renamed without changes.
3 changes: 3 additions & 0 deletions sources/checkmk.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# :fzf-tab:complete:(\\|*/|)checkmk:
[[ -f $realpath ]] && checkmk $realpath | bat --color=always -plc ||
less $realpath
2 changes: 2 additions & 0 deletions sources/gcov.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# :fzf-tab:complete:(\\|*/|)gcov:
[[ -f $realpath ]] && gcov $realpath || less $realpath
2 changes: 2 additions & 0 deletions sources/ifnames.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# :fzf-tab:complete:(\\|*/|)ifnames:
[[ -f $realpath ]] && ifnames $realpath || less $realpath
6 changes: 6 additions & 0 deletions sources/ninja.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# :fzf-tab:complete:(\\|*/|)ninja:argument-rest
case $group in
targets)
ninja -n $word
;;
esac
13 changes: 13 additions & 0 deletions sources/nix-env.zsh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions sources/nix-hash.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# :fzf-tab:complete:(\\|*/|)nix-hash:argument-rest
nix-hash $realpath
6 changes: 6 additions & 0 deletions sources/nix-instantiate.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# :fzf-tab:complete:(\\|*/|)nix-instantiate:*
case $group in
(shortcuts|'Local file'))
nix-instantiate --eval $word | bat --color=always -plnix
;;
esac
8 changes: 6 additions & 2 deletions sources/nix-store.zsh
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# :fzf-tab:complete:(\\|*/|)nix-build:option-A-1
nix-build --no-out-link '<nixpkgs>' -A $word
# :fzf-tab:complete:(\\|*/|)nix-store:*
case $group in
'Store Paths')
nix-store -q --tree $realpath
;;
esac

0 comments on commit 2937334

Please sign in to comment.