Skip to content

Instantly share code, notes, and snippets.

@echo-dave
Last active October 25, 2019 04:49
Show Gist options
  • Save echo-dave/af03a1161f94f5d573ef974b7e0e8cdd to your computer and use it in GitHub Desktop.
Save echo-dave/af03a1161f94f5d573ef974b7e0e8cdd to your computer and use it in GitHub Desktop.
Quick and basic zsh setup for Mac

A better terminal for all

First off lets set zsh to our default shell

open up Terminal and run chsh -s /bin/zsh
If interested you could go ahead and make a few basic visual changes in Profiles tab.

Oh-my-zsh

official repo has pretty good documentaion. The punch line is find somewhere to clone it then tell your ~/.zshrc about it. /usr/local is probably a better spot in hindsight than /etc where I put put it.

Getting a default

  • cd into your newly cloned oh-my-zsh into templates and you can do a cp zshrc.zsh-template ~/; mv ~/zshrc.zsh-template ~/.zshrc
  • next open up the ~/.zhshrc in your editor of choice and edit the line below "# Path to your oh-my-zsh installation" to the path of your clone. export ZSH=/etc/oh-my-zsh in my case. You'll also want to add the following to avoid an warning that wants you to muck around with permissions unnecessarily:
# skip the verification of [oh-my-zsh] insecure directories
ZSH_DISABLE_COMPFIX="true"

It's also worth noting that a lot of people are fans of using iTerm2 over Apple's Terminal. I'm kinda lazy and not gotten around to playing with it as something else to learn with everything else I'm doing.

Additional .zshrc options

  • so I don't have to option my ls command all the time: alias ls='ls -Ghp'
  • since I've never learned vi I setmy default editor to nano: export EDITOR=nano
  • some additional highlighting zsh-syntax-highlighting clone into oh-my-zsh directory and add the following accounting for your path:
source /etc/oh-my-zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets cursor)
  • if like me you can't stand their ls colors then you can insert the block below for standard terminal ansi colors which can be easily adjusted in the Terminal preferences:
# ls colors
autoload -U colors && colors
LS_COLORS="di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"
export LS_COLORS
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# Enable lscolors
export LSCOLORS="exfxcxdxbxegedabagacad"
  • the last big thing for me was a rework of thier promp. comment out #ZSH_THEME="robbyrussell" and insert following:
# escapse \e[...m 35 forground 48 background 5 blink 1 bold to reset {\e[0m:%}
if [[ -n $SSH_CONNECTION ]]; then
#remotehost
  PROMPT=$'%{\e[38;5;125m%}%m%{\e[0m:%}%{\e[38;5;172m%}%2~%{\e[0m%}%# \ '
else
#localhost
# PROMPT=$'%{\e[38;5;100m%}\u27A4 %{\e[0m:%}%{\e[38;5;172m%}%2~%{\e[0m%}%# \ '
  PROMPT=$'%{\e[38;5;100m%}\u27A4 %{\e[38;5;172m%}%2~%{\e[0m%} $(git_prompt_info) %# \ '
fi
  • followed by git promt modifications:
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment