Advertisement
Guest User

Untitled

a guest
Aug 16th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.68 KB | None | 0 0
  1. xo() {
  2. xo_exit() {
  3.     disown
  4.     exit
  5. }
  6. case "$1" in
  7.     g:*)
  8.         exo-open "https://www.google.ru/search?q=`echo $* | sed 's/g\://'`" &
  9.         xo_exit
  10.     ;;
  11.     w:*)
  12.         exo-open "https://ru.wikipedia.org/wiki/`echo $* | sed 's/w\://'`" &
  13.         xo_exit
  14.     ;;
  15. esac
  16. if (( $+commands[$1] ))
  17. then
  18.     $* &
  19.     xo_exit
  20. elif [ -e "$1" ]
  21. then
  22.     if [ -x "$1" ] && [ ! -d "$1" ]
  23.     then
  24.         if [[ "$(dirname $1)" = "." ]]
  25.         then
  26.             ./$* &
  27.             xo_exit
  28.         else
  29.             $* &
  30.             xo_exit
  31.         fi
  32.     else
  33.         exo-open "$1" &
  34.         xo_exit
  35.     fi
  36. else
  37.     exo-open "$1" &
  38.     xo_exit
  39. fi
  40. }
  41.  
  42. _xo()
  43. {
  44. _arguments '1: : _alternative "commands\:commands\: _command_names -e" "files\:files\:_files"' '*:: : _normal';
  45. };
  46.  
  47. compdef _xo xo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement