dot

packages and services management
Log | Files | Refs | README

commit 9e779605df83fbb7924ae64c28e7069494f35ef0
parent 24eb98d4364c0506fc152efcdc0795649459c80b
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sat, 29 Apr 2017 00:19:54 +0200

Layer 05

Diffstat:
Malias | 6++----
Mbin/io | 92+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
Dbin/io-abduco | 57---------------------------------------------------------
Dbin/io-edit | 46----------------------------------------------
4 files changed, 55 insertions(+), 146 deletions(-)

diff --git a/alias b/alias @@ -1,12 +1,10 @@ # core -alias l='ls -lhp' -alias la='ls -lhpA' +alias l='ls -lp' +alias la='ls -lpA' alias cl='printf "\033[H\033[2J"' alias ..='cd ..' # iomenu -alias v='io-abduco' -alias a='io-abduco' alias r='io-run' alias j='fg "%$(jobs | iomenu | sed -r "s/.([0-9]*).*/\1/")"' alias f='find . ! -path "*/.git/*" -type f | iomenu -p file' diff --git a/bin/io b/bin/io @@ -1,44 +1,58 @@ -# content of Wired +# Attach to an abduco session -CACHE="$HOME/.cache/io" +CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/io" +[ "$ABDUCO" ] && exit 1 -line="$(while IFS='' read -r line +mkdir -p "$CACHE/find" +touch "$CACHE/files" + + +# --- prompt ------------------------------------------------------------------- + +file="$({ + printf '# ' + abduco | sed 's/.*\t//; s|!|/|g' + + printf '# Recent files\n' + tac "$CACHE/files" + + printf '# All files\n' + find "$HOME" -maxdepth 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 ! -path '*/.git/*' | sort | + tee "$CACHE/find/$dir" + else + cat "$CACHE/find/$dir" + fi + done +} | iomenu -s -p io)" + +name="$(printf %s "$file" | sed 's|/|!|g')" + + +# --- history ------------------------------------------------------------------ + +[ -f "$file" ] && printf '%s\n' "$file" >> "$CACHE/files" + +sort "$CACHE/files" | uniq -d | while IFS='' read -r path do - if [ "$line" ] && [ -z "${line%%# *}" ] - then - line="${line### }" - command="${line%%#*}" - [ -z "${line##*#*}" ] && options="${line#*#}" || option='' - - printf '# %s\n' "$command" - - elif [ "$line" ] && [ -d "$line" ] - then - mkdir -p "$CACHE/${command%% *}" - name="$(printf %s "$line" | sed 's|/|!|g')" - - find "$line" $options | tee -a "$CACHE/${command%% *}/$name" - - elif [ -f "$line" ] - then - cat "$line" - - elif [ "$line" ] - then - printf '%s\n' "$line" - fi -done << EOF | iomenu -s -h -p io | sed 's/# //' - -# mandoc -a # -type f -name *.[1-9] -o -name *.[1-9].gz -$(printf %s "$MANPATH" | sed 's/:/\n/g') -/usr/share/man -EOF -)" - -command="${line%% *}" -path="${line#* }" -printf '%s\n' "$command" "$path" - -[ "$command" ] && [ "$path" ] && exec $command "$path" + printf '%s\n' "$( + grep -Fxv "$path" "$CACHE/files" + )" "$path" > "$CACHE/files" +done + +printf '%s\n' "$(sed '/^$/d' "$CACHE/files" | tail)" > "$CACHE/files" + + +# --- attach ------------------------------------------------------------------- + +printf '\033[H\033[2J' + +[ "$SSH_TTY" ] && e='^\' || e='^Z' +[ "$name" ] && ABDUCO="$name" exec abduco -e "$e" -A "$name" $EDITOR "$file" diff --git a/bin/io-abduco b/bin/io-abduco @@ -1,57 +0,0 @@ -# Attach to an abduco session - - -CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/io" - -[ "$ABDUCO" ] && exit 1 - -mkdir -p "$CACHE/find" -touch "$CACHE/files" - - -# --- prompt ------------------------------------------------------------------- - -file="$({ - printf '# ' - abduco | sed 's/.*\t//; s|!|/|g' - - printf '# Recent files\n' - tac "$CACHE/files" - - printf '# All files\n' - 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 ------------------------------------------------------------------ - -[ -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/files" - )" "$path" > "$CACHE/files" -done - -printf '%s\n' "$(tail "$CACHE/files")" > "$CACHE/files" - - -# --- attach ------------------------------------------------------------------- - -printf '\033[H\033[2J' - -[ "$SSH_TTY" ] && e='^\' || e='^Z' -[ "$name" ] && ABDUCO="$name" exec abduco -e "$e" -A "$name" $EDITOR "$file" diff --git a/bin/io-edit b/bin/io-edit @@ -1,46 +0,0 @@ -# prompt for a file to open with EDITOR, with an history of last 10 opened - - -CACHE="${XDG_CACHE_HOME:-$HOME/.cache}" - - -path() -{ - { - printf '# Recent files\n' - tac "$CACHE/io/files" - - printf '# All files\n' - find "$HOME" -type f ! -path '*/.git/*' - } | iomenu -l 255 -s -p edit | tee -a "$CACHE/io/files" -} - - -history() -{ - sort "$CACHE/io/files" | uniq -d | while IFS='' read -r path - do - printf '%s\n' "$( - grep -Fxv "$path" "$CACHE/io/files" - )" "$path" > "$CACHE/io/files" - done - - printf '%s\n' "$(tail "$CACHE/io/files")" > "$CACHE/io/files" -} - - -main() -{ - mkdir -p "$CACHE/io" - touch "$CACHE/io/files" - - file="$(path)" - - # terminal name - history - - [ "$file" ] && [ -d "${file%/*}" ] && exec $EDITOR "$file" -} - - -main "$@"