Skip to content

Instantly share code, notes, and snippets.

@pboucher
Created October 20, 2012 04:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pboucher/3922052 to your computer and use it in GitHub Desktop.
Save pboucher/3922052 to your computer and use it in GitHub Desktop.
iTunes plugin for oh-my-zsh
# ------------------------------------------------------------------------------
# FILE: iTunes.plugin.zsh
# DESCRIPTION: oh-my-zsh plugin file to control iTunes
# AUTHOR: Patrick Boucher (pboucher@patrickboucher.com)
# VERSION: 1.0
# ------------------------------------------------------------------------------
function play() {
osascript 2>/dev/null <<EOF
tell application "iTunes" to play
EOF
}
function pause() {
osascript 2>/dev/null <<EOF
tell application "iTunes" to pause
EOF
}
function stop() {
osascript 2>/dev/null <<EOF
tell application "iTunes" to stop
EOF
}
function playlists() {
osascript 2>/dev/null <<EOF
tell application "iTunes"
set output to ""
set newLine to ASCII character 10
repeat with i from 1 to count of playlists
set playlistName to name of playlist i
set output to output & i & ": " & playlistName & newLine
end repeat
copy output to stdout
end tell
EOF
}
function playlist() {
osascript 2>/dev/null <<EOF
tell application "iTunes"
play playlist $1
end tell
EOF
}
function skip() {
osascript 2>/dev/null <<EOF
tell application "iTunes"
next track
end tell
EOF
}
alias itunes="open -a iTunes"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment