Last active
August 29, 2015 13:57
-
-
Save mapfel/9435808 to your computer and use it in GitHub Desktop.
MBP zsh prompt with GIT and battery status
This file contains 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
ZSH_THEME_GIT_PROMPT_PREFIX="[git:" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="]$reset_color" | |
ZSH_THEME_GIT_PROMPT_DIRTY="$fg[red]+" | |
ZSH_THEME_GIT_PROMPT_CLEAN="$fg[green]" | |
function git_prompt_info() { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX" | |
} | |
function battery_charge() { | |
if [ -e ~/SkyDrive/Config/batcharge.py ] | |
then | |
echo `python ~/SkyDrive/Config/batcharge.py` | |
else | |
echo '' | |
fi | |
} | |
function get_pwd() { | |
echo "${PWD/$HOME/~}" | |
} | |
function put_spacing() { | |
local git=$(git_prompt_info) | |
if [ ${#git} != 0 ]; then | |
((git = ${#git} - 10)) | |
else | |
git=0 | |
fi | |
local bat=$(battery_charge) | |
if [ ${#bat} != 0 ]; then | |
((bat=${#bat} - 18)) | |
else | |
bat=0 | |
fi | |
local termwidth; | |
((termwidth = ${COLUMNS} - 3 - ${#HOST} - ${#$(get_pwd)} - ${bat} - ${git})) | |
local spacing="" | |
for i in {1..$termwidth}; do | |
spacing="${spacing} " | |
done | |
echo $spacing; | |
} | |
PROMPT=' | |
$fg[cyan]%m: $fg[yellow]$(get_pwd)$(put_spacing)$(git_prompt_info) $(battery_charge) | |
$reset_color➜ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment