Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # snapshare
- # this bash snippet lets you quickly take screenshots and share them. See code for details
- # usage:
- # snapshare
- # prereq/installation (update path accordingly):
- # setting up the environment
- sudo apt install shutter # screenshotting
- sudo apt install xclip # for copying published url to clipboard directly
- sudo apt install imagemagick # for converting from png to jpg
- sudo apt install exiftool # embedding EXIF info in jpegs
- cd ~/Downloads
- wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
- sudo tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz
- go get -u github.com/odeke-em/drive/cmd/drive
- mkdir ~/software
- cd ~/software
- git clone https://github.com/odeke-em/drive.git
- cd ~/software/drive
- make all
- # setting up your gdrive:
- mkdir ~/gdrive
- cd ~/gdrive
- drive init # you will need to use a browser to log in using the url it prints and paste the code
- mkdir p
- cd p
- drive push
- # run this if you'd like this to work on your current session:
- source ~/.bashrc
- # add the following to your .bashrc
- # go
- export PATH=$PATH:/usr/local/go/bin
- # drive
- alias drive="~/software/drive/bin/drive_linux"
- # code to initiate a screenshot, sync the resulting file and publish it
- function putscan() {
- names=( $@ ) ;
- # find the latest screenshot file
- # note: a certain path has been assumed
- filename=`ls ${names[@]} | sort -r | head -1` ;
- # hashing is not necessary but looks cool lol
- # hostname is used so that there
- outfile=~/gdrive/p/$(echo "`cat /etc/hostname`$filename" | md5sum | cut -c1-8).jpg ;
- convert "$filename" -quality 100 "$outfile" ;
- # push to cloud. the flag -no-prompt suppresses the confirmation
- drive push -no-prompt "$outfile" ;
- # echo "infile=$filename outfile=$outfile" ;
- # publish
- push_res=$(drive pub "$outfile") ;
- echo $push_res | cut -d ' ' -f 4 | xclip -selection clipboard ;
- echo $push_res ; # in case the xclip copy fails
- }
- export -f putscan
- # shutter -s (=select) -e (=exit right after)
- alias snapshare='shutter -s -e && putscan ~/Pictures/Sel*.png'
- export PATH=$PATH:/home/nasa/bin
- alias gitlog="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement