diff --git a/home/-shrc b/home/-shrc index d03091c..be0a3cc 100644 --- a/home/-shrc +++ b/home/-shrc @@ -144,3 +144,4 @@ unset cdrive [ -e ~/sh/z/z.sh ] && . ~/sh/z/z.sh . ~/.streamcrap +. ~/.ea diff --git a/home/ea b/home/ea new file mode 100644 index 0000000..f93ac42 --- /dev/null +++ b/home/ea @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# remote file access (http file-sharing shenanigans) + +_REMOTE_DOMAIN="https://eaguru.guru" +_REMOTE_DIR="t" +_REMOTE_AUTH="auth" + +eahead() { + curl -I "$_REMOTE_DOMAIN/$_REMOTE_DIR/$1" +} + +eaput() { + curl -n -T "$1" "$_REMOTE_DOMAIN/$_REMOTE_AUTH/" +} + +eamove() { + local src="$_REMOTE_DOMAIN/$_REMOTE_AUTH/$1" + local dst="$_REMOTE_DOMAIN/$_REMOTE_DIR/$2" + curl -n -X MOVE -H "Destination: $dst" "$src" +} + +eacopy() { + local src="$_REMOTE_DOMAIN/$_REMOTE_AUTH/$1" + local dst="$_REMOTE_DOMAIN/$_REMOTE_DIR/$2" + curl -n -X COPY -H "Destination: $dst" "$src" +} + +eadelete() { + curl -n -X DELETE "$_REMOTE_DOMAIN/$_REMOTE_AUTH/$1" +} + +alias eamv=eamove +alias eacp=eacopy +alias earm=eadelete diff --git a/install b/install index c83451f..3b69813 100755 --- a/install +++ b/install @@ -101,7 +101,7 @@ PATH="${PATH:?No existing PATH}:$rc/sh" backup_dir="$rc/backup-$(date '+%s')" -for f in .bashrc .zshrc .-shrc .streamcrap .vimrc \ +for f in .bashrc .zshrc .-shrc .streamcrap .ea .vimrc \ .inputrc .Xresources .screenrc .indent.pro .uncrustify.cfg; do dotless "$f" r="$rc/home/$REPLY" diff --git a/sh/sc b/sh/sc index ca18313..5cc9e4c 100755 --- a/sh/sc +++ b/sh/sc @@ -1,8 +1,5 @@ #!/usr/bin/env bash -: ${SC_DBD:="/home/$USER/Dropbox"} -: ${SC_DBS:="$SC_DBD/Public/screenshots"} -: ${SC_DBT:="$SC_DBD/Public/temp"} -: ${SC_DOM:="https://eaguru.guru"} +. ~/.ea sc_shorten() { REPLY="${1:2:2}${1:5:2}${1:8:2}${1:11:12}" @@ -20,23 +17,20 @@ copy_scr() { local r='20\d\d-\d\d-\d\d_\d\d\d\d\d\d\d\d.(png|jpg)' grep -Pq "$r" <<<"$short" || return 1 - cp "$fn" "$SC_DBS/" + eaput "$fn" "$short" sc_shorten "$short" uri_encode "$REPLY" - REPLY="$SC_DOM/s/$REPLY" + REPLY="$_REMOTE_DOMAIN/s/$REPLY" return 0 } copy_tmp() { local fn="$1" - local dlen=${#SC_DBT} - if [ "${fn:0:dlen}" != "${SC_DBT}" ]; then - cp "$fn" "$SC_DBT/" - fi local short="$(basename "$fn")" + eaput "$fn" "$short" uri_encode "$short" - REPLY="$SC_DOM/t/$REPLY" + REPLY="$_REMOTE_DOMAIN/t/$REPLY" return 0 }