Skip to content

Instantly share code, notes, and snippets.

@abe33
Created December 30, 2015 15:23
Show Gist options
  • Save abe33/35cff538f9bf5367a5c1 to your computer and use it in GitHub Desktop.
Save abe33/35cff538f9bf5367a5c1 to your computer and use it in GitHub Desktop.
Iterm setup
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.18021853268146515</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.15279652178287506</real>
<key>Red Component</key>
<real>0.13223165273666382</real>
</dict>
<key>Ansi 1 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.27450981736183167</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.25490197539329529</real>
<key>Red Component</key>
<real>0.77254903316497803</real>
</dict>
<key>Ansi 10 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.074509806931018829</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.54117649793624878</real>
<key>Red Component</key>
<real>0.45098039507865906</real>
</dict>
<key>Ansi 11 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.02416127547621727</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.47550284862518311</real>
<key>Red Component</key>
<real>0.66953158378601074</real>
</dict>
<key>Ansi 12 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.79626995325088501</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.44916436076164246</real>
<key>Red Component</key>
<real>0.054370075464248657</real>
</dict>
<key>Ansi 13 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.41939488053321838</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.0</real>
<key>Red Component</key>
<real>0.86070984601974487</real>
</dict>
<key>Ansi 14 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.75294119119644165</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.7607843279838562</real>
<key>Red Component</key>
<real>0.48627451062202454</real>
</dict>
<key>Ansi 15 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.86405980587005615</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.95794391632080078</real>
<key>Red Component</key>
<real>0.98943418264389038</real>
</dict>
<key>Ansi 2 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.074509806931018829</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.54117649793624878</real>
<key>Red Component</key>
<real>0.45098039507865906</real>
</dict>
<key>Ansi 3 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.023484811186790466</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.46751424670219421</real>
<key>Red Component</key>
<real>0.64746475219726562</real>
</dict>
<key>Ansi 4 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.78231418132781982</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.46265947818756104</real>
<key>Red Component</key>
<real>0.12754884362220764</real>
</dict>
<key>Ansi 5 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.43516635894775391</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.10802463442087173</real>
<key>Red Component</key>
<real>0.77738940715789795</real>
</dict>
<key>Ansi 6 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.75294119119644165</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.7607843279838562</real>
<key>Red Component</key>
<real>0.48627451062202454</real>
</dict>
<key>Ansi 7 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.79781103134155273</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.89001238346099854</real>
<key>Red Component</key>
<real>0.91611063480377197</real>
</dict>
<key>Ansi 8 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.46020755171775818</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.39627176523208618</real>
<key>Red Component</key>
<real>0.32024088501930237</real>
</dict>
<key>Ansi 9 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.27450981736183167</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.25490197539329529</real>
<key>Red Component</key>
<real>0.77254903316497803</real>
</dict>
<key>Background Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.10196078568696976</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.086274512112140656</real>
<key>Red Component</key>
<real>0.078431375324726105</real>
</dict>
<key>Badge Color</key>
<dict>
<key>Alpha Component</key>
<real>0.5</real>
<key>Blue Component</key>
<real>0.0</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.0</real>
<key>Red Component</key>
<real>1</real>
</dict>
<key>Bold Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.56363654136657715</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.56485837697982788</real>
<key>Red Component</key>
<real>0.50599193572998047</real>
</dict>
<key>Cursor Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.41939488053321838</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.0</real>
<key>Red Component</key>
<real>0.86070984601974487</real>
</dict>
<key>Cursor Guide Color</key>
<dict>
<key>Alpha Component</key>
<real>0.25</real>
<key>Blue Component</key>
<real>1</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.9100000262260437</real>
<key>Red Component</key>
<real>0.64999997615814209</real>
</dict>
<key>Cursor Text Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.090196080505847931</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.070588238537311554</real>
<key>Red Component</key>
<real>0.019607843831181526</real>
</dict>
<key>Foreground Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.59213429689407349</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.58079218864440918</real>
<key>Red Component</key>
<real>0.50252813100814819</real>
</dict>
<key>Link Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.78039216995239258</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.46274510025978088</real>
<key>Red Component</key>
<real>0.14117647707462311</real>
</dict>
<key>Selected Text Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.51004815101623535</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.51004815101623535</real>
<key>Red Component</key>
<real>0.45394286513328552</real>
</dict>
<key>Selection Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.14117647707462311</real>
<key>Color Space</key>
<string>Calibrated</string>
<key>Green Component</key>
<real>0.12156862765550613</real>
<key>Red Component</key>
<real>0.10588235408067703</real>
</dict>
</dict>
</plist>
# vim:ft=zsh ts=2 sw=2 sts=2
CURRENT_BG='NONE'
SYMLINK_SYMBOL='➦'
SEPARATOR_RIGHT='⮀'
SEPARATOR_LEFT='⮂'
ANGLE_RIGHT='⮁'
ANGLE_LEFT='⮃'
GIT_BRANCH=' '
GIT_BRANCH_ALT='⭠'
GIT_STAGED='✚'
GIT_UNSTAGED='●'
CMD_ERROR='✖'
CMD_SUCCESS='✔'
ZSH_THEME_NVM_PROMPT_PREFIX='%{%F{magenta}%}⬢ %{%F{black}%}'
ZSH_THEME_NVM_PROMPT_SUFFIX=''
RBENV_PROMPT_PREFIX='%{%F{magenta}%}▼ %{%F{black}%}'
# Begin a left segment
# Takes two arguments, background and foreground. Both can be omitted,
# rendering default background/foreground.
prompt_left_segment() {
local bg fg
[[ -n $1 ]] && bg="%K{$1}" || bg="%k"
[[ -n $2 ]] && fg="%F{$2}" || fg="%f"
if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
echo -n " %{$bg%F{$CURRENT_BG}%}$SEPARATOR_RIGHT%{%f$fg%} "
elif [[ $CURRENT_BG != 'NONE' && $1 == $CURRENT_BG ]]; then
echo -n " $ANGLE_RIGHT%{%f$fg%} "
else
echo -n "%{$bg%}%{$fg%} "
fi
CURRENT_BG=$1
[[ -n $3 ]] && echo -n $3
}
# End the left prompt, closing any open segments
prompt_left_end() {
if [[ -n $CURRENT_BG ]]; then
echo -n " %{%k%F{$CURRENT_BG}%}$SEPARATOR_RIGHT"
else
echo -n "%{%k%}"
fi
echo -n "%{%f%} "
CURRENT_BG=''
}
# Begin a right segment
# Takes two arguments, background and foreground. Both can be omitted,
# rendering default background/foreground.
prompt_right_segment() {
local bg fg
[[ -n $1 ]] && bg="%K{$1}" || bg="%k"
[[ -n $2 ]] && fg="%F{$2}" || fg="%f"
if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
echo -n " %{%k%f%K{$CURRENT_BG}%F{$1}%}$SEPARATOR_LEFT%{$bg%}%{$fg%} "
elif [[ $CURRENT_BG != 'NONE' && $1 == $CURRENT_BG ]]; then
echo -n " $ANGLE_LEFT%{$fg%} "
else
echo -n "%{%F{$1}%}$SEPARATOR_LEFT%{$bg%}%{$fg%} "
fi
CURRENT_BG=$1
[[ -n $3 ]] && echo -n $3
}
# End the right prompt, closing any open segments
prompt_right_end() {
# echo -n "%{ ${terminfo[cub1]}%k%f%}"
echo -n " %{%k%f%}"
CURRENT_BG=''
}
### Prompt components
# Each component will draw itself, and hide itself if no information needs to be shown
# Context: user@hostname (who am I and where am I)
prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_left_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"
fi
}
# Git: branch/detached head, dirty status
prompt_git() {
local ref dirty mode repo_path
repo_path=$(git rev-parse --git-dir 2>/dev/null)
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
dirty=$(parse_git_dirty)
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="$SYMLINK_SYMBOL $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
if [[ -n $dirty ]]; then
prompt_left_segment magenta black
else
prompt_left_segment green black
fi
if [[ -e "${repo_path}/BISECT_LOG" ]]; then
mode=" <B>"
elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then
mode=" >M<"
elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then
mode=" >R>"
fi
setopt promptsubst
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' get-revision true
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' stagedstr $GIT_STAGED
zstyle ':vcs_info:git:*' unstagedstr $GIT_UNSTAGED
zstyle ':vcs_info:*' formats ' %u%c'
zstyle ':vcs_info:*' actionformats ' %u%c'
vcs_info
echo -n "${ref/refs\/heads\//$GIT_BRANCH}${vcs_info_msg_0_}"
fi
}
prompt_hg() {
local rev status
if $(hg id >/dev/null 2>&1); then
if $(hg prompt >/dev/null 2>&1); then
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
# if files are not added
prompt_left_segment red white
st='±'
elif [[ -n $(hg prompt "{status|modified}") ]]; then
# if any modification
prompt_left_segment magenta black
st='±'
else
# if working copy is clean
prompt_left_segment green black
fi
echo -n $(hg prompt "$GIT_BRANCH {rev}@{branch}") $st
else
st=""
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
branch=$(hg id -b 2>/dev/null)
if `hg st | grep -q "^\?"`; then
prompt_left_segment red black
st='±'
elif `hg st | grep -Eq "^(M|A)"`; then
prompt_left_segment magenta black
st='±'
else
prompt_left_segment green black
fi
echo -n "$GIT_BRANCH $rev@$branch" $st
fi
fi
}
# Shorten PWD if it goes beyon the length parameter
shorten_pwd ()
{
local PRE= NAME="$1" LENGTH="$2";
[[ "$NAME" != "${NAME#$HOME/}" || -z "${NAME#$HOME}" ]] &&
PRE+='~' NAME="${NAME#$HOME}" LENGTH=$[LENGTH-1];
((${#NAME}>$LENGTH)) && NAME="/...${NAME:$[${#NAME}-LENGTH+4]}";
echo -n "$PRE$NAME"
}
# Dir: current working directory
prompt_dir() {
# prompt_left_segment black blue '%~'
prompt_left_segment black cyan
shorten_pwd "$PWD" 20
}
# Virtualenv: current working virtualenv
prompt_virtualenv() {
local virtualenv_path="$VIRTUAL_ENV"
if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then
prompt_left_segment black blue "(`basename $virtualenv_path`)"
fi
}
# Status:
# - was there an error
# - am I root
# - are there background jobs?
prompt_status() {
local symbols
symbols=()
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}$CMD_ERROR%{%f%}"
[[ $RETVAL -eq 0 ]] && symbols+="%{%F{green}%}$CMD_SUCCESS%{%f%}"
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡%{%f%}"
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙%{%f%}"
[[ -n "$symbols" ]] && prompt_right_segment black default $symbols
}
prompt_rbenv() {
version=$(rbenv version-name)
prompt_right_segment cyan black
echo -n "$RBENV_PROMPT_PREFIX$(rbenv version-name)"
}
prompt_nvm() {
prompt_right_segment cyan black
echo -n $(nvm_prompt_info)
}
## Main prompt
build_left_prompt() {
prompt_git
prompt_hg
prompt_virtualenv
prompt_context
prompt_dir
prompt_left_end
}
build_right_status() {
RETVAL=$?
prompt_status
prompt_rbenv
prompt_nvm
# prompt_right_segment yellow black '!%!'
prompt_right_end
}
RPROMPT='%{%f%b%k%}$(build_right_status)'
PROMPT='%{%f%b%k%}$(build_left_prompt)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment