dot

packages and services management
Log | Files | Refs | README

commit 24eb98d4364c0506fc152efcdc0795649459c80b
parent dde314563f58d11c79522eb9d1055aeb5cc5019e
Author: Josuah Demangeon <mail@josuah.net>
Date:   Fri, 28 Apr 2017 21:54:26 +0200

Layer 04

Diffstat:
M.profile | 1+
Malias | 2--
Dbin/ii-client | 120-------------------------------------------------------------------------------
Abin/ii-server | 22++++++++++++++++++++++
Mbin/io-abduco | 34+++++++++++++++++++++++-----------
Mbin/io-mblaze | 6+++---
6 files changed, 49 insertions(+), 136 deletions(-)

diff --git a/.profile b/.profile @@ -33,6 +33,7 @@ export MANPATH LIBPATH LD_RUN_PATH LD_LIBRARY_PATH # info NAME='Josuah Demangeon' +NICK='josuah' EMAIL='mail@josuah.net' TZ='Europe/Paris' export NAME EMAIL TZ diff --git a/alias b/alias @@ -13,8 +13,6 @@ alias f='find . ! -path "*/.git/*" -type f | iomenu -p file' alias d='find . ! -path "*/.git/*" -type d | iomenu -p directory' alias c='cd "$(find "$HOME" -type d | iomenu -p cd)"' -alias i='ii-client' - # utilities alias inv='printf "\033[?5%s" h' alias myip='curl icanhazip.com' diff --git a/bin/ii-client b/bin/ii-client @@ -1,120 +0,0 @@ -# wrapper script for ii irc client http://tools.suckless.org/ii - - -E="$(printf '\033')" - - -# Read one character from /dev/tty in raw mode. - -get_char() -{ - stty -echo raw - dd count=1 2> /dev/null - stty sane -} - - -#1 - key to use - -key() -{ - case "$1" in - - ( [[:print:]] ) - printf %s "$key" >> "$INPUT" - ;; - - ( "$(printf '\020')" | "$(printf '\016')" ) # Ctrl-P Ctrl-N - ;; - - ( "$(printf '\033')" | "$(printf '\003')" ) # Escape Ctrl-C - return 1 - ;; - - ( "$(printf '\015')" ) # Ctrl-M Enter - sed 's/$/\n/' "$INPUT" > in - printf '' > "$INPUT" - ;; - - ( "$(printf '\025')" ) # Ctrl-U - printf '' > "$INPUT" - ;; - - ( "$(printf '\027')" ) # Ctrl-W - [ -f "$INPUT" ] && sed -i 's/[^ \t]* *$//' "$INPUT" - ;; - - ( "$(printf '\010')" | "$(printf '\177')" ) # Ctrl-H Backspace - [ -f "$INPUT" ] && sed -i 's/.$//' "$INPUT" - ;; - - ( "$(printf '\014')" ) # Ctrl-L - ii-filter < out | less -R - print_screen - ;; - esac - - prompt - - return 0 -} - - -# Print a prompt with the current input - -prompt() -{ - [ -f "$INPUT" ] && IFS='' read -r input < "$INPUT" - - size="$(stty -F /dev/tty size)" - width="$((${#input} + 4 - ${size#* }))" - - if [ "$width" -gt 0 ] - then - input="$(printf %s "$input" | cut -c "$width"-)" - fi - - printf '\r\033[K> %s' "$input" -} - - -# Update the buffer lines and prompt - -print_screen() -{ - size="$(stty -F /dev/tty size)" - - stty sane - - printf '\033[H\033[J' - [ -f out ] && tail -n "${size#* }" out | ii-filter - prompt - - stty raw -} - - -main() -{ - INPUT="$(mktemp)" - - print_screen - - while IFS='' read -r line - do - printf '\r\033[K%s\n' "$line" - prompt - done & - - while key="$(get_char)" - do - key "$key" || break - done - - stty sane - - rm -f "$INPUT" -} - - -main "$@" diff --git a/bin/ii-server b/bin/ii-server @@ -0,0 +1,22 @@ +# run ii as a daemon + +IRC="${IRC:-$HOME/var/irc}" + +stty -echo; printf 'password: '; read PASS; stty sane; printf '\n' + +alias ii="nohup ii -i '$IRC' -k '$PASS' -f '$NAME'" + +ii -s irc.cyberia.is -e 6697 & +[ -p "$IRC/irc.cyberia.is/in" ] && cat << . >> "$IRC/irc.cyberia.is/in" +/join #cyberia +. + +ii -s unix.chat -e 6697 & +[ -p "$IRC/irc.cyberia.is/in" ] && cat << . >> "$IRC/irc.cyberia.is/in" +/join #unix +. + +ii -s irc.freenode.net -e 6697 & +[ -p "$IRC/irc.cyberia.is/in" ] && cat << . >> "$IRC/irc.cyberia.is/in" +/join #2f30 #openbsd +. diff --git a/bin/io-abduco b/bin/io-abduco @@ -1,12 +1,12 @@ # Attach to an abduco session -CACHE="${XDG_CACHE_HOME:-$HOME/.cache}" +CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/io" [ "$ABDUCO" ] && exit 1 -mkdir -p "$CACHE/io" -touch "$CACHE/io/files" +mkdir -p "$CACHE/find" +touch "$CACHE/files" # --- prompt ------------------------------------------------------------------- @@ -16,30 +16,42 @@ file="$({ abduco | sed 's/.*\t//; s|!|/|g' printf '# Recent files\n' - tac "$CACHE/io/files" + tac "$CACHE/files" printf '# All files\n' - find "$HOME" -type f ! -path '*/.git/*' -} | iomenu -s -p io | tee -a "$CACHE/io/files")" + find "$HOME" -maxdepth 1 -mindepth 1 -type f | sort + find "$HOME" -maxdepth 1 -mindepth 1 -type d | sort | sed 's|.*/||' | + while IFS='' read -r dir + do + if [ "$HOME/$dir" -nt "$CACHE/find/$dir" ] + then + find "$HOME/$dir" -type f | tee -a "$CACHE/find/$dir" + else + cat "$CACHE/find/$dir" + fi + done +} | iomenu -s -p io)" name="$(printf %s "$file" | sed 's|/|!|g')" # --- history ------------------------------------------------------------------ -sort "$CACHE/io/files" | uniq -d | while IFS='' read -r path +[ -f "$file" ] && printf '%s\n' "$file" >> "$CACHE/files" + +sort "$CACHE/files" | uniq -d | while IFS='' read -r path do printf '%s\n' "$( - grep -Fxv "$path" "$CACHE/io/files" - )" "$path" > "$CACHE/io/files" + grep -Fxv "$path" "$CACHE/files" + )" "$path" > "$CACHE/files" done -printf '%s\n' "$(tail "$CACHE/io/files")" > "$CACHE/io/files" +printf '%s\n' "$(tail "$CACHE/files")" > "$CACHE/files" # --- attach ------------------------------------------------------------------- printf '\033[H\033[2J' -[ "$SSH_TTY" ] && e='^z' || e='^\' +[ "$SSH_TTY" ] && e='^\' || e='^Z' [ "$name" ] && ABDUCO="$name" exec abduco -e "$e" -A "$name" $EDITOR "$file" diff --git a/bin/io-mblaze b/bin/io-mblaze @@ -3,11 +3,11 @@ # get the main mail directory with all mailing lists dirname "$MAIL" | -# find all mailboxes in it +# find all mailboxes from it xargs -I % find % -type d -mindepth 1 ! -name cur ! -name new ! -name tmp | -# pick one from it, generate a list of mails -iomenu -l 255 -p mblaze | xargs mdirs | mlist | msort -r -d | mseq -S | +# prompt for a mailbox and sort messages +iomenu -p mblaze | xargs mdirs | mlist | msort -r -d | mseq -S | # prompt for a mail with iomenu mscan -f '%6n %u %D %20f %t%2i%120S' | iomenu -p mblaze |