Skip to content

Instantly share code, notes, and snippets.

@bendog
Last active August 27, 2025 04:07
Show Gist options
  • Select an option

  • Save bendog/b55df6d90385e7dd475b12fbb0b1024f to your computer and use it in GitHub Desktop.

Select an option

Save bendog/b55df6d90385e7dd475b12fbb0b1024f to your computer and use it in GitHub Desktop.
ZSH setup

setting up zsh

install HomeBrew for Mac

go to https://brew.sh

install and setup zsh

echo $SHELL

if this is zsh go to the next stage, if not check zsh is installed

which zsh

if this is found go to install oh-my-zsh

if this is not found, install with brew following the steps below

brew install zsh

to set zsh as your shell use chsh

chsh -s `which zsh`

close and reopen the terminal

install and setup oh-my-zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

install nerd fonts

brew tap homebrew/cask-fonts
brew install --force $( brew search font | grep nerd | tr '\n' ' ' )

install PowerLevel10k

https://github.com/romkatv/powerlevel10k#oh-my-zsh

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

Now, edit the ZSH_THEME in ~/.zshrc file into :

ZSH_THEME="powerlevel10k/powerlevel10k"

then run p10 configure

p10k configure

additional zsh tools

Download zsh-autosuggestions :

git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions 

Download zsh-syntax-higlighting :

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

Edit ~/.zshrc file, find plugins=(git) replace plugins=(git) with :

plugins=(
  # autoswitch_virtualenv
  aws
  git
  zsh-autosuggestions 
  zsh-syntax-highlighting
  )

Reopen your terminal, now you should be able to use the auto suggestions and syntax highlighting.

commands for installing python

brew install pyenv
brew install pipenv

add pyenv settings to ~/.zprofile

cat <<EOF >> ~/.zprofile
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
EOF

edit ~/.zshrc and add pyenv and pipenv to the plugins

plugins=(
  # autoswitch_virtualenv
  aws
  git
  pipenv
  pyenv
  zsh-autosuggestions 
  zsh-syntax-highlighting
  )
# Aliases
**Do these in a new terminal window**
#### install fancy helper tools for aliases
```shell
brew install lsd exa
```
#### enable .aliases file
add this line to `~/.zshrc` under the aliases section
```shell
if [ -f ~/.aliases ]; then
source $HOME/.aliases
fi
```
#### add the aliases to the .aliases file
edit the ~/.aliases file with `code ~/.aliases` and add these lines
```shell
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ls="lsd"
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias tree='exa --tree --long'
# mac DNS flush
alias flushdnscache='sudo killall -HUP mDNSResponder; sleep 1; echo "macOS DNS Cache Reset"'
alias randompw='openssl rand -base64 8 |md5 |head -c32;echo'
alias tf='terraform'
function ports() {
netstat -Watnlv | grep LISTEN | awk '{"ps -o comm= -p " $9 | getline procname;colred="\033[01;31m";colclr="\033[0m"; print colred "proto: " colclr $1 colred " | addr.port: " colclr $4 colred " | pid: " colclr $9 colred " | name: " colclr procname; }' | column -t -s "|"
}
whoseport() {
lsof -i ":$1" | grep LISTEN
}
function docker_rm_images() {
docker rmi $2 $(docker image ls | grep $1 | awk '{print $3}' )
}
function project() {
local sub_dir="$1"
local dir="$HOME/projects/${sub_dir}"
echo "$dir"
if [[ ! -e "$dir" ]]
then
# if dir doesn't exist prompt to create one
echo "Doesn't exist, create a new one? [y/N] "
read confirm
if [[ ! "$confirm" =~ ^[Yy] ]]
then
echo "exit"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell or function but don't exit interactive shell
else
echo "creating ${dir}"
mkdir -p "$dir";
fi
fi
cd "$dir"
}
# Git Tools
# git remote rename
function git_remote_rename() {
local remote="$1"
local oldname="$2"
local newname="$3"
echo "$remote:$oldname -> $remote:$newname"
if git ls-remote --heads "$remote" \
| cut -f2 \
| sed 's:refs/heads/::' \
| grep -q ^"$newname"$; then
echo "Error: $newname already exists"
exit 1
fi
git push "${remote}" "${remote}/${oldname}:refs/heads/${newname}" ":${oldname}"
}
function git_remote_bulk_rename() {
# usage: git_remote_bulk_rename origin CR feature/
# result: origin:CR-2135 -> origin:feature/CR-2135
local remote="$1"
local prefix = "$2"
local newprefix = "$3"
echo "${remote}:${prefix}... -> ${remote}:${newprefix}${prefix}..."
git ls-remote --heads origin \
| cut -f2 | sed 's:refs/heads/::' \
| grep ^"${prefix}.*"$ \
| while read line ; do \
git_remote_rename "${remote}" "${line}" "${newprefix}${line}" ; \
done
}
alias git-prune='git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d'
```
## ignore all .DS_Store files
```shell
echo ".DS_Store" >> ~/.gitignore
git config --global core.excludesFile ~/.gitignore
```
## add git lg alias for better git log
```shell
cat <<EOF >> ~/.gitconfig
[alias]
lg = lg1
lg1 = lg1-specific --all
lg2 = lg2-specific --all
lg3 = lg3-specific --all
lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
lg3-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
EOF
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment