Sane defaults are sane

This commit is contained in:
Nox Sluijtman 2023-11-30 15:55:15 +01:00
parent 005a022307
commit a2a5318fa8
3 changed files with 11 additions and 10 deletions

View file

@ -6,6 +6,7 @@ usage(){
printf "Usage: %s -c|h\n" "$(basename $0)" printf "Usage: %s -c|h\n" "$(basename $0)"
printf "OR\n" printf "OR\n"
printf "Usage: %s <bookmark-url>\n" "$(basename $0)" printf "Usage: %s <bookmark-url>\n" "$(basename $0)"
exit 1
} }
@ -22,10 +23,12 @@ addUrl(){
printf "added '%s' to '%s'" "$url" "$bookmarks" printf "added '%s' to '%s'" "$url" "$bookmarks"
} }
while getopts chu: flag; do
while getopts ch: flag; do
case $flag in case $flag in
c)addUrl $(xclip -o);; c)addUrl $(xclip -o) && exit 0;;
u)addUrl $OPTARG;;
h)usage;; h)usage;;
esac esac
done done
addUrl $1

View file

@ -1,8 +1,7 @@
#compdef _add-bookmark add-bookmark #compdef _add-bookmark add-bookmark
_arguments : \ _arguments : \
"(-u -h)-c[take url from clipboard]" \ "(-h)-c[take url from clipboard]" \
"(-c -h)-u[url as argument]:bookmark url:" \ "(-c)-h[print usage and exit]"
"(-u -c)-h[print usage and exit]"
_arguments : $arguments _arguments : $arguments

View file

@ -6,7 +6,9 @@ add-bookmark(1)
# SYNOPSIS # SYNOPSIS
*copy-bookmark -u|h|c* *copy-bookmark -h|c*
*copy-bookmark <url>*
# DESCRIPTION # DESCRIPTION
*qutebrowser(1)* saves its bookmarks in *qutebrowser(1)* saves its bookmarks in
@ -16,9 +18,6 @@ qutebrowser.
# OPTIONS # OPTIONS
*-u*
URL given as argument
*-c* *-c*
URL read from clipboard URL read from clipboard