Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

rlwrap is fantastic. here's a multichannel text chat system for other people who can ssh to the same host, with command-line editing, cross-session history, and logging provided by rlwrap:

    #!/bin/sh
    # Simple chat system frontend, wrapping gyap in rlwrap and maybe ssh.
    : ${GYAP_LOGFILE=$HOME/gyap.log} ${GYAP_COMMAND=gyap}
    if [ "$#" -eq 0 ]; then
        rlwrap -C gyap -l "$GYAP_LOGFILE"             "$GYAP_COMMAND" "$@"
    else
        host=$1; shift
        rlwrap -C gyap -l "$GYAP_LOGFILE" ssh "$host" "$GYAP_COMMAND" "$@"
    fi
the actual chat system is another 10-line shell script called `gyap`

    #!/bin/sh
    : Simple chat system.  cf. rgyap.  ${nick=${1-$USER}} ${chan=${2-/var/tmp/chat}}
    echo "Chatting on $chan as <$nick> (override with $0 \$nick [\$chan])"
    touch "$chan" && chmod 666 "$chan" 2>/dev/null
    sign() {
        echo "$(date +%T) * $nick signed $1 ($(date +%05Y-%m-%d))" >> "$chan"
    }
    echo "Press ^R if a chat line appears as you are typing.  Recently:"
    tail -Fn 16 "$chan" & pid=$?; trap "sign off; sleep .1; kill $pid" 0
    sign on; while read t; do echo "$(date +%T) <$nick> $t"; done >> "$chan"
from http://canonical.org/~kragen/sw/dev3/gyap and http://canonical.org/~kragen/sw/dev3/rgyap

it's not secure of course; anyone can spoof anyone else or fill up your /var/tmp disk, or read the log without signing onto the channel

it would be nice to have rlwrap options to customize tab-completion, for example for expanding to recently-mentioned nicks or slapping someone around a bit with a large trout



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: