aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--functions/icons.zsh3
-rwxr-xr-xpowerlevel9k.zsh-theme60
2 files changed, 35 insertions, 28 deletions
diff --git a/functions/icons.zsh b/functions/icons.zsh
index fb2683b2..dd256b06 100644
--- a/functions/icons.zsh
+++ b/functions/icons.zsh
@@ -22,6 +22,7 @@ case $POWERLEVEL9K_MODE in
icons=(
LEFT_SEGMENT_SEPARATOR $'\UE0B0' # 
RIGHT_SEGMENT_SEPARATOR $'\UE0B2' # 
+ LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace
LEFT_SUBSEGMENT_SEPARATOR $'\UE0B1' # 
RIGHT_SUBSEGMENT_SEPARATOR $'\UE0B3' # 
CARRIAGE_RETURN_ICON $'\U21B5' # ↵
@@ -72,6 +73,7 @@ case $POWERLEVEL9K_MODE in
icons=(
LEFT_SEGMENT_SEPARATOR $'\UE0B0' # 
RIGHT_SEGMENT_SEPARATOR $'\UE0B2' # 
+ LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace
LEFT_SUBSEGMENT_SEPARATOR $'\UE0B1' # 
RIGHT_SUBSEGMENT_SEPARATOR $'\UE0B3' # 
CARRIAGE_RETURN_ICON $'\U21B5' # ↵
@@ -117,6 +119,7 @@ case $POWERLEVEL9K_MODE in
icons=(
LEFT_SEGMENT_SEPARATOR $'\uE0B0' # 
RIGHT_SEGMENT_SEPARATOR $'\uE0B2' # 
+ LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace
LEFT_SUBSEGMENT_SEPARATOR $'\UE0B1' # 
RIGHT_SUBSEGMENT_SEPARATOR $'\UE0B3' # 
CARRIAGE_RETURN_ICON $'\U21B5' # ↵
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index abab9d8e..12659e5e 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -144,7 +144,7 @@ left_prompt_end() {
else
echo -n "%k"
fi
- echo -n "%f "
+ echo -n "%{%f%}$(print_icon 'LEFT_SEGMENT_END_SEPARATOR')"
CURRENT_BG=''
}
@@ -222,10 +222,11 @@ prompt_battery() {
# set default values of not specified in shell
[[ -z $POWERLEVEL9K_BATTERY_CHARGING ]] && POWERLEVEL9K_BATTERY_CHARGING="yellow"
[[ -z $POWERLEVEL9K_BATTERY_CHARGED ]] && POWERLEVEL9K_BATTERY_CHARGED="green"
- [[ -z $POWERLEVEL9K_BATTERY_DISCONNECTED ]] && POWERLEVEL9K_BATTERY_DISCONNECTED="$DEFAULT_COLOR"
+ [[ -z $POWERLEVEL9K_BATTERY_DISCONNECTED ]] && POWERLEVEL9K_BATTERY_DISCONNECTED="$DEFAULT_COLOR_INVERTED"
[[ -z $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && POWERLEVEL9K_BATTERY_LOW_THRESHOLD=10
[[ -z $POWERLEVEL9K_BATTERY_LOW_COLOR ]] && POWERLEVEL9K_BATTERY_LOW_COLOR="red"
- [[ -z $POWERLEVEL9K_BATTERY_FOREGROUND ]] && local fg_color="$DEFAULT_COLOR" || local fg_color=$POWERLEVEL9K_BATTERY_FOREGROUND
+ [[ -z $POWERLEVEL9K_BATTERY_FOREGROUND ]] && local fg_color="" || local fg_color="%F{$POWERLEVEL9K_BATTERY_FOREGROUND}"
+ [[ -z $POWERLEVEL9K_BATTERY_FOREGROUND ]] && local conn="$DEFAULT_COLOR_INVERTED" || local conn="$POWERLEVEL9K_BATTERY_FOREGROUND"
if [[ $OS =~ OSX && -f /usr/sbin/ioreg && -x /usr/sbin/ioreg ]]; then
# return if there is no battery on system
@@ -249,10 +250,10 @@ prompt_battery() {
[[ ! -z $max_capacity && ! -z $current_capacity ]] && local bat_percent=$(ruby -e "puts ($current_capacity.to_f / $max_capacity.to_f * 100).round.to_i")
# logic for string output
- [[ $charging =~ true && $connected =~ true ]] && local conn="%F{$POWERLEVEL9K_BATTERY_CHARGING}" && local remain=" ($tstring)"
- [[ ! $charging =~ true && $connected =~ true ]] && local conn="%F{$POWERLEVEL9K_BATTERY_CHARGED}" && local remain=""
+ [[ $charging =~ true && $connected =~ true ]] && local conn="$POWERLEVEL9K_BATTERY_CHARGING" && local remain=" ($tstring)"
+ [[ ! $charging =~ true && $connected =~ true ]] && local conn="$POWERLEVEL9K_BATTERY_CHARGED" && local remain=""
if [[ ! $connected =~ true ]]; then
- [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && local conn="%F{$POWERLEVEL9K_BATTERY_LOW_COLOR}" || local conn="%F{$POWERLEVEL9K_BATTERY_DISCONNECTED}"
+ [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && local conn="$POWERLEVEL9K_BATTERY_LOW_COLOR" || local conn="$POWERLEVEL9K_BATTERY_DISCONNECTED"
local remain=" ($tstring)"
fi
fi
@@ -265,27 +266,26 @@ prompt_battery() {
# return if no battery found
[[ -z $bat ]] && return
-
[[ $(cat $bat/capacity) -gt 100 ]] && local bat_percent=100 || local bat_percent=$(cat $bat/capacity)
[[ $(cat $bat/status) =~ Charging ]] && local connected=true
- [[ $(cat $bat/status) =~ Charging && $bat_percent =~ 100 ]] && local conn="%F{$POWERLEVEL9K_BATTERY_CHARGED}"
- [[ $(cat $bat/status) =~ Charging && $bat_percent -lt 100 ]] && local conn="%F{$POWERLEVEL9K_BATTERY_CHARGING}"
- if [[ ! $connected =~ true ]]; then
- [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && local conn="%F{$POWERLEVEL9K_BATTERY_LOW_COLOR}" || local conn="%F{$POWERLEVEL9K_BATTERY_DISCONNECTED}"
+ [[ $(cat $bat/status) =~ Charging && $bat_percent =~ 100 ]] && local conn="$POWERLEVEL9K_BATTERY_CHARGED"
+ [[ $(cat $bat/status) =~ Charging && $bat_percent -lt 100 ]] && local conn="$POWERLEVEL9K_BATTERY_CHARGING"
+ if [[ -z $connected ]]; then
+ [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && local conn="$POWERLEVEL9K_BATTERY_LOW_COLOR" || local conn="$POWERLEVEL9K_BATTERY_DISCONNECTED"
fi
if [[ -f /usr/bin/acpi ]]; then
local time_remaining=$(acpi | awk '{ print $5 }')
if [[ $time_remaining =~ rate ]]; then
local tstring="..."
elif [[ $time_remaining =~ "[:digit:]+" ]]; then
- local tstring=${(f)$(date -u -d @$(echo $time_remaining | sed s/://g) +%k:%M)}
+ local tstring=${(f)$(date -u -d "$(echo $time_remaining)" +%k:%M)}
fi
fi
[[ ! -z $tstring ]] && local remain=" ($tstring)"
fi
# display prompt_segment
- [[ ! -z $bat_percent ]] && "$1_prompt_segment" "$0" "black" "$DEFAULT_COLOR" "$conn$(print_icon 'BATTERY_ICON')%F{$fg_color} $bat_percent%%$remain"
+ [[ ! -z $bat_percent ]] && "$1_prompt_segment" "$0" "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "%F{$conn}$(print_icon 'BATTERY_ICON')$fg_color $bat_percent%%$remain%f"
}
# Context: user@hostname (who am I and where am I)
@@ -326,7 +326,7 @@ prompt_dir() {
# GO-prompt
prompt_go_version() {
local go_version
- go_version=$(go version 2>&1 | grep -oe "^go[0-9.]*")
+ go_version=$(go version 2>&1 | sed -E "s/.*(go[0-9.]*).*/\1/")
if [[ -n "$go_version" ]]; then
"$1_prompt_segment" "$0" "green" "255" "$go_version"
@@ -404,11 +404,10 @@ prompt_load() {
# Node version
prompt_node_version() {
- local nvm_prompt
- nvm_prompt=$(node -v 2>/dev/null)
- [[ -z "${nvm_prompt}" ]] && return
+ local node_version=$(node -v 2>/dev/null)
+ [[ -z "${node_version}" ]] && return
- "$1_prompt_segment" "$0" "green" "white" "${nvm_prompt:1} $(print_icon 'NODE_ICON')"
+ "$1_prompt_segment" "$0" "green" "white" "${node_version:1} $(print_icon 'NODE_ICON')"
}
# print a little OS icon
@@ -477,8 +476,8 @@ prompt_nvm() {
local nvm_default=$(cat $NVM_DIR/alias/default)
[[ -z "${node_version}" ]] && return
[[ "$node_version" =~ "$nvm_default" ]] && return
- NODE_ICON=$'\u2B22' # ⬢
- $1_prompt_segment "$0" "green" "011" "${node_version:1} $NODE_ICON"
+
+ $1_prompt_segment "$0" "green" "011" "${node_version:1} $(print_icon 'NODE_ICON')"
}
# rbenv information
@@ -723,14 +722,19 @@ powerlevel9k_prepare_prompts() {
if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then
PROMPT="$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%{%f%b%k%}$(build_left_prompt)
$(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')"
- # The right prompt should be on the same line as the first line of the left
- # prompt. To do so, there is just a quite ugly workaround: Before zsh draws
- # the RPROMPT, we advise it, to go one line up. At the end of RPROMPT, we
- # advise it to go one line down. See:
- # http://superuser.com/questions/357107/zsh-right-justify-in-ps1
- local LC_ALL="" LC_CTYPE="en_US.UTF-8" # Set the right locale to protect special characters
- RPROMPT_PREFIX='%{'$'\e[1A''%}' # one line up
- RPROMPT_SUFFIX='%{'$'\e[1B''%}' # one line down
+ if [[ "$POWERLEVEL9K_RPROMPT_ON_NEWLINE" != true ]]; then
+ # The right prompt should be on the same line as the first line of the left
+ # prompt. To do so, there is just a quite ugly workaround: Before zsh draws
+ # the RPROMPT, we advise it, to go one line up. At the end of RPROMPT, we
+ # advise it to go one line down. See:
+ # http://superuser.com/questions/357107/zsh-right-justify-in-ps1
+ local LC_ALL="" LC_CTYPE="en_US.UTF-8" # Set the right locale to protect special characters
+ RPROMPT_PREFIX='%{'$'\e[1A''%}' # one line up
+ RPROMPT_SUFFIX='%{'$'\e[1B''%}' # one line down
+ else
+ RPROMPT_PREFIX=''
+ RPROMPT_SUFFIX=''
+ fi
else
PROMPT="%{%f%b%k%}$(build_left_prompt)"
RPROMPT_PREFIX=''