Ubuntu – Alias to take a parameter and exit after execution

aliascommand linegnome-shell

In my ~/.bashrc, I have an alias called yy as follows

alias yy="youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]'"

But I often run it this way

yy <url list> && exit

I would like to make it simpler and convert it to a simple alias called yye.

yye <url list>

Would anyone please advise how to carry out this alias definition?

Best Answer

Don't use an alias for that. Use a function:

yye() { youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]' "$@" && exit; }

The above command defines the alias. If you want it to be permanent, put the above in your ~/.bashrc file.

The command yye may be invoked as:

yye <url list>
Related Question