Last active
February 26, 2016 12:10
-
-
Save kristopherjohnson/74b1d0aa3ca271c9ccc6 to your computer and use it in GitHub Desktop.
Personal oh-my-zsh theme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # If in a Mercurial repository, output "<branch:bookmark/qtop+*->", where | |
| # "branch" is the current branch | |
| # ":bookmark" is the active bookmark, if any | |
| # "/qtop" is the current patch, if any | |
| # "+" if any files have been added | |
| # "-" if any files have been removed | |
| # "*" if any files have been modified | |
| # "?" if any files exist that have not been added | |
| # | |
| # If not in a Mercurial repository, produce no output. | |
| kdj_hg_prompt() { | |
| local summary="$(hg summary 2>/dev/null)" | |
| if [[ -z $summary ]]; then return; fi | |
| local branch="$(echo \"$summary\" | sed -E -n '/^branch: ([^ ]+).*$/ s//\1/p')" | |
| local bookmark="$(echo \"$summary\" | sed -E -n '/^bookmarks: \*([^ ]+).*$/ s//:\1/p')" | |
| # Use qtop to get current patch. | |
| # Special handling for "no patches applied" and for the error message that | |
| # is generated if the mq extension is not enabled. | |
| local qtop=$(hg qtop 2>/dev/null | sed -E -n ' | |
| /no patches applied/ q | |
| /is provided by the following extension/ q | |
| /(.+)/ s//\/\1/p | |
| ') | |
| local commit="$(echo \"$summary\" | sed -n '/^commit: .*$/p')" | |
| local mod="$(echo \"$commit\" | sed -n '/.*modified.*/ s//*/p')" | |
| local unk="$(echo \"$commit\" | sed -n '/.*unknown.*/ s//?/p')" | |
| local add="$(echo \"$commit\" | sed -n '/.*added.*/ s//+/p')" | |
| local del="$(echo \"$commit\" | sed -n '/.*removed.*/ s//-/p')" | |
| echo "<$branch$bookmark$qtop$add$del$mod$unk>" | |
| } | |
| # If in a Git repository, output "[branch+-%=*?^]", where | |
| # "branch" is the current branch | |
| # "+" if files have been added to the working directory but not the index | |
| # "-" if files have been removed from the working directory but not the index | |
| # "%" if files have been renamed in the working directory but not the index | |
| # "=" if files have been copied in the working directory but not the index | |
| # "?" if files exist in the working directory that have not been added or ignored | |
| # "^" if the index is not empty | |
| # | |
| # If not in a Git repository, produce no output. | |
| kdj_git_prompt() { | |
| local branch="$(git branch --no-color 2>/dev/null | sed -n '/* \(.*\)/ s//\1/p')" | |
| if [[ -z $branch ]]; then return; fi | |
| local stat="$(git status --porcelain 2>/dev/null)" | |
| local add=$(echo "$stat" | sed -n '/^.A.*$/ s//+/p' | head -n 1) | |
| local del=$(echo "$stat" | sed -n '/^.D.*$/ s//-/p' | head -n 1) | |
| local mod=$(echo "$stat" | sed -n '/^.M.*$/ s//*/p' | head -n 1) | |
| local ren=$(echo "$stat" | sed -n '/^.R.*$/ s//%/p' | head -n 1) | |
| local cop=$(echo "$stat" | sed -n '/^.C.*$/ s//=/p' | head -n 1) | |
| local unk=$(echo "$stat" | sed -n '/^??.*$/ s//?/p' | head -n 1) | |
| local dir=$(echo "$stat" | sed -n '/^[ADMRC].*$/ s//^/p' | head -n 1) | |
| echo "[$branch$add$del$ren$cop$mod$unk$dir]" | |
| } | |
| export PROMPT='%B%{$fg[yellow]%}%n@%m %2~ %# %{$reset_color%}%b' | |
| export RPROMPT='$(kdj_hg_prompt)$(kdj_git_prompt)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment