Advertisement
alexs77

Shorten-URL Script w/ notify

Sep 26th, 2011
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.90 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. # Verkürze die übergebene URL mit Hilfe eines Scripts
  4. # und "speichere" die Short URL in der Zwischenablage
  5.  
  6. # Short URL Script
  7. shorl="$HOME/bin/is.gd"
  8. shorl="$HOME/bin/x.co"
  9.  
  10. # Holen:
  11. # xclip -out -selection clipboard
  12. # Setzen:
  13. # echo foo | xclip -in -selection clipboard
  14.  
  15. # Welche X Clipboard Selection soll bearbeitet werden?
  16. # Werte: "primary", "secondary", "clipboard" or "buffer-cut"
  17. selection="clipboard"
  18.  
  19. # Wurde Text auf der Kommandozeile uebergeben?
  20. if [[ "$#" -eq 0 ]]; then
  21.   # Hole Text aus der Zwischenablage
  22.   clip=$( xclip -out -selection $selection )
  23. else
  24.   # Text von der Kommandozeile nehmen
  25.   clip="$@"
  26. fi
  27.  
  28. # Rufe Short URL Script auf und "speichere" Short URL im Clipboard
  29. short=$( "$shorl" "$clip" )
  30. printf '%s' "$short" | xclip -in -selection $selection
  31. printf "%s\n" "$short"
  32.  
  33. notifyme.sh "URL gekürzt" "URL $clip zu $short gekürzt"
  34.  
  35. exit $?
  36. # EOF #
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement