Skip to content

Instantly share code, notes, and snippets.

@ngohuytrieu
Last active June 21, 2023 07:51
Show Gist options
  • Save ngohuytrieu/eac04a50b17d7e1fbb8ee084242670d8 to your computer and use it in GitHub Desktop.
Save ngohuytrieu/eac04a50b17d7e1fbb8ee084242670d8 to your computer and use it in GitHub Desktop.
MacOS Useful tips

Enable command auto suggestion in terminal

sudo nano ~/.inputrc

# Add following content
set completion-ignore-case on
set show-all-if-ambiguous on
TAB: menu-complete

# close terminal then try again

Enable Git Tab Autocomplete for Zsh

echo 'autoload -Uz compinit && compinit' >> ~/.zshrc
source ~/.zshrc

If above code not work then try this

sudo nano ~/.zshrc

# put this at the end of file
autoload -Uz compinit && compinit

# reload
source ~/.zshrc

Display git branch in terminal

You can change the color with the color defined in here https://misc.flogisoft.com/bash/tip_colors_and_formatting

# Open zshrc file
sudo nano ~/.zshrc

# Add this to the bottom
parse_git_branch() {
    git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
COLOR_DEF='%f'
COLOR_USR='%F{243}'
COLOR_DIR='%F{197}'
COLOR_GIT='%F{39}'
NEWLINE=$'\n'
setopt PROMPT_SUBST
export PROMPT='${COLOR_USR}%n@%M ${COLOR_DIR}%d ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF}${NEWLINE}%% '

# Reload
source ~/.zshrc

NPM i takes long

Run this command first

npm config set registry https://registry.npmjs.org/

Open textedit from terminal

open -a TextEdit filename

Edit hosts file

sudo nano /etc/hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment