Skip to content

Instantly share code, notes, and snippets.

@bric3
Last active January 24, 2017 16:41
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 bric3/3665316 to your computer and use it in GitHub Desktop.
Save bric3/3665316 to your computer and use it in GitHub Desktop.
hckr theme for oh-my-zsh
# HCKR oh-my-zsh theme
#
# see http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#SEC59
# inspired from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
# http://forrst.com/posts/Oh_my_zsh_iTerm2_Nice_Colors_git_hg_suppo-1Ct
#
# Dependencies
# ============
# svn-fast-info plugin
# battery plugin
# oh-my-zsh-git plugin => https://github.com/bric3/oh-my-zsh-git
# nice-exit-code plugin => https://github.com/bric3/nice-exit-code
# Mercurial extension http://sjl.bitbucket.org/hg-prompt/
# Note : care was taken to avoid characters with a unicode "variant selector", which might confuse the shell on the size of the string and might results in wrong layout in the terminal.
ZSH_PROMPT_BASE_COLOR="%{%f%k%b%}"
ZSH_THEME_SVN_PROMPT_PREFIX=" %{%B%F{green}%}["
ZSH_THEME_REPO_NAME_COLOR="%{%B%F{blue}%}"
ZSH_THEME_SVN_PROMPT_SUFFIX="%{%B%F{green}%}]"
ZSH_THEME_SVN_PROMPT_DIRTY="%{%F{red}%}!"
ZSH_THEME_SVN_PROMPT_ADDITIONS="%{%b%F{green}%}★"
ZSH_THEME_SVN_PROMPT_DELETIONS="%{%B%F{red}%}✖"
ZSH_THEME_SVN_PROMPT_MODIFICATIONS="%{%b%F{yellow}%}✎"
ZSH_THEME_SVN_PROMPT_REPLACEMENTS="%{%F{magenta}%}∿"
ZSH_THEME_SVN_PROMPT_UNTRACKED="%{%F{magenta}%}?"
function _prompt_char {
git branch >/dev/null 2>/dev/null && [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]] && echo '±' && return
hg root >/dev/null 2>/dev/null && echo '☿' && return
svn info >/dev/null 2>/dev/null && echo 'S' && return
echo '○'
}
function colored_prompt_char() {
echo "%{%F{blue}%}%1{$(_prompt_char)%}%{%f%k%b%}"
}
function hg_prompt_info {
hg prompt --angle-brackets "\
< %{%B%F{green}%}[%{%F{magenta}%}<branch>%{%f%k%b%}>\
< at %{%F{yellow}%}<tags|%{%f%k%b%}, %{%F{yellow}%}>%{%f%k%b%}>\
< %{%F{red}%}<status|modified|unknown>%{%f%k%b%}>\
< %{%F{red}%}<update>%{%f%k%b%}>\
%{%B%F{green}%}]%{%f%k%b%}" 2>/dev/null
}
# oh-my-zsh-git config
omg_prefix=" %{%B%F{green}%}[%{%f%k%b%}"
omg_suffix="%{%B%F{green}%}]%{%f%k%b%}"
display_git_symbol=false
display_git_current_action=left
print_unactive_flags_space=false
# quick char pick tool :)
various_intersting_unicode_chars='⚙ ♨ ♋ ㍖♫𝄢♬♪𝄆𝄇𝄈𝄐〖⦖〘〙》〰︴෴⸚⌁⌀⌖𝌁⿓⎃☢☣☠☤⚕☸⚔☉♁☄⚚⚛ ⌘⎋⏎⌤⌥⌃⌅⇧⇪⌫⌦⇥⬆⬇⬍✔✘✖✭☲✎⌫ᄉ⇅⚯»Ⴤ↶↑±'
# nice exit code config
ZSH_PROMPT_EXIT_SIGNAL_PREFIX='%{%K{red}%F{white}%}%1{↪%} '
ZSH_PROMPT_EXIT_SIGNAL_SUFFIX='%{%f%k%b%} '
# Addtional documentation can be found here :
# http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html
# http://tldp.org/LDP/abs/html/exitcodes.html
# http://docs.openlinksw.com/virtuoso/signalsandexitcodes.html
directory_name() {
if [[ "$(dirname ${PWD})" == / ]]; then
local prompt_path=""
elif [[ $PWD == $HOME ]]; then
local prompt_path=""
else
local prompt_path="$(print -P %~)"
prompt_path="${prompt_path%/*}/"
fi
echo "%{%b%F{yellow}%}${prompt_path}%{%f%k%b%}%{%F{white}%}%1~%{%f%k%b%}"
}
function {
if [[ -n "$SSH_CLIENT" ]]; then
prompt_host="%{%f%k%b%}%{%B%F{green}%}%n%{%B%F{blue}%}@%{%B%F{cyan}%}%m%{%B%F{green}%} "
else
prompt_host=''
fi
}
PROMPT='$(nice_exit_code)${prompt_host}%{%b%F{yellow}%}$(directory_name)%E%{%f%k%b%} $(colored_prompt_char) %(#.%3{%F{red}❯❯❯%f%}.%1{❯%}%f) %{%f%k%b%}'
RPROMPT='$(oh_my_git_info)$(hg_prompt_info)$(svn_prompt_info)$(battery_level_gauge)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment