Posts

Showing posts from July, 2026

Make MacOS zsh shell to be compatible with bash shell commands

Enable it temporarily in current shell / terminal # Load Zsh's native completion system, then load the Bash compatibility bridge autoload -Uz compinit && compinit autoload -Uz bashcompinit && bashcompinit Enable it automatically by adding the above commands to ~/.zprofile or ~/.zshrc file 

Define and Execute custom shell function on Unix Bash or Mac Zsh

Add the below function to ~/.bash_profile or ~/.zprofile file # Continuously print the current timestamp until Ctrl+C is pressed clockon() {     # Clear the screen initially (optional)     clear     echo "Press [CTRL+C] to stop."     echo "------------------------"          while true; do         # \r overwrites the current line instead of scrolling down         printf "\rCurrent Time: %s" "$(date '+%Y-%m-%d %H:%M:%S')"         sleep 1     done } Source the file or close and reopen the Terminal     source ~/.bash_profile  or      source ~/.zprofile List the function available on the shell     compgen -A function | grep 'clockon' Execute the function     clockon