2022-01-15 19:00:35 +09:00
|
|
|
#! bash oh-my-bash.module
|
2017-10-10 18:07:01 +07:00
|
|
|
|
|
|
|
|
source "$OSH/themes/powerline/powerline.base.sh"
|
|
|
|
|
|
|
|
|
|
function __powerline_left_segment {
|
|
|
|
|
local OLD_IFS="${IFS}"; IFS="|"
|
|
|
|
|
local params=( $1 )
|
|
|
|
|
IFS="${OLD_IFS}"
|
|
|
|
|
|
2022-01-19 16:52:15 +09:00
|
|
|
LEFT_PROMPT+="${separator}$(set_color - ${params[1]}) ${params[0]} ${_omb_prompt_normal}"
|
2017-10-10 18:07:01 +07:00
|
|
|
LAST_SEGMENT_COLOR=${params[1]}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function __powerline_prompt_command {
|
|
|
|
|
local last_status="$?" ## always the first
|
|
|
|
|
|
|
|
|
|
LEFT_PROMPT=""
|
|
|
|
|
|
|
|
|
|
## left prompt ##
|
|
|
|
|
for segment in $POWERLINE_PROMPT; do
|
|
|
|
|
local info="$(__powerline_${segment}_prompt)"
|
|
|
|
|
[[ -n "${info}" ]] && __powerline_left_segment "${info}"
|
|
|
|
|
done
|
|
|
|
|
[[ "${last_status}" -ne 0 ]] && __powerline_left_segment $(__powerline_last_status_prompt ${last_status})
|
2022-01-19 16:52:15 +09:00
|
|
|
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -) ${_omb_prompt_normal}"
|
2017-10-10 18:07:01 +07:00
|
|
|
|
|
|
|
|
PS1="${LEFT_PROMPT} "
|
|
|
|
|
|
|
|
|
|
## cleanup ##
|
|
|
|
|
unset LEFT_PROMPT
|
|
|
|
|
}
|