Created
September 11, 2018 00:16
-
-
Save claus/49847a232c4694e72ad23f4aa060c6b7 to your computer and use it in GitHub Desktop.
MacOS: capture screenshot and add it to IPFS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Exit on errors | |
set -e | |
set -o pipefail | |
# Filename of captured image | |
FILE="$(date +%Y-%m-%d-%H-%M-%S).png" | |
# User/host | |
HOST="user@xx.xxx.xxx.xxx" | |
# Capture screen (interactively) and save image to the desktop | |
screencapture -i ~/Desktop/$FILE | |
# Upload the captured image to the server | |
scp -qC ~/Desktop/$FILE $HOST:/home/ipfs/ | |
# SSH into server and, as user ipfs, add image to IPFS | |
# Store the returned CID into the variable $CID | |
CID=$(ssh $HOST "su ipfs -c 'ipfs add -Q /home/ipfs/$FILE'") | |
# Clean up | |
ssh $HOST "rm /home/ipfs/$FILE" | |
# Put gateway URL of the added image on the clipboard | |
echo "https://ipfs.io/ipfs/$CID" | pbcopy | |
# Bloop | |
afplay /System/Library/Sounds/Sosumi.aiff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment