alexs77

Shorten-URL Script

Sep 26th, 2011
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.04 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.  
  9. # Holen:
  10. # xclip -out -selection clipboard
  11. # Setzen:
  12. # echo foo | xclip -in -selection clipboard
  13.  
  14. # Welche X Clipboard Selection soll bearbeitet werden?
  15. # Werte: "primary", "secondary", "clipboard" or "buffer-cut"
  16. selection="clipboard"
  17.  
  18. # Wurde Text auf der Kommandozeile uebergeben?
  19. if [[ "$#" -eq 0 ]]; then
  20.   # Hole Text aus der Zwischenablage
  21.   clip=$( xclip -out -selection $selection )
  22.   printf "$(date +%Y-%m-%d--%H:%M:%S): $$: Hole Clipboard mit xclip aus selection $selection. Inhalt: %s\n" "$clip" >> $l
  23. else
  24.   # Text von der Kommandozeile nehmen
  25.   clip="$@"
  26.   printf "$(date +%Y-%m-%d--%H:%M:%S): $$: Hole Clipboard von Kommandozeile. Inhalt: %s\n" "$clip" >> $l
  27. fi
  28.  
  29. # Rufe Short URL Script auf und "speichere" Short URL im Clipboard
  30. short=$( "$shorl" "$clip" )
  31. printf '%s' "$short" | xclip -in -selection $selection
  32. printf "%s\n" "$short"
  33.  
  34. exit $?
  35. # EOF #
  36.  
Advertisement
Add Comment
Please, Sign In to add comment