dot

packages and services management
Log | Files | Refs | README

commit b43507d3e744845de1146b6af845463f0071a1c2
parent cc9d5dfccc6b62f9387493e801d057a0c351f5ef
Author: Josuah Demangeon <mail@josuah.net>
Date:   Mon, 11 Dec 2017 04:00:36 +0100

ii wrapper based off eel

Diffstat:
Mbin/ii-client | 37+++++++++++++++++++++++++++++++++----
Dbin/uri | 52----------------------------------------------------
Apackage/eel/git | 1+
3 files changed, 34 insertions(+), 56 deletions(-)

diff --git a/bin/ii-client b/bin/ii-client @@ -1,11 +1,40 @@ #!/bin/sh # Simple tiny ii client -[ -d "$1" ] || exit 1 +INPUT=$HOME/.cache/ii-client -tail -n 80 -f "$1/out" & +tail -f "$1/out" | eel | while IFS='' read -r line +do printf '\r\033[K%s\n> %s' "$line" "$(cat "$INPUT")" +done & -while IFS='' read -r line +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 - printf '%s\n' "$line" > "$1/in" + case $key in + (000) # Enter + printf '%s\n' "$(cat "$INPUT")" > "$1/in" + printf '' > "$INPUT" + ;; + (014) # Ctrl + L + tail -n 1000 "$1/out"| eel | less + ;; + (025) # Ctrl + U + printf '' > "$INPUT" + ;; + (027) # Ctrl + W + printf %s "$(sed 's/[^ ]* *$//' "$INPUT")" > "$INPUT" + ;; + (177) # Backspace + printf %s "$(sed 's/.$//' "$INPUT")" > "$INPUT" + ;; + (*) + if [ "$key" -gt 41 ] && [ "$key" -lt 177 ] || [ "$key" -eq 40 ] + then printf "\\$key" >> "$INPUT" + fi + ;; + esac done diff --git a/bin/uri b/bin/uri @@ -1,52 +0,0 @@ -# scheme://[user[:pass]@]host[:port][/path] -IFS=' ' read scheme user pass host port path << EOF -$(printf %s "$1" | awk '{ - gsub(" ", "%20"); - gsub("\t", "%0b"); - - scheme = $0; - if (sub("^[^:/]*://", "", $0) > 0) - sub("://.*", "", scheme); - else - scheme = "."; - - user = $0; - if (sub("^[^@/]*@", "", $0) > 0) - sub("@.*", "", user); - else - user = "."; - - pass = user; - if (sub(":.*", "", user) > 0) - sub("[^:]*:", "", pass) ; - else - pass = "."; - - host = $0 - if (sub("^[^:]*:", ":", $0) > 0) - sub(":.*", "", host); - else if (sub("[^/]*/", "/", $0) > 0) - sub("/.*", "", host); - - port = $0 - if (sub("^:[0-9]+:", "", $0) > 0 || sub("^:[0-9]+/", "/", $0) > 0) { - sub(":", "", port); - sub("[:/].*", "", port); - } else if (sub("^:[0-9]+$", "", $0) > 0) { - sub(":", "", port); - } else { - port = "."; - } - - path = $0; - - printf("%s\t%s\t%s\t%s\t%s\t%s", scheme, user, pass, host, port, path); -}') -EOF - -printf 'scheme: %s\n' "$scheme" -printf 'user: %s\n' "$user" -printf 'pass: %s\n' "$pass" -printf 'host: %s\n' "$host" -printf 'port: %s\n' "$port" -printf 'path: %s\n' "$path" diff --git a/package/eel/git b/package/eel/git @@ -0,0 +1 @@ +git://josuah.net:9000/eel.git