summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorRobby Russell <robby@planetargon.com>2015-09-27 12:40:31 -0700
committerRobby Russell <robby@planetargon.com>2015-09-27 12:40:31 -0700
commita51a9169a9c53da455056906735589a7ec69a240 (patch)
tree701a9c0db008aeae8abfdf8795a40a501ad6a939 /plugins
parent9e291033d996d7672745a19bb794104ffd0a084e (diff)
parent326c2b08593e9b02da149dcc0d3c5cf99b21d3a2 (diff)
downloadzsh-a51a9169a9c53da455056906735589a7ec69a240.tar.gz
zsh-a51a9169a9c53da455056906735589a7ec69a240.tar.bz2
zsh-a51a9169a9c53da455056906735589a7ec69a240.zip
Merge pull request #4348 from andybateman/patch-1
Display song currently playing in iTunes
Diffstat (limited to 'plugins')
-rw-r--r--plugins/osx/osx.plugin.zsh12
1 files changed, 12 insertions, 0 deletions
diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh
index 2cbb95977..a1516dcce 100644
--- a/plugins/osx/osx.plugin.zsh
+++ b/plugins/osx/osx.plugin.zsh
@@ -167,6 +167,17 @@ function itunes() {
vol)
opt="set sound volume to $1" #$1 Due to the shift
;;
+ playing|status)
+ local state=`osascript -e 'tell application "iTunes" to player state as string'`
+ if [[ "$state" = "playing" ]]; then
+ currenttrack=`osascript -e 'tell application "iTunes" to name of current track as string'`
+ currentartist=`osascript -e 'tell application "iTunes" to artist of current track as string'`
+ echo -E "Listening to $fg[yellow]$currenttrack$reset_color by $fg[yellow]$currentartist$reset_color";
+ else
+ echo "iTunes is" $state;
+ fi
+ return 0
+ ;;
shuf|shuff|shuffle)
# The shuffle property of current playlist can't be changed in iTunes 12,
# so this workaround uses AppleScript to simulate user input instead.
@@ -205,6 +216,7 @@ EOF
echo "\tnext|previous\tplay next or previous track"
echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
echo "\tvol\tSet the volume, takes an argument from 0 to 100"
+ echo "\tplaying|status\tShow what song is currently playing in iTunes."
echo "\thelp\tshow this message and exit"
return 0
;;