I want to run a command, for example
echo "foobar";
After each command, entered by the user.
Two scenarios:
How to accomplish the above two scenarios?
NB: I don't want to use the prompt for this purpose, (leave the PS1 variable as is).
The Operators &&, ||, and ; The first logical operator we will be looking at will be the AND operator: &&. In Bash, it is used to chain commands together. It can also be used to run two different scripts together.
As l0b0 suggests, you can use PROMPT_COMMAND
to do your second request and you won't have to touch PS1
.
To do your first request, you can trap
the DEBUG
pseudo-signal:
trap 'echo "foobar"' DEBUG
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With