Posts

Showing posts from 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  

Apple MacOS allow downloaded programs to run

In MacOS, when we try to run a standalone program or open an app downloaded from Internet, then MacOS's security will prevent us from running the program. In order to execute the program or app, the following commands can be executed in Terminal to remove the quarantine attribute associated with the file. Unblock a standalone program sudo xattr -d com.apple.quarantine /path/to/your/program Unblock an app Recursively remove the attribute in the app bundle sudo xattr -rd com.apple.quarantine /path/to/YourApp.app