my.zsh/themes/lxsameer.zsh-theme

65 lines
1.3 KiB
Plaintext
Raw Normal View History

2013-04-11 22:25:45 +01:00
# lxsameer.zsh-theme
#
# Author: @lxsameer <lxsameer@gnu.org>
2013-05-06 15:49:28 +01:00
# Repo: https://github.com/lxsameer/My.Zsh
2013-04-11 22:25:45 +01:00
#
# Created on: Apr 10, 2012
function my_git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
2016-04-23 13:30:28 +01:00
echo "$ZSH_THEME_GIT_PROMPT_PREFIX $(parse_git_dirty)${ref#refs/heads/} %F{007}\uf126 $ZSH_THEME_GIT_PROMPT_SUFFIX"
2013-04-11 22:25:45 +01:00
}
function get_pwd() {
echo "${PWD/$HOME/~}"
}
function spaces() {
local git=$(my_git_prompt_info)
if [ ${#git} != 0 ]; then
local clean=$(parse_git_dirty)
if [ ${#clean} != 0 ]; then
2016-04-23 13:24:36 +01:00
(( git = ${#git} - 20 - ${#clean} + 1 ))
2013-04-11 22:25:45 +01:00
else
2016-04-23 13:24:36 +01:00
(( git = ${#git} - 20 ))
2013-04-11 22:25:45 +01:00
fi
else
git=0
fi
local termwidth
2016-04-23 13:24:36 +01:00
(( termwidth = ${COLUMNS} - 7 - ${#$(get_pwd)} - ${git} ))
2013-04-11 22:25:45 +01:00
local spacing=" "
for i in {1..$termwidth}; do
spacing="${spacing}-"
done
echo $spacing
}
function user_sign () {
if [ $UID != 0 ]; then
2016-04-23 12:58:27 +01:00
echo "%F{002}\uf058"
2013-04-11 22:25:45 +01:00
else
2016-04-23 12:58:27 +01:00
echo "%F{009}\uf071"
2013-04-11 22:25:45 +01:00
fi
}
2016-04-23 12:58:27 +01:00
function path_icon () {
2016-04-23 13:30:28 +01:00
echo "%F{0033}\uf0c1"
}
function code_icon () {
echo "%F{007}\uf121 "
2016-04-23 12:58:27 +01:00
}
2013-04-11 22:25:45 +01:00
PROMPT='
2016-04-23 13:24:36 +01:00
$(user_sign) $(path_icon) %F{003}%~%F{008}$(spaces) $(my_git_prompt_info)
2016-04-23 13:30:28 +01:00
$(code_icon)%f'
2013-04-11 22:25:45 +01:00
# git settings
2013-05-06 12:54:02 +01:00
ZSH_THEME_GIT_PROMPT_PREFIX="%F{002}["
2013-04-11 22:25:45 +01:00
ZSH_THEME_GIT_PROMPT_CLEAN=""
2013-05-06 12:54:02 +01:00
ZSH_THEME_GIT_PROMPT_DIRTY="%F{003}*"
ZSH_THEME_GIT_PROMPT_SUFFIX="%F{002}]"