I use the following script called "~/.music.automation.sh" and load it from my "~/.bash_profile" with "source ~/.music.automation.sh".
---
# ~/.music.automation.sh
# Volume stuff
alias vol="osascript -e 'output volume of (get volume settings)'"
alias 0="osascript -e 'set Volume 0'"
alias 1="osascript -e 'set Volume 0.3'"
alias 2="osascript -e 'set Volume 0.6'"
alias 3="osascript -e 'set Volume 0.9'"
alias 4="osascript -e 'set Volume 1.2'"
alias 5="osascript -e 'set Volume 1.5'"
alias 6="osascript -e 'set Volume 1.8'"
alias 7="osascript -e 'set Volume 2.1'"
alias 8="osascript -e 'set Volume 2.4'"
alias 9="osascript -e 'set Volume 2.7'"
alias 10="osascript -e 'set Volume 3.0'"
# Synonyms for above
alias m="osascript -e 'set Volume 0'"
# Spotify stuff
alias next="osascript -e 'tell application \"spotify\" to next track'"
alias n="osascript -e 'tell application \"spotify\" to next track'"
alias previous="osascript -e 'tell application \"spotify\" to previous track'"
alias prev="osascript -e 'tell application \"spotify\" to previous track'"
alias p="osascript -e 'tell application \"spotify\" to previous track'"
alias pp="osascript -e 'tell application \"spotify\" to playpause'"
---
Then, I can SSH into MacOS and control the music remotely, from my phone for example. Enjoy!