1
0
Fork 0
mirror of synced 2024-11-26 17:25:35 -05:00

update eriner prompt

This commit is contained in:
Matt Hamilton 2015-12-15 19:21:06 -05:00
parent 6bab0875fd
commit 25cec0876a
2 changed files with 46 additions and 64 deletions

View file

@ -1,6 +1,4 @@
# vim:ft=zsh ts=2 sw=2 sts=2 # Eriner's Theme - fork of agnoster
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH # A Powerline-inspired theme for ZSH
# #
# # README # # README
@ -8,11 +6,6 @@
# In order for this theme to render correctly, you will need a # In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://gist.github.com/1595572). # [Powerline-patched font](https://gist.github.com/1595572).
# #
# In addition, I recommend the
# [Solarized theme](https://github.com/altercation/solarized/) and, if you're
# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app -
# it has significantly better color fidelity.
#
# # Goals # # Goals
# #
# The aim of this theme is to only show you *relevant* information. Like most # The aim of this theme is to only show you *relevant* information. Like most
@ -42,21 +35,21 @@ GEAR="\u2699"
# rendering default background/foreground. # rendering default background/foreground.
prompt_segment() { prompt_segment() {
local bg fg local bg fg
[[ -n $1 ]] && bg="%K{$1}" || bg="%k" [[ -n ${1} ]] && bg="%K{${1}}" || bg="%k"
[[ -n $2 ]] && fg="%F{$2}" || fg="%f" [[ -n ${2} ]] && fg="%F{${2}}" || fg="%f"
if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then if [[ $CURRENT_BG != 'NONE' && ${1} != $CURRENT_BG ]]; then
print -n "%{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%}" print -n "%{${bg}%F{${CURRENT_BG}}%}${SEGMENT_SEPARATOR}%{${fg}%}"
else else
print -n "%{$bg%}%{$fg%}" print -n "%{${bg}%}%{${fg}%}"
fi fi
CURRENT_BG=$1 CURRENT_BG=${1}
[[ -n $3 ]] && print -n $3 [[ -n ${3} ]] && print -n ${3}
} }
# End the prompt, closing any open segments # End the prompt, closing any open segments
prompt_end() { prompt_end() {
if [[ -n $CURRENT_BG ]]; then if [[ -n $CURRENT_BG ]]; then
print -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" print -n "%{%k%F{${CURRENT_BG}}%}${SEGMENT_SEPARATOR}"
else else
print -n "%{%k%}" print -n "%{%k%}"
fi fi
@ -69,10 +62,8 @@ prompt_end() {
# Context: user@hostname (who am I and where am I) # Context: user@hostname (who am I and where am I)
prompt_context() { prompt_context() {
local user=`whoami` if [[ ${USERNAME} != ${DEFAULT_USER} || -n ${SSH_CONNECTION} ]]; then
prompt_segment ${PRIMARY_FG} default " %(!.%{%F{yellow}%}.)${USERNAME}@%m "
if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CONNECTION" ]]; then
prompt_segment $PRIMARY_FG default " %(!.%{%F{yellow}%}.)$user@%m "
fi fi
} }
@ -82,28 +73,28 @@ prompt_git() {
is_dirty() { is_dirty() {
test -n "$(git status --porcelain --ignore-submodules)" test -n "$(git status --porcelain --ignore-submodules)"
} }
ref="$vcs_info_msg_0_" ref=${vcs_info_msg_0_}
if [[ -n "$ref" ]]; then if [[ -n ${ref} ]]; then
if is_dirty; then if is_dirty; then
color=yellow color=yellow
ref="${ref} $PLUSMINUS" ref="${ref} ${PLUSMINUS}"
else else
color=green color=green
ref="${ref} " ref="${ref} "
fi fi
if [[ "${ref/.../}" == "$ref" ]]; then if [[ "${ref/.../}" == ${ref} ]]; then
ref="$BRANCH $ref" ref="${BRANCH} ${ref}"
else else
ref="$DETACHED ${ref/.../}" ref="$DETACHED ${ref/.../}"
fi fi
prompt_segment $color $PRIMARY_FG prompt_segment ${color} ${PRIMARY_FG}
print -Pn " $ref" print -Pn " ${ref}"
fi fi
} }
# Dir: current working directory # Dir: current working directory
prompt_dir() { prompt_dir() {
prompt_segment cyan $PRIMARY_FG ' %~ ' prompt_segment cyan ${PRIMARY_FG} ' %~ '
} }
# Status: # Status:
@ -113,11 +104,11 @@ prompt_dir() {
prompt_status() { prompt_status() {
local symbols local symbols
symbols=() symbols=()
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}$CROSS" [[ ${RETVAL} -ne 0 ]] && symbols+="%{%F{red}%}${CROSS}"
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}$LIGHTNING" [[ ${UID} -eq 0 ]] && symbols+="%{%F{yellow}%}${LIGHTNING}"
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}$GEAR" [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}${GEAR}"
[[ -n "$symbols" ]] && prompt_segment $PRIMARY_FG default " $symbols " [[ -n ${symbols} ]] && prompt_segment ${PRIMARY_FG} default " ${symbols} "
} }
## Main prompt ## Main prompt

View file

@ -1,6 +1,4 @@
# vim:ft=zsh ts=2 sw=2 sts=2 # Eriner's Theme - fork of agnoster
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH # A Powerline-inspired theme for ZSH
# #
# # README # # README
@ -8,11 +6,6 @@
# In order for this theme to render correctly, you will need a # In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://gist.github.com/1595572). # [Powerline-patched font](https://gist.github.com/1595572).
# #
# In addition, I recommend the
# [Solarized theme](https://github.com/altercation/solarized/) and, if you're
# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app -
# it has significantly better color fidelity.
#
# # Goals # # Goals
# #
# The aim of this theme is to only show you *relevant* information. Like most # The aim of this theme is to only show you *relevant* information. Like most
@ -42,21 +35,21 @@ GEAR="\u2699"
# rendering default background/foreground. # rendering default background/foreground.
prompt_segment() { prompt_segment() {
local bg fg local bg fg
[[ -n $1 ]] && bg="%K{$1}" || bg="%k" [[ -n ${1} ]] && bg="%K{${1}}" || bg="%k"
[[ -n $2 ]] && fg="%F{$2}" || fg="%f" [[ -n ${2} ]] && fg="%F{${2}}" || fg="%f"
if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then if [[ $CURRENT_BG != 'NONE' && ${1} != $CURRENT_BG ]]; then
print -n "%{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%}" print -n "%{${bg}%F{${CURRENT_BG}}%}${SEGMENT_SEPARATOR}%{${fg}%}"
else else
print -n "%{$bg%}%{$fg%}" print -n "%{${bg}%}%{${fg}%}"
fi fi
CURRENT_BG=$1 CURRENT_BG=${1}
[[ -n $3 ]] && print -n $3 [[ -n ${3} ]] && print -n ${3}
} }
# End the prompt, closing any open segments # End the prompt, closing any open segments
prompt_end() { prompt_end() {
if [[ -n $CURRENT_BG ]]; then if [[ -n $CURRENT_BG ]]; then
print -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" print -n "%{%k%F{${CURRENT_BG}}%}${SEGMENT_SEPARATOR}"
else else
print -n "%{%k%}" print -n "%{%k%}"
fi fi
@ -69,10 +62,8 @@ prompt_end() {
# Context: user@hostname (who am I and where am I) # Context: user@hostname (who am I and where am I)
prompt_context() { prompt_context() {
local user=`whoami` if [[ ${USERNAME} != ${DEFAULT_USER} || -n ${SSH_CONNECTION} ]]; then
prompt_segment ${PRIMARY_FG} default " %(!.%{%F{yellow}%}.)${USERNAME}@%m "
if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CONNECTION" ]]; then
prompt_segment $PRIMARY_FG default " %(!.%{%F{yellow}%}.)$user@%m "
fi fi
} }
@ -82,28 +73,28 @@ prompt_git() {
is_dirty() { is_dirty() {
test -n "$(git status --porcelain --ignore-submodules)" test -n "$(git status --porcelain --ignore-submodules)"
} }
ref="$vcs_info_msg_0_" ref=${vcs_info_msg_0_}
if [[ -n "$ref" ]]; then if [[ -n ${ref} ]]; then
if is_dirty; then if is_dirty; then
color=yellow color=yellow
ref="${ref} $PLUSMINUS" ref="${ref} ${PLUSMINUS}"
else else
color=green color=green
ref="${ref} " ref="${ref} "
fi fi
if [[ "${ref/.../}" == "$ref" ]]; then if [[ "${ref/.../}" == ${ref} ]]; then
ref="$BRANCH $ref" ref="${BRANCH} ${ref}"
else else
ref="$DETACHED ${ref/.../}" ref="$DETACHED ${ref/.../}"
fi fi
prompt_segment $color $PRIMARY_FG prompt_segment ${color} ${PRIMARY_FG}
print -Pn " $ref" print -Pn " ${ref}"
fi fi
} }
# Dir: current working directory # Dir: current working directory
prompt_dir() { prompt_dir() {
prompt_segment cyan $PRIMARY_FG ' %~ ' prompt_segment cyan ${PRIMARY_FG} ' %~ '
} }
# Status: # Status:
@ -113,11 +104,11 @@ prompt_dir() {
prompt_status() { prompt_status() {
local symbols local symbols
symbols=() symbols=()
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}$CROSS" [[ ${RETVAL} -ne 0 ]] && symbols+="%{%F{red}%}${CROSS}"
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}$LIGHTNING" [[ ${UID} -eq 0 ]] && symbols+="%{%F{yellow}%}${LIGHTNING}"
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}$GEAR" [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}${GEAR}"
[[ -n "$symbols" ]] && prompt_segment $PRIMARY_FG default " $symbols " [[ -n ${symbols} ]] && prompt_segment ${PRIMARY_FG} default " ${symbols} "
} }
## Main prompt ## Main prompt