diff options
Diffstat (limited to '.local')
-rwxr-xr-x | .local/bin/rupload | 28 | ||||
-rwxr-xr-x | .local/bin/rws | 4 |
2 files changed, 26 insertions, 6 deletions
diff --git a/.local/bin/rupload b/.local/bin/rupload index 925fc0e..61db5cf 100755 --- a/.local/bin/rupload +++ b/.local/bin/rupload @@ -1,13 +1,17 @@ #!/bin/sh if [ $# -eq 0 ]; then - printf '%s\n' "usage: $0 [-n] [-x override_ext] <filename>" >&2 + printf '%s\n' "usage: $0 [-n] [-x EXT | -r NAME | -R] FILENAME" >&2 printf '\t%s\n' "-n: dry run (don't actually upload anything)" >&2 - printf '\t%s\n' "-x override_ext: set extension to override_ext on uploaded filename" >&2 + printf '\t%s\n' "-x EXT: set extension to EXT on uploaded filename" >&2 + printf '\t%s\n' "-r NAME: set remote name to NAME including extension" >&2 + printf '\t%s\n' "-R: set remote name to basename of FILENAME" >&2 exit 1 fi dry_run=0 +samename=0 +override_rname= while [ $# -gt 1 ]; do if [ "$1" = "-x" ]; then override_ext=".$2" @@ -15,6 +19,15 @@ while [ $# -gt 1 ]; do elif [ "$1" = "-n" ]; then dry_run=1 shift + elif [ "$1" = "-r" ]; then + override_rname="$2" + shift 2 + elif [ "$1" = "-R" ]; then + samename=1 + shift + else + printf "%s: unrecognized argument %s\n" "$0" "$1" + exit 2 fi done @@ -23,6 +36,10 @@ if [ ! -f "$1" ]; then exit 1 fi +if [ "$samename" -eq 1 ]; then + override_rname="$(basename "$1")" +fi + REMOTE="do" URLBASE="https://ubq323.website/files/" REMOTEDIR="/srv/web/ubq/files/" @@ -37,8 +54,8 @@ else fi ext=${override_ext:-$ext} -rbname="$(md5sum "$1"|cut -d' ' -f1|tr 'a-z' 'A-Z'|basenc -d --base16|basenc --base64|head -c8)" -rname="$rbname$ext" +rbname="$(md5sum "$1"|cut -d' ' -f1|tr 'a-z' 'A-Z'|basenc -d --base16|basenc --base64url|head -c8)" +rname="${override_rname:-$rbname$ext}" exists_already() { ssh "$REMOTE" stat "$REMOTEDIR$1" 2>/dev/null >/dev/null @@ -47,8 +64,7 @@ exists_already() { while exists_already "$rname"; do printf "%s exists already\n" "$rname" - rbname="${rbname}_" - rname="$rbname$ext" + rname="_$rname" done printf 'uploading to %s\n' "$rname" diff --git a/.local/bin/rws b/.local/bin/rws index ebee83c..7041e8c 100755 --- a/.local/bin/rws +++ b/.local/bin/rws @@ -54,6 +54,10 @@ gowork() { cd "$d" || return 1 fi } +renws () { + # renames current ws to current working dir + swaymsg "rename workspace to $(apwd)" +} queryws () { # uses bmenu to prompt for a workspace name, then switches to that workspace |