commit ec0972fd73457448a994a2f5c925eee03295fb2c
parent 429a9ab40cebda48592bdd8743bfecb66d525085
Author: Luxferre <lux@ferre>
Date: Fri, 31 Mar 2023 14:35:35 +0300
Changed the stash format
Diffstat:
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
@@ -13,7 +13,7 @@ Improvements over the original Bopher from that post:
- mouse support (where possible)
- smoother rendering and scrolling
- better edge-case stability (e.g. on macOS where using file descriptor 3 actually crashes everything)
-- better Gophermap processing according to the RFC
+- better Gophermap processing according to the RFC1436
- multi-level navigation history (although you can only go back)
- status bar with currently opened resource name
- ability to accept `gopher://` URLs from the command line
@@ -27,6 +27,8 @@ Improvements over the original Bopher from that post:
- `stty` (to fetch current terminal size in rows and columns)
- `date` (to shape entry timestamps when stashing links)
+This Bopher-NG repo also contains a set of useful tools (also written in pure Bash) to ease authoring and publishing your own Gopher content. See the [Bopher Tools README](tools/README-tools.md) for more information.
+
## Which Bash versions are supported?
Bopher-NG was only tested on Bash 5.1, but should support any version from 4.2 and up.
@@ -75,7 +77,7 @@ No. Besides the ambiguity problem, it will also introduce huge external dependen
## What is the link stash?
-Link stash is a viable and interoperable alternative to both bookmarks and clipboard that can be implemented with pure Bash. Essentially, it's an append-only text file at a fixed location (`~/.bopher-links.txt` by default) where the user can instruct Bopher-NG to save the link to the currently viewed resource. For your convenience, links are stashed with a UTC-based timestamp and in the `gopher://` format, so they can be copied from the file later and used in other browsers.
+Link stash is a viable and interoperable alternative to both bookmarks and clipboard that can be implemented with pure Bash. Essentially, it's an append-only text file at a fixed location (`~/.bopher-links.txt` by default) where the user can instruct Bopher-NG to save the link to the currently viewed resource. For your convenience, links are stashed with a UTC-based timestamp and in the `gopher://` format, so they can be copied from the file later and used in other browsers. As of now, every stash file line is a valid Gophermap line, so can easily share your findings on the Gopherspace if you need to.
You can override the `BOPHER_LINKSTASH` environment variable to change the location and name of this file if you need to.
diff --git a/bopher-ng.sh b/bopher-ng.sh
@@ -7,7 +7,7 @@
# - mouse support
# - smoother rendering and scrolling
# - better edge-case stability
-# - better Gophermap processing according to the RFC
+# - better Gophermap processing according to the RFC1436
# - multi-level navigation history (although you can only go back)
# - status bar with currently opened resource name
# - ability to accept gopher:// URLs from the command line
@@ -269,8 +269,11 @@ goback() { # remove the last AM line from history and go there
stashlink() { # stash the link to the currently viewed resource
local gopherlink="$(amtogopher "$CURRENTAM")"
- printf '[%s] %s\n' "$(date -u '+%F %T')" "$gopherlink" >> $BOPHER_LINKSTASH
- printf 'Stashed %s%s' "$gopherlink" "$ERESET${ESC}[$TERMROWS;0H" # just reset the cursor to the last line
+ readarray -d $'\t' -t fields < <(printf '%s' "$CURRENTAM") # extract individual fields
+ local desc="${fields[1]}"
+ [[ -z "$desc" ]] && desc='Unnamed'
+ printf '%s [%s] %s - %s\t%s\t%s\t%s\r\n' "${fields[5]}" "$(date -u '+%F %T')" "$desc" "$gopherlink" "${fields[4]}" "${fields[2]}" "${fields[3]}" >> $BOPHER_LINKSTASH
+ printf 'Stashed %s - %s%s' "$desc" "$gopherlink" "$ERESET${ESC}[$TERMROWS;0H" # just reset the cursor to the last line
}
# Focus and click a link on a Gophermap