Reviewed bookmarks script
Following my previous post I kept improving my bookmarks script.
I simplified the script to use only one bookmark file and defined a structure to help me while searching.
The bookmarks.txt file
It has two sections (just for organization sake), a Quickmarks section for common urls and a Bookmarks section for everything else.
Each line is divided in three parts. A category/name, tags and the url.
1cat ~/.local/bin/bookmarks.txt
2
3>> Quickmarks
4#
5#---
6📚books/Goodreads ...... (reviews) ......... https://www.goodreads.com/
7📚books/Audible ........ (audiobook) ....... https://www.audible.com/
8📚books/Kindle_Deals ... (kindle,ebooks) ... https://www.amazon.com/b/?ie=UTF8&node=11552285011&ref_=sv_kstore_5
9#---
10🟠headspace ............ (meditation) ...... https://www.headspace.com/login
11📶reddit ............... (news,forum) ...... https://www.reddit.com/
12📺youtube .............. (video,stream) .... https://www.youtube.com/
13⭐paapereira.xyz ....... (blog) ............ https://paapereira.xyz/
14#
15-------------------------------------------------------------------------------------------------------------------
16#
17>> Bookmarks
18#
19🏦banking/cgd.pt ..................... (bank) ............ https://www.cgd.pt/
20🏦banking/big.pt ..................... (bank) ............ https://big.pt/
21🏦banking/sodexo ..................... (bank) ............ https://www.sodexobeneficios.pt/
22#---
23#eof
The bookmarks script
With this reviewed script you can also quickly edit the bookmarks.txt file.
1cat ~/.local/bin/bookmarks
2
3#!/usr/bin/env bash
4
5default_browser="$BROWSER"
6
7cat $HOME/.local/bin/bookmarks.txt | grep -v "^#" > /tmp/bookmarks.txt_tmp
8bookmarks_file="/tmp/bookmarks.txt_tmp"
9
10readarray -t bmarks < "${bookmarks_file}"
11
12edit="Edit bookmarks.txt"
13
14choice=$(printf '%s\n' "${edit}" "${bmarks[@]}" | \
15 rofi -dmenu -i -l 20 -theme ~/.config/rofi/themes/gruvbox-dark.rasi \
16 -matching normal -font "Noto Sans Mono 10" -p 'open url:' "$@" ) || exit
17
18if [ "${choice}" = "${edit}" ]; then
19 $TERMINAL -e $EDITOR $HOME/.local/bin/bookmarks.txt
20elif [[ `echo "$choice" | grep -c "^>>\|^--"` -eq 0 && "$choice" ]]; then
21 url=$(echo "${choice}" | awk '{print $NF}') || exit
22 nohup ${default_browser} "$url" >/dev/null 2>&1 &
23fi
24
25#eof