Play sound and show message when the terminal is ready in Ubuntu, also from Vagrant


Sometimes it's nice to get an alert when your terminal has finished a task.

You need to have sox installed to play a sound with the "play" command:

sudo apt-get install sox

Add this to your ~/.bashrc file (remember to also source it) to play a sound and show the text "Ready" at the top of your screen:

export ready_sound=/usr/share/sounds/freedesktop/stereo/service-login.oga
alias ready="play --no-show-progress $ready_sound; notify-send 'Ready :-)'"

To play the sound, just insert it whenever you need it. To alert you when a command is finished:

cd scotch-pro-VM; vagrant up --debug; ready; vagrant ssh;

I found the service-login.oga file at /usr/share/sounds/freedesktop/stereo/, more sounds can be found in these folders: /usr/share/sounds

Notifications from Vagrant

To show notifications from Vagrant, use the vagrant-notify Vagrant plugin: "Vagrant plugin that redirects `notify-send` from guest to host machine and notifies provisioning status.". You might have to install libnotify-bin first: sudo apt-get install libnotify-bin

Use like this in your ~/.bashrc (it's difficult to play sound from a Vagrant virtualbox):

alias ready="notify-send 'Ready :-)'"