How to make the terminal prompt make sound every time i am prompted to write a command?

by Black Block   Last Updated April 06, 2015 01:00 AM

I want every time i have the command prompt (i.e, end of a command) to get a sound to get attention to the terminal [as i am using laptop \a character is not going to work with me].

The command i want to run is: mplayer /home/naruto/Music/sfx_msg-highlight.wv &> /dev/null & i put it in a sound.sh file and i make it accessible but when i add ./sound.sh to my .bashrc --> ps1 it just prints it [you can also see my ps1 in the background].

enter image description here
so how to make this work ?



Answers 2


Put any one of the below lines before the user input statement.

echo -en "\007"

or

echo -ne '\a' and printf '\a'

Vyas Senthil
Vyas Senthil
April 02, 2015 03:31 AM

I have found the answer,
just \[$(COMMAND) to run a command with every terminal prompt.
For me i just put the command in a script and then run it by putting \[$(~/sound2.sh \# \u) at the end of the ps1 variable and before the ending ` of it --> in the .bashrc file
And the script is:

if [ $1 = 1 ]; then
    spd-say "Welcome $2" &
else
    mplayer /home/naruto/Music/sfx_msg-highlight.wv &> /dev/null &
fi

Simply the script take 2 arguments:
$1 --> is the Number of commands entered into this shell session.
to know if you just opened the terminal then the terminal will say hello followed by
$2 --> the current user name
and if you entered a command every time you get the prompt back it will play a sound file to get my attention that the command that i was running was finished.
And here is my ps1 for who loves it: enter image description here

PS1='${debian_chroot:+($debian_chroot)}\[\033[0;43m\]\[\033[1;34m\]██▓▒░\[\033[1;32m\]\u\[\033[1;30m\]⌘ \[\033[1;32m\]\h:\[\033[1;31m\]\w░▒▓█\[\033[0;31m\]█▓░\[\033[0;32m\]⇒᚜\!:\#᚛\[\033[00m\]\$ \[$(~/sound2.sh \# \u)'

And my terminal looks like: enter image description here

Black Block
Black Block
April 05, 2015 22:30 PM

Related Questions


How to save working directory in gnome-terminal?

Updated April 06, 2015 19:00 PM

How to get to terminal?

Updated September 26, 2015 04:01 AM



How to execute a specific command on opening a terminal

Updated September 29, 2015 14:01 PM