about summary refs log tree commit diff stats
path: root/bin/lh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/lh')
-rwxr-xr-xbin/lh19
1 files changed, 16 insertions, 3 deletions
diff --git a/bin/lh b/bin/lh
index 25a2f62..016b37f 100755
--- a/bin/lh
+++ b/bin/lh
@@ -4,14 +4,27 @@
 
 # if $1 isn't provided, spawn $BROWSER and exit. this allows lh to be used as a pseudo-browser.
 [ -z "$1" ] && exec "$BROWSER"
+#from pure-sh-bible
+split() {
+	set -f
+	old_ifs=$IFS
+	IFS=$2
+	set -- $1
+	printf '%s\n' "$@"
+	IFS=$old_ifs
+	set +f
+}
+
 case "$1" in
+	gemini://*|gopher://*)
+		$TERMINAL -e bombadillo "$1" ;;
 	*mkv|*webm|*mp4)
 		mpv "$1" >/dev/null 2>&1 & ;;
 	*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*|*twitch.tv/videos/*|*twitch.tv/*/v/*)
 		mpv --ytdl "$1" >/dev/null 2>&1 & ;;
 	*twitch.tv/*)
-		STREAMQUAL="$(streamlink "$1"|\
-			grep "Available streams"|tr " " "\n"|grep -E "[0-9]"|tr -d ,|\
+		STREAMQUAL="$(split "$(streamlink "$1"|grep 'Available streams')" ", "|\
+			grep -E "[0-9]"|\
 			dmenu -p "choose stream quality for $1")"
 		streamlink -p mpv $1 $STREAMQUAL >/dev/null 2>&1 & ;;
 	*png|*jpg|*jpe|*jpeg|*gif)
@@ -28,7 +41,7 @@ case "$1" in
 		fi ;;
 	*)
 		if [ -f "$1" ]; then
-			$TERMINAL -e "$EDITOR $1"
+			$TERMINAL -e "${EDITOR:-vi} $1"
 		else
 			$BROWSER "$1" >/dev/null 2>&1 &
 		fi ;;