Various shell scripts for use on the RTC server. Not your official RTC stuff!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

37 lines
740 B

#! /bin/bash
# runurl - "uNiVeRsAl" URL handler
# Author: samhunter@rawtext.club
# https://git.rawtext.club/samhunter/rtc-shell-scripts
#
readonly PROGNAME="${0##/}"
readonly VERSION="1.0"
FULLURL="${1:?"$PROGNAME requires one URL as a parameter"}"
SCHEME="${FULLURL%%://*}"
URL="${FULLURL##*://}"
HOST="${URL%%:*}"
PORT="${URL##*:}"
printf "Full URL: %s \nScheme: %s\nUrl: %s\nHost: %s\nPort: %s\n" $FULLURL $SCHEME $URL $HOST $PORT
case "$SCHEME" in
https*) # http/https
${BROWSER:-w3m} $FULLURL
;;
gopher) # http/https
${GOPHER:-w3m} $FULLURL
;;
gemini) # gemini
${GEMINI:-amfora} $FULLURL
;;
telnet) # telnet
telnet $HOST $PORT
;;
ssh) # ssh
ssh -p $PORT $HOST
;;
*) # default
w3m "$FULLURL"
;;
esac