Advertisement
nasarouf

.bashrc : : snapshare

Aug 10th, 2017
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.36 KB | None | 0 0
  1. # snapshare
  2. # this bash snippet lets you quickly take screenshots and share them. See code for details
  3.  
  4. # usage:
  5. #   snapshare
  6.  
  7. # prereq/installation (update path accordingly):
  8.  
  9.     # setting up the environment
  10.     sudo apt install shutter      # screenshotting
  11.     sudo apt install xclip        # for copying published url to clipboard directly
  12.     sudo apt install imagemagick  # for converting from png to jpg
  13.     sudo apt install exiftool     # embedding EXIF info in jpegs
  14.     cd ~/Downloads
  15.     wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
  16.     sudo tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz
  17.     go get -u github.com/odeke-em/drive/cmd/drive
  18.     mkdir ~/software
  19.     cd ~/software
  20.     git clone https://github.com/odeke-em/drive.git
  21.     cd ~/software/drive
  22.     make all
  23.  
  24.     # setting up your gdrive:
  25.     mkdir ~/gdrive
  26.     cd ~/gdrive
  27.     drive init # you will need to use a browser to log in using the url it prints and paste the code
  28.     mkdir p
  29.     cd p
  30.     drive push
  31.  
  32.     # run this if you'd like this to work on your current session:
  33.     source ~/.bashrc
  34.  
  35.  
  36.  
  37. # add the following to your .bashrc
  38. # go
  39. export PATH=$PATH:/usr/local/go/bin
  40. # drive
  41. alias drive="~/software/drive/bin/drive_linux"
  42. # code to initiate a screenshot, sync the resulting file and publish it
  43. function putscan() {
  44.     names=( $@ ) ;
  45.     # find the latest screenshot file
  46.     # note: a certain path has been assumed
  47.     filename=`ls ${names[@]} | sort -r | head -1` ;
  48.     # hashing is not necessary but looks cool lol
  49.     # hostname is used so that there  
  50.     outfile=~/gdrive/p/$(echo "`cat /etc/hostname`$filename" | md5sum | cut -c1-8).jpg ;
  51.     convert "$filename" -quality 100 "$outfile" ;
  52.     # push to cloud. the flag -no-prompt suppresses the confirmation
  53.     drive push -no-prompt "$outfile" ;  
  54.     # echo "infile=$filename outfile=$outfile" ;
  55.     # publish
  56.     push_res=$(drive pub "$outfile") ;
  57.     echo $push_res | cut -d ' ' -f 4 | xclip -selection clipboard ;
  58.     echo $push_res ;  # in case the xclip copy fails
  59. }
  60. export -f putscan
  61. # shutter -s (=select) -e (=exit right after)
  62. alias snapshare='shutter -s -e && putscan ~/Pictures/Sel*.png'
  63.  
  64. export PATH=$PATH:/home/nasa/bin
  65.  
  66. 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