Skip to content

Instantly share code, notes, and snippets.

@claus
Created September 11, 2018 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claus/49847a232c4694e72ad23f4aa060c6b7 to your computer and use it in GitHub Desktop.
Save claus/49847a232c4694e72ad23f4aa060c6b7 to your computer and use it in GitHub Desktop.
MacOS: capture screenshot and add it to IPFS
# 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