dot

packages and services management
Log | Files | Refs | README

commit 6e35bd2524d4b01adece6986335a2b0a9eeb854e
parent 604f887a60264a99f518c9e865bb5e2598229b72
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Tue,  1 Aug 2017 18:10:32 +0200

scripts/bin/io -> iomenu/bin/io

Diffstat:
Mex-vi/.exrc | 1+
Aiomenu/bin/io | 100+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dscripts/bin/io | 98-------------------------------------------------------------------------------
3 files changed, 101 insertions(+), 98 deletions(-)

diff --git a/ex-vi/.exrc b/ex-vi/.exrc @@ -1 +1,2 @@ set number +map g 1G diff --git a/iomenu/bin/io b/iomenu/bin/io @@ -0,0 +1,100 @@ +# cache and filter find output and execute one path as argument of a script + +[ "$ABDUCO" != dvtm ] && [ "$ABDUCO" ] && exit 1 + + +# --- cache -------------------------------------------------------------------- + +mkdir -p "$HOME/.cache" +touch "$HOME/.cache/io" + +[ "$1" = -c ] && find "$HOME" \ + -path "$HOME/.*" -prune -o \ + -path "*/.git/*" -prune -o \ + -path "*/.hg/*" -prune -o \ + -path "${MAIL%/*}/*/*" -prune -o \ + -type d -exec printf '%s/\n' {} + -o \ + -print 2> /dev/null | sort | + +awk -v VAR="$VAR" -v MAIL="${MAIL%/*}" ' + + $0 ~ VAR "/irc/.*/$" { + ircv[ircc++] = $0; + } + + $0 ~ MAIL "/*/" { + mailv[mailc++] = $0; + } + + $0 ~ "/[.]git/$" || + $0 ~ "/src/[^/]*/$" && + $0 !~ "/git/.*/src/" && + $0 !~ "/src/.*/src/" { + sub("/[.]git/$", "/"); + searchv[searchc++] = $0; + } + + $0 ~ VAR "/music" { + musicv[musicc++] = $0; + } + + $0 ~ ".*\.[1-9]p?(.gz)?$" { + manv[manc++] = $0; + } + + $0 !~ "/$" { + filesv[filesc++] = $0; + } + + END { + print "# irc"; + for (i = 0; i < ircc; i++) print(ircv[i] ); + + print "# mail"; + for (i = 0; i < mailc; i++) print(mailv[i] ); + + print "# search"; + for (i = 0; i < searchc; i++) print(searchv[i]); + + print "# music"; + for (i = 0; i < musicc; i++) print(musicv[i] ); + + print "# man"; + for (i = 0; i < manc; i++) print(manv[i] ); + + print "# files"; + for (i = 0; i < filesc; i++) print(filesv[i] ); + } + +' > "$HOME/.cache/io" + +[ "$1" = -c ] && exit + + +# --- select ------------------------------------------------------------------- + +selection=$({ + + printf '# %s\n' abduco + io-abduco + + cat "$HOME/.cache/io" + + printf '# %s\n' url + cat "$HOME"/var/url/* "$PKG/var/url" + cut -d ' ' -f 1 "$HOME/.ssh/known_hosts" | sed -r 's|^|ssh://root@|' + +} | iomenu -p io -s -h | cut -c 3-) + +command="io-${selection%% *}" +path="${selection#* }" + + +# --- run ---------------------------------------------------------------------- + +printf '\033[H\033[2J' + +cd "$(dirname "$path")" + +command -v "${command%% *}" && [ "$path" ] && +exec io-abduco "$path" $command "$path" diff --git a/scripts/bin/io b/scripts/bin/io @@ -1,98 +0,0 @@ -# cache and filter find output and execute one path as argument of a script - -[ "$ABDUCO" != dvtm ] && [ "$ABDUCO" ] && exit 1 - - -# --- cache -------------------------------------------------------------------- - -mkdir -p "$HOME/.cache" -touch "$HOME/.cache/io" - -[ "$1" = -c ] && find "$HOME" \ - -path "$HOME/.*" -prune -o \ - -path "*/.git/*" -prune -o \ - -path "*/.hg/*" -prune -o \ - -path "${MAIL%/*}/*/*" -prune -o \ - -type d -exec printf '%s/\n' {} + -o \ - -print 2> /dev/null | sort | - -awk -v VAR="$VAR" -v MAIL="${MAIL%/*}" ' - - $0 ~ VAR "/irc/.*/$" { - ircv[ircc++] = $0; - } - - $0 ~ MAIL "/*/" { - mailv[mailc++] = $0; - } - - $0 ~ "/[.]git/$" || - $0 ~ "/src/[^/]*/$" && - $0 !~ "/git/.*/src/" && - $0 !~ "/src/.*/src/" { - sub("/[.]git/$", "/"); - searchv[searchc++] = $0; - } - - $0 ~ VAR "/music" { - musicv[musicc++] = $0; - } - - $0 ~ ".*\.[1-9]p?(.gz)?$" { - manv[manc++] = $0; - } - - $0 !~ "/$" { - filesv[filesc++] = $0; - } - - END { - print "# irc"; - for (i = 0; i < ircc; i++) print(ircv[i] ); - - print "# mail"; - for (i = 0; i < mailc; i++) print(mailv[i] ); - - print "# search"; - for (i = 0; i < searchc; i++) print(searchv[i]); - - print "# music"; - for (i = 0; i < musicc; i++) print(musicv[i] ); - - print "# man"; - for (i = 0; i < manc; i++) print(manv[i] ); - - print "# files"; - for (i = 0; i < filesc; i++) print(filesv[i] ); - } - -' > "$HOME/.cache/io" - -[ "$1" = -c ] && exit - - -# --- select ------------------------------------------------------------------- - -selection=$({ - - printf '# %s\n' abduco - io-abduco - - cat "$HOME/.cache/io" - - printf '# %s\n' url - cat "$HOME"/var/url/* "$PKG/var/url" - cut -d ' ' -f 1 "$HOME/.ssh/known_hosts" | sed -r 's|^|ssh://root@|' - -} | iomenu -p io -s -h | cut -c 3-) - -command="io-${selection%% *}" -path="${selection#* }" - - -# --- run ---------------------------------------------------------------------- - -printf '\033[H\033[2J' - -command -v "${command%% *}" && [ "$path" ] && -exec io-abduco "$path" $command "$path"