dot

packages and services management
Log | Files | Refs | README

commit 95b65dc2767ee0d79d761b03d6047a29ea6d7ef4
parent a82aef4cbc7595a04009f9ef9b07765671bffdb5
Author: Josuah Demangeon <mail@josuah.net>
Date:   Mon, 29 Jan 2018 20:58:04 +0100

lt and lr combined into lt

Diffstat:
Mbin/irc | 50+++++++++++++++++++++++++++++---------------------
Dbin/lr | 15---------------
Mbin/lt | 18+++++++++++++-----
Mdaemon/ii | 2+-
Mdot/profile | 2+-
5 files changed, 44 insertions(+), 43 deletions(-)

diff --git a/bin/irc b/bin/irc @@ -1,49 +1,57 @@ #!/bin/sh -# Simple tiny ii client using eel(1) for formatting and iomenu(1) for selection. +# Tiny ii client using eel(1) for formatting and iomenu(1) for selection. -IRCPATH=$HOME/.cache/irc -INPUT=$HOME/.cache/irc/input +INPUT="${VAR}/irc/input" -[ $# -eq 0 ] && exec "$0" "$(find "$IRCPATH" -mindepth 1 -type d | iomenu)" -clear +[ "${#}" -lt 1 ] && +exec "${0}" "$(find "${VAR}/irc" -mindepth 1 -type d | iomenu)" -touch "$INPUT" -tail -fn50 "$1/out" | eel | while IFS= read -r line -do printf '\r\033[K%s\n> %s' "$line" "$(cat "$INPUT")" -done & pid=$! +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")" + printf '\r\033[K> %s' "$(cat "${INPUT}")" key=$(printf %03o "'$(dd bs=1 count=1 2>/dev/null)") do - case $key in + case "${key}" in (000) # Enter - printf '%s\n' "$(cat "$INPUT")" > "$1/in" - printf '' > "$INPUT" + printf '%s\n' "$(cat "${INPUT}")" > "${chan}/in" + printf '' > "${INPUT}" ;; (014) # Ctrl + L - tail -n 1000 "$1/out"| eel | less + tail -n 1000 "${chan}/out"| eel | less ;; (016) # Ctrl + N - pkill -fx "tail -fn50 $1/out" - exec "$0" "$(find "$IRCPATH" -mindepth 1 -type d | iomenu)" + pkill -fx "tail -fn50 ${chan}/out" + exec "${0}" "$(find "${VAR}/irc" -mindepth 1 -type d | iomenu)" ;; (025) # Ctrl + U - printf '' > "$INPUT" + printf '' > "${INPUT}" ;; (027) # Ctrl + W - printf %s "$(sed 's/[^ ]* *$//' "$INPUT")" > "$INPUT" + printf %s "$(sed 's/[^ ]* *$//' "${INPUT}")" > "${INPUT}" ;; (177) # Backspace - printf %s "$(sed 's/.$//' "$INPUT")" > "$INPUT" + printf %s "$(sed 's/.$//' "${INPUT}")" > "${INPUT}" ;; (*) - if [ "$key" -ge 41 ] && [ "$key" -lt 177 ] || [ "$key" -eq 40 ] + if + [ "${key}" -ge 41 ] && + [ "${key}" -lt 177 ] || + [ "${key}" -eq 40 ] then - printf "\\$key" >> "$INPUT" + printf "\\${key}" >> "${INPUT}" fi ;; esac diff --git a/bin/lr b/bin/lr @@ -1,15 +0,0 @@ -#!/bin/sh -# list recursively with some stat infos - -LC_COLLATE=C - -e=$(printf '\033') -t=$(printf '\t') - -find "${@:-.}" -exec stat -f '%Sp %10z%t%N/' {} + -o \ - -name .git -prune -o -name CVS -o -prune | sort -u -t ' ' -k 2 | -sed -r " - s|/*$|| - /^d/ s/$t(.*)/$t$e\[1;34m\1$e\[m/ - /^l/ s/$t(.*)/$t$e\[1;36m\1$e\[m/ -" diff --git a/bin/lt b/bin/lt @@ -3,17 +3,24 @@ LC_COLLATE=C -case $# in (0) ;; (1) cd "$1" || exit 1 ;; (*) exit 1 ;; esac +cd "${1:-.}" + +find . -name .git -prune -o -name CVS -prune -o -exec ls -ld {} + | + awk -v LINE='| ' -v NODE='|- ' -v TAIL='`- ' -v VOID=' ' ' -du -a | grep -v -e/CVS -e/.git | sort -k2 -t' ' | -awk -v LINE='| ' -v NODE='|- ' -v TAIL='`- ' -v VOID=' ' ' { + sub(" \.$", "", $0); + sub(" -> .*", "", $0); + infos = $0; + sub(" \\./.*", "", infos); + sub(".* \\./", "./", $0); + count = split($0, path_v, "/"); for (i = 2; i <= count; i++) line_v[NR":"i] = LINE; - sub("\t.*", "", $0); + line_v[NR":"count] = NODE; - line_v[NR":"1] = sprintf("%10d ", $0); + line_v[NR":"1] = infos " "; line_v[NR"name"] = count == 1 ? "." : path_v[count]; } @@ -32,6 +39,7 @@ END { } } } + for (l = 1; l <= NR; l++) { for (i = 1; line_v[l":"i] != ""; i++) printf("%s", line_v[l":"i]); diff --git a/daemon/ii b/daemon/ii @@ -3,7 +3,7 @@ host="${1:?host required}" port="${2:-6667}" -mkdir -p "${HOME}/${VAR}/${1}" "${HOME}/${LOG}/ii" +mkdir -p "${VAR}/irc/${host}" "${LOG}/ii" exec ii \ -s "${host}" \ diff --git a/dot/profile b/dot/profile @@ -50,5 +50,5 @@ pgrep -x ssh-agent || { } export PS1='$([ "${?}" -gt 0 ] && printf "\033[31;1mx\033[m\n\r")' -export PS1="${PS1}$(printf '\033]0;${PWD} $(git-status)\a') +export PS1="${PS1}$(printf '\033]0;%s\a' '${PWD} $(git-status)') ${SSH_TTY:+$(uname -n)}$ "