Moves includes into includes folder

Jonathan Hodgson 5 years ago
parent 3933e1b17b
commit c9291ffcbf
  1. 2
      shells/zsh/includes/aliases.zsh
  2. 0
      shells/zsh/includes/completion.zsh
  3. 0
      shells/zsh/includes/functions.zsh
  4. 2
      shells/zsh/includes/fzf.zsh
  5. 0
      shells/zsh/includes/globals.zsh
  6. 12
      shells/zsh/includes/lfcd.zsh
  7. 8
      shells/zsh/includes/promptconfig.zsh
  8. 2
      shells/zsh/includes/rangercd.zsh
  9. 0
      shells/zsh/includes/shortcuts.zsh
  10. 144
      shells/zsh/oh-my-zsh-custom/completion/_pass
  11. 1
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/.gitignore
  12. 3
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/.gitmodules
  13. 30
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/.travis.yml
  14. 362
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/CHANGELOG.md
  15. 20
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/LICENSE
  16. 514
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/README.md
  17. 22
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/TESTS.md
  18. 182
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/debug/font-issues.zsh
  19. 86
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/debug/iterm.zsh
  20. 56
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/colors.zsh
  21. 342
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/icons.zsh
  22. 234
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/utilities.zsh
  23. 152
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/vcs.zsh
  24. 1402
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/powerlevel9k.zsh-theme
  25. 1
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/prompt_powerlevel9k_setup
  26. 87
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-bsd-vm/Vagrantfile
  27. 3
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-bsd-vm/bootstrap-zero.sh
  28. 13
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-bsd-vm/bootstrap.sh
  29. 9
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm-providers/plain.sh
  30. 44
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm-providers/setup-environment.sh
  31. 25
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/README.md
  32. 82
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/Vagrantfile
  33. 30
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/antigen.sh
  34. 19
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/bootstrap.sh
  35. 33
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/omz.sh
  36. 29
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/prezto.sh
  37. 42
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/functions/colors.spec
  38. 362
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/functions/icons.spec
  39. 109
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/functions/utilities.spec
  40. 117
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/powerlevel9k.spec
  41. 96
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/command_execution_time.spec
  42. 364
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/dir.spec
  43. 86
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/go_version.spec
  44. 40
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/rust_version.spec
  45. 81
      shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/vcs.spec

@ -21,4 +21,4 @@ alias -s gitignore=$EDITOR
alias -s json=$EDITOR
unalias gf
#unalias gf

@ -1,5 +1,5 @@
# this rg command will get a list of files that are not in gitignore or similar
export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git"
export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git --exclude .PlayOnLinux --exclude \"PlayOnLinux\'s virtual drives\""
export FZF_DEFAULT_OPTS="--preview '[[ \$(file -L --mime {}) =~ binary ]] && echo {} is a binary file || ( bat --style=numbers --color=always {} || cat {}) 2> /dev/null | head -500'"
export FZF_CTRL_R_OPTS="--no-preview"
# this is the argument completeion optionm, use the same command

@ -0,0 +1,12 @@
# Use lf to switch directories and bind it to ctrl-o
lfcd () {
tmp="$(mktemp)"
lf -last-dir-path="$tmp" "$@"
if [ -f "$tmp" ]; then
dir="$(cat "$tmp")"
rm -f "$tmp"
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
fi
}
alias lf="lfcd"
bindkey -s '^o' 'lf\n'

@ -104,12 +104,12 @@ function prompt_project() {
local parent_process="$(ps -ocommand -p $PPID | grep -v 'COMMAND' | cut -d' ' -f1)"
local current_project_full="$(project current --path)"
local current_project_name="$(project current)"
if [[ "$parent_process" == "/usr/bin/script" ]]; then
segment_content="辶"
fi
# If there is a current project
if [ -n "$current_project_name" ]; then
segment_content="$current_project_name"
if [[ "$parent_process" == "/usr/bin/script" ]]; then
segment_content="$segment_content"
fi
segment_content="${segment_content}$current_project_name"
# If in the current project
if echo "$PWD" | grep -q "$current_project_full"; then
state="INSIDE"

@ -9,4 +9,4 @@ rangercd () {
fi
}
alias ranger="rangercd"
bindkey -s '^o' 'ranger\n'
#bindkey -s '^o' 'ranger\n'

@ -1,144 +0,0 @@
#compdef pass
#autoload
# Copyright (C) 2012 - 2014:
# Johan Venant <jvenant@invicem.pro>
# Brian Mattern <rephorm@rephorm.com>
# Jason A. Donenfeld <Jason@zx2c4.com>.
# All Rights Reserved.
# This file is licensed under the GPLv2+. Please see COPYING for more information.
# If you use multiple repositories, you can configure completion like this:
#
# compdef _pass workpass
# zstyle ':completion::complete:workpass::' prefix "$HOME/work/pass"
# workpass() {
# PASSWORD_STORE_DIR=$HOME/work/pass pass $@
# }
_pass () {
local cmd
if (( CURRENT > 2)); then
cmd=${words[2]}
# Set the context for the subcommand.
curcontext="${curcontext%:*:*}:pass-$cmd"
# Narrow the range of words we are looking at to exclude `pass'
(( CURRENT-- ))
shift words
# Run the completion for the subcommand
case "${cmd}" in
init)
_arguments : \
"-p[gpg-id will only be applied to this subfolder]" \
"--path[gpg-id will only be applied to this subfolder]"
_pass_complete_keys
;;
ls|list|edit)
_pass_complete_entries_with_subdirs
;;
insert)
_arguments : \
"-e[echo password to console]" \
"--echo[echo password to console]" \
"-m[multiline]" \
"--multiline[multiline]"
_pass_complete_entries_with_subdirs
;;
generate)
_arguments : \
"-n[don't include symbols in password]" \
"--no-symbols[don't include symbols in password]" \
"-c[copy password to the clipboard]" \
"--clip[copy password to the clipboard]" \
"-f[force overwrite]" \
"--force[force overwrite]" \
"-i[replace first line]" \
"--in-place[replace first line]"
_pass_complete_entries_with_subdirs
;;
cp|copy|mv|rename)
_arguments : \
"-f[force rename]" \
"--force[force rename]"
_pass_complete_entries_with_subdirs
;;
rm)
_arguments : \
"-f[force deletion]" \
"--force[force deletion]" \
"-r[recursively delete]" \
"--recursive[recursively delete]"
_pass_complete_entries_with_subdirs
;;
git)
local -a subcommands
subcommands=(
"init:Initialize git repository"
"push:Push to remote repository"
"pull:Pull from remote repository"
"config:Show git config"
"log:Show git log"
"reflog:Show git reflog"
)
_describe -t commands 'pass git' subcommands
;;
show|*)
_pass_cmd_show
;;
esac
else
local -a subcommands
subcommands=(
"init:Initialize new password storage"
"ls:List passwords"
"find:Find password files or directories based on pattern"
"grep:Search inside decrypted password files for matching pattern"
"show:Decrypt and print a password"
"insert:Insert a new password"
"generate:Generate a new password using pwgen"
"edit:Edit a password with \$EDITOR"
"mv:Rename the password"
"cp:Copy the password"
"rm:Remove the password"
"git:Call git on the password store"
"version:Output version information"
"help:Output help message"
)
_describe -t commands 'pass' subcommands
_arguments : \
"--version[Output version information]" \
"--help[Output help message]"
_pass_cmd_show
fi
}
_pass_cmd_show () {
_arguments : \
"-c[put it on the clipboard]" \
"--clip[put it on the clipboard]"
_pass_complete_entries
}
_pass_complete_entries_helper () {
local IFS=$'\n'
local prefix
zstyle -s ":completion:${curcontext}:" prefix prefix || prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
_values -C 'passwords' ${$(find -L "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print 2>/dev/null | sed -e "s#${prefix}/\{0,1\}##" -e 's#\.gpg##' -e 's#\\#\\\\#' | sort):-""}
}
_pass_complete_entries_with_subdirs () {
_pass_complete_entries_helper
}
_pass_complete_entries () {
_pass_complete_entries_helper -type f
}
_pass_complete_keys () {
local IFS=$'\n'
# Extract names and email addresses from gpg --list-keys
_values 'gpg keys' $(gpg2 --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')
}
_pass

@ -1,3 +0,0 @@
[submodule "shunit2"]
path = shunit2
url = https://github.com/kward/shunit2.git

@ -1,30 +0,0 @@
sudo: true
dist: trusty
language: sh
addons:
apt:
packages:
- build-essential
before_script:
# Show the git version being used to test.
- "git --version"
# Show the zsh version being used to test.
- "zsh --version"
install:
- "sudo apt-get update -qq"
- "sudo apt-get install -y zsh"
- "sudo chsh -s $(which zsh)"
- "sudo apt-get install -y git mercurial subversion jq node golang ruby python python-virtualenv"
script:
- test/powerlevel9k.spec
- test/functions/utilities.spec
- test/functions/colors.spec
- test/functions/icons.spec
- test/segments/command_execution_time.spec
- test/segments/dir.spec
- test/segments/rust_version.spec
- test/segments/go_version.spec
- test/segments/vcs.spec

@ -1,362 +0,0 @@
## v0.6.3
- Fixed susceptibility to [pw3nage exploit](https://github.com/njhartwell/pw3nage).
- Added support for Android
- The abbreviation for $HOME is now configurable (doesn't have to be `~`).
- Fixed colorization of VCS segment in Subversion repos.
- Improved handling of symlinks in installation paths.
## v0.6.2
- Fixed some issues with the new `nerdfont-fontconfig` option.
- Fixed typo in README.
- The `get_icon_names` function can now print sorted output, and show which
icons users have overridden.
- Added a FreeBSD VM for testing.
### Add debug script for iTerm2 issues
A new script `debug/iterm.zsh` was added for easier spotting problems with your iTerm2 configuration.
### Add debug script for font issues
A new script `debug/font-issues.zsh` was added, so that problems with your font could be spotted easier.
### `ram` changes
The `ram` segment now shows the available ram instead of free.
## v0.6.0
- Fixed a bug where the tag display was broken on detached HEADs.
- Fixed a bug where SVN detection sometimes failed.
- Fixed the `load` and `ram` segments for BSD.
- Fixed code-points that changed in Awesome fonts.
- Fixed display of "OK_ICON" in `status` segment in non-verbose mode.
- Fixed an issue where dir name truncation that was very short sometimes failed.
- Speed & accuracy improvements to the battery segment.
- Added Github syntax highlighting to README.
- Various documentation cleanup.
### New Font Option: nerd-fonts
There is now an option to use [nerd-fonts](https://github.com/ryanoasis/nerd-fonts) with P9k. Simply configure the `nerdfont-fontconfig`, and you'll be set!
### `vcs` changes
The VCS segment can now display icons for remote repo hosting services, including Github, Gitlab, and 'other'.
### `dir` changes
Added an option to configure the path separator. If you want something
else than an ordinary slash, you could set
`POWERLEVEL9K_DIR_PATH_SEPARATOR` to whatever you want.
#### `truncate_with_package_name` now searches for `composer.json` as well
Now `composer.json` files are searched as well. By default `package.json` still takes
precedence. If you want to change that, set `POWERLEVEL9K_DIR_PACKAGE_FILES=(composer.json package.json)`.
### New segment `command_execution_time` added
Shows the duration a command needed to run. By default only durations over 3 seconds
are shown (can be adjusted by setting POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD).
### New segment `dir_writable` added
This segment displays a lock icon if your user has no write permissions in the current folder.
### New segment `disk_usage` added
This segment will show the usage level of your current partition.
### New segment `public_ip` added
Fetches your Public IP (using ident.me) and displays it in your prompt.
### New segment `swift_version` added
This segment displays the version of Swift that is installed / in your path.
### New segment `detect_virt` added
Detects and reports if you are in a virtualized session using `systemd`.
## v0.5.0
### `load` and `ram` changes
These two segments now support BSD.
### `vcs` changes
- We implemented a huge speed improvement for this segment.
- Now this segment supports Subversion repositories.
- Add ability to hide tags by setting `POWERLEVEL9K_VCS_HIDE_TAGS` to true.
## `anaconda` changes
Speed improvements for `anaconda` segment.
## v0.4.0
### Development changes
From now on, development makes use of a CI system "travis".
### `vcs` changes
The default state was renamed to `clean`. If you overrode foreground
or background color in the past, you need to rename your variables to:
```zsh
POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan'
POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white'
```
Additionaly the vcs segment now has an `untracked` state which
indicates that you have untracked files in your repository.
The foreground color of actionformat is now configurable via:
```zsh
POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND='green'
```
Also, the vcs segment uses the foreground color it was configured to.
That said, the variables `POWERLEVEL9K_VCS_FOREGROUND` and
`POWERLEVEL9K_VCS_DARK_FOREGROUND` are no longer used. Instead use
the proper variable `POWERLEVEL9K_VCS_<STATE>_FOREGROUND` to change
foreground color.
### `dir` Shortening Strategies
There is now a path shortening strategy that will use the `package.json` file to
shorten your directory path. See the documentation for the `dir` segment for more
details.
Also, the shorten delimiter was changed to an unicode ellipsis. It is configurable
via `POWERLEVEL9K_SHORTEN_DELIMITER`.
### `rbenv` changes
The `rbenv` segment now makes use of the full rbenv command, so the correct
ruby version is now shown if it differs from the globally one.
### `node`, `nvm` Segments
Improvements to speed / reliability.
### `ram` changes
The `ram` segment was split up into `ram` and `swap`. The
`POWERLEVEL9K_RAM_ELEMENTS` variable is obsolete.
### New segment `swap` added
Due to the split up of the ram segment, this one was created. It
shows the currently used swap size.
### New segment `nodeenv` added
Added new `nodeenv` segment that shows the currently used node environment.
### New segment `aws_eb_env` added
This segment displays the current Elastic Beanstalk environment.
### New segment `chruby` added
Added new `chruby` segment to support this version manager.
### New segment `docker_machine` added
Added new `docker_machine` segment that will show your Docker machine.
### New segment `anaconda` added
A new segment `anaconda` was added that shows the current used
anaconda environment.
## New segment `pyenv` added
This segment shows your active python version as reported by `pyenv`.
## v0.3.2
### `vcs` changes
A new state `UNTRACKED` was added to the `vcs` segment. So we now
have 3 states for repositories: `UNTRACKED`, `MODIFIED`, and the
default state. The `UNTRACKED` state is active when there are files
in the repository directory which have not been added to the repo
(the same as when the `+` icon appears). The default color for the
`UNTRACKED` state is now yellow, and the default color for the
`MODIFIED` state is now read, but those colors can be changed by
setting these variables, for example:
```zsh
POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='black'
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='white'
POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='green'
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='blue'
```
## v0.3.1
### `dir` changes
A new state `HOME_SUBFOLDER` was added. So if you want to overwrite
colors for this segment, also set this variables:
```zsh
POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND='black'
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND='white'
```
### `background_jobs` changes
Now displays the number of background jobs if there's more than 1.
You can disable it by setting :
```zsh
POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false
```
## v0.3.0
### Introduced "visual identifiers" to the segments
Now almost every segment can have a visual identifier, which is an
icon whose color could be adjusted by users.
### Added ability for "joined" segments
You can now merge segments together by suffixing the segment name with "_joined".
For Developers: Be aware that the order of parameters in left/right_prompt_segment
has changed. Now a boolean parameter must be set as second parameter (true if joined).
### `dir` changes
This segment now has "state", which means you now can change the colors seperatly
depending if you are in your homefolder or not.
Your variables for that should now look like:
```zsh
POWERLEVEL9K_DIR_HOME_BACKGROUND='green'
POWERLEVEL9K_DIR_HOME_FOREGROUND='cyan'
POWERLEVEL9K_DIR_DEFAULT_BACKGROUND='red'
POWERLEVEL9K_DIR_DEFAULT_FOREGROUND='yellow'
```
### `status` changes
The `status` segment was split up into three segments. `background_jobs` prints
an icon if there are background jobs. `root_indicator` prints an icon if the user
is root. The `status` segment focuses now on the status only.
The `status` segment also now has "state". If you want to overwrite the colors,
you have to add the state to your variables:
```zsh
POWERLEVEL9K_STATUS_ERROR_BACKGROUND='green'
POWERLEVEL9K_STATUS_ERROR_FOREGROUND='cyan'
POWERLEVEL9K_STATUS_OK_BACKGROUND='red'
POWERLEVEL9K_STATUS_OK_FOREGROUND='yellow'
```
### New segment `custom_command` added
A new segment that allows users to define a custom command was added.
### `virtualenv` changes
This segment now respects `VIRTUAL_ENV_DISABLE_PROMPT`. If this variable is set
to `true`, the segments does not get rendered.
### `load` changes
The `load` segement was split and a new segment `ram` was extracted. This new
segment is able to show the free ram and used swap.
### `vcs` changes
This prompt uses the `VCS_INFO` subsystem by ZSH. From now on this subsystem
is only invoked if a `vcs` segment was configured.
### `rvm` changes
This segment now does not invoke RVM directly anymore. Instead, is relys on the
circumstance that RVM was invoked beforehand and just reads the environment
variables '$GEM_HOME' and '$MY_RUBY_HOME'. It also now displays the used gemset.
### New segment `battery` added
A new segment that shows the battery status of your laptop was added.
### New segment `go_version` added
This segment shows the GO version.
### New segment `nvm` added
This segment shows your NodeJS version by using NVM (and if it is not 'default').
### New segment `todo` added
This segment shows your ToDos from [todo.sh](http://todotxt.com/).
### New segment `rust_version` added
This segment shows your local rust version.
## v0.2.0
### `longstatus` is now `status`
The segments got merged together. To show the segment only if an error occurred,
set `POWERLEVEL9K_STATUS_VERBOSE=false` (this is the same behavior as the old
`status` segment.
### Icon overriding mechanism added
All icons can now be overridden by setting a variable named by the internal icon
name. You can get a full list of icon name by calling `get_icon_names`.
### Same color segements get visual separator
This separator can be controlled by setting `POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR`
or `POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR`. By default this separator is
printed in the foreground color.
### `dir` segment has different strategies for truncation
Now you can choose between `truncate_middle` or `truncate_from_right` by setting
`POWERLEVEL9K_SHORTEN_STRATEGY`. Default behavior is unchanged (truncate whole
directories). `POWERLEVEL9K_SHORTEN_DIR_LENGTH` can be used to influence how
much will be truncated (either direcories or chars).
### New segment `ip` added
This segment shows your internal IP address. You can define which interfaces IP
will be shown by specifying it via `POWERLEVEL9K_IP_INTERFACE`.
### New segment `load` added
This segment shows your computers 5min load average.
### New segment `os_icon` added
This segment shows a little indicator which OS you are running.
### New segment `php_version` added
This segment shows your PHP version.
### New segment `vi_mode` added
This segment gives you a hint in which VI-mode you currently are. This
segment requires a proper configured VI-mode.
### Added the ability to have empty left or right prompts
By setting the according variable to an empty array, the left or right
prompt will be empty.
## v0.1.0
This is the first release

@ -1,20 +0,0 @@
Copyright (c) 2014-2017 Ben Hilburn <bhilburn@gmail.com>
MIT LICENSE
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -1,514 +0,0 @@
![](https://raw.githubusercontent.com/bhilburn/powerlevel9k-logo/master/logo-banner.png)
---
[![Build Status](https://travis-ci.org/bhilburn/powerlevel9k.svg?branch=next)](https://travis-ci.org/bhilburn/powerlevel9k)
[![Join the chat at https://gitter.im/bhilburn/powerlevel9k](https://badges.gitter.im/bhilburn/powerlevel9k.svg)](https://gitter.im/bhilburn/powerlevel9k?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Powerlevel9k is a theme for ZSH which uses [Powerline
Fonts](https://github.com/powerline/fonts). It can be used with vanilla ZSH or
ZSH frameworks such as [Oh-My-Zsh](https://github.com/robbyrussell/oh-my-zsh),
[Prezto](https://github.com/sorin-ionescu/prezto),
[Antigen](https://github.com/zsh-users/antigen), and [many
others](https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions).
Get more out of your terminal. Be a badass. Impress everyone in 'Screenshot Your
Desktop' threads. Use powerlevel9k.
![](http://bhilburn.org/content/images/2015/01/pl9k-improved.png)
You can check out some other users' configurations in our wiki: [Show Off Your
Config](https://github.com/bhilburn/powerlevel9k/wiki/Show-Off-Your-Config).
There are a number of Powerline ZSH themes available, now. The developers of
this theme focus on four primary goals:
1. Give users a great out-of-the-box configuration with no additional
configuration required.
2. Make customization easy for users who do want to tweak their prompt.
3. Provide useful segments that you can enable to make your prompt even more
effective and helpful. We have prompt segments for everything from unit test
coverage to your AWS instance.
4. Optimize the code for execution speed as much as possible. A snappy terminal
is a happy terminal.
Powerlevel9k can be used to create both very useful and beautiful terminal environments:
![](https://camo.githubusercontent.com/b5d7eb49a30bfe6bdb5706fa3c9be95fe8e5956e/687474703a2f2f67696679752e636f6d2f696d616765732f70396b6e65772e676966)
### Table of Contents
1. [Installation](#installation)
2. [Customization](#prompt-customization)
1. [Stylizing Your Prompt](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt)
2. [Customizing Prompt Segments](#customizing-prompt-segments)
3. [Available Prompt Segments](#available-prompt-segments)
3. [Troubleshooting](https://github.com/bhilburn/powerlevel9k/wiki/Troubleshooting)
Be sure to also [check out the Wiki](https://github.com/bhilburn/powerlevel9k/wiki)!
### Installation
There are two installation steps to go from a vanilla terminal to a PL9k
terminal. Once you are done, you can optionally customize your prompt.
[Installation Instructions](https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions)
1. [Install the Powerlevel9k Theme](https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions#step-1-install-powerlevel9k)
2. [Install Powerline Fonts](https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions#step-2-install-a-powerline-font)
No configuration is necessary post-installation if you like the default
settings, but there are plenty of segment customization options available if you
are interested.
### Prompt Customization
Be sure to check out the wiki page on the additional prompt customization
options, including color and icon settings: [Stylizing Your Prompt](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt)
#### Customizing Prompt Segments
Customizing your prompt is easy! Select the segments you want to have displayed,
and then assign them to either the left or right prompt by adding the following
variables to your `~/.zshrc`.
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_LEFT_PROMPT_ELEMENTS`|`(context dir rbenv vcs)`|Segment list for left prompt|
|`POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS`|`(status root_indicator background_jobs history time)`|Segment list for right prompt|
The table above shows the default values, so if you wanted to set these
variables manually, you would put the following in
your `~/.zshrc`:
```zsh
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time)
```
#### Available Prompt Segments
The segments that are currently available are:
**System Status Segments:**
* [`background_jobs`](#background_jobs) - Indicator for background jobs.
* [`battery`](#battery) - Current battery status.
* [`context`](#context) - Your username and host, conditionalized based on $USER and SSH status.
* [`dir`](#dir) - Your current working directory.
* `dir_writable` - Displays a lock icon, if you do not have write permissions on the current folder.
* [`disk_usage`](#disk_usage) - Disk usage of your current partition.
* `history` - The command number for the current line.
* [`ip`](#ip) - Shows the current IP address.
* [`public_ip`](#public_ip) - Shows your public IP address.
* `load` - Your machine's load averages.
* `os_icon` - Display a nice little icon, depending on your operating system.
* `ram` - Show free RAM.
* `root_indicator` - An indicator if the user has superuser status.
* [`status`](#status) - The return code of the previous command.
* `swap` - Prints the current swap size.
* [`time`](#time) - System time.
* [`vi_mode`](#vi_mode)- Your prompt's Vi editing mode (NORMAL|INSERT).
* `ssh` - Indicates whether or not you are in an SSH session.
**Development Environment Segments:**
* [`vcs`](#vcs) - Information about this `git` or `hg` repository (if you are in one).
**Language Segments:**
* **GoLang Segments:**
* `go_version` - Show the current GO version.
* **Javascript / Node.js Segments:**
* `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.
* `nvm` - Show the version of Node that is currently active, if it differs from the version used by NVM
* **PHP Segments:**
* `php_version` - Show the current PHP version.
* [`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.
* **Python Segments:**
* `virtualenv` - Your Python [VirtualEnv](https://virtualenv.pypa.io/en/latest/).
* [`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.
* **Ruby Segments:**
* [`chruby`](#chruby) - Ruby environment information using `chruby` (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.
* **Rust Segments:**
* `rust_version` - Display the current rust version and [logo](https://www.rust-lang.org/logos/rust-logo-blk.svg).
* **Swift Segments:**
* `swift_version` - Show the version number of the installed Swift.
**Cloud Segments:**
* **AWS Segments:**
* [`aws`](#aws) - The current AWS profile, if active.
* `aws_eb_env` - The current Elastic Beanstalk Environment.
* `docker_machine` - The current Docker Machine.
**Other:**
* [`custom_command`](#custom_command) - Create a custom segment to display the
output of an arbitrary command.
* [`command_execution_time`](#command_execution_time) - Display the time the current command took to execute.
* [`todo`](http://todotxt.com/) - Shows the number of tasks in your todo.txt tasks file.
* `detect_virt` - Virtualization detection with systemd
---------------------------------------------------------------------------------
##### anaconda
This segment shows your active anaconda environment. It relies on either the
`CONDA_ENV_PATH` or the `CONDA_PREFIX` (depending on the `conda` version)
environment variable to be set which happens when you properly `source
activate` an environment.
Special configuration variables:
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_ANACONDA_LEFT_DELIMITER`|"("|The left delimiter just before the environment name.|
|`POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER`|")"|The right delimiter just after the environment name.|
Additionally the following segment specific parameters can be used to customize
it: `POWERLEVEL9K_PYTHON_ICON`, `POWERLEVEL9K_ANACONDA_BACKGROUND`, and
`POWERLEVEL9K_ANACONDA_FOREGROUND`.
##### aws
If you would like to display the [current AWS
profile](http://docs.aws.amazon.com/cli/latest/userguide/installing.html), add
the `aws` segment to one of the prompts, and define `AWS_DEFAULT_PROFILE` in
your `~/.zshrc`:
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`AWS_DEFAULT_PROFILE`|None|Your AWS profile name|
##### background_jobs
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE`|`true`|If there is more than one background job, this segment will show the number of jobs. Set this to `false` to turn this feature off.|
##### battery
This segment will display your current battery status (fails gracefully on
systems without a battery). It is supported on both OSX and Linux (note that it
requires `acpi` on Linux).
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_BATTERY_CHARGING`|`"yellow"`|Color to indicate a charging battery.|
|`POWERLEVEL9K_BATTERY_CHARGED`|`"green"`|Color to indicate a charged battery.|
|`POWERLEVEL9K_BATTERY_DISCONNECTED`|`$DEFAULT_COLOR`|Color to indicate absence of battery.|
|`POWERLEVEL9K_BATTERY_LOW_THRESHOLD`|`10`|Threshold to consider battery level critical.|
|`POWERLEVEL9K_BATTERY_LOW_COLOR`|`"red"`|Color to indicate critically low charge level.|
|`POWERLEVEL9K_BATTERY_VERBOSE`|`true`|Display time remaining next to battery level.|
Note that you can [modify the `_FOREGROUND`
color](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt#segment-color-customization)
without affecting the icon color.
##### command_execution_time
Display the time the previous command took to execute if the time is above
`POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD`. The time is formatted to be
"human readable", and so scales the units based on the length of execution time.
If you want more precision, just set the
`POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION` field.
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD`|3|Threshold above which to print this segment. Can be set to `0` to always print.|
|`POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION`|2|Number of digits to use in the fractional part of the time value.|
##### custom_command
The `custom_...` segment allows you to turn the output of a custom command into
a prompt segment. As an example, if you wanted to create a custom segment to
display your WiFi signal strength, you might define a custom segment called
`custom_wifi_signal` like this:
```zsh
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal)
POWERLEVEL9K_CUSTOM_WIFI_SIGNAL="echo signal: \$(nmcli device wifi | grep yes | awk '{print \$8}')"
POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_BACKGROUND="blue"
POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_FOREGROUND="yellow"
```
If you prefer, you can also define the function in your `.zshrc` rather than
putting it in-line with the variable export, as shown above. Just don't forget
to invoke your function from your segment! Example code that achieves the same
result as the above:
```zsh
zsh_wifi_signal(){
local signal=$(nmcli device wifi | grep yes | awk '{print $8}')
local color='%F{yellow}'
[[ $signal -gt 75 ]] && color='%F{green}'
[[ $signal -lt 50 ]] && color='%F{red}'
echo -n "%{$color%}\uf230 $signal%{%f%}" # \uf230 is
}
POWERLEVEL9K_CUSTOM_WIFI_SIGNAL="zsh_wifi_signal"
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal)
```
The command, above, gives you the wireless signal segment shown below:
![signal](http://i.imgur.com/hviMATC.png)
You can define as many custom segments as you wish. If you think you have
a segment that others would find useful, please consider upstreaming it to the
main theme distribution so that everyone can use it!
##### context
The `context` segment (user@host string) is conditional. By default, it will
only print if you are not your 'normal' user (including if you are root), or if
you are SSH'd to a remote host.
To use this feature, make sure the `context` segment is enabled in your prompt
elements (it is by default), and define a `DEFAULT_USER` in your `~/.zshrc`.
You can customize the `context` segment. For example, you can make it to print the
full hostname by setting
```
POWERLEVEL9K_CONTEXT_TEMPLATE="%n@`hostname -f`"
```
You can set the `POWERLEVEL9K_CONTEXT_HOST_DEPTH` variable to change how the
hostname is displayed. See (ZSH Manual)[http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Login-information]
for details. The default is set to %m which will show the hostname up to the first ‘.’
You can set it to %{N}m where N is an integer to show that many segments of system
hostname. Setting N to a negative integer will show that many segments from the
end of the hostname.
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`DEFAULT_USER`|None|Username to consider a "default context" (you can also set `$USER`).|
|`POWERLEVEL9K_ALWAYS_SHOW_CONTEXT`|false|Always show this segment, including $USER and hostname.|
|`POWERLEVEL9K_ALWAYS_SHOW_USER`|false|Always show the username, but conditionalize the hostname.|
|`POWERLEVEL9K_CONTEXT_TEMPLATE`|%n@%m|Default context prompt (username@machine). Refer to the [ZSH Documentation](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) for all possible expansions, including deeper host depths.|
##### dir
The `dir` segment shows the current working directory. When using the "Awesome
Powerline" fonts, there are additional glyphs, as well:
| `Compatible` | `Powerline` | `Awesome Powerline` | Situation
|------------|-----------|-------------------|----------------------------
| None | None | ![](https://cloud.githubusercontent.com/assets/1544760/12183451/40ec4016-b58f-11e5-9b9e-74e2b2f0b8b3.png) | At the root of your home folder |
| None | None | ![](https://cloud.githubusercontent.com/assets/1544760/12369315/8a5d762c-bbf5-11e5-8a20-ca1179f48d6c.png) | Within a subfolder of your home directory |
| None | None | ![](https://cloud.githubusercontent.com/assets/1544760/12183452/40f79286-b58f-11e5-9b8c-ed1343a07b08.png) | Outside of your home folder |
To turn off these icons you could set these variables to an empty string.
```zsh
POWERLEVEL9K_HOME_ICON=''
POWERLEVEL9K_HOME_SUB_ICON=''
POWERLEVEL9K_FOLDER_ICON=''
```
You can limit the output to a certain length by truncating long paths.
Customizations available are:
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_SHORTEN_DIR_LENGTH`|`2`|If your shorten strategy, below, is entire directories, this field determines how many directories to leave at the end. If your shorten strategy is by character count, this field determines how many characters to allow per directory string.|
|`POWERLEVEL9K_SHORTEN_STRATEGY`|None|How the directory strings should be truncated. See the table below for more informations.|
|`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 |
|---------------|-------------|
|Default|Truncate whole directories from left. How many is defined by `POWERLEVEL9K_SHORTEN_DIR_LENGTH`|
|`truncate_middle`|Truncates the middle part of a folder. E.g. you are in a folder named "~/MySuperProjects/AwesomeFiles/BoringOffice", then it will truncated to "~/MyS..cts/Awe..les/BoringOffice", if `POWERLEVEL9K_SHORTEN_DIR_LENGTH=3` is also set (controls the amount of characters to be left).|
|`truncate_from_right`|Just leaves the beginning of a folder name untouched. E.g. your folders will be truncated like so: "/ro../Pr../office". How many characters will be untouched is controlled by `POWERLEVEL9K_SHORTEN_DIR_LENGTH`.|
|`truncate_with_package_name`|Search for a `package.json` or `composer.json` and prints the `name` field to abbreviate the directory path. The precedence and/or files could be set by `POWERLEVEL9K_DIR_PACKAGE_FILES=(package.json composer.json)`. If you have [jq](https://stedolan.github.io/jq/) installed, it will dramatically improve the speed of this strategy.|
|`truncate_with_folder_marker`|Search for a file that is specified by `POWERLEVEL9K_SHORTEN_FOLDER_MARKER` and truncate everything before that (if found, otherwise stop on $HOME and ROOT).|
For example, if you wanted the truncation behavior of the `fish` shell, which
truncates `/usr/share/plasma` to `/u/s/plasma`, you would use the following:
```zsh
POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
POWERLEVEL9K_SHORTEN_DELIMITER=""
POWERLEVEL9K_SHORTEN_STRATEGY="truncate_from_right"
```
In each case you have to specify the length you want to shorten the directory
to. So in some cases `POWERLEVEL9K_SHORTEN_DIR_LENGTH` means characters, in
others whole directories.
The `truncate_with_package_name` strategy gives your directory path relative to the root of your project. For example, if you have a project inside `$HOME/projects/my-project` with a `package.json` that looks like:
```json
{
"name": "my-cool-project"
}
```
the path shown would be `my-cool-project`. If you navigate to `$HOME/projects/my-project/src`, then the path shown would be `my-cool-project/src`. Please note that this currently looks for `.git` directory to determine the root of the project.
If you want to customize the directory separator, you could set:
```zsh
# Double quotes are important here!
POWERLEVEL9K_DIR_PATH_SEPARATOR="%F{red} $(print_icon 'LEFT_SUBSEGMENT_SEPARATOR') %F{black}"
```
To omit the first character (usually a slash that gets replaced if you set `POWERLEVEL9K_DIR_PATH_SEPARATOR`),
you could set `POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true`.
You can also customize the leading tilde character when you are in `$HOME` using:
```zsh
# Double quotes are important here!
POWERLEVEL9K_HOME_FOLDER_ABBREVIATION="%F{red} $(print_icon 'HOME_ICON') %F{black}"
```
##### disk_usage
The `disk_usage` segment will show the usage level of the partition that your current working directory resides in. It can be configured with the following variables.
| Variable | Default Value | Description |
|----------|---------------|-------------|
|POWERLEVEL9K_DISK_USAGE_ONLY_WARNING|false|Hide the segment except when usage levels have hit warning or critical levels.|
|POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL|90|The usage level that triggers a warning state.|
|POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL|95|The usage level that triggers a critical state.|
##### ip
This segment tries to examine all currently used network interfaces and prints
the first address it finds. In the case that this is not the right NIC, you can
specify the correct network interface by setting:
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_IP_INTERFACE`|None|The NIC for which you wish to display the IP address. Example: `eth0`.|
##### public_ip
This segment will display your public IP address. There are several methods of obtaining this
information and by default it will try all of them starting with the most efficient. You can
also specify which method you would like it to use. The methods available are dig using opendns,
curl, or wget. The host used for wget and curl is http://ident.me by default but can be set to
another host if you prefer.
The public_ip segment will attempt to update your public IP address every 5 minutes by default(also
configurable by the user). If you lose connection your cached IP address will be displayed until
your timeout expires at which point every time your prompt is generated a new attempt will be made.
Until an IP is successfully pulled the value of $POWERLEVEL9K_PUBLIC_IP_NONE will be displayed for
this segment. If this value is empty(the default)and $POWERLEVEL9K_PUBLIC_IP_FILE is empty the
segment will not be displayed.
| 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_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_METHODS`|(dig curl wget)| These methods in that order are used to refresh your IP.|
|`POWERLEVEL9K_PUBLIC_IP_NONE`|None|The string displayed when an IP was not obtained|
##### rbenv
This segment shows the version of Ruby being used when using `rbenv` to change your current Ruby stack.
It figures out the version being used by taking the output of the `rbenv version-name` command.
* If `rbenv` is not in $PATH, nothing will be shown.
* If the current Ruby version is the same as the global Ruby version, nothing will be shown.
##### rspec_stats
See [Unit Test Ratios](#unit-test-ratios), below.
##### status
This segment shows the return code of the last command.
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_STATUS_VERBOSE`|`true`|Set to false if you wish to not show the error code when the last command returned an error and optionally hide this segment when the last command completed successfully by setting `POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE` to false.|
|`POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE`|`false`|Set to true if you wish to show this segment when the last command completed successfully in non-verbose mode.|
##### ram
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_RAM_ELEMENTS`|Both|Specify `ram_free` or `swap_used` to only show one or the other rather than both.|
##### symfony2_tests
See [Unit Test Ratios](#unit-test-ratios), below.
##### time
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_TIME_FORMAT`|`'H:M:S'`|ZSH time format to use in this segment.|
As an example, if you wanted a reversed time format, you would use this:
```zsh
# Reversed time format
POWERLEVEL9K_TIME_FORMAT='%D{%S:%M:%H}'
```
If you are using an "Awesome Powerline Font", you can add a time symbol to this
segment, as well:
```zsh
# Output time, date, and a symbol from the "Awesome Powerline Font" set
POWERLEVEL9K_TIME_FORMAT="%D{%H:%M:%S \uE868 %d.%m.%y}"
```
##### vcs
By default, the `vcs` segment will provide quite a bit of information. Further
customization is provided via:
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_HIDE_BRANCH_ICON`|`false`|Set to `true` to hide the branch icon from the segment.|
|`POWERLEVEL9K_SHOW_CHANGESET`|`false`|Set to `true` to display the hash / changeset in the segment.|
|`POWERLEVEL9K_CHANGESET_HASH_LENGTH`|`12`|How many characters of the hash / changeset to display in the segment.|
|`POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY`|`true`|Set to `false` to not reflect submodule status in the top-level repository prompt.|
|`POWERLEVEL9K_VCS_HIDE_TAGS`|`false`|Set to `true` to stop tags being displayed in the segment.|
##### vcs symbols
The `vcs` segment uses various symbols to tell you the state of your repository.
These symbols depend on your installed font and selected `POWERLEVEL9K_MODE`
from the [Installation](#Installation) section above.
| `Compatible` | `Powerline` | `Awesome Powerline` | Explanation
|--------------|---------------------|-------------------|--------------------------
| `↑4` | `↑4` | ![icon_outgoing](https://cloud.githubusercontent.com/assets/1544760/7976089/b5904d6e-0a76-11e5-8147-5e873ac52d79.gif)4 | Number of commits your repository is ahead of your remote branch
| `↓5` | `↓5` | ![icon_incoming](https://cloud.githubusercontent.com/assets/1544760/7976091/b5909c9c-0a76-11e5-9cad-9bf0a28a897c.gif)5 | Number of commits your repository is behind of your remote branch
| `⍟3` | `⍟3` | ![icon_stash](https://cloud.githubusercontent.com/assets/1544760/7976094/b5ae9346-0a76-11e5-8cc7-e98b81824118.gif)3 | Number of stashes, here 3.
| `●` | `●` | ![icon_unstaged](https://cloud.githubusercontent.com/assets/1544760/7976096/b5aefa98-0a76-11e5-9408-985440471215.gif) | There are unstaged changes in your working copy
| `✚` | `✚` | ![icon_staged](https://cloud.githubusercontent.com/assets/1544760/7976095/b5aecc8a-0a76-11e5-8988-221afc6e8982.gif) | There are staged changes in your working copy
| `?` | `?` | ![icon_untracked](https://cloud.githubusercontent.com/assets/1544760/7976098/b5c7a2e6-0a76-11e5-8c5b-315b595b2bc4.gif) | There are files in your working copy, that are unknown to your repository
| `→` | `→` | ![icon_remote_tracking_branch](https://cloud.githubusercontent.com/assets/1544760/7976093/b5ad2c0e-0a76-11e5-9cd3-62a077b1b0c7.gif) | The name of your branch differs from its tracking branch.
| `☿` | `☿` | ![icon_bookmark](https://cloud.githubusercontent.com/assets/1544760/7976197/546cfac6-0a78-11e5-88a6-ce3a1e0a174e.gif) | A mercurial bookmark is active.
| `@` | ![icon_branch_powerline](https://cloud.githubusercontent.com/assets/1544760/8000852/e7e8d8a0-0b5f-11e5-9834-de9b25c92284.gif) | ![](https://cloud.githubusercontent.com/assets/1544760/7976087/b58bbe3e-0a76-11e5-8d0d-7a5c1bc7f730.gif) | Branch Icon
| None | None | ![icon_commit](https://cloud.githubusercontent.com/assets/1544760/7976088/b58f4e50-0a76-11e5-9e70-86450d937030.gif)2c3705 | The current commit hash. Here "2c3705"
| 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
##### vi_mode
This segment shows ZSH's current input mode. Note that this is only useful if
you are using the [ZSH Line Editor](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html)
(VI mode). You can enable this either by `.zshrc` configuration or using a plugin, like
[Oh-My-Zsh's vi-mode plugin](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/vi-mode/vi-mode.plugin.zsh).
| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_VI_INSERT_MODE_STRING`|`"INSERT"`|String to display while in 'Insert' mode.|
|`POWERLEVEL9K_VI_COMMAND_MODE_STRING`|`"NORMAL"`|String to display while in 'Command' mode.|
#### Unit Test Ratios
The `symfony2_tests` and `rspec_stats` segments both show a ratio of "real"
classes vs test classes in your source code. This is just a very simple ratio,
and does not show your code coverage or any sophisticated stats. All this does
is count your source files and test files, and calculate the ratio between them.
Just enough to give you a quick overview about the test situation of the project
you are dealing with.
### tl; dr
Want to just get a quick start? Check out the [Show Off Your
Config](https://github.com/bhilburn/powerlevel9k/wiki/Show-Off-Your-Config)
portion of the wiki to get going.
[The Wiki also has a ton of other useful
information!](https://github.com/bhilburn/powerlevel9k/wiki)
### License
Project: MIT
Logo: CC-BY-SA. Source repository: https://github.com/bhilburn/powerlevel9k-logo

@ -1,22 +0,0 @@
# Structure
The Unit-Tests do not follow exactly the file structure of Powerlevel9k itself.
## Basic Tests
Basic Tests belong in `test/powerlevel9k.spec` if they test basic functionality of
Powerlevel9k itself. Basic functions from the `functions` directory have their
Tests in separate files under `test/functions`.
## Segment Tests
These Tests tend to be more complex in setup than the basic tests. To avoid ending
up in a huge single file, there is one file per segment in `test/segments`.
# Test-VMs
If unit tests are not sufficient (e.g. you have an issue with your prompt that
occurs only in a specific ZSH framework), then you could use our Test-VMs!
Currently there are two test VMs. `test-vm` is an Ubuntu machine with several
pre-installed ZSH frameworks. And there is `test-bsd-vm` which is a FreeBSD!
For how to run the machines see [here](test-vm/README.md).

@ -1,182 +0,0 @@
#!/usr/bin/env zsh
#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
# Taken from NeoFetch (slightly modified)
get_term() {
local term
# If function was run, stop here.
#((term_run == 1)) && return
# Workaround for macOS systems that
# don't support the block below.
case "$TERM_PROGRAM" in
"iTerm.app") term="iTerm2" ;;
"Terminal.app") term="Apple Terminal" ;;
"Hyper") term="HyperTerm" ;;
*) term="${TERM_PROGRAM/\.app}" ;;
esac
# Check $PPID for terminal emulator.
while [[ -z "$term" ]]; do
parent="$(get_ppid "$parent")"
name="$(get_process_name "$parent")"
case "${name// }" in
"${SHELL/*\/}" | *"sh" | "tmux"* | "screen" | "su"*) ;;
"login"* | *"Login"* | "init" | "(init)") term="$(tty)" ;;
"ruby" | "1" | "systemd" | "sshd"* | "python"* | "USER"*"PID"*) break ;;
"gnome-terminal-") term="gnome-terminal" ;;
*) term="${name##*/}" ;;
esac
done
# Log that the function was run.
#term_run=1
echo "${term}"
}
get_term_font() {
local term="${1}"
#((term_run != 1)) && get_term
case "$term" in
"alacritty"*)
term_font="$(awk -F ':|#' '/normal:/ {getline; print}' "${XDG_CONFIG_HOME}/alacritty/alacritty.yml")"
term_font="${term_font/*family:}"
term_font="${term_font/$'\n'*}"
term_font="${term_font/\#*}"
;;
"Apple_Terminal")
term_font="$(osascript -e 'tell application "Terminal" to font name of window frontmost')"
;;
"iTerm2")
# Unfortunately the profile name is not unique, but it seems to be the only thing
# that identifies an active profile. There is the "id of current session of current window"
# thou, but that does not match to a guid in the plist.
# So, be warned! Collisions may occur!
# See: https://groups.google.com/forum/#!topic/iterm2-discuss/0tO3xZ4Zlwg
# and: https://gitlab.com/gnachman/iterm2/issues/5586
local currentProfileName=$(osascript -e 'tell application "iTerm2" to profile name of current session of current window')
# Warning: Dynamic profiles are not taken into account here!
# https://www.iterm2.com/documentation-dynamic-profiles.html
local nonAsciiFont
# Count Guids in "New Bookmarks"; they should be unique
local profilesCount=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:" ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null | grep -c "Guid")
for idx in $(seq 0 "${profilesCount}"); do
local profileName=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Name:" ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null)
if [[ "${profileName}" == "${currentProfileName}" ]]; then
# "Normal Font"
term_font=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Normal\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist)
# Font for non-ascii characters
# Only check for a different non-ascii font, if the user checked
# the "use a different font for non-ascii text" switch.
local useDifferentFont=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Use\ Non-ASCII\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist)
if [[ "$useDifferentFont" == "true" ]]; then
local nonAsciiFont=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Non\ Ascii\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist)
if [[ "$term_font" != "$nonAsciiFont" ]]; then
term_font="$term_font (normal) / $nonAsciiFont (non-ascii)"
fi
fi
fi
done
;;
"deepin-terminal"*)
term_font="$(awk -F '=' '/font=/ {a=$2} /font_size/ {b=$2} END{print a " " b}' "${XDG_CONFIG_HOME}/deepin/deepin-terminal/config.conf")"
;;
"Hyper"*)
term_font="$(awk -F "," '/fontFamily/ {a=$1} END{print a}' "${HOME}/.hyper.js" | awk -F "'" '{a=$2} END{print a}')"
;;
"konsole"*)
# Get Process ID of current konsole window / tab
child="$(get_ppid "$$")"
konsole_instances=($(qdbus | grep 'org.kde.konsole'))
for i in "${konsole_instances[@]}"; do
konsole_sessions=($(qdbus "${i}" | grep '/Sessions/'))
for session in "${konsole_sessions[@]}"; do
if ((child == "$(qdbus "${i}" "${session}" processId)")); then
profile="$(qdbus "${i}" "${session}" environment | awk -F '=' '/KONSOLE_PROFILE_NAME/ {print $2}')"
break
fi
done
[[ "$profile" ]] && break
done
# We could have two profile files for the same profile name, take first match
profile_filename="$(grep -l "Name=${profile}" "${HOME}"/.local/share/konsole/*.profile)"
profile_filename="${profile_filename/$'\n'*}"
[[ "$profile_filename" ]] && term_font="$(awk -F '=|,' '/Font=/ {print $2 " " $3}' "$profile_filename")"
;;
"mintty")
term_font="$(awk -F '=' '!/^($|#)/ && /Font/ {printf $2; exit}' "${HOME}/.minttyrc")"
;;
"pantheon"*)
term_font="$(gsettings get org.pantheon.terminal.settings font)"
[[ -z "${term_font//\'}" ]] && term_font="$(gsettings get org.gnome.desktop.interface monospace-font-name)"
term_font="$(trim_quotes "$term_font")"
;;
"sakura"*)
term_font="$(awk -F '=' '/^font=/ {a=$2} END{print a}' "${XDG_CONFIG_HOME}/sakura/sakura.conf")"
;;
"terminology")
term_font="$(strings "${XDG_CONFIG_HOME}/terminology/config/standard/base.cfg" | awk '/^font\.name$/{print a}{a=$0}')"
term_font="${term_font/.pcf}"
term_font="${term_font/:*}"
;;
"termite")
[[ -f "${XDG_CONFIG_HOME}/termite/config" ]] && termite_config="${XDG_CONFIG_HOME}/termite/config"
term_font="$(awk -F '= ' '/\[options\]/ {opt=1} /^font/ {if(opt==1) a=$2; opt=0} END{print a}' "/etc/xdg/termite/config" "$termite_config")"
;;
"urxvt" | "urxvtd" | "rxvt-unicode" | "xterm")
term_font="$(grep -i -F "${term/d}*font" < <(xrdb -query))"
term_font="${term_font/*font:}"
term_font="$(trim "$term_font")"
# Xresources has two different font formats, this checks which
# one is in use and formats it accordingly.
case "$term_font" in
*"xft:"*)
term_font="${term_font/xft:}"
term_font="${term_font/:*}"
;;
"-"*) term_font="$(awk -F '\\-' '{printf $3}' <<< "$term_font")" ;;
esac
;;
"xfce4-terminal")
term_font="$(awk -F '=' '/^FontName/ {a=$2} END{print a}' "${XDG_CONFIG_HOME}/xfce4/terminal/terminalrc")"
;;
esac
echo "${term_font}"
}
local currentTerminal=$(get_term)
local currentFont=$(get_term_font "${currentTerminal}")
print -P "===== Font debugging ====="
print -P "You are using %F{blue}${currentTerminal}%f with Font %F{blue}${currentFont}%f\n"
if [[ $(echo "${currentFont}" | grep -c -E "Powerline|Awesome|Nerd") -eq 0 ]]; then
print -P "%F{yellow}WARNING%f It does not seem like you use an Powerline-enabled or Awesome Terminal Font!"
print -P "Please make sure that your font settings are correct!"
else
print -P "Your font settings seem to be all right. If you still have issues,"
print -P "it is more likely to be a font issue than a Powerlevel9k related one."
fi

@ -1,86 +0,0 @@
#!/usr/bin/env zsh
#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
if [[ "$TERM_PROGRAM" != "iTerm.app" ]]; then
print "Your Terminal Emulator does not appear to be iTerm2!"
print "This debug script is intended only for iTerm2 terminals."
exit 1
fi
if [[ ! -x "/usr/libexec/PlistBuddy" ]]; then
print "To use this debug script, you need to install XCode!"
exit 2
fi
local normalFont
local type
local command
local ambiguousDoubleWidth
local minimumContrast
local useDifferentFont
# Unfortunately the profile name is not unique, but it seems to be the only
# thing that identifies an active profile. There is the "ID of current session
# of current window" though, but that does not match to a `guid` in the plist.
# So, be warned - collisions may occur!
# See: https://groups.google.com/forum/#!topic/iterm2-discuss/0tO3xZ4Zlwg
local currentProfileName=$(osascript -e 'tell application "iTerm2" to profile name of current session of current window')
# Warning: Dynamic profiles are not taken into account here!
# https://www.iterm2.com/documentation-dynamic-profiles.html
# Count `guids` in "New Bookmarks"; they should be unique
local profilesCount=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:" ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null | grep -c "Guid")
for idx in $(seq 0 "${profilesCount}"); do
local profileName=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Name:" ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null)
if [[ "${profileName}" == "${currentProfileName}" ]]; then
# "Normal Font"
normalFont=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Normal\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist)
type=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Terminal\ Type:" ~/Library/Preferences/com.googlecode.iterm2.plist)
command=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Command:" ~/Library/Preferences/com.googlecode.iterm2.plist)
ambiguousDoubleWidth=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Ambiguous\ Double\ Width:" ~/Library/Preferences/com.googlecode.iterm2.plist)
minimumContrast=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Minimum\ Contrast:" ~/Library/Preferences/com.googlecode.iterm2.plist)
# Font for non-ascii characters
# Only check for a different non-ASCII font, if the user checked
# the "use a different font for non-ascii text" switch.
useDifferentFont=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Use\ Non-ASCII\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist)
if [[ "$useDifferentFont" == "true" ]]; then
nonAsciiFont=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Non\ Ascii\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist)
if [[ "$normalFont" != "$nonAsciiFont" ]]; then
normalFont="$normalFont (normal) / $nonAsciiFont (non-ascii)"
fi
fi
break
fi
done
print -P "You use %F{blue}iTerm2%f with the following settings:"
print -P " Font: ${normalFont}"
print -P " Terminal-Type: ${type}"
print -P " Command: ${command}"
#############################
# Analyse possible problems #
#############################
local problemsFound
if [[ "${ambiguousDoubleWidth}" == "true" ]]; then
problemsFound="${problemsFound}\n * Please uncheck 'Treat ambiguous characters as double-width'."
fi
if (( minimumContrast > 0 )); then
problemsFound="${problemsFound}\n * Please set minimum contrast to zero."
fi
if [[ $(echo "${normalFont}" | grep -c -E "Powerline|Awesome|Nerd|Source Code Pro") -eq 0 ]]; then
problemsFound="${problemsFound}\n * It does not seem like you use an Powerline-enabled or Awesome Terminal Font!"
fi
#############################
# Output problems #
#############################
if [[ -n "${problemsFound}" ]]; then
print -P "\n"
print -P "%F{yellow}Possible Problems found:%f"
print -P "${problemsFound}"
else
print -P "%F{green}No Problems found%f. Yay!"
fi

@ -1,56 +0,0 @@
# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
################################################################
# Color functions
# This file holds some color-functions for
# the powerlevel9k-ZSH-theme
# https://github.com/bhilburn/powerlevel9k
################################################################
# Get numerical color codes. That way we translate ANSI codes
# into ZSH-Style color codes.
function getColorCode() {
# Check if given value is already numerical
if [[ "$1" = <-> ]]; then
# ANSI color codes distinguish between "foreground"
# and "background" colors. We don't need to do that,
# as ZSH uses a 256 color space anyway.
if [[ "$1" = <8-15> ]]; then
echo $(($1 - 8))
else
echo "$1"
fi
else
typeset -A codes
codes=(
'black' '000'
'red' '001'
'green' '002'
'yellow' '003'
'blue' '004'
'magenta' '005'
'cyan' '006'
'white' '007'
)
# Strip eventual "bg-" prefixes
1=${1#bg-}
# Strip eventual "fg-" prefixes
1=${1#fg-}
# Strip eventual "br" prefixes ("bright" colors)
1=${1#br}
echo $codes[$1]
fi
}
# Check if two colors are equal, even if one is specified as ANSI code.
function isSameColor() {
if [[ "$1" == "NONE" || "$2" == "NONE" ]]; then
return 1
fi
local color1=$(getColorCode "$1")
local color2=$(getColorCode "$2")
return $(( color1 != color2 ))
}

@ -1,342 +0,0 @@
# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
################################################################
# icons
# This file holds the icon definitions and
# icon-functions for the powerlevel9k-ZSH-theme
# https://github.com/bhilburn/powerlevel9k
################################################################
# These characters require the Powerline fonts to work properly. If you see
# boxes or bizarre characters below, your fonts are not correctly installed. If
# you do not want to install a special font, you can set `POWERLEVEL9K_MODE` to
# `compatible`. This shows all icons in regular symbols.
# Initialize the icon list according to the user's `POWERLEVEL9K_MODE`.
typeset -gAH icons
case $POWERLEVEL9K_MODE in
'flat'|'awesome-patched')
# Awesome-Patched Font required! See:
# https://github.com/gabrielelana/awesome-terminal-fonts/tree/patching-strategy/patched
# Set the right locale to protect special characters
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
icons=(
LEFT_SEGMENT_SEPARATOR $'\uE0B0' #
RIGHT_SEGMENT_SEPARATOR $'\uE0B2' #
LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace
LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #
RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #
CARRIAGE_RETURN_ICON $'\u21B5' # ↵
ROOT_ICON $'\uE801' #
RUBY_ICON $'\uE847 ' #
AWS_ICON $'\uE895' #
AWS_EB_ICON $'\U1F331 ' # 🌱
BACKGROUND_JOBS_ICON $'\uE82F ' #
TEST_ICON $'\uE891' #
TODO_ICON $'\u2611' # ☑
BATTERY_ICON $'\uE894' #
DISK_ICON $'\uE1AE ' #
OK_ICON $'\u2713' # ✓
FAIL_ICON $'\u2718' # ✘
SYMFONY_ICON 'SF'
NODE_ICON $'\u2B22' # ⬢
MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500'
MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 '
APPLE_ICON $'\uE26E' #
FREEBSD_ICON $'\U1F608 ' # 😈
ANDROID_ICON $'\uE270' #
LINUX_ICON $'\uE271' #
SUNOS_ICON $'\U1F31E ' # 🌞
HOME_ICON $'\uE12C' #
HOME_SUB_ICON $'\uE18D' #
FOLDER_ICON $'\uE818' #
NETWORK_ICON $'\uE1AD' #
LOAD_ICON $'\uE190 ' #
SWAP_ICON $'\uE87D' #
RAM_ICON $'\uE1E2 ' #
SERVER_ICON $'\uE895' #
VCS_UNTRACKED_ICON $'\uE16C' #
VCS_UNSTAGED_ICON $'\uE17C' #
VCS_STAGED_ICON $'\uE168' #
VCS_STASH_ICON $'\uE133 ' #
#VCS_INCOMING_CHANGES_ICON $'\uE1EB ' #
#VCS_INCOMING_CHANGES_ICON $'\uE80D ' #
VCS_INCOMING_CHANGES_ICON $'\uE131 ' #
#VCS_OUTGOING_CHANGES_ICON $'\uE1EC ' #
#VCS_OUTGOING_CHANGES_ICON $'\uE80E ' #
VCS_OUTGOING_CHANGES_ICON $'\uE132 ' #
VCS_TAG_ICON $'\uE817 ' #
VCS_BOOKMARK_ICON $'\uE87B' #
VCS_COMMIT_ICON $'\uE821 ' #
VCS_BRANCH_ICON $'\uE220' #
VCS_REMOTE_BRANCH_ICON $'\u2192' # →
VCS_GIT_ICON $'\uE20E ' #
VCS_GIT_GITHUB_ICON $'\uE20E ' #
VCS_GIT_BITBUCKET_ICON $'\uE20E ' #
VCS_GIT_GITLAB_ICON $'\uE20E ' #
VCS_HG_ICON $'\uE1C3 ' #
VCS_SVN_ICON '(svn) '
RUST_ICON ''
PYTHON_ICON $'\U1F40D' # 🐍
SWIFT_ICON ''
GO_ICON ''
PUBLIC_IP_ICON ''
LOCK_ICON $'\UE138' #
EXECUTION_TIME_ICON $'\UE89C' #
SSH_ICON '(ssh)'
)
;;
'awesome-fontconfig')
# fontconfig with awesome-font required! See
# https://github.com/gabrielelana/awesome-terminal-fonts
# Set the right locale to protect special characters
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
icons=(
LEFT_SEGMENT_SEPARATOR $'\uE0B0' #
RIGHT_SEGMENT_SEPARATOR $'\uE0B2' #
LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace
LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #
RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #
CARRIAGE_RETURN_ICON $'\u21B5' # ↵
ROOT_ICON $'\uF201' #
RUBY_ICON $'\uF219 ' #
AWS_ICON $'\uF270' #
AWS_EB_ICON $'\U1F331 ' # 🌱
BACKGROUND_JOBS_ICON $'\uF013 ' #
TEST_ICON $'\uF291' #
TODO_ICON $'\u2611' # ☑
BATTERY_ICON $'\U1F50B' # 🔋
DISK_ICON $'\uF0A0 ' #
OK_ICON $'\u2713' # ✓
FAIL_ICON $'\u2718' # ✘
SYMFONY_ICON 'SF'
NODE_ICON $'\u2B22' # ⬢
MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─
MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─
APPLE_ICON $'\uF179' #
FREEBSD_ICON $'\U1F608 ' # 😈
ANDROID_ICON $'\uE17B' #
LINUX_ICON $'\uF17C' #
SUNOS_ICON $'\uF185 ' #
HOME_ICON $'\uF015' #
HOME_SUB_ICON $'\uF07C' #
FOLDER_ICON $'\uF115' #
NETWORK_ICON $'\uF09E' #
LOAD_ICON $'\uF080 ' #
SWAP_ICON $'\uF0E4' #
RAM_ICON $'\uF0E4' #
SERVER_ICON $'\uF233' #
VCS_UNTRACKED_ICON $'\uF059' #
VCS_UNSTAGED_ICON $'\uF06A' #
VCS_STAGED_ICON $'\uF055' #
VCS_STASH_ICON $'\uF01C ' #
VCS_INCOMING_CHANGES_ICON $'\uF01A ' #
VCS_OUTGOING_CHANGES_ICON $'\uF01B ' #
VCS_TAG_ICON $'\uF217 ' #
VCS_BOOKMARK_ICON $'\uF27B' #
VCS_COMMIT_ICON $'\uF221 ' #
VCS_BRANCH_ICON $'\uF126' #
VCS_REMOTE_BRANCH_ICON $'\u2192' # →
VCS_GIT_ICON $'\uF1D3 ' #
VCS_GIT_GITHUB_ICON $'\uF113 ' #
VCS_GIT_BITBUCKET_ICON $'\uF171 ' #
VCS_GIT_GITLAB_ICON $'\uF296 ' #
VCS_HG_ICON $'\uF0C3 ' #
VCS_SVN_ICON '(svn) '
RUST_ICON $'\uE6A8' #
PYTHON_ICON $'\U1F40D' # 🐍
SWIFT_ICON ''
GO_ICON ''
PUBLIC_IP_ICON ''
LOCK_ICON $'\UE138' #
EXECUTION_TIME_ICON $'\uF253'
SSH_ICON '(ssh)'
)
;;
'nerdfont-complete'|'nerdfont-fontconfig')
# nerd-font patched (complete) font required! See
# https://github.com/ryanoasis/nerd-fonts
# Set the right locale to protect special characters
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
icons=(
LEFT_SEGMENT_SEPARATOR $'\uE0B0' #
RIGHT_SEGMENT_SEPARATOR $'\uE0B2' #
LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace
LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #
RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #
CARRIAGE_RETURN_ICON $'\u21B5' # ↵
ROOT_ICON $'\uE614 ' #
RUBY_ICON $'\uF219 ' #
AWS_ICON $'\uF270' #
AWS_EB_ICON $'\UF1BD ' #
BACKGROUND_JOBS_ICON $'\uF013 ' #
TEST_ICON $'\uF188' #
TODO_ICON $'\uF133' #
BATTERY_ICON $'\UF240 ' #
DISK_ICON $'\uF0A0' #
OK_ICON $'\uF00C' #
FAIL_ICON $'\uF00D' #
SYMFONY_ICON $'\uE757' #
NODE_ICON $'\uE617 ' #
MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─
MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─
APPLE_ICON $'\uF179' #
FREEBSD_ICON $'\UF30E ' #
ANDROID_ICON $'\uF17B' #
LINUX_ICON $'\uF17C' #
SUNOS_ICON $'\uF185 ' #
HOME_ICON $'\uF015' #
HOME_SUB_ICON $'\uF07C' #
FOLDER_ICON $'\uF115' #
NETWORK_ICON $'\uF1EB' #
LOAD_ICON $'\uF080 ' #
SWAP_ICON $'\uF464' #
RAM_ICON $'\uF0E4' #
SERVER_ICON $'\uF0AE' #
VCS_UNTRACKED_ICON $'\uF059' #
VCS_UNSTAGED_ICON $'\uF06A' #
VCS_STAGED_ICON $'\uF055' #
VCS_STASH_ICON $'\uF01C ' #
VCS_INCOMING_CHANGES_ICON $'\uF01A ' #
VCS_OUTGOING_CHANGES_ICON $'\uF01B ' #
VCS_TAG_ICON $'\uF02B ' #
VCS_BOOKMARK_ICON $'\uF461 ' #
VCS_COMMIT_ICON $'\uE729 ' #
VCS_BRANCH_ICON $'\uF126 ' #
VCS_REMOTE_BRANCH_ICON $'\uE728 ' #
VCS_GIT_ICON $'\uF113 ' #
VCS_GIT_GITHUB_ICON $'\uE709 ' #
VCS_GIT_BITBUCKET_ICON $'\uE703 ' #
VCS_GIT_GITLAB_ICON $'\uF296 ' #
VCS_HG_ICON $'\uF0C3 ' #
VCS_SVN_ICON $'\uE72D ' #
RUST_ICON $'\uE7A8 ' #
PYTHON_ICON $'\UE73C ' #
SWIFT_ICON $'\uE755' #
GO_ICON $'\uE626' #
PUBLIC_IP_ICON $'\UF0AC' #
LOCK_ICON $'\UF023' #
EXECUTION_TIME_ICON $'\uF252' #
SSH_ICON $'\uF489' #
)
;;
*)
# Powerline-Patched Font required!
# See https://github.com/Lokaltog/powerline-fonts
# Set the right locale to protect special characters
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
icons=(
LEFT_SEGMENT_SEPARATOR $'\uE0B0' #
RIGHT_SEGMENT_SEPARATOR $'\uE0B2' #
LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace
LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #
RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #
CARRIAGE_RETURN_ICON $'\u21B5' # ↵
ROOT_ICON $'\u26A1' # ⚡
RUBY_ICON ''
AWS_ICON 'AWS:'
AWS_EB_ICON $'\U1F331 ' # 🌱
BACKGROUND_JOBS_ICON $'\u2699' # ⚙
TEST_ICON ''
TODO_ICON $'\u2611' # ☑
BATTERY_ICON $'\U1F50B' # 🔋
DISK_ICON $'hdd '
OK_ICON $'\u2713' # ✓
FAIL_ICON $'\u2718' # ✘
SYMFONY_ICON 'SF'
NODE_ICON $'\u2B22' # ⬢
MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\u2500'
MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\u2500 '
APPLE_ICON 'OSX'
FREEBSD_ICON 'BSD'
ANDROID_ICON 'And'
LINUX_ICON 'Lx'
SUNOS_ICON 'Sun'
HOME_ICON ''
HOME_SUB_ICON ''
FOLDER_ICON ''
NETWORK_ICON 'IP'
LOAD_ICON 'L'
SWAP_ICON 'SWP'
RAM_ICON 'RAM'
SERVER_ICON ''
VCS_UNTRACKED_ICON '?'
VCS_UNSTAGED_ICON $'\u25CF' # ●
VCS_STAGED_ICON $'\u271A' # ✚
VCS_STASH_ICON $'\u235F' # ⍟
VCS_INCOMING_CHANGES_ICON $'\u2193' # ↓
VCS_OUTGOING_CHANGES_ICON $'\u2191' # ↑
VCS_TAG_ICON ''
VCS_BOOKMARK_ICON $'\u263F' # ☿
VCS_COMMIT_ICON ''
VCS_BRANCH_ICON $'\uE0A0' #
VCS_REMOTE_BRANCH_ICON $'\u2192' # →
VCS_GIT_ICON ''
VCS_GIT_GITHUB_ICON ''
VCS_GIT_BITBUCKET_ICON ''
VCS_GIT_GITLAB_ICON ''
VCS_HG_ICON ''
VCS_SVN_ICON ''
RUST_ICON ''
PYTHON_ICON ''
SWIFT_ICON 'Swift'
GO_ICON 'Go'
PUBLIC_IP_ICON ''
LOCK_ICON $'\UE0A2'
EXECUTION_TIME_ICON 'Dur'
SSH_ICON '(ssh)'
)
;;
esac
# Override the above icon settings with any user-defined variables.
case $POWERLEVEL9K_MODE in
'flat')
# Set the right locale to protect special characters
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
icons[LEFT_SEGMENT_SEPARATOR]=''
icons[RIGHT_SEGMENT_SEPARATOR]=''
icons[LEFT_SUBSEGMENT_SEPARATOR]='|'
icons[RIGHT_SUBSEGMENT_SEPARATOR]='|'
;;
'compatible')
# Set the right locale to protect special characters
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
icons[LEFT_SEGMENT_SEPARATOR]=$'\u2B80' # ⮀
icons[RIGHT_SEGMENT_SEPARATOR]=$'\u2B82' # ⮂
icons[VCS_BRANCH_ICON]='@'
;;
esac
if [[ "$POWERLEVEL9K_HIDE_BRANCH_ICON" == true ]]; then
icons[VCS_BRANCH_ICON]=''
fi
# Safety function for printing icons
# Prints the named icon, or if that icon is undefined, the string name.
function print_icon() {
local icon_name=$1
local ICON_USER_VARIABLE=POWERLEVEL9K_${icon_name}
if defined "$ICON_USER_VARIABLE"; then
echo -n "${(P)ICON_USER_VARIABLE}"
else
echo -n "${icons[$icon_name]}"
fi
}
# Get a list of configured icons
# * $1 string - If "original", then the original icons are printed,
# otherwise "print_icon" is used, which takes the users
# overrides into account.
get_icon_names() {
# Iterate over a ordered list of keys of the icons array
for key in ${(@kon)icons}; do
echo -n "POWERLEVEL9K_$key: "
if [[ "${1}" == "original" ]]; then
# print the original icons as they are defined in the array above
echo "${icons[$key]}"
else
# print the icons as they are configured by the user
echo "$(print_icon "$key")"
fi
done
}

@ -1,234 +0,0 @@
# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
################################################################
# Utility functions
# This file holds some utility-functions for
# the powerlevel9k-ZSH-theme
# https://github.com/bhilburn/powerlevel9k
################################################################
# Exits with 0 if a variable has been previously defined (even if empty)
# Takes the name of a variable that should be checked.
function defined() {
local varname="$1"
typeset -p "$varname" > /dev/null 2>&1
}
# Given the name of a variable and a default value, sets the variable
# value to the default only if it has not been defined.
#
# Typeset cannot set the value for an array, so this will only work
# for scalar values.
function set_default() {
local varname="$1"
local default_value="$2"
defined "$varname" || typeset -g "$varname"="$default_value"
}
# Converts large memory values into a human-readable unit (e.g., bytes --> GB)
# Takes two arguments:
# * $size - The number which should be prettified
# * $base - The base of the number (default Bytes)
printSizeHumanReadable() {
typeset -F 2 size
size="$1"+0.00001
local extension
extension=('B' 'K' 'M' 'G' 'T' 'P' 'E' 'Z' 'Y')
local index=1
# if the base is not Bytes
if [[ -n $2 ]]; then
for idx in "${extension[@]}"; do
if [[ "$2" == "$idx" ]]; then
break
fi
index=$(( index + 1 ))
done
fi
while (( (size / 1024) > 0.1 )); do
size=$(( size / 1024 ))
index=$(( index + 1 ))
done
echo "$size${extension[$index]}"
}
# Gets the first value out of a list of items that is not empty.
# The items are examined by a callback-function.
# Takes two arguments:
# * $list - A list of items
# * $callback - A callback function to examine if the item is
# worthy. The callback function has access to
# the inner variable $item.
function getRelevantItem() {
local -a list
local callback
# Explicitly split the elements by whitespace.
list=(${=1})
callback=$2
for item in $list; do
# The first non-empty item wins
try=$(eval "$callback")
if [[ -n "$try" ]]; then
echo "$try"
break;
fi
done
}
# OS detection
case $(uname) in
Darwin)
OS='OSX'
OS_ICON=$(print_icon 'APPLE_ICON')
;;
FreeBSD)
OS='BSD'
OS_ICON=$(print_icon 'FREEBSD_ICON')
;;
OpenBSD)
OS='BSD'
OS_ICON=$(print_icon 'FREEBSD_ICON')
;;
DragonFly)
OS='BSD'
OS_ICON=$(print_icon 'FREEBSD_ICON')
;;
Linux)
OS='Linux'
OS_ICON=$(print_icon 'LINUX_ICON')
# Check if we're running on Android
case $(uname -o 2>/dev/null) in
Android)
OS='Android'
OS_ICON=$(print_icon 'ANDROID_ICON')
;;
esac
;;
SunOS)
OS='Solaris'
OS_ICON=$(print_icon 'SUNOS_ICON')
;;
*)
OS=''
OS_ICON=''
;;
esac
# Determine the correct sed parameter.
#
# `sed` is unfortunately not consistent across OSes when it comes to flags.
SED_EXTENDED_REGEX_PARAMETER="-r"
if [[ "$OS" == 'OSX' ]]; then
local IS_BSD_SED="$(sed --version &>> /dev/null || echo "BSD sed")"
if [[ -n "$IS_BSD_SED" ]]; then
SED_EXTENDED_REGEX_PARAMETER="-E"
fi
fi
# Determine if the passed segment is used in the prompt
#
# Pass the name of the segment to this function to test for its presence in
# either the LEFT or RIGHT prompt arrays.
# * $1: The segment to be tested.
segment_in_use() {
local key=$1
if [[ -n "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[(r)$key]}" ]] || [[ -n "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[(r)$key]}" ]]; then
return 0
else
return 1
fi
}
# Print a deprecation warning if an old segment is in use.
# Takes the name of an associative array that contains the
# deprecated segments as keys, the values contain the new
# segment names.
print_deprecation_warning() {
typeset -AH raw_deprecated_segments
raw_deprecated_segments=(${(kvP@)1})
for key in ${(@k)raw_deprecated_segments}; do
if segment_in_use $key; then
# segment is deprecated
print -P "%F{yellow}Warning!%f The '$key' segment is deprecated. Use '%F{blue}${raw_deprecated_segments[$key]}%f' instead. For more informations, have a look at the CHANGELOG.md."
fi
done
}
# A helper function to determine if a segment should be
# joined or promoted to a full one.
# Takes three arguments:
# * $1: The array index of the current segment
# * $2: The array index of the last printed segment
# * $3: The array of segments of the left or right prompt
function segmentShouldBeJoined() {
local current_index=$1
local last_segment_index=$2
# Explicitly split the elements by whitespace.
local -a elements
elements=(${=3})
local current_segment=${elements[$current_index]}
local joined=false
if [[ ${current_segment[-7,-1]} == '_joined' ]]; then
joined=true
# promote segment to a full one, if the predecessing full segment
# was conditional. So this can only be the case for segments that
# are not our direct predecessor.
if (( $(($current_index - $last_segment_index)) > 1)); then
# Now we have to examine every previous segment, until we reach
# the last printed one (found by its index). This is relevant if
# all previous segments are joined. Then we want to join our
# segment as well.
local examined_index=$((current_index - 1))
while (( $examined_index > $last_segment_index )); do
local previous_segment=${elements[$examined_index]}
# If one of the examined segments is not joined, then we know
# that the current segment should not be joined, as the target
# segment is the wrong one.
if [[ ${previous_segment[-7,-1]} != '_joined' ]]; then
joined=false
break
fi
examined_index=$((examined_index - 1))
done
fi
fi
# Return 1 means error; return 0 means no error. So we have
# to invert $joined
if [[ "$joined" == "true" ]]; then
return 0
else
return 1
fi
}
# Given a directory path, truncate it according to the settings for
# `truncate_from_right`
function truncatePathFromRight() {
local delim_len=${#POWERLEVEL9K_SHORTEN_DELIMITER}
echo $1 | sed $SED_EXTENDED_REGEX_PARAMETER \
"s@(([^/]{$((POWERLEVEL9K_SHORTEN_DIR_LENGTH))})([^/]{$delim_len}))[^/]+/@\2$POWERLEVEL9K_SHORTEN_DELIMITER/@g"
}
# Search recursively in parent folders for given file.
function upsearch () {
if [[ "$PWD" == "$HOME" || "$PWD" == "/" ]]; then
echo "$PWD"
elif test -e "$1"; then
pushd .. > /dev/null
upsearch "$1"
popd > /dev/null
echo "$PWD"
else
pushd .. > /dev/null
upsearch "$1"
popd > /dev/null
fi
}

@ -1,152 +0,0 @@
# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
################################################################
# vcs
# This file holds supplemental VCS functions
# for the powerlevel9k-ZSH-theme
# https://github.com/bhilburn/powerlevel9k
################################################################
set_default POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY true
function +vi-git-untracked() {
# TODO: check git >= 1.7.2 - see function git_compare_version()
local FLAGS
FLAGS=('--porcelain')
if [[ "$POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY" == "false" ]]; then
FLAGS+='--ignore-submodules=dirty'
fi
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \
-n $(git status ${FLAGS} | grep -E '^\?\?' 2> /dev/null | tail -n1) ]]; then
hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')"
VCS_WORKDIR_HALF_DIRTY=true
else
VCS_WORKDIR_HALF_DIRTY=false
fi
}
function +vi-git-aheadbehind() {
local ahead behind branch_name
local -a gitstatus
branch_name=$(git symbolic-ref --short HEAD 2>/dev/null)
# for git prior to 1.7
# ahead=$(git rev-list origin/${branch_name}..HEAD | wc -l)
ahead=$(git rev-list "${branch_name}"@{upstream}..HEAD 2>/dev/null | wc -l)
(( ahead )) && gitstatus+=( " $(print_icon 'VCS_OUTGOING_CHANGES_ICON')${ahead// /}" )
# for git prior to 1.7
# behind=$(git rev-list HEAD..origin/${branch_name} | wc -l)
behind=$(git rev-list HEAD.."${branch_name}"@{upstream} 2>/dev/null | wc -l)
(( behind )) && gitstatus+=( " $(print_icon 'VCS_INCOMING_CHANGES_ICON')${behind// /}" )
hook_com[misc]+=${(j::)gitstatus}
}
function +vi-git-remotebranch() {
local remote branch_name
# Are we on a remote-tracking branch?
remote=${$(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)
hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${hook_com[branch]}"
# Always show the remote
#if [[ -n ${remote} ]] ; then
# Only show the remote if it differs from the local
if [[ -n ${remote} ]] && [[ "${remote#*/}" != "${branch_name}" ]] ; then
hook_com[branch]+="$(print_icon 'VCS_REMOTE_BRANCH_ICON')${remote// /}"
fi
}
set_default POWERLEVEL9K_VCS_HIDE_TAGS false
function +vi-git-tagname() {
if [[ "$POWERLEVEL9K_VCS_HIDE_TAGS" == "false" ]]; then
# If we are on a tag, append the tagname to the current branch string.
local tag
tag=$(git describe --tags --exact-match HEAD 2>/dev/null)
if [[ -n "${tag}" ]] ; then
# 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.
if [[ -z $(git symbolic-ref HEAD 2>/dev/null) ]]; then
# 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
# exists, so we have to manually retrieve it and clobber the branch
# string.
local revision
revision=$(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}"
else
# We are on both a tag and a branch; print both by appending the tag name.
hook_com[branch]+=" $(print_icon 'VCS_TAG_ICON')${tag}"
fi
fi
fi
}
# Show count of stashed changes
# Port from https://github.com/whiteinge/dotfiles/blob/5dfd08d30f7f2749cfc60bc55564c6ea239624d9/.zsh_shouse_prompt#L268
function +vi-git-stash() {
local -a stashes
if [[ -s $(git rev-parse --git-dir)/refs/stash ]] ; then
stashes=$(git stash list 2>/dev/null | wc -l)
hook_com[misc]+=" $(print_icon 'VCS_STASH_ICON')${stashes// /}"
fi
}
function +vi-hg-bookmarks() {
if [[ -n "${hgbmarks[@]}" ]]; then
hook_com[hg-bookmark-string]=" $(print_icon 'VCS_BOOKMARK_ICON')${hgbmarks[@]}"
# To signal that we want to use the sting we just generated, set the special
# variable `ret' to something other than the default zero:
ret=1
return 0
fi
}
function +vi-vcs-detect-changes() {
if [[ "${hook_com[vcs]}" == "git" ]]; then
local remote=$(git ls-remote --get-url 2> /dev/null)
if [[ "$remote" =~ "github" ]] then
vcs_visual_identifier='VCS_GIT_GITHUB_ICON'
elif [[ "$remote" =~ "bitbucket" ]] then
vcs_visual_identifier='VCS_GIT_BITBUCKET_ICON'
elif [[ "$remote" =~ "gitlab" ]] then
vcs_visual_identifier='VCS_GIT_GITLAB_ICON'
else
vcs_visual_identifier='VCS_GIT_ICON'
fi
elif [[ "${hook_com[vcs]}" == "hg" ]]; then
vcs_visual_identifier='VCS_HG_ICON'
elif [[ "${hook_com[vcs]}" == "svn" ]]; then
vcs_visual_identifier='VCS_SVN_ICON'
fi
if [[ -n "${hook_com[staged]}" ]] || [[ -n "${hook_com[unstaged]}" ]]; then
VCS_WORKDIR_DIRTY=true
else
VCS_WORKDIR_DIRTY=false
fi
}
function +vi-svn-detect-changes() {
local svn_status="$(svn status)"
if [[ -n "$(echo "$svn_status" | grep \^\?)" ]]; then
hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')"
VCS_WORKDIR_HALF_DIRTY=true
fi
if [[ -n "$(echo "$svn_status" | grep \^\M)" ]]; then
hook_com[unstaged]+=" $(print_icon 'VCS_UNSTAGED_ICON')"
VCS_WORKDIR_DIRTY=true
fi
if [[ -n "$(echo "$svn_status" | grep \^\A)" ]]; then
hook_com[staged]+=" $(print_icon 'VCS_STAGED_ICON')"
VCS_WORKDIR_DIRTY=true
fi
}

@ -1,87 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "freebsd/FreeBSD-11.0-STABLE"
# Bootstrap
config.vm.provision :shell, path: "bootstrap-zero.sh", privileged: true
config.vm.provision :shell, path: "bootstrap.sh", privileged: false
config.vm.provision :shell, path: "../test-vm-providers/plain.sh", privileged: false
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
#config.vm.network "public_network"
# The BSD base box does not define a MAC address. Whysoever.
config.vm.base_mac = "8AAB4975994A"
# There is no BASH for root on BSD. We need to set another shell.
# See https://www.freebsd.org/doc/en/articles/linux-users/shells.html
config.ssh.shell = "/bin/sh"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder "..", "/vagrant_data", type: "nfs"
config.vm.synced_folder ".", "/vagrant", type: "nfs"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
config.vm.provider "virtualbox" do |vb|
# Change name to "powerlevel9k-bsd"
vb.name = "powerlevel9k-bsd"
# Display the VirtualBox GUI when booting the machine
#vb.gui = true
# Customize the amount of memory on the VM:
vb.memory = "256"
end
# View the documentation for the provider you are using for more
# information on available options.
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# apt-get update
# apt-get install -y apache2
# SHELL
end

@ -1,13 +0,0 @@
#!/bin/sh
# Install ZSH
sudo pkg install -y zsh
sudo chsh -s `which zsh` vagrant
sudo ln -s /usr/local/bin/zsh /usr/bin/zsh
# Install git
sudo pkg install -y git
# Install mercurial
sudo pkg install -y mercurial
# Install subversion
sudo pkg install -y subversion

@ -1,9 +0,0 @@
#!/usr/bin/zsh
echo 'LANG=en_US.UTF-8' >! ~/.zshrc
echo 'source /vagrant_data/powerlevel9k.zsh-theme' >> ~/.zshrc
echo 'echo "Have a look at the ~/p9k folder for prepared test setups."' >> ~/.zshrc
# setup environment
/vagrant_data/test-vm-providers/setup-environment.sh

@ -1,44 +0,0 @@
#!/usr/bin/zsh
OLDPWD="$(pwd)"
cd $HOME
TESTFOLDER="${HOME}/p9k"
mkdir -p $TESTFOLDER
cd $TESTFOLDER
# Make a deep test folder
mkdir -p deep-folder/1/12/123/1234/12345/123456/1234567/123455678/123456789
# Make a git repo
mkdir git-repo
cd git-repo
git config --global user.email "test@powerlevel9k.theme"
git config --global user.name "Testing Tester"
git init
echo "TEST" >> testfile
git add testfile
git commit -m "Initial commit"
cd $TESTFOLDER
# Make a Mercurial repo
mkdir hg-repo
cd hg-repo
export HGUSER="Test bot <bot@example.com>"
hg init
echo "TEST" >> testfile
hg add testfile
hg ci -m "Initial commit"
cd $TESTFOLDER
# Setup a SVN folder
svnadmin create ~/.svn-repo
mkdir svn-repo
svn checkout "file://${HOME}/.svn-repo" "svn-repo"
cd svn-repo
echo "TEST" >> testfile
svn add testfile
svn commit -m "Initial commit"
cd $TESTFOLDER
cd $OLDPWD

@ -1,25 +0,0 @@
# Test-VM for powerlevel9k
In this virtual machine you will find a recent ubuntu with preinstalled ZSH, oh-my-zsh, antigen, prezto and - of course - powerlevel9k. The main use-case is to test the powerlevel9k theme.
## Installation
In order to run this virtual machine, you need [vagrant](https://www.vagrantup.com/) and [VirtualBox](http://www.virtualbox.org/).
## Running
`vagrant` is a quite easy to use command line tool to configure a virtual machine. To fire the machine up, just run `vagrant up`. At the first run, it will install a whole ubuntu. With `vagrant ssh` you can log in into the machine.
## Testing
Once you have SSH'd into the machine, you'll see a plain ZSH. To test the other frameworks, you just have to switch to one of the following users:
* `vagrant-antigen`
* `vagrant-prezto`
* `vagrant-omz`
To switch use `sudo -i -H -u <USERNAME>`. `-i` stands for "simulate initial login", `-H` sets the "$HOME" variable to the directory of the user , `-u` for the username.
All users have `vagrant` as password and are in the /etc/sudoers.
The regular `vagrant` user has a plain ZSH with the powerlevel9k theme.

@ -1,82 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "ubuntu/precise64"
# Bootstrap
config.vm.provision :shell, path: "bootstrap.sh", privileged: false
config.vm.provision :shell, path: "../test-vm-providers/plain.sh", privileged: false
config.vm.provision :shell, path: "antigen.sh"
config.vm.provision :shell, path: "prezto.sh"
config.vm.provision :shell, path: "omz.sh"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder "..", "/vagrant_data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
config.vm.provider "virtualbox" do |vb|
# Change name to "powerlevel9k"
vb.name = "powerlevel9k"
# Display the VirtualBox GUI when booting the machine
#vb.gui = true
# Customize the amount of memory on the VM:
vb.memory = "256"
end
#
# View the documentation for the provider you are using for more
# information on available options.
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# sudo apt-get update
# sudo apt-get install -y apache2
# SHELL
end

@ -1,30 +0,0 @@
#!/usr/bin/zsh
# We need to run this script in ZSH, so that switching user works!
NEW_USER=vagrant-antigen
# Create User
PASSWORD='$6$OgLg9v2Z$Db38Jr9inZG7y8BzL8kqFK23fF5jZ7FU1oiIBLFjNYR9XVX03fwQayMgA6Rm1rzLbXaf.gkZaTWhB9pv5XLq11'
useradd -p $PASSWORD -g vagrant -s $(which zsh) -m $NEW_USER
echo "$NEW_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$NEW_USER
chmod 440 /etc/sudoers.d/$NEW_USER
(
# Change User (See http://unix.stackexchange.com/questions/86778/why-cant-we-execute-a-list-of-commands-as-different-user-without-sudo)
USERNAME=$NEW_USER
#UID=$(id -u $NEW_USER)
#EUID=$(id -u $NEW_USER)
HOME=/home/$NEW_USER
echo "
source ~/antigen/antigen.zsh\n
antigen theme /vagrant_data powerlevel9k --no-local-clone\n
antigen apply
" > ~/.zshrc
# install antigen
mkdir ~/antigen
curl -qL https://raw.githubusercontent.com/zsh-users/antigen/master/antigen.zsh > ~/antigen/antigen.zsh
source ~/antigen/antigen.zsh
# setup environment
/vagrant_data/test-vm-providers/setup-environment.sh
)

@ -1,19 +0,0 @@
#!/bin/sh
#sudo apt-get update
sudo apt-get install -y curl
sudo apt-get install -y git
sudo apt-get install -y zsh
sudo chsh -s $(which zsh) vagrant
# Install mercurial
sudo apt-get install -y mercurial
# Install Subversion
sudo apt-get install -y subversion
# install golang
echo 'golang-go golang-go/dashboard boolean false' | sudo debconf-set-selections
sudo apt-get install -y golang
# Install dependencies for tests
sudo apt-get install -y jq node ruby python python-virtualenv

@ -1,33 +0,0 @@
#!/usr/bin/zsh
# We need to run this script in ZSH, so that switching user works!
NEW_USER=vagrant-omz
# Create User
PASSWORD='$6$OgLg9v2Z$Db38Jr9inZG7y8BzL8kqFK23fF5jZ7FU1oiIBLFjNYR9XVX03fwQayMgA6Rm1rzLbXaf.gkZaTWhB9pv5XLq11'
useradd -p $PASSWORD -g vagrant -s $(which zsh) -m $NEW_USER
echo "$NEW_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$NEW_USER
chmod 440 /etc/sudoers.d/$NEW_USER
(
# Change User (See http://unix.stackexchange.com/questions/86778/why-cant-we-execute-a-list-of-commands-as-different-user-without-sudo)
USERNAME=$NEW_USER
#UID=$(id -u $NEW_USER)
#EUID=$(id -u $NEW_USER)
HOME=/home/$NEW_USER
SHELL=$(which zsh)
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
mkdir -p ~/.oh-my-zsh/custom/themes
ln -s /vagrant_data ~/.oh-my-zsh/custom/themes/powerlevel9k
echo '
export ZSH=$HOME/.oh-my-zsh
ZSH_THEME="powerlevel9k/powerlevel9k"
plugins=(git rake ruby)
source $ZSH/oh-my-zsh.sh
' > $HOME/.zshrc
# setup environment
/vagrant_data/test-vm-providers/setup-environment.sh
)

@ -1,29 +0,0 @@
#!/usr/bin/zsh
# We need to run this script in ZSH, so that switching user works!
NEW_USER=vagrant-prezto
# Create User
PASSWORD='$6$OgLg9v2Z$Db38Jr9inZG7y8BzL8kqFK23fF5jZ7FU1oiIBLFjNYR9XVX03fwQayMgA6Rm1rzLbXaf.gkZaTWhB9pv5XLq11'
useradd -p $PASSWORD -g vagrant -s $(which zsh) -m $NEW_USER
echo "$NEW_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$NEW_USER
chmod 440 /etc/sudoers.d/$NEW_USER
(
# Change User (See http://unix.stackexchange.com/questions/86778/why-cant-we-execute-a-list-of-commands-as-different-user-without-sudo)
USERNAME=$NEW_USER
#UID=$(id -u $NEW_USER)
#EUID=$(id -u $NEW_USER)
HOME=/home/$NEW_USER
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done
ln -s /vagrant_data/powerlevel9k.zsh-theme ~/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup
sed -i "s/theme\ 'sorin'/theme\ 'powerlevel9k'/g" ~/.zpreztorc
# setup environment
/vagrant_data/test-vm-providers/setup-environment.sh
)

@ -1,42 +0,0 @@
#!/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() {
# Load Powerlevel9k
source functions/colors.zsh
}
function testGetColorCodeWithAnsiForegroundColor() {
assertEquals '002' "$(getColorCode 'green')"
}
function testGetColorCodeWithAnsiBackgroundColor() {
assertEquals '002' "$(getColorCode 'bg-green')"
}
function testGetColorCodeWithNumericalColor() {
assertEquals '002' "$(getColorCode '002')"
}
function testIsSameColorComparesAnsiForegroundAndNumericalColorCorrectly() {
assertTrue "isSameColor 'green' '002'"
}
function testIsSameColorComparesAnsiBackgroundAndNumericalColorCorrectly() {
assertTrue "isSameColor 'bg-green' '002'"
}
function testIsSameColorComparesNumericalBackgroundAndNumericalColorCorrectly() {
assertTrue "isSameColor '010' '2'"
}
function testIsSameColorDoesNotYieldNotEqualColorsTruthy() {
assertFalse "isSameColor 'green' '003'"
}
source shunit2/source/2.1/src/shunit2

@ -1,362 +0,0 @@
#!/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() {
# Store old value for LC_CTYPE
_OLD_LC_CTYPE="${LC_CTYPE}"
# Reset actual LC_CTYPE
unset LC_CTYPE
# Store old P9K mode
_OLD_P9K_MODE="${POWERLEVEL9K_MODE}"
}
function tearDown() {
# Restore LC_CTYPE
LC_CTYPE="${_OLD_LC_CTYPE}"
# Restore old P9K mode
POWERLEVEL9K_MODE="${_OLD_P9K_MODE}"
}
function testLcCtypeIsSetCorrectlyInDefaultMode() {
POWERLEVEL9K_MODE="default"
# Load Powerlevel9k
source functions/icons.zsh
assertEquals 'en_US.UTF-8' "${LC_CTYPE}"
}
function testLcCtypeIsSetCorrectlyInAwesomePatchedMode() {
POWERLEVEL9K_MODE="awesome-patched"
# Load Powerlevel9k
source functions/icons.zsh
assertEquals 'en_US.UTF-8' "${LC_CTYPE}"
}
function testLcCtypeIsSetCorrectlyInAwesomeFontconfigMode() {
POWERLEVEL9K_MODE="awesome-fontconfig"
# Load Powerlevel9k
source functions/icons.zsh
assertEquals 'en_US.UTF-8' "${LC_CTYPE}"
}
function testLcCtypeIsSetCorrectlyInNerdfontFontconfigMode() {
POWERLEVEL9K_MODE="nerdfont-fontconfig"
# Load Powerlevel9k
source functions/icons.zsh
assertEquals 'en_US.UTF-8' "${LC_CTYPE}"
}
function testLcCtypeIsSetCorrectlyInFlatMode() {
POWERLEVEL9K_MODE="flat"
# Load Powerlevel9k
source functions/icons.zsh
assertEquals 'en_US.UTF-8' "${LC_CTYPE}"
}
function testLcCtypeIsSetCorrectlyInCompatibleMode() {
POWERLEVEL9K_MODE="compatible"
# Load Powerlevel9k
source functions/icons.zsh
assertEquals 'en_US.UTF-8' "${LC_CTYPE}"
}
# Go through all icons defined in default mode, and
# check if all of them are defined in the other modes.
function testAllIconsAreDefinedLikeInDefaultMode() {
# Always compare against this mode
local _P9K_TEST_MODE="default"
POWERLEVEL9K_MODE="${_P9K_TEST_MODE}"
source functions/icons.zsh
# _ICONS_UNDER_TEST is an array of just the keys of $icons.
# We later check via (r) "subscript" flag that our key
# is in the values of our flat array.
typeset -ah _ICONS_UNDER_TEST
_ICONS_UNDER_TEST=(${(k)icons[@]})
# Switch to "awesome-patched" mode
POWERLEVEL9K_MODE="awesome-patched"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
# Iterate over all keys found in the _ICONS_UNDER_TEST
# array and compare it with the icons array of the
# current POWERLEVEL9K_MODE.
# Use parameter expansion, to directly check if the
# key exists in the flat current array of keys. That
# is quite complicated, but there seems no easy way
# to check the mere existance of a key in an array.
# The usual way would always return the value, so that
# would do the wrong thing as we have some (on purpose)
# empty values.
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
# Switch to "awesome-fontconfig" mode
POWERLEVEL9K_MODE="awesome-fontconfig"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
# Switch to "nerdfont-fontconfig" mode
POWERLEVEL9K_MODE="nerdfont-fontconfig"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
# Switch to "flat" mode
POWERLEVEL9K_MODE="flat"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
# Switch to "compatible" mode
POWERLEVEL9K_MODE="compatible"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
unset current_icons
unset _ICONS_UNDER_TEST
}
# Go through all icons defined in awesome-patched mode, and
# check if all of them are defined in the other modes.
function testAllIconsAreDefinedLikeInAwesomePatchedMode() {
# Always compare against this mode
local _P9K_TEST_MODE="awesome-patched"
POWERLEVEL9K_MODE="$_P9K_TEST_MODE"
source functions/icons.zsh
# _ICONS_UNDER_TEST is an array of just the keys of $icons.
# We later check via (r) "subscript" flag that our key
# is in the values of our flat array.
typeset -ah _ICONS_UNDER_TEST
_ICONS_UNDER_TEST=(${(k)icons[@]})
# Switch to "default" mode
POWERLEVEL9K_MODE="default"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
# Iterate over all keys found in the _ICONS_UNDER_TEST
# array and compare it with the icons array of the
# current POWERLEVEL9K_MODE.
# Use parameter expansion, to directly check if the
# key exists in the flat current array of keys. That
# is quite complicated, but there seems no easy way
# to check the mere existance of a key in an array.
# The usual way would always return the value, so that
# would do the wrong thing as we have some (on purpose)
# empty values.
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
# Switch to "awesome-fontconfig" mode
POWERLEVEL9K_MODE="awesome-fontconfig"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
# Switch to "nerdfont-fontconfig" mode
POWERLEVEL9K_MODE="nerdfont-fontconfig"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
# Switch to "flat" mode
POWERLEVEL9K_MODE="flat"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
# Switch to "compatible" mode
POWERLEVEL9K_MODE="compatible"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
unset current_icons
unset _ICONS_UNDER_TEST
}
# Go through all icons defined in awesome-fontconfig mode, and
# check if all of them are defined in the other modes.
function testAllIconsAreDefinedLikeInAwesomeFontconfigMode() {
# Always compare against this mode
local _P9K_TEST_MODE="awesome-fontconfig"
POWERLEVEL9K_MODE="$_P9K_TEST_MODE"
source functions/icons.zsh
# _ICONS_UNDER_TEST is an array of just the keys of $icons.
# We later check via (r) "subscript" flag that our key
# is in the values of our flat array.
typeset -ah _ICONS_UNDER_TEST
_ICONS_UNDER_TEST=(${(k)icons[@]})
# Switch to "default" mode
POWERLEVEL9K_MODE="default"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
# Iterate over all keys found in the _ICONS_UNDER_TEST
# array and compare it with the icons array of the
# current POWERLEVEL9K_MODE.
# Use parameter expansion, to directly check if the
# key exists in the flat current array of keys. That
# is quite complicated, but there seems no easy way
# to check the mere existance of a key in an array.
# The usual way would always return the value, so that
# would do the wrong thing as we have some (on purpose)
# empty values.
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
# Switch to "awesome-patched" mode
POWERLEVEL9K_MODE="awesome-patched"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
# Switch to "nerdfont-fontconfig" mode
POWERLEVEL9K_MODE="nerdfont-fontconfig"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
# Switch to "flat" mode
POWERLEVEL9K_MODE="flat"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
# Switch to "compatible" mode
POWERLEVEL9K_MODE="compatible"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
unset current_icons
unset _ICONS_UNDER_TEST
}
# Go through all icons defined in nerdfont-fontconfig mode, and
# check if all of them are defined in the other modes.
function testAllIconsAreDefinedLikeInNerdfontFontconfigMode() {
# Always compare against this mode
local _P9K_TEST_MODE="nerdfont-fontconfig"
POWERLEVEL9K_MODE="$_P9K_TEST_MODE"
source functions/icons.zsh
# _ICONS_UNDER_TEST is an array of just the keys of $icons.
# We later check via (r) "subscript" flag that our key
# is in the values of our flat array.
typeset -ah _ICONS_UNDER_TEST
_ICONS_UNDER_TEST=(${(k)icons[@]})
# Switch to "default" mode
POWERLEVEL9K_MODE="default"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
# Iterate over all keys found in the _ICONS_UNDER_TEST
# array and compare it with the icons array of the
# current POWERLEVEL9K_MODE.
# Use parameter expansion, to directly check if the
# key exists in the flat current array of keys. That
# is quite complicated, but there seems no easy way
# to check the mere existance of a key in an array.
# The usual way would always return the value, so that
# would do the wrong thing as we have some (on purpose)
# empty values.
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
# Switch to "awesome-patched" mode
POWERLEVEL9K_MODE="awesome-patched"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
# Switch to "awesome-fontconfig" mode
POWERLEVEL9K_MODE="awesome-fontconfig"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
# Switch to "flat" mode
POWERLEVEL9K_MODE="flat"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
# Switch to "compatible" mode
POWERLEVEL9K_MODE="compatible"
source functions/icons.zsh
typeset -ah current_icons
current_icons=(${(k)icons[@]})
for key in ${_ICONS_UNDER_TEST}; do
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))"
done
unset current_icons
unset _ICONS_UNDER_TEST
}
source shunit2/source/2.1/src/shunit2

@ -1,109 +0,0 @@
#!/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() {
# Load Powerlevel9k
source functions/icons.zsh
source functions/utilities.zsh
}
function testDefinedFindsDefinedVariable() {
my_var='X'
assertTrue "defined 'my_var'"
unset my_var
}
function testDefinedDoesNotFindUndefinedVariable() {
assertFalse "defined 'my_var'"
}
function testSetDefaultSetsVariable() {
set_default 'my_var' 'x'
assertEquals 'x' "$my_var"
unset my_var
}
function testPrintSizeHumanReadableWithBigNumber() {
# Interesting: Currently we can't support numbers bigger than that.
assertEquals '0.87E' "$(printSizeHumanReadable 1000000000000000000)"
}
function testPrintSizeHumanReadableWithExabytesAsBase() {
assertEquals '9.77Z' "$(printSizeHumanReadable 10000 'E')"
}
function testGetRelevantItem() {
typeset -a list
list=(a b c)
local callback='[[ "$item" == "b" ]] && echo "found"'
local result=$(getRelevantItem "$list" "$callback")
assertEquals 'found' "$result"
unset list
}
function testGetRelevantItemDoesNotReturnNotFoundItems() {
typeset -a list
list=(a b c)
local callback='[[ "$item" == "d" ]] && echo "found"'
local result=$(getRelevantItem "$list" "$callback")
assertEquals '' ''
unset list
}
function testSegmentShouldBeJoinedIfDirectPredecessingSegmentIsJoined() {
typeset -a segments
segments=(a b_joined c_joined)
# Look at the third segment
local current_index=3
local last_element_index=2
local joined
segmentShouldBeJoined $current_index $last_element_index "$segments" && joined=true || joined=false
assertTrue "$joined"
unset segments
}
function testSegmentShouldBeJoinedIfPredecessingSegmentIsJoinedTransitivley() {
typeset -a segments
segments=(a b_joined c_joined)
# Look at the third segment
local current_index=3
# The last printed segment was the first one,
# the second segmend was conditional.
local last_element_index=1
local joined
segmentShouldBeJoined $current_index $last_element_index "$segments" && joined=true || joined=false
assertTrue "$joined"
unset segments
}
function testSegmentShouldNotBeJoinedIfPredecessingSegmentIsNotJoinedButConditional() {
typeset -a segments
segments=(a b_joined c d_joined)
# Look at the fourth segment
local current_index=4
# The last printed segment was the first one,
# the second segmend was conditional.
local last_element_index=1
local joined
segmentShouldBeJoined $current_index $last_element_index "$segments" && joined=true || joined=false
assertFalse "$joined"
unset segments
}
source shunit2/source/2.1/src/shunit2

@ -1,117 +0,0 @@
#!/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
source functions/*
# Unset mode, so that user settings
# do not interfere with tests
unset POWERLEVEL9K_MODE
}
function testJoinedSegments() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir dir_joined)
cd /tmp
assertEquals "%K{blue} %F{black}/tmp %K{blue}%F{black}%F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
cd -
}
function testTransitiveJoinedSegments() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir root_indicator_joined dir_joined)
cd /tmp
assertEquals "%K{blue} %F{black}/tmp %K{blue}%F{black}%F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
cd -
}
function testJoiningWithConditionalSegment() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir background_jobs dir_joined)
cd /tmp
assertEquals "%K{blue} %F{black}/tmp %K{blue}%F{black} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
cd -
}
function testDynamicColoringOfSegmentsWork() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
POWERLEVEL9K_DIR_DEFAULT_BACKGROUND='red'
cd /tmp
assertEquals "%K{red} %F{black}/tmp %k%F{red}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_DIR_DEFAULT_BACKGROUND
cd -
}
function testDynamicColoringOfVisualIdentifiersWork() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR='green'
POWERLEVEL9K_FOLDER_ICON="icon-here"
cd /tmp
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_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR
unset POWERLEVEL9K_FOLDER_ICON
cd -
}
function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR='green'
POWERLEVEL9K_DIR_DEFAULT_FOREGROUND='red'
POWERLEVEL9K_DIR_DEFAULT_BACKGROUND='yellow'
POWERLEVEL9K_FOLDER_ICON="icon-here"
# Re-Source the icons, as the POWERLEVEL9K_MODE is directly
# evaluated there.
source functions/icons.zsh
cd /tmp
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_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR
unset POWERLEVEL9K_DIR_DEFAULT_FOREGROUND
unset POWERLEVEL9K_DIR_DEFAULT_BACKGROUND
unset POWERLEVEL9K_FOLDER_ICON
cd -
}
function testOverwritingIconsWork() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
POWERLEVEL9K_FOLDER_ICON='icon-here'
#local testFolder=$(mktemp -d -p p9k)
# Move testFolder under home folder
#mv testFolder ~
# Go into testFolder
#cd ~/$testFolder
cd /tmp
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_DIR_FOLDER_ICON
cd -
# rm -fr ~/$testFolder
}
source shunit2/source/2.1/src/shunit2

@ -1,96 +0,0 @@
#!/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 testCommandExecutionTimeIsNotShownIfTimeIsBelowThreshold() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world command_execution_time)
POWERLEVEL9K_CUSTOM_WORLD='echo world'
_P9K_COMMAND_DURATION=2
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_CUSTOM_WORLD
unset _P9K_COMMAND_DURATION
}
function testCommandExecutionTimeThresholdCouldBeChanged() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=1
_P9K_COMMAND_DURATION=2.03
assertEquals "%K{red} %F{226%}Dur%f %F{226}2.03 %k%F{red}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION
unset POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD
}
function testCommandExecutionTimeThresholdCouldBeSetToZero() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0
_P9K_COMMAND_DURATION=0.03
assertEquals "%K{red} %F{226%}Dur%f %F{226}0.03 %k%F{red}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION
unset POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD
}
function testCommandExecutionTimePrecisionCouldBeChanged() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0
POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=4
_P9K_COMMAND_DURATION=0.0001
assertEquals "%K{red} %F{226%}Dur%f %F{226}0.0001 %k%F{red}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION
unset POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION
unset POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD
}
function testCommandExecutionTimePrecisionCouldBeSetToZero() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
_P9K_COMMAND_DURATION=23.5001
assertEquals "%K{red} %F{226%}Dur%f %F{226}23 %k%F{red}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION
unset POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION
}
function testCommandExecutionTimeIsFormattedHumandReadbleForMinuteLongCommand() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
_P9K_COMMAND_DURATION=180
assertEquals "%K{red} %F{226%}Dur%f %F{226}03:00 %k%F{red}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION
}
function testCommandExecutionTimeIsFormattedHumandReadbleForHourLongCommand() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
_P9K_COMMAND_DURATION=7200
assertEquals "%K{red} %F{226%}Dur%f %F{226}02:00:00 %k%F{red}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION
}
source shunit2/source/2.1/src/shunit2

@ -1,364 +0,0 @@
#!/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
# Every test should at least use the dir segment
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
}
function tearDown() {
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
}
function testTruncateFoldersWorks() {
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders'
FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER
cd $FOLDER
assertEquals "%K{blue} %F{black}…/12345678/123456789 %k%F{blue}%f " "$(build_left_prompt)"
cd -
rm -fr /tmp/powerlevel9k-test
unset FOLDER
unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
unset POWERLEVEL9K_SHORTEN_STRATEGY
}
function testTruncateMiddleWorks() {
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle'
FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER
cd $FOLDER
assertEquals "%K{blue} %F{black}/tmp/po…st/1/12/123/1234/12…45/12…56/12…67/12…78/123456789 %k%F{blue}%f " "$(build_left_prompt)"
cd -
rm -fr /tmp/powerlevel9k-test
unset FOLDER
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_SHORTEN_STRATEGY
}
function testTruncationFromRightWorks() {
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right'
FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER
cd $FOLDER
assertEquals "%K{blue} %F{black}/tmp/po…/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{blue}%f " "$(build_left_prompt)"
cd -
rm -fr /tmp/powerlevel9k-test
unset FOLDER
unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
unset POWERLEVEL9K_SHORTEN_STRATEGY
}
function testTruncateWithFolderMarkerWorks() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker"
local BASEFOLDER=/tmp/powerlevel9k-test
local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567
mkdir -p $FOLDER
# Setup folder marker
touch $BASEFOLDER/1/12/.shorten_folder_marker
cd $FOLDER
assertEquals "%K{blue} %F{black}/…/12/123/1234/12345/123456/1234567 %k%F{blue}%f " "$(build_left_prompt)"
cd -
rm -fr $BASEFOLDER
unset BASEFOLDER
unset FOLDER
unset POWERLEVEL9K_SHORTEN_STRATEGY
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
}
function testTruncateWithFolderMarkerWithChangedFolderMarker() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker"
POWERLEVEL9K_SHORTEN_FOLDER_MARKER='.xxx'
local BASEFOLDER=/tmp/powerlevel9k-test
local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567
mkdir -p $FOLDER
# Setup folder marker
touch $BASEFOLDER/1/12/.xxx
cd $FOLDER
assertEquals "%K{blue} %F{black}/…/12/123/1234/12345/123456/1234567 %k%F{blue}%f " "$(build_left_prompt)"
cd -
rm -fr $BASEFOLDER
unset BASEFOLDER
unset FOLDER
unset POWERLEVEL9K_SHORTEN_FOLDER_MARKER
unset POWERLEVEL9K_SHORTEN_STRATEGY
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
}
function testTruncateWithPackageNameWorks() {
local p9kFolder=$(pwd)
local BASEFOLDER=/tmp/powerlevel9k-test
local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER
cd /tmp/powerlevel9k-test
echo '
{
"name": "My_Package"
}
' > package.json
# Unfortunately: The main folder must be a git repo..
git init &>/dev/null
# Go back to deeper folder
cd "${FOLDER}"
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name'
assertEquals "%K{blue} %F{black}My_Package/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{blue}%f " "$(build_left_prompt)"
# Go back
cd $p9kFolder
rm -fr $BASEFOLDER
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_SHORTEN_STRATEGY
unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
}
function testTruncateWithPackageNameIfRepoIsSymlinkedInsideDeepFolder() {
local p9kFolder=$(pwd)
local BASEFOLDER=/tmp/powerlevel9k-test
local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER
cd $FOLDER
# Unfortunately: The main folder must be a git repo..
git init &>/dev/null
echo '
{
"name": "My_Package"
}
' > package.json
# Create a subdir inside the repo
mkdir -p asdfasdf/qwerqwer
cd $BASEFOLDER
ln -s ${FOLDER} linked-repo
# Go to deep folder inside linked repo
cd linked-repo/asdfasdf/qwerqwer
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name'
assertEquals "%K{blue} %F{black}My_Package/as…/qwerqwer %k%F{blue}%f " "$(build_left_prompt)"
# Go back
cd $p9kFolder
rm -fr $BASEFOLDER
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_SHORTEN_STRATEGY
unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
}
function testTruncateWithPackageNameIfRepoIsSymlinkedInsideGitDir() {
local p9kFolder=$(pwd)
local BASEFOLDER=/tmp/powerlevel9k-test
local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER
cd $FOLDER
# Unfortunately: The main folder must be a git repo..
git init &>/dev/null
echo '
{
"name": "My_Package"
}
' > package.json
cd $BASEFOLDER
ln -s ${FOLDER} linked-repo
cd linked-repo/.git/refs/heads
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name'
assertEquals "%K{blue} %F{black}My_Package/.g…/re…/heads %k%F{blue}%f " "$(build_left_prompt)"
# Go back
cd $p9kFolder
rm -fr $BASEFOLDER
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_SHORTEN_STRATEGY
unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
}
function testHomeFolderDetectionWorks() {
POWERLEVEL9K_HOME_ICON='home-icon'
cd ~
assertEquals "%K{blue} %F{black%}home-icon%f %F{black}~ %k%F{blue}%f " "$(build_left_prompt)"
cd -
unset POWERLEVEL9K_HOME_ICON
}
function testHomeSubfolderDetectionWorks() {
POWERLEVEL9K_HOME_SUB_ICON='sub-icon'
FOLDER=~/powerlevel9k-test
mkdir $FOLDER
cd $FOLDER
assertEquals "%K{blue} %F{black%}sub-icon%f %F{black}~/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)"
cd -
rm -fr $FOLDER
unset FOLDER
unset POWERLEVEL9K_HOME_SUB_ICON
}
function testOtherFolderDetectionWorks() {
POWERLEVEL9K_FOLDER_ICON='folder-icon'
FOLDER=/tmp/powerlevel9k-test
mkdir $FOLDER
cd $FOLDER
assertEquals "%K{blue} %F{black%}folder-icon%f %F{black}/tmp/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)"
cd -
rm -fr $FOLDER
unset FOLDER
unset POWERLEVEL9K_FOLDER_ICON
}
function testChangingDirPathSeparator() {
POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
local FOLDER="/tmp/powerlevel9k-test/1/2"
mkdir -p $FOLDER
cd $FOLDER
assertEquals "%K{blue} %F{black}xXxtmpxXxpowerlevel9k-testxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)"
cd -
unset FOLDER
rm -fr /tmp/powerlevel9k-test
unset POWERLEVEL9K_DIR_PATH_SEPARATOR
}
function testOmittingFirstCharacterWorks() {
POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
POWERLEVEL9K_FOLDER_ICON='folder-icon'
cd /tmp
assertEquals "%K{blue} %F{black%}folder-icon%f %F{black}tmp %k%F{blue}%f " "$(build_left_prompt)"
cd -
unset POWERLEVEL9K_FOLDER_ICON
unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER
}
function testOmittingFirstCharacterWorksWithChangingPathSeparator() {
POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
POWERLEVEL9K_FOLDER_ICON='folder-icon'
mkdir -p /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)"
cd -
rm -fr /tmp/powerlevel9k-test
unset POWERLEVEL9K_FOLDER_ICON
unset POWERLEVEL9K_DIR_PATH_SEPARATOR
unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER
}
# This test makes it obvious that combining a truncation strategy
# that cuts off folders from the left and omitting the the first
# character does not make much sense. The truncation strategy
# comes first, prints an ellipsis and that gets then cut off by
# POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER..
# But it does more sense in combination with other truncation
# strategies.
function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndDefaultTruncation() {
POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders'
mkdir -p /tmp/powerlevel9k-test/1/2
cd /tmp/powerlevel9k-test/1/2
assertEquals "%K{blue} %F{black}xXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)"
cd -
rm -fr /tmp/powerlevel9k-test
unset POWERLEVEL9K_DIR_PATH_SEPARATOR
unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER
unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
unset POWERLEVEL9K_SHORTEN_STRATEGY
}
function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndMiddleTruncation() {
POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle'
mkdir -p /tmp/powerlevel9k-test/1/2
cd /tmp/powerlevel9k-test/1/2
assertEquals "%K{blue} %F{black}tmpxXxpo…stxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)"
cd -
rm -fr /tmp/powerlevel9k-test
unset POWERLEVEL9K_DIR_PATH_SEPARATOR
unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER
unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
unset POWERLEVEL9K_SHORTEN_STRATEGY
}
function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndRightTruncation() {
POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right'
mkdir -p /tmp/powerlevel9k-test/1/2
cd /tmp/powerlevel9k-test/1/2
assertEquals "%K{blue} %F{black}tmpxXxpo…xXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)"
cd -
rm -fr /tmp/powerlevel9k-test
unset POWERLEVEL9K_DIR_PATH_SEPARATOR
unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER
unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
unset POWERLEVEL9K_SHORTEN_STRATEGY
}
source shunit2/source/2.1/src/shunit2

@ -1,86 +0,0 @@
#!/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 mockGo() {
case "$1" in
'version')
echo 'go version go1.5.3 darwin/amd64'
;;
'env')
echo "$HOME/go"
;;
esac
}
function mockGoEmptyGopath() {
case "$1" in
'version')
echo 'go version go1.5.3 darwin/amd64'
;;
'env')
echo ""
;;
esac
}
function testGo() {
alias go=mockGo
POWERLEVEL9K_GO_ICON=""
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(go_version)
PWD="$HOME/go/src/github.com/bhilburn/powerlevel9k"
assertEquals "%K{green} %F{255%}%f %F{255}go1.5.3 %k%F{green}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_GO_ICON
unset PWD
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unalias go
}
function testGoSegmentPrintsNothingIfEmptyGopath() {
alias go=mockGoEmptyGopath
POWERLEVEL9K_CUSTOM_WORLD='echo world'
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version)
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_CUSTOM_WORLD
}
function testGoSegmentPrintsNothingIfNotInGopath() {
alias go=mockGo
POWERLEVEL9K_CUSTOM_WORLD='echo world'
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version)
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_CUSTOM_WORLD
}
function testGoSegmentPrintsNothingIfGoIsNotAvailable() {
alias go=noGo
POWERLEVEL9K_CUSTOM_WORLD='echo world'
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version)
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_CUSTOM_WORLD
unalias go
}
source shunit2/source/2.1/src/shunit2

@ -1,40 +0,0 @@
#!/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 mockRust() {
echo 'rustc 0.4.1a-alpha'
}
function testRust() {
alias rustc=mockRust
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version)
assertEquals "%K{208} %F{black}Rust 0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unalias rustc
}
function testRustPrintsNothingIfRustIsNotAvailable() {
alias rustc=noRust
POWERLEVEL9K_CUSTOM_WORLD='echo world'
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world rust_version)
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_CUSTOM_WORLD
unalias rustc
}
source shunit2/source/2.1/src/shunit2

@ -1,81 +0,0 @@
#!/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 testColorOverridingForCleanStateWorks() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan'
POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white'
FOLDER=/tmp/powerlevel9k-test/vcs-test
mkdir -p $FOLDER
cd $FOLDER
git init 1>/dev/null
assertEquals "%K{white} %F{cyan}master %k%F{white}%f " "$(build_left_prompt)"
cd -
rm -fr /tmp/powerlevel9k-test
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_VCS_CLEAN_FOREGROUND
unset POWERLEVEL9K_VCS_CLEAN_BACKGROUND
}
function testColorOverridingForModifiedStateWorks() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='red'
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='yellow'
FOLDER=/tmp/powerlevel9k-test/vcs-test
mkdir -p $FOLDER
cd $FOLDER
git init 1>/dev/null
git config user.email "test@powerlevel9k.theme"
git config user.name "Testing Tester"
touch testfile
git add testfile
git commit -m "test" 1>/dev/null
echo "test" > testfile
assertEquals "%K{yellow} %F{red}master ● %k%F{yellow}%f " "$(build_left_prompt)"
cd -
rm -fr /tmp/powerlevel9k-test
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_VCS_MODIFIED_FOREGROUND
unset POWERLEVEL9K_VCS_MODIFIED_BACKGROUND
}
function testColorOverridingForUntrackedStateWorks() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='cyan'
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='yellow'
FOLDER=/tmp/powerlevel9k-test/vcs-test
mkdir -p $FOLDER
cd $FOLDER
git init 1>/dev/null
touch testfile
assertEquals "%K{yellow} %F{cyan}master ? %k%F{yellow}%f " "$(build_left_prompt)"
cd -
rm -fr /tmp/powerlevel9k-test
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND
unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND
}
source shunit2/source/2.1/src/shunit2
Loading…
Cancel
Save