1

I run a lot of commands(unit tests) that take a long time to finish. Is there a way to alter my .bashrc to add a 'beep' to the end of every command so I don't have to remember to add it myself?

ex: %phpunit yadayada ; beep

thanks.

0

2 Answers 2

3

The contents of PROMPT_COMMAND is executed before every prompt. You can therefore cause a beep after every command with

PROMPT_COMMAND='beep'

To just beep after one specific command, you can override it with a function:

phpunit() {
  command phpunit "$@"
  beep
}

It's also prudent to preserve phpunit's exit code, so that you can still do things like phpunit .. && doStuff to only doStuff when the tests pass:

phpunit() {
  command phpunit "$@"
  local r=$?
  beep
  return $r
}
Sign up to request clarification or add additional context in comments.

Comments

1

Pretty certain that it's not possible for every command, but you could create an alias to achieve this (using ping as the example)

#!/bin/bash
ping () { command ping "$@"; beep; }

[Edit:] that other guy's solution is much better, i've adapted mine...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.