Skip to content

Commit

Permalink
Merge pull request #28 from rnwgnr/main
Browse files Browse the repository at this point in the history
add u command to jump one path segment up
  • Loading branch information
blmayer authored Jan 23, 2023
2 parents 9ffc3fb + 5d00cb2 commit 5658ddf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ To remove a certificate simply delete the `<domain>.crt` and `<domain>.key` file
### Key bindings

- `b` to go back one page
- `u` go one path segment up
- `o` to open a new URL, you'll be prompted to type it
- `r` to reload the page
- `H` to go to the home page
- `g` to follow a link in the current page, a link will be displayed, and
- `s` to save the page to a file
- `m` to add the current page to bookmarks
- `M` to go to a bookmark
- `K` to delete the bookmark of the current page
- `q` to quit

More coming.
Expand Down
22 changes: 16 additions & 6 deletions astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/sh

version="0.19.0"

usage() {
echo "Astro v0.18.0: Browse the gemini web on the terminal."
echo "astro v$version: Browse the gemini web on the terminal."
echo ""
echo "Usage: astro [url]|[option]"
echo ""
Expand All @@ -14,6 +16,7 @@ usage() {
echo " g go to a link"
echo " r reload current page"
echo " b go back one page"
echo " u jump one path segment up"
echo " o open an address"
echo " s save current page"
echo " H go to homepage"
Expand All @@ -32,11 +35,10 @@ usage() {
echo "Report bugs to: bleemayer@gmail.com"
echo "Home page: <https://www.github.com/blmayer/astro/>"
echo "General help: <https://www.github.com/blmayer/astro/wiki>"
exit
}

version() {
echo "astro 0.18.0"
echo "astro $version"
echo "Copyright (C) 2021-2023 Brian Mayer."
echo "License MIT: MIT License <https://opensource.org/licenses/MIT>"
echo "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,"
Expand Down Expand Up @@ -87,9 +89,11 @@ cachedir="$cachehome/astro"
# m (54): add page to bookmarks
# M (55): go to a bookmark
# K (56): remove bookmark for current url
[ -n "$LESSKEY" ] && echo "AE0rR2MoAG8AmDEAcgCYMgBnAJgzAGIAmDQASACYNQBtAJg2AE0AmDcASwCYOABlAAB2AAB4RW5k" | \
# u (57): jump one path element up
[ -n "$LESSKEY" ] && echo "AE0rR2MtAG8AmDEAcgCYMgBnAJgzAGIAmDQASACYNQBtAJg2AE0AmDcASwCYOAB1AJg5AGUAAHYAAHhFbmQ=" | \
base64 -d > "$LESSKEY"

margin=8
if [ ! -s "$configfile" ]
then
# Default values
Expand All @@ -108,6 +112,8 @@ sty_listt='0'
EOF
fi


# shellcheck disable=SC1090
. "$configfile"

mkdir -p "$cachedir"
Expand Down Expand Up @@ -401,16 +407,20 @@ EOF
;;
56)
url="$1://$2:$3/$4"
cat "$bookmarkfile" | grep -iv "^$url " > "$cachedir/bookmarks"
grep -iv "^$url " "$bookmarkfile" > "$cachedir/bookmarks"
mv "$cachedir/bookmarks" "$bookmarkfile"
;;
57)
newpath=$(echo "/$4" | rev | cut -d'/' -f2- | rev)
url="$1://$2:$3/$newpath"
;;
esac

debug "new url: $url"
}

# Execution
export LESS='-P Keys\: qgrbosHmMK, to see a description run astro -h'
export LESS='-P Keys\: qgrubosHmMK, to see a description run astro -h'

# First request
url="${args:-$homepage}"
Expand Down
2 changes: 1 addition & 1 deletion less.keys
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ H quit 5
m quit 6
M quit 7
K quit 8

u quit 9

0 comments on commit 5658ddf

Please sign in to comment.