dot

packages and services management
Log | Files | Refs | README

commit d934387e7d057ad2036c0b3c634710327d5ac2bf
parent 52d23ac74bd36d3bf5df3b30efeb5346c85ef100
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sat, 20 May 2017 19:57:38 +0200

Repetition.  Layer 12

Diffstat:
Mbin/io | 2+-
Mbin/io-abduco | 20++++++++++++--------
Mbin/io-files | 2+-
Mbin/io-search | 22+++++++++++++++-------
4 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/bin/io b/bin/io @@ -92,4 +92,4 @@ printf '\033[H\033[2J' [ "$SSH_TTY" ] && e='^\' || e='^Z' command -v "$command" && [ "$path" ] && -exec $command "$path" +exec io-abduco $command "$path" diff --git a/bin/io-abduco b/bin/io-abduco @@ -4,8 +4,15 @@ touch "$HOME/.abduco/names" -# --- update ------------------------------------------------------------------- +# --- option ------------------------------------------------------------------- +if [ "$1" = -n ] +then + mode=-n + shift +else + mode=-A +fi if [ $# = 0 ] then @@ -21,15 +28,13 @@ do shift done -path=$1 - -# --- update names ------------------------------------------------------------- +# --- update session names ----------------------------------------------------- -hash=`printf %s "$path" | md5sum | cut -d ' ' -f 1` +hash=`printf %s "$1" | md5sum | cut -d ' ' -f 1` { - [ "$attach" = 1 ] && printf '%s %s\n' "$hash" "$path" + [ "$attach" = 1 ] && printf '%s %s\n' "$hash" "$1" { abduco | awk -v FS='\t' 'NR > 1 { printf("-e\n%s\n", $3); }' @@ -41,9 +46,8 @@ hash=`printf %s "$path" | md5sum | cut -d ' ' -f 1` if [ "$attach" = 1 ] then - [ "$ABDUCO" ] && exit 1 [ "$SSH_TTY" ] && e='^\' || e='^Z' - ABDUCO=$1 exec abduco -e "$e" -A "$hash" $command "$path" + ABDUCO=$1 exec abduco -e "$e" $mode "$hash" $command "$1" else sed 's/[^ ]* //' "$HOME/.abduco/names" fi diff --git a/bin/io-files b/bin/io-files @@ -1,3 +1,3 @@ # Attach to an abduco session -[ -f "$1" ] && io-abduco $EDITOR -R "$1" +[ -f "$1" ] && $EDITOR "$1" diff --git a/bin/io-search b/bin/io-search @@ -1,17 +1,25 @@ # interactively search a string in all code of a directory -IFS=' ' read -r path number content << EOF -$( +output=` find "$1" -type f ! -path '*/.git/*' | xargs -n 1 awk ' FNR == 1 { printf("# %s\n", FILENAME); } { printf("%7s\t%s\n", FNR, $0); } - ' | iomenu -s -h -p search -) + ' +` + +number=. + +while [ "$number" ] +do + IFS=' ' read -r path number content << EOF +`printf '%s\n' "$output" | iomenu -s -h -p search` EOF -[ "$path" ] || exit 1 + [ "$path" ] || exit + path="${path#\# }" + + io-abduco -n $EDITOR +"`printf %s "$number" | tr -d ' '`" "$path" +done -path="${path#\# }" -exec io-abduco $EDITOR +"$number" "$path"