mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-13 09:20:09 +00:00
* Added header with help and information
* Moved git information to left prompt, with support for: * +ZSH_THEME_GIT_PROMPT_UNTRACKED, MODIFIED, STASHED, ADDED, UPSTREAM STATUS (if applicable) * Removed right prompt * Refactored following Google's guidelines for scripts [ http://goo.gl/oJSXH2 ] * Using local variables where applicable
This commit is contained in:
parent
1f008b4113
commit
81eec406c8
1 changed files with 66 additions and 36 deletions
|
@ -1,44 +1,74 @@
|
||||||
# reference colors
|
# Michele Bologna's theme
|
||||||
GREEN="%{$fg_bold[green]%}"
|
# http://michelebologna.net
|
||||||
RED="%{$fg_bold[red]%}"
|
#
|
||||||
CYAN="%{$fg_bold[cyan]%}"
|
# This a theme for oh-my-zsh. Features a colored prompt with:
|
||||||
YELLOW="%{$fg_bold[yellow]%}"
|
# * username@host: [jobs] [git] workdir %
|
||||||
BLUE="%{$fg_bold[blue]%}"
|
# * hostname color is based on hostname characters. When using as root, the
|
||||||
MAGENTA="%{$fg_bold[magenta]%}"
|
# prompt shows only the hostname in red color.
|
||||||
WHITE="%{$fg_bold[white]%}"
|
# * [jobs], if applicable, counts the number of suspended jobs tty
|
||||||
|
# * [git], if applicable, represents the status of your git repo (more on that
|
||||||
|
# later)
|
||||||
|
# * '%' prompt will be green if last command return value is 0, yellow otherwise.
|
||||||
|
#
|
||||||
|
# git prompt is inspired by official git contrib prompt:
|
||||||
|
# https://github.com/git/git/tree/master/contrib/completion/git-prompt.sh
|
||||||
|
# and it adds:
|
||||||
|
# * the current branch
|
||||||
|
# * '%' if there are untracked files
|
||||||
|
# * '$' if there are stashed changes
|
||||||
|
# * '*' if there are modified files
|
||||||
|
# * '+' if there are added files
|
||||||
|
# * '<' if local repo is behind remote repo
|
||||||
|
# * '>' if local repo is ahead remote repo
|
||||||
|
# * '=' if local repo is equal to remote repo (in sync)
|
||||||
|
# * '<>' if local repo is diverged
|
||||||
|
|
||||||
COLOR_ARRAY=($GREEN $RED $CYAN $YELLOW $BLUE $MAGENTA $WHITE)
|
local green="%{$fg_bold[green]%}"
|
||||||
|
local red="%{$fg_bold[red]%}"
|
||||||
|
local cyan="%{$fg_bold[cyan]%}"
|
||||||
|
local yellow="%{$fg_bold[yellow]%}"
|
||||||
|
local blue="%{$fg_bold[blue]%}"
|
||||||
|
local magenta="%{$fg_bold[magenta]%}"
|
||||||
|
local white="%{$fg_bold[white]%}"
|
||||||
|
local reset="%{$reset_color%}"
|
||||||
|
|
||||||
# color reset
|
local -a color_array
|
||||||
RESET_COLOR="%{$reset_color%}"
|
color_array=($green $red $cyan $yellow $blue $magenta $white)
|
||||||
|
|
||||||
# which color should be applied?
|
local username_normal_color=$white
|
||||||
USERNAME_NORMAL_COLOR=$WHITE
|
local username_root_color=$red
|
||||||
USERNAME_ROOT_COLOR=$RED
|
local hostname_root_color=$red
|
||||||
HOSTNAME_NORMAL_COLOR=$BLUE
|
|
||||||
# uncomment next line if you want auto-generated hostname color
|
|
||||||
#for i in $HOST; HOSTNAME_NORMAL_COLOR=$COLOR_ARRAY[$[((#i))%7+1]]
|
|
||||||
HOSTNAME_ROOT_COLOR=$RED
|
|
||||||
HOSTNAME_COLOR=%(!.$HOSTNAME_ROOT_COLOR.$HOSTNAME_NORMAL_COLOR)
|
|
||||||
CURRENT_DIR_COLOR=$CYAN
|
|
||||||
|
|
||||||
# zsh commands
|
# calculating hostname color with hostname characters
|
||||||
USERNAME_COMMAND="%n"
|
for i in `hostname`; local hostname_normal_color=$color_array[$[((#i))%7+1]]
|
||||||
HOSTNAME_COMMAND="%m"
|
local -a hostname_color
|
||||||
CURRENT_DIR="%~"
|
hostname_color=%(!.$hostname_root_color.$hostname_normal_color)
|
||||||
|
|
||||||
# output: colors + commands
|
local current_dir_color=$blue
|
||||||
USERNAME_OUTPUT="%(!..$USERNAME_NORMAL_COLOR$USERNAME_COMMAND$RESET_COLOR@)"
|
local username_command="%n"
|
||||||
HOSTNAME_OUTPUT="$HOSTNAME_COLOR$HOSTNAME_COMMAND$RESET_COLOR"
|
local hostname_command="%m"
|
||||||
CURRENT_DIR_OUTPUT="$CURRENT_DIR_COLOR$CURRENT_DIR"
|
local current_dir="%~"
|
||||||
LAST_COMMAND_OUTPUT="%(?.%(!.$RED.$GREEN).$YELLOW)"
|
|
||||||
|
|
||||||
# git theming
|
local username_output="%(!..$username_normal_color$username_command$reset@)"
|
||||||
ZSH_THEME_GIT_PROMPT_PREFIX="("
|
local hostname_output="$hostname_color$hostname_command$reset"
|
||||||
|
local current_dir_output="$current_dir_color$current_dir$reset"
|
||||||
|
local jobs_bg="${red}fg: %j$reset"
|
||||||
|
local last_command_output="%(?.%(!.$red.$green).$yellow)"
|
||||||
|
|
||||||
|
ZSH_THEME_GIT_PROMPT_PREFIX=""
|
||||||
ZSH_THEME_GIT_PROMPT_SUFFIX=""
|
ZSH_THEME_GIT_PROMPT_SUFFIX=""
|
||||||
ZSH_THEME_GIT_PROMPT_DIRTY=")$RED*"
|
ZSH_THEME_GIT_PROMPT_DIRTY=""
|
||||||
ZSH_THEME_GIT_PROMPT_CLEAN=")"
|
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
||||||
|
ZSH_THEME_GIT_PROMPT_UNTRACKED="%%"
|
||||||
|
ZSH_THEME_GIT_PROMPT_MODIFIED="*"
|
||||||
|
ZSH_THEME_GIT_PROMPT_ADDED="+"
|
||||||
|
ZSH_THEME_GIT_PROMPT_STASHED="$"
|
||||||
|
ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE="="
|
||||||
|
ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE=">"
|
||||||
|
ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE="<"
|
||||||
|
ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="<>"
|
||||||
|
|
||||||
# wrap all together
|
PROMPT='$username_output$hostname_output:$current_dir_output%1(j. [$jobs_bg].)'
|
||||||
PROMPT='$USERNAME_OUTPUT$HOSTNAME_OUTPUT:$CURRENT_DIR_OUTPUT $LAST_COMMAND_OUTPUT%#$RESET_COLOR '
|
PROMPT+='$(__git_ps1)'
|
||||||
RPROMPT='%1(j.fg: [%j].) $GREEN$(git_prompt_info)$RESET_COLOR [%@]'
|
PROMPT+=" $last_command_output%#$reset "
|
||||||
|
RPROMPT=''
|
||||||
|
|
Loading…
Reference in a new issue