Music from command line
Pretty sure I am very late to the game but only recently I’ve found out how to
download and listen to music right from the
iTerm2, whichever your terminal is).
Download youtube music with
On Mac, with
Homebrew, it’s just a command away:
brew install youtube-dl
sudo port install youtube-dl
2. Add alias for common usage
youtube-dl is a very powerful tool to download video/audio from Youtube.
Its syntax is, therefore, also pretty complicated.
For my usage, I simply needed the mp3 versions of the music videos. Also some of the meta information like artist and title should be correct at least for easier classification later.
So here are 3 aliases that I commonly used to make the downloading easier:
You can put this to your
.bashrc, and start using as follow:
What the commands will be doing are:
- Extract audio and save the mp3 version of youtube video specify
- Save meta infos like
titleaccording to partern
ytdl, the pattern is:
[title] [separator] [artist], in which
[separator] can be
For example, in the case of following video:
(Charlie Puth) Attention
Josephine Alexandra | Fingerstyle Guitar Cover
I used short forms of
al) as reminder how the pattern looks like
album), the pattern is:
[title] [separator] [artist] [separator] [album], in which
[separator] is same as above with extra
( in case of last separator.
With the same video above, if we use
ytdl-atal the result would be:
(Charlie Puth) Attention
Fingerstyle Guitar Cover
It is still not perfect yet but it is quite enough for me
ytdl-ta is just a reverse in order of
ytdl, should be used for cases like in this video:
Of course there will be more patterns of title you will see on youtube but those are the common ones.
Play music with
Again with magic of
Homebrew, to install
cmus on Mac is simply:
brew install cmus
The first installation, I’ve accidentally downloaded and compiled the build on
https://cmus.github.io/#download. But still
Homebrew installation is much better.
cmus is a very useful player when you mostly work on Terminal. Its UI has 7 views (that you can switch around using number key 1-7 once cmus open):
If you are used to use terminal, it won’t be that hard to use
cmus. But to make it easier to remember the list of commands, I recommend this cheatsheet
As of the 2 video above, here is what it will look like after we’ve added them in playlist:
One thing I definitely loved about
cmus is that the navigation keys are
k for up and down which is super familiar if you used
vim. So again, everything is seamless.
There are much more functionalities of cmus to explore and I am still in the learning process.
Hope you will find this useful if you are also late to the game :)