Skip to content

Instantly share code, notes, and snippets.

@lpadukana
Last active July 10, 2016 13:03
Show Gist options
  • Select an option

  • Save lpadukana/9692f9fe27362e76818c48c2865a4e0e to your computer and use it in GitHub Desktop.

Select an option

Save lpadukana/9692f9fe27362e76818c48c2865a4e0e to your computer and use it in GitHub Desktop.
#!/usr/bin/env zsh
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[blue]%}."
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}Δ%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}✓%{$reset_color%} "
ruby_ver() {
echo "%{$fg[magenta]%}rb:$(chruby_auto; echo $RUBY_VERSION) "
}
python_ver() {
# add `changeps1: False` to ~/.condarc to disable PS1 mutilation
if [[ -n "$CONDA_ENV_PATH" ]]; then
echo "%{$fg[green]%}conda:${CONDA_ENV_PATH##*\/} "
else
echo "%{$fg[green]%}py:$(python --version 2>&1 | cut -d' ' -f2) "
fi
}
node_ver() {
echo "%{$fg[cyan]%}node:$(node --version) "
}
setopt PROMPT_SUBST
function git_prompt_info() {
if [[ "$(command git config --get prompt.hide-status 2>/dev/null)" != "1" ]]; then
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/} $(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
fi
}
parse_git_dirty() {
local STATUS=''
local FLAGS
FLAGS=('--porcelain')
if [[ "$(command git config --get prompt.hide-dirty)" != "1" ]]; then
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
FLAGS+='--ignore-submodules=dirty'
fi
if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
FLAGS+='--untracked-files=no'
fi
STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1)
fi
if [[ -n $STATUS ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
else
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
fi
}
# PROMPT_ARROW="%(?.❯❯.%? ❯❯) "
# PROMPT_ARROW="%(?.%{$fg[green]%}❯❯.%{$fg[red]%}%? ❯❯) %{$reset_color%}"
PROMPT_ARROW="%(?..%{$fg[red]%}err: %? )%{$fg[cyan]%}❯❯ %{$reset_color%}"
# PROMPT_ARROW="%(?..err: %{$fg[red]%}%? )%{$fg[cyan]%}❯❯ %{$reset_color%}"
# PROMPT_LINE="%(?.%{$fg[green]%}.%{$fg[red]%})\$(printf %\${COLUMNS}s | tr ' ' '▬')
# ▌%{$reset_color%}"
PROMPT_LINE="%(?.%{$fg[green]%}.%{$fg[red]%})\$(printf %\${COLUMNS}s | tr ' ' '▬')%{$reset_color%}"
PROMPT_DIR="%~%{$reset_color%} "
# PROMPT_DIR="%c%{$reset_color%} "
export PROMPT="${PROMPT_LINE}
${PROMPT_DIR}\$(git_prompt_info)\$(python_ver)\$(node_ver)\$(ruby_ver)
${PROMPT_ARROW}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment