Skip to content

Instantly share code, notes, and snippets.

@demaisj
Created June 6, 2017 00:16
Show Gist options
  • Save demaisj/9016188a9e30b0e303e7a735acf035a7 to your computer and use it in GitHub Desktop.
Save demaisj/9016188a9e30b0e303e7a735acf035a7 to your computer and use it in GitHub Desktop.
My personal terminal theme. To use with this custom color scheme: http://terminal.sexy/#Jiks-PjyJygi-SZypuIu9L91ZtnvroH_oe_k-PjydXFe-SZypuIu9L91ZtnvroH_oe_k-fj1
prompt_start() {
echo -n "%{%f%b%k%}"
}
prompt_status() {
if [[ $(jobs -l | wc -l) -gt 0 ]]; then
echo -n "%{$fg[yellow]%}⚙ %{$reset_color%}"
fi
}
prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
echo -n "%(!.%{$fg[red]%}.)$USER@%m%{$reset_color%}: "
fi
}
prompt_dir() {
echo -n "%{$fg_bold[cyan]%}%~%{$fg_no_bold[cyan]%}"
}
prompt_git() {
(( $+commands[git] )) || return
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="-$(git rev-parse --short HEAD 2> /dev/null)"
echo -n "%{$reset_color%}"
if [[ -n $dirty ]]; then
echo -n ":%{$fg[yellow]%}"
else
echo -n ":%{$fg[green]%}"
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 '+'
zstyle ':vcs_info:*' unstagedstr '✱'
zstyle ':vcs_info:*' formats '%u%c'
zstyle ':vcs_info:*' actionformats '%u%c'
vcs_info
echo -n "${ref/refs\/heads\/}${vcs_info_msg_0_%% }${mode}"
fi
}
prompt_arrow() {
if [[ $UID -eq 0 ]]; then
echo -n "%(0?.%{$fg_bold[yellow]%}.%{$fg_bold[red]%}) ⚡"
else
echo -n "%(0?.%{$fg_bold[green]%}.%{$fg_bold[red]%}) ➜"
fi
}
prompt_end() {
echo -n "%{%f%b%k%}"
}
build_prompt() {
RETVAL=$?
prompt_start
prompt_status
prompt_context
prompt_dir
prompt_git
prompt_arrow
prompt_end
}
PROMPT='$(build_prompt) '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment