aboutsummaryrefslogtreecommitdiffstats
path: root/.config/init/funcs
diff options
context:
space:
mode:
authorkatherine <shmibs@shmibbles.me>2016-03-19 23:33:35 -0700
committerkatherine <shmibs@shmibbles.me>2016-03-19 23:33:35 -0700
commit549c206bb8c3a9434294c2064eb25c149fee18bc (patch)
treed8fca84a86bdcf1cd5a11b989a5761c096e81e52 /.config/init/funcs
parente92af1f7088cc5b6b40a5ceba275a197c305de62 (diff)
downloaddotfiles-549c206bb8c3a9434294c2064eb25c149fee18bc.tar.gz
clean send
was a bit ad-hoc; hopefully cleaner to read now
Diffstat (limited to '.config/init/funcs')
-rwxr-xr-x.config/init/funcs/send62
1 files changed, 30 insertions, 32 deletions
diff --git a/.config/init/funcs/send b/.config/init/funcs/send
index 88b3dbb..e88c8aa 100755
--- a/.config/init/funcs/send
+++ b/.config/init/funcs/send
@@ -1,5 +1,5 @@
#!/bin/zsh
-# quickly send a file to hosted tmp dir
+# quickly send a file to hosted /tmp/ dir
local name
local basename
@@ -12,37 +12,35 @@ escapes=(' ' '%20' '"' '%22' '#' '%23' '$' '%24'
'@' '%40' '[' '%5b' '\' '%5c' ']' '%5d'
'^' '%5e' '`' '%60' '{' '%7b' '|' '%7c'
'}' '%7d' '~' '%7e')
-if [[ "$1" ]]; then
- for i in "$@"; do
- [[ -f "$i" ]] \
- || { echo "file '$i' not found"; return 1 }
- done
- scp "$@" shmibbles.me:http/tmp/ >/dev/null 2>&1 \
- || { echo "sending files failed"; return 1 }
- if [[ $? -eq 0 ]]; then
- for name in "$@"
- do
- basename=${name:t}
- ssh shmibbles.me "cd http/tmp; chmod o+r \"${basename//\"/\\\"}\""
- if [[ $? -eq 0 ]]; then
- {
- printf "%s" 'https://shmibbles.me/tmp/'
- for c in "${(s::)basename}"; do
- if [[ "${escapes[$c]}" == "" ]]; then
- printf "%s" "$c"
- else
- printf "%s" "${escapes[$c]}"
- fi
- done
- } | tee >(xclip -i -selection clipboard) \
- | xclip -i -selection primary
+
+[[ "$1" ]] \
+ || { echo "please specify at least one file to send"; return 1 }
+
+for i in "$@"; do
+ [[ -f "$i" ]] \
+ || { echo "file '$i' not found"; return 1 }
+done
+
+scp "$@" shmibbles.me:http/tmp/ 2>/dev/null \
+ || { echo "sending files failed"; return 1 }
+
+for name in "$@"
+do
+ basename=${name:t}
+
+ ssh shmibbles.me "cd http/tmp; chmod o+r \"${basename//\"/\\\"}\"" \
+ || { echo "making '$name' readable failed"; return 1 }
+
+ {
+ printf "%s" 'https://shmibbles.me/tmp/'
+ for c in "${(s::)basename}"; do
+ if [[ "${escapes[$c]}" == "" ]]; then
+ printf "%s" "$c"
else
- echo "making '$name' readable failed"
- return 1
+ printf "%s" "${escapes[$c]}"
fi
done
- fi
-else
- echo "specify at least one file to send"
- return 1
-fi
+ } | tee \
+ >(xclip -i -selection clipboard) \
+ >(xclip -i -selection primary) >/dev/null
+done