Once you have Homebrew installed, it is really helpful to have
your user profile ~/.zshrc
setup. This will give you your
aliases, paths, environment, etc.
🍺 Homebrew in its installation output instructs you to add it to your
~/.zshrc
.
⚙️ You may find it useful to both automate the installation of your common profile files as well as keep them under source code control even if just locally.
I use a GitHub repository for my basic standard macOS
~/.zshrc
with an installation script. This installation
script installs the .zshrc
file in another directory so that
it can be put under git
and then soft links it to ~/.zshrc
.
This .zshrc
file contains the configuration needed for Homebrew.
You can use my repository to install a basic Mac ~/.zshrc
with Homebrew support and then customize it if you want.
Just follow the README of my GitHub Repository mac-dev-zsh-profile
If you wish to create your own profile here is a sample that may be useful...
# ----------------------------------
# Z shell for MacOS profile
# ----------------------------------
#-- HOMEBREW --
# Add Homebrew package management to shell environment
# Add brew shellenv to your ~/.zshrc file"
# This is inside baseball from the brew install script
# Determine where brew itself is installed based on Intel vs Apple Silicon
[[ `uname -m` == "arm64" ]] && homebrew_prefix="/opt/homebrew" || homebrew_prefix="/usr/local"
eval "$(${homebrew_prefix}/bin/brew shellenv)"
unset homebrew_prefix
# -- UTILITIES (ETC.) --
# Enable git autocomplete
autoload -Uz compinit && compinit
# -- ALIASES --
# Basic Aliases
alias lsa='ls -al '
alias cls='clear '
# Git Aliases
alias ga='git add '
alias gb='git branch '
alias gc='git commit '
alias gcm='git commit -m '
alias gd='git diff '
alias go='git checkout '
alias gs='git status '
alias golo='git log '
# -- PATH --
# Nothing yet
#--- PROMPT ---
# Zshell specific includes git branch in prompt
# Simple function to get the git branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# NOTE: PROMPT_SUBST must be set for variable/special character
# expansion
setopt PROMPT_SUBST
# Prompt:username@shorthostname currentdirectoryonly (gitbranchname)%
PROMPT='%n@%m %1~%F{green}$(parse_git_branch)%f%# '
Thanks for sharing!