dot

packages and services management
Log | Files | Refs | README

commit 3561fc781d34b485f6a9104bcc51c454caa3beb6
parent c976cde3186bfe17885589c6c3e6a268162f2c84
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sun, 25 Mar 2018 12:08:32 +0200

half-assed ssh-based setup

Diffstat:
M.bashrc | 1+
M.ssh/config | 10+++++++++-
Mbin/io | 12+++++++-----
Mbin/pack | 2+-
Mbin/xdg-abduco | 18++++++++++--------
Mbin/xdg-open | 39++++++++++++++++++++++++++++++++++++---
6 files changed, 64 insertions(+), 18 deletions(-)

diff --git a/.bashrc b/.bashrc @@ -2,3 +2,4 @@ PS1='\[\033[31;1m\]$([ $? -gt 0 ] && printf "x\\n ")\033[m\] \[\033]0;$PWD\a\]\h\$ ' +alias ix='curl -F f:1=@- ix.io' diff --git a/.ssh/config b/.ssh/config @@ -1,5 +1,13 @@ AddKeysToAgent yes -IdentityFile /mnt/key/josuah.key + +host nas.josuah.net + IdentityFile /mnt/key/josuah.key + +host rpi.josuah.net + IdentityFile /mnt/key/josuah.key + +host josuah.net + IdentityFile /mnt/key/josuah.key host git.nixers.net IdentityFile /mnt/key/git.nixers.net.key diff --git a/bin/io b/bin/io @@ -6,12 +6,14 @@ export LC_COLLATE='C' cache="$HOME/.cache/find" -mkdir -p "$(dirname "$cache")" +mkdir -p "$cache" -if [ "$1" = -c ] || [ ! -f "$cache" ] +if [ "$1" = -c ] || [ ! -f "$cache/!ocalhost" ] then - find "$HOME" \( -name .git -o -name CVS \) -prune -o -print | - sort -o "$cache" + find "$HOME" \( -name .git -o -name CVS \) -prune -o \ + -type d -exec printf '%s/\n' {} + -o \ + -type f -exec printf '%s\n' {} + | + sort -o "$cache/!ocalhost" exit fi @@ -20,5 +22,5 @@ h='----------------------------------------------------------------------------' exec xdg-open "$({ xdg-abduco printf '#%s\n' "$h$h$h$h$h$h$h$h$h$h$h$hh$h$h" - cat "$cache" "$HOME/etc/uri" + cat "$cache"/* "$HOME/etc/uri" } | iomenu -# | cut -f 2-)" diff --git a/bin/pack b/bin/pack @@ -66,6 +66,6 @@ case "$1" in (*) echo "usage: pack tar | git | get | build | add | del <package>" echo "" - COLUMNS=80 ls "$PACK" + ls "$PACK" | column ;; esac diff --git a/bin/xdg-abduco b/bin/xdg-abduco @@ -2,6 +2,8 @@ # wrapper over abduco for supporting any length session names +# usage: xdg-abduco <command> <long-name> + [ "$ABDUCO_SOCKET_DIR" ] && dir="$ABDUCO_SOCKET_DIR/abduco/$USER" || dir="$HOME/.abduco" @@ -14,19 +16,19 @@ grep -e "^$(abduco | sed -rn 's/.* ([0-9]+)$/\1/p') " "$dir/names" | sort -k2 -uo "$dir/names" # get the reas path name -! [ -h "$1" ] || set -- "$(readlink -f "$1")" -! [ -e "$1" ] || set -- "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")" -! [ -d "$1" ] || set -- "$(cd "$1"; pwd)" +! [ -h "$2" ] || set -- "$1" "$(readlink -f "$2")" +! [ -e "$2" ] || set -- "$1" "$(cd "$(dirname "$2")"; pwd)/$(basename "$2")" +! [ -d "$2" ] || set -- "$1" "$(cd "$2"; pwd)" case "$#" in (0) cut -f 2 "$dir/names" ;; -(1) - printf '\033]0;%s\a' "$1" 1>&2 +(2) + printf '\033]0;%s\a' "$2" 1>&2 - hash="$(printf %s "$1" | cksum | cut -d ' ' -f 1)" - printf '%s\t%s\n' "$hash" "$1" >> "$dir/names" - [ "$ABDUCO" ] || ABDUCO="$1" exec abduco -A "$hash" xdg-open "$1" + hash="$(printf %s "$2" | cksum | cut -d ' ' -f 1)" + printf '%s\t%s\n' "$hash" "$2" >> "$dir/names" + [ "$ABDUCO" ] || ABDUCO="$2" exec abduco -A "$hash" "$@" ;; esac diff --git a/bin/xdg-open b/bin/xdg-open @@ -10,7 +10,7 @@ ;; esac -[ "$ABDUCO" ] || exec xdg-abduco "$@" +[ "$ABDUCO" ] || exec xdg-abduco xdg-open "$@" # [scheme://][user[:pass]@]host[:port][/path] IFS=' ' read scheme user pass host port path << EOF @@ -54,12 +54,22 @@ BEGIN { } path = URI; + if (match(path, "^/") == 0) + path = ""; sub("[#?].*", "", path); printf("%s\t%s\t%s\t%s\t%s\t%s", scheme, user, pass, host, port, path); }') EOF +case "$scheme" in +(ssh) + [ "$port" = . ] && port="" || port="-P $port" + [ "$user" = . ] && user="" || user="$user@" + [ "$pass" = . ] && pass="" || pass="$" + ;; +esac + case "$host" in (*.onion) [ "$TOR" ] || TOR="$1" exec torsocks xdg-open "$1" @@ -180,9 +190,32 @@ case "$1" in [ "$port" = . ] && port='22' exec sftp -P "$port" "$host" ;; +(ssh://*/*.pdf) + ssh $port "$user$host" xz -c - "$path" | xz -d - | mupdf /dev/stdin & + exit ;; +(ssh://*/*.ff) + ssh $port "$user$host" xz -c - "$path" | xz -d - | lel + exit ;; +(ssh://*/*.png|ssh://*/*.PNG) + ssh $port "$user$host" png2ff '<' "$path"| xz -c -" | xz -d - | lel + exit ;; +(ssh://*/*.jpg|ssh://*/*.jpeg|ssh://*/*.JPG|ssh://*/*.JPEG) + ssh $port "$user$host" jpg2ff '<' "$path" | xz -c -" | xz -d - | lel + exit ;; +(ssh://*/*.opus|ssh://*/*.flac|ssh://*/*.ogg|ssh://*/*.vorbis|ssh://*/*.wav) + ssh $port "$user$host" "opusenc '$path' -" #| ffplay - + exit ;; +(ssh://*/*.webm|ssh://*/*.mp4|ssh://*/*.mkv|ssh://*/*.ogv|ssh://*/*.avi) + ssh $port "$user$host" cat "$path" | ffplay - + exit ;; +(ssh://*/*.[0-9]|ssh://*/*.[0-9]p|ssh://*/ssh://*/*.[0-9].gz) + ssh $port "$user$host" mandoc -T utf8 "$path" | less + exit ;; +(ssh://*/*) + exec ssh $port "$user$host" "\$EDITOR '$path'" + ;; (ssh://*) - [ "$port" = . ] && port='22' - exec ssh -p "$port" "${1#*://}" + exec ssh $port "$user$host" ;; (telnet://*) exec telnet "$port" "$host"