dot

packages and services management
Log | Files | Refs | README

commit 5ecca62849b08130d296b903c1382c17a6e1e4e9
parent da9eb3f797902734e27b09b919df24fc457942c2
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sat, 10 Feb 2018 10:18:29 +0100

[ref] grouped scripts into one with options

Diffstat:
Dbin/34c3-stream | 76----------------------------------------------------------------------------
Dbin/curl-0x0 | 3---
Dbin/curl-ip | 3---
Dbin/curl-ix | 3---
Dbin/curl-rfc | 3---
Dbin/curl-sprunge | 3---
Dbin/curl-w1r3 | 3---
Dbin/curl-wttr | 3---
Dbin/etc | 31-------------------------------
Dbin/fmt | 3---
Abin/http | 28++++++++++++++++++++++++++++
Mbin/io | 130+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
Dbin/io-abduco | 12------------
Dbin/io-find | 3---
Dbin/io-fs | 11-----------
Dbin/io-grpwd | 9---------
Dbin/io-lineart | 9---------
Dbin/io-mail | 12------------
Dbin/io-man | 9---------
Dbin/io-netstat | 3---
Dbin/io-ps | 5-----
Dbin/io-sfeed | 4----
Dbin/io-src | 6------
Mbin/twt | 2+-
Mdot/profile | 24++++++++++++------------
25 files changed, 155 insertions(+), 243 deletions(-)

diff --git a/bin/34c3-stream b/bin/34c3-stream @@ -1,76 +0,0 @@ -#!/bin/sh - -sformat="webm" -squality="hd" -mediaplayer="mpv --mute=yes" -translated="native" - -usage() { - printf "usage: %s [-t] [-f format] [-q quality] hall\n" \ - "$(basename "$1")" >&2 - exit 1 -} - -while getopts "f:q:t" opt; -do - case "$opt" in - f) - sformat="$OPTARG" - ;; - q) - squality="$OPTARG" - ;; - t) - translated="translated" - ;; - \?) - usage $0 - ;; - esac -done - -shift "$(($OPTIND - 1))" - -hall="$1" - -case "$hall" in -1|2|3|4) - ;; -*) - printf "There are only hall »1«, »2«, »3« and »4«.\n" >&2 - exit 1 - ;; -esac - -case "$squality" in -hd|sd|slides) - ;; -*) - printf "The quality has to be »sd«, »hd« or »slides«.\n" >&2 - exit 1 - ;; -esac - -webmbase="http://cdn.c3voc.de/s%s_%s_%s.webm" -hlsbase="http://cdn.c3voc.de/hls/s%s_%s_%s.m3u8" -audiobase="http://cdn.c3voc.de/s%s_%s.%s" - -slink="" -case "$sformat" in -webm) - slink="$(printf "$webmbase" "${hall}" "${translated}" "${squality}")" - ;; -m3u8|hls) - slink="$(printf "$hlsbase" "${hall}" "${translated}" "${squality}")" - ;; -mp3|opus) - slink="$(printf "$audiobase" "${hall}" "${translated}" "${sformat}")" - ;; -*) - printf "Only the stream formats »webm«, »hls«, »opus« and »mp3« are available.\n" >&2 - exit 1 - ;; -esac - -http_proxy= https_proxy= $mediaplayer "$slink" - diff --git a/bin/curl-0x0 b/bin/curl-0x0 @@ -1,3 +0,0 @@ -#!/bin/sh - -curl -F file=@- 0x0.st diff --git a/bin/curl-ip b/bin/curl-ip @@ -1,3 +0,0 @@ -#!/bin/sh - -curl icanhazip.com diff --git a/bin/curl-ix b/bin/curl-ix @@ -1,3 +0,0 @@ -#!/bin/sh - -curl -F f:1=@- ix.io diff --git a/bin/curl-rfc b/bin/curl-rfc @@ -1,3 +0,0 @@ -#!/bin/sh - -curl -L "http://www.ietf.org/rfc/rfc${1}".txt | ${PAGER} diff --git a/bin/curl-sprunge b/bin/curl-sprunge @@ -1,3 +0,0 @@ -#!/bin/sh - -curl -F sprunge=@- sprunge.us diff --git a/bin/curl-w1r3 b/bin/curl-w1r3 @@ -1,3 +0,0 @@ -#!/bin/sh - -curl -F upload=@- w1r3.net diff --git a/bin/curl-wttr b/bin/curl-wttr @@ -1,3 +0,0 @@ -#!/bin/sh - -curl wttr.in diff --git a/bin/etc b/bin/etc @@ -1,31 +0,0 @@ -#!/bin/sh -e - -cd "${0%/*}/.." - -. dot/profile - -case "${1}" in -(link) - find * -type d -exec mkdir -p "${ETC}/{}" \; - find * ! -type d -exec ln -fs "${PWD}/{}" "${ETC}/{}" \; - - cd dot - find * -type d -exec mkdir -p "${HOME}/.{}" \; - find * ! -type d -exec ln -fs "${PWD}/{}" "${HOME}/.{}" \; - find -L "${HOME}" -maxdepth 2 -type l -exec rm {} + - ;; -(mkdir) - mkdir -p "${HOME}/tmp" - mkdir -p "${VAR}/mail/cur" - mkdir -p "${VAR}/mail/new" - mkdir -p "${VAR}/mail/tmp" - mkdir -p "${RUN}" - mkdir -p "${HOME}/git" - ;; -(srv) - git clone josuah@josuah.net:srv/git/srv.git "${HOME}/srv" - cd "${HOME}/srv" && make - ;; -(*) - echo 'usage: etc link | mkdir | srv | tinc <remote>' -esac diff --git a/bin/fmt b/bin/fmt @@ -1,3 +0,0 @@ -#!/bin/sh - -tr '\n' ' ' | fold -w 80 -s | sed 's/ *$//' diff --git a/bin/http b/bin/http @@ -0,0 +1,28 @@ +#!/bin/sh + +case "${1}" in +(0x0) + curl -F file=@- 0x0.st + ;; +(ip) + curl icanhazip.com + ;; +(ix) + curl -F f:1=@- ix.io + ;; +(rfc) + curl -L "http://www.ietf.org/rfc/rfc${1}".txt | ${PAGER} + ;; +(sprunge) + curl -F sprunge=@- sprunge.us + ;; +(w1r3) + curl -F upload=@- w1r3.net + ;; +(wttr) + curl wttr.in + ;; +(*) + echo 'usage: http 0x0 | ip | ix | rfc <num> | sprunge | w1r3 | wttr' + ;; +esac diff --git a/bin/io b/bin/io @@ -1,21 +1,119 @@ #!/bin/sh +# various interactive selection menu wrappers -export LC_COLLATE=C +cmd="${1:-open}" +[ "$#" -gt 0 ] && shift -cache="${HOME}/.cache/find" -mkdir -p "${cache}" +case "${cmd}" in +(a|abduco) -case "${PWD}" in ("${HOME}"/*) - dir=$(printf %s "${PWD##${HOME}/}" | sed 's|/.*||') - find "${HOME}/$dir" '(' -name .git -o -name CVS ')' -prune -o -print | - sort > "${cache}/${dir}" -esac + if [ "${#}" -gt 0 ] + then + name="${1}" + shift + else + name=$({ printf '#'; abduco; } | iomenu -# | cut -f4) + fi + + [ "${SSH_TTY}" ] && e='^Z' || e='^\' + [ "${name}" ] && ABDUCO="${name}" exec abduco -e "${e}" -A "${name}" "${@}" + ;; +(f|find) + find "${@:-.}" -name .git -prune -o -print | iomenu + ;; +(fs) + { + printf '#spec .file .vfstype .mntops .freq .passno\n' | + cat - /etc/fstab | column -ts ' ' + { + printf '#device . .path . .type .mntops\n' + mount + } | column -ts ' ' + + } | iomenu -# + ;; +(g|grep) + less "$(find "${1}" -name .git -prune -o -type f | sort | xargs -n 128 awk ' + FNR == 1 { printf("#%s\n", FILENAME); } + { printf("%7s\t%s\n", FNR, $0); } + ' | iomenu -# | cut -f 1)" + ;; +(l|lineart) + iomenu << 'EOF' | sed 's/^[^ ]* *//' +put sunglasses on (•_•) / ( •_•)>⌐■-■ / (⌐■_■) +shrug ¯\_(ツ)_/¯ +rose --{@ +magic (∩`-´)⊃━☆゚.*・。゚ +EOF + ;; +(m|mail) + export LC_COLLATE=C + + mdirs "$HOME/.cache/mail" | sort | + while IFS='' read -r dir + do + printf '%s\t%s\n' "$(mlist -s "$dir" | wc -l)" "$dir" + done | iomenu | cut -f 2 | mlist | mthread | msort -r -d | + mseq -S | mscan -f '%6n %u %D %20f %t%2i%120S' | iomenu | + sed -r 's/^ *([0-9]*) .*/\1/'| + xargs mless + ;; +(man) + export LC_COLLATE='C' + + man -k ' ' | sed -r ' + s/ - / - / + s/(.{25}[^ ]* ) * - /\1- / + ' | iomenu | sed -r 's/([_a-zA-Z0-9]*).*\(([0-9p]+).*\).*/\2 \1/' | + xargs man + ;; +(n|netstat) + netstat -na | sed 's/^[AP]/#&/' | iomenu -# + ;; +(o|open) + export LC_COLLATE=C -exec xdg-open "$(find "${HOME}" -maxdepth 1 -mindepth 1 | - sort | - cut -c $((${#HOME} + 2))- | - xargs -I {} printf '%s/%s\n' "${cache}" {} | - xargs -I {} cat "${cache}" {} 2> /dev/null | - cat - "${HOME}/etc/lib/uri" | - iomenu -# | - cut -f 2-)" + cache="${HOME}/.cache/find" + mkdir -p "${cache}" + + case "${PWD}" in ("${HOME}"/*) + dir=$(printf %s "${PWD##${HOME}/}" | sed 's|/.*||') + find "${HOME}/$dir" '(' -name .git -o -name CVS ')' -prune -o -print | + sort > "${cache}/${dir}" + esac + + exec xdg-open "$(find "${HOME}" -maxdepth 1 -mindepth 1 | + sort | + cut -c $((${#HOME} + 2))- | + xargs -I {} printf '%s/%s\n' "${cache}" {} | + xargs -I {} cat "${cache}" {} 2> /dev/null | + cat - "${ETC}/uri" | + iomenu -# | + cut -f 2-)" + ;; +(ps) + { + ps -ax || ps + } | sed '1 s/^/#/' | iomenu -# | sed -r 's/[^ ]* *([0-9]*).*/\1/' + ;; +(pwd) + { + printf '#name: pw: uid: gid: class: home_dir: shell\n' | + cat - /etc/passwd | sed 's/::/: :/g' | column -ts : + + printf '#group: pw: gid: member\n' | + cat - /etc/group | sed 's/::/: :/g' | column -ts : + } | iomenu -# + ;; +(s|sfeed) + exec xdg-open "$(find "${HOME}/.sfeed/feeds" -type f -exec sfeed_plain {} + | + iomenu | sed 's/.* //')" + ;; +(*) + printf 'usage: %s ' "${0##*/}" + sed -n '/^(/ { s/^(//; s/)$//; s/|.\(.*\)/[\1]/; /^\*$/d; p; }' "${0}" | + tr '\n' '|' | sed 's/|/ | /g' | fold -sw 60 | + sed 's/^[ |]*//; s/[ |]*$//; 2,$ s/^/ /' + printf '\n' + ;; +esac diff --git a/bin/io-abduco b/bin/io-abduco @@ -1,12 +0,0 @@ -#!/bin/sh - -if [ "${#}" -gt 0 ] -then - name="${1}" - shift -else - name=$({ printf '#'; abduco; } | iomenu -# | cut -f4) -fi - -[ "${SSH_TTY}" ] && e='^Z' || e='^\' -[ "${name}" ] && ABDUCO="${name}" exec abduco -e "${e}" -A "${name}" "${@}" diff --git a/bin/io-find b/bin/io-find @@ -1,3 +0,0 @@ -#!/bin/sh - -find "${@:-.}" -name .git -prune -o -print | iomenu diff --git a/bin/io-fs b/bin/io-fs @@ -1,11 +0,0 @@ -#!/bin/sh - -{ - printf '#spec .file .vfstype .mntops .freq .passno\n' | - cat - /etc/fstab | column -ts ' ' - { - printf '#device . .path . .type .mntops\n' - mount - } | column -ts ' ' - -} | iomenu -# diff --git a/bin/io-grpwd b/bin/io-grpwd @@ -1,9 +0,0 @@ -#!/bin/sh - -{ - printf '#name: pw: uid: gid: class: home_dir: shell\n' | - cat - /etc/passwd | sed 's/::/: :/g' | column -ts : - - printf '#group: pw: gid: member\n' | - cat - /etc/group | sed 's/::/: :/g' | column -ts : -} | iomenu -# diff --git a/bin/io-lineart b/bin/io-lineart @@ -1,9 +0,0 @@ -#!/bin/sh -# cool lines to paste - -iomenu << 'EOF' | sed 's/^[^ ]* *//' -put sunglasses on (•_•) / ( •_•)>⌐■-■ / (⌐■_■) -shrug ¯\_(ツ)_/¯ -rose --{@ -magic (∩`-´)⊃━☆゚.*・。゚ -EOF diff --git a/bin/io-mail b/bin/io-mail @@ -1,12 +0,0 @@ -#!/bin/sh -e - -export LC_COLLATE=C - -mdirs "$HOME/.cache/mail" | sort | -while IFS='' read -r dir -do - printf '%s\t%s\n' "$(mlist -s "$dir" | wc -l)" "$dir" -done | iomenu | cut -f 2 | mlist | mthread | msort -r -d | -mseq -S | mscan -f '%6n %u %D %20f %t%2i%120S' | iomenu | -sed -r 's/^ *([0-9]*) .*/\1/'| -xargs mless diff --git a/bin/io-man b/bin/io-man @@ -1,9 +0,0 @@ -#!/bin/sh - -export LC_COLLATE='C' - -man -k ' ' | sed -r ' - s/ - / - / - s/(.{25}[^ ]* ) * - /\1- / -' | iomenu | sed -r 's/([_a-zA-Z0-9]*).*\(([0-9p]+).*\).*/\2 \1/' | -xargs man diff --git a/bin/io-netstat b/bin/io-netstat @@ -1,3 +0,0 @@ -#!/bin/sh - -netstat -na | sed 's/^[AP]/#&/' | iomenu -# diff --git a/bin/io-ps b/bin/io-ps @@ -1,5 +0,0 @@ -#!/bin/sh - -{ - ps -ax || ps -} | sed '1 s/^/#/' | iomenu -# | sed -r 's/[^ ]* *([0-9]*).*/\1/' diff --git a/bin/io-sfeed b/bin/io-sfeed @@ -1,4 +0,0 @@ -#!/bin/sh - -exec xdg-open "$(find "${HOME}/.sfeed/feeds" -type f -exec sfeed_plain {} + | - iomenu -p sfeed | sed 's/.* //')" diff --git a/bin/io-src b/bin/io-src @@ -1,6 +0,0 @@ -#!/bin/sh - -less "$(find "${1}" -name .git -prune -o -type f | sort | xargs -n 128 awk ' -FNR == 1 { printf("#%s\n", FILENAME); } - { printf("%7s\t%s\n", FNR, $0); } -' | iomenu -# | cut -f 1)" diff --git a/bin/twt b/bin/twt @@ -147,7 +147,7 @@ case "${1}" in (following) [ "${#}" -ne 1 ] && exec "${0}" - sed -r's/[[:space:]]/ /; s/(.{12}[^ ]*) */\1 @ /' \ + sed -r 's/[[:space:]]/ /; s/(.{12}[^ ]*) */\1 @ /' \ "${CONF}" ;; (*) diff --git a/dot/profile b/dot/profile @@ -15,22 +15,22 @@ export LC_MESSAGES='en_US.UTF-8' export LC_NUMERIC='en_US.UTF-8' export LC_TIME='en_US.UTF-8' -export VAR="${HOME}/.cache" -export RUN="${VAR}/run" -export LOG="${VAR}/log" -export ETC="${HOME}/.config" -export SYS="${HOME}/.local" -export LIB="${HOME}/lib" +export CFG="${HOME}/cfg" # configuration source +export ETC="${HOME}/.config" # /etc installed configuration +export SYS="${HOME}/.local" # /usr/local package installation path +export VAR="${HOME}/.cache" # /var generated data +export LIB="${HOME}/lib" # original data +export RUN="${VAR}/run" # /var/run runtime information +export LOG="${VAR}/log" # /var/log log files export MAIL="${VAR}/mail/mbox" - -export PLAN9="${HOME}/.local/src/plan9" +export PLAN9="${SYS}/src/plan9" export PATH="${HOME}/etc/bin:${HOME}/.local/bin:${PATH}:${PLAN9}/bin" export MANPATH="${HOME}/etc/man:/usr/share/man:/usr/local/man" -export MANPATH="${HOME}/.local/share/man:${MANPATH}:${PLAN9}/man" -export C_INCLUDE_PATH="${HOME}/.local/include" -export LIBRARY_PATH="${HOME}/.local/lib:/usr/local/lib/inotify" -export LD_LIBRARY_PATH="${HOME}/.local/lib:/usr/local/lib/inotify" +export MANPATH="${SYS}/share/man:${MANPATH}:${PLAN9}/man" +export C_INCLUDE_PATH="${SYS}/include" +export LIBRARY_PATH="${SYS}/lib:/usr/local/lib/inotify" +export LD_LIBRARY_PATH="${SYS}/lib:/usr/local/lib/inotify" export BLIH='josuah.demangeon@epitech.eu' export CVSROOT='anoncvs@anoncvs.fr.openbsd.org:/cvs'