From b9cf6d786ce4f16e0d20d22199d75c955c71b326 Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Fri, 20 Oct 2023 17:55:10 +0200 Subject: [PATCH] ZSH completions --- flake.nix | 5 +++-- src/bin/copy-bookmark | 2 +- src/bin/open-bookmark | 6 ++---- src/completions/_copy-bookmark | 18 ++++++++++++++++++ src/completions/_open-bookmark | 18 ++++++++++++++++++ 5 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 src/completions/_copy-bookmark create mode 100644 src/completions/_open-bookmark diff --git a/flake.nix b/flake.nix index 8248352..3a5c24c 100644 --- a/flake.nix +++ b/flake.nix @@ -28,9 +28,10 @@ ''; installPhase = '' - mkdir -p $out/{share/man/man1,bin} + mkdir -p $out/{share/man/man1,bin,share/zsh/site-functions} cp bin/* $out/bin/ - cp *.1 $out/share/man/man1 + cp completions/* $out/share/zsh/site-functions/ + cp *.1 $out/share/man/man1/ ''; }; }; diff --git a/src/bin/copy-bookmark b/src/bin/copy-bookmark index 88ca427..7f809cc 100755 --- a/src/bin/copy-bookmark +++ b/src/bin/copy-bookmark @@ -1,7 +1,7 @@ #!/bin/sh usage(){ printf "Usage: %s -s|f|r|d|R|h\n" $(basename $0); } - +[ $# -eq 0 ] && usage && exit 2 bookmarks="${BOOKMARKS:-"$HOME/.config/qutebrowser/bookmarks/urls"}" while getopts sfrdRh name; do case $name in diff --git a/src/bin/open-bookmark b/src/bin/open-bookmark index 71993a7..7c5df19 100755 --- a/src/bin/open-bookmark +++ b/src/bin/open-bookmark @@ -1,9 +1,7 @@ #!/bin/sh -usage(){ - printf "Usage: %s -s|f|r|d|R|h\n" $(basename $0) -} - +usage(){ printf "Usage: %s -s|f|r|d|R|h\n" $(basename $0); } +[ $# -eq 0 ] && usage && exit 2 bookmarks="${BOOKMARKS:-"$HOME/.config/qutebrowser/bookmarks/urls"}" while getopts sfrdRh name; do case $name in diff --git a/src/completions/_copy-bookmark b/src/completions/_copy-bookmark new file mode 100644 index 0000000..62e7dc5 --- /dev/null +++ b/src/completions/_copy-bookmark @@ -0,0 +1,18 @@ +#compdef _copy-bookmark copy-bookmark + +_arguments : \ + "(-f -r -d -R -h)-f[use 'fzf' to open bookmarks file]" \ + "(-s -r -d -R -h)-r[use 'rofi' to open bookmarks file]" \ + "(-s -f -d -R -h)-s[use 'sk' to open bookmarks file]" \ + "(-s -f -r -R -h)-d[use '$MENU' to open bookmarks file]" \ + "(-s -f -r -d -h)-R[copy random bookmark]" \ + "(-s -f -r -d -R)-h[print usage and exit]" +_arguments : $arguments + + + + + + + + diff --git a/src/completions/_open-bookmark b/src/completions/_open-bookmark new file mode 100644 index 0000000..1617b68 --- /dev/null +++ b/src/completions/_open-bookmark @@ -0,0 +1,18 @@ +#compdef _open-bookmark open-bookmark + +_arguments : \ + "(-f -r -d -R -h)-f[use 'fzf' to open bookmarks file]" \ + "(-s -r -d -R -h)-r[use 'rofi' to open bookmarks file]" \ + "(-s -f -d -R -h)-s[use 'sk' to open bookmarks file]" \ + "(-s -f -r -R -h)-d[use '$MENU' to open bookmarks file]" \ + "(-s -f -r -d -h)-R[open random bookmark]" \ + "(-s -f -r -d -R)-h[print usage and exit]" +_arguments : $arguments + + + + + + + +