简体   繁体   中英

Executing a command after the first command executed

I just recently installed beep on Ubuntu and finally managed to get it to work. So I was able to hear the beeping sound after executing:

beep

Everything worked well, however, I was just wondering if it's possible to execute "beep" everytime I execute a command. Say for example:

cat /etc/passwd && beep

After reading /etc/passwd, it will be executing a beeping sound. I'd like to know if there's a way to execute beep after every command without having me to use "&& beep" always.

A clearer example:

ls && beep
ls -la && beep
cat /etc/passwd && beep

Notice the constant command "beep" followed by "&&" after every initial command.

You can set PROMPT_COMMAND=beep (try it first, then add to your ~/.bashrc if it doesn't drive you crazy). This will execute beep just before it displays the command prompt.

您可以尝试更改提示:

PS1="$PS1"'\007'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM