Skip to content

Instantly share code, notes, and snippets.

@scottschmitz
Last active August 25, 2023 15:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottschmitz/90ff71cd0989704ee392071138e36120 to your computer and use it in GitHub Desktop.
Save scottschmitz/90ff71cd0989704ee392071138e36120 to your computer and use it in GitHub Desktop.
oh-my-zsh theme
# Path to your oh-my-zsh installation.
export ZSH=/Users/sschmitz/.oh-my-zsh
bindkey -e
bindkey '\e\e[C' forward-word
bindkey '\e\e[D' backward-word
ZSH_THEME="m"
plugins=(git)
source $ZSH/oh-my-zsh.sh
eval "$(/opt/homebrew/bin/brew shellenv)"
# nodenv
eval "$(nodenv init -)"
# pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
# rbenv
export RBENV_ROOT="$HOME/.rbenv"
export PATH="$RBENV_ROOT/bin:$PATH"
eval "$(rbenv init - zsh)"
# history search
alias hist="history | grep $1"
# Rebalance audio because Macs are bad at
/usr/bin/osascript "$HOME/bin/reset-audio-balance.scpt"
alias soundishard="/usr/bin/osascript \"$HOME/bin/reset-audio-balance.scpt\""
# Terminal is annoying and I want to push what I want to push
# https://github.com/nvbn/thefuck
eval $(thefuck --alias heck)
alias servepublic="ipconfig getifaddr en0; pushd ~/Public; python -m SimpleHTTPServer 8080; popd"
alias squeaky="./gradlew clean assembleDebug --rerun-tasks"
alias linter="bundle exec fastlane detekt"
alias git_delete_branches="git branch | grep "feature" | xargs git branch -D"
# IP Addresses and Charles is hard
alias ip='ifconfig | grep en0: -A6 | grep "\ \d*\.\d*\.\d*\.\d*\ " -C10'
alias iptrim='echo $(ip) | cut -d" " -f16'
alias chls='echo -e "hostname: $(iptrim)\nport: 8888"'
# Colors are neat
alias red="$HOME/bin/set-background.sh '{8000, 0, 0, 0}'"
alias orange="$HOME/bin/set-background.sh '{9000, 6000, 1000, 0}'"
alias yellow="$HOME/bin/set-background.sh '{8000, 8000, 0, 0}'"
alias lime="$HOME/bin/set-background.sh '{3000, 8000, 1000, 0}'"
alias green="$HOME/bin/set-background.sh '{0, 6000, 0, 0}'"
alias cyan="$HOME/bin/set-background.sh '{0, 6000, 8000, 0}'"
alias blue="$HOME/bin/set-background.sh '{0, 0, 8000, 0}'"
alias purple="$HOME/bin/set-background.sh '{4000, 0, 8000, 0}'"
alias magenta="$HOME/bin/set-background.sh '{8000, 0, 7000, 0}'"
# oh-my-zsh m Theme
### Git [master <> ●]
ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg[white]%}>%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg[white]%}<%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[green]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg[red]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_STASHED="%{$fg[cyan]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}]"
m_git_branch () {
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
echo "${ref#refs/heads/}"
}
m_git_status1() {
# Show ahead/behind status
_INDEX=$(command git status -uno --porcelain -sb 2> /dev/null)
_STATUS=""
if $(echo "$_INDEX" | grep '^## .*behind' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_BEHIND"
fi
if $(echo "$_INDEX" | grep '^## .*ahead' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
if $(echo "$_INDEX" | grep '^## .*diverged' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_DIVERGED"
fi
# Prepend space if non empty
if [ "${_STATUS}x" != "x" ]; then
_STATUS=" $_STATUS"
fi
echo $_STATUS
}
m_git_status2 () {
# Show working copy/staged changes status
_INDEX=$(command git status -uno --porcelain -sb 2> /dev/null)
_STATUS=""
if $(echo "$_INDEX" | grep '^[AMRD]. ' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
fi
if $(echo "$_INDEX" | grep '^.[MTD] ' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
fi
if $(echo "$_INDEX" | grep '^UU ' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
fi
if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STASHED"
fi
# Prepend space if non empty
if [ "${_STATUS}x" != "x" ]; then
_STATUS=" $_STATUS"
fi
echo $_STATUS
}
m_git_prompt () {
local _branch=$(m_git_branch)
local _status="$(m_git_status1)$(m_git_status2)"
local _result=""
if [[ "${_branch}x" != "x" ]]; then
_result="[$_branch"
if [[ "${_status}x" != "x" ]]; then
_result="$_result$_status"
fi
_result="$_result$ZSH_THEME_GIT_PROMPT_SUFFIX"
fi
echo $_result
}
if [[ $(id -u) == 0 ]]; then
_LIBERTY="%{$fg[red]%}#%{$reset_color%}"
else
_LIBERTY="%{$fg[green]%}$%{$reset_color%}"
fi
# Add 'user@hostname' in ssh session
_USERNAME=""
if [[ -n $SSH_CONNECTION ]]; then
_USERNAME="%{$bg[white]%}%{$fg[black]%}%n@%m%{$reset_color%}:"
fi
_PATH="%{$fg_bold[white]%}%~%{$reset_color%}"
setopt prompt_subst
PROMPT='
$_USERNAME$_PATH
$_LIBERTY '
RPROMPT='$(m_git_prompt)'
autoload -U add-zsh-hook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment