autoload -U colors && colors function set_prompt() { PS1="[%{$fg[yellow]%}%D{%H:%M:%S}%{$reset_color%}] %{$fg[green]%}%n%{$fg[cyan]%}@%m %{$fg[magenta]%}%~%{$reset_color%} $(git_prompt_info)%(?..%{$fg[red]%})$ %{$reset_color%}" } function __git_prompt_git() { GIT_OPTIONAL_LOCKS=0 command git "$@" } function git_prompt_info() { if ! __git_prompt_git rev-parse --git-dir &> /dev/null ; then return 0 fi echo "%{$reset_color%}\ue725 on %{$fg[green]%}$(git_current_branch)$(parse_git_dirty)%{$reset_color%} " } function git_current_branch() { local ref ref=$(__git_prompt_git symbolic-ref --quiet HEAD 2> /dev/null) local ret=$? if [[ $ret != 0 ]]; then [[ $ret == 128 ]] && return # no git repo. ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) || return fi echo ${ref#refs/heads/} } function parse_git_dirty() { local STATUS local -a FLAGS FLAGS=('--porcelain') if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then FLAGS+='--untracked-files=no' fi case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in git) # let git decide (this respects per-repo config in .gitmodules) ;; *) # if unset: ignore dirty submodules # other values are passed to --ignore-submodules FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}" ;; esac STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1) fi if [[ -n $STATUS ]]; then echo "%{$fg[yellow]%}%1{±%}" fi } set_prompt chpwd_functions+=(set_prompt)