dot

packages and services management
Log | Files | Refs | README

commit 1111abb44dbf6ed75c85b5c9e7b8216f223d6a8c
parent f17e845bdf95b716f919945364995c6fa24ff526
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sun, 11 Feb 2018 22:01:50 +0100

[add] srw-based irc client script

Diffstat:
Mbin/irc | 66+++++++++++-------------------------------------------------------
Apack/srw/tar | 1+
2 files changed, 12 insertions(+), 55 deletions(-)

diff --git a/bin/irc b/bin/irc @@ -1,60 +1,16 @@ #!/bin/sh -# Tiny ii client using eel(1) for formatting and iomenu(1) for selection. +# Tiny ii log reader using eel(1) for formatting and iomenu(1) for selection. -INPUT="${VAR}/irc/input" +if [ "${#}" -eq 1 ] +then + [ "${1}" ] || exit 1 + eel < "${1}/out" | less + srw -p "${1##*/}> " sh -c ' + tail -n 80 -f "${0}/out" | eel & + cat > "${0}/in" + ' "${1}" +fi -mkdir -p "${VAR}/irc" +trap '' INT -[ "${#}" -lt 1 ] && exec "${0}" "$(find "${VAR}/irc" -mindepth 1 -type d | iomenu)" - -chan="${1}" - -printf '\033[H\033[J\033]0;%s\a' "${chan#${VAR}/irc}" - -touch "${INPUT}" -tail -fn50 "${chan}/out" | eel | while IFS='' read -r line -do - printf '\r\033[K%s\n> %s' "${line}" "$(cat "${INPUT}")" -done & -pid="${!}" - -trap 'tty sane' EXIT - -stty -icanon -echo -while - printf '\r\033[K> %s' "$(cat "${INPUT}")" - key=$(printf %03o "'$(dd bs=1 count=1 2>/dev/null)") -do - case "${key}" in - (000) # Enter - printf '%s\n' "$(cat "${INPUT}")" > "${chan}/in" - printf '' > "${INPUT}" - ;; - (014) # Ctrl + L - tail -n 1000 "${chan}/out"| eel | less - ;; - (016) # Ctrl + N - pkill -fx "tail -fn50 ${chan}/out" - exec "${0}" "$(find "${VAR}/irc" -mindepth 1 -type d | iomenu)" - ;; - (025) # Ctrl + U - printf '' > "${INPUT}" - ;; - (027) # Ctrl + W - printf %s "$(sed 's/[^ ]* *$//' "${INPUT}")" > "${INPUT}" - ;; - (177) # Backspace - printf %s "$(sed 's/.$//' "${INPUT}")" > "${INPUT}" - ;; - (*) - if - [ "${key}" -ge 41 ] && - [ "${key}" -lt 177 ] || - [ "${key}" -eq 40 ] - then - printf "\\${key}" >> "${INPUT}" - fi - ;; - esac -done diff --git a/pack/srw/tar b/pack/srw/tar @@ -0,0 +1 @@ +https://bitbucket.org/emg/srw/get/295139501255.tar.gz