{"repo":"rcaloras/bash-preexec","free":true,"listed":false,"github":"https://github.com/rcaloras/bash-preexec","clone":"git clone https://github.com/rcaloras/bash-preexec.git","description":"⚡ preexec and precmd functions for Bash just like Zsh.","language":"Shell","stars":1060,"topics":["bash","preexec","precmd"],"license":"MIT","category":"cli-tools","readme_excerpt":"Bash-Preexec ============ preexec and precmd hook functions for Bash 3.1+ in the style of Zsh. They aim to emulate the behavior as described for Zsh. This project is currently being used in production by Bashhub, iTerm2, and Ghostty. Hype! Quick Start Install You'll want to pull down the file and add it to your bash profile/configuration (i.e /.bashrc, /.profile, /.bash profile, etc). It must be the last thing imported in your bash profile. Usage Two functions preexec and precmd can now be defined and they'll be automatically invoked by bash-preexec if they exist. preexec Executed just after a command has been read and is about to be executed. The string that the user typed is passed as the first argument. precmd Executed just before each prompt. Equivalent to PROMPT COMMAND, but more flexible and resilient. Should output something like: Function Arrays You can also define functions to be invoked by appending them to two different arrays. This is great if you want to have many functions invoked for either hook. Both preexec and precmd functions are added to these by default and don't need to be added manually. $preexec functions Array of functions invoked by preexec. $precmd functions Array of functions invoked by precmd. preexec precmd You can also define multiple functions to be invoked like so. You can check the functions set for each by echoing its contents. Subshells bash-preexec does not support invoking preexec() for subshells by default. It must be enabled by setting ","default_branch":null,"files":null,"tree":[],"storefront":"/r/rcaloras","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/rcaloras/bash-preexec/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}