From c709793a7df8c088ff6d3ae887e8be91c8cd9a28 Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Fri, 20 Oct 2023 16:07:24 +0200 Subject: [PATCH] Copy bookmark script --- src/bin/copy-bookmark | 19 ++++++++++++++++ src/manpages/copy-bookmark.1.scd | 38 ++++++++++++++++++++++++++++++++ src/manpages/irs.1.scd | 6 ++++- src/manpages/open-bookmark.1.scd | 2 +- 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100755 src/bin/copy-bookmark create mode 100644 src/manpages/copy-bookmark.1.scd diff --git a/src/bin/copy-bookmark b/src/bin/copy-bookmark new file mode 100755 index 0000000..88ca427 --- /dev/null +++ b/src/bin/copy-bookmark @@ -0,0 +1,19 @@ +#!/bin/sh + +usage(){ printf "Usage: %s -s|f|r|d|R|h\n" $(basename $0); } + +bookmarks="${BOOKMARKS:-"$HOME/.config/qutebrowser/bookmarks/urls"}" +while getopts sfrdRh name; do + case $name in + f) menu="fzf";; + r) menu="rofi -dmenu -i -p 'Bookmarks'";; + s) menu="sk";; + d) menu="${MENU}";; + R) shuf -n1 $bookmarks | awk '{print $1}' | xclip -sel clip;; + h) usage ;; + *) usage + exit 2;; + esac +done +choice="$(sort $bookmarks | $menu )" +[ -z "$choice" ] || echo "$choice" | awk '{print$1}' | xclip -sel clip diff --git a/src/manpages/copy-bookmark.1.scd b/src/manpages/copy-bookmark.1.scd new file mode 100644 index 0000000..5094ef0 --- /dev/null +++ b/src/manpages/copy-bookmark.1.scd @@ -0,0 +1,38 @@ +open-bookmark(1) + +# NAME + +*copy-bookmark* - puts a *qutebrowser(1)* bookmark into *xclip(1)* clipboard + +# SYNOPSIS + +*open-bookmark -s|f|r|d|R|h* + +# DESCRIPTION +*qutebrowser(1)* saves its bookmarks in +'*~/.config/qutebrowser/bookmarks/urls*'. +I would like to be able to access those bookmarks more easily outside of +qutebrowser sometimes. Hence this script now exists. + +# 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 + +*-h* + print usage and exit + +# SEE ALSO + *fzf(1)*, *sk(1)*, *rofi(1)*, *qutebrowser(1)*, *xclip(1)* diff --git a/src/manpages/irs.1.scd b/src/manpages/irs.1.scd index 4f60712..8860c52 100644 --- a/src/manpages/irs.1.scd +++ b/src/manpages/irs.1.scd @@ -23,6 +23,10 @@ both problems. *open-bookmark* Opens a bookmark in *xdg-open(1)*, see its own manpage for more information +*copy-bookmark* + Adds a bookmark to clipboard using *xclip(1)*, see its own manpage for more + information + # SEE ALSO -*open-bookmark(1)*, *xdg-open(1)* +*open-bookmark(1)*, *xdg-open(1)*, *xclip(1)* diff --git a/src/manpages/open-bookmark.1.scd b/src/manpages/open-bookmark.1.scd index d375888..5997aa7 100644 --- a/src/manpages/open-bookmark.1.scd +++ b/src/manpages/open-bookmark.1.scd @@ -35,4 +35,4 @@ qutebrowser sometimes. Hence this script now exists. print usage and exit # SEE ALSO - *fzf(1)*, *sk(1)*, *rofi(1)*, *qutebrowser(1)* + *fzf(1)*, *sk(1)*, *rofi(1)*, *qutebrowser(1)*, *xdg-open(1)*