nexus.sh

Minimal hacked-together nex browser
[raw]

01: #!/bin/bash
02: # @desc Minimal hacked-together nex browser
03: URL='nex.nightfall.city/'
04: LINK=/
05: while [ -n "$LINK" ]
06: do
07:     HOST=${URL%%/*}
08:     QUERY=${URL#*/}
09:     PAGE=$(mktemp nexpage.XXXX.txt)
10:     echo /$QUERY |nc $HOST 1900 > $PAGE
11:     clear
12:     echo "=> nex://$URL <="
13:     cat $PAGE
14:     unset LINK
15:     select LINK in . .. $(grep '^=>' $PAGE|cut -d' ' -f 2)
16:     do
17:         if [[ ! ( $REPLY =~ ^[0-9]+$ ) ]]
18:         then
19:             LINK=$REPLY
20:         fi
21:         case $LINK in
22:             nex://*/)
23:                 URL=${LINK:6}
24:             ;;
25:             nex://*)
26:                 URL=${LINK:6}/
27:             ;;
28:             .)
29:                 URL=${URL%/*}/
30:             ;;
31:             ..)
32:                 URL=${URL%/*/}/
33:             ;;
34:             *)
35:                 URL=${URL%/*}/${LINK}
36:             ;;
37:         esac
38:         break
39:     done
40:     rm $PAGE
41: done
42: