-
-
Save nsfmc/76d0bce821649bb656b6afd57378f8cd to your computer and use it in GitHub Desktop.
Adds the currently playing iTunes/Spotify track to your prepared git commit message.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Adds the currently playing iTunes track to your prepared commit message. | |
# | |
# To install, save in repo as chmod +x to .git/hooks/prepare-commit-msg | |
# save music.js somewhere like ~/.bin | |
# if you don't use a commit template $SONG should precede $1 to allow --verbose | |
# commits to work, otherwise change the echo to "$(cat $1)\n\n$SONG" | |
SONG=`osascript -l JavaScript ~/.bin/music.js` | |
if [[ $SONG ]]; then | |
echo -e "\n\n$SONG\n$(cat $1)" > $1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env osascript -l JavaScript | |
var trackForPlayer = (appName) => { | |
if (Application(appName).running()) { | |
var player = Application(appName) | |
if (player.playerState() === 'playing') { | |
var track = player.currentTrack() | |
return `♬ : ${track.artist()} / ${track.name()}` | |
} | |
} | |
} | |
function run(args) { | |
var currentTrack = trackForPlayer('iTunes') || trackForPlayer('spotify') | |
if (currentTrack) { | |
app = Application.currentApplication() | |
app.includeStandardAdditions = true; | |
return currentTrack | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment