configuration/local/bin/push.sh

28 lines
701 B
Bash
Raw Normal View History

2015-01-05 17:15:23 +01:00
#!/bin/bash
# Thanks to noctua for the base script
# Thanks to Iasoon for the advanced ssh config parsing
set -e
sshhost="Flesje"
2016-01-10 19:55:38 +01:00
fles="http://t2-wan.be"
port="7070"
2015-01-05 17:15:23 +01:00
# Find ssh username
user=$(
# Join config entries
sed -n '$!{/host /I!{H;d}};x;s/\n/ /g;p' $HOME/.ssh/config |
# Extract user/host combinations
2016-01-10 19:55:38 +01:00
grep -i 'user' | tr -s ' ' ' ' |
2015-01-05 17:15:23 +01:00
sed 's/^.*host \([^ \t]\+\).*user \([^ \t]\+\).*$/\1 \2/I' |
# Find user
(grep "^$sshhost" || echo $USER) | cut -d ' ' -f 2 )
2016-01-10 19:55:38 +01:00
2015-01-05 17:15:23 +01:00
file="$(mktemp XXXXXX.png)"
2015-04-14 17:11:28 +02:00
escrotum $* "$file"
2016-01-10 19:55:38 +01:00
chmod 644 $file
2015-01-05 17:15:23 +01:00
scp -p $file $sshhost:~/images/
rm "$file"
2016-01-10 19:55:38 +01:00
url="$fles:$port/~$user/$file"
2015-01-05 17:15:23 +01:00
notify-send "Screenshot uploaded to $url"
echo "$url" | xclip