Merge remote-tracking branch 'ben/master' into HEAD

pull/22/head
Dominik Ritter 6 years ago
commit 06151eeba9

@ -116,7 +116,7 @@ The segments that are currently available are:
* `go_version` - Show the current GO version. * `go_version` - Show the current GO version.
* **Javascript / Node.js Segments:** * **Javascript / Node.js Segments:**
* `node_version` - Show the version number of the installed Node.js. * `node_version` - Show the version number of the installed Node.js.
* `nodeenv` - [nodeenv](https://github.com/ekalinin/nodeenv) prompt for displaying node version and environment name. * [`nodeenv`](#nodeenv) - [nodeenv](https://github.com/ekalinin/nodeenv) prompt for displaying node version and environment name.
* `nvm` - Show the version of Node that is currently active, if it differs from the version used by NVM * `nvm` - Show the version of Node that is currently active, if it differs from the version used by NVM
* **PHP Segments:** * **PHP Segments:**
* `php_version` - Show the current PHP version. * `php_version` - Show the current PHP version.
@ -124,7 +124,7 @@ The segments that are currently available are:
* [`symfony2_tests`](#symfony2_tests) - Show a ratio of test classes vs code classes for Symfony2. * [`symfony2_tests`](#symfony2_tests) - Show a ratio of test classes vs code classes for Symfony2.
* `symfony2_version` - Show the current Symfony2 version, if you are in a Symfony2-Project dir. * `symfony2_version` - Show the current Symfony2 version, if you are in a Symfony2-Project dir.
* **Python Segments:** * **Python Segments:**
* `virtualenv` - Your Python [VirtualEnv](https://virtualenv.pypa.io/en/latest/). * [`virtualenv`](#virtualenv) - Your Python [VirtualEnv](https://virtualenv.pypa.io/en/latest/).
* [`anaconda`](#anaconda) - Your active [Anaconda](https://www.continuum.io/why-anaconda) environment. * [`anaconda`](#anaconda) - Your active [Anaconda](https://www.continuum.io/why-anaconda) environment.
* `pyenv` - Your active python version as reported by the first word of [`pyenv version`](https://github.com/yyuu/pyenv). Note that the segment is not displayed if that word is _system_ i.e. the segment is inactive if you are using system python. * `pyenv` - Your active python version as reported by the first word of [`pyenv version`](https://github.com/yyuu/pyenv). Note that the segment is not displayed if that word is _system_ i.e. the segment is inactive if you are using system python.
* **Ruby Segments:** * **Ruby Segments:**
@ -557,6 +557,12 @@ prompt itself.
This only works on the left side. On the right side it does nothing. This only works on the left side. On the right side it does nothing.
##### nodeenv
Shows the currently used [nodeenv](https://github.com/ekalinin/nodeenv). To avoid
Nodeenvs activate command from interfering with Powerlevel9k, you should set
`NODE_VIRTUAL_ENV_DISABLE_PROMPT=1` in your `~/.zshrc`.
##### rbenv ##### rbenv
This segment shows the version of Ruby being used when using `rbenv` to change your current Ruby stack. This segment shows the version of Ruby being used when using `rbenv` to change your current Ruby stack.
@ -725,6 +731,12 @@ you are using the [ZSH Line Editor](http://zsh.sourceforge.net/Doc/Release/Zsh-L
To hide the segment entirely when in `INSERT` mode, set `POWERLEVEL9K_VI_INSERT_MODE_STRING=''` To hide the segment entirely when in `INSERT` mode, set `POWERLEVEL9K_VI_INSERT_MODE_STRING=''`
##### virtualenv
This segment shows your Python [VirtualEnv](https://virtualenv.pypa.io/en/latest/). To avoid
VirtualEnvs activate command from interfering with Powerlevel9k, you should set
`VIRTUAL_ENV_DISABLE_PROMPT=1` in your `~/.zshrc`.
#### Unit Test Ratios #### Unit Test Ratios
The `symfony2_tests` and `rspec_stats` segments both show a ratio of "real" The `symfony2_tests` and `rspec_stats` segments both show a ratio of "real"

@ -16,6 +16,12 @@ trim() {
set +f set +f
} }
trim_quotes() {
trim_output="${1//\'}"
trim_output="${trim_output//\"}"
printf "%s" "$trim_output"
}
get_ppid() { get_ppid() {
# Get parent process ID of PID. # Get parent process ID of PID.
case "$os" in case "$os" in
@ -113,18 +119,19 @@ get_term() {
} }
get_term_font() { get_term_font() {
local confs term_font mateterm_config role profile xrdb child profile_filename
local term="${1}" local term="${1}"
# ((term_run != 1)) && get_term # ((term_run != 1)) && get_term
case "$term" in case "$term" in
"alacritty"*) "alacritty"*)
shopt -s nullglob setopt nullglob
confs=({$XDG_CONFIG_HOME,$HOME}/{alacritty,}/{.,}alacritty.ym?) confs=({$XDG_CONFIG_HOME,$HOME}/{alacritty,}/{.,}alacritty.ym?)
shopt -u nullglob unsetopt nullglob
[[ -f "${confs[0]}" ]] || return [[ -f "${confs[1]}" ]] || return
term_font="$(awk -F ':|#' '/normal:/ {getline; print}' "${confs[0]}")" term_font="$(awk -F ':|#' '/normal:/ {getline; print}' "${confs[1]}")"
term_font="${term_font/*family:}" term_font="${term_font/*family:}"
term_font="${term_font/$'\n'*}" term_font="${term_font/$'\n'*}"
term_font="${term_font/\#*}" term_font="${term_font/\#*}"
@ -156,26 +163,26 @@ END
font_file="${HOME}/Library/Preferences/com.googlecode.iterm2.plist" font_file="${HOME}/Library/Preferences/com.googlecode.iterm2.plist"
# Count Guids in "New Bookmarks"; they should be unique # Count Guids in "New Bookmarks"; they should be unique
profiles_count="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:'" "$font_file" | \ profiles_count="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:'" "$font_file" 2>/dev/null | \
grep -w -c "Guid")" grep -w -c "Guid")"
for ((i=0; i<profiles_count; i++)); do for ((i=0; i<profiles_count; i++)); do
profile_name="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Name:'" "$font_file")" profile_name="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Name:'" "$font_file" 2>/dev/null)"
if [[ "$profile_name" == "$current_profile_name" ]]; then if [[ "$profile_name" == "$current_profile_name" ]]; then
# "Normal Font" # "Normal Font"
term_font="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Normal Font:'" \ term_font="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Normal Font:'" \
"$font_file")" "$font_file" 2>/dev/null)"
# Font for non-ascii characters # Font for non-ascii characters
# Only check for a different non-ascii font, if the user checked # Only check for a different non-ascii font, if the user checked
# the "use a different font for non-ascii text" switch. # the "use a different font for non-ascii text" switch.
diff_font="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Use Non-ASCII Font:'" \ diff_font="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Use Non-ASCII Font:'" \
"$font_file")" "$font_file" 2>/dev/null)"
if [[ "$diff_font" == "true" ]]; then if [[ "$diff_font" == "true" ]]; then
non_ascii="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Non Ascii Font:'" \ non_ascii="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Non Ascii Font:'" \
"$font_file")" "$font_file" 2>/dev/null)"
[[ "$term_font" != "$non_ascii" ]] && \ [[ "$term_font" != "$non_ascii" ]] && \
term_font="$term_font (normal) / $non_ascii (non-ascii)" term_font="$term_font (normal) / $non_ascii (non-ascii)"
@ -185,13 +192,13 @@ END
;; ;;
"deepin-terminal"*) "deepin-terminal"*)
term_font="$(awk -F '=' '/font=/ {a=$2} /font_size/ {b=$2} END {print a " " b}' \ term_font="$(awk -F '=' '/font=/ {a=$2} /font_size/ {b=$2} END {print a,b}' \
"${XDG_CONFIG_HOME}/deepin/deepin-terminal/config.conf")" "${XDG_CONFIG_HOME}/deepin/deepin-terminal/config.conf")"
;; ;;
"GNUstep_Terminal") "GNUstep_Terminal")
term_font="$(awk -F '>|<' '/>TerminalFont</ {getline; f=$3} term_font="$(awk -F '>|<' '/>TerminalFont</ {getline; f=$3}
/>TerminalFontSize</ {getline; s=$3} END {print f " " s}' \ />TerminalFontSize</ {getline; s=$3} END {print f,s}' \
"${HOME}/GNUstep/Defaults/Terminal.plist")" "${HOME}/GNUstep/Defaults/Terminal.plist")"
;; ;;
@ -201,34 +208,26 @@ END
;; ;;
"kitty"*) "kitty"*)
shopt -s nullglob kitty_config="$(kitty --debug-config)"
confs=({$KITTY_CONFIG_DIRECTORY,$XDG_CONFIG_HOME,~/Library/Preferences}/kitty/kitty.con?) [[ "$kitty_config" != *font_family* ]] && return
shopt -u nullglob
term_font_size="${kitty_config/*font_size}"
[[ -f "${confs[0]}" ]] || return term_font_size="${term_font_size/$'\n'*}"
term_font="${kitty_config/*font_family}"
term_font="$(awk '/^([[:space:]]*|[^#_])font_family[[:space:]]+/ { term_font="${term_font/$'\n'*} $term_font_size"
$1 = "";
gsub(/^[[:space:]]/, "");
font = $0
}
/^([[:space:]]*|[^#_])font_size[[:space:]]+/ {
size = $2
}
END { print font " " size}' "${confs[0]}")"
;; ;;
"konsole"*) "konsole" | "yakuake")
# Get Process ID of current konsole window / tab # Get Process ID of current konsole window / tab
child="$(get_ppid "$$")" child="$(get_ppid "$$")"
IFS=$'\n' read -d "" -ra konsole_instances < <(qdbus | grep -F 'org.kde.konsole') declare -a konsole_instances; konsole_instances=( "${(@f)"$(qdbus | grep -F 'org.kde.konsole')"/ /}" )
for i in "${konsole_instances[@]}"; do for i in "${konsole_instances[@]}"; do
IFS=$'\n' read -d "" -ra konsole_sessions < <(qdbus "$i" | grep -F '/Sessions/') declare -a konsole_sessions; konsole_sessions=( "${(@f)"$(qdbus "$i" | grep -F '/Sessions/')"}" )
for session in "${konsole_sessions[@]}"; do for session in "${konsole_sessions[@]}"; do
if ((child == "$(qdbus "$i" "$session" processId)")); then if ((child == $(qdbus "$i" "$session" processId))); then
profile="$(qdbus "$i" "$session" environment |\ profile="$(qdbus "$i" "$session" environment |\
awk -F '=' '/KONSOLE_PROFILE_NAME/ {print $2}')" awk -F '=' '/KONSOLE_PROFILE_NAME/ {print $2}')"
break break
@ -242,7 +241,7 @@ END
profile_filename="${profile_filename/$'\n'*}" profile_filename="${profile_filename/$'\n'*}"
[[ "$profile_filename" ]] && \ [[ "$profile_filename" ]] && \
term_font="$(awk -F '=|,' '/Font=/ {print $2 " " $3}' "$profile_filename")" term_font="$(awk -F '=|,' '/Font=/ {print $2,$3}' "$profile_filename")"
;; ;;
"lxterminal"*) "lxterminal"*)
@ -256,7 +255,7 @@ END
mateterm_config="/tmp/mateterm.cfg" mateterm_config="/tmp/mateterm.cfg"
# Ensure /tmp exists and we do not overwrite anything. # Ensure /tmp exists and we do not overwrite anything.
if [[ -d /tmp && ! -f "$mateterm_config" ]]; then if [[ -d "/tmp" && ! -f "$mateterm_config" ]]; then
mate-terminal --save-config="$mateterm_config" mate-terminal --save-config="$mateterm_config"
role="$(xprop -id "${WINDOWID}" WM_WINDOW_ROLE)" role="$(xprop -id "${WINDOWID}" WM_WINDOW_ROLE)"
@ -301,7 +300,7 @@ END
;; ;;
"qterminal") "qterminal")
term_font="$(awk -F '=' '/fontFamily=/ {a=$2} /fontSize=/ {b=$2} END {print a " " b}' \ term_font="$(awk -F '=' '/fontFamily=/ {a=$2} /fontSize=/ {b=$2} END {print a,b}' \
"${XDG_CONFIG_HOME}/qterminal.org/qterminal.ini")" "${XDG_CONFIG_HOME}/qterminal.org/qterminal.ini")"
;; ;;
@ -321,7 +320,7 @@ END
# On Linux we can get the exact path to the running binary through the procfs # On Linux we can get the exact path to the running binary through the procfs
# (in case `st` is launched from outside of $PATH) on other systems we just # (in case `st` is launched from outside of $PATH) on other systems we just
# have to guess and assume `st` is invoked from somewhere in the users $PATH # have to guess and assume `st` is invoked from somewhere in the users $PATH
[[ -L /proc/$parent/exe ]] && binary="/proc/$parent/exe" || binary="$(type -p st)" [[ -L "/proc/$parent/exe" ]] && binary="/proc/$parent/exe" || binary="$(type -p st)"
# Grep the output of strings on the `st` binary for anything that looks vaguely # Grep the output of strings on the `st` binary for anything that looks vaguely
# like a font definition. NOTE: There is a slight limitation in this approach. # like a font definition. NOTE: There is a slight limitation in this approach.
@ -374,8 +373,7 @@ END
term_font="$(trim "${term_font/*"faceName:"}")" term_font="$(trim "${term_font/*"faceName:"}")"
# xft: isn't required at the beginning so we prepend it if it's missing # xft: isn't required at the beginning so we prepend it if it's missing
[[ "${term_font:0:1}" != "-" && \ [[ "${term_font:0:1}" != "-" && "${term_font:0:4}" != "xft:" ]] && \
"${term_font:0:4}" != "xft:" ]] && \
term_font="xft:$term_font" term_font="xft:$term_font"
# Xresources has two different font formats, this checks which # Xresources has two different font formats, this checks which

@ -102,7 +102,9 @@ case $(uname) in
;; ;;
Linux) Linux)
OS='Linux' OS='Linux'
os_release_id="$(grep -E '^ID=([a-zA-Z]*)' /etc/os-release | cut -d '=' -f 2)" if [ -f /etc/os-release ]; then
[[ ${(f)"$((</etc/os-release) 2>/dev/null)"} =~ "ID=([A-Za-z]+)" ]] && os_release_id="${match[1]}"
fi
case "$os_release_id" in case "$os_release_id" in
*arch*) *arch*)
OS_ICON=$(print_icon 'LINUX_ARCH_ICON') OS_ICON=$(print_icon 'LINUX_ARCH_ICON')

@ -172,7 +172,7 @@ left_prompt_segment() {
# Allow users to overwrite the color for the visual identifier only. # Allow users to overwrite the color for the visual identifier only.
local visual_identifier_color_variable=POWERLEVEL9K_${(U)${segment_name}#prompt_}_VISUAL_IDENTIFIER_COLOR local visual_identifier_color_variable=POWERLEVEL9K_${(U)${segment_name}#prompt_}_VISUAL_IDENTIFIER_COLOR
set_default $visual_identifier_color_variable "${foregroundColor}" set_default $visual_identifier_color_variable "${foregroundColor}"
visual_identifier="$(foregroundColor ${(P)visual_identifier_color_variable})${visual_identifier}%f" visual_identifier="$(foregroundColor ${(P)visual_identifier_color_variable})${visual_identifier}"
fi fi
fi fi
@ -274,7 +274,7 @@ right_prompt_segment() {
# Allow users to overwrite the color for the visual identifier only. # Allow users to overwrite the color for the visual identifier only.
local visual_identifier_color_variable=POWERLEVEL9K_${(U)${segment_name}#prompt_}_VISUAL_IDENTIFIER_COLOR local visual_identifier_color_variable=POWERLEVEL9K_${(U)${segment_name}#prompt_}_VISUAL_IDENTIFIER_COLOR
set_default $visual_identifier_color_variable "${foregroundColor}" set_default $visual_identifier_color_variable "${foregroundColor}"
visual_identifier="$(foregroundColor ${(P)visual_identifier_color_variable})${visual_identifier}%f" visual_identifier="$(foregroundColor ${(P)visual_identifier_color_variable})${visual_identifier}"
fi fi
fi fi
@ -363,7 +363,8 @@ prompt_newline() {
"$1_prompt_segment" \ "$1_prompt_segment" \
"$0" \ "$0" \
"$2" \ "$2" \
"NONE" "NONE" "${newline}" "" "" "${newline}"
CURRENT_BG='NONE'
POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws
} }
@ -798,7 +799,7 @@ prompt_dir() {
# using $PWD instead of "$(print -P '%~')" to allow use of POWERLEVEL9K_DIR_PATH_ABSOLUTE # using $PWD instead of "$(print -P '%~')" to allow use of POWERLEVEL9K_DIR_PATH_ABSOLUTE
local current_path=$PWD # WAS: local current_path="$(print -P '%~')" local current_path=$PWD # WAS: local current_path="$(print -P '%~')"
# check if the user wants to use absolute paths or "~" paths # check if the user wants to use absolute paths or "~" paths
[[ ${(L)POWERLEVEL9K_DIR_PATH_ABSOLUTE} != "true" ]] && current_path=${current_path//$HOME/"~"} [[ ${(L)POWERLEVEL9K_DIR_PATH_ABSOLUTE} != "true" ]] && current_path=${current_path/#$HOME/"~"}
# declare all local variables # declare all local variables
local paths directory test_dir test_dir_length trunc_path threshhold local paths directory test_dir test_dir_length trunc_path threshhold
# if we are not in "~" or "/", split the paths into an array and exclude "~" # if we are not in "~" or "/", split the paths into an array and exclude "~"
@ -1217,9 +1218,8 @@ prompt_nvm() {
################################################################ ################################################################
# Segment to display NodeEnv # Segment to display NodeEnv
prompt_nodeenv() { prompt_nodeenv() {
local nodeenv_path="$NODE_VIRTUAL_ENV" if [[ -n "$NODE_VIRTUAL_ENV" ]]; then
if [[ -n "$nodeenv_path" && "$NODE_VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then local info="$(node -v)[${NODE_VIRTUAL_ENV:t}]"
local info="$(node -v)[$(basename "$nodeenv_path")]"
"$1_prompt_segment" "$0" "$2" "black" "green" "$info" 'NODE_ICON' "$1_prompt_segment" "$0" "$2" "black" "green" "$info" 'NODE_ICON'
fi fi
} }
@ -1627,9 +1627,11 @@ prompt_vi_mode() {
# https://virtualenv.pypa.io/en/latest/ # https://virtualenv.pypa.io/en/latest/
prompt_virtualenv() { prompt_virtualenv() {
local virtualenv_path="$VIRTUAL_ENV" local virtualenv_path="$VIRTUAL_ENV"
if [[ -n "$virtualenv_path" && -z "$VIRTUAL_ENV_DISABLE_PROMPT" ]]; then
"$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" 'PYTHON_ICON' # Early exit; $virtualenv_path must always be set.
fi [[ -z "$virtualenv_path" ]] && return
"$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "${virtualenv_path:t}" 'PYTHON_ICON'
} }
################################################################ ################################################################

@ -16,7 +16,7 @@ function testDynamicColoringOfSegmentsWork() {
local POWERLEVEL9K_DATE_ICON="date-icon" local POWERLEVEL9K_DATE_ICON="date-icon"
local POWERLEVEL9K_DATE_BACKGROUND='red' local POWERLEVEL9K_DATE_BACKGROUND='red'
assertEquals "%K{001} %F{000}date-icon %f%F{000}%D{%d.%m.%y} %k%F{001}%f " "$(build_left_prompt)" assertEquals "%K{001} %F{000}date-icon %F{000}%D{%d.%m.%y} %k%F{001}%f " "$(build_left_prompt)"
} }
function testDynamicColoringOfVisualIdentifiersWork() { function testDynamicColoringOfVisualIdentifiersWork() {
@ -24,7 +24,7 @@ function testDynamicColoringOfVisualIdentifiersWork() {
local POWERLEVEL9K_DATE_ICON="date-icon" local POWERLEVEL9K_DATE_ICON="date-icon"
local POWERLEVEL9K_DATE_VISUAL_IDENTIFIER_COLOR='green' local POWERLEVEL9K_DATE_VISUAL_IDENTIFIER_COLOR='green'
assertEquals "%K{007} %F{002}date-icon %f%F{000}%D{%d.%m.%y} %k%F{007}%f " "$(build_left_prompt)" assertEquals "%K{007} %F{002}date-icon %F{000}%D{%d.%m.%y} %k%F{007}%f " "$(build_left_prompt)"
} }
function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() { function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() {
@ -34,7 +34,7 @@ function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() {
local POWERLEVEL9K_DATE_FOREGROUND='red' local POWERLEVEL9K_DATE_FOREGROUND='red'
local POWERLEVEL9K_DATE_BACKGROUND='yellow' local POWERLEVEL9K_DATE_BACKGROUND='yellow'
assertEquals "%K{003} %F{002}date-icon %f%F{001}%D{%d.%m.%y} %k%F{003}%f " "$(build_left_prompt)" assertEquals "%K{003} %F{002}date-icon %F{001}%D{%d.%m.%y} %k%F{003}%f " "$(build_left_prompt)"
} }
function testColorOverridingOfStatefulSegment() { function testColorOverridingOfStatefulSegment() {
@ -45,7 +45,7 @@ function testColorOverridingOfStatefulSegment() {
# Provoke state # Provoke state
local SSH_CLIENT="x" local SSH_CLIENT="x"
assertEquals "%K{001} %F{002}ssh-icon %f%F{002}%m %k%F{001}%f " "$(build_left_prompt)" assertEquals "%K{001} %F{002}ssh-icon %F{002}%m %k%F{001}%f " "$(build_left_prompt)"
} }
function testColorOverridingOfCustomSegment() { function testColorOverridingOfCustomSegment() {
@ -56,7 +56,7 @@ function testColorOverridingOfCustomSegment() {
local POWERLEVEL9K_CUSTOM_WORLD_FOREGROUND='red' local POWERLEVEL9K_CUSTOM_WORLD_FOREGROUND='red'
local POWERLEVEL9K_CUSTOM_WORLD_BACKGROUND='red' local POWERLEVEL9K_CUSTOM_WORLD_BACKGROUND='red'
assertEquals "%K{001} %F{002}CW %f%F{001}world %k%F{001}%f " "$(build_left_prompt)" assertEquals "%K{001} %F{002}CW %F{001}world %k%F{001}%f " "$(build_left_prompt)"
} }
source shunit2/shunit2 source shunit2/shunit2

@ -18,7 +18,7 @@ function testOverwritingIconsWork() {
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1' local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here' local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here'
assertEquals "%K{007} %F{000}icon-here %f%F{000}world1 %k%F{007}%f " "$(build_left_prompt)" assertEquals "%K{007} %F{000}icon-here %F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
} }
function testVisualIdentifierAppearsBeforeSegmentContentOnLeftSegments() { function testVisualIdentifierAppearsBeforeSegmentContentOnLeftSegments() {
@ -27,7 +27,7 @@ function testVisualIdentifierAppearsBeforeSegmentContentOnLeftSegments() {
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1' local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here' local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here'
assertEquals "%K{007} %F{000}icon-here %f%F{000}world1 %k%F{007}%f " "$(build_left_prompt)" assertEquals "%K{007} %F{000}icon-here %F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
} }
function testVisualIdentifierAppearsAfterSegmentContentOnRightSegments() { function testVisualIdentifierAppearsAfterSegmentContentOnRightSegments() {
@ -36,7 +36,7 @@ function testVisualIdentifierAppearsAfterSegmentContentOnRightSegments() {
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1' local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here' local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here'
assertEquals "%F{007}%f%K{007}%F{000} world1%F{000} icon-here%f%E" "$(build_right_prompt)" assertEquals "%F{007}%f%K{007}%F{000} world1%F{000} icon-here%E" "$(build_right_prompt)"
} }
function testVisualIdentifierPrintsNothingIfNotAvailable() { function testVisualIdentifierPrintsNothingIfNotAvailable() {
@ -54,7 +54,7 @@ function testVisualIdentifierIsPrintedInNumericalColorCode() {
local POWERLEVEL9K_CUSTOM_WORLD1_ICON="xxx" local POWERLEVEL9K_CUSTOM_WORLD1_ICON="xxx"
local POWERLEVEL9K_CUSTOM_WORLD1_VISUAL_IDENTIFIER_COLOR="purple3" local POWERLEVEL9K_CUSTOM_WORLD1_VISUAL_IDENTIFIER_COLOR="purple3"
assertEquals "%K{007} %F{056}xxx %f%F{000}world1 %k%F{007}%f " "$(build_left_prompt)" assertEquals "%K{007} %F{056}xxx %F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
} }
source shunit2/shunit2 source shunit2/shunit2

@ -65,7 +65,7 @@ function testDynamicColoringOfVisualIdentifiersWork() {
cd /tmp cd /tmp
assertEquals "%K{004} %F{002}icon-here %f%F{000}/tmp %k%F{004}%f " "$(build_left_prompt)" assertEquals "%K{004} %F{002}icon-here %F{000}/tmp %k%F{004}%f " "$(build_left_prompt)"
cd - cd -
} }
@ -84,7 +84,7 @@ function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() {
cd /tmp cd /tmp
assertEquals "%K{003} %F{002}icon-here %f%F{001}/tmp %k%F{003}%f " "$(build_left_prompt)" assertEquals "%K{003} %F{002}icon-here %F{001}/tmp %k%F{003}%f " "$(build_left_prompt)"
cd - cd -
} }
@ -100,7 +100,7 @@ function testOverwritingIconsWork() {
#cd ~/$testFolder #cd ~/$testFolder
cd /tmp cd /tmp
assertEquals "%K{004} %F{000}icon-here %f%F{000}/tmp %k%F{004}%f " "$(build_left_prompt)" assertEquals "%K{004} %F{000}icon-here %F{000}/tmp %k%F{004}%f " "$(build_left_prompt)"
cd - cd -
# rm -fr ~/$testFolder # rm -fr ~/$testFolder

@ -35,7 +35,7 @@ function testAnacondaSegmentWorksIfOnlyAnacondaPathIsSet() {
CONDA_ENV_PATH=/tmp CONDA_ENV_PATH=/tmp
unset CONDA_PREFIX unset CONDA_PREFIX
assertEquals "%K{004} %F{000}icon-here %f%F{000}(tmp) %k%F{004}%f " "$(build_left_prompt)" assertEquals "%K{004} %F{000}icon-here %F{000}(tmp) %k%F{004}%f " "$(build_left_prompt)"
} }
function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() { function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() {
@ -49,7 +49,7 @@ function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() {
unset CONDA_ENV_PATH unset CONDA_ENV_PATH
local CONDA_PREFIX="test" local CONDA_PREFIX="test"
assertEquals "%K{004} %F{000}icon-here %f%F{000}(test) %k%F{004}%f " "$(build_left_prompt)" assertEquals "%K{004} %F{000}icon-here %F{000}(test) %k%F{004}%f " "$(build_left_prompt)"
} }
function testAnacondaSegmentWorks() { function testAnacondaSegmentWorks() {
@ -63,7 +63,7 @@ function testAnacondaSegmentWorks() {
local CONDA_ENV_PATH=/tmp local CONDA_ENV_PATH=/tmp
local CONDA_PREFIX="test" local CONDA_PREFIX="test"
assertEquals "%K{004} %F{000}icon-here %f%F{000}(tmptest) %k%F{004}%f " "$(build_left_prompt)" assertEquals "%K{004} %F{000}icon-here %F{000}(tmptest) %k%F{004}%f " "$(build_left_prompt)"
} }
source shunit2/shunit2 source shunit2/shunit2

@ -31,7 +31,7 @@ function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSet() {
echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml
cd /tmp/powerlevel9k-test cd /tmp/powerlevel9k-test
assertEquals "%K{000} %F{002}🌱 %f%F{002}test %k%F{000}%f " "$(build_left_prompt)" assertEquals "%K{000} %F{002}🌱 %F{002}test %k%F{000}%f " "$(build_left_prompt)"
rm -fr /tmp/powerlevel9k-test rm -fr /tmp/powerlevel9k-test
cd - cd -
@ -52,7 +52,7 @@ function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSetInParentDirec
echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml
cd /tmp/powerlevel9k-test/1/12/123/1234/12345 cd /tmp/powerlevel9k-test/1/12/123/1234/12345
assertEquals "%K{000} %F{002}🌱 %f%F{002}test %k%F{000}%f " "$(build_left_prompt)" assertEquals "%K{000} %F{002}🌱 %F{002}test %k%F{000}%f " "$(build_left_prompt)"
rm -fr /tmp/powerlevel9k-test rm -fr /tmp/powerlevel9k-test
cd - cd -

@ -34,7 +34,7 @@ function testBackgroundJobsSegmentWorksWithOneBackgroundJob() {
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
assertEquals "%K{000} %F{006}⚙%f %k%F{000}%f " "$(build_left_prompt)" assertEquals "%K{000} %F{006}⚙ %k%F{000}%f " "$(build_left_prompt)"
unfunction jobs unfunction jobs
} }
@ -52,7 +52,7 @@ function testBackgroundJobsSegmentWorksWithMultipleBackgroundJobs() {
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
assertEquals "%K{000} %F{006}⚙%f %k%F{000}%f " "$(build_left_prompt)" assertEquals "%K{000} %F{006}⚙ %k%F{000}%f " "$(build_left_prompt)"
unfunction jobs unfunction jobs
} }
@ -70,7 +70,7 @@ function testBackgroundJobsSegmentWithVerboseMode() {
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
assertEquals "%K{000} %F{006}⚙ %f%F{006}3 %k%F{000}%f " "$(build_left_prompt)" assertEquals "%K{000} %F{006}⚙ %F{006}3 %k%F{000}%f " "$(build_left_prompt)"
unfunction jobs unfunction jobs
} }

@ -69,7 +69,7 @@ function testBatterySegmentIfBatteryIsLowWhileDischargingOnOSX() {
makeBatterySay "Now drawing from 'Battery Power' makeBatterySay "Now drawing from 'Battery Power'
-InternalBattery-0 (id=1234567) 4%; discharging; 0:05 remaining present: true" -InternalBattery-0 (id=1234567) 4%; discharging; 0:05 remaining present: true"
assertEquals "%K{000} %F{001}🔋 %f%F{001}4%% (0:05) " "$(prompt_battery left 1 false ${FOLDER})" assertEquals "%K{000} %F{001}🔋 %F{001}4%% (0:05) " "$(prompt_battery left 1 false ${FOLDER})"
} }
function testBatterySegmentIfBatteryIsLowWhileChargingOnOSX() { function testBatterySegmentIfBatteryIsLowWhileChargingOnOSX() {
@ -77,7 +77,7 @@ function testBatterySegmentIfBatteryIsLowWhileChargingOnOSX() {
makeBatterySay "Now drawing from 'Battery Power' makeBatterySay "Now drawing from 'Battery Power'
-InternalBattery-0 (id=1234567) 4%; charging; 0:05 remaining present: true" -InternalBattery-0 (id=1234567) 4%; charging; 0:05 remaining present: true"
assertEquals "%K{000} %F{003}🔋 %f%F{003}4%% (0:05) " "$(prompt_battery left 1 false ${FOLDER})" assertEquals "%K{000} %F{003}🔋 %F{003}4%% (0:05) " "$(prompt_battery left 1 false ${FOLDER})"
} }
function testBatterySegmentIfBatteryIsAlmostFullWhileDischargingOnOSX() { function testBatterySegmentIfBatteryIsAlmostFullWhileDischargingOnOSX() {
@ -85,7 +85,7 @@ function testBatterySegmentIfBatteryIsAlmostFullWhileDischargingOnOSX() {
makeBatterySay "Now drawing from 'Battery Power' makeBatterySay "Now drawing from 'Battery Power'
-InternalBattery-0 (id=1234567) 98%; discharging; 3:57 remaining present: true" -InternalBattery-0 (id=1234567) 98%; discharging; 3:57 remaining present: true"
assertEquals "%K{000} %F{007}🔋 %f%F{007}98%% (3:57) " "$(prompt_battery left 1 false ${FOLDER})" assertEquals "%K{000} %F{007}🔋 %F{007}98%% (3:57) " "$(prompt_battery left 1 false ${FOLDER})"
} }
function testBatterySegmentIfBatteryIsAlmostFullWhileChargingOnOSX() { function testBatterySegmentIfBatteryIsAlmostFullWhileChargingOnOSX() {
@ -93,7 +93,7 @@ function testBatterySegmentIfBatteryIsAlmostFullWhileChargingOnOSX() {
makeBatterySay "Now drawing from 'Battery Power' makeBatterySay "Now drawing from 'Battery Power'
-InternalBattery-0 (id=1234567) 98%; charging; 3:57 remaining present: true" -InternalBattery-0 (id=1234567) 98%; charging; 3:57 remaining present: true"
assertEquals "%K{000} %F{003}🔋 %f%F{003}98%% (3:57) " "$(prompt_battery left 1 false ${FOLDER})" assertEquals "%K{000} %F{003}🔋 %F{003}98%% (3:57) " "$(prompt_battery left 1 false ${FOLDER})"
} }
function testBatterySegmentIfBatteryIsFullOnOSX() { function testBatterySegmentIfBatteryIsFullOnOSX() {
@ -101,7 +101,7 @@ function testBatterySegmentIfBatteryIsFullOnOSX() {
makeBatterySay "Now drawing from 'AC Power' makeBatterySay "Now drawing from 'AC Power'
-InternalBattery-0 (id=1234567) 99%; charged; 0:00 remaining present: true" -InternalBattery-0 (id=1234567) 99%; charged; 0:00 remaining present: true"
assertEquals "%K{000} %F{002}🔋 %f%F{002}99%% " "$(prompt_battery left 1 false ${FOLDER})" assertEquals "%K{000} %F{002}🔋 %F{002}99%% " "$(prompt_battery left 1 false ${FOLDER})"
} }
function testBatterySegmentIfBatteryIsCalculatingOnOSX() { function testBatterySegmentIfBatteryIsCalculatingOnOSX() {
@ -109,42 +109,42 @@ function testBatterySegmentIfBatteryIsCalculatingOnOSX() {
makeBatterySay "Now drawing from 'Battery Power' makeBatterySay "Now drawing from 'Battery Power'
-InternalBattery-0 (id=1234567) 99%; discharging; (no estimate) present: true" -InternalBattery-0 (id=1234567) 99%; discharging; (no estimate) present: true"
assertEquals "%K{000} %F{007}🔋 %f%F{007}99%% (...) " "$(prompt_battery left 1 false ${FOLDER})" assertEquals "%K{000} %F{007}🔋 %F{007}99%% (...) " "$(prompt_battery left 1 false ${FOLDER})"
} }
function testBatterySegmentIfBatteryIsLowWhileDischargingOnLinux() { function testBatterySegmentIfBatteryIsLowWhileDischargingOnLinux() {
local OS='Linux' # Fake Linux local OS='Linux' # Fake Linux
makeBatterySay "4" "Discharging" makeBatterySay "4" "Discharging"
assertEquals "%K{000} %F{001}🔋 %f%F{001}4%% " "$(prompt_battery left 1 false ${FOLDER})" assertEquals "%K{000} %F{001}🔋 %F{001}4%% " "$(prompt_battery left 1 false ${FOLDER})"
} }
function testBatterySegmentIfBatteryIsLowWhileChargingOnLinux() { function testBatterySegmentIfBatteryIsLowWhileChargingOnLinux() {
local OS='Linux' # Fake Linux local OS='Linux' # Fake Linux
makeBatterySay "4" "Charging" makeBatterySay "4" "Charging"
assertEquals "%K{000} %F{003}🔋 %f%F{003}4%% " "$(prompt_battery left 1 false ${FOLDER})" assertEquals "%K{000} %F{003}🔋 %F{003}4%% " "$(prompt_battery left 1 false ${FOLDER})"
} }
function testBatterySegmentIfBatteryIsNormalWhileDischargingOnLinux() { function testBatterySegmentIfBatteryIsNormalWhileDischargingOnLinux() {
local OS='Linux' # Fake Linux local OS='Linux' # Fake Linux
makeBatterySay "10" "Discharging" makeBatterySay "10" "Discharging"
assertEquals "%K{000} %F{007}🔋 %f%F{007}10%% " "$(prompt_battery left 1 false ${FOLDER})" assertEquals "%K{000} %F{007}🔋 %F{007}10%% " "$(prompt_battery left 1 false ${FOLDER})"
} }
function testBatterySegmentIfBatteryIsNormalWhileChargingOnLinux() { function testBatterySegmentIfBatteryIsNormalWhileChargingOnLinux() {
local OS='Linux' # Fake Linux local OS='Linux' # Fake Linux
makeBatterySay "10" "Charging" makeBatterySay "10" "Charging"
assertEquals "%K{000} %F{003}🔋 %f%F{003}10%% " "$(prompt_battery left 1 false ${FOLDER})" assertEquals "%K{000} %F{003}🔋 %F{003}10%% " "$(prompt_battery left 1 false ${FOLDER})"
} }
function testBatterySegmentIfBatteryIsFullOnLinux() { function testBatterySegmentIfBatteryIsFullOnLinux() {
local OS='Linux' # Fake Linux local OS='Linux' # Fake Linux
makeBatterySay "100" "Full" makeBatterySay "100" "Full"
assertEquals "%K{000} %F{002}🔋 %f%F{002}100%% " "$(prompt_battery left 1 false ${FOLDER})" assertEquals "%K{000} %F{002}🔋 %F{002}100%% " "$(prompt_battery left 1 false ${FOLDER})"
} }
function testBatterySegmentIfBatteryIsNormalWithAcpiEnabledOnLinux() { function testBatterySegmentIfBatteryIsNormalWithAcpiEnabledOnLinux() {
@ -155,7 +155,7 @@ function testBatterySegmentIfBatteryIsNormalWithAcpiEnabledOnLinux() {
# For running on Mac, we need to mock date :( # For running on Mac, we need to mock date :(
[[ -f /usr/local/bin/gdate ]] && alias date=gdate [[ -f /usr/local/bin/gdate ]] && alias date=gdate
assertEquals "%K{000} %F{007}🔋 %f%F{007}50%% (1:38) " "$(prompt_battery left 1 false ${FOLDER})" assertEquals "%K{000} %F{007}🔋 %F{007}50%% (1:38) " "$(prompt_battery left 1 false ${FOLDER})"
unalias date &>/dev/null unalias date &>/dev/null
# unaliasing date fails where it was never aliased (e.g. on Linux). # unaliasing date fails where it was never aliased (e.g. on Linux).
@ -171,7 +171,7 @@ function testBatterySegmentIfBatteryIsCalculatingWithAcpiEnabledOnLinux() {
echo "echo 'Batter 0: Discharging, 50%, rate remaining'" > ${FOLDER}/usr/bin/acpi echo "echo 'Batter 0: Discharging, 50%, rate remaining'" > ${FOLDER}/usr/bin/acpi
chmod +x ${FOLDER}/usr/bin/acpi chmod +x ${FOLDER}/usr/bin/acpi
assertEquals "%K{000} %F{007}🔋 %f%F{007}50%% (...) " "$(prompt_battery left 1 false ${FOLDER})" assertEquals "%K{000} %F{007}🔋 %F{007}50%% (...) " "$(prompt_battery left 1 false ${FOLDER})"
} }
source shunit2/shunit2 source shunit2/shunit2

@ -34,7 +34,7 @@ function testCommandExecutionTimeThresholdCouldBeChanged() {
# Override payload # Override payload
local _P9K_COMMAND_DURATION=2.03 local _P9K_COMMAND_DURATION=2.03
assertEquals "%K{001} %F{226}Dur %f%F{226}2.03 %k%F{001}%f " "$(build_left_prompt)" assertEquals "%K{001} %F{226}Dur %F{226}2.03 %k%F{001}%f " "$(build_left_prompt)"
} }
function testCommandExecutionTimeThresholdCouldBeSetToZero() { function testCommandExecutionTimeThresholdCouldBeSetToZero() {
@ -43,7 +43,7 @@ function testCommandExecutionTimeThresholdCouldBeSetToZero() {
local POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0 local POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0
local _P9K_COMMAND_DURATION=0.03 local _P9K_COMMAND_DURATION=0.03
assertEquals "%K{001} %F{226}Dur %f%F{226}0.03 %k%F{001}%f " "$(build_left_prompt)" assertEquals "%K{001} %F{226}Dur %F{226}0.03 %k%F{001}%f " "$(build_left_prompt)"
} }
function testCommandExecutionTimePrecisionCouldBeChanged() { function testCommandExecutionTimePrecisionCouldBeChanged() {
@ -58,7 +58,7 @@ function testCommandExecutionTimePrecisionCouldBeChanged() {
# Override payload # Override payload
local _P9K_COMMAND_DURATION=0.0001 local _P9K_COMMAND_DURATION=0.0001
assertEquals "%K{001} %F{226}Dur %f%F{226}0.0001 %k%F{001}%f " "$(build_left_prompt)" assertEquals "%K{001} %F{226}Dur %F{226}0.0001 %k%F{001}%f " "$(build_left_prompt)"
} }
function testCommandExecutionTimePrecisionCouldBeSetToZero() { function testCommandExecutionTimePrecisionCouldBeSetToZero() {
@ -72,7 +72,7 @@ function testCommandExecutionTimePrecisionCouldBeSetToZero() {
# Override payload # Override payload
local _P9K_COMMAND_DURATION=23.5001 local _P9K_COMMAND_DURATION=23.5001
assertEquals "%K{001} %F{226}Dur %f%F{226}23 %k%F{001}%f " "$(build_left_prompt)" assertEquals "%K{001} %F{226}Dur %F{226}23 %k%F{001}%f " "$(build_left_prompt)"
} }
function testCommandExecutionTimeIsFormattedHumandReadbleForMinuteLongCommand() { function testCommandExecutionTimeIsFormattedHumandReadbleForMinuteLongCommand() {
@ -85,7 +85,7 @@ function testCommandExecutionTimeIsFormattedHumandReadbleForMinuteLongCommand()
# Override payload # Override payload
local _P9K_COMMAND_DURATION=180 local _P9K_COMMAND_DURATION=180
assertEquals "%K{001} %F{226}Dur %f%F{226}03:00 %k%F{001}%f " "$(build_left_prompt)" assertEquals "%K{001} %F{226}Dur %F{226}03:00 %k%F{001}%f " "$(build_left_prompt)"
} }
function testCommandExecutionTimeIsFormattedHumandReadbleForHourLongCommand() { function testCommandExecutionTimeIsFormattedHumandReadbleForHourLongCommand() {
@ -98,7 +98,7 @@ function testCommandExecutionTimeIsFormattedHumandReadbleForHourLongCommand() {
# Override payload # Override payload
local _P9K_COMMAND_DURATION=7200 local _P9K_COMMAND_DURATION=7200
assertEquals "%K{001} %F{226}Dur %f%F{226}02:00:00 %k%F{001}%f " "$(build_left_prompt)" assertEquals "%K{001} %F{226}Dur %F{226}02:00:00 %k%F{001}%f " "$(build_left_prompt)"
} }
source shunit2/shunit2 source shunit2/shunit2

@ -67,7 +67,7 @@ function testSettingVisualIdentifierForCustomSegment() {
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
assertEquals "%K{007} %F{000}hw %f%F{000}world %k%F{007}%f " "$(build_left_prompt)" assertEquals "%K{007} %F{000}hw %F{000}world %k%F{007}%f " "$(build_left_prompt)"
} }
function testSettingVisualIdentifierForegroundColorForCustomSegment() { function testSettingVisualIdentifierForegroundColorForCustomSegment() {
@ -80,7 +80,7 @@ function testSettingVisualIdentifierForegroundColorForCustomSegment() {
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
assertEquals "%K{007} %F{001}hw %f%F{000}world %k%F{007}%f " "$(build_left_prompt)" assertEquals "%K{007} %F{001}hw %F{000}world %k%F{007}%f " "$(build_left_prompt)"
} }
source shunit2/shunit2 source shunit2/shunit2

@ -352,7 +352,7 @@ function testHomeFolderDetectionWorks() {
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
cd ~ cd ~
assertEquals "%K{004} %F{000}home-icon %f%F{000}~ %k%F{004}%f " "$(build_left_prompt)" assertEquals "%K{004} %F{000}home-icon %F{000}~ %k%F{004}%f " "$(build_left_prompt)"
cd - cd -
} }
@ -368,7 +368,7 @@ function testHomeSubfolderDetectionWorks() {
local FOLDER=~/powerlevel9k-test local FOLDER=~/powerlevel9k-test
mkdir $FOLDER mkdir $FOLDER
cd $FOLDER cd $FOLDER
assertEquals "%K{004} %F{000}sub-icon %f%F{000}~/powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)" assertEquals "%K{004} %F{000}sub-icon %F{000}~/powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)"
cd - cd -
rm -fr $FOLDER rm -fr $FOLDER
@ -385,7 +385,7 @@ function testOtherFolderDetectionWorks() {
local FOLDER=/tmp/powerlevel9k-test local FOLDER=/tmp/powerlevel9k-test
mkdir $FOLDER mkdir $FOLDER
cd $FOLDER cd $FOLDER
assertEquals "%K{004} %F{000}folder-icon %f%F{000}/tmp/powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)" assertEquals "%K{004} %F{000}folder-icon %F{000}/tmp/powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)"
cd - cd -
rm -fr $FOLDER rm -fr $FOLDER
@ -462,7 +462,7 @@ function testOmittingFirstCharacterWorks() {
cd /tmp cd /tmp
assertEquals "%K{004} %F{000}folder-icon %f%F{000}tmp %k%F{004}%f " "$(build_left_prompt)" assertEquals "%K{004} %F{000}folder-icon %F{000}tmp %k%F{004}%f " "$(build_left_prompt)"
cd - cd -
} }
@ -480,7 +480,7 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparator() {
mkdir -p /tmp/powerlevel9k-test/1/2 mkdir -p /tmp/powerlevel9k-test/1/2
cd /tmp/powerlevel9k-test/1/2 cd /tmp/powerlevel9k-test/1/2
assertEquals "%K{004} %F{000}folder-icon %f%F{000}tmpxXxpowerlevel9k-testxXx1xXx2 %k%F{004}%f " "$(build_left_prompt)" assertEquals "%K{004} %F{000}folder-icon %F{000}tmpxXxpowerlevel9k-testxXx1xXx2 %k%F{004}%f " "$(build_left_prompt)"
cd - cd -
rm -fr /tmp/powerlevel9k-test rm -fr /tmp/powerlevel9k-test
@ -768,4 +768,22 @@ function testDirSeparatorColorRootSubSubdirWorks() {
rm -fr /tmp/powerlevel9k-test rm -fr /tmp/powerlevel9k-test
} }
function testDirHomeTruncationWorksOnlyAtTheBeginning() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local FOLDER=/tmp/p9ktest
local SAVED_HOME="${HOME}"
HOME="/p9ktest"
mkdir -p $FOLDER
# Setup folder marker
cd $FOLDER
assertEquals "%K{004} %F{000}/tmp/p9ktest %k%F{004}%f " "$(build_left_prompt)"
cd -
rm -fr $FOLDER
HOME="${SAVED_HOME}"
}
source shunit2/shunit2 source shunit2/shunit2

@ -40,7 +40,7 @@ function testDiskUsageSegmentWhenDiskIsAlmostFull() {
# Load Powerlevel9k # Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{001} %F{007}hdd %f%F{007}97%% %k%F{001}%f " "$(build_left_prompt)" assertEquals "%K{001} %F{007}hdd %F{007}97%% %k%F{001}%f " "$(build_left_prompt)"
unfunction df unfunction df
} }
@ -56,7 +56,7 @@ function testDiskUsageSegmentWhenDiskIsVeryFull() {
# Load Powerlevel9k # Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{003} %F{000}hdd %f%F{000}94%% %k%F{003}%f " "$(build_left_prompt)" assertEquals "%K{003} %F{000}hdd %F{000}94%% %k%F{003}%f " "$(build_left_prompt)"
unfunction df unfunction df
} }
@ -72,7 +72,7 @@ function testDiskUsageSegmentWhenDiskIsQuiteEmpty() {
# Load Powerlevel9k # Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{000} %F{003}hdd %f%F{003}4%% %k%F{000}%f " "$(build_left_prompt)" assertEquals "%K{000} %F{003}hdd %F{003}4%% %k%F{000}%f " "$(build_left_prompt)"
unfunction df unfunction df
} }
@ -105,7 +105,7 @@ function testDiskUsageSegmentWarningLevelCouldBeAdjusted() {
# Load Powerlevel9k # Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{003} %F{000}hdd %f%F{000}11%% %k%F{003}%f " "$(build_left_prompt)" assertEquals "%K{003} %F{000}hdd %F{000}11%% %k%F{003}%f " "$(build_left_prompt)"
unfunction df unfunction df
} }
@ -123,7 +123,7 @@ function testDiskUsageSegmentCriticalLevelCouldBeAdjusted() {
# Load Powerlevel9k # Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{001} %F{007}hdd %f%F{007}11%% %k%F{001}%f " "$(build_left_prompt)" assertEquals "%K{001} %F{007}hdd %F{007}11%% %k%F{001}%f " "$(build_left_prompt)"
unfunction df unfunction df
} }

@ -42,7 +42,7 @@ function testGo() {
local PWD="$HOME/go/src/github.com/bhilburn/powerlevel9k" local PWD="$HOME/go/src/github.com/bhilburn/powerlevel9k"
assertEquals "%K{002} %F{255} %f%F{255}go1.5.3 %k%F{002}%f " "$(build_left_prompt)" assertEquals "%K{002} %F{255} %F{255}go1.5.3 %k%F{002}%f " "$(build_left_prompt)"
unalias go unalias go
} }

@ -206,7 +206,7 @@ function testIpSegmentWorksOnOsxWithNoInterfaceSpecified() {
fakeIfconfig "eth1" "eth2" fakeIfconfig "eth1" "eth2"
assertEquals "%K{006} %F{000}IP %f%F{000}1.2.3.4 " "$(prompt_ip left 1 false "$FOLDER")" assertEquals "%K{006} %F{000}IP %F{000}1.2.3.4 " "$(prompt_ip left 1 false "$FOLDER")"
} }
function testIpSegmentWorksOnOsxWithInterfaceSpecified() { function testIpSegmentWorksOnOsxWithInterfaceSpecified() {
@ -216,7 +216,7 @@ function testIpSegmentWorksOnOsxWithInterfaceSpecified() {
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
local OS='OSX' # Fake OSX local OS='OSX' # Fake OSX
assertEquals "%K{006} %F{000}IP %f%F{000}1.2.3.4 " "$(prompt_ip left 1 false "$FOLDER")" assertEquals "%K{006} %F{000}IP %F{000}1.2.3.4 " "$(prompt_ip left 1 false "$FOLDER")"
} }
function testIpSegmentWorksOnLinuxWithNoInterfaceSpecified() { function testIpSegmentWorksOnLinuxWithNoInterfaceSpecified() {
@ -226,7 +226,7 @@ function testIpSegmentWorksOnLinuxWithNoInterfaceSpecified() {
fakeIp "eth0" fakeIp "eth0"
assertEquals "%K{006} %F{000}IP %f%F{000}1.2.3.4 " "$(prompt_ip left 1 false "$FOLDER")" assertEquals "%K{006} %F{000}IP %F{000}1.2.3.4 " "$(prompt_ip left 1 false "$FOLDER")"
} }
function testIpSegmentWorksOnLinuxWithInterfaceSpecified() { function testIpSegmentWorksOnLinuxWithInterfaceSpecified() {
@ -236,7 +236,7 @@ function testIpSegmentWorksOnLinuxWithInterfaceSpecified() {
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
local OS='Linux' # Fake Linux local OS='Linux' # Fake Linux
assertEquals "%K{006} %F{000}IP %f%F{000}1.2.3.4 " "$(prompt_ip left 1 false "$FOLDER")" assertEquals "%K{006} %F{000}IP %F{000}1.2.3.4 " "$(prompt_ip left 1 false "$FOLDER")"
} }
source shunit2/shunit2 source shunit2/shunit2

@ -71,7 +71,7 @@ function testKubeContext() {
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
assertEquals "%K{005} %F{007}⎈ %f%F{007}minikube/default %k%F{005}%f " "$(build_left_prompt)" assertEquals "%K{005} %F{007}⎈ %F{007}minikube/default %k%F{005}%f " "$(build_left_prompt)"
unalias kubectl unalias kubectl
} }
@ -83,7 +83,7 @@ function testKubeContextOtherNamespace() {
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
assertEquals "%K{005} %F{007}⎈ %f%F{007}minikube/kube-system %k%F{005}%f " "$(build_left_prompt)" assertEquals "%K{005} %F{007}⎈ %F{007}minikube/kube-system %k%F{005}%f " "$(build_left_prompt)"
unalias kubectl unalias kubectl
} }

@ -34,7 +34,7 @@ function testLaravelVersionSegment() {
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
assertEquals "%K{009} %F{007}x %f%F{007}5.4.23 %k%F{009}%f " "$(build_left_prompt)" assertEquals "%K{009} %F{007}x %F{007}5.4.23 %k%F{009}%f " "$(build_left_prompt)"
unalias php unalias php
} }

@ -42,7 +42,7 @@ function testLoadSegmentWorksOnOsx() {
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="OSX" # Fake OSX local OS="OSX" # Fake OSX
assertEquals "%K{002} %F{000}L %f%F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})" assertEquals "%K{002} %F{000}L %F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})"
unfunction sysctl unfunction sysctl
} }
@ -64,7 +64,7 @@ function testLoadSegmentWorksOnBsd() {
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="BSD" # Fake BSD local OS="BSD" # Fake BSD
assertEquals "%K{002} %F{000}L %f%F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})" assertEquals "%K{002} %F{000}L %F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})"
unfunction sysctl unfunction sysctl
} }
@ -81,7 +81,7 @@ function testLoadSegmentWorksOnLinux() {
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="Linux" # Fake Linux local OS="Linux" # Fake Linux
assertEquals "%K{002} %F{000}L %f%F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})" assertEquals "%K{002} %F{000}L %F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})"
unalias nproc unalias nproc
} }
@ -101,7 +101,7 @@ function testLoadSegmentNormalState() {
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="Linux" # Fake Linux local OS="Linux" # Fake Linux
assertEquals "%K{002} %F{000}L %f%F{000}1.00 " "$(prompt_load left 1 false ${FOLDER})" assertEquals "%K{002} %F{000}L %F{000}1.00 " "$(prompt_load left 1 false ${FOLDER})"
unalias nproc unalias nproc
} }
@ -121,7 +121,7 @@ function testLoadSegmentWarningState() {
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="Linux" # Fake Linux local OS="Linux" # Fake Linux
assertEquals "%K{003} %F{000}L %f%F{000}2.01 " "$(prompt_load left 1 false ${FOLDER})" assertEquals "%K{003} %F{000}L %F{000}2.01 " "$(prompt_load left 1 false ${FOLDER})"
unalias nproc unalias nproc
} }
@ -141,7 +141,7 @@ function testLoadSegmentCriticalState() {
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="Linux" # Fake Linux local OS="Linux" # Fake Linux
assertEquals "%K{001} %F{000}L %f%F{000}2.81 " "$(prompt_load left 1 false ${FOLDER})" assertEquals "%K{001} %F{000}L %F{000}2.81 " "$(prompt_load left 1 false ${FOLDER})"
unalias nproc unalias nproc
} }

@ -0,0 +1,42 @@
#!/usr/bin/env zsh
#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
# Required for shunit2 to run correctly
setopt shwordsplit
SHUNIT_PARENT=$0
function setUp() {
export TERM="xterm-256color"
P9K_HOME=$(pwd)
### Test specific
}
function testNewlineDoesNotCreateExtraSegmentSeparator() {
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 newline newline newline custom_world2)
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="OSX" # Fake OSX
local newline=$'\n'
assertEquals "%K{007} %F{000}world1 %k%F{007}%f${newline}%k%f${newline}%k%f${newline}%K{007} %F{000}world2 %k%F{007}%f " "$(build_left_prompt)"
}
function testNewlineMakesPreviousSegmentEndWell() {
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 newline)
# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="OSX" # Fake OSX
local newline=$'\n'
assertEquals "%K{007} %F{000}world1 %k%F{007}%f${newline}%k%F{none}%f " "$(build_left_prompt)"
}
source shunit2/shunit2

@ -33,7 +33,7 @@ function testNodeVersionSegmentWorks() {
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
assertEquals "%K{002} %F{007}⬢ %f%F{007}1.2.3 %k%F{002}%f " "$(build_left_prompt)" assertEquals "%K{002} %F{007}⬢ %F{007}1.2.3 %k%F{002}%f " "$(build_left_prompt)"
unfunction node unfunction node
} }

@ -44,26 +44,6 @@ function testNodeenvSegmentPrintsNothingIfNodeVirtualEnvIsNotSet() {
unfunction node unfunction node
} }
function testNodeenvSegmentPrintsNothingIfNodeVirtualEnvDisablePromptIsSet() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
node() {
echo "v1.2.3"
}
NODE_VIRTUAL_ENV="node-env"
NODE_VIRTUAL_ENV_DISABLE_PROMPT=true
# Load Powerlevel9k
source powerlevel9k.zsh-theme
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
unset NODE_VIRTUAL_ENV_DISABLE_PROMPT
unset NODE_VIRTUAL_ENV
unfunction node
}
function testNodeenvSegmentPrintsAtLeastNodeEnvWithoutNode() { function testNodeenvSegmentPrintsAtLeastNodeEnvWithoutNode() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv)
@ -73,7 +53,7 @@ function testNodeenvSegmentPrintsAtLeastNodeEnvWithoutNode() {
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
assertEquals "%K{000} %F{002}⬢ %f%F{002}[node-env] %k%F{000}%f " "$(build_left_prompt)" assertEquals "%K{000} %F{002}⬢ %F{002}[node-env] %k%F{000}%f " "$(build_left_prompt)"
unset NODE_VIRTUAL_ENV unset NODE_VIRTUAL_ENV
unalias node unalias node
@ -90,7 +70,7 @@ function testNodeenvSegmentWorks() {
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
assertEquals "%K{000} %F{002}⬢ %f%F{002}v1.2.3[node-env] %k%F{000}%f " "$(build_left_prompt)" assertEquals "%K{000} %F{002}⬢ %F{002}v1.2.3[node-env] %k%F{000}%f " "$(build_left_prompt)"
unfunction node unfunction node
unset NODE_VIRTUAL_ENV unset NODE_VIRTUAL_ENV

@ -51,7 +51,7 @@ function testNvmSegmentWorksWithoutHavingADefaultAlias() {
[[ ${1} == 'current' ]] && echo 'v4.6.0' || echo 'v1.4.0' [[ ${1} == 'current' ]] && echo 'v4.6.0' || echo 'v1.4.0'
} }
assertEquals "%K{005} %F{000}⬢ %f%F{000}4.6.0 %k%F{005}%f " "$(build_left_prompt)" assertEquals "%K{005} %F{000}⬢ %F{000}4.6.0 %k%F{005}%f " "$(build_left_prompt)"
} }
function testNvmSegmentPrintsNothingWhenOnDefaultVersion() { function testNvmSegmentPrintsNothingWhenOnDefaultVersion() {

@ -337,7 +337,7 @@ function testPublicIpSegmentWithVPNTurnedOnLinux() {
# Fake ip command # Fake ip command
fakeIp "tun1" fakeIp "tun1"
assertEquals "%K{000} %F{007}(vpn) %f%F{007}1.2.3.4 " "$(prompt_public_ip left 1 false "$FOLDER")" assertEquals "%K{000} %F{007}(vpn) %F{007}1.2.3.4 " "$(prompt_public_ip left 1 false "$FOLDER")"
} }
function testPublicIpSegmentWithVPNTurnedOnOsx() { function testPublicIpSegmentWithVPNTurnedOnOsx() {
@ -357,7 +357,7 @@ function testPublicIpSegmentWithVPNTurnedOnOsx() {
# Fake ifconfig # Fake ifconfig
fakeIfconfig "tun1" fakeIfconfig "tun1"
assertEquals "%K{000} %F{007}(vpn) %f%F{007}1.2.3.4 " "$(prompt_public_ip left 1 false "$FOLDER")" assertEquals "%K{000} %F{007}(vpn) %F{007}1.2.3.4 " "$(prompt_public_ip left 1 false "$FOLDER")"
unfunction stat unfunction stat
} }
@ -379,7 +379,7 @@ function testPublicIpSegmentWithVPNTurnedOnAndFuzzyMatchingOnOsx() {
# Fake ifconfig # Fake ifconfig
fakeIfconfig "tun3" fakeIfconfig "tun3"
assertEquals "%K{000} %F{007}(vpn) %f%F{007}1.2.3.4 " "$(prompt_public_ip left 1 false "$FOLDER")" assertEquals "%K{000} %F{007}(vpn) %F{007}1.2.3.4 " "$(prompt_public_ip left 1 false "$FOLDER")"
unfunction stat unfunction stat
} }

@ -36,7 +36,7 @@ Pages inactive: 1313411.
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="OSX" # Fake OSX local OS="OSX" # Fake OSX
assertEquals "%K{003} %F{000}RAM %f%F{000}6.15G " "$(prompt_ram left 1 false ${FOLDER})" assertEquals "%K{003} %F{000}RAM %F{000}6.15G " "$(prompt_ram left 1 false ${FOLDER})"
unalias vm_stat unalias vm_stat
} }
@ -49,7 +49,7 @@ function testRamSegmentWorksOnBsd() {
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="BSD" # Fake BSD local OS="BSD" # Fake BSD
assertEquals "%K{003} %F{000}RAM %f%F{000}0.29M " "$(prompt_ram left 1 false ${FOLDER})" assertEquals "%K{003} %F{000}RAM %F{000}0.29M " "$(prompt_ram left 1 false ${FOLDER})"
} }
function testRamSegmentWorksOnLinux() { function testRamSegmentWorksOnLinux() {
@ -60,7 +60,7 @@ function testRamSegmentWorksOnLinux() {
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="Linux" # Fake Linux local OS="Linux" # Fake Linux
assertEquals "%K{003} %F{000}RAM %f%F{000}0.29G " "$(prompt_ram left 1 false ${FOLDER})" assertEquals "%K{003} %F{000}RAM %F{000}0.29G " "$(prompt_ram left 1 false ${FOLDER})"
} }
source shunit2/shunit2 source shunit2/shunit2

@ -34,7 +34,7 @@ function testRust() {
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
assertEquals "%K{208} %F{000}Rust %f%F{000}0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)" assertEquals "%K{208} %F{000}Rust %F{000}0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)"
} }
function testRustPrintsNothingIfRustIsNotAvailable() { function testRustPrintsNothingIfRustIsNotAvailable() {

@ -37,7 +37,7 @@ function testSshSegmentWorksIfOnlySshClientIsSet() {
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
assertEquals "%K{000} %F{003}ssh-icon%f %k%F{000}%f " "$(build_left_prompt)" assertEquals "%K{000} %F{003}ssh-icon %k%F{000}%f " "$(build_left_prompt)"
unset SSH_CLIENT unset SSH_CLIENT
} }
@ -54,7 +54,7 @@ function testSshSegmentWorksIfOnlySshTtyIsSet() {
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
assertEquals "%K{000} %F{003}ssh-icon%f %k%F{000}%f " "$(build_left_prompt)" assertEquals "%K{000} %F{003}ssh-icon %k%F{000}%f " "$(build_left_prompt)"
unset SSH_TTY unset SSH_TTY
} }
@ -71,7 +71,7 @@ function testSshSegmentWorksIfAllNecessaryVariablesAreSet() {
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
assertEquals "%K{000} %F{003}ssh-icon%f %k%F{000}%f " "$(build_left_prompt)" assertEquals "%K{000} %F{003}ssh-icon %k%F{000}%f " "$(build_left_prompt)"
unset SSH_TTY unset SSH_TTY
unset SSH_CLIENT unset SSH_CLIENT

@ -37,7 +37,7 @@ function testStatusWorksAsExpectedIfReturnCodeIsZeroAndVerboseIsSet() {
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
assertEquals "%K{000} %F{002}✔%f %k%F{000}%f " "$(build_left_prompt)" assertEquals "%K{000} %F{002}✔ %k%F{000}%f " "$(build_left_prompt)"
} }
function testStatusInGeneralErrorCase() { function testStatusInGeneralErrorCase() {
@ -50,7 +50,7 @@ function testStatusInGeneralErrorCase() {
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
local RETVAL=1 local RETVAL=1
assertEquals "%K{001} %F{226}↵ %f%F{226}1 %k%F{001}%f " "$(build_left_prompt)" assertEquals "%K{001} %F{226}↵ %F{226}1 %k%F{001}%f " "$(build_left_prompt)"
} }
function testPipestatusInErrorCase() { function testPipestatusInErrorCase() {
@ -64,7 +64,7 @@ function testPipestatusInErrorCase() {
local -a RETVALS local -a RETVALS
RETVALS=(0 0 1 0) RETVALS=(0 0 1 0)
assertEquals "%K{001} %F{226}↵ %f%F{226}0|0|1|0 %k%F{001}%f " "$(build_left_prompt)" assertEquals "%K{001} %F{226}↵ %F{226}0|0|1|0 %k%F{001}%f " "$(build_left_prompt)"
} }
function testStatusCrossWinsOverVerbose() { function testStatusCrossWinsOverVerbose() {
@ -78,7 +78,7 @@ function testStatusCrossWinsOverVerbose() {
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
local RETVAL=1 local RETVAL=1
assertEquals "%K{000} %F{001}✘%f %k%F{000}%f " "$(build_left_prompt)" assertEquals "%K{000} %F{001}✘ %k%F{000}%f " "$(build_left_prompt)"
} }
function testStatusShowsSignalNameInErrorCase() { function testStatusShowsSignalNameInErrorCase() {
@ -92,7 +92,7 @@ function testStatusShowsSignalNameInErrorCase() {
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
local RETVAL=132 local RETVAL=132
assertEquals "%K{001} %F{226}↵ %f%F{226}SIGILL(4) %k%F{001}%f " "$(build_left_prompt)" assertEquals "%K{001} %F{226}↵ %F{226}SIGILL(4) %k%F{001}%f " "$(build_left_prompt)"
} }
function testStatusSegmentIntegrated() { function testStatusSegmentIntegrated() {
@ -107,7 +107,7 @@ function testStatusSegmentIntegrated() {
false; powerlevel9k_prepare_prompts false; powerlevel9k_prepare_prompts
assertEquals "%f%b%k%K{000} %F{001}✘%f %k%F{000}%f " "${(e)PROMPT}" assertEquals "%f%b%k%K{000} %F{001}✘ %k%F{000}%f " "${(e)PROMPT}"
} }
source shunit2/shunit2 source shunit2/shunit2

@ -36,7 +36,7 @@ function testSwapSegmentWorksOnOsx() {
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="OSX" # Fake OSX local OS="OSX" # Fake OSX
assertEquals "%K{003} %F{000}SWP %f%F{000}1.58G " "$(prompt_swap left 1 false ${FOLDER})" assertEquals "%K{003} %F{000}SWP %F{000}1.58G " "$(prompt_swap left 1 false ${FOLDER})"
unfunction sysctl unfunction sysctl
} }
@ -52,7 +52,7 @@ function testSwapSegmentWorksOnLinux() {
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
local OS="Linux" # Fake Linux local OS="Linux" # Fake Linux
assertEquals "%K{003} %F{000}SWP %f%F{000}0.95G " "$(prompt_swap left 1 false ${FOLDER})" assertEquals "%K{003} %F{000}SWP %F{000}0.95G " "$(prompt_swap left 1 false ${FOLDER})"
} }
source shunit2/shunit2 source shunit2/shunit2

@ -49,7 +49,7 @@ function testSwiftSegmentWorks() {
# Load Powerlevel9k # Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{005} %F{007}Swift %f%F{007}3.0.1 %k%F{005}%f " "$(build_left_prompt)" assertEquals "%K{005} %F{007}Swift %F{007}3.0.1 %k%F{005}%f " "$(build_left_prompt)"
unfunction swift unfunction swift
} }

@ -52,7 +52,7 @@ function testTodoSegmentWorksAsExpected() {
# Load Powerlevel9k # Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{244} %F{000}☑ %f%F{000}100 %k%F{244}%f " "$(build_left_prompt)" assertEquals "%K{244} %F{000}☑ %F{000}100 %k%F{244}%f " "$(build_left_prompt)"
} }
source shunit2/shunit2 source shunit2/shunit2

@ -117,7 +117,7 @@ function testGitIconWorks() {
# Load Powerlevel9k # Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{002} %F{000}Git-Icon %f%F{000} master %k%F{002}%f " "$(build_left_prompt)" assertEquals "%K{002} %F{000}Git-Icon %F{000} master %k%F{002}%f " "$(build_left_prompt)"
} }
function testGitlabIconWorks() { function testGitlabIconWorks() {
@ -132,7 +132,7 @@ function testGitlabIconWorks() {
# Load Powerlevel9k # Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{002} %F{000}GL-Icon %f%F{000} master %k%F{002}%f " "$(build_left_prompt)" assertEquals "%K{002} %F{000}GL-Icon %F{000} master %k%F{002}%f " "$(build_left_prompt)"
} }
function testBitbucketIconWorks() { function testBitbucketIconWorks() {
@ -147,7 +147,7 @@ function testBitbucketIconWorks() {
# Load Powerlevel9k # Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{002} %F{000}BB-Icon %f%F{000} master %k%F{002}%f " "$(build_left_prompt)" assertEquals "%K{002} %F{000}BB-Icon %F{000} master %k%F{002}%f " "$(build_left_prompt)"
} }
function testGitHubIconWorks() { function testGitHubIconWorks() {
@ -162,7 +162,7 @@ function testGitHubIconWorks() {
# Load Powerlevel9k # Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{002} %F{000}GH-Icon %f%F{000} master %k%F{002}%f " "$(build_left_prompt)" assertEquals "%K{002} %F{000}GH-Icon %F{000} master %k%F{002}%f " "$(build_left_prompt)"
} }
function testUntrackedFilesIconWorks() { function testUntrackedFilesIconWorks() {

@ -189,7 +189,7 @@ function testMercurialIconWorks() {
# Load Powerlevel9k # Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme source ${P9K_HOME}/powerlevel9k.zsh-theme
assertEquals "%K{002} %F{000}HG-Icon %f%F{000} default %k%F{002}%f " "$(build_left_prompt)" assertEquals "%K{002} %F{000}HG-Icon %F{000} default %k%F{002}%f " "$(build_left_prompt)"
} }
function testBookmarkIconWorks() { function testBookmarkIconWorks() {

@ -163,7 +163,7 @@ function testVpnIpSegmentWorksOnOsxWithInterfaceSpecified() {
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
local OS='OSX' # Fake OSX local OS='OSX' # Fake OSX
assertEquals "%K{006} %F{000}(vpn) %f%F{000}1.2.3.4 " "$(prompt_vpn_ip left 1 false "$FOLDER")" assertEquals "%K{006} %F{000}(vpn) %F{000}1.2.3.4 " "$(prompt_vpn_ip left 1 false "$FOLDER")"
} }
function testVpnIpSegmentWorksOnLinuxWithInterfaceSpecified() { function testVpnIpSegmentWorksOnLinuxWithInterfaceSpecified() {
@ -175,7 +175,7 @@ function testVpnIpSegmentWorksOnLinuxWithInterfaceSpecified() {
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
local OS='Linux' # Fake Linux local OS='Linux' # Fake Linux
assertEquals "%K{006} %F{000}(vpn) %f%F{000}1.2.3.4 " "$(prompt_vpn_ip left 1 false "$FOLDER")" assertEquals "%K{006} %F{000}(vpn) %F{000}1.2.3.4 " "$(prompt_vpn_ip left 1 false "$FOLDER")"
} }
# vpn_ip is not capable of handling multiple vpn interfaces ATM. # vpn_ip is not capable of handling multiple vpn interfaces ATM.
@ -189,7 +189,7 @@ function testVpnIpSegmentWorksOnLinuxWithInterfaceSpecified() {
# local OS='Linux' # Fake Linux # local OS='Linux' # Fake Linux
# setopt xtrace # setopt xtrace
# assertEquals "%K{006} %F{000}(vpn) %f%F{000}10.0.2.15 " "$(prompt_vpn_ip left 1 false "$FOLDER")" # assertEquals "%K{006} %F{000}(vpn) %F{000}10.0.2.15 " "$(prompt_vpn_ip left 1 false "$FOLDER")"
# unsetopt xtrace # unsetopt xtrace
# } # }

Loading…
Cancel
Save