分类:
2008-12-12 03:50:44
#!/bin/bash # # SCRIPT: music # # AUTHOR: lizeliang # # DATE: 11.5.2008 # # REV: 1.0.A # # PLATFROM: Linux/Unix # # PORPOSE: play music only use a command # # REV LIST: # DATE: 11.11.2008 # BY: lizeliang # MODIFICATION: fix some bugs:-) # # Initialize all variable ############################################################################### ########## DEFINE FILES AND VARIABLES HERE #################################### ############################################################################### DEFAULT=wuti ############################################################################### ########## DEFINE FUNCTIONS HERE ############################################## ############################################################################### #echo $DEFAULT ;debug play_back(){ if [ $1 = "DEFAULT" ];then #echo $1 ;debug cd $DEFAULT #echo $DEFAULT ;debug fi echo -e "Now we begian play back music ..." mplayer *.wma *mp3 } chice_path(){ while true do echo -e "Please input the music's path: \c" read path if [ $path == 'q' ];then exit 0 fi for var in `ls` do if [ $var = $path ];then #a bug such when "Soft music"..!!! cd $path break fi done if [ $var = $path ];then break fi echo -e "$path :No such path ..." done } chice_path_again(){ cd ~/Music || cd ~/音乐 ls while true do echo -e "Play over, Please chice path again: \c" read path if [ $path == 'q' ];then exit 0 fi if [ -z $path ]; then play_back DEFAULT chice_path_again fi for var in `ls` do if [ $var = $path ];then cd $path break fi done if [ $var = $path ];then break elif [ $path = 'DEFAULT' ]; then #do with Enter!!! cd $DEFAULT break elif [ -z $path ]; then cd $DEFAULT break fi echo -e "$path :No such path ..." done } ############################################################################### ########## BEGIAN OF MAIN ##################################################### ############################################################################### cd ~/Music || cd ~/音乐 echo -e "You have such music path:" ls while true do if [ $# -eq 0 ];then play_back DEFAULT chice_path_again elif [ $# -eq 1 ];then #echo $1 ;debug if [ -a $1 ];then cd $1 echo -e "Now we begian play back music ..." mplayer *.wma *mp3 else echo -e "No such directory ..." exit 0 fi echo -e "You have such music path:" ls #chice_path play_back chice_path_again else echo -e "Usage: music [dirname]: only one option.\n" exit 1 fi done cd - exit 0 # End of script#!/bin/bash |
$echo "alias music=\"/bin/bash ~/.music/music.sh\"">>~/.bashrc |