summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroxnz <yunxinyi@gmail.com>2013-10-16 16:43:03 +0800
committeroxnz <yunxinyi@gmail.com>2013-10-16 16:43:03 +0800
commit500e5a73b61b063f83e1eecbf424e4b3733e59b7 (patch)
tree676b738a20c5199e875d2e91c788aeead7443cfa
parentc79e5a97a906457d1778197bd4f29640d1917201 (diff)
downloadzsh-500e5a73b61b063f83e1eecbf424e4b3733e59b7.tar.gz
zsh-500e5a73b61b063f83e1eecbf424e4b3733e59b7.tar.bz2
zsh-500e5a73b61b063f83e1eecbf424e4b3733e59b7.zip
add itunes function to control itnues from the terminal
-rw-r--r--plugins/osx/osx.plugin.zsh34
1 files changed, 34 insertions, 0 deletions
diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh
index dd785f911..608ec3789 100644
--- a/plugins/osx/osx.plugin.zsh
+++ b/plugins/osx/osx.plugin.zsh
@@ -157,3 +157,37 @@ function trash() {
function vncviewer() {
open vnc://$@
}
+
+# iTunes control function
+function itunes() {
+ local opt=$1
+ shift
+ case "$opt" in
+ launch|play|pause|stop|rewind|resume|quit)
+ ;;
+ mute)
+ opt="set mute to true"
+ ;;
+ unmute)
+ opt="set mute to false"
+ ;;
+ next|previous)
+ opt="$opt track"
+ ;;
+ ""|-h|--help)
+ echo "Usage: itunes <option>"
+ echo "option:"
+ echo "\tlaunch|play|pause|stop|rewind|resume|quit"
+ echo "\tmute|unmute\tcontrol volume set"
+ echo "\tnext|previous\tplay next or previous track"
+ echo "\thelp\tshow this message and exit"
+ return 0
+ ;;
+ *)
+ print "Unkonwn option: $opt"
+ return 1
+ ;;
+ esac
+ osascript -e "tell application \"iTunes\" to $opt"
+}
+