Fored from https://github.com/lixiaoyan/powerline-bash/blob/master/powerline.sh
Last active
August 29, 2015 14:13
-
-
Save orzFly/810c09ab682eb59a2225 to your computer and use it in GitHub Desktop.
powerline-zsh
This file contains hidden or 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
local COLOR_FG_WHITE="%{$(tput setaf 7)%}" | |
local COLOR_FG_GRAY="%{$(tput setaf 8)%}" | |
local COLOR_FG_FAILURE="%{$(tput setaf 1)%}" | |
local COLOR_FG_SUCCESS="%{$(tput setaf 4)%}" | |
local COLOR_FG="%{$(tput setaf 0)%}" | |
local COLOR_BG_FAILURE="%{$(tput setab 1)%}" | |
local COLOR_BG_SUCCESS="%{$(tput setab 4)%}" | |
local COLOR_BG="%{$(tput setab 7)%}" | |
local COLOR_RESET="%{$(tput sgr0)%}" | |
readonly _ZSH_POWERLINE_SEP="$COLOR_FG_GRAY"$'\uE0B1'"$COLOR_FG" | |
__ps1() { | |
local ret=$? | |
local state_bg | |
local state_fg | |
if [ $ret -eq 0 ]; then | |
state_fg="$COLOR_FG_SUCCESS" | |
state_bg="$COLOR_BG_SUCCESS" | |
else | |
state_fg="$COLOR_FG_FAILURE" | |
state_bg="$COLOR_BG_FAILURE" | |
fi | |
local __pwd="$PWD" | |
[[ "$__pwd" =~ ^"$HOME"(/|$) ]] && __pwd="${__pwd/#$HOME/~}" | |
__pwd=("${(s./.)__pwd}") | |
test "$__pwd[1]" = "" && __pwd[1]="/" | |
PS1="$COLOR_FG$COLOR_BG" | |
PS1+=" ${(j. $_ZSH_POWERLINE_SEP .)__pwd} " | |
PS1+="$COLOR_FG_WHITE$state_bg"$'\uE0B0'"$COLOR_FG" | |
PS1+=" $ " | |
PS1+="$COLOR_RESET$state_fg"$'\uE0B0' | |
PS1+="$COLOR_RESET " | |
return $ret | |
} | |
precmd_functions=(__ps1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment