Update ZSH theme

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-11-17 00:17:13 +01:00
parent 08ea6abf2b
commit 60d08b8998
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -1,7 +1,6 @@
# luzifer.zsh-theme # luzifer.zsh-theme
# Use with a dark background and 256-color terminal! # Use with a dark background and 256-color terminal!
# Meant for people with RVM and git. Tested only on OS X 10.7.
# You can set your computer name in the ~/.box-name file if you want. # You can set your computer name in the ~/.box-name file if you want.
@ -11,72 +10,81 @@
# #
# Also borrowing from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/ # Also borrowing from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
function prompt_char { function box_color() {
git branch >/dev/null 2>/dev/null && echo '⠠⠵' && return
echo '○'
}
function box_color {
[ -f ~/.box_color ] && cat ~/.box_color || ~/bin/color_from_hostname.py [ -f ~/.box_color ] && cat ~/.box_color || ~/bin/color_from_hostname.py
} }
function box_name { function box_name() {
[ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST} [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
} }
function git_describe { function git_describe() {
git describe --tags 2>/dev/null || git rev-parse --short HEAD 2>/dev/null || echo "" git describe --tags 2>/dev/null || git rev-parse --short HEAD 2>/dev/null || printf '\ue701'
} }
function awsenv_prompt { function awsenv_prompt() {
local pr=$(awsenv prompt 2>/dev/null) local pr=$(awsenv prompt 2>/dev/null)
[ -z "${pr}" ] || echo "${bracket_open} ${pr} ${bracket_close}" [ -z "${pr}" ] || echo "${bracket_open} ${pr} ${bracket_close}"
} }
function config-git_prompt { function config-git_prompt() {
if [ -f ~/bin/config-git-status.sh ]; then if [ -f ~/bin/config-git-status.sh ]; then
if ! ( ~/bin/config-git-status.sh ); then if ! (~/bin/config-git-status.sh); then
echo "${bracket_open} %{$fg[red]%} ${bracket_close}" echo "${bracket_open} %{$fg[red]%} ${bracket_close}"
fi fi
fi fi
} }
function build_git_prompt { function build_git_prompt() {
$( test "${NO_RIGHT}" = "true" ) && return # Allow hiding the right side of the prompt
(test "${NO_RIGHT}" = "true") && return
# When there is no git, don't show a git prompt
git branch >/dev/null 2>/dev/null || return git branch >/dev/null 2>/dev/null || return
local INDEX=$(command git status --porcelain -b 2> /dev/null)
echo -n "${bracket_open} %{$fg[blue]%}" # Fetch status of the current repo
local INDEX=$(command git status --porcelain -b 2>/dev/null)
local REMOTE=$(command git remote -v | grep fetch) local REMOTE=$(command git remote -v | grep fetch)
(echo "$REMOTE" | grep -q bitbucket.org) && echo -n "B "
(echo "$REMOTE" | grep -q github.com) && echo -n "G " echo -n "${bracket_open} %{$fg[blue]%}"
(echo "$REMOTE" | grep -q gitlab.com) && echo -n "L "
(echo "$REMOTE" | grep -q collins.kg) && echo -n "C " # Mark specific remotes
case "${REMOTE}" in
*bitbucket.org*)
printf '\ue703 '
;;
*github.com*)
printf '\ue709 '
;;
*gitlab.com*)
printf '\uf296 '
;;
*)
printf '\uf1d3 '
;;
esac
# Show current branch and commit / tag
echo -n "%{$reset_color%}" echo -n "%{$reset_color%}"
echo -n "$(git_current_branch) " echo -n "$(git_current_branch) "
echo -n "($(git_describe)) " echo -n "($(git_describe)) "
# Repository status
echo -n "%{$FG[236]%}" # Print repository status information
( echo "$INDEX" | grep -E '^\?\? ' &> /dev/null ) && echo -n "%{$fg[blue]%}" [ $(echo "$INDEX" | wc -l) -gt 1 ] && echo -n "%{$fg[red]%}$(printf '\uf0f6')%{$FG[236]%} "
echo -n "U%{$FG[236]%}"
( echo "$INDEX" | grep -E '^(A |M ) ' &> /dev/null ) && echo -n "%{$fg[green]%}" (git rev-parse --verify refs/stash >/dev/null 2>&1) && echo -n "%{$fg[blue]%}$(printf '\uf64c')%{$FG[236]%} "
echo -n "A%{$FG[236]%}"
( echo "$INDEX" | grep -E '^( M|AM| T) ' &> /dev/null ) && echo -n "%{$fg[yellow]%}" # Show difference to remote
echo -n "M%{$FG[236]%}" if (echo "$INDEX" | grep '^## .*ahead.*behind' &>/dev/null); then
( echo "$INDEX" | grep -E '^R ' &> /dev/null ) && echo -n "%{$fg[yellow]%}" echo -n "%{$fg[red]%}$(printf '\uf047')"
echo -n "R%{$FG[236]%}" elif (echo "$INDEX" | grep '^## .*ahead' &>/dev/null); then
( echo "$INDEX" | grep -E '^( D|D |AD) ' &> /dev/null ) && echo -n "%{$fg[red]%}" echo -n "%{$fg[green]%}$(printf '\uf061')"
echo -n "D%{$FG[236]%}" elif (echo "$INDEX" | grep '^## .*behind' &>/dev/null); then
( git rev-parse --verify refs/stash >/dev/null 2>&1 ) && echo -n "%{$fg[green]%}" echo -n "%{$fg[yellow]%}$(printf '\uf060')"
echo -n "S%{$FG[236]%}"
if ( echo "$INDEX" | grep '^## .*ahead.*behind' &> /dev/null ); then
echo -n "%{$fg[red]%}↔"
elif ( echo "$INDEX" | grep '^## .*ahead' &> /dev/null ); then
echo -n "%{$fg[green]%}→"
elif ( echo "$INDEX" | grep '^## .*behind' &> /dev/null ); then
echo -n "%{$fg[yellow]%}←"
else else
echo -n "%{$fg[green]%}=" echo -n "%{$fg[green]%}="
fi fi
echo -n "%{$reset_color%} ${bracket_close}" echo -n "%{$reset_color%} ${bracket_close}"
} }
@ -94,8 +102,8 @@ local prompt_part_char='$(prompt_char)'
local prompt_part_configgit='$(config-git_prompt)' local prompt_part_configgit='$(config-git_prompt)'
PROMPT=" PROMPT="
╭─ ${prompt_part_time}${prompt_part_user}${prompt_part_configgit}$(awsenv_prompt)${prompt_part_exit} ${prompt_part_path} ╭─ ${prompt_part_time}${prompt_part_user}${prompt_part_configgit}${prompt_part_exit} ${prompt_part_path}
╰─${prompt_part_char} " ╰─ "
RPROMPT="${git_info}" RPROMPT="${git_info}"
@ -105,3 +113,5 @@ ZSH_THEME_GIT_PROMPT_SUFFIX=""
# Format for git_prompt_long_sha() and git_prompt_short_sha() # Format for git_prompt_long_sha() and git_prompt_short_sha()
ZSH_THEME_GIT_PROMPT_SHA_BEFORE="" ZSH_THEME_GIT_PROMPT_SHA_BEFORE=""
ZSH_THEME_GIT_PROMPT_SHA_AFTER="" ZSH_THEME_GIT_PROMPT_SHA_AFTER=""
# vim: set ft=zsh: