gc

simple gopher client
git clone git://git.alexkarle.com.com/gc
Log | Files | Refs | README

commit f72cc04de2e058f975cc1fcdfc43bde69419d834 (patch)
parent 79769a98e3a98e9c17238a4602c1a410b811194c
Author: Alex Karle <alex@alexkarle.com>
Date:   Sat, 13 Nov 2021 11:59:02 -0500

ui: Add first steps--don't pager if not a tty!

Diffstat:
Mgc | 26+++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/gc b/gc @@ -22,12 +22,28 @@ END { ' } +catlike() { + case "$TARGET" in + /0/*) echo "${TARGET##/0}" | nc "$HOST" 70 ;; + /1/*) echo "${TARGET##/1}" | nc "$HOST" 70 | pretty ;; + *) echo "$TARGET" | nc "$HOST" 70 | pretty ;; # TODO: handle other types? + esac +} + +ui() { + case "$TARGET" in + /0/*) echo "${TARGET##/0}" | nc "$HOST" 70 | ${PAGER:-less} ;; + /1/*) echo "${TARGET##/1}" | nc "$HOST" 70 | pretty ;; + *) echo "$TARGET" | nc "$HOST" 70 | pretty ;; # TODO: handle other types? + esac +} + uri=${1##gopher://} HOST=${uri%%/*} TARGET=${uri##$HOST} -case $TARGET in - /0/*) echo "${TARGET##/0}" | nc "$HOST" 70 | ${PAGER:-less} ;; - /1/*) echo "${TARGET##/1}" | nc "$HOST" 70 | pretty ;; - *) echo "$TARGET" | nc "$HOST" 70 | pretty ;; # TODO: handle other types? -esac +if ! tty >/dev/null; then + catlike +else + ui +fi