commit 8038f07202209b75db5e7e660e6c98f219152a24 parent df9c8409e178a9c6850e23c8991dcef8d066b5e3 Author: Sven Möller <sven@svenmoeller.xyz> Date: Mon, 28 Feb 2022 23:06:18 +0100 Work on script Diffstat:
M | bin/.local/bin/lh | | | 40 | ++++++++++++++++++++++++++-------------- |
1 file changed, 26 insertions(+), 14 deletions(-)
diff --git a/bin/.local/bin/lh b/bin/.local/bin/lh @@ -18,7 +18,7 @@ openbrowser () { if [ $gui = true ] ; then qutebrowser $1 > /dev/null 2>&1 & else - python -m readability.readability -u $1 2> /dev/null | w3m -T text/html + python -m readability.readability -u $1 | w3m -T text/html fi } @@ -52,17 +52,29 @@ choose () { $action "$1" } -while [ $# -gt 0 ]; do -case $1 in - -g) - gui=true - shift ;; - -o) open $2 && exit ;; - -c) cat "$0" | choose $2 && exit;; - -*) echo "Unknown option: $1" && exit ;; - *) - [ $# -eq 2 ] && "$1" "$2" && exit - [ $# -eq 1 ] && cat "$0" | open "$1" && exit - ;; -esac +while [ $# -gt 1 ]; do + case $1 in + -g) + gui="true" + shift + ;; + -o) + action="open" + shift + ;; + -c) + action="choose" + shift + ;; + -*) + echo "Unknown option: $1" + shift + ;; + *) + "$1" "$2" && exit + ;; + esac done + +[ -z "$action" ] && action="open" +cat "$0" | "$action" "$1"