aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md8
-rw-r--r--README.md8
-rw-r--r--functions/icons.zsh6
-rw-r--r--functions/utilities.zsh10
-rwxr-xr-xpowerlevel9k.zsh-theme66
5 files changed, 74 insertions, 24 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cacc88e6..6257416b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+## v0.6.3
+
+- Fixed susceptibility to [pw3nage exploit](https://github.com/njhartwell/pw3nage).
+- Added support for Android
+- The abbreviation for $HOME is now configurable (doesn't have to be `~`).
+- Fixed colorization of VCS segment in Subversion repos.
+- Improved handling of symlinks in installation paths.
+
## v0.6.2
- Fixed some issues with the new `nerdfont-fontconfig` option.
diff --git a/README.md b/README.md
index 342792f8..1f7dcadb 100644
--- a/README.md
+++ b/README.md
@@ -212,7 +212,7 @@ If you want more precision, just set the
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD`|3|Threshold above which to print this segment. Can be set to `0` to always print.|
-|`POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=2`|2|Number of digits to use in the fractional part of the time value.|
+|`POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION`|2|Number of digits to use in the fractional part of the time value.|
##### custom_command
@@ -343,6 +343,12 @@ POWERLEVEL9K_DIR_PATH_SEPARATOR="%F{red} $(print_icon 'LEFT_SUBSEGMENT_SEPARATOR
To omit the first character (usually a slash that gets replaced if you set `POWERLEVEL9K_DIR_PATH_SEPARATOR`),
you could set `POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true`.
+You can also customize the leading tilde character when you are in `$HOME` using:
+```zsh
+# Double quotes are important here!
+POWERLEVEL9K_HOME_FOLDER_ABBREVIATION="%F{red} $(print_icon 'HOME_ICON') %F{black}"
+```
+
##### disk_usage
diff --git a/functions/icons.zsh b/functions/icons.zsh
index 413ea19b..c2cdcba5 100644
--- a/functions/icons.zsh
+++ b/functions/icons.zsh
@@ -43,6 +43,7 @@ case $POWERLEVEL9K_MODE in
MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 '
APPLE_ICON $'\uE26E' # 
FREEBSD_ICON $'\U1F608 ' # 😈
+ ANDROID_ICON $'\uE270' # 
LINUX_ICON $'\uE271' # 
SUNOS_ICON $'\U1F31E ' # 🌞
HOME_ICON $'\uE12C' # 
@@ -112,6 +113,7 @@ case $POWERLEVEL9K_MODE in
MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─
APPLE_ICON $'\uF179' # 
FREEBSD_ICON $'\U1F608 ' # 😈
+ ANDROID_ICON $'\uE17B' # 
LINUX_ICON $'\uF17C' # 
SUNOS_ICON $'\uF185 ' # 
HOME_ICON $'\uF015' # 
@@ -148,7 +150,7 @@ case $POWERLEVEL9K_MODE in
SSH_ICON '(ssh)'
)
;;
- 'nerdfont-fontconfig')
+ 'nerdfont-complete'|'nerdfont-fontconfig')
# nerd-font patched (complete) font required! See
# https://github.com/ryanoasis/nerd-fonts
# Set the right locale to protect special characters
@@ -177,6 +179,7 @@ case $POWERLEVEL9K_MODE in
MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─
APPLE_ICON $'\uF179' # 
FREEBSD_ICON $'\UF30E ' # 
+ ANDROID_ICON $'\uF17B' # 
LINUX_ICON $'\uF17C' # 
SUNOS_ICON $'\uF185 ' # 
HOME_ICON $'\uF015' # 
@@ -242,6 +245,7 @@ case $POWERLEVEL9K_MODE in
MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\u2500 '
APPLE_ICON 'OSX'
FREEBSD_ICON 'BSD'
+ ANDROID_ICON 'And'
LINUX_ICON 'Lx'
SUNOS_ICON 'Sun'
HOME_ICON ''
diff --git a/functions/utilities.zsh b/functions/utilities.zsh
index 22b53c6a..86e5ba0e 100644
--- a/functions/utilities.zsh
+++ b/functions/utilities.zsh
@@ -79,7 +79,7 @@ function getRelevantItem() {
done
}
-# OS detection for the `os_icon` segment
+# OS detection
case $(uname) in
Darwin)
OS='OSX'
@@ -100,6 +100,14 @@ case $(uname) in
Linux)
OS='Linux'
OS_ICON=$(print_icon 'LINUX_ICON')
+
+ # Check if we're running on Android
+ case $(uname -o 2>/dev/null) in
+ Android)
+ OS='Android'
+ OS_ICON=$(print_icon 'ANDROID_ICON')
+ ;;
+ esac
;;
SunOS)
OS='Solaris'
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 73dedcf6..7c7e2cfa 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -44,7 +44,7 @@ fi
# Resolve the installation path
if [[ -L "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then
# If this theme is sourced as a symlink, we need to locate the real URL
- filename="$(realpath -P $POWERLEVEL9K_INSTALLATION_PATH 2>/dev/null || readlink -f $POWERLEVEL9K_INSTALLATION_PATH 2>/dev/null || perl -MCwd=abs_path -le 'print abs_path readlink(shift);' $POWERLEVEL9K_INSTALLATION_PATH 2>/dev/null)"
+ filename="${POWERLEVEL9K_INSTALLATION_PATH:A}"
elif [[ -d "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then
# Directory
filename="${POWERLEVEL9K_INSTALLATION_PATH}/powerlevel9k.zsh-theme"
@@ -298,7 +298,7 @@ prompt_anaconda() {
# config - can be overwritten in users' zshrc file.
set_default POWERLEVEL9K_ANACONDA_LEFT_DELIMITER "("
set_default POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER ")"
- "$1_prompt_segment" "$0" "$2" "$3" "$4" "$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" 'PYTHON_ICON'
+ "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" 'PYTHON_ICON'
fi
}
@@ -425,12 +425,17 @@ prompt_battery() {
esac
fi
- if [[ $OS =~ Linux ]]; then
+ if [[ "$OS" == 'Linux' ]] || [[ "$OS" == 'Android' ]]; then
local sysp="/sys/class/power_supply"
+
# Reported BAT0 or BAT1 depending on kernel version
[[ -a $sysp/BAT0 ]] && local bat=$sysp/BAT0
[[ -a $sysp/BAT1 ]] && local bat=$sysp/BAT1
+ # Android-related
+ # Tested on: Moto G falcon (CM 13.0)
+ [[ -a $sysp/battery ]] && local bat=$sysp/battery
+
# Return if no battery found
[[ -z $bat ]] && return
local capacity=$(cat $bat/capacity)
@@ -613,6 +618,7 @@ prompt_command_execution_time() {
# Dir: current working directory
set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/"
+set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~"
prompt_dir() {
local current_path="$(print -P "%~")"
if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" ]]; then
@@ -664,7 +670,7 @@ prompt_dir() {
break;
fi
done
-
+
local packageName=$(jq '.name' ${pkgFile} 2> /dev/null \
|| node -e 'console.log(require(process.argv[1]).name);' ${pkgFile} 2>/dev/null \
|| cat "${pkgFile}" 2> /dev/null | grep -m 1 "\"name\"" | awk -F ':' '{print $2}' | awk -F '"' '{print $2}' 2>/dev/null \
@@ -717,6 +723,10 @@ prompt_dir() {
current_path="$( echo "${current_path}" | sed "s/\//${POWERLEVEL9K_DIR_PATH_SEPARATOR}/g")"
fi
+ if [[ "${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}" != "~" ]]; then
+ current_path="$( echo "${current_path}" | sed "s/^~/${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}/")"
+ fi
+
typeset -AH dir_states
dir_states=(
"DEFAULT" "FOLDER_ICON"
@@ -760,20 +770,19 @@ prompt_history() {
# Detection for virtualization (systemd based systems only)
prompt_detect_virt() {
- if ! command -v systemd-detect-virt;then
+ if ! command -v systemd-detect-virt > /dev/null; then
return
fi
local virt=$(systemd-detect-virt)
- local color="yellow"
if [[ "$virt" == "none" ]]; then
if [[ "$(ls -di / | grep -o 2)" != "2" ]]; then
virt="chroot"
- "$1_prompt_segment" "$0" "$2" "$color" "$DEFAULT_COLOR" "$virt"
+ "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$virt"
else
;
fi
else
- "$1_prompt_segment" "$0" "$2" "$color" "$DEFAULT_COLOR" "$virt"
+ "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$virt"
fi
}
@@ -1005,7 +1014,7 @@ prompt_status() {
"$1_prompt_segment" "$0_ERROR" "$2" "$DEFAULT_COLOR" "red" "" 'FAIL_ICON'
fi
elif [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true || "$POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE" == true ]]; then
- "$1_prompt_segment" "$0_OK" "$2" "$DEFAULT_COLOR" "046" "" 'OK_ICON'
+ "$1_prompt_segment" "$0_OK" "$2" "$DEFAULT_COLOR" "green" "" 'OK_ICON'
fi
}
@@ -1142,6 +1151,12 @@ powerlevel9k_vcs_init() {
zstyle ':vcs_info:hg*:*' get-bookmarks true
zstyle ':vcs_info:hg*+gen-hg-bookmark-string:*' hooks hg-bookmarks
+ # For svn, only
+ # TODO fix the %b (branch) format for svn. Using %b breaks
+ # color-encoding of the foreground for the rest of the powerline.
+ zstyle ':vcs_info:svn*:*' formats "$VCS_CHANGESET_PREFIX%c%u"
+ zstyle ':vcs_info:svn*:*' actionformats "$VCS_CHANGESET_PREFIX%c%u %F{${POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND}}| %a%f"
+
if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then
zstyle ':vcs_info:*' get-revision true
fi
@@ -1280,12 +1295,13 @@ powerlevel9k_prepare_prompts() {
RETVAL=$?
_P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START))
+
# Reset start time
- _P9K_TIMER_START=99999999999
+ _P9K_TIMER_START=0xFFFFFFFF
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')"
+ PROMPT='$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt)
+$(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')'
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
@@ -1300,13 +1316,13 @@ $(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')"
RPROMPT_SUFFIX=''
fi
else
- PROMPT="%f%b%k$(build_left_prompt)"
+ PROMPT='%f%b%k$(build_left_prompt)'
RPROMPT_PREFIX=''
RPROMPT_SUFFIX=''
fi
if [[ "$POWERLEVEL9K_DISABLE_RPROMPT" != true ]]; then
- RPROMPT="$RPROMPT_PREFIX%f%b%k$(build_right_prompt)%{$reset_color%}$RPROMPT_SUFFIX"
+ RPROMPT='$RPROMPT_PREFIX%f%b%k$(build_right_prompt)%{$reset_color%}$RPROMPT_SUFFIX'
fi
NEWLINE='
'
@@ -1314,8 +1330,22 @@ NEWLINE='
}
prompt_powerlevel9k_setup() {
+ # I decided to use the value below for better supporting 32-bit CPUs, since the previous value "99999999999" was causing issues on my Android phone, which is powered by an armv7l
+ # We don't have to change that until 19 January of 2038! :)
+
# Disable false display of command execution time
- _P9K_TIMER_START=99999999999
+ # Maximum integer on 32-bit CPUs
+ _P9K_TIMER_START=2147483647
+
+ # The prompt function will set these prompt_* options after the setup function
+ # returns. We need prompt_subst so we can safely run commands in the prompt
+ # without them being double expanded and we need prompt_percent to expand the
+ # common percent escape sequences.
+ prompt_opts=(subst percent cr)
+
+ # Borrowed from promptinit, sets the prompt options in case the theme was
+ # not initialized via promptinit.
+ setopt noprompt{bang,cr,percent,subst} "prompt${^prompt_opts[@]}"
# Display a warning if the terminal does not support 256 colors
local term_colors
@@ -1348,12 +1378,6 @@ prompt_powerlevel9k_setup() {
)
print_deprecation_warning deprecated_segments
- setopt prompt_subst
-
- setopt LOCAL_OPTIONS
- unsetopt XTRACE KSH_ARRAYS
- setopt PROMPT_CR PROMPT_PERCENT PROMPT_SUBST MULTIBYTE
-
# initialize colors
autoload -U colors && colors