Repeat Bash Prompts

By  on  

I'm sure you wont be surprised when I tell you it's my job to automate things in our my household.  My wife is tech savvy but she relies on me to make tech matters easy for everyone; I guess it's flattering that she trusts me to do that.  One easy task she's trusted me with is make it easy to grab music from YouTube so she can put it on her phone or rock to on AudioShield.  I could probably point her to numerous sites that do that conversion but most are filled with disgusting ads and malware.  Since I love youtube-dl, I set out to create a bash script my wife could use to download as much music as she wanted!

Almost a decade ago I wrote about using a text file to download with youtube-dl but even that's a bit annoying for most people.  I could make a web interface but that seemed like too much I created a bash script to repeatedly ask for a YouTube link which to download and convert to MP3:

while true; do
    read -p "What is the YouTube link? " answer
    youtube-dl --extract-audio --audio-format mp3 $answer

The script repeatedly asks for a YouTube link, downloads and converts to mp3, then asks for YouTube link again.  I created a desktop shortcut for this script to make usage even easier.  An easy script to make music download easy!

Of course the script could use some validation (i.e. that it's a link from YouTube) but I trust that we'll paste a valid link.  The key takeaway is that while true; do ...done will allow you to create repeated loop in a bash script!

Recent Features

  • By
    Facebook Open Graph META Tags

    It's no secret that Facebook has become a major traffic driver for all types of websites.  Nowadays even large corporations steer consumers toward their Facebook pages instead of the corporate websites directly.  And of course there are Facebook "Like" and "Recommend" widgets on every website.  One...

  • By
    Page Visibility API

    One event that's always been lacking within the document is a signal for when the user is looking at a given tab, or another tab. When does the user switch off our site to look at something else? When do they come back?

Incredible Demos

  • By
    Modal-Style Text Selection with Fokus

    Every once in a while I find a tiny JavaScript library that does something very specific, very well.  My latest find, Fokus, is a utility that listens for text selection within the page, and when such an event occurs, shows a beautiful modal dialog in...

  • By
    Facebook Sliders With Mootools and CSS

    One of the great parts of being a developer that uses Facebook is that I can get some great ideas for progressive website enhancement. Facebook incorporates many advanced JavaScript and AJAX features: photo loads by left and right arrow, dropdown menus, modal windows, and...


  1. test
    • test


Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!