a51a9169a9c53da455056906735589a7ec69a240

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #4348 from andybateman/patch-1

Display song currently playing in iTunes

Diff

 1diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh
 2index 2cbb95977af17c2bc88a731b8e1e711e2139c860..a1516dcce88c74e912c22d3ef266e5260336f975 100644
 3--- a/plugins/osx/osx.plugin.zsh
 4+++ b/plugins/osx/osx.plugin.zsh
 5@@ -167,6 +167,17 @@ function itunes() {
 6 		vol)
 7 			opt="set sound volume to $1" #$1 Due to the shift
 8 			;;
 9+		playing|status)
10+			local state=`osascript -e 'tell application "iTunes" to player state as string'`
11+			if [[ "$state" = "playing" ]]; then
12+				currenttrack=`osascript -e 'tell application "iTunes" to name of current track as string'`
13+				currentartist=`osascript -e 'tell application "iTunes" to artist of current track as string'`
14+				echo -E "Listening to $fg[yellow]$currenttrack$reset_color by $fg[yellow]$currentartist$reset_color";
15+			else
16+				echo "iTunes is" $state;
17+			fi
18+			return 0
19+			;;
20 		shuf|shuff|shuffle)
21 			# The shuffle property of current playlist can't be changed in iTunes 12,
22 			# so this workaround uses AppleScript to simulate user input instead.
23@@ -205,6 +216,7 @@ EOF
24 			echo "\tnext|previous\tplay next or previous track"
25 			echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
26 			echo "\tvol\tSet the volume, takes an argument from 0 to 100"
27+			echo "\tplaying|status\tShow what song is currently playing in iTunes."
28 			echo "\thelp\tshow this message and exit"
29 			return 0
30 			;;