dot

packages and services management
Log | Files | Refs | README

commit 554d2b776307cc131d853fe8ed4c392658672708
parent db4dbab8c9d7c2cc20521fb5bcd429304d6b4fff
Author: Josuah Demangeon <mail@josuah.net>
Date:   Wed, 27 Dec 2017 23:36:33 +0100

restoring previous "irc" (ii client) version

Diffstat:
Mbin/irc | 49+++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 45 insertions(+), 4 deletions(-)

diff --git a/bin/irc b/bin/irc @@ -1,6 +1,48 @@ #!/bin/sh -# Simple tiny ii client using eel(1) for formatting the logs. +# Simple tiny ii client using eel(1) for formatting and iomenu(1) for selection. -tail -fn50 "$1/out" | eel & +IRCPATH=$HOME/var/irc +INPUT=$HOME/.cache/ii-client -[ -p "$1/in" ] && cat > "$1/in"- \ No newline at end of file +[ $# -eq 0 ] && exec "$0" "$(find "$IRCPATH" -type d | iomenu)" +clear + +tail -fn50 "$1/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")" > "$1/in" + printf '' > "$INPUT" + ;; + (014) # Ctrl + L + tail -n 1000 "$1/out"| eel | less + ;; + (016) # Ctrl + N + pkill -fx "tail -fn50 $1/out" + exec "$0" "$(find "$IRCPATH" -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