Advertisement
infodox

nyan.sh

Nov 14th, 2011
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.18 KB | None | 0 0
  1. #!/bin/bash
  2. # TOTALLY POINTLESS NYANCAT SCRIPT
  3. # config
  4. IMGS=(
  5. "
  6. +      o     +              o    \n\
  7.     +             o     +       +\n\
  8. o          +                     \n\
  9.     o  +           +        +    \n\
  10. +        o     o       +        o\n\
  11. -_-_-_-_-_-_-_,------,      o    \n\
  12. _-_-_-_-_-_-_-|   /\_/\          \n\
  13. -_-_-_-_-_-_-~|__( ^ .^)  +     +\n\
  14. _-_-_-_-_-_-_-\"\"  \"\"         \n\
  15. +      o         o   +       o   \n\
  16.     +         +                  \n\
  17. o        o         o      o     +\n\
  18.     o           +                \n\
  19. +      +     o        o      +   \n
  20. " "
  21.     o  +           +        +    \n\
  22. o          +                    o\n\
  23.     o                 +          \n\
  24. +      o     +              o    \n\
  25.  o     +        o               +\n\
  26. _-_-_-_-_-_-_-,------,  o      + \n\
  27. -_-_-_-_-_-_-_|   /\_/\    +     \n\
  28. _-_-_-_-_-_-_~|__( ^ .^)     o   \n\
  29. -_-_-_-_-_-_-_  \"\"  \"\"       \n\
  30. +      +     o        o      +   \n\
  31. o        +                o     +\n\
  32. +      o         +     +       o \n\
  33.     +         +                  \n\
  34.        +           o        +    \n
  35. " )
  36. REFRESH="0.5"
  37. AUDIO_FILE="/tmp/nyan-cat.mp3"
  38. # end
  39.  
  40. # count lines of first ascii picture in array
  41. LINES_PER_IMG=$(( $(echo $IMGS[0] | sed 's/\\n/\n/g' | wc -l) + 1 ))
  42.  
  43. # tput $1 LINES_PER_IMG times, used for cuu1(cursor up) cud1(cursor down)
  44. tput_loop() { for((x=0; x < $LINES_PER_IMG; x++)); do tput $1; done; }
  45.  
  46. # ^C abort, script cleanup
  47. trap sigtrap INT
  48. sigtrap()
  49.     {
  50.     # make cursor visible again
  51.     tput cvvis
  52.  
  53.     # reset cursor
  54.     tput_loop "cud1"
  55.  
  56.     # stop audio
  57.     #kill `pgrep vlc`
  58.     #kill `pgrep mplayer` 2&> /dev/null
  59.  
  60.     echo "caught signal SIGINT(CTRL+C), quitting ..."
  61.     exit 1
  62.     }
  63.  
  64. # need multi-space strings
  65. IFS='%'
  66.  
  67. # start audio, vlc & mplayer examples
  68. #vlc $AUDIO_FILE --quiet --loop --volume=100 &
  69. #mplayer -really-quiet -loop 0 $AUDIO_FILE < /dev/null &
  70.  
  71. # hide the cursor
  72. tput civis
  73.  
  74. # main loop, pretty self explanatory
  75. while [ 1 ]; do for x in "${IMGS[@]}"; do
  76.     echo -ne $x
  77.     tput_loop "cuu1"
  78.     sleep $REFRESH
  79. done; done
  80.  
  81. # will never reach here, CTRL+C is required to quit
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement