Hook function before a command is executed

This function is executed right before a command is executed by the shell. It’s called with three parameters which describe the command to be executed.

Usage

1st argument
(required)
If the history mechanism is active, then this is the string the user typed. Otherwise it’s an empty string.
2nd argument
(required)
The size-limited, single-line value of the executed command.
3rd argument
(required)
Full text of the command which is going to be executed.

Examples

Log executed commands
1
2
preexec() { echo "Command to be executed: $3" >&2; }
echo hello $LOGNAME                                                                                                  ~
Output:
1
2
Command to be executed: echo hello $LOGNAME
hello user1
BashSupport Pro ist eine Zsh IDE mit Unterstützung für preexec - probieren Sie es jetzt aus!
© 2020–2024 Joachim Ansorg
Impressum
Datenschutz
Rechtliches