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. |
Links
Examples
- Log executed commands
- Output:
1 2
preexec() { echo "Command to be executed: $3" >&2; } echo hello $LOGNAME ~
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!