Simplification
This commit is contained in:
parent
0703487e4d
commit
d4da13c3ea
|
@ -2,25 +2,30 @@
|
|||
|
||||
bookmarks="${BOOKMARKS:-"$HOME/.config/qutebrowser/bookmarks/urls"}"
|
||||
|
||||
usage(){ printf "Usage: %s -s|f|r|d|R|h\n" $(basename $0); }
|
||||
usage(){ printf "Usage: %s -R|h|c\n" $(basename $0); }
|
||||
|
||||
copy(){
|
||||
random(){
|
||||
shuf -n1 $bookmarks | awk '{print $1}' | xclip -sel clip
|
||||
xclip -o -sel clip
|
||||
}
|
||||
|
||||
[ $# -eq 0 ] && usage && exit 2
|
||||
while getopts sfrdRh name; do
|
||||
default(){
|
||||
if [ -z ${MENU} ]
|
||||
then printf 'err: $MENU not set\n' && exit 2
|
||||
else export menu="${MENU}"
|
||||
fi
|
||||
}
|
||||
|
||||
[ $# -eq 0 ] && default
|
||||
|
||||
while getopts Rhc: name; do
|
||||
case $name in
|
||||
f) menu="fzf";;
|
||||
r) menu="rofi -dmenu -i -p 'Bookmarks'";;
|
||||
s) menu="sk";;
|
||||
d) menu="${MENU}";;
|
||||
R) copy ;;
|
||||
R) random ;;
|
||||
h) usage ;;
|
||||
*) usage
|
||||
exit 2;;
|
||||
c) menu="$OPTARG";;
|
||||
esac
|
||||
done
|
||||
|
||||
choice="$(sort $bookmarks | $menu )"
|
||||
|
||||
[ -z "$choice" ] || echo "$choice" | awk '{print$1}' | xclip -sel clip
|
||||
|
|
|
@ -1,19 +1,26 @@
|
|||
#!/bin/sh
|
||||
|
||||
usage(){ printf "Usage: %s -s|f|r|d|R|h\n" $(basename $0); }
|
||||
[ $# -eq 0 ] && usage && exit 2
|
||||
usage(){ printf "Usage: %s -R|h|c\n" $(basename $0); }
|
||||
|
||||
bookmarks="${BOOKMARKS:-"$HOME/.config/qutebrowser/bookmarks/urls"}"
|
||||
while getopts sfrdRh name; do
|
||||
|
||||
default(){
|
||||
if [ -z ${MENU} ]
|
||||
then printf 'err: $MENU not set\n' && exit 2
|
||||
else export menu="${MENU}"
|
||||
fi
|
||||
}
|
||||
|
||||
[ $# -eq 0 ] && default
|
||||
|
||||
while getopts Rhc: name; do
|
||||
case $name in
|
||||
f) menu="fzf";;
|
||||
r) menu="rofi -dmenu -i -p 'Bookmarks'";;
|
||||
s) menu="sk";;
|
||||
d) menu="${MENU}";;
|
||||
R) xdg-open "$(shuf -n1 $bookmarks | awk '{print $1}')";;
|
||||
h) usage ;;
|
||||
*) usage
|
||||
exit 2;;
|
||||
h) usage;;
|
||||
c) menu="$OPTARG";;
|
||||
esac
|
||||
done
|
||||
|
||||
choice="$(sort $bookmarks | $menu )"
|
||||
|
||||
[ -z "$choice" ] || xdg-open "$(echo "$choice" | awk '{print$1}')"
|
||||
|
|
|
@ -1,18 +1,8 @@
|
|||
#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]"
|
||||
"(-R -h)-c[menu command]:dmenu-like program" \
|
||||
"(-h -c)-R[copy random bookmark]" \
|
||||
"(-R -c)-h[print usage and exit]"
|
||||
_arguments : $arguments
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
#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]"
|
||||
"(-R -h)-c[menu command]:dmenu-like program" \
|
||||
"(-h -c)-R[copy random bookmark]" \
|
||||
"(-R -c)-h[print usage and exit]"
|
||||
_arguments : $arguments
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ open-bookmark(1)
|
|||
|
||||
# SYNOPSIS
|
||||
|
||||
*open-bookmark -s|f|r|d|R|h*
|
||||
*copy-bookmark -R|h|c*
|
||||
|
||||
# DESCRIPTION
|
||||
*qutebrowser(1)* saves its bookmarks in
|
||||
|
@ -14,25 +14,19 @@ open-bookmark(1)
|
|||
I would like to be able to access those bookmarks more easily outside of
|
||||
qutebrowser sometimes. Hence this script now exists.
|
||||
|
||||
Defaults to using *$MENU* as menu command.
|
||||
|
||||
# OPTIONS
|
||||
|
||||
*-s*
|
||||
use *sk(1)* to select bookmark
|
||||
|
||||
*-f*
|
||||
use *fzf(1)* to select bookmark
|
||||
|
||||
*-r*
|
||||
use *rofi(1)* to select bookmark
|
||||
|
||||
*-d*
|
||||
use *$MENU* to select bookmark
|
||||
|
||||
*-R*
|
||||
copy random bookmark
|
||||
|
||||
*-c*
|
||||
specify menu command, has to me something that reads from STDIN and allows
|
||||
the user to make a selection eg *dmenu(1)*
|
||||
|
||||
*-h*
|
||||
print usage and exit
|
||||
|
||||
# SEE ALSO
|
||||
*fzf(1)*, *sk(1)*, *rofi(1)*, *qutebrowser(1)*, *xclip(1)*
|
||||
*fzf(1)*, *dmenu(1)*, *qutebrowser(1)*, *xclip(1)*
|
||||
|
|
|
@ -6,7 +6,7 @@ open-bookmark(1)
|
|||
|
||||
# SYNOPSIS
|
||||
|
||||
*open-bookmark -s|f|r|d|R|h*
|
||||
*open-bookmark -R|h|c*
|
||||
|
||||
# DESCRIPTION
|
||||
*qutebrowser(1)* saves its bookmarks in
|
||||
|
@ -14,25 +14,19 @@ open-bookmark(1)
|
|||
I would like to be able to access those bookmarks more easily outside of
|
||||
qutebrowser sometimes. Hence this script now exists.
|
||||
|
||||
Defaults to using *$MENU* as menu command.
|
||||
|
||||
# OPTIONS
|
||||
|
||||
*-s*
|
||||
use *sk(1)* to select bookmark
|
||||
|
||||
*-f*
|
||||
use *fzf(1)* to select bookmark
|
||||
|
||||
*-r*
|
||||
use *rofi(1)* to select bookmark
|
||||
|
||||
*-d*
|
||||
use *$MENU* to select bookmark
|
||||
|
||||
*-R*
|
||||
open random bookmark
|
||||
|
||||
*-c*
|
||||
specify menu command, has to me something that reads from STDIN and allows
|
||||
the user to make a selection eg *dmenu(1)*
|
||||
|
||||
*-h*
|
||||
print usage and exit
|
||||
|
||||
# SEE ALSO
|
||||
*fzf(1)*, *sk(1)*, *rofi(1)*, *qutebrowser(1)*, *xdg-open(1)*
|
||||
*fzf(1)*, *dmenu(1)*, *qutebrowser(1)*, *xdg-open(1)*
|
||||
|
|
Loading…
Reference in a new issue