From 06e39ee847cb3a06cd6f5926f00f2b0a1864ea77 Mon Sep 17 00:00:00 2001 From: foswret Date: Sun, 5 Apr 2026 16:55:20 -0500 Subject: initial commit --- README.md | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ jumper.sh | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 README.md create mode 100755 jumper.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..2729887 --- /dev/null +++ b/README.md @@ -0,0 +1,85 @@ +jumper.sh: A roundabout way of managing and launching bookmarks + +# Why? +I sometimes feel like a bookmark hoarder. I have hundreds of bookmarks of random odds and ends, but they are beholden to whatever browser im using. They cannot be easily shared, must be exported/imported, and are hard to navigate. `jumper.sh` attempts to be a tool to wrangle your bookmarks in a simpler fashion. + +In terms of speed, this script isn't that much better than the autofill results in your browser, but it has 3 main advantages. +1. Plaintext Storage + - To import/export Chrome or Firefox bookmarks, you need to do so in `.html` or `.json` format. + - `jumper.sh` simply takes in plaintext files that are readable by themselves. +2. Scriptable + - Because `jumper.sh` works in the terminal, the data it outputs can be chopped, analyzed, or used however one likes. + - Ex. Share list of websites on the internet, curl them, open whichever one you like, etc. +3. Browser Agnostic + - You can launch the same exact bookmarks in chrome, firefox, `w3m(1)`, `lynx(1)`, etc. without much hassle. + +# Install +- Note: There is probably a better way to install than this way. +```shell +git clone https://git.foswret.com/jumper +cd jumper +chmod +x jumper.sh +doas cp jumper.sh /usr/local/bin +``` + +# "Importing Bookmarks" +Easiest way to do this is open the browser you're already using and right clicking on a folder and select "copy". Paste the contents into a file. There may be folder titles, which should be deleted or commented out with "#". jumper.sh ignores any empty lines, but they can be removed with `vim` by typing `:g/^$/d`. + +Comments about entries should come after their link and should preferably be enclosed in double quotes, but this isn't a hard requirement. + +# Usage +```shell +# List all bookmarks in a file and their position +./jumper.sh [BOOKMARK_FILE] + +# Launch bookmark [NUM] from [BOOKMARK_FILE] +./jumper.sh [BOOKMARK_FILE] [NUM] +``` + +`jumper.sh` truly shines when used in combination with `fzf` for easier bookmark opening. An example of such a script is illustrated below. + +```shell +#!/bin/sh + +bookmark_dir=$HOME/.config/bookmarks +bookmark_file=bookmarks + +launch=$(exec jumper.sh "$bookmark_dir"/"$bookmark_file" | fzf) +num=$(echo "$launch" | cut -d " " -f 1 | grep -o -E "[0-9]+") +if [ "$num" ]; then + jumper.sh "$bookmark_file" "$num" +fi +``` + +# Example +Lets say I have a bookmark file called `games` with the following contents: +``` +# games +https://lichess.org/ "Lichess.org" +https://www.chess.com/home "Chess.com" +https://www.nytimes.com/games/wordle/index.html "Word Game" +https://www.myabandonware.com/game/chessmaster-10th-edition-gr8 "Old chess game for Windows" +https://www.pagat.com/ "Extensive and simple card game rule database" +``` + +Each entry consists of the link and a short comment about it. Each entry only takes up one line. I can list all of these bookmarks with `jumper.sh`: + +```shell +./jumper.sh games + +(1) "Lichess.org": https://lichess.org/ +(2) "Chess.com": https://www.chess.com/home +(3) "Word Game": https://www.nytimes.com/games/wordle/index.html +(4) "Old chess game for Windows": https://www.myabandonware.com/game/chessmaster-10th-edition-gr8 +(5) "Extensive and simple card game rule database": https://www.pagat.com/ +``` + +Each entry has a number corresponding to its position in the list. this isn't alphabetized, but is based on the order in which they appear in the text file. Bookmarks can be launched in the browser defined in `$browser`. + +```shell +# Launches "https://chess.com" in your browser. +./jumper.sh games.txt 2 +``` + +# Contact +[foswret.com/about](https://foswret.com/about) diff --git a/jumper.sh b/jumper.sh new file mode 100755 index 0000000..e31b6d3 --- /dev/null +++ b/jumper.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# jumper: Plaintext bookmark launcher +# https://foswret.com + +browser=/bin/librewolf + +if [ -z "$1" ]; then + echo "Error: no bookmark file specifed." + exit 1 +fi + +filename="$1" + + +# If a position file is specified +if [ "$2" ]; then + position="$2" +fi + +increment=0 + +# If a specific postion is specified +if [ "$position" ]; then + while IFS=" " read -r field comment; do + case $field in + # If the line starts with a "#" (comment) + \#*) + continue + ;; + *[!\ ]*) + increment=$((increment+1)) + if [ "$position" = "$increment" ]; then + $browser "$field" + exit 0 + fi + ;; + # If $field is only whitespace (blank line) + *) + continue + ;; + esac +done < "$filename" +echo "Error: position $position unknown." +exit 1 +fi + +while IFS=" " read -r field comment; do + case $field in + # If the line starts with a "#" (comment) + \#*) + continue + ;; + + *[!\ ]*) + increment=$((increment+1)) + printf "(%d)" "$increment" + if [ "$comment" ]; then + printf " %s:" "$comment" + fi + printf " %s" "$field" + printf "\n" + ;; + + # If $field is only whitespace (blank line) + *) + continue + ;; +esac +done < "$filename" + +exit 0 -- cgit v1.2.3