WIP: more fixes to the prompts

pull/1944/head
Konstantin Gredeskoul 2021-04-08 15:24:51 -07:00
parent f1fa5e0ccd
commit 380cfb3343
No known key found for this signature in database
GPG Key ID: F64DECB748F527EB
1 changed files with 21 additions and 25 deletions

View File

@ -177,13 +177,13 @@ function powerline.prompt.choose() {
} }
local left="$1" local left="$1"
local rigth="$2" local right="$2"
if [[ -z ${right} ]]; then if [[ -z ${right} ]]; then
export BASH_IT_THEME="powerline" export BASH_IT_THEME="powerline"
export POWERLINE_PROMPT="$(powerline.filter-and-print "$*")"
else else
export BASH_IT_THEME="powerline-multiline" export BASH_IT_THEME="powerline-multiline"
fi
for component_string in "left" "right"; do for component_string in "left" "right"; do
local -a components local -a components
@ -191,23 +191,18 @@ function powerline.prompt.choose() {
components=(${!component_string}) components=(${!component_string})
# shellcheck disable=2207 # shellcheck disable=2207
components=($(powerline.filter-and-print "${components[@]}")) components=($(powerline.filter-and-print "${components[*]}"))
done done
fi
[[ -z ${right} ]] && {
# Single-line Powerline Prompts
export POWERLINE_PROMPT="${POWERLINE_LEFT_PROMPT}"
}
} }
# usage: powerline.prompt.randomize [ lang [ lang ]... ] # usage: powerline.prompt.randomize [ lang [ lang ]... ]
# eg: powerline.prompt.randomize cwd ruby go node battery # eg: powerline.prompt.randomize cwd ruby go node battery
function powerline.prompt.randomize() { function powerline.prompt.randomize() {
local -a components local -a components
local -a randomized
if [[ -z $* ]]; then if [[ -z $* ]]; then
# shellcheck disable=2207 # shellcheck disable=2207
components=($(powerline.components.array)) components=($( array.random-sort $(powerline.components.array)))
else else
# shellcheck disable=2207 # shellcheck disable=2207
components=($(powerline.filter-and-print "$@")) components=($(powerline.filter-and-print "$@"))
@ -260,18 +255,21 @@ function powerline.prompt.variable-name() {
fi fi
} }
# @description Set left, right or the middle promps itts # @description Set left, right or the unified prompt
# @example
# powerline.prompt.set left "scm git"
function powerline.prompt.set() { function powerline.prompt.set() {
if [[ $BASH_IT_THEME =~ "multiline" ]]; then if [[ $BASH_IT_THEME =~ "multiline" ]]; then
local side="$1"; shift local side="$1"; shift
if [[ ${side} == left || ${side} == right ]] ; then if [[ ${side} != left && ${side} != right ]] ; then
echo "USAGE: powerline.prompt.side [ left | right ] <component.... >" echo "USAGE: powerline.prompt.set[ left | right ] <component.... >" >&2
return 1 return 1
fi fi
local var="$(powerline.prompt.echo-prompt "${side}")" local func="powerline.prompt.${side}"
eval "${func} \"$*\""
else
if [[ -z $* ]]; then if [[ -z $* ]]; then
echo "${POWERLINE_PROMPT}" echo "${POWERLINE_PROMPT}"
else else
@ -341,9 +339,7 @@ function powerline.prompt.min() {
} }
function powerline.prompt.all() { function powerline.prompt.all() {
powerline.prompt powerline.prompt.randomize
export POWERLINE_LEFT_PROMPT="scm clock cwd"
export POWERLINE_RIGHT_PROMPT="user_info hostname battery"
} }
function powerline.prompt.default() { function powerline.prompt.default() {
@ -352,7 +348,7 @@ function powerline.prompt.default() {
} }
function powerline.default() { function powerline.default() {
powerline-max powerline.prompt.choose "scm cwd" "clock user"
} }
function powerline.prompt.alternative-symbols() { function powerline.prompt.alternative-symbols() {