Terminal Customization

How to improve default terminal experience

ZSH

Completion Features

# enable auto-completion for applicable apps installed with brew e.g., gh.
# https://docs.brew.sh/Shell-Completion
if type brew &>/dev/null
then
  FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"

  autoload -Uz compinit
  compinit
fi
# automatically capitalizes where needed e.g., `cd documents/` >> `cd Documents/`
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'

Auto-Suggestions

# add to ~/.zshrc
# enables suggestions based on previously used commands
source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh

AWS CLI

# add to ~/.zshrc
# enables command completion for aws cli (tab to complete)
# make sure path to aws_completer is correct
autoload bashcompinit && bashcompinit
autoload -Uz compinit && compinit
complete -C '/usr/local/bin/aws_completer' aws

Display Current Git Branch

# add to ~/.zsh
# updates shell colors, format, and displays git branch
parse_git_branch() {
    git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
# color #s found here: https://misc.flogisoft.com/bash/tip_colors_and_formatting
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}%% '

Last updated