From 4762791fad362c8afe1c9a2b1c555c6a8d7b79d1 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Fri, 28 Apr 2023 02:28:29 +0100 Subject: th --- .bashrc | 11 ++++++++++- .local/bin/rupload | 24 +++++++++++++++++------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.bashrc b/.bashrc index 018ee89..fc22a7f 100644 --- a/.bashrc +++ b/.bashrc @@ -5,7 +5,8 @@ alias ls='ls --color=auto' alias grep='grep --color=auto' -PS1='\[\e[90m\][\u@\h \W]\$\[\e[0m\] ' +PROMPT_DIRTRIM=3 +PS1='\[\e[90m\][\u@\h \w]\$\[\e[0m\] ' shopt -s histappend HISTCONTROL=ignoreboth @@ -58,6 +59,14 @@ add_path () { export PATH="$1:$PATH" } +shed () { + # week year, week week + wy=$(date +%G) + ww=$(date +%V) + mkdir -p "$HOME/shed/$wy/w$ww" + cd "$HOME/shed/$wy/w$ww" +} + add_path ~/.local/bin . ~/.local/bin/rws diff --git a/.local/bin/rupload b/.local/bin/rupload index 61db5cf..c414b68 100755 --- a/.local/bin/rupload +++ b/.local/bin/rupload @@ -1,8 +1,9 @@ #!/bin/sh if [ $# -eq 0 ]; then - printf '%s\n' "usage: $0 [-n] [-x EXT | -r NAME | -R] FILENAME" >&2 + printf '%s\n' "usage: $0 [-n] [-p] [-x EXT | -r NAME | -R] FILENAME" >&2 printf '\t%s\n' "-n: dry run (don't actually upload anything)" >&2 + printf '\t%s\n' "-p: print uploaded url instead of copying to clipboard and notifying" >&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 @@ -11,6 +12,7 @@ fi dry_run=0 samename=0 +printurl=0 override_rname= while [ $# -gt 1 ]; do if [ "$1" = "-x" ]; then @@ -19,6 +21,9 @@ while [ $# -gt 1 ]; do elif [ "$1" = "-n" ]; then dry_run=1 shift + elif [ "$1" = "-p" ]; then + printurl=1 + shift elif [ "$1" = "-r" ]; then override_rname="$2" shift 2 @@ -26,7 +31,7 @@ while [ $# -gt 1 ]; do samename=1 shift else - printf "%s: unrecognized argument %s\n" "$0" "$1" + printf "%s: unrecognized argument %s\n" "$0" "$1" >&2 exit 2 fi done @@ -63,19 +68,24 @@ exists_already() { } while exists_already "$rname"; do - printf "%s exists already\n" "$rname" + printf "%s exists already\n" "$rname" >&2 rname="_$rname" done -printf 'uploading to %s\n' "$rname" +printf 'uploading to %s\n' "$rname" >&2 if [ "$dry_run" -eq 1 ]; then echo dryrun, not uploading anything exit 0 fi -scp "$1" "${REMOTE}:$REMOTEDIR$rname" +scp -q "$1" "${REMOTE}:$REMOTEDIR$rname" ssh "$REMOTE" chmod a+r "$REMOTEDIR$rname" url="$URLBASE$rname" -printf %s "$url" | wl-copy -notify-send 'copied url to clipboard' "$url" +if [ "$printurl" -eq 0 ]; then + printf %s "$url" | wl-copy + notify-send 'copied url to clipboard' "$url" +else + printf '%s\n' "$url" +fi + -- cgit v1.2.3