For videos, this should work... added to your .bashrc file, which then needs to be reloaded (only once) by typing source .bashrc in your home directory from the command line:
alias yt='youtube-dl --recode-video mp4'
On my system I have a funky python setup so I need to use this instead: alias yt='unset PYTHONPATH; youtube-dl --recode-video mp4'
I don't see the need for interactivity because the only format I ever want is mp4.For audio, I would just do a separate alias with a different name. For example (edit: tested):
alias yta='youtube-dl --extract-audio --audio-format mp3'
Invoke each with the URL. For example:Video:
yt https://www.youtube.com/watch?v=IFe9wiDfb0E
Audio: yta https://www.youtube.com/watch?v=qKS8KsTC4IU
If a youtube URL has extra parameters separated by &, delete those before invoking. For example the URL below, which has extra parameters because it came from a playlist: https://www.youtube.com/watch?v=7uQuX1sOYk4&list=PLYq_mcte9NvDA2Xi5Qjl1DrH5LuDKDlAI
should be changed to this before using it to attempt a download: https://www.youtube.com/watch?v=7uQuX1sOYk4
Or you can use the full original URL but you need to protect it from interpretation by UNIX by surrounding it with single quotes when invoking. yta 'https://www.youtube.com/watch?v=7uQuX1sOYk4&list=PLYq_mcte9NvDA2Xi5Qjl1DrH5LuDKDlAI'