3

I'd like to know if I can track commands entered by user in a bash shell, in real time.

What I'm trying to do is something similar to thefuck, but I need to prompt the user as and when he enters new commands into the shell.

Is there any way I could write a hook to bash that kind of lets me wrap my code around it ? Alternatively: is there a way to pull updated bash history? afaik bash writes to history when the shell is exited, unless you run 'history' command in the same terminal.

3

Put export PROMPT_COMMAND='history -a' to /etc/profile or other profile file. This causes the history -a command to execute before every command prompt display. history -a flushes history to .bash_history immediately.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.