1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-18 02:30:07 +00:00

Merge pull request #859 from dritter/staging_065

Merging the staging branch for 0.6.5!
This commit is contained in:
Ben Hilburn 2018-06-25 09:41:54 -04:00 committed by GitHub
commit 348617040b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 462 additions and 107 deletions

View file

@ -29,3 +29,4 @@ script:
- test/segments/go_version.spec - test/segments/go_version.spec
- test/segments/vcs.spec - test/segments/vcs.spec
- test/segments/kubecontext.spec - test/segments/kubecontext.spec
- test/segments/laravel_version.spec

View file

@ -1,3 +1,9 @@
## next
### New Segment: `laravel_version`
Displays the current laravel version.
## v0.6.4 ## v0.6.4
- `load` segment now has configurable averages. - `load` segment now has configurable averages.

View file

@ -120,6 +120,7 @@ The segments that are currently available are:
* `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.
* `laravel_version` - Show the current Laravel version.
* [`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:**
@ -130,10 +131,13 @@ The segments that are currently available are:
* [`chruby`](#chruby) - Ruby environment information using `chruby` (if one is active). * [`chruby`](#chruby) - Ruby environment information using `chruby` (if one is active).
* [`rbenv`](#rbenv) - Ruby environment information using `rbenv` (if one is active). * [`rbenv`](#rbenv) - Ruby environment information using `rbenv` (if one is active).
* [`rspec_stats`](#rspec_stats) - Show a ratio of test classes vs code classes for RSpec. * [`rspec_stats`](#rspec_stats) - Show a ratio of test classes vs code classes for RSpec.
* `rvm` - Ruby environment information using `$GEM_HOME` and `$MY_RUBY_HOME` (if one is active).
* **Rust Segments:** * **Rust Segments:**
* `rust_version` - Display the current rust version and [logo](https://www.rust-lang.org/logos/rust-logo-blk.svg). * `rust_version` - Display the current rust version and [logo](https://www.rust-lang.org/logos/rust-logo-blk.svg).
* **Swift Segments:** * **Swift Segments:**
* `swift_version` - Show the version number of the installed Swift. * `swift_version` - Show the version number of the installed Swift.
* **Java Segments:**
* `java_version` - Show the current Java version.
**Cloud Segments:** **Cloud Segments:**
* **AWS Segments:** * **AWS Segments:**
@ -213,8 +217,10 @@ You can also change the battery icon automatically depending on the battery
level. This will override the default battery icon. In order to do this, you level. This will override the default battery icon. In order to do this, you
need to define the `POWERLEVEL9k_BATTERY_STAGES` variable. need to define the `POWERLEVEL9k_BATTERY_STAGES` variable.
| Variable | Default Value | Description |
| `POWERLEVEL9K_BATTERY_STAGES`|Unset|A string or array, which each index indicates a charge level.| | Variable | Default Value | Description |
|-------------------------------|---------------|---------------------------------------------------------------|
| `POWERLEVEL9K_BATTERY_STAGES` | Unset | A string or array, which each index indicates a charge level. |
Powerlevel9k will use each index of the string or array as a stage to indicate battery Powerlevel9k will use each index of the string or array as a stage to indicate battery
charge level, progressing from left to right. You can provide any number of charge level, progressing from left to right. You can provide any number of
@ -254,10 +260,23 @@ As with the battery stages, you can use any number of colors and Powerlevel9k
will automatically use all of them appropriately. will automatically use all of them appropriately.
Some example settings: Some example settings:
|Brightness|Possible Array|
|Bright Colors|(red1 orangered1 darkorange orange1 gold1 yellow1 yellow2 greenyellow chartreuse1 chartreuse2 green1)| | Brightness | Possible Array |
|Normal Colors|(red3 darkorange3 darkgoldenrod gold3 yellow3 chartreuse2 mediumspringgreen green3 green3 green4 darkgreen)| |----------------|---------------------------------------------------------------------------------------------------------------|
|Subdued Colors|(darkred orange4 yellow4 yellow4 chartreuse3 green3 green4 darkgreen)| | Bright Colors | `(red1 orangered1 darkorange orange1 gold1 yellow1 yellow2 greenyellow chartreuse1 chartreuse2 green1)` |
| Normal Colors | `(red3 darkorange3 darkgoldenrod gold3 yellow3 chartreuse2 mediumspringgreen green3 green3 green4 darkgreen)` |
| Subdued Colors | `(darkred orange4 yellow4 yellow4 chartreuse3 green3 green4 darkgreen)` |
##### chruby
This segment shows the version of Ruby being used when using `chruby` to change your current Ruby stack.
It uses `$RUBY_ENGINE` and `$RUBY_VERSION` as set by `chruby`.
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_CHRUBY_SHOW_ENGINE`|true|Show the currently selected Ruby engine (e.g. `ruby`, `jruby`, `rbx`, etc)
|`POWERLEVEL9K_CHRUBY_SHOW_VERSION`|true|Shows the currently selected engine's version (e.g. `2.5.1`)
##### command_execution_time ##### command_execution_time
@ -499,7 +518,7 @@ segment will not be displayed.
| Variable | Default Value | Description | | Variable | Default Value | Description |
|----------|---------------|-------------| |----------|---------------|-------------|
|`POWERLEVEL9K_PUBLIC_IP_FILE`|'/tmp/p8k_public_ip'|This is the file your public IP is cached in.| |`POWERLEVEL9K_PUBLIC_IP_FILE`|'/tmp/p9k_public_ip'|This is the file your public IP is cached in.|
|`POWERLEVEL9K_PUBLIC_IP_HOST`|'http://ident.me'|This is the default host to get your public IP.| |`POWERLEVEL9K_PUBLIC_IP_HOST`|'http://ident.me'|This is the default host to get your public IP.|
|`POWERLEVEL9K_PUBLIC_IP_TIMEOUT`|300|The amount of time in seconds between refreshing your cached IP.| |`POWERLEVEL9K_PUBLIC_IP_TIMEOUT`|300|The amount of time in seconds between refreshing your cached IP.|
|`POWERLEVEL9K_PUBLIC_IP_METHODS`|(dig curl wget)| These methods in that order are used to refresh your IP.| |`POWERLEVEL9K_PUBLIC_IP_METHODS`|(dig curl wget)| These methods in that order are used to refresh your IP.|
@ -538,6 +557,10 @@ Variable | Default Value | Description |
|----------|---------------|-------------| |----------|---------------|-------------|
|`POWERLEVEL9K_RBENV_ALWAYS`|'false'|Always show the `rbenv` segment, even if the local version matches the global.| |`POWERLEVEL9K_RBENV_ALWAYS`|'false'|Always show the `rbenv` segment, even if the local version matches the global.|
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW`|`false`|Set to true if you wish to show the rbenv segment even if the current Ruby version is the same as the global Ruby version|
##### rspec_stats ##### rspec_stats
See [Unit Test Ratios](#unit-test-ratios), below. See [Unit Test Ratios](#unit-test-ratios), below.
@ -637,6 +660,31 @@ from the [Installation](#Installation) section above.
| None | None | ![icon_git](https://cloud.githubusercontent.com/assets/1544760/7976092/b5909f80-0a76-11e5-9950-1438b9d72465.gif) | Repository is a git repository | None | None | ![icon_git](https://cloud.githubusercontent.com/assets/1544760/7976092/b5909f80-0a76-11e5-9950-1438b9d72465.gif) | Repository is a git repository
| None | None | ![icon_mercurial](https://cloud.githubusercontent.com/assets/1544760/7976090/b5908da6-0a76-11e5-8c91-452b6e73f631.gif) | Repository is a Mercurial repository | None | None | ![icon_mercurial](https://cloud.githubusercontent.com/assets/1544760/7976090/b5908da6-0a76-11e5-8c91-452b6e73f631.gif) | Repository is a Mercurial repository
##### vcs truncation
You can limit the branch name to a certain length by truncating long names.
Customizations available are:
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_VCS_SHORTEN_LENGTH`|None|This field determines how many characters to show.|
|`POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH`|None|This field determines minimum branch length. Branch name will be truncated if its length greater than this field.|
|`POWERLEVEL9K_VCS_SHORTEN_STRATEGY`|None|This field determines how branch name should be truncated. See the table below for more information.|
|`POWERLEVEL9K_SHORTEN_DELIMITER`|`...`|Delimiter to use in truncated strings. This can be any string you choose, including an empty string if you wish to have no delimiter.|
| Strategy Name | Description |
|---------------|-------------|
|`truncate_middle`|Truncates the middle part of a branch. E.g. branch name is `1234-super_super_long_branch_name`, then it will truncated to `1234-..._name`, if `POWERLEVEL9K_VCS_SHORTEN_LENGTH=5` is also set (controls the amount of characters to be left).|
|`truncate_from_right`|Just leaves the beginning of a branch name untouched. E.g. branch name will be truncated like so: `1234-...`. How many characters will be untouched is controlled by `POWERLEVEL9K_VCS_SHORTEN_LENGTH`.|
For example, if you want to truncate `1234-super_super_long_branch_name` to `1234-..` and don't do it with `development`:
```zsh
POWERLEVEL9K_VCS_SHORTEN_LENGTH=4
POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=11
POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right"
POWERLEVEL9K_VCS_SHORTEN_DELIMITER=".."
```
##### vi_mode ##### vi_mode
This segment shows ZSH's current input mode. Note that this is only useful if This segment shows ZSH's current input mode. Note that this is only useful if

View file

@ -71,6 +71,7 @@ case $POWERLEVEL9K_MODE in
HOME_SUB_ICON $'\uE18D' #  HOME_SUB_ICON $'\uE18D' # 
FOLDER_ICON $'\uE818' #  FOLDER_ICON $'\uE818' # 
NETWORK_ICON $'\uE1AD' #  NETWORK_ICON $'\uE1AD' # 
ETC_ICON $'\uE82F' # 
LOAD_ICON $'\uE190 ' #  LOAD_ICON $'\uE190 ' # 
SWAP_ICON $'\uE87D' #  SWAP_ICON $'\uE87D' # 
RAM_ICON $'\uE1E2 ' #  RAM_ICON $'\uE1E2 ' # 
@ -96,7 +97,7 @@ case $POWERLEVEL9K_MODE in
VCS_GIT_GITLAB_ICON $'\uE20E ' # VCS_GIT_GITLAB_ICON $'\uE20E ' #
VCS_HG_ICON $'\uE1C3 ' #  VCS_HG_ICON $'\uE1C3 ' # 
VCS_SVN_ICON '(svn) ' VCS_SVN_ICON '(svn) '
RUST_ICON '' RUST_ICON '(rust)'
PYTHON_ICON $'\ue63c' #  PYTHON_ICON $'\ue63c' # 
SWIFT_ICON '' SWIFT_ICON ''
GO_ICON '' GO_ICON ''
@ -109,6 +110,8 @@ case $POWERLEVEL9K_MODE in
DROPBOX_ICON $'\UF16B' #  DROPBOX_ICON $'\UF16B' # 
DATE_ICON $'\uE184' #  DATE_ICON $'\uE184' # 
TIME_ICON $'\uE12E' #  TIME_ICON $'\uE12E' # 
JAVA_ICON $'\U2615' # ☕︎
LARAVEL_ICON ''
) )
;; ;;
'awesome-fontconfig') 'awesome-fontconfig')
@ -167,6 +170,7 @@ case $POWERLEVEL9K_MODE in
HOME_ICON $'\uF015' #  HOME_ICON $'\uF015' # 
HOME_SUB_ICON $'\uF07C' #  HOME_SUB_ICON $'\uF07C' # 
FOLDER_ICON $'\uF115' #  FOLDER_ICON $'\uF115' # 
ETC_ICON $'\uF013 ' # 
NETWORK_ICON $'\uF09E' #  NETWORK_ICON $'\uF09E' # 
LOAD_ICON $'\uF080 ' #  LOAD_ICON $'\uF080 ' # 
SWAP_ICON $'\uF0E4' #  SWAP_ICON $'\uF0E4' # 
@ -202,6 +206,8 @@ case $POWERLEVEL9K_MODE in
DROPBOX_ICON $'\UF16B' #  DROPBOX_ICON $'\UF16B' # 
DATE_ICON $'\uF073 ' #  DATE_ICON $'\uF073 ' # 
TIME_ICON $'\uF017 ' #  TIME_ICON $'\uF017 ' # 
JAVA_ICON $'\U2615' # ☕︎
LARAVEL_ICON ''
) )
;; ;;
'awesome-mapped-fontconfig') 'awesome-mapped-fontconfig')
@ -266,6 +272,7 @@ case $POWERLEVEL9K_MODE in
HOME_ICON '\u'$CODEPOINT_OF_AWESOME_HOME #  HOME_ICON '\u'$CODEPOINT_OF_AWESOME_HOME # 
HOME_SUB_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN #  HOME_SUB_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN # 
FOLDER_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_O #  FOLDER_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_O # 
ETC_ICON '\u'$CODEPOINT_OF_AWESOME_COG' ' # 
NETWORK_ICON '\u'$CODEPOINT_OF_AWESOME_RSS #  NETWORK_ICON '\u'$CODEPOINT_OF_AWESOME_RSS # 
LOAD_ICON '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' #  LOAD_ICON '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' # 
SWAP_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  SWAP_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD # 
@ -300,6 +307,8 @@ case $POWERLEVEL9K_MODE in
DROPBOX_ICON '\u'$CODEPOINT_OF_AWESOME_DROPBOX #  DROPBOX_ICON '\u'$CODEPOINT_OF_AWESOME_DROPBOX # 
DATE_ICON $'\uF073 ' #  DATE_ICON $'\uF073 ' # 
TIME_ICON $'\uF017 ' #  TIME_ICON $'\uF017 ' # 
JAVA_ICON $'\U2615' # ☕︎
LARAVEL_ICON ''
) )
;; ;;
'nerdfont-complete'|'nerdfont-fontconfig') 'nerdfont-complete'|'nerdfont-fontconfig')
@ -359,6 +368,7 @@ case $POWERLEVEL9K_MODE in
HOME_ICON $'\uF015' #  HOME_ICON $'\uF015' # 
HOME_SUB_ICON $'\uF07C' #  HOME_SUB_ICON $'\uF07C' # 
FOLDER_ICON $'\uF115' #  FOLDER_ICON $'\uF115' # 
ETC_ICON $'\uF013' # 
NETWORK_ICON $'\uF1EB' #  NETWORK_ICON $'\uF1EB' # 
LOAD_ICON $'\uF080 ' #  LOAD_ICON $'\uF080 ' # 
SWAP_ICON $'\uF464' #  SWAP_ICON $'\uF464' # 
@ -394,6 +404,8 @@ case $POWERLEVEL9K_MODE in
DROPBOX_ICON $'\UF16B' #  DROPBOX_ICON $'\UF16B' # 
DATE_ICON $'\uF073 ' #  DATE_ICON $'\uF073 ' # 
TIME_ICON $'\uF017 ' #  TIME_ICON $'\uF017 ' # 
JAVA_ICON $'\U2615' # ☕︎
LARAVEL_ICON $'\ue73f ' # 
) )
;; ;;
*) *)
@ -452,6 +464,7 @@ case $POWERLEVEL9K_MODE in
HOME_ICON '' HOME_ICON ''
HOME_SUB_ICON '' HOME_SUB_ICON ''
FOLDER_ICON '' FOLDER_ICON ''
ETC_ICON $'\u2699' # ⚙
NETWORK_ICON 'IP' NETWORK_ICON 'IP'
LOAD_ICON 'L' LOAD_ICON 'L'
SWAP_ICON 'SWP' SWAP_ICON 'SWP'
@ -474,7 +487,7 @@ case $POWERLEVEL9K_MODE in
VCS_GIT_GITLAB_ICON '' VCS_GIT_GITLAB_ICON ''
VCS_HG_ICON '' VCS_HG_ICON ''
VCS_SVN_ICON '' VCS_SVN_ICON ''
RUST_ICON '' RUST_ICON 'Rust'
PYTHON_ICON '' PYTHON_ICON ''
SWIFT_ICON 'Swift' SWIFT_ICON 'Swift'
GO_ICON 'Go' GO_ICON 'Go'
@ -487,6 +500,8 @@ case $POWERLEVEL9K_MODE in
DROPBOX_ICON 'Dropbox' DROPBOX_ICON 'Dropbox'
DATE_ICON '' DATE_ICON ''
TIME_ICON '' TIME_ICON ''
JAVA_ICON $'\U2615' # ☕︎
LARAVEL_ICON ''
) )
;; ;;
esac esac

View file

@ -106,58 +106,58 @@ case $(uname) in
OS='Linux' OS='Linux'
os_release_id="$(grep -E '^ID=([a-zA-Z]*)' /etc/os-release | cut -d '=' -f 2)" os_release_id="$(grep -E '^ID=([a-zA-Z]*)' /etc/os-release | cut -d '=' -f 2)"
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')
;; ;;
"debian") *debian*)
OS_ICON=$(print_icon 'LINUX_DEBIAN_ICON') OS_ICON=$(print_icon 'LINUX_DEBIAN_ICON')
;; ;;
"ubuntu") *ubuntu*)
OS_ICON=$(print_icon 'LINUX_UBUNTU_ICON') OS_ICON=$(print_icon 'LINUX_UBUNTU_ICON')
;; ;;
"elementary") *elementary*)
OS_ICON=$(print_icon 'LINUX_ELEMENTARY_ICON') OS_ICON=$(print_icon 'LINUX_ELEMENTARY_ICON')
;; ;;
"fedora") *fedora*)
OS_ICON=$(print_icon 'LINUX_FEDORA_ICON') OS_ICON=$(print_icon 'LINUX_FEDORA_ICON')
;; ;;
"coreos") *coreos*)
OS_ICON=$(print_icon 'LINUX_COREOS_ICON') OS_ICON=$(print_icon 'LINUX_COREOS_ICON')
;; ;;
"gentoo") *gentoo*)
OS_ICON=$(print_icon 'LINUX_GENTOO_ICON') OS_ICON=$(print_icon 'LINUX_GENTOO_ICON')
;; ;;
"mageia") *mageia*)
OS_ICON=$(print_icon 'LINUX_MAGEIA_ICON') OS_ICON=$(print_icon 'LINUX_MAGEIA_ICON')
;; ;;
"centos") *centos*)
OS_ICON=$(print_icon 'LINUX_CENTOS_ICON') OS_ICON=$(print_icon 'LINUX_CENTOS_ICON')
;; ;;
"opensuse"|"tumbleweed") *opensuse*|*tumbleweed*)
OS_ICON=$(print_icon 'LINUX_OPENSUSE_ICON') OS_ICON=$(print_icon 'LINUX_OPENSUSE_ICON')
;; ;;
"sabayon") *sabayon*)
OS_ICON=$(print_icon 'LINUX_SABAYON_ICON') OS_ICON=$(print_icon 'LINUX_SABAYON_ICON')
;; ;;
"slackware") *slackware*)
OS_ICON=$(print_icon 'LINUX_SLACKWARE_ICON') OS_ICON=$(print_icon 'LINUX_SLACKWARE_ICON')
;; ;;
"linuxmint") *linuxmint*)
OS_ICON=$(print_icon 'LINUX_MINT_ICON') OS_ICON=$(print_icon 'LINUX_MINT_ICON')
;; ;;
"alpine") *alpine*)
OS_ICON=$(print_icon 'LINUX_ALPINE_ICON') OS_ICON=$(print_icon 'LINUX_ALPINE_ICON')
;; ;;
"aosc") *aosc*)
OS_ICON=$(print_icon 'LINUX_AOSC_ICON') OS_ICON=$(print_icon 'LINUX_AOSC_ICON')
;; ;;
"nixos") *nixos*)
OS_ICON=$(print_icon 'LINUX_NIXOS_ICON') OS_ICON=$(print_icon 'LINUX_NIXOS_ICON')
;; ;;
"devuan") *devuan*)
OS_ICON=$(print_icon 'LINUX_DEVUAN_ICON') OS_ICON=$(print_icon 'LINUX_DEVUAN_ICON')
;; ;;
"manjaro") *manjaro*)
OS_ICON=$(print_icon 'LINUX_MANJARO_ICON') OS_ICON=$(print_icon 'LINUX_MANJARO_ICON')
;; ;;
*) *)

View file

@ -16,8 +16,8 @@ function +vi-git-untracked() {
FLAGS+='--ignore-submodules=dirty' FLAGS+='--ignore-submodules=dirty'
fi fi
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \ if [[ $(command git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \
-n $(git status ${FLAGS} | \grep -E '^\?\?' 2> /dev/null | tail -n1) ]]; then -n $(command git status ${FLAGS} | \grep -E '^\?\?' 2> /dev/null | tail -n1) ]]; then
hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')" hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')"
VCS_WORKDIR_HALF_DIRTY=true VCS_WORKDIR_HALF_DIRTY=true
else else
@ -29,16 +29,16 @@ function +vi-git-aheadbehind() {
local ahead behind branch_name local ahead behind branch_name
local -a gitstatus local -a gitstatus
branch_name=$(git symbolic-ref --short HEAD 2>/dev/null) branch_name=$(command git symbolic-ref --short HEAD 2>/dev/null)
# for git prior to 1.7 # for git prior to 1.7
# ahead=$(git rev-list origin/${branch_name}..HEAD | wc -l) # ahead=$(command git rev-list origin/${branch_name}..HEAD | wc -l)
ahead=$(git rev-list "${branch_name}"@{upstream}..HEAD 2>/dev/null | wc -l) ahead=$(command git rev-list "${branch_name}"@{upstream}..HEAD 2>/dev/null | wc -l)
(( ahead )) && gitstatus+=( " $(print_icon 'VCS_OUTGOING_CHANGES_ICON')${ahead// /}" ) (( ahead )) && gitstatus+=( " $(print_icon 'VCS_OUTGOING_CHANGES_ICON')${ahead// /}" )
# for git prior to 1.7 # for git prior to 1.7
# behind=$(git rev-list HEAD..origin/${branch_name} | wc -l) # behind=$(command git rev-list HEAD..origin/${branch_name} | wc -l)
behind=$(git rev-list HEAD.."${branch_name}"@{upstream} 2>/dev/null | wc -l) behind=$(command git rev-list HEAD.."${branch_name}"@{upstream} 2>/dev/null | wc -l)
(( behind )) && gitstatus+=( " $(print_icon 'VCS_INCOMING_CHANGES_ICON')${behind// /}" ) (( behind )) && gitstatus+=( " $(print_icon 'VCS_INCOMING_CHANGES_ICON')${behind// /}" )
hook_com[misc]+=${(j::)gitstatus} hook_com[misc]+=${(j::)gitstatus}
@ -48,8 +48,23 @@ function +vi-git-remotebranch() {
local remote branch_name local remote branch_name
# Are we on a remote-tracking branch? # Are we on a remote-tracking branch?
remote=${$(git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/} remote=${$(command git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/}
branch_name=$(git symbolic-ref --short HEAD 2>/dev/null) branch_name=$(command git symbolic-ref --short HEAD 2>/dev/null)
if [[ -n "$POWERLEVEL9K_VCS_SHORTEN_LENGTH" ]] && [[ -n "$POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH" ]]; then
set_default POWERLEVEL9K_VCS_SHORTEN_DELIMITER $'\U2026'
if [ ${#hook_com[branch]} -gt $POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH ] && [ ${#hook_com[branch]} -gt $POWERLEVEL9K_VCS_SHORTEN_LENGTH ]; then
case "$POWERLEVEL9K_VCS_SHORTEN_STRATEGY" in
truncate_middle)
hook_com[branch]="$(echo "${branch_name:0:$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")$POWERLEVEL9K_VCS_SHORTEN_DELIMITER$(echo "${branch_name: -$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")"
;;
truncate_from_right)
hook_com[branch]="$(echo "${branch_name:0:$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")$POWERLEVEL9K_VCS_SHORTEN_DELIMITER"
;;
esac
fi
fi
hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${hook_com[branch]}" hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${hook_com[branch]}"
# Always show the remote # Always show the remote
@ -65,18 +80,18 @@ function +vi-git-tagname() {
if [[ "$POWERLEVEL9K_VCS_HIDE_TAGS" == "false" ]]; then if [[ "$POWERLEVEL9K_VCS_HIDE_TAGS" == "false" ]]; then
# If we are on a tag, append the tagname to the current branch string. # If we are on a tag, append the tagname to the current branch string.
local tag local tag
tag=$(git describe --tags --exact-match HEAD 2>/dev/null) tag=$(command git describe --tags --exact-match HEAD 2>/dev/null)
if [[ -n "${tag}" ]] ; then if [[ -n "${tag}" ]] ; then
# There is a tag that points to our current commit. Need to determine if we # There is a tag that points to our current commit. Need to determine if we
# are also on a branch, or are in a DETACHED_HEAD state. # are also on a branch, or are in a DETACHED_HEAD state.
if [[ -z $(git symbolic-ref HEAD 2>/dev/null) ]]; then if [[ -z $(command git symbolic-ref HEAD 2>/dev/null) ]]; then
# DETACHED_HEAD state. We want to append the tag name to the commit hash # DETACHED_HEAD state. We want to append the tag name to the commit hash
# and print it. Unfortunately, `vcs_info` blows away the hash when a tag # and print it. Unfortunately, `vcs_info` blows away the hash when a tag
# exists, so we have to manually retrieve it and clobber the branch # exists, so we have to manually retrieve it and clobber the branch
# string. # string.
local revision local revision
revision=$(git rev-list -n 1 --abbrev-commit --abbrev=${POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH} HEAD) revision=$(command git rev-list -n 1 --abbrev-commit --abbrev=${POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH} HEAD)
hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${revision} $(print_icon 'VCS_TAG_ICON')${tag}" hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${revision} $(print_icon 'VCS_TAG_ICON')${tag}"
else else
# We are on both a tag and a branch; print both by appending the tag name. # We are on both a tag and a branch; print both by appending the tag name.
@ -91,8 +106,8 @@ function +vi-git-tagname() {
function +vi-git-stash() { function +vi-git-stash() {
local -a stashes local -a stashes
if [[ -s $(git rev-parse --git-dir)/refs/stash ]] ; then if [[ -s $(command git rev-parse --git-dir)/refs/stash ]] ; then
stashes=$(git stash list 2>/dev/null | wc -l) stashes=$(command git stash list 2>/dev/null | wc -l)
hook_com[misc]+=" $(print_icon 'VCS_STASH_ICON')${stashes// /}" hook_com[misc]+=" $(print_icon 'VCS_STASH_ICON')${stashes// /}"
fi fi
} }
@ -111,7 +126,7 @@ function +vi-hg-bookmarks() {
function +vi-vcs-detect-changes() { function +vi-vcs-detect-changes() {
if [[ "${hook_com[vcs]}" == "git" ]]; then if [[ "${hook_com[vcs]}" == "git" ]]; then
local remote=$(git ls-remote --get-url 2> /dev/null) local remote=$(command git ls-remote --get-url 2> /dev/null)
if [[ "$remote" =~ "github" ]] then if [[ "$remote" =~ "github" ]] then
vcs_visual_identifier='VCS_GIT_GITHUB_ICON' vcs_visual_identifier='VCS_GIT_GITHUB_ICON'
elif [[ "$remote" =~ "bitbucket" ]] then elif [[ "$remote" =~ "bitbucket" ]] then

View file

@ -156,12 +156,14 @@ left_prompt_segment() {
if [[ -n $6 ]]; then if [[ -n $6 ]]; then
visual_identifier="$(print_icon $6)" visual_identifier="$(print_icon $6)"
if [[ -n "$visual_identifier" ]]; then if [[ -n "$visual_identifier" ]]; then
# Add an whitespace if we print more than just the visual identifier.
# To avoid cutting off the visual identifier in some terminal emulators (e.g., Konsole, st),
# we need to color both the visual identifier and the whitespace.
[[ -n "$5" ]] && visual_identifier="$visual_identifier "
# 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)1#prompt_}_VISUAL_IDENTIFIER_COLOR local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR
set_default $visual_identifier_color_variable $4 set_default $visual_identifier_color_variable $4
visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f"
# Add an whitespace if we print more than just the visual identifier
[[ -n "$5" ]] && visual_identifier="$visual_identifier "
fi fi
fi fi
@ -222,6 +224,12 @@ right_prompt_segment() {
[[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="$(foregroundColor)" [[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="$(foregroundColor)"
# If CURRENT_RIGHT_BG is "NONE", we are the first right segment. # If CURRENT_RIGHT_BG is "NONE", we are the first right segment.
if [[ "$CURRENT_RIGHT_BG" != "NONE" ]]; then
# This is the closing whitespace for the previous segment
echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f"
fi
if [[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]]; then if [[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]]; then
if isSameColor "$CURRENT_RIGHT_BG" "$3"; then if isSameColor "$CURRENT_RIGHT_BG" "$3"; then
# Middle segment with same color as previous segment # Middle segment with same color as previous segment
@ -241,12 +249,14 @@ right_prompt_segment() {
if [[ -n "$6" ]]; then if [[ -n "$6" ]]; then
visual_identifier="$(print_icon $6)" visual_identifier="$(print_icon $6)"
if [[ -n "$visual_identifier" ]]; then if [[ -n "$visual_identifier" ]]; then
# Add an whitespace if we print more than just the visual identifier.
# To avoid cutting off the visual identifier in some terminal emulators (e.g., Konsole, st),
# we need to color both the visual identifier and the whitespace.
[[ -n "$5" ]] && visual_identifier=" $visual_identifier"
# 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)1#prompt_}_VISUAL_IDENTIFIER_COLOR local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR
set_default $visual_identifier_color_variable $4 set_default $visual_identifier_color_variable $4
visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f"
# Add an whitespace if we print more than just the visual identifier
[[ -n "$5" ]] && visual_identifier=" $visual_identifier"
fi fi
fi fi
@ -258,7 +268,7 @@ right_prompt_segment() {
# Print segment content if there is any # Print segment content if there is any
[[ -n "$5" ]] && echo -n "${5}" [[ -n "$5" ]] && echo -n "${5}"
# Print the visual identifier # Print the visual identifier
echo -n "${visual_identifier}${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f" echo -n "${visual_identifier}"
CURRENT_RIGHT_BG=$3 CURRENT_RIGHT_BG=$3
last_right_element_index=$current_index last_right_element_index=$current_index
@ -487,16 +497,20 @@ prompt_battery() {
[[ "${(t)POWERLEVEL9K_BATTERY_STAGES}" =~ "array" ]] && POWERLEVEL9K_BATTERY_ICON="$POWERLEVEL9K_BATTERY_STAGES[$offset]" || POWERLEVEL9K_BATTERY_ICON=${POWERLEVEL9K_BATTERY_STAGES:$offset:1} [[ "${(t)POWERLEVEL9K_BATTERY_STAGES}" =~ "array" ]] && POWERLEVEL9K_BATTERY_ICON="$POWERLEVEL9K_BATTERY_STAGES[$offset]" || POWERLEVEL9K_BATTERY_ICON=${POWERLEVEL9K_BATTERY_STAGES:$offset:1}
fi fi
fi fi
# return if POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD is set and the battery percentage is greater or equal
# override the default color if we are using a color level array if [[ -v "POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD" && "${bat_percent}" -ge $POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD ]]; then
if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then return
local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) ))
local offset=$(( ($bat_percent / $segment) + 1 ))
"$1_prompt_segment" "$0_${current_state}" "$2" "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON"
else
# Draw the prompt_segment
"$1_prompt_segment" "$0_${current_state}" "$2" "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON"
fi fi
# override the default color if we are using a color level array
if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then
local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) ))
local offset=$(( ($bat_percent / $segment) + 1 ))
"$1_prompt_segment" "$0_${current_state}" "$2" "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON"
else
# Draw the prompt_segment
"$1_prompt_segment" "$0_${current_state}" "$2" "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON"
fi
} }
################################################################ ################################################################
@ -637,14 +651,14 @@ prompt_user() {
"FOREGROUND_COLOR" "yellow" "FOREGROUND_COLOR" "yellow"
"VISUAL_IDENTIFIER" "ROOT_ICON" "VISUAL_IDENTIFIER" "ROOT_ICON"
) )
elif sudo -n true 2>/dev/null; then elif sudo -n true 2>/dev/null; then
user_state=( user_state=(
"STATE" "SUDO" "STATE" "SUDO"
"CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}"
"BACKGROUND_COLOR" "${DEFAULT_COLOR}" "BACKGROUND_COLOR" "${DEFAULT_COLOR}"
"FOREGROUND_COLOR" "yellow" "FOREGROUND_COLOR" "yellow"
"VISUAL_IDENTIFIER" "SUDO_ICON" "VISUAL_IDENTIFIER" "SUDO_ICON"
) )
else else
user_state=( user_state=(
"STATE" "DEFAULT" "STATE" "DEFAULT"
@ -895,7 +909,9 @@ prompt_dir() {
fi fi
;; ;;
*) *)
current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" if [[ $current_path != "~" ]]; then
current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")"
fi
;; ;;
esac esac
fi fi
@ -909,10 +925,13 @@ prompt_dir() {
"HOME" "HOME_ICON" "HOME" "HOME_ICON"
"HOME_SUBFOLDER" "HOME_SUB_ICON" "HOME_SUBFOLDER" "HOME_SUB_ICON"
"NOT_WRITABLE" "LOCK_ICON" "NOT_WRITABLE" "LOCK_ICON"
"ETC" "ETC_ICON"
) )
local state_path="$(print -P '%~')" local state_path="$(print -P '%~')"
local current_state="DEFAULT" local current_state="DEFAULT"
if [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then if [[ $state_path == '/etc'* ]]; then
current_state='ETC'
elif [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then
current_state="NOT_WRITABLE" current_state="NOT_WRITABLE"
elif [[ $state_path == '~' ]]; then elif [[ $state_path == '~' ]]; then
current_state="HOME" current_state="HOME"
@ -1096,6 +1115,18 @@ prompt_vpn_ip() {
done done
} }
################################################################
# Segment to display laravel version
prompt_laravel_version() {
local laravel_version="$(php artisan --version 2>/dev/null)"
if [[ -n "${laravel_version}" ]]; then
# Remove unrelevant infos
laravel_version="${laravel_version//Laravel Framework version /}"
"$1_prompt_segment" "$0" "$2" "maroon" "white" "${laravel_version}" 'LARAVEL_ICON'
fi
}
################################################################ ################################################################
# Segment to display load # Segment to display load
set_default POWERLEVEL9K_LOAD_WHICH 5 set_default POWERLEVEL9K_LOAD_WHICH 5
@ -1229,19 +1260,21 @@ prompt_ram() {
"$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON' "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON'
} }
################################################################
# Segment to display rbenv information set_default POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW false
set_default POWERLEVEL9K_RBENV_ALWAYS false # rbenv information
prompt_rbenv() { prompt_rbenv() {
if which rbenv 2>/dev/null >&2; then if command which rbenv 2>/dev/null >&2; then
local rbenv_version_name="$(rbenv version-name)" local rbenv_version_name="$(rbenv version-name)"
local rbenv_global="$(rbenv global)" local rbenv_global="$(rbenv global)"
# Don't show anything if the current Ruby is the same as the global Ruby # Don't show anything if the current Ruby is the same as the global Ruby
# unless `POWERLEVEL9K_RBENV_ALWAYS` is set. # unless `POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW` is set.
if [[ $POWERLEVEL9K_RBENV_ALWAYS == true || $rbenv_version_name != $rbenv_global ]];then if [[ $rbenv_version_name == $rbenv_global && "$POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW" = false ]]; then
"$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' return
fi fi
"$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON'
fi fi
} }
@ -1249,11 +1282,24 @@ prompt_rbenv() {
# Segment to display chruby information # Segment to display chruby information
# see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH # see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH
prompt_chruby() { prompt_chruby() {
local chruby_env # Uses $RUBY_VERSION and $RUBY_ENGINE set by chruby
chrb_env="$(chruby 2> /dev/null | grep \* | tr -d '* ')" set_default POWERLEVEL9K_CHRUBY_SHOW_VERSION true
set_default POWERLEVEL9K_CHRUBY_SHOW_ENGINE true
local chruby_label=""
if [[ "$POWERLEVEL9K_CHRUBY_SHOW_ENGINE" == true ]]; then
chruby_label+="$RUBY_ENGINE "
fi
if [[ "$POWERLEVEL9K_CHRUBY_SHOW_VERSION" == true ]]; then
chruby_label+="$RUBY_VERSION"
fi
# Truncate trailing spaces
chruby_label="${chruby_label%"${chruby_label##*[![:space:]]}"}"
# Don't show anything if the chruby did not change the default ruby # Don't show anything if the chruby did not change the default ruby
if [[ "${chrb_env:-system}" != "system" ]]; then if [[ "$RUBY_ENGINE" != "" ]]; then
"$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "${chrb_env}" 'RUBY_ICON' "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "${chruby_label}" 'RUBY_ICON'
fi fi
} }
@ -1269,15 +1315,18 @@ prompt_root_indicator() {
# Segment to display Rust version number # Segment to display Rust version number
prompt_rust_version() { prompt_rust_version() {
local rust_version local rust_version
rust_version=$(rustc --version 2>&1 | grep -oe "^rustc\s*[^ ]*" | grep -o '[0-9.a-z\\\-]*$') rust_version=$(command rustc --version 2>/dev/null)
# Remove "rustc " (including the whitespace) from the beginning
# of the version string and remove everything after the next
# whitespace. This way we'll end up with only the version.
rust_version=${${rust_version/rustc /}%% *}
if [[ -n "$rust_version" ]]; then if [[ -n "$rust_version" ]]; then
"$1_prompt_segment" "$0" "$2" "darkorange" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON' "$1_prompt_segment" "$0" "$2" "darkorange" "$DEFAULT_COLOR" "$rust_version" 'RUST_ICON'
fi fi
} }
################################################################ # RSpec test ratio
# Segment to display RSpec test ratio
prompt_rspec_stats() { prompt_rspec_stats() {
if [[ (-d app && -d spec) ]]; then if [[ (-d app && -d spec) ]]; then
local code_amount tests_amount local code_amount tests_amount
@ -1337,8 +1386,13 @@ prompt_status() {
local ec local ec
if [[ $POWERLEVEL9K_STATUS_SHOW_PIPESTATUS == true ]]; then if [[ $POWERLEVEL9K_STATUS_SHOW_PIPESTATUS == true ]]; then
ec_text=$(exit_code_or_status "${RETVALS[1]}") if (( $#RETVALS > 1 )); then
ec_sum=${RETVALS[1]} ec_text=$(exit_code_or_status "${RETVALS[1]}")
ec_sum=${RETVALS[1]}
else
ec_text=$(exit_code_or_status "${RETVAL}")
ec_sum=${RETVAL}
fi
for ec in "${(@)RETVALS[2,-1]}"; do for ec in "${(@)RETVALS[2,-1]}"; do
ec_text="${ec_text}|$(exit_code_or_status "$ec")" ec_text="${ec_text}|$(exit_code_or_status "$ec")"
@ -1654,7 +1708,21 @@ prompt_dropbox() {
"$1_prompt_segment" "$0" "$2" "white" "blue" "$dropbox_status" "DROPBOX_ICON" "$1_prompt_segment" "$0" "$2" "white" "blue" "$dropbox_status" "DROPBOX_ICON"
fi fi
}
# print Java version number
prompt_java_version() {
local java_version
# Stupid: Java prints its version on STDERR.
# The first version ouput will print nothing, we just
# use it to transport whether the command was successful.
# If yes, we parse the version string (and need to
# redirect the stderr to stdout to make the pipe work).
java_version=$(java -version 2>/dev/null && java -fullversion 2>&1 | cut -d '"' -f 2)
if [[ -n "$java_version" ]]; then
"$1_prompt_segment" "$0" "$2" "red" "white" "$java_version" "JAVA_ICON"
fi
} }
################################################################ ################################################################
@ -1700,6 +1768,9 @@ build_right_prompt() {
index=$((index + 1)) index=$((index + 1))
done done
# Clear to the end of the line
echo -n "%E"
} }
powerlevel9k_preexec() { powerlevel9k_preexec() {
@ -1740,7 +1811,7 @@ $(print_icon 'MULTILINE_LAST_PROMPT_PREFIX')'
fi fi
if [[ "$POWERLEVEL9K_DISABLE_RPROMPT" != true ]]; then 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 fi
local NEWLINE=' local NEWLINE='

View file

@ -65,7 +65,7 @@ function testDynamicColoringOfVisualIdentifiersWork() {
cd /tmp cd /tmp
assertEquals "%K{blue} %F{green%}icon-here%f %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{green%}icon-here %f%F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR unset POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR
@ -86,7 +86,7 @@ function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() {
cd /tmp cd /tmp
assertEquals "%K{yellow} %F{green%}icon-here%f %F{red}/tmp %k%F{yellow}%f " "$(build_left_prompt)" assertEquals "%K{yellow} %F{green%}icon-here %f%F{red}/tmp %k%F{yellow}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR unset POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR
@ -106,7 +106,7 @@ function testOverwritingIconsWork() {
#cd ~/$testFolder #cd ~/$testFolder
cd /tmp cd /tmp
assertEquals "%K{blue} %F{black%}icon-here%f %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black%}icon-here %f%F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_DIR_FOLDER_ICON unset POWERLEVEL9K_DIR_FOLDER_ICON
@ -114,4 +114,23 @@ function testOverwritingIconsWork() {
# rm -fr ~/$testFolder # rm -fr ~/$testFolder
} }
function testNewlineOnRpromptCanBeDisabled() {
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_RPROMPT_ON_NEWLINE=false
POWERLEVEL9K_CUSTOM_WORLD='echo world'
POWERLEVEL9K_CUSTOM_RWORLD='echo rworld'
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_rworld)
powerlevel9k_prepare_prompts
assertEquals '$(print_icon MULTILINE_FIRST_PROMPT_PREFIX) world  $(print_icon MULTILINE_LAST_PROMPT_PREFIX) rworld' "$(print -P ${PROMPT}${RPROMPT})"
unset POWERLEVEL9K_PROMPT_ON_NEWLINE
unset POWERLEVEL9K_RPROMPT_ON_NEWLINE
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
unset POWERLEVEL9K_CUSTOM_WORLD
unset POWERLEVEL9K_CUSTOM_RWORLD
}
source shunit2/source/2.1/src/shunit2 source shunit2/source/2.1/src/shunit2

View file

@ -28,7 +28,7 @@ function testCommandExecutionTimeThresholdCouldBeChanged() {
POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=1 POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=1
_P9K_COMMAND_DURATION=2.03 _P9K_COMMAND_DURATION=2.03
assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}2.03 %k%F{red}%f " "$(build_left_prompt)" assertEquals "%K{red} %F{yellow1%}Dur %f%F{yellow1}2.03 %k%F{red}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION unset _P9K_COMMAND_DURATION
@ -40,7 +40,7 @@ function testCommandExecutionTimeThresholdCouldBeSetToZero() {
POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0 POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0
_P9K_COMMAND_DURATION=0.03 _P9K_COMMAND_DURATION=0.03
assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}0.03 %k%F{red}%f " "$(build_left_prompt)" assertEquals "%K{red} %F{yellow1%}Dur %f%F{yellow1}0.03 %k%F{red}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION unset _P9K_COMMAND_DURATION
@ -53,7 +53,7 @@ function testCommandExecutionTimePrecisionCouldBeChanged() {
POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=4 POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=4
_P9K_COMMAND_DURATION=0.0001 _P9K_COMMAND_DURATION=0.0001
assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}0.0001 %k%F{red}%f " "$(build_left_prompt)" assertEquals "%K{red} %F{yellow1%}Dur %f%F{yellow1}0.0001 %k%F{red}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION unset _P9K_COMMAND_DURATION
@ -66,7 +66,7 @@ function testCommandExecutionTimePrecisionCouldBeSetToZero() {
POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
_P9K_COMMAND_DURATION=23.5001 _P9K_COMMAND_DURATION=23.5001
assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}23 %k%F{red}%f " "$(build_left_prompt)" assertEquals "%K{red} %F{yellow1%}Dur %f%F{yellow1}23 %k%F{red}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION unset _P9K_COMMAND_DURATION
@ -77,7 +77,7 @@ function testCommandExecutionTimeIsFormattedHumandReadbleForMinuteLongCommand()
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
_P9K_COMMAND_DURATION=180 _P9K_COMMAND_DURATION=180
assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}03:00 %k%F{red}%f " "$(build_left_prompt)" assertEquals "%K{red} %F{yellow1%}Dur %f%F{yellow1}03:00 %k%F{red}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION unset _P9K_COMMAND_DURATION
@ -87,7 +87,7 @@ function testCommandExecutionTimeIsFormattedHumandReadbleForHourLongCommand() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
_P9K_COMMAND_DURATION=7200 _P9K_COMMAND_DURATION=7200
assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}02:00:00 %k%F{red}%f " "$(build_left_prompt)" assertEquals "%K{red} %F{yellow1%}Dur %f%F{yellow1}02:00:00 %k%F{red}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION unset _P9K_COMMAND_DURATION

View file

@ -46,6 +46,27 @@ function testTruncateFoldersWorks() {
unset POWERLEVEL9K_SHORTEN_STRATEGY unset POWERLEVEL9K_SHORTEN_STRATEGY
} }
function testTruncateFolderWithHomeDirWorks() {
POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
CURRENT_DIR=$(pwd)
cd ~
FOLDER="powerlevel9k-test-${RANDOM}"
mkdir -p $FOLDER
cd $FOLDER
# Switch back to home folder as this causes the problem.
cd ..
assertEquals "%K{blue} %F{black}~ %k%F{blue}%f " "$(build_left_prompt)"
rmdir $FOLDER
cd ${CURRENT_DIR}
unset CURRENT_DIR
unset FOLDER
unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
}
function testTruncateMiddleWorks() { function testTruncateMiddleWorks() {
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle' POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle'
@ -308,7 +329,7 @@ function testHomeFolderDetectionWorks() {
POWERLEVEL9K_HOME_ICON='home-icon' POWERLEVEL9K_HOME_ICON='home-icon'
cd ~ cd ~
assertEquals "%K{blue} %F{black%}home-icon%f %F{black}~ %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black%}home-icon %f%F{black}~ %k%F{blue}%f " "$(build_left_prompt)"
cd - cd -
unset POWERLEVEL9K_HOME_ICON unset POWERLEVEL9K_HOME_ICON
@ -320,7 +341,7 @@ function testHomeSubfolderDetectionWorks() {
FOLDER=~/powerlevel9k-test FOLDER=~/powerlevel9k-test
mkdir $FOLDER mkdir $FOLDER
cd $FOLDER cd $FOLDER
assertEquals "%K{blue} %F{black%}sub-icon%f %F{black}~/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black%}sub-icon %f%F{black}~/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)"
cd - cd -
rm -fr $FOLDER rm -fr $FOLDER
@ -334,7 +355,7 @@ function testOtherFolderDetectionWorks() {
FOLDER=/tmp/powerlevel9k-test FOLDER=/tmp/powerlevel9k-test
mkdir $FOLDER mkdir $FOLDER
cd $FOLDER cd $FOLDER
assertEquals "%K{blue} %F{black%}folder-icon%f %F{black}/tmp/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black%}folder-icon %f%F{black}/tmp/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)"
cd - cd -
rm -fr $FOLDER rm -fr $FOLDER
@ -386,7 +407,7 @@ function testOmittingFirstCharacterWorks() {
POWERLEVEL9K_FOLDER_ICON='folder-icon' POWERLEVEL9K_FOLDER_ICON='folder-icon'
cd /tmp cd /tmp
assertEquals "%K{blue} %F{black%}folder-icon%f %F{black}tmp %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black%}folder-icon %f%F{black}tmp %k%F{blue}%f " "$(build_left_prompt)"
cd - cd -
unset POWERLEVEL9K_FOLDER_ICON unset POWERLEVEL9K_FOLDER_ICON
@ -400,7 +421,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{blue} %F{black%}folder-icon%f %F{black}tmpxXxpowerlevel9k-testxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" assertEquals "%K{blue} %F{black%}folder-icon %f%F{black}tmpxXxpowerlevel9k-testxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)"
cd - cd -
rm -fr /tmp/powerlevel9k-test rm -fr /tmp/powerlevel9k-test

View file

@ -40,7 +40,7 @@ function testGo() {
PWD="$HOME/go/src/github.com/bhilburn/powerlevel9k" PWD="$HOME/go/src/github.com/bhilburn/powerlevel9k"
assertEquals "%K{green} %F{grey93%}%f %F{grey93}go1.5.3 %k%F{green}%f " "$(build_left_prompt)" assertEquals "%K{green} %F{grey93%} %f%F{grey93}go1.5.3 %k%F{green}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_GO_ICON unset POWERLEVEL9K_GO_ICON
unset PWD unset PWD

View file

@ -69,7 +69,7 @@ function testKubeContext() {
alias kubectl=mockKubectl alias kubectl=mockKubectl
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext)
assertEquals "%K{magenta} %F{white%}%f %F{white}minikube/default %k%F{magenta}%f " "$(build_left_prompt)" assertEquals "%K{magenta} %F{white%} %f%F{white}minikube/default %k%F{magenta}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unalias kubectl unalias kubectl
@ -78,7 +78,7 @@ function testKubeContextOtherNamespace() {
alias kubectl=mockKubectlOtherNamespace alias kubectl=mockKubectlOtherNamespace
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext)
assertEquals "%K{magenta} %F{white%}%f %F{white}minikube/kube-system %k%F{magenta}%f " "$(build_left_prompt)" assertEquals "%K{magenta} %F{white%} %f%F{white}minikube/kube-system %k%F{magenta}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unalias kubectl unalias kubectl

View file

@ -0,0 +1,69 @@
#!/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"
# Load Powerlevel9k
source powerlevel9k.zsh-theme
}
function mockLaravelVersion() {
case "$1" in
"artisan")
echo "Laravel Framework version 5.4.23"
;;
default)
esac
}
function mockNoLaravelVersion() {
# This should output some error
>&2 echo "Artisan not available"
return 1
}
function testLaravelVersionSegment() {
alias php=mockLaravelVersion
POWERLEVEL9K_LARAVEL_ICON='x'
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(laravel_version)
assertEquals "%K{001} %F{white%}x %f%F{white}5.4.23 %k%F{maroon}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_LARAVEL_ICON
unalias php
}
function testLaravelVersionSegmentIfArtisanIsNotAvailable() {
alias php=mockNoLaravelVersion
POWERLEVEL9K_CUSTOM_WORLD='echo world'
POWERLEVEL9K_LARAVEL_ICON='x'
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world laravel_version)
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_LARAVEL_ICON
unset POWERLEVEL9K_CUSTOM_WORLD
unalias php
}
function testLaravelVersionSegmentPrintsNothingIfPhpIsNotAvailable() {
alias php=noPhp
POWERLEVEL9K_CUSTOM_WORLD='echo world'
POWERLEVEL9K_LARAVEL_ICON='x'
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world laravel_version)
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_LARAVEL_ICON
unset POWERLEVEL9K_CUSTOM_WORLD
unalias php
}
source shunit2/source/2.1/src/shunit2

View file

@ -5,28 +5,39 @@
setopt shwordsplit setopt shwordsplit
SHUNIT_PARENT=$0 SHUNIT_PARENT=$0
TEST_BASE_FOLDER=/tmp/powerlevel9k-test
RUST_TEST_FOLDER="${TEST_BASE_FOLDER}/rust-test"
function setUp() { function setUp() {
OLDPATH="${PATH}"
mkdir -p "${RUST_TEST_FOLDER}"
PATH="${RUST_TEST_FOLDER}:${PATH}"
export TERM="xterm-256color" export TERM="xterm-256color"
# Load Powerlevel9k # Load Powerlevel9k
source powerlevel9k.zsh-theme source powerlevel9k.zsh-theme
} }
function tearDown() {
PATH="${OLDPATH}"
rm -fr "${TEST_BASE_FOLDER}"
}
function mockRust() { function mockRust() {
echo 'rustc 0.4.1a-alpha' echo "#!/bin/sh\n\necho 'rustc 0.4.1a-alpha'" > "${RUST_TEST_FOLDER}/rustc"
chmod +x "${RUST_TEST_FOLDER}/rustc"
} }
function testRust() { function testRust() {
alias rustc=mockRust mockRust
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version)
assertEquals "%K{208} %F{black}Rust 0.4.1a-alpha %k%F{darkorange}%f " "$(build_left_prompt)" assertEquals "%K{208} %F{black%}Rust %f%F{black}0.4.1a-alpha %k%F{darkorange}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unalias rustc
} }
function testRustPrintsNothingIfRustIsNotAvailable() { function testRustPrintsNothingIfRustIsNotAvailable() {
alias rustc=noRust
POWERLEVEL9K_CUSTOM_WORLD='echo world' POWERLEVEL9K_CUSTOM_WORLD='echo world'
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world rust_version) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world rust_version)
@ -34,7 +45,6 @@ function testRustPrintsNothingIfRustIsNotAvailable() {
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_CUSTOM_WORLD unset POWERLEVEL9K_CUSTOM_WORLD
unalias rustc
} }
source shunit2/source/2.1/src/shunit2 source shunit2/source/2.1/src/shunit2

View file

@ -78,4 +78,84 @@ function testColorOverridingForUntrackedStateWorks() {
unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND
} }
function testBranchNameTruncatingShortenLength() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
POWERLEVEL9K_VCS_SHORTEN_LENGTH=6
POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=3
POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right"
FOLDER=/tmp/powerlevel9k-test/vcs-test
mkdir -p $FOLDER
cd $FOLDER
git init 1>/dev/null
touch testfile
assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)"
POWERLEVEL9K_VCS_SHORTEN_LENGTH=3
assertEquals "%K{green} %F{black} mas ? %k%F{green}%f " "$(build_left_prompt)"
cd -
rm -fr /tmp/powerlevel9k-test
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_VCS_SHORTEN_LENGTH
unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH
unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY
}
function testBranchNameTruncatingMinLength() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
POWERLEVEL9K_VCS_SHORTEN_LENGTH=3
POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=6
POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right"
FOLDER=/tmp/powerlevel9k-test/vcs-test
mkdir -p $FOLDER
cd $FOLDER
git init 1>/dev/null
touch testfile
assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)"
POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=7
assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)"
cd -
rm -fr /tmp/powerlevel9k-test
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_VCS_SHORTEN_LENGTH
unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH
unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY
}
function testBranchNameTruncatingShortenStrategy() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
POWERLEVEL9K_VCS_SHORTEN_LENGTH=3
POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=3
POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right"
FOLDER=/tmp/powerlevel9k-test/vcs-test
mkdir -p $FOLDER
cd $FOLDER
git init 1>/dev/null
touch testfile
assertEquals "%K{green} %F{black} mas ? %k%F{green}%f " "$(build_left_prompt)"
POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_middle"
assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)"
cd -
rm -fr /tmp/powerlevel9k-test
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_VCS_SHORTEN_LENGTH
unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH
unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY
}
source shunit2/source/2.1/src/shunit2 source shunit2/source/2.1/src/shunit2