1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2025-02-05 07:43:22 -08:00

add http file stuff; update sc accordingly

This commit is contained in:
Connor Olding 2017-03-03 07:24:01 +00:00
parent 4cded095fe
commit 7caa55f2bc
4 changed files with 41 additions and 12 deletions

View file

@ -144,3 +144,4 @@ unset cdrive
[ -e ~/sh/z/z.sh ] && . ~/sh/z/z.sh
. ~/.streamcrap
. ~/.ea

34
home/ea Normal file
View file

@ -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

View file

@ -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"

16
sh/sc
View file

@ -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
}