Does bash have a hook that is run before executing a command?
        Posted  
        
            by 
                Gilles
            
        on Super User
        
        See other posts from Super User
        
            or by Gilles
        
        
        
        Published on 2010-08-14T11:09:20Z
        Indexed on 
            2012/03/22
            11:33 UTC
        
        
        Read the original article
        Hit count: 361
        
In bash, can I arrange for a function to be executed just before running a command?
There is $PROMPT_COMMAND, which is executed before showing a prompt, i.e., just after running a command.
Bash's $PROMPT_COMMAND is analogous to zsh's precmd function; so what I'm looking for is a bash equivalent to zsh's preexec.
Example applications: set your terminal title to the command being executed; automatically add time before every command.
© Super User or respective owner