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
More Related Contents:
- How do I parse command line arguments in Bash?
- How do I set a variable to the output of a command in Bash?
- Why do you need ./ (dot-slash) before executable or script name to run it in bash?
- How to iterate over arguments in a Bash script
- Timeout a command in bash without unnecessary delay
- What is the purpose of “&&” in a shell command?
- Capture stdout and stderr into different variables
- Remove the last line from a file in Bash
- How to get Maven project version to the bash command line
- How to replace ${} placeholders in a text file?
- How to use arguments from previous command?
- How can I get a recursive full-path listing, one line per file?
- How to reload .bash_profile from the command line
- Why do I get “/bin/sh: Argument list too long” when passing quoted arguments?
- What is your single most favorite command-line trick using Bash? [closed]
- Convert line endings [duplicate]
- Multiplication on command line terminal
- -bash: !”: event not found [closed]
- Why doesn’t my terminal output unicode characters properly?
- How to mount a host directory in a Docker container
- “~/Desktop/test.txt: No such file or directory”
- Integer ASCII value to character in BASH using printf
- How do I write a ‘for’ loop in Bash?
- Hexadecimal To Decimal in Shell Script
- LINES and COLUMNS environmental variables lost in a script
- bash script loop through two variables in lock step
- Check if a file is executable
- When does command substitution spawn more subshells than the same commands in isolation?
- Rsync syntax error when run from bash script
- Multi Level Bash Completion