Skip to content

Instantly share code, notes, and snippets.

@npatarino
Last active April 2, 2019 20:49
Show Gist options
  • Save npatarino/d689a16bf8824f240722b5644b2789fa to your computer and use it in GitHub Desktop.
Save npatarino/d689a16bf8824f240722b5644b2789fa to your computer and use it in GitHub Desktop.
colorUserHost="\[\033[01;32m\]"
colorNormal="\[\033[0m\]"
colorFolder="\[\033[01;34m\]"
colorBranch="\[\033[38;5;14m\]"
gitBranch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
branch=$(gitBranch)
if [ "$branch" != "" ]; then
branch=" $branch\n"
fi
basePrompt="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}$colorUserHost\u@\h$colorNormal:$colorFolder\w$colorNormal\$\n"
branchName="$colorBranch$branch$colorFolder > $colorNormal"
export PS1="$basePrompt$branchName"
PROMPT_COMMAND="source ~/.bashrc"
eval red=$fg[red]
eval green=$fg[green]
eval yellow=$fg[yellow]
eval blue=$fg[blue]
eval magenta=$fg[magenta]
eval cyan=$fg[cyan]
eval white=$fg[white]
eval grey=$fg[grey]
PROMPT='$(_user_host)${_current_dir}$(git_prompt_info)
%{$white%}>%{$reset_color%} '
PROMPT2='%{$grey%}◀%{$reset_color%} '
RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(git_remote_status) $(git_prompt_short_sha) ${_return_status} %{$white%}%T%{$(echotc DO 1)%}%{$reset_color%}'
local _current_dir="%{$green%}%0~%{$reset_color%} "
local _return_status="%{$red%}%(?..×)%{$reset_color%}"
function _user_host() {
echo "%{$red%}%n%{$reset_color%}%{$white%} at %{$yellow%}%m%{$reset_color%} %{$white%}in "
}
function _vi_status() {
if {echo $fpath | grep -q "plugins/vi-mode"}; then
echo "$(vi_mode_prompt_info)"
fi
}
if [[ $USER == "root" ]]; then
CARETCOLOR="$red"
else
CARETCOLOR="$white"
fi
MODE_INDICATOR="%{_bold$yellow%}❮%{$reset_color%}%{$yellow%}❮❮%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$white%}on %{$blue%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$red%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$green%}✔%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE="%{$red%}⬇%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE="%{$green%}⬆%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="%{$yellow%}⬌%{$reset_color%}"
# Format for git_prompt_long_sha() and git_prompt_short_sha()
ZSH_THEME_GIT_PROMPT_SHA_BEFORE="%{$reset_color%}[%{$yellow%}"
ZSH_THEME_GIT_PROMPT_SHA_AFTER="%{$reset_color%}]"
# LS colors, made with http://geoff.greer.fm/lscolors/
export LSCOLORS="exfxcxdxbxegedabagacad"
export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:'
export GREP_COLOR='1;33'
@npatarino
Copy link
Author

Add this code to ~/.bashrc, at the end for example

@npatarino
Copy link
Author

For mac with Oh My Zh!
Add it to the theme file.
For example to .oh-my-zsh/custom/materialshell.zsh-theme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment