Advertisement
shiftdot515

tweetpaste

Jan 3rd, 2017
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.97 KB | None | 0 0
  1. #!/var/bin/mksh
  2. integer chars
  3. X="$(cat)"
  4. chars=$(wc -c <<<"$X")
  5. #print "$chars"
  6. if (( chars > 140 ))
  7. then
  8.     pbcopy <<< " "
  9.     print " over 140 by $(( 140 - chars ))"
  10.     return 1;
  11. elif (( chars < 2 ))
  12. then
  13.     pbcopy <<< " "
  14.     print " too short!"
  15.     return 2
  16. fi
  17.  
  18. # tried with w/o case too many WTFs to/from me!
  19. # SO to a fav 4 me!
  20. case "$1" in
  21.   ""|-)  # match mothing or -
  22.     # translate newlines to spaces
  23.     tr '\012' ' ' <<< "$X" | pbcopy
  24.     #print 1
  25.     ;;
  26.   *) # matchs anything especially "raw" or +
  27.     pbcopy <<< "$X"
  28.     #print 2
  29.     ;;
  30. esac    
  31. shift 2>/dev/null||exit
  32. #why shift? SO I CAN CUT&PASTE
  33.  
  34.  
  35. SPLAT="
  36. Hi"
  37. case "$1" in
  38.   ""|nosave|nosave|-) # match that
  39.     #print 3
  40.     ;;
  41.   *) # CATCH ALL especially "save or +
  42.     #append tweet to daily file in /tmp/
  43.     cat <<< "${X}$SPLAT" >> /tmp/tweetpaste.$(date '+%j')
  44.     print 4
  45.     ;;
  46. esac
  47. shift 2>/dev/null||exit
  48. #MADEWITH Obama #ASPRESIDENT
  49. #NOTWITH #notmypresident
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement