remove most things
parent
71b763b692
commit
ceae2d7422
@ -1,450 +0,0 @@
|
||||
## v0.6.6
|
||||
|
||||
- The `rbenv` segment is no longer a default segment in the LPROMPT.
|
||||
- PR #959 - Fixing issue in v0.6.5 where we changed some color codes.
|
||||
- PR #934 - Add Tests
|
||||
- PR #884 - test-in-docker: fix with newer ZSH versions
|
||||
- PR #928 - [Docs] Add etc state description in dir docs
|
||||
- PR #937 - Use SUDO_COMMAND to check for sudo
|
||||
- PR #925 - [Bugfix] Resolve #918 Transparent background
|
||||
- PR #923 - Fix font issue debugging script
|
||||
- PR #921 - Add missing colors to fix color comparison
|
||||
- PR #951 - Add fallback icon for missing linux distro icons
|
||||
- PR #956 - Fix broken link in readme
|
||||
- Fixed #936 - fallback icons for Linux distros
|
||||
- Fixed #926 - `etc` state for `dir` segment in docs
|
||||
- Fixed #852 - `sudo` detection got crazy, there. sorry, everyone.
|
||||
- Fixed #927 - more default color issues.
|
||||
|
||||
## v0.6.5
|
||||
|
||||
- Multiple PRs: General fixes to README, improved documentation.
|
||||
- Multiple PRs: Improvements to icons / glyphs.
|
||||
- PR #777: now possible to always show the Ruby env segment.
|
||||
- PR #773: Fixed issue with home abbreviation in directory segment.
|
||||
- PR #789: Now properly working around some odd ZSH status return codes.
|
||||
- PR #716: Now possible to configure the colors of the VCS segment in rebase mode.
|
||||
- PR #722: Removed dependency on `bc` for `load` segment.
|
||||
- PR #686: Fixed issue where whitespaces in path occasionally broke `dir` segment.
|
||||
- PR #685: No longer accidentally invoking user `grep` aliases.
|
||||
- PR #680: Using env variable for `PYENV` properly, now.
|
||||
- PR #676, #611: Fixes for Kubernetes segment.
|
||||
- PR #667: Supporting multiple AWS profiles.
|
||||
- PR #660: Fixing directory parsing issue with PYTHONPATH.
|
||||
- PR #663: Fixed silly issues causing ZSH warnings.
|
||||
- PR #647: Fixing `public_ip` segment for macOS.
|
||||
- PR #643: Fixing `vpn_ip` segment naming.
|
||||
- PR #636: `context` segment now grabs user with command rather than env.
|
||||
- PR #618: Fix issue where `su -` didn't change context segment.
|
||||
- PR #608: Load average selection in `load` segment.
|
||||
|
||||
### New Segment: `laravel_version`
|
||||
|
||||
Displays the current laravel version.
|
||||
|
||||
## v0.6.4
|
||||
|
||||
- `load` segment now has configurable averages.
|
||||
- Update to `dir` segment to add `dir_writable` feature.
|
||||
- `status` segment can now display POSIX signal name of exit code.
|
||||
- Added `teardown` command to turn off P9k prompt.
|
||||
- Fixes for P9k in Cygwin and 32-bit systems.
|
||||
- Better colors in virtualization segments.
|
||||
- Added 'Gopher' icon to the `go_version` segment.
|
||||
- Improved detection in `nvm`
|
||||
- Added option to support command status reading from piped command sequences.
|
||||
- Fixed issue with visual artifacts with quick consecutive commands.
|
||||
- Updated 'ananconda' segment for more uniform styling.
|
||||
- `rvm` segment can now support usernames with dashes.
|
||||
- Fixed Python icon reference in some font configurations.
|
||||
- Vi mode indicator fixed.
|
||||
- Fixes for Docker segment.
|
||||
- Added new Docker-based testing system.
|
||||
- Significant enhancements to the `battery` segment. Check out the README to
|
||||
read more!
|
||||
- New truncation strategy that truncates until the path becomes unique.
|
||||
|
||||
### New Segments: `host` and `user`
|
||||
|
||||
Provides two separate segments for `host` and `user` in case you don't wont both
|
||||
in one (per the `context` segment).
|
||||
|
||||
### New Segment: `newline`
|
||||
|
||||
Allows you to split segments across multiple lines.
|
||||
|
||||
### New Segment: `kubecontext`
|
||||
|
||||
Shows the current context of your `kubectl` configuration.
|
||||
|
||||
### New Segment: `vpn`
|
||||
|
||||
Shows current `vpn` interface.
|
||||
|
||||
## 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.
|
||||
|
||||
### Add new segments `host` and `user`
|
||||
|
||||
The user and host segments allow you to have different icons and colors for both the user and host segments
|
||||
depending on their state.
|
||||
|
||||
## 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,46 +0,0 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at bhilburn@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
@ -1,69 +0,0 @@
|
||||
# Tests
|
||||
|
||||
## Automated Tests
|
||||
|
||||
The Unit-Tests do not follow exactly the file structure of Powerlevel9k itself,
|
||||
but we try to reflect the structure as much as possible. All tests are located
|
||||
under `test/`. Segment specific tests under `test/segments/` (one file per
|
||||
segment).
|
||||
|
||||
### Installation
|
||||
|
||||
In order to execute the tests you need to install `shunit2`, which is a
|
||||
submodule. To install the submodule, you can execute
|
||||
`git submodule init && git submodule update`.
|
||||
|
||||
### Executing tests
|
||||
|
||||
The tests are shell scripts on their own. So you can execute them right away.
|
||||
To execute all tests you could just execute `./test/suite.spec`.
|
||||
|
||||
### General Test Structure
|
||||
|
||||
The tests usually have a `setUp()` function which is executed before every
|
||||
test function. Speaking of, test functions must be prefixed with `test`. In
|
||||
the tests, you can do [different Assertions](https://github.com/kward/shunit2#-asserts).
|
||||
It is always a good idea to mock the program you want to test (just have a
|
||||
look at other tests), so that the testrunner does not have to have all
|
||||
programs installed.
|
||||
|
||||
### Travis
|
||||
|
||||
We use [Travis](https://travis-ci.org/) for Continuous Integration. This
|
||||
service executes our tests after every push. For now, we need to tell travis
|
||||
where to find the tests, which is what happens in the `.travis.yml` file.
|
||||
|
||||
## Manual Testing
|
||||
|
||||
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 can use either Docker or
|
||||
or our Vagrant.
|
||||
|
||||
### Docker
|
||||
|
||||
This is the easiest to use _if_ you have Docker already installed and running.
|
||||
|
||||
The command `./test-in-docker` should make it fairly easy to get into a running
|
||||
container with the framework of your choice.
|
||||
|
||||
Examples:
|
||||
|
||||
``` zsh
|
||||
# Test Antigen with the oldest version of ZSH
|
||||
$ ./test-in-docker antigen
|
||||
```
|
||||
|
||||
``` zsh
|
||||
# Test Prezto with ZSH version 5.2
|
||||
$ ./test-in-docker --zsh 5.2 prezto
|
||||
```
|
||||
|
||||
You can get Docker at <https://www.docker.com/community-edition>.
|
||||
|
||||
**Note:** Not all frameworks work with all versions of ZSH (or the underlying OS).
|
||||
|
||||
### Vagrant
|
||||
|
||||
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,421 +0,0 @@
|
||||
#!/usr/bin/env zsh
|
||||
#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
|
||||
|
||||
source functions/colors.zsh
|
||||
source functions/icons.zsh
|
||||
source functions/utilities.zsh
|
||||
# Map our $OS to neofetch $os
|
||||
os="$OS"
|
||||
|
||||
|
||||
trim() {
|
||||
set -f
|
||||
# shellcheck disable=2048,2086
|
||||
set -- $*
|
||||
printf '%s\n' "${*//[[:space:]]/}"
|
||||
set +f
|
||||
}
|
||||
|
||||
trim_quotes() {
|
||||
trim_output="${1//\'}"
|
||||
trim_output="${trim_output//\"}"
|
||||
printf "%s" "$trim_output"
|
||||
}
|
||||
|
||||
get_ppid() {
|
||||
# Get parent process ID of PID.
|
||||
case "$os" in
|
||||
"Windows")
|
||||
ppid="$(ps -p "${1:-$PPID}" | awk '{printf $2}')"
|
||||
ppid="${ppid/PPID}"
|
||||
;;
|
||||
|
||||
"Linux")
|
||||
ppid="$(grep -i -F "PPid:" "/proc/${1:-$PPID}/status")"
|
||||
ppid="$(trim "${ppid/PPid:}")"
|
||||
;;
|
||||
|
||||
*)
|
||||
ppid="$(ps -p "${1:-$PPID}" -o ppid=)"
|
||||
;;
|
||||
esac
|
||||
|
||||
printf "%s" "$ppid"
|
||||
}
|
||||
|
||||
get_process_name() {
|
||||
# Get PID name.
|
||||
case "$os" in
|
||||
"Windows")
|
||||
name="$(ps -p "${1:-$PPID}" | awk '{printf $8}')"
|
||||
name="${name/COMMAND}"
|
||||
name="${name/*\/}"
|
||||
;;
|
||||
|
||||
"Linux")
|
||||
name="$(< "/proc/${1:-$PPID}/comm")"
|
||||
;;
|
||||
|
||||
*)
|
||||
name="$(ps -p "${1:-$PPID}" -o comm=)"
|
||||
;;
|
||||
esac
|
||||
|
||||
printf "%s" "$name"
|
||||
}
|
||||
|
||||
# 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
|
||||
|
||||
# Most likely TosWin2 on FreeMiNT - quick check
|
||||
[[ "$TERM" == "tw52" || "$TERM" == "tw100" ]] && \
|
||||
term="TosWin2"
|
||||
|
||||
[[ "$SSH_CONNECTION" ]] && \
|
||||
term="$SSH_TTY"
|
||||
|
||||
# Check $PPID for terminal emulator.
|
||||
while [[ -z "$term" ]]; do
|
||||
parent="$(get_ppid "$parent")"
|
||||
[[ -z "$parent" ]] && break
|
||||
name="$(get_process_name "$parent")"
|
||||
|
||||
case "${name// }" in
|
||||
"${SHELL/*\/}"|*"sh"|"screen"|"su"*) ;;
|
||||
|
||||
"login"*|*"Login"*|"init"|"(init)")
|
||||
term="$(tty)"
|
||||
;;
|
||||
|
||||
"ruby"|"1"|"tmux"*|"systemd"|"sshd"*|"python"*|"USER"*"PID"*|"kdeinit"*|"launchd"*)
|
||||
break
|
||||
;;
|
||||
|
||||
"gnome-terminal-") term="gnome-terminal" ;;
|
||||
"urxvtd") term="urxvt" ;;
|
||||
*"nvim") term="Neovim Terminal" ;;
|
||||
*"NeoVimServer"*) term="VimR Terminal" ;;
|
||||
*) term="${name##*/}" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Log that the function was run.
|
||||
# term_run=1
|
||||
|
||||
echo "${term}"
|
||||
}
|
||||
|
||||
get_term_font() {
|
||||
local confs term_font mateterm_config role profile xrdb child profile_filename
|
||||
local term="${1}"
|
||||
# ((term_run != 1)) && get_term
|
||||
|
||||
case "$term" in
|
||||
"alacritty"*)
|
||||
setopt nullglob
|
||||
confs=({$XDG_CONFIG_HOME,$HOME}/{alacritty,}/{.,}alacritty.ym?)
|
||||
unsetopt nullglob
|
||||
|
||||
[[ -f "${confs[1]}" ]] || return
|
||||
|
||||
term_font="$(awk -F ':|#' '/normal:/ {getline; print}' "${confs[1]}")"
|
||||
term_font="${term_font/*family:}"
|
||||
term_font="${term_font/$'\n'*}"
|
||||
term_font="${term_font/\#*}"
|
||||
;;
|
||||
|
||||
"Apple_Terminal")
|
||||
term_font="$(osascript <<END
|
||||
tell application "Terminal" to font name of window frontmost
|
||||
END
|
||||
)"
|
||||
;;
|
||||
|
||||
"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 win-
|
||||
# dow" 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 current_profile_name profiles_count profile_name diff_font
|
||||
|
||||
current_profile_name="$(osascript <<END
|
||||
tell application "iTerm2" to profile name \
|
||||
of current session of current window
|
||||
END
|
||||
)"
|
||||
|
||||
# Warning: Dynamic profiles are not taken into account here!
|
||||
# https://www.iterm2.com/documentation-dynamic-profiles.html
|
||||
font_file="${HOME}/Library/Preferences/com.googlecode.iterm2.plist"
|
||||
|
||||
# Count Guids in "New Bookmarks"; they should be unique
|
||||
profiles_count="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:'" "$font_file" 2>/dev/null | \
|
||||
grep -w -c "Guid")"
|
||||
|
||||
for ((i=0; i<profiles_count; i++)); do
|
||||
profile_name="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Name:'" "$font_file" 2>/dev/null)"
|
||||
|
||||
if [[ "$profile_name" == "$current_profile_name" ]]; then
|
||||
# "Normal Font"
|
||||
term_font="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Normal Font:'" \
|
||||
"$font_file" 2>/dev/null)"
|
||||
|
||||
# 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.
|
||||
diff_font="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Use Non-ASCII Font:'" \
|
||||
"$font_file" 2>/dev/null)"
|
||||
|
||||
if [[ "$diff_font" == "true" ]]; then
|
||||
non_ascii="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Non Ascii Font:'" \
|
||||
"$font_file" 2>/dev/null)"
|
||||
|
||||
[[ "$term_font" != "$non_ascii" ]] && \
|
||||
term_font="$term_font (normal) / $non_ascii (non-ascii)"
|
||||
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")"
|
||||
;;
|
||||
|
||||
"GNUstep_Terminal")
|
||||
term_font="$(awk -F '>|<' '/>TerminalFont</ {getline; f=$3}
|
||||
/>TerminalFontSize</ {getline; s=$3} END {print f,s}' \
|
||||
"${HOME}/GNUstep/Defaults/Terminal.plist")"
|
||||
;;
|
||||
|
||||
"Hyper"*)
|
||||
term_font="$(awk -F':|,' '/fontFamily/ {print $2; exit}' "${HOME}/.hyper.js")"
|
||||
term_font="$(trim_quotes "$term_font")"
|
||||
;;
|
||||
|
||||
"kitty"*)
|
||||
kitty_config="$(kitty --debug-config)"
|
||||
[[ "$kitty_config" != *font_family* ]] && return
|
||||
|
||||
term_font_size="${kitty_config/*font_size}"
|
||||
term_font_size="${term_font_size/$'\n'*}"
|
||||
term_font="${kitty_config/*font_family}"
|
||||
term_font="${term_font/$'\n'*} $term_font_size"
|
||||
;;
|
||||
|
||||
"konsole" | "yakuake")
|
||||
# Get Process ID of current konsole window / tab
|
||||
child="$(get_ppid "$$")"
|
||||
|
||||
declare -a konsole_instances; konsole_instances=( "${(@f)"$(qdbus | grep -F 'org.kde.konsole')"/ /}" )
|
||||
|
||||
for i in "${konsole_instances[@]}"; do
|
||||
declare -a konsole_sessions; konsole_sessions=( "${(@f)"$(qdbus "$i" | grep -F '/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")"
|
||||
;;
|
||||
|
||||
"lxterminal"*)
|
||||
term_font="$(awk -F '=' '/fontname=/ {print $2; exit}' \
|
||||
"${XDG_CONFIG_HOME}/lxterminal/lxterminal.conf")"
|
||||
;;
|
||||
|
||||
"mate-terminal")
|
||||
# To get the actual config we have to create a temporarily file with the
|
||||
# --save-config option.
|
||||
mateterm_config="/tmp/mateterm.cfg"
|
||||
|
||||
# Ensure /tmp exists and we do not overwrite anything.
|
||||
if [[ -d "/tmp" && ! -f "$mateterm_config" ]]; then
|
||||
mate-terminal --save-config="$mateterm_config"
|
||||
|
||||
role="$(xprop -id "${WINDOWID}" WM_WINDOW_ROLE)"
|
||||
role="${role##* }"
|
||||
role="${role//\"}"
|
||||
|
||||
profile="$(awk -F '=' -v r="$role" \
|
||||
'$0~r {
|
||||
getline;
|
||||
if(/Maximized/) getline;
|
||||
if(/Fullscreen/) getline;
|
||||
id=$2"]"
|
||||
} $0~id {if(id) {getline; print $2; exit}}' \
|
||||
"$mateterm_config")"
|
||||
|
||||
rm -f "$mateterm_config"
|
||||
|
||||
mate_get() {
|
||||
gsettings get org.mate.terminal.profile:/org/mate/terminal/profiles/"$1"/ "$2"
|
||||
}
|
||||
|
||||
if [[ "$(mate_get "$profile" "use-system-font")" == "true" ]]; then
|
||||
term_font="$(gsettings get org.mate.interface monospace-font-name)"
|
||||
else
|
||||
term_font="$(mate_get "$profile" "font")"
|
||||
fi
|
||||
term_font="$(trim_quotes "$term_font")"
|
||||
fi
|
||||
;;
|
||||
|
||||
"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")"
|
||||
;;
|
||||
|
||||
"qterminal")
|
||||
term_font="$(awk -F '=' '/fontFamily=/ {a=$2} /fontSize=/ {b=$2} END {print a,b}' \
|
||||
"${XDG_CONFIG_HOME}/qterminal.org/qterminal.ini")"
|
||||
;;
|
||||
|
||||
"sakura"*)
|
||||
term_font="$(awk -F '=' '/^font=/ {print $2; exit}' \
|
||||
"${XDG_CONFIG_HOME}/sakura/sakura.conf")"
|
||||
;;
|
||||
|
||||
"st")
|
||||
term_font="$(ps -o command= -p "$parent" | grep -F -- "-f")"
|
||||
|
||||
if [[ "$term_font" ]]; then
|
||||
term_font="${term_font/*-f/}"
|
||||
term_font="${term_font/ -*/}"
|
||||
|
||||
else
|
||||
# On Linux we can get the exact path to the running binary through the procfs
|
||||
# (in case `st` is launched from outside of $PATH) on other systems we just
|
||||
# have to guess and assume `st` is invoked from somewhere in the users $PATH
|
||||
[[ -L "/proc/$parent/exe" ]] && binary="/proc/$parent/exe" || binary="$(type -p st)"
|
||||
|
||||
# Grep the output of strings on the `st` binary for anything that looks vaguely
|
||||
# like a font definition. NOTE: There is a slight limitation in this approach.
|
||||
# Technically "Font Name" is a valid font. As it doesn't specify any font options
|
||||
# though it is hard to match it correctly amongst the rest of the noise.
|
||||
[[ -n "$binary" ]] && \
|
||||
term_font="$(strings "$binary" | grep -F -m 1 \
|
||||
-e "pixelsize=" \
|
||||
-e "size=" \
|
||||
-e "antialias=" \
|
||||
-e "autohint=")"
|
||||
fi
|
||||
|
||||
term_font="${term_font/xft:}"
|
||||
term_font="${term_font/:*}"
|
||||
;;
|
||||
|
||||
"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
|
||||
}
|
||||
/^\s*font/ {
|
||||
if(opt==1) a=$2;
|
||||
opt=0
|
||||
} END {print a}' "/etc/xdg/termite/config" \
|
||||
"$termite_config")"
|
||||
;;
|
||||
|
||||
"urxvt" | "urxvtd" | "rxvt-unicode" | "xterm")
|
||||
xrdb="$(xrdb -query)"
|
||||
term_font="$(grep -im 1 -e "^${term/d}"'\**\.*font' -e '^\*font' <<< "$xrdb")"
|
||||
term_font="${term_font/*"*font:"}"
|
||||
term_font="${term_font/*".font:"}"
|
||||
term_font="${term_font/*"*.font:"}"
|
||||
term_font="$(trim "$term_font")"
|
||||
|
||||
[[ -z "$term_font" && "$term" == "xterm" ]] && \
|
||||
term_font="$(grep '^XTerm.vt100.faceName' <<< "$xrdb")"
|
||||
|
||||
term_font="$(trim "${term_font/*"faceName:"}")"
|
||||
|
||||
# xft: isn't required at the beginning so we prepend it if it's missing
|
||||
[[ "${term_font:0:1}" != "-" && "${term_font:0:4}" != "xft:" ]] && \
|
||||
term_font="xft:$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/:*}"
|
||||
;;
|
||||
|
||||
"-"*)
|
||||
IFS=- read -r _ _ term_font _ <<< "$term_font"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
"xfce4-terminal")
|
||||
term_font="$(awk -F '=' '/^FontName/{a=$2}/^FontUseSystem=TRUE/{a=$0} END {print a}' \
|
||||
"${XDG_CONFIG_HOME}/xfce4/terminal/terminalrc")"
|
||||
|
||||
[[ "$term_font" == "FontUseSystem=TRUE" ]] && \
|
||||
term_font="$(gsettings get org.gnome.desktop.interface monospace-font-name)"
|
||||
|
||||
term_font="$(trim_quotes "$term_font")"
|
||||
|
||||
# Default fallback font hardcoded in terminal-preferences.c
|
||||
[[ -z "$term_font" ]] && term_font="Monospace 12"
|
||||
;;
|
||||
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,8 +0,0 @@
|
||||
ARG base
|
||||
FROM p9k:${base}
|
||||
|
||||
COPY docker/antibody/install.zsh /tmp/
|
||||
RUN zsh /tmp/install.zsh
|
||||
|
||||
COPY ./ p9k/
|
||||
COPY docker/antibody/zshrc .zshrc
|
@ -1 +0,0 @@
|
||||
curl -sL https://git.io/antibody | bash -s
|
@ -1,2 +0,0 @@
|
||||
source <(antibody init)
|
||||
antibody bundle ~/p9k/
|
@ -1,8 +0,0 @@
|
||||
ARG base
|
||||
FROM p9k:${base}
|
||||
|
||||
COPY docker/antigen/install.zsh /tmp/
|
||||
RUN zsh /tmp/install.zsh
|
||||
|
||||
COPY ./ p9k/
|
||||
COPY docker/antigen/zshrc .zshrc
|
@ -1,12 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
mkdir ~/antigen
|
||||
|
||||
curl \
|
||||
-qLsSf \
|
||||
-o ~/antigen/antigen.zsh \
|
||||
https://git.io/antigen
|
||||
|
||||
source ~/antigen/antigen.zsh
|
||||
|
||||
# EOF
|
@ -1,4 +0,0 @@
|
||||
source ~/antigen/antigen.zsh
|
||||
|
||||
antigen theme "${HOME}/p9k" powerlevel9k --no-local-clone
|
||||
antigen apply
|
@ -1,31 +0,0 @@
|
||||
FROM centos:6
|
||||
|
||||
RUN \
|
||||
yum install -y \
|
||||
curl \
|
||||
git \
|
||||
zsh \
|
||||
mercurial \
|
||||
subversion \
|
||||
golang \
|
||||
jq \
|
||||
node \
|
||||
ruby \
|
||||
python \
|
||||
python-virtualenv \
|
||||
sudo
|
||||
|
||||
RUN adduser --shell /bin/zsh --comment 'fred' --user-group fred
|
||||
|
||||
COPY docker/fred-sudoers /etc/sudoers.d/fred
|
||||
|
||||
USER fred
|
||||
WORKDIR /home/fred
|
||||
ENV LANG=en_US.UTF-8
|
||||
ENV TERM=xterm-256color
|
||||
ENV DEFAULT_USER=fred
|
||||
ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
|
||||
|
||||
RUN touch .zshrc
|
||||
|
||||
CMD ["/bin/zsh", "-l"]
|
@ -1,33 +0,0 @@
|
||||
FROM ubuntu:14.04
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
curl \
|
||||
git \
|
||||
zsh=5.0.2-3ubuntu6.2 \
|
||||
mercurial \
|
||||
subversion \
|
||||
golang \
|
||||
jq \
|
||||
node \
|
||||
ruby \
|
||||
python \
|
||||
python-virtualenv
|
||||
|
||||
RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred
|
||||
RUN locale-gen "en_US.UTF-8"
|
||||
|
||||
COPY docker/fred-sudoers /etc/sudoers.d/fred
|
||||
|
||||
USER fred
|
||||
WORKDIR /home/fred
|
||||
ENV LANG=en_US.UTF-8
|
||||
ENV TERM=xterm-256color
|
||||
ENV DEFAULT_USER=fred
|
||||
ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
|
||||
|
||||
RUN touch .zshrc
|
||||
|
||||
CMD ["/bin/zsh", "-l"]
|
@ -1,35 +0,0 @@
|
||||
FROM ubuntu:16.04
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
curl \
|
||||
git \
|
||||
zsh=5.1.1-1ubuntu2.2 \
|
||||
mercurial \
|
||||
subversion \
|
||||
golang \
|
||||
jq \
|
||||
nodejs \
|
||||
ruby \
|
||||
python \
|
||||
python-virtualenv \
|
||||
sudo \
|
||||
locales
|
||||
|
||||
RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred
|
||||
RUN locale-gen "en_US.UTF-8"
|
||||
|
||||
COPY docker/fred-sudoers /etc/sudoers.d/fred
|
||||
|
||||
USER fred
|
||||
WORKDIR /home/fred
|
||||
ENV LANG=en_US.UTF-8
|
||||
ENV TERM=xterm-256color
|
||||
ENV DEFAULT_USER=fred
|
||||
ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
|
||||
|
||||
RUN touch .zshrc
|
||||
|
||||
CMD ["/bin/zsh", "-l"]
|
@ -1,35 +0,0 @@
|
||||
FROM ubuntu:17.10
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
curl \
|
||||
git \
|
||||
zsh=5.2-5ubuntu1.2 \
|
||||
mercurial \
|
||||
subversion \
|
||||
golang \
|
||||
jq \
|
||||
nodejs \
|
||||
ruby \
|
||||
python \
|
||||
python-virtualenv \
|
||||
sudo \
|
||||
locales
|
||||
|
||||
RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred
|
||||
RUN locale-gen "en_US.UTF-8"
|
||||
|
||||
COPY docker/fred-sudoers /etc/sudoers.d/fred
|
||||
|
||||
USER fred
|
||||
WORKDIR /home/fred
|
||||
ENV LANG=en_US.UTF-8
|
||||
ENV TERM=xterm-256color
|
||||
ENV DEFAULT_USER=fred
|
||||
ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
|
||||
|
||||
RUN touch .zshrc
|
||||
|
||||
CMD ["/bin/zsh", "-l"]
|
@ -1,40 +0,0 @@
|
||||
FROM debian:stretch
|
||||
|
||||
# We switched here to debian, as there seems no ZSH 5.3 in ubuntu.
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
curl \
|
||||
git \
|
||||
zsh=5.3.1-4+b2 \
|
||||
mercurial \
|
||||
subversion \
|
||||
golang \
|
||||
jq \
|
||||
nodejs \
|
||||
ruby \
|
||||
python \
|
||||
python-virtualenv \
|
||||
sudo \
|
||||
locales
|
||||
|
||||
RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred
|
||||
# Locale generation is different in debian. We need to enable en_US
|
||||
# locale and then regenerate locales.
|
||||
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
|
||||
RUN locale-gen "en_US.UTF-8"
|
||||
|
||||
COPY docker/fred-sudoers /etc/sudoers.d/fred
|
||||
|
||||
USER fred
|
||||
WORKDIR /home/fred
|
||||
ENV LANG=en_US.UTF-8
|
||||
ENV TERM=xterm-256color
|
||||
ENV DEFAULT_USER=fred
|
||||
ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
|
||||
|
||||
RUN touch .zshrc
|
||||
|
||||
CMD ["/bin/zsh", "-l"]
|
@ -1,35 +0,0 @@
|
||||
FROM ubuntu:18.04
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
curl \
|
||||
git \
|
||||
zsh=5.4.2-3ubuntu3 \
|
||||
mercurial \
|
||||
subversion \
|
||||
golang \
|
||||
jq \
|
||||
nodejs \
|
||||
ruby \
|
||||
python \
|
||||
python-virtualenv \
|
||||
sudo \
|
||||
locales
|
||||
|
||||
RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred
|
||||
RUN locale-gen "en_US.UTF-8"
|
||||
|
||||
COPY docker/fred-sudoers /etc/sudoers.d/fred
|
||||
|
||||
USER fred
|
||||
WORKDIR /home/fred
|
||||
ENV LANG=en_US.UTF-8
|
||||
ENV TERM=xterm-256color
|
||||
ENV DEFAULT_USER=fred
|
||||
ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
|
||||
|
||||
RUN touch .zshrc
|
||||
|
||||
CMD ["/bin/zsh", "-l"]
|
@ -1,35 +0,0 @@
|
||||
FROM ubuntu:18.10
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
curl \
|
||||
git \
|
||||
zsh=5.5.1-1ubuntu1 \
|
||||
mercurial \
|
||||
subversion \
|
||||
golang \
|
||||
jq \
|
||||
nodejs \
|
||||
ruby \
|
||||
python \
|
||||
python-virtualenv \
|
||||
sudo \
|
||||
locales
|
||||
|
||||
RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred
|
||||
RUN locale-gen "en_US.UTF-8"
|
||||
|
||||
COPY docker/fred-sudoers /etc/sudoers.d/fred
|
||||
|
||||
USER fred
|
||||
WORKDIR /home/fred
|
||||
ENV LANG=en_US.UTF-8
|
||||
ENV TERM=xterm-256color
|
||||
ENV DEFAULT_USER=fred
|
||||
ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
|
||||
|
||||
RUN touch .zshrc
|
||||
|
||||
CMD ["/bin/zsh", "-l"]
|
@ -1,5 +0,0 @@
|
||||
ARG base
|
||||
FROM p9k:${base}
|
||||
|
||||
COPY ./ p9k/
|
||||
COPY docker/dotfile/zshrc .zshrc
|
@ -1 +0,0 @@
|
||||
source "${HOME}/p9k/prompt_powerlevel9k_setup"
|
@ -1,2 +0,0 @@
|
||||
Defaults:fred !requiretty
|
||||
fred ALL=(ALL) NOPASSWD: ALL
|
@ -1,8 +0,0 @@
|
||||
ARG base
|
||||
FROM p9k:${base}
|
||||
|
||||
COPY docker/omz/install.zsh /tmp/
|
||||
RUN zsh /tmp/install.zsh
|
||||
|
||||
COPY docker/omz/zshrc .zshrc
|
||||
COPY ./ p9k/
|
@ -1,4 +0,0 @@
|
||||
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
|
||||
|
||||
mkdir -p ~/.oh-my-zsh/custom/themes
|
||||
ln -nsf ~/p9k/ ~/.oh-my-zsh/custom/themes/powerlevel9k
|
@ -1,5 +0,0 @@
|
||||
export ZSH=$HOME/.oh-my-zsh
|
||||
ZSH_THEME="powerlevel9k/powerlevel9k"
|
||||
plugins=(git rake ruby)
|
||||
|
||||
source $ZSH/oh-my-zsh.sh
|
@ -1,7 +0,0 @@
|
||||
ARG base
|
||||
FROM p9k:${base}
|
||||
|
||||
COPY docker/prezto/install.zsh /tmp/
|
||||
RUN zsh /tmp/install.zsh
|
||||
|
||||
COPY ./ p9k/
|
@ -1,18 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
set -eu
|
||||
|
||||
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 -nsf "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
|
||||
done
|
||||
|
||||
ln -snf "${HOME}/p9k/powerlevel9k.zsh-theme" \
|
||||
"${HOME}/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup"
|
||||
|
||||
echo "zstyle ':prezto:module:prompt' theme 'powerlevel9k'" \
|
||||
>> "${HOME}/.zpreztorc"
|
||||
|
||||
# EOF
|
@ -1,8 +0,0 @@
|
||||
ARG base
|
||||
FROM p9k:${base}
|
||||
|
||||
COPY docker/zgen/install.zsh /tmp/
|
||||
RUN zsh /tmp/install.zsh
|
||||
|
||||
COPY ./ p9k/
|
||||
COPY docker/zgen/zshrc .zshrc
|
@ -1,5 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
git clone https://github.com/tarjoilija/zgen.git "${HOME}/.zgen"
|
||||
|
||||
# EOF
|
@ -1,10 +0,0 @@
|
||||
# load zgen
|
||||
source ~/.zgen/zgen.zsh
|
||||
|
||||
# if the init scipt doesn't exist
|
||||
if ! zgen saved; then
|
||||
zgen load ~/p9k/powerlevel9k.zsh-theme
|
||||
|
||||
# generate the init script from plugins above
|
||||
zgen save
|
||||
fi
|
@ -1,7 +0,0 @@
|
||||
ARG base
|
||||
FROM p9k:${base}
|
||||
|
||||
COPY docker/zim/install.zsh /tmp/
|
||||
RUN zsh /tmp/install.zsh
|
||||
|
||||
COPY ./ p9k/
|
@ -1,21 +0,0 @@
|
||||
#!zsh
|
||||
|
||||
git clone --recursive https://github.com/Eriner/zim.git "${ZDOTDIR:-${HOME}}/.zim"
|
||||
|
||||
setopt EXTENDED_GLOB
|
||||
for template_file ( ${ZDOTDIR:-${HOME}}/.zim/templates/* ); do
|
||||
user_file="${ZDOTDIR:-${HOME}}/.${template_file:t}"
|
||||
touch ${user_file}
|
||||
( print -rn "$(<${template_file})$(<${user_file})" >! ${user_file} ) 2>/dev/null
|
||||
done
|
||||
|
||||
source "${ZDOTDIR:-${HOME}}/.zlogin"
|
||||
|
||||
ln -nsf \
|
||||
~/p9k/ \
|
||||
~/.zim/modules/prompt/external-themes/powerlevel9k
|
||||
ln -nsf \
|
||||
~/.zim/modules/prompt/external-themes/powerlevel9k/powerlevel9k.zsh-theme \
|
||||
~/.zim/modules/prompt/functions/prompt_powerlevel9k_setup
|
||||
|
||||
sed -i "s/zprompt_theme='steeef'/zprompt_theme='powerlevel9k'/g" ~/.zimrc
|
@ -1,8 +0,0 @@
|
||||
ARG base
|
||||
FROM p9k:${base}
|
||||
|
||||
COPY docker/zplug/install.zsh /tmp/
|
||||
RUN zsh /tmp/install.zsh
|
||||
|
||||
COPY ./ p9k/
|
||||
COPY docker/zplug/zshrc .zshrc
|
@ -1,5 +0,0 @@
|
||||
#!zsh
|
||||
|
||||
curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh| zsh
|
||||
|
||||
# git clone https://github.com/zplug/zplug "${HOME}/.zplug"
|
@ -1,5 +0,0 @@
|
||||
#!zsh
|
||||
|
||||
source ~/.zplug/init.zsh
|
||||
zplug "${HOME}/p9k", use:"powerlevel9k.zsh-theme", from:local, as:theme
|
||||
zplug load --verbose
|
@ -1,8 +0,0 @@
|
||||
ARG base
|
||||
FROM p9k:${base}
|
||||
|
||||
COPY docker/zplugin/install.zsh /tmp/
|
||||
RUN zsh /tmp/install.zsh
|
||||
|
||||
COPY ./ p9k/
|
||||
COPY docker/zplugin/zshrc.plugins .zshrc.plugins
|
@ -1,12 +0,0 @@
|
||||
sh -c "$(curl -fsSL https://raw.githubusercontent.com/psprint/zplugin/master/doc/install.sh)"
|
||||
|
||||
# The 'zplugin snippet' only copies the .zsh-theme file, not everything else.
|
||||
mkdir -p ~/.zplugin/snippets
|
||||
ln -nsf \
|
||||
~/p9k/ \
|
||||
~/.zplugin/snippets/--SLASH--home--SLASH--fred--SLASH--p9k--SLASH--powerlevel9k--DOT--zsh-theme
|
||||
|
||||
{
|
||||
echo
|
||||
echo "source ~/.zshrc.plugins"
|
||||
} >> ~/.zshrc
|
@ -1,5 +0,0 @@
|
||||
#!zsh
|
||||
|
||||
zplugin load psprint zsh-navigation-tools
|
||||
zplugin load psprint---zprompts
|
||||
zplugin snippet ~/p9k/powerlevel9k.zsh-theme
|
@ -1,8 +0,0 @@
|
||||
ARG base
|
||||
FROM p9k:${base}
|
||||
|
||||
COPY docker/zpm/install.zsh /tmp/
|
||||
RUN zsh /tmp/install.zsh
|
||||
|
||||
COPY ./ p9k/
|
||||
COPY docker/zpm/zshrc .zshrc
|
@ -1,6 +0,0 @@
|
||||
# install zpm
|
||||
git clone --recursive https://github.com/zpm-zsh/zpm.git ~/.zpm
|
||||
|
||||
# Install powerlevel9k
|
||||
mkdir ~/.zpm/plugins/powerlevel9k
|
||||
ln -s ~/p9k/powerlevel9k.zsh-theme ~/.zpm/plugins/powerlevel9k/powerlevel9k.plugin.zsh
|
@ -1,3 +0,0 @@
|
||||
source ~/.zpm/zpm.zsh
|
||||
|
||||
zpm load powerlevel9k
|
@ -1,7 +0,0 @@
|
||||
ARG base
|
||||
FROM p9k:${base}
|
||||
|
||||
COPY docker/zshing/install.zsh /tmp/
|
||||
RUN zsh /tmp/install.zsh
|
||||
|
||||
COPY ./ p9k/
|
@ -1,16 +0,0 @@
|
||||
#!zsh
|
||||
|
||||
# install zshing https://github.com/zakariaGatter/zshing
|
||||
git clone https://github.com/zakariaGatter/zshing.git ~/.zshing/zshing
|
||||
|
||||
# Link P9K in zshing directory
|
||||
ln -nsf ~/p9k ~/.zshing/powerlevel9k
|
||||
|
||||
{
|
||||
echo
|
||||
echo 'ZSHING_PLUGINS=(
|
||||
"bhilburn/powerlevel9k"
|
||||
)'
|
||||
echo
|
||||
echo "source ~/.zshing/zshing/zshing.zsh"
|
||||
} >> ~/.zshrc
|
@ -1,7 +0,0 @@
|
||||
ARG base
|
||||
FROM p9k:${base}
|
||||
|
||||
COPY docker/zulu/install.zsh /tmp/
|
||||
RUN zsh /tmp/install.zsh
|
||||
|
||||
COPY ./ p9k/
|
@ -1,10 +0,0 @@
|
||||
#!zsh
|
||||
|
||||
# install zulu https://github.com/zulu-zsh/zulu
|
||||
curl -L https://git.io/zulu-install | zsh && zsh
|
||||
|
||||
{
|
||||
echo 'zulu fpath add ~/p9k'
|
||||
echo 'zulu fpath add ~/p9k/functions'
|
||||
echo 'zulu theme powerlevel9k'
|
||||
} >> ~/.zshrc
|
@ -0,0 +1 @@
|
||||
powerlevel9k.zsh-theme
|
@ -0,0 +1 @@
|
||||
prompt_powerlevel9k_setup
|
@ -1 +0,0 @@
|
||||
Subproject commit 07bb3292048a4982aad7247bdd7890f2bf532ece
|
@ -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,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
pkg install -y sudo
|
@ -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,200 +0,0 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
set -eu
|
||||
|
||||
# The default ZSH to use; it can just be the first few characters.
|
||||
# This should be the oldest version we support.
|
||||
default_version='4.'
|
||||
|
||||
setopt extended_glob glob_subst numeric_glob_sort
|
||||
setopt warn_create_global warn_nested_var 2> /dev/null
|
||||
cd "${${(%):-%x}:A:h}"
|
||||
|
||||
# TODO: Crazy Logic to munge TERM to something supported in Ubuntu 14.04
|
||||
term=screen-256color
|
||||
|
||||
# Note: If versions and frameworks looks complicated, it isn't that bad...
|
||||
# ...see Modifiers in zshexpn(1) for details.
|
||||
|
||||
# List of ZSH versions
|
||||
typeset -aU versions
|
||||
versions=( docker/base-*/Dockerfile(N.on:h:t:s/base-//) )
|
||||
typeset -r versions
|
||||
|
||||
# List of frameworks
|
||||
typeset -aU frameworks
|
||||
frameworks=( docker/*/Dockerfile(N.on:h:t) )
|
||||
for i in {$#frameworks..1}; do
|
||||
# Remove all base entries
|
||||
[[ "${frameworks[$i]}" == base-* ]] && frameworks[$i]=()
|
||||
done
|
||||
typeset -r frameworks
|
||||
|
||||
# Known Issues
|
||||
typeset -A known_issues
|
||||
known_issues["4.3.11-antigen"]="Antigen commands that need git won't work; it needs a newer version of git."
|
||||
known_issues["4.3.11-zim"]="BROKEN: Zim wants ZSH 5.2 or newer."
|
||||
known_issues["5.0.3-zim"]="DEPRECATED: Zim wants ZSH 5.2 or newer."
|
||||
known_issues["5.1.1-zim"]="DEPRECATED: Zim wants ZSH 5.2 or newer."
|
||||
known_issues["4.3.11-zulu"]="Zulu doesn't work; it needs a newer version of git."
|
||||
typeset -r known_issues
|
||||
|
||||
err()
|
||||
{
|
||||
print -P "%F{red}Error:%f $*"
|
||||
exit 2
|
||||
}
|
||||
|
||||
resolve_framework() {
|
||||
local f=$1 found
|
||||
found=${frameworks[(In:-1:)$f*]}
|
||||
if (( found <= $#frameworks )); then
|
||||
echo "${frameworks[$found]}"
|
||||
fi
|
||||
}
|
||||
|
||||
resolve_version() {
|
||||
local v=$1 found
|
||||
found=${versions[(In:-1:)$v*]}
|
||||
if (( found <= $#versions )); then
|
||||
echo "${versions[$found]}"
|
||||
fi
|
||||
}
|
||||
|
||||
check_for_known_issues() {
|
||||
local version="$1"
|
||||
local framework="$2"
|
||||
local name="${version}-${framework}"
|
||||
|
||||
if (( ${+known_issues["$name"]} )); then
|
||||
echo
|
||||
print -P "%F{red}Known Issue: %F{yellow}${known_issues["$name"]}%f"
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
cmd() {
|
||||
if (( dry_run )); then
|
||||
echo "${(@q)*}" 1>&2
|
||||
else
|
||||
"${(@)*}"
|
||||
fi
|
||||
}
|
||||
|
||||
build_and_run() {
|
||||
local version="$1"
|
||||
local framework="$2"
|
||||
local name="${version}-${framework}"
|
||||
|
||||
check_for_known_issues "$version" "$framework"
|
||||
|
||||
print -P "%F{green}Preparing containers...%f"
|
||||
|
||||
echo -n "p9k:base-${version}: "
|
||||
cmd docker build \
|
||||
--quiet \
|
||||
--tag "p9k:base-${version}" \
|
||||
--file "docker/base-${version}/Dockerfile" \
|
||||
.
|
||||
|
||||
echo -n "p9k:${version}-${framework}: "
|
||||
cmd docker build \
|
||||
--quiet \
|
||||
--build-arg="base=base-${version}" \
|
||||
--tag "p9k:${version}-${framework}" \
|
||||
--file "docker/${framework}/Dockerfile" \
|
||||
.
|
||||
|
||||
print -P "%F{green}Starting ${name} container...%f"
|
||||
cmd docker run \
|
||||
--rm \
|
||||
--interactive \
|
||||
--tty \
|
||||
--hostname="${name//./_}" \
|
||||
--env="TERM=${term}" \
|
||||
"p9k:${version}-${framework}"
|
||||
}
|
||||
|
||||
show_help() {
|
||||
local f v
|
||||
echo "Usage: ${(%):-%x} <framework>|--list"
|
||||
echo
|
||||
echo "Loads up a docker image with powershell9k configured in <framework>"
|
||||
echo
|
||||
echo " -f --frameworks Lists all available frameworks, newline separated."
|
||||
echo " -v --versions Lists all available ZSH versions, newline separated."
|
||||
echo " -z --zsh VER Uses ZSH with version VER."
|
||||
echo " -n --dry-run Just prints the docker commands that would be run."
|
||||
echo " --help You're soaking in it."
|
||||
echo
|
||||
echo "ZSH versions:"
|
||||
for v in "${(@)versions}"; do
|
||||
echo " $v"
|
||||
done
|
||||
echo
|
||||
echo "Framework containers:"
|
||||
for f in "${(@)frameworks}"; do
|
||||
echo " $f"
|
||||
done
|
||||
}
|
||||
|
||||
# No arguments
|
||||
if (( $# == 0 )); then
|
||||
show_help
|
||||
exit
|
||||
fi
|
||||
|
||||
# Parse flags and such.
|
||||
asked_for_version=$default_version
|
||||
asked_for_framework=
|
||||
dry_run=0
|
||||
while (( $# > 0 )); do
|
||||
case "$1" in
|
||||
-f | --frameworks )
|
||||
print -l "${(@)frameworks}"
|
||||
exit
|
||||
;;
|
||||
-v | --versions )
|
||||
print -l "${(@)versions}"
|
||||
exit
|
||||
;;
|
||||
-z | --zsh )
|
||||
shift
|
||||
asked_for_version=$1
|
||||
;;
|
||||
-n | --dry-run ) dry_run=1 ;;
|
||||
-h | --help )
|
||||
show_help
|
||||
exit
|
||||
;;;
|
||||
-* )
|
||||
err "Unknown option ${1}"
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
* )
|
||||
if [[ -z "$asked_for_framework" ]]; then
|
||||
asked_for_framework=$1
|
||||
else
|
||||
err "You can only specify one framework at a time; you already specified '${asked_for_framework}'"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
typeset -r asked_for_version asked_for_framework
|
||||
|
||||
typeset -r use_version="$(resolve_version "${asked_for_version}")"
|
||||
if [[ -z "$use_version" ]]; then
|
||||
err "No such ZSH version '${asked_for_version}'"
|
||||
fi
|
||||
|
||||
typeset -r use_framework="$(resolve_framework "${asked_for_framework}")"
|
||||
if [[ -z "$use_framework" ]]; then
|
||||
err "No such framework '${asked_for_framework}'"
|
||||
fi
|
||||
|
||||
build_and_run "$use_version" "$use_framework"
|
||||
|
||||
# EOF
|
@ -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,62 +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 testDynamicColoringOfSegmentsWork() {
|
||||
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(date)
|
||||
local POWERLEVEL9K_DATE_ICON="date-icon"
|
||||
local POWERLEVEL9K_DATE_BACKGROUND='red'
|
||||
|
||||
assertEquals "%K{001} %F{000}date-icon %F{000}%D{%d.%m.%y} %k%F{001}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testDynamicColoringOfVisualIdentifiersWork() {
|
||||
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(date)
|
||||
local POWERLEVEL9K_DATE_ICON="date-icon"
|
||||
local POWERLEVEL9K_DATE_VISUAL_IDENTIFIER_COLOR='green'
|
||||
|
||||
assertEquals "%K{007} %F{002}date-icon %F{000}%D{%d.%m.%y} %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() {
|
||||
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(date)
|
||||
local POWERLEVEL9K_DATE_ICON="date-icon"
|
||||
local POWERLEVEL9K_DATE_VISUAL_IDENTIFIER_COLOR='green'
|
||||
local POWERLEVEL9K_DATE_FOREGROUND='red'
|
||||
local POWERLEVEL9K_DATE_BACKGROUND='yellow'
|
||||
|
||||
assertEquals "%K{003} %F{002}date-icon %F{001}%D{%d.%m.%y} %k%F{003}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testColorOverridingOfStatefulSegment() {
|
||||
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(host)
|
||||
local POWERLEVEL9K_SSH_ICON="ssh-icon"
|
||||
local POWERLEVEL9K_HOST_REMOTE_BACKGROUND='red'
|
||||
local POWERLEVEL9K_HOST_REMOTE_FOREGROUND='green'
|
||||
# Provoke state
|
||||
local SSH_CLIENT="x"
|
||||
|
||||
assertEquals "%K{001} %F{002}ssh-icon %F{002}%m %k%F{001}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testColorOverridingOfCustomSegment() {
|
||||
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
local POWERLEVEL9K_CUSTOM_WORLD_ICON='CW'
|
||||
local POWERLEVEL9K_CUSTOM_WORLD_VISUAL_IDENTIFIER_COLOR='green'
|
||||
local POWERLEVEL9K_CUSTOM_WORLD_FOREGROUND='red'
|
||||
local POWERLEVEL9K_CUSTOM_WORLD_BACKGROUND='red'
|
||||
|
||||
assertEquals "%K{001} %F{002}CW %F{001}world %k%F{001}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,187 +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 testLeftNormalSegmentsShouldNotBeJoined() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 custom_world2 custom_world3 custom_world4_joined custom_world5 custom_world6)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD3="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD4="echo world4"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD5="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD6="echo world6"
|
||||
|
||||
assertEquals "%K{007} %F{000}world1 %K{007}%F{000} %F{000}world2 %K{007}%F{000} %F{000}world4 %K{007}%F{000} %F{000}world6 %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testLeftJoinedSegments() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 custom_world2_joined)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
|
||||
|
||||
assertEquals "%K{007} %F{000}world1 %K{007}%F{000}%F{000}world2 %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testLeftTransitiveJoinedSegments() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 custom_world2_joined custom_world3_joined)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD3="echo world3"
|
||||
|
||||
assertEquals "%K{007} %F{000}world1 %K{007}%F{000}%F{000}world2 %K{007}%F{000}%F{000}world3 %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testLeftTransitiveJoiningWithConditionalJoinedSegment() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 custom_world2_joined custom_world3_joined custom_world4_joined)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD3="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD4="echo world4"
|
||||
|
||||
assertEquals "%K{007} %F{000}world1 %K{007}%F{000}%F{000}world2 %K{007}%F{000}%F{000}world4 %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testLeftPromotingSegmentWithConditionalPredecessor() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 custom_world2 custom_world3_joined)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD3="echo world3"
|
||||
|
||||
assertEquals "%K{007} %F{000}world1 %K{007}%F{000} %F{000}world3 %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testLeftPromotingSegmentWithJoinedConditionalPredecessor() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 custom_world2 custom_world3_joined custom_world4_joined)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD3="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD4="echo world4"
|
||||
|
||||
assertEquals "%K{007} %F{000}world1 %K{007}%F{000} %F{000}world4 %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testLeftPromotingSegmentWithDeepJoinedConditionalPredecessor() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 custom_world2 custom_world3_joined custom_world4_joined custom_world5_joined custom_world6_joined)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD3="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD4="echo world4"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD5="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD6="echo world6"
|
||||
|
||||
assertEquals "%K{007} %F{000}world1 %K{007}%F{000} %F{000}world4 %K{007}%F{000}%F{000}world6 %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testLeftJoiningBuiltinSegmentWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(php_version php_version_joined)
|
||||
alias php="echo PHP 1.2.3"
|
||||
|
||||
assertEquals "%K{013} %F{255}PHP 1.2.3 %K{013}%F{255}%F{255}PHP 1.2.3 %k%F{013}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias php
|
||||
}
|
||||
|
||||
function testRightNormalSegmentsShouldNotBeJoined() {
|
||||
local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2 custom_world3 custom_world4 custom_world5_joined custom_world6)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD3="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD4="echo world4"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD5="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD6="echo world6"
|
||||
|
||||
assertEquals "%F{007}%f%K{007}%F{000} world1 %f%F{000}%f%K{007}%F{000} world2 %f%F{000}%f%K{007}%F{000} world4 %f%F{000}%f%K{007}%F{000} world6%E" "$(build_right_prompt)"
|
||||
}
|
||||
|
||||
function testRightJoinedSegments() {
|
||||
local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2_joined)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
|
||||
|
||||
assertEquals "%F{007}%f%K{007}%F{000} world1 %f%K{007}%F{000}world2%E" "$(build_right_prompt)"
|
||||
}
|
||||
|
||||
function testRightTransitiveJoinedSegments() {
|
||||
local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2_joined custom_world3_joined)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD3="echo world3"
|
||||
|
||||
assertEquals "%F{007}%f%K{007}%F{000} world1 %f%K{007}%F{000}world2 %f%K{007}%F{000}world3%E" "$(build_right_prompt)"
|
||||
}
|
||||
|
||||
function testRightTransitiveJoiningWithConditionalJoinedSegment() {
|
||||
local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2_joined custom_world3_joined custom_world4_joined)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD3="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD4="echo world4"
|
||||
|
||||
assertEquals "%F{007}%f%K{007}%F{000} world1 %f%K{007}%F{000}world2 %f%K{007}%F{000}world4%E" "$(build_right_prompt)"
|
||||
}
|
||||
|
||||
function testRightPromotingSegmentWithConditionalPredecessor() {
|
||||
local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2 custom_world3_joined)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD3="echo world3"
|
||||
|
||||
assertEquals "%F{007}%f%K{007}%F{000} world1 %f%F{000}%f%K{007}%F{000} world3%E" "$(build_right_prompt)"
|
||||
}
|
||||
|
||||
function testRightPromotingSegmentWithJoinedConditionalPredecessor() {
|
||||
local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2 custom_world3_joined custom_world4_joined)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD3="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD4="echo world4"
|
||||
|
||||
assertEquals "%F{007}%f%K{007}%F{000} world1 %f%F{000}%f%K{007}%F{000} world4%E" "$(build_right_prompt)"
|
||||
}
|
||||
|
||||
function testRightPromotingSegmentWithDeepJoinedConditionalPredecessor() {
|
||||
local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2 custom_world3_joined custom_world4_joined custom_world5_joined custom_world6_joined)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD3="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD4="echo world4"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD5="echo " # Print nothing to simulate unmet conditions
|
||||
local POWERLEVEL9K_CUSTOM_WORLD6="echo world6"
|
||||
|
||||
assertEquals "%F{007}%f%K{007}%F{000} world1 %f%F{000}%f%K{007}%F{000} world4 %f%K{007}%F{000}world6%E" "$(build_right_prompt)"
|
||||
}
|
||||
|
||||
function testRightJoiningBuiltinSegmentWorks() {
|
||||
local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(php_version php_version_joined)
|
||||
alias php="echo PHP 1.2.3"
|
||||
|
||||
assertEquals "%F{013}%f%K{013}%F{255} PHP 1.2.3 %f%K{013}%F{255}PHP 1.2.3%E" "$(build_right_prompt)"
|
||||
|
||||
unalias php
|
||||
}
|
||||
source shunit2/shunit2
|
@ -1,104 +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 testSegmentOnRightSide() {
|
||||
# Reset RPROMPT, so a running P9K does not interfere with the test
|
||||
local RPROMPT=
|
||||
local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2='echo world2'
|
||||
|
||||
powerlevel9k_prepare_prompts
|
||||
|
||||
local reset_attributes=$'\e[00m'
|
||||
assertEquals "%f%b%k%F{007}%f%K{007}%F{000} world1 %f%F{000}%f%K{007}%F{000} world2%E%{${reset_attributes}%}" "${(e)RPROMPT}"
|
||||
}
|
||||
|
||||
function testDisablingRightPrompt() {
|
||||
# Reset RPROMPT, so a running P9K does not interfere with the test
|
||||
local RPROMPT=
|
||||
local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1 custom_world2)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2='echo world2'
|
||||
local POWERLEVEL9K_DISABLE_RPROMPT=true
|
||||
|
||||
powerlevel9k_prepare_prompts
|
||||
|
||||
assertEquals "" "${(e)RPROMPT}"
|
||||
}
|
||||
|
||||
function testLeftMultilinePrompt() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
|
||||
local POWERLEVEL9K_PROMPT_ON_NEWLINE=true
|
||||
|
||||
powerlevel9k_prepare_prompts
|
||||
|
||||
local nl=$'\n'
|
||||
assertEquals "╭─%f%b%k%K{007} %F{000}world1 %k%F{007}%f ${nl}╰─ " "${(e)PROMPT}"
|
||||
}
|
||||
|
||||
function testRightPromptOnSameLine() {
|
||||
# Reset RPROMPT, so a running P9K does not interfere with the test
|
||||
local RPROMPT=
|
||||
local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
|
||||
|
||||
local POWERLEVEL9K_PROMPT_ON_NEWLINE=true
|
||||
local POWERLEVEL9K_RPROMPT_ON_NEWLINE=false # We want the RPROMPT on the same line as our left prompt
|
||||
|
||||
# Skip test, as this cannot be tested properly.
|
||||
# The "go one line up" instruction does not get
|
||||
# printed as real characters in RPROMPT.
|
||||
# On command line the assert statement produces
|
||||
# a visually identical output as we expect, but
|
||||
# it fails anyway. :(
|
||||
startSkipping
|
||||
|
||||
powerlevel9k_prepare_prompts
|
||||
assertEquals "%{\e[1A%}%F{007}%f%K{007}%F{000} world1 %f%{\e[1B%}" "${(e)RPROMPT}"
|
||||
}
|
||||
|
||||
function testPrefixingFirstLineOnLeftPrompt() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
|
||||
|
||||
local POWERLEVEL9K_PROMPT_ON_NEWLINE=true
|
||||
local POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX='XXX'
|
||||
|
||||
powerlevel9k_prepare_prompts
|
||||
|
||||
local nl=$'\n'
|
||||
assertEquals "XXX%f%b%k%K{007} %F{000}world1 %k%F{007}%f ${nl}╰─ " "${(e)PROMPT}"
|
||||
}
|
||||
|
||||
function testPrefixingSecondLineOnLeftPrompt() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
|
||||
|
||||
local POWERLEVEL9K_PROMPT_ON_NEWLINE=true
|
||||
local POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX='XXX'
|
||||
|
||||
powerlevel9k_prepare_prompts
|
||||
|
||||
local nl=$'\n'
|
||||
assertEquals "╭─%f%b%k%K{007} %F{000}world1 %k%F{007}%f ${nl}XXX" "${(e)PROMPT}"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,60 +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/*
|
||||
}
|
||||
|
||||
function testOverwritingIconsWork() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here'
|
||||
|
||||
assertEquals "%K{007} %F{000}icon-here %F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testVisualIdentifierAppearsBeforeSegmentContentOnLeftSegments() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here'
|
||||
|
||||
assertEquals "%K{007} %F{000}icon-here %F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testVisualIdentifierAppearsAfterSegmentContentOnRightSegments() {
|
||||
local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here'
|
||||
|
||||
assertEquals "%F{007}%f%K{007}%F{000} world1%F{000} icon-here%E" "$(build_right_prompt)"
|
||||
}
|
||||
|
||||
function testVisualIdentifierPrintsNothingIfNotAvailable() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
|
||||
|
||||
assertEquals "%K{007} %F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testVisualIdentifierIsPrintedInNumericalColorCode() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1_ICON="xxx"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1_VISUAL_IDENTIFIER_COLOR="purple3"
|
||||
|
||||
assertEquals "%K{007} %F{056}xxx %F{000}world1 %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,67 +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 testGetColorCodeWithNoneColor() {
|
||||
assertEquals 'none' "$(getColorCode 'NONE')"
|
||||
}
|
||||
|
||||
function testIsSameColorComparesAnsiForegroundAndNumericalColorCorrectly() {
|
||||
assertTrue "isSameColor 'green' '002'"
|
||||
}
|
||||
|
||||
function testIsSameColorComparesAnsiBackgroundAndNumericalColorCorrectly() {
|
||||
assertTrue "isSameColor 'bg-green' '002'"
|
||||
}
|
||||
|
||||
function testIsSameColorComparesShortCodesCorrectly() {
|
||||
assertTrue "isSameColor '002' '2'"
|
||||
}
|
||||
|
||||
function testIsSameColorDoesNotYieldNotEqualColorsTruthy() {
|
||||
assertFalse "isSameColor 'green' '003'"
|
||||
}
|
||||
|
||||
function testIsSameColorHandlesNoneCorrectly() {
|
||||
assertTrue "isSameColor 'none' 'NOnE'"
|
||||
}
|
||||
|
||||
function testIsSameColorCompareTwoNoneColorsCorrectly() {
|
||||
assertTrue "isSameColor 'none' 'none'"
|
||||
}
|
||||
|
||||
function testIsSameColorComparesColorWithNoneCorrectly() {
|
||||
assertFalse "isSameColor 'green' 'none'"
|
||||
}
|
||||
|
||||
function testBrightColorsWork() {
|
||||
# We had some code in the past that equalized bright colors
|
||||
# with normal ones. This code is now gone, and this test should
|
||||
# ensure that all input channels for bright colors are handled
|
||||
# correctly.
|
||||
assertTrue "isSameColor 'cyan' '006'"
|
||||
assertEquals '006' "$(getColorCode 'cyan')"
|
||||
assertEquals '006' "$(getColor 'cyan')"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,479 +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
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
# Restore LC_CTYPE
|
||||
LC_CTYPE="${_OLD_LC_CTYPE}"
|
||||
}
|
||||
|
||||
function testLcCtypeIsNotOverwrittenInDefaultMode() {
|
||||
local POWERLEVEL9K_MODE="default"
|
||||
local LC_CTYPE="my-locale"
|
||||
# Load Powerlevel9k
|
||||
source functions/icons.zsh
|
||||
|
||||
assertEquals 'my-locale' "${LC_CTYPE}"
|
||||
}
|
||||
|
||||
function testLcCtypeIsNotOverwrittenInAwesomePatchedMode() {
|
||||
local POWERLEVEL9K_MODE="awesome-patched"
|
||||
local LC_CTYPE="my-locale"
|
||||
# Load Powerlevel9k
|
||||
source functions/icons.zsh
|
||||
|
||||
assertEquals 'my-locale' "${LC_CTYPE}"
|
||||
}
|
||||
|
||||
function testLcCtypeIsNotOverwrittenInAwesomeFontconfigMode() {
|
||||
local POWERLEVEL9K_MODE="awesome-fontconfig"
|
||||
local LC_CTYPE="my-locale"
|
||||
# Load Powerlevel9k
|
||||
source functions/icons.zsh
|
||||
|
||||
assertEquals 'my-locale' "${LC_CTYPE}"
|
||||
}
|
||||
|
||||
function testLcCtypeIsNotOverwrittenInNerdfontFontconfigMode() {
|
||||
local POWERLEVEL9K_MODE="nerdfont-fontconfig"
|
||||
local LC_CTYPE="my-locale"
|
||||
# Load Powerlevel9k
|
||||
source functions/icons.zsh
|
||||
|
||||
assertEquals 'my-locale' "${LC_CTYPE}"
|
||||
}
|
||||
|
||||
function testLcCtypeIsNotOverwrittenInFlatMode() {
|
||||
local POWERLEVEL9K_MODE="flat"
|
||||
local LC_CTYPE="my-locale"
|
||||
# Load Powerlevel9k
|
||||
source functions/icons.zsh
|
||||
|
||||
assertEquals 'my-locale' "${LC_CTYPE}"
|
||||
}
|
||||
|
||||
function testLcCtypeIsNotOverwrittenInCompatibleMode() {
|
||||
local POWERLEVEL9K_MODE="compatible"
|
||||
local LC_CTYPE="my-locale"
|
||||
# Load Powerlevel9k
|
||||
source functions/icons.zsh
|
||||
|
||||
assertEquals 'my-locale' "${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"
|
||||
local 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 "nerdfont-complete" mode
|
||||
POWERLEVEL9K_MODE="nerdfont-complete"
|
||||
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"
|
||||
local 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 "nerdfont-complete" mode
|
||||
POWERLEVEL9K_MODE="nerdfont-complete"
|
||||
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"
|
||||
local 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 "nerdfont-complete" mode
|
||||
POWERLEVEL9K_MODE="nerdfont-complete"
|
||||
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"
|
||||
local 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 "nerdfont-complete" mode
|
||||
POWERLEVEL9K_MODE="nerdfont-complete"
|
||||
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-complete mode, and
|
||||
# check if all of them are defined in the other modes.
|
||||
function testAllIconsAreDefinedLikeInNerdfontCompleteMode() {
|
||||
# Always compare against this mode
|
||||
local _P9K_TEST_MODE="nerdfont-complete"
|
||||
local 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 "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
|
||||
}
|
||||
|
||||
source shunit2/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/shunit2
|
@ -1,69 +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"
|
||||
}
|
||||
|
||||
function testAnacondaSegmentPrintsNothingIfNoAnacondaPathIsSet() {
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda custom_world)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
# Unset anacona variables
|
||||
unset CONDA_ENV_PATH
|
||||
unset CONDA_PREFIX
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testAnacondaSegmentWorksIfOnlyAnacondaPathIsSet() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda)
|
||||
local POWERLEVEL9K_PYTHON_ICON="icon-here"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
CONDA_ENV_PATH=/tmp
|
||||
unset CONDA_PREFIX
|
||||
|
||||
assertEquals "%K{004} %F{000}icon-here %F{000}(tmp) %k%F{004}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda)
|
||||
local POWERLEVEL9K_PYTHON_ICON="icon-here"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
unset CONDA_ENV_PATH
|
||||
local CONDA_PREFIX="test"
|
||||
|
||||
assertEquals "%K{004} %F{000}icon-here %F{000}(test) %k%F{004}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testAnacondaSegmentWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda)
|
||||
local POWERLEVEL9K_PYTHON_ICON="icon-here"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
local CONDA_ENV_PATH=/tmp
|
||||
local CONDA_PREFIX="test"
|
||||
|
||||
assertEquals "%K{004} %F{000}icon-here %F{000}(tmptest) %k%F{004}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,61 +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"
|
||||
}
|
||||
|
||||
function testAwsEbEnvSegmentPrintsNothingIfNoElasticBeanstalkEnvironmentIsSet() {
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(aws_eb_env custom_world)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSet() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(aws_eb_env)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
mkdir -p /tmp/powerlevel9k-test/.elasticbeanstalk
|
||||
echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml
|
||||
cd /tmp/powerlevel9k-test
|
||||
|
||||
assertEquals "%K{000} %F{002}🌱 %F{002}test %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
cd -
|
||||
}
|
||||
|
||||
function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSetInParentDirectory() {
|
||||
# Skip test, because currently we cannot detect
|
||||
# if the configuration is in a parent directory
|
||||
startSkipping # Skip test
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(aws_eb_env)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
mkdir -p /tmp/powerlevel9k-test/.elasticbeanstalk
|
||||
mkdir -p /tmp/powerlevel9k-test/1/12/123/1234/12345
|
||||
echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml
|
||||
cd /tmp/powerlevel9k-test/1/12/123/1234/12345
|
||||
|
||||
assertEquals "%K{000} %F{002}🌱 %F{002}test %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
cd -
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,78 +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"
|
||||
}
|
||||
|
||||
function testBackgroundJobsSegmentPrintsNothingWithoutBackgroundJobs() {
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(background_jobs custom_world)
|
||||
alias jobs="nojobs 2>/dev/null"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias jobs
|
||||
}
|
||||
|
||||
function testBackgroundJobsSegmentWorksWithOneBackgroundJob() {
|
||||
unset POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(background_jobs)
|
||||
jobs() {
|
||||
echo '[1] + 30444 suspended nvim xx'
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{006}⚙ %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction jobs
|
||||
}
|
||||
|
||||
function testBackgroundJobsSegmentWorksWithMultipleBackgroundJobs() {
|
||||
local POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(background_jobs)
|
||||
jobs() {
|
||||
echo "[1] 31190 suspended nvim xx"
|
||||
echo "[2] - 31194 suspended nvim xx2"
|
||||
echo "[3] + 31206 suspended nvim xx3"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{006}⚙ %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction jobs
|
||||
}
|
||||
|
||||
function testBackgroundJobsSegmentWithVerboseMode() {
|
||||
local POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=true
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(background_jobs)
|
||||
jobs() {
|
||||
echo "[1] 31190 suspended nvim xx"
|
||||
echo "[2] - 31194 suspended nvim xx2"
|
||||
echo "[3] + 31206 suspended nvim xx3"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{006}⚙ %F{006}3 %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction jobs
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,177 +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
|
||||
|
||||
P9K_HOME=$(pwd)
|
||||
### Test specific
|
||||
# Create default folder
|
||||
FOLDER=/tmp/powerlevel9k-test
|
||||
mkdir -p "${FOLDER}"
|
||||
cd $FOLDER
|
||||
|
||||
# Prepare folder for pmset (OSX)
|
||||
PMSET_PATH=$FOLDER/usr/bin
|
||||
mkdir -p $PMSET_PATH
|
||||
# Prepare folder for $BATTERY (Linux)
|
||||
BATTERY_PATH=$FOLDER/sys/class/power_supply
|
||||
mkdir -p $BATTERY_PATH
|
||||
mkdir -p $BATTERY_PATH/BAT0
|
||||
mkdir -p $BATTERY_PATH/BAT1
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
# Go back to powerlevel9k folder
|
||||
cd "${P9K_HOME}"
|
||||
# Remove eventually created test-specific folder
|
||||
rm -fr "${FOLDER}" &>/dev/null
|
||||
# At least remove test folder completely
|
||||
rm -fr /tmp/powerlevel9k-test &>/dev/null
|
||||
unset PMSET_PATH
|
||||
unset BATTERY_PATH
|
||||
unset FOLDER
|
||||
unset P9K_HOME
|
||||
}
|
||||
|
||||
# Mock Battery
|
||||
# For mocking pmset on OSX this function takes one argument (the
|
||||
# content that pmset should echo).
|
||||
# For mocking the battery on Linux this function takes two
|
||||
# arguments: $1 is the capacity; $2 the battery status.
|
||||
function makeBatterySay() {
|
||||
if [[ -z "${FOLDER}" ]]; then
|
||||
echo "Fake root path is not correctly set!"
|
||||
exit 1
|
||||
fi
|
||||
# OSX
|
||||
echo "#!/bin/sh" > $PMSET_PATH/pmset
|
||||
echo "echo \"$1\"" >> $PMSET_PATH/pmset
|
||||
chmod +x $PMSET_PATH/pmset
|
||||
|
||||
# Linux
|
||||
local capacity="$1"
|
||||
echo "$capacity" > $BATTERY_PATH/BAT0/capacity
|
||||
echo "$capacity" > $BATTERY_PATH/BAT1/capacity
|
||||
local battery_status="$2"
|
||||
echo "$battery_status" > $BATTERY_PATH/BAT0/status
|
||||
echo "$battery_status" > $BATTERY_PATH/BAT1/status
|
||||
}
|
||||
|
||||
function testBatterySegmentIfBatteryIsLowWhileDischargingOnOSX() {
|
||||
local OS='OSX' # Fake OSX
|
||||
makeBatterySay "Now drawing from 'Battery Power'
|
||||
-InternalBattery-0 (id=1234567) 4%; discharging; 0:05 remaining present: true"
|
||||
|
||||
assertEquals "%K{000} %F{001}🔋 %F{001}4%% (0:05) " "$(prompt_battery left 1 false ${FOLDER})"
|
||||
}
|
||||
|
||||
function testBatterySegmentIfBatteryIsLowWhileChargingOnOSX() {
|
||||
local OS='OSX' # Fake OSX
|
||||
makeBatterySay "Now drawing from 'Battery Power'
|
||||
-InternalBattery-0 (id=1234567) 4%; charging; 0:05 remaining present: true"
|
||||
|
||||
assertEquals "%K{000} %F{003}🔋 %F{003}4%% (0:05) " "$(prompt_battery left 1 false ${FOLDER})"
|
||||
}
|
||||
|
||||
function testBatterySegmentIfBatteryIsAlmostFullWhileDischargingOnOSX() {
|
||||
local OS='OSX' # Fake OSX
|
||||
makeBatterySay "Now drawing from 'Battery Power'
|
||||
-InternalBattery-0 (id=1234567) 98%; discharging; 3:57 remaining present: true"
|
||||
|
||||
assertEquals "%K{000} %F{007}🔋 %F{007}98%% (3:57) " "$(prompt_battery left 1 false ${FOLDER})"
|
||||
}
|
||||
|
||||
function testBatterySegmentIfBatteryIsAlmostFullWhileChargingOnOSX() {
|
||||
local OS='OSX' # Fake OSX
|
||||
makeBatterySay "Now drawing from 'Battery Power'
|
||||
-InternalBattery-0 (id=1234567) 98%; charging; 3:57 remaining present: true"
|
||||
|
||||
assertEquals "%K{000} %F{003}🔋 %F{003}98%% (3:57) " "$(prompt_battery left 1 false ${FOLDER})"
|
||||
}
|
||||
|
||||
function testBatterySegmentIfBatteryIsFullOnOSX() {
|
||||
local OS='OSX' # Fake OSX
|
||||
makeBatterySay "Now drawing from 'AC Power'
|
||||
-InternalBattery-0 (id=1234567) 99%; charged; 0:00 remaining present: true"
|
||||
|
||||
assertEquals "%K{000} %F{002}🔋 %F{002}99%% " "$(prompt_battery left 1 false ${FOLDER})"
|
||||
}
|
||||
|
||||
function testBatterySegmentIfBatteryIsCalculatingOnOSX() {
|
||||
local OS='OSX' # Fake OSX
|
||||
makeBatterySay "Now drawing from 'Battery Power'
|
||||
-InternalBattery-0 (id=1234567) 99%; discharging; (no estimate) present: true"
|
||||
|
||||
assertEquals "%K{000} %F{007}🔋 %F{007}99%% (...) " "$(prompt_battery left 1 false ${FOLDER})"
|
||||
}
|
||||
|
||||
function testBatterySegmentIfBatteryIsLowWhileDischargingOnLinux() {
|
||||
local OS='Linux' # Fake Linux
|
||||
makeBatterySay "4" "Discharging"
|
||||
|
||||
assertEquals "%K{000} %F{001}🔋 %F{001}4%% " "$(prompt_battery left 1 false ${FOLDER})"
|
||||
}
|
||||
|
||||
function testBatterySegmentIfBatteryIsLowWhileChargingOnLinux() {
|
||||
local OS='Linux' # Fake Linux
|
||||
makeBatterySay "4" "Charging"
|
||||
|
||||
assertEquals "%K{000} %F{003}🔋 %F{003}4%% " "$(prompt_battery left 1 false ${FOLDER})"
|
||||
}
|
||||
|
||||
function testBatterySegmentIfBatteryIsNormalWhileDischargingOnLinux() {
|
||||
local OS='Linux' # Fake Linux
|
||||
makeBatterySay "10" "Discharging"
|
||||
|
||||
assertEquals "%K{000} %F{007}🔋 %F{007}10%% " "$(prompt_battery left 1 false ${FOLDER})"
|
||||
}
|
||||
|
||||
function testBatterySegmentIfBatteryIsNormalWhileChargingOnLinux() {
|
||||
local OS='Linux' # Fake Linux
|
||||
makeBatterySay "10" "Charging"
|
||||
|
||||
assertEquals "%K{000} %F{003}🔋 %F{003}10%% " "$(prompt_battery left 1 false ${FOLDER})"
|
||||
}
|
||||
|
||||
function testBatterySegmentIfBatteryIsFullOnLinux() {
|
||||
local OS='Linux' # Fake Linux
|
||||
makeBatterySay "100" "Full"
|
||||
|
||||
assertEquals "%K{000} %F{002}🔋 %F{002}100%% " "$(prompt_battery left 1 false ${FOLDER})"
|
||||
}
|
||||
|
||||
function testBatterySegmentIfBatteryIsNormalWithAcpiEnabledOnLinux() {
|
||||
local OS='Linux' # Fake Linux
|
||||
makeBatterySay "50" "Discharging"
|
||||
echo "echo 'Batter 0: Discharging, 50%, 01:38:54 remaining'" > ${FOLDER}/usr/bin/acpi
|
||||
chmod +x ${FOLDER}/usr/bin/acpi
|
||||
# For running on Mac, we need to mock date :(
|
||||
[[ -f /usr/local/bin/gdate ]] && alias date=gdate
|
||||
|
||||
assertEquals "%K{000} %F{007}🔋 %F{007}50%% (1:38) " "$(prompt_battery left 1 false ${FOLDER})"
|
||||
|
||||
unalias date &>/dev/null
|
||||
# unaliasing date fails where it was never aliased (e.g. on Linux).
|
||||
# This causes the whole test to fail, because the return code is
|
||||
# non-zero.
|
||||
return 0
|
||||
}
|
||||
|
||||
function testBatterySegmentIfBatteryIsCalculatingWithAcpiEnabledOnLinux() {
|
||||
local OS='Linux' # Fake Linux
|
||||
makeBatterySay "50" "Discharging"
|
||||
# Todo: Include real acpi output!
|
||||
echo "echo 'Batter 0: Discharging, 50%, rate remaining'" > ${FOLDER}/usr/bin/acpi
|
||||
chmod +x ${FOLDER}/usr/bin/acpi
|
||||
|
||||
assertEquals "%K{000} %F{007}🔋 %F{007}50%% (...) " "$(prompt_battery left 1 false ${FOLDER})"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,104 +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"
|
||||
}
|
||||
|
||||
function testCommandExecutionTimeIsNotShownIfTimeIsBelowThreshold() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world command_execution_time)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
# Override payload
|
||||
local _P9K_COMMAND_DURATION=2
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testCommandExecutionTimeThresholdCouldBeChanged() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
|
||||
local POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=1
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
# Override payload
|
||||
local _P9K_COMMAND_DURATION=2.03
|
||||
|
||||
assertEquals "%K{001} %F{226}Dur %F{226}2.03 %k%F{001}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testCommandExecutionTimeThresholdCouldBeSetToZero() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
|
||||
local POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0
|
||||
local _P9K_COMMAND_DURATION=0.03
|
||||
|
||||
assertEquals "%K{001} %F{226}Dur %F{226}0.03 %k%F{001}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testCommandExecutionTimePrecisionCouldBeChanged() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
|
||||
local POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0
|
||||
local POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=4
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
# Override payload
|
||||
local _P9K_COMMAND_DURATION=0.0001
|
||||
|
||||
assertEquals "%K{001} %F{226}Dur %F{226}0.0001 %k%F{001}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testCommandExecutionTimePrecisionCouldBeSetToZero() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
|
||||
local POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
# Override payload
|
||||
local _P9K_COMMAND_DURATION=23.5001
|
||||
|
||||
assertEquals "%K{001} %F{226}Dur %F{226}23 %k%F{001}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testCommandExecutionTimeIsFormattedHumandReadbleForMinuteLongCommand() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
# Override payload
|
||||
local _P9K_COMMAND_DURATION=180
|
||||
|
||||
assertEquals "%K{001} %F{226}Dur %F{226}03:00 %k%F{001}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testCommandExecutionTimeIsFormattedHumandReadbleForHourLongCommand() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
# Override payload
|
||||
local _P9K_COMMAND_DURATION=7200
|
||||
|
||||
assertEquals "%K{001} %F{226}Dur %F{226}02:00:00 %k%F{001}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,131 +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"
|
||||
|
||||
# Test specific settings
|
||||
OLD_DEFAULT_USER=$DEFAULT_USER
|
||||
unset DEFAULT_USER
|
||||
|
||||
# Fix leaked state for travis
|
||||
OLD_POWERLEVEL9K_CONTEXT_ALWAYS_SHOW=$POWERLEVEL9K_CONTEXT_ALWAYS_SHOW
|
||||
unset POWERLEVEL9K_CONTEXT_ALWAYS_SHOW
|
||||
OLD_SSH_CLIENT=$SSH_CLIENT
|
||||
unset SSH_CLIENT
|
||||
OLD_SSH_TTY=$SSH_TTY
|
||||
unset SSH_TTY
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
# Restore old variables
|
||||
[[ -n "$OLD_DEFAULT_USER" ]] && DEFAULT_USER=$OLD_DEFAULT_USER
|
||||
unset OLD_DEFAULT_USER
|
||||
|
||||
[[ -n "$OLD_POWERLEVEL9K_CONTEXT_ALWAYS_SHOW" ]] && POWERLEVEL9K_CONTEXT_ALWAYS_SHOW=$OLD_POWERLEVEL9K_CONTEXT_ALWAYS_SHOW
|
||||
unset OLD_POWERLEVEL9K_CONTEXT_ALWAYS_SHOW
|
||||
|
||||
[[ -n "$OLD_SSH_CLIENT" ]] && SSH_CLIENT=$OLD_SSH_CLIENT
|
||||
unset OLD_SSH_CLIENT
|
||||
|
||||
[[ -n "$OLD_SSH_TTY" ]] && SSH_TTY=$OLD_SSH_TTY
|
||||
unset OLD_SSH_TTY
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function testContextSegmentDoesNotGetRenderedWithDefaultUser() {
|
||||
local DEFAULT_USER=$(whoami)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context custom_world)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testContextSegmentDoesGetRenderedWhenSshConnectionIsOpen() {
|
||||
function sudo() {
|
||||
return 0
|
||||
}
|
||||
local SSH_CLIENT="putty"
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{003}%n@%m %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction sudo
|
||||
}
|
||||
|
||||
function testContextSegmentWithForeignUser() {
|
||||
function sudo() {
|
||||
return 0
|
||||
}
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{003}%n@%m %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction sudo
|
||||
}
|
||||
|
||||
# TODO: How to test root?
|
||||
function testContextSegmentWithRootUser() {
|
||||
startSkipping # Skip test
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{003}%n@%m %k%F{000}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testOverridingContextTemplate() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
|
||||
local POWERLEVEL9K_CONTEXT_TEMPLATE=xx
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{003}xx %k%F{000}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testContextSegmentIsShownIfDefaultUserIsSetWhenForced() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
|
||||
local POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
|
||||
local DEFAULT_USER=$(whoami)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{003}%n@%m %k%F{000}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testContextSegmentIsShownIfForced() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
|
||||
local POWERLEVEL9K_ALWAYS_SHOW_USER=true
|
||||
local DEFAULT_USER=$(whoami)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{003}$(whoami) %k%F{000}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
source shunit2/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"
|
||||
}
|
||||
|
||||
function testCustomDirectOutputSegment() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD="echo world"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testCustomClosureSegment() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
|
||||
function p9k_hello_world() {
|
||||
echo "world"
|
||||
}
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='p9k_hello_world'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testSettingBackgroundForCustomSegment() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD="echo world"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD_BACKGROUND="yellow"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{003} %F{000}world %k%F{003}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testSettingForegroundForCustomSegment() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD="echo world"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD_FOREGROUND="red"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{001}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testSettingVisualIdentifierForCustomSegment() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD="echo world"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD_ICON="hw"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}hw %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testSettingVisualIdentifierForegroundColorForCustomSegment() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD="echo world"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD_ICON="hw"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD_VISUAL_IDENTIFIER_COLOR="red"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{001}hw %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,83 +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 testDetectVirtSegmentPrintsNothingIfSystemdIsNotAvailable() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(detect_virt custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
alias systemd-detect-virt="novirt"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias systemd-detect-virt
|
||||
}
|
||||
|
||||
function testDetectVirtSegmentIfSystemdReturnsPlainName() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(detect_virt)
|
||||
alias systemd-detect-virt="echo 'xxx'"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{003}xxx %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias systemd-detect-virt
|
||||
}
|
||||
|
||||
function testDetectVirtSegmentIfRootFsIsOnExpectedInode() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(detect_virt)
|
||||
# Well. This is a weak test, as it fixates the implementation,
|
||||
# but it is necessary, as the implementation relys on the root
|
||||
# directory having the inode number "2"..
|
||||
alias systemd-detect-virt="echo 'none'"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
# The original command in the implementation is "ls -di / | grep -o 2",
|
||||
# which translates to: Show the inode number of "/" and test if it is "2".
|
||||
alias ls="echo '2'"
|
||||
|
||||
assertEquals "%K{000} %F{003}none %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias ls
|
||||
unalias systemd-detect-virt
|
||||
}
|
||||
|
||||
function testDetectVirtSegmentIfRootFsIsNotOnExpectedInode() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(detect_virt)
|
||||
# Well. This is a weak test, as it fixates the implementation,
|
||||
# but it is necessary, as the implementation relys on the root
|
||||
# directory having the inode number "2"..
|
||||
alias systemd-detect-virt="echo 'none'"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
# The original command in the implementation is "ls -di / | grep -o 2",
|
||||
# which translates to: Show the inode number of "/" and test if it is "2".
|
||||
alias ls="echo '3'"
|
||||
|
||||
assertEquals "%K{000} %F{003}chroot %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias ls
|
||||
unalias systemd-detect-virt
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,789 +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"
|
||||
|
||||
P9K_HOME="${PWD}"
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
unset P9K_HOME
|
||||
}
|
||||
|
||||
function testDirPathAbsoluteWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_PATH_ABSOLUTE=true
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
cd ~
|
||||
|
||||
# Unfortunately, we cannot fake Linux or OSX here, because
|
||||
# of /home or /Users path.. That is why we change the test
|
||||
# according to the OS of the host.
|
||||
if [[ "${OS}" == 'Linux' ]]; then
|
||||
assertEquals "%K{004} %F{000}/home/${USER} %k%F{004}%f " "$(build_left_prompt)"
|
||||
elif [[ "${OS}" == 'OSX' ]]; then
|
||||
assertEquals "%K{004} %F{000}/Users/${USER} %k%F{004}%f " "$(build_left_prompt)"
|
||||
fi
|
||||
|
||||
cd -
|
||||
}
|
||||
|
||||
function testTruncateFoldersWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
|
||||
mkdir -p $FOLDER
|
||||
cd $FOLDER
|
||||
|
||||
assertEquals "%K{004} %F{000}…/12345678/123456789 %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testTruncateFolderWithHomeDirWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
|
||||
local CURRENT_DIR=$(pwd)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
cd ~
|
||||
local FOLDER="powerlevel9k-test-${RANDOM}"
|
||||
mkdir -p $FOLDER
|
||||
cd $FOLDER
|
||||
# Switch back to home folder as this causes the problem.
|
||||
cd ..
|
||||
|
||||
assertEquals "%K{004} %F{000}~ %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
rmdir $FOLDER
|
||||
cd ${CURRENT_DIR}
|
||||
}
|
||||
|
||||
function testTruncateMiddleWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
|
||||
mkdir -p $FOLDER
|
||||
cd $FOLDER
|
||||
|
||||
assertEquals "%K{004} %F{000}/tmp/po…st/1/12/123/1234/12…45/12…56/12…67/12…78/123456789 %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testTruncationFromRightWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
|
||||
mkdir -p $FOLDER
|
||||
cd $FOLDER
|
||||
|
||||
assertEquals "%K{004} %F{000}/tmp/po…/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testTruncateToLastWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||
local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_last"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
|
||||
mkdir -p $FOLDER
|
||||
cd $FOLDER
|
||||
|
||||
assertEquals "%K{004} %F{000}123456789 %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testTruncateToFirstAndLastWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||
local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_first_and_last"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
|
||||
mkdir -p $FOLDER
|
||||
cd $FOLDER
|
||||
|
||||
assertEquals "%K{004} %F{000}/tmp/powerlevel9k-test/…/…/…/…/…/…/…/12345678/123456789 %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testTruncateAbsoluteWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||
local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_absolute"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
|
||||
mkdir -p $FOLDER
|
||||
cd $FOLDER
|
||||
|
||||
assertEquals "%K{004} %F{000}…89 %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testTruncationFromRightWithEmptyDelimiter() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||
local POWERLEVEL9K_SHORTEN_DELIMITER=""
|
||||
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
|
||||
mkdir -p $FOLDER
|
||||
cd $FOLDER
|
||||
|
||||
assertEquals "%K{004} %F{000}/tmp/po/1/12/123/12/12/12/12/12/123456789 %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testTruncateWithFolderMarkerWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
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{004} %F{000}/…/12/123/1234/12345/123456/1234567 %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr $BASEFOLDER
|
||||
}
|
||||
|
||||
function testTruncateWithFolderMarkerWithChangedFolderMarker() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker"
|
||||
local POWERLEVEL9K_SHORTEN_FOLDER_MARKER='.xxx'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
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{004} %F{000}/…/12/123/1234/12345/123456/1234567 %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr $BASEFOLDER
|
||||
}
|
||||
|
||||
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}"
|
||||
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{004} %F{000}My_Package/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
# Go back
|
||||
cd $p9kFolder
|
||||
rm -fr $BASEFOLDER
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{004} %F{000}My_Package/as…/qwerqwer %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
# Go back
|
||||
cd $p9kFolder
|
||||
rm -fr $BASEFOLDER
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{004} %F{000}My_Package/.g…/re…/heads %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
# Go back
|
||||
cd $p9kFolder
|
||||
rm -fr $BASEFOLDER
|
||||
}
|
||||
|
||||
function testHomeFolderDetectionWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_HOME_ICON='home-icon'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
cd ~
|
||||
assertEquals "%K{004} %F{000}home-icon %F{000}~ %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
}
|
||||
|
||||
function testHomeSubfolderDetectionWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_HOME_SUB_ICON='sub-icon'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
local FOLDER=~/powerlevel9k-test
|
||||
mkdir $FOLDER
|
||||
cd $FOLDER
|
||||
assertEquals "%K{004} %F{000}sub-icon %F{000}~/powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr $FOLDER
|
||||
}
|
||||
|
||||
function testOtherFolderDetectionWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_FOLDER_ICON='folder-icon'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
local FOLDER=/tmp/powerlevel9k-test
|
||||
mkdir $FOLDER
|
||||
cd $FOLDER
|
||||
assertEquals "%K{004} %F{000}folder-icon %F{000}/tmp/powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr $FOLDER
|
||||
}
|
||||
|
||||
function testChangingDirPathSeparator() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
local FOLDER="/tmp/powerlevel9k-test/1/2"
|
||||
mkdir -p $FOLDER
|
||||
cd $FOLDER
|
||||
|
||||
assertEquals "%K{004} %F{000}xXxtmpxXxpowerlevel9k-testxXx1xXx2 %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testHomeFolderAbbreviation() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local dir=$PWD
|
||||
|
||||
cd ~/
|
||||
# default
|
||||
local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{004} %F{000}~ %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
# substituted
|
||||
local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{004} %F{000}qQq %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd /tmp
|
||||
# default
|
||||
local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{004} %F{000}/tmp %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
# substituted
|
||||
local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{004} %F{000}/tmp %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd "$dir"
|
||||
}
|
||||
|
||||
function testOmittingFirstCharacterWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
|
||||
local POWERLEVEL9K_FOLDER_ICON='folder-icon'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
cd /tmp
|
||||
|
||||
assertEquals "%K{004} %F{000}folder-icon %F{000}tmp %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
}
|
||||
|
||||
function testOmittingFirstCharacterWorksWithChangingPathSeparator() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
|
||||
local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
|
||||
local POWERLEVEL9K_FOLDER_ICON='folder-icon'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
mkdir -p /tmp/powerlevel9k-test/1/2
|
||||
cd /tmp/powerlevel9k-test/1/2
|
||||
|
||||
assertEquals "%K{004} %F{000}folder-icon %F{000}tmpxXxpowerlevel9k-testxXx1xXx2 %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
# 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() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
|
||||
local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
|
||||
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
mkdir -p /tmp/powerlevel9k-test/1/2
|
||||
cd /tmp/powerlevel9k-test/1/2
|
||||
|
||||
assertEquals "%K{004} %F{000}xXx1xXx2 %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndMiddleTruncation() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
|
||||
local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
|
||||
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
mkdir -p /tmp/powerlevel9k-test/1/2
|
||||
cd /tmp/powerlevel9k-test/1/2
|
||||
|
||||
assertEquals "%K{004} %F{000}tmpxXxpo…stxXx1xXx2 %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndRightTruncation() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
|
||||
local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
|
||||
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
mkdir -p /tmp/powerlevel9k-test/1/2
|
||||
cd /tmp/powerlevel9k-test/1/2
|
||||
|
||||
assertEquals "%K{004} %F{000}tmpxXxpo…xXx1xXx2 %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testTruncateToUniqueWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
|
||||
local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx'
|
||||
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_to_unique'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
mkdir -p /tmp/powerlevel9k-test/adam/devl
|
||||
mkdir -p /tmp/powerlevel9k-test/alice/devl
|
||||
mkdir -p /tmp/powerlevel9k-test/alice/docs
|
||||
mkdir -p /tmp/powerlevel9k-test/bob/docs
|
||||
cd /tmp/powerlevel9k-test/alice/devl
|
||||
|
||||
assertEquals "%K{004} %F{000}txXxpxXxalxXxde %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testBoldHomeDirWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
cd ~
|
||||
|
||||
assertEquals "%K{004} %F{000}%B~%b %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
}
|
||||
|
||||
function testBoldHomeSubdirWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
mkdir -p ~/powerlevel9k-test
|
||||
cd ~/powerlevel9k-test
|
||||
|
||||
assertEquals "%K{004} %F{000}~/%Bpowerlevel9k-test%b %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr ~/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testBoldRootDirWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
cd /
|
||||
|
||||
assertEquals "%K{004} %F{000}%B/%b %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
}
|
||||
|
||||
function testBoldRootSubdirWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
cd /tmp
|
||||
|
||||
assertEquals "%K{004} %F{000}/%Btmp%b %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
}
|
||||
|
||||
function testBoldRootSubSubdirWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
mkdir -p /tmp/powerlevel9k-test
|
||||
cd /tmp/powerlevel9k-test
|
||||
|
||||
assertEquals "%K{004} %F{000}/tmp/%Bpowerlevel9k-test%b %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testHighlightHomeWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
cd ~
|
||||
|
||||
assertEquals "%K{004} %F{000}%F{red}~ %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
}
|
||||
|
||||
function testHighlightHomeSubdirWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
mkdir -p ~/powerlevel9k-test
|
||||
cd ~/powerlevel9k-test
|
||||
|
||||
assertEquals "%K{004} %F{000}~/%F{red}powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr ~/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testHighlightRootWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
cd /
|
||||
|
||||
assertEquals "%K{004} %F{000}%F{red}/ %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
}
|
||||
|
||||
function testHighlightRootSubdirWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
cd /tmp
|
||||
|
||||
assertEquals "%K{004} %F{000}/%F{red}tmp %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
}
|
||||
|
||||
function testHighlightRootSubSubdirWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
mkdir /tmp/powerlevel9k-test
|
||||
cd /tmp/powerlevel9k-test
|
||||
|
||||
assertEquals "%K{004} %F{000}/tmp/%F{red}powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testDirSeparatorColorHomeSubdirWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND='red'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
mkdir -p ~/powerlevel9k-test
|
||||
cd ~/powerlevel9k-test
|
||||
|
||||
assertEquals "%K{004} %F{000}~%F{red}/%F{black}powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr ~/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testDirSeparatorColorRootSubSubdirWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
local POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND='red'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
mkdir -p /tmp/powerlevel9k-test
|
||||
cd /tmp/powerlevel9k-test
|
||||
|
||||
assertEquals "%K{004} %F{000}%F{red}/%F{black}tmp%F{red}/%F{black}powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testDirHomeTruncationWorksOnlyAtTheBeginning() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
|
||||
|
||||
local FOLDER=/tmp/p9ktest
|
||||
local SAVED_HOME="${HOME}"
|
||||
HOME="/p9ktest"
|
||||
|
||||
mkdir -p $FOLDER
|
||||
# Setup folder marker
|
||||
cd $FOLDER
|
||||
assertEquals "%K{004} %F{000}/tmp/p9ktest %k%F{004}%f " "$(build_left_prompt)"
|
||||
|
||||
cd -
|
||||
rm -fr $FOLDER
|
||||
HOME="${SAVED_HOME}"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,131 +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"
|
||||
|
||||
# Test specific
|
||||
P9K_HOME=$(pwd)
|
||||
FOLDER=/tmp/powerlevel9k-test
|
||||
mkdir -p $FOLDER
|
||||
cd $FOLDER
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
# Go back to powerlevel9k folder
|
||||
cd "${P9K_HOME}"
|
||||
# Remove eventually created test-specific folder
|
||||
rm -fr "${FOLDER}"
|
||||
# At least remove test folder completely
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
unset FOLDER
|
||||
unset P9K_HOME
|
||||
|
||||
# Remove IP cache file
|
||||
rm -f ${POWERLEVEL9K_PUBLIC_IP_FILE}
|
||||
}
|
||||
|
||||
function testDiskUsageSegmentWhenDiskIsAlmostFull() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
|
||||
df() {
|
||||
echo "Filesystem 1K-blocks Used Available Use% Mounted on
|
||||
/dev/disk1 487219288 471466944 15496344 97% /"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{001} %F{007}hdd %F{007}97%% %k%F{001}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction df
|
||||
}
|
||||
|
||||
function testDiskUsageSegmentWhenDiskIsVeryFull() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
|
||||
df() {
|
||||
echo "Filesystem 1K-blocks Used Available Use% Mounted on
|
||||
/dev/disk1 487219288 471466944 15496344 94% /"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{003} %F{000}hdd %F{000}94%% %k%F{003}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction df
|
||||
}
|
||||
|
||||
function testDiskUsageSegmentWhenDiskIsQuiteEmpty() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
|
||||
df() {
|
||||
echo "Filesystem 1K-blocks Used Available Use% Mounted on
|
||||
/dev/disk1 487219288 471466944 15496344 4% /"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{003}hdd %F{003}4%% %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction df
|
||||
}
|
||||
|
||||
function testDiskUsageSegmentPrintsNothingIfDiskIsQuiteEmptyAndOnlyWarningsShouldBeDisplayed() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage custom_world)
|
||||
df() {
|
||||
echo "Filesystem 1K-blocks Used Available Use% Mounted on
|
||||
/dev/disk1 487219288 471466944 15496344 4% /"
|
||||
}
|
||||
|
||||
local POWERLEVEL9K_DISK_USAGE_ONLY_WARNING=true
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction df
|
||||
}
|
||||
|
||||
function testDiskUsageSegmentWarningLevelCouldBeAdjusted() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
|
||||
local POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=10
|
||||
df() {
|
||||
echo "Filesystem 1K-blocks Used Available Use% Mounted on
|
||||
/dev/disk1 487219288 471466944 15496344 11% /"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{003} %F{000}hdd %F{000}11%% %k%F{003}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction df
|
||||
}
|
||||
|
||||
function testDiskUsageSegmentCriticalLevelCouldBeAdjusted() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
|
||||
local POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=5
|
||||
local POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=10
|
||||
df() {
|
||||
echo "Filesystem 1K-blocks Used Available Use% Mounted on
|
||||
/dev/disk1 487219288 471466944 15496344 11% /"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{001} %F{007}hdd %F{007}11%% %k%F{001}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction df
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,88 +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"
|
||||
}
|
||||
|
||||
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
|
||||
local POWERLEVEL9K_GO_ICON=""
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(go_version)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
local PWD="$HOME/go/src/github.com/bhilburn/powerlevel9k"
|
||||
|
||||
assertEquals "%K{002} %F{255} %F{255}go1.5.3 %k%F{002}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias go
|
||||
}
|
||||
|
||||
function testGoSegmentPrintsNothingIfEmptyGopath() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
alias go=mockGoEmptyGopath
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testGoSegmentPrintsNothingIfNotInGopath() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
alias go=mockGo
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testGoSegmentPrintsNothingIfGoIsNotAvailable() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
alias go=noGo
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias go
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,231 +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"
|
||||
}
|
||||
|
||||
function testIpSegmentPrintsNothingOnOsxIfNotConnected() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip custom_world)
|
||||
alias networksetup='echo "not connected"'
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
local OS="OSX" # Fake OSX
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias networksetup
|
||||
}
|
||||
|
||||
function testIpSegmentPrintsNothingOnLinuxIfNotConnected() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip custom_world)
|
||||
alias ip='echo "not connected"'
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
local OS="Linux" # Fake Linux
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias ip
|
||||
}
|
||||
|
||||
function testIpSegmentWorksOnOsxWithNoInterfaceSpecified() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
|
||||
alias networksetup="echo 'An asterisk (*) denotes that a network service is disabled.
|
||||
(1) Ethernet
|
||||
(Hardware Port: Ethernet, Device: en0)
|
||||
|
||||
(2) FireWire
|
||||
(Hardware Port: FireWire, Device: fw0)
|
||||
|
||||
(3) Wi-Fi
|
||||
(Hardware Port: Wi-Fi, Device: en1)
|
||||
|
||||
(4) Bluetooth PAN
|
||||
(Hardware Port: Bluetooth PAN, Device: en3)
|
||||
|
||||
(5) Thunderbolt Bridge
|
||||
(Hardware Port: Thunderbolt Bridge, Device: bridge0)
|
||||
|
||||
(6) Apple USB Ethernet Adapter
|
||||
(Hardware Port: Apple USB Ethernet Adapter, Device: en4)
|
||||
'"
|
||||
|
||||
alias ipconfig="_(){ echo '1.2.3.4'; };_"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
local OS='OSX' # Fake OSX
|
||||
|
||||
assertEquals "%K{006} %F{000}IP %F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias ipconfig
|
||||
unalias networksetup
|
||||
}
|
||||
|
||||
# There could be more than one confiured network interfaces.
|
||||
# `networksetup -listnetworkserviceorder` lists the interfaces
|
||||
# in hierarchical order, but from outside this is not obvious
|
||||
# (implementation detail). So we need a test for this case.
|
||||
function testIpSegmentWorksOnOsxWithMultipleInterfacesSpecified() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
|
||||
alias networksetup="echo 'An asterisk (*) denotes that a network service is disabled.
|
||||
(1) Ethernet
|
||||
(Hardware Port: Ethernet, Device: en0)
|
||||
|
||||
(2) FireWire
|
||||
(Hardware Port: FireWire, Device: fw0)
|
||||
|
||||
(3) Wi-Fi
|
||||
(Hardware Port: Wi-Fi, Device: en1)
|
||||
|
||||
(4) Bluetooth PAN
|
||||
(Hardware Port: Bluetooth PAN, Device: en3)
|
||||
|
||||
(5) Thunderbolt Bridge
|
||||
(Hardware Port: Thunderbolt Bridge, Device: bridge0)
|
||||
|
||||
(6) Apple USB Ethernet Adapter
|
||||
(Hardware Port: Apple USB Ethernet Adapter, Device: en4)
|
||||
'"
|
||||
|
||||
# Return a unique IP address for every interface
|
||||
ipconfig() {
|
||||
case "${2}" {
|
||||
en0)
|
||||
echo 1.2.3.4
|
||||
;;
|
||||
fw0)
|
||||
echo 2.3.4.5
|
||||
;;
|
||||
en1)
|
||||
echo 3.4.5.6
|
||||
;;
|
||||
en3)
|
||||
echo 4.5.6.7
|
||||
;;
|
||||
}
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
local OS='OSX' # Fake OSX
|
||||
|
||||
assertEquals "%K{006} %F{000}IP %F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction ipconfig
|
||||
unalias networksetup
|
||||
}
|
||||
|
||||
function testIpSegmentWorksOnOsxWithInterfaceSpecified() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
|
||||
local POWERLEVEL9K_IP_INTERFACE='xxx'
|
||||
alias ipconfig="_(){ echo '1.2.3.4'; };_"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
local OS='OSX' # Fake OSX
|
||||
|
||||
assertEquals "%K{006} %F{000}IP %F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias ipconfig
|
||||
}
|
||||
|
||||
function testIpSegmentWorksOnLinuxWithNoInterfaceSpecified() {
|
||||
setopt aliases
|
||||
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
|
||||
# That command is harder to test, as it is used at first
|
||||
# to get all relevant network interfaces and then for
|
||||
# getting the configuration of that segment..
|
||||
ip(){
|
||||
if [[ "$*" == 'link ls up' ]]; then
|
||||
echo "1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
|
||||
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
|
||||
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
|
||||
link/ether 08:00:27:7e:84:45 brd ff:ff:ff:ff:ff:ff";
|
||||
fi
|
||||
|
||||
if [[ "$*" == '-4 a show eth0' ]]; then
|
||||
echo '2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
|
||||
inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
|
||||
valid_lft forever preferred_lft forever';
|
||||
fi
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
local OS='Linux' # Fake Linux
|
||||
|
||||
assertEquals "%K{006} %F{000}IP %F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction ip
|
||||
}
|
||||
|
||||
function testIpSegmentWorksOnLinuxWithMultipleInterfacesSpecified() {
|
||||
setopt aliases
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
|
||||
# That command is harder to test, as it is used at first
|
||||
# to get all relevant network interfaces and then for
|
||||
# getting the configuration of that segment..
|
||||
ip(){
|
||||
if [[ "$*" == 'link ls up' ]]; then
|
||||
echo "1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
|
||||
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
|
||||
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
|
||||
link/ether 08:00:27:7e:84:45 brd ff:ff:ff:ff:ff:ff
|
||||
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
|
||||
link/ether 08:00:27:7e:84:45 brd ff:ff:ff:ff:ff:ff
|
||||
4: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
|
||||
link/ether 08:00:27:7e:84:45 brd ff:ff:ff:ff:ff:ff";
|
||||
fi
|
||||
|
||||
if [[ "$*" == '-4 a show eth1' ]]; then
|
||||
echo '3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
|
||||
inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
|
||||
valid_lft forever preferred_lft forever';
|
||||
fi
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
local OS='Linux' # Fake Linux
|
||||
|
||||
assertEquals "%K{006} %F{000}IP %F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction ip
|
||||
}
|
||||
|
||||
function testIpSegmentWorksOnLinuxWithInterfaceSpecified() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
|
||||
local POWERLEVEL9K_IP_INTERFACE='xxx'
|
||||
ip(){
|
||||
echo '2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
|
||||
inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
|
||||
valid_lft forever preferred_lft forever';
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
local OS='Linux' # Fake Linux
|
||||
|
||||
assertEquals "%K{006} %F{000}IP %F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction ip
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,104 +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"
|
||||
}
|
||||
|
||||
function mockKubectl() {
|
||||
case "$1" in
|
||||
'version')
|
||||
echo 'non-empty text'
|
||||
;;
|
||||
'config')
|
||||
case "$2" in
|
||||
'view')
|
||||
case "$3" in
|
||||
'-o=jsonpath={.current-context}')
|
||||
echo 'minikube'
|
||||
;;
|
||||
'-o=jsonpath={.contexts'*)
|
||||
echo ''
|
||||
;;
|
||||
*)
|
||||
echo "Mock value missed"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function mockKubectlOtherNamespace() {
|
||||
case "$1" in
|
||||
'version')
|
||||
echo 'non-empty text'
|
||||
;;
|
||||
'config')
|
||||
case "$2" in
|
||||
'view')
|
||||
case "$3" in
|
||||
# Get Current Context
|
||||
'-o=jsonpath={.current-context}')
|
||||
echo 'minikube'
|
||||
;;
|
||||
# Get current namespace
|
||||
'-o=jsonpath={.contexts'*)
|
||||
echo 'kube-system'
|
||||
;;
|
||||
*)
|
||||
echo "Mock value missed"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function testKubeContext() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext)
|
||||
alias kubectl=mockKubectl
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{005} %F{007}⎈ %F{007}minikube/default %k%F{005}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias kubectl
|
||||
}
|
||||
function testKubeContextOtherNamespace() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext)
|
||||
alias kubectl=mockKubectlOtherNamespace
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{005} %F{007}⎈ %F{007}minikube/kube-system %k%F{005}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias kubectl
|
||||
}
|
||||
function testKubeContextPrintsNothingIfKubectlNotAvailable() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world kubecontext)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
alias kubectl=noKubectl
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias kubectl
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,72 +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"
|
||||
}
|
||||
|
||||
function mockLaravelVersion() {
|
||||
case "$1" in
|
||||
"artisan")
|
||||
# artisan --version follows the format Laravel Framework <version>
|
||||
echo "Laravel Framework 5.4.23"
|
||||
;;
|
||||
default)
|
||||
esac
|
||||
}
|
||||
|
||||
function mockNoLaravelVersion() {
|
||||
# When php can't find a file it will output a message
|
||||
echo "Could not open input file: artisan"
|
||||
return 0
|
||||
}
|
||||
|
||||
function testLaravelVersionSegment() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(laravel_version)
|
||||
local POWERLEVEL9K_LARAVEL_ICON='x'
|
||||
alias php=mockLaravelVersion
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{009} %F{007}x %F{007}5.4.23 %k%F{009}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias php
|
||||
}
|
||||
|
||||
function testLaravelVersionSegmentIfArtisanIsNotAvailable() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world laravel_version)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
local POWERLEVEL9K_LARAVEL_ICON='x'
|
||||
alias php=mockNoLaravelVersion
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias php
|
||||
}
|
||||
|
||||
function testLaravelVersionSegmentPrintsNothingIfPhpIsNotAvailable() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world laravel_version)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
local POWERLEVEL9K_LARAVEL_ICON='x'
|
||||
alias php=noPhp
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias php
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,149 +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"
|
||||
|
||||
P9K_HOME=$(pwd)
|
||||
### Test specific
|
||||
# Create default folder and git init it.
|
||||
FOLDER=/tmp/powerlevel9k-test/load-test
|
||||
mkdir -p "${FOLDER}"
|
||||
cd $FOLDER
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
# Go back to powerlevel9k folder
|
||||
cd "${P9K_HOME}"
|
||||
# Remove eventually created test-specific folder
|
||||
rm -fr "${FOLDER}"
|
||||
# At least remove test folder completely
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testLoadSegmentWorksOnOsx() {
|
||||
sysctl() {
|
||||
if [[ "$*" == 'vm.loadavg' ]]; then
|
||||
echo "vm.loadavg: { 1,38 1,45 2,16 }";
|
||||
fi
|
||||
|
||||
if [[ "$*" == '-n hw.logicalcpu' ]]; then
|
||||
echo "4";
|
||||
fi
|
||||
}
|
||||
|
||||
local POWERLEVEL9K_LOAD_WHICH=1
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
local OS="OSX" # Fake OSX
|
||||
|
||||
assertEquals "%K{002} %F{000}L %F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})"
|
||||
|
||||
unfunction sysctl
|
||||
}
|
||||
|
||||
function testLoadSegmentWorksOnBsd() {
|
||||
sysctl() {
|
||||
if [[ "$*" == 'vm.loadavg' ]]; then
|
||||
echo "vm.loadavg: { 1,38 1,45 2,16 }";
|
||||
fi
|
||||
|
||||
if [[ "$*" == '-n hw.ncpu' ]]; then
|
||||
echo "4";
|
||||
fi
|
||||
}
|
||||
|
||||
local POWERLEVEL9K_LOAD_WHICH=1
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
local OS="BSD" # Fake BSD
|
||||
|
||||
assertEquals "%K{002} %F{000}L %F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})"
|
||||
|
||||
unfunction sysctl
|
||||
}
|
||||
|
||||
function testLoadSegmentWorksOnLinux() {
|
||||
# Prepare loadavg
|
||||
mkdir proc
|
||||
echo "1.38 0.01 0.05 1/87 8641" > proc/loadavg
|
||||
|
||||
alias nproc="echo 4"
|
||||
local POWERLEVEL9K_LOAD_WHICH=1
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
local OS="Linux" # Fake Linux
|
||||
|
||||
assertEquals "%K{002} %F{000}L %F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})"
|
||||
|
||||
unalias nproc
|
||||
}
|
||||
|
||||
# Test normal state. This test is not OS specific.
|
||||
# We test it as the Linux version, but that
|
||||
# does not matter here.
|
||||
function testLoadSegmentNormalState() {
|
||||
# Prepare loadavg
|
||||
mkdir proc
|
||||
echo "1.00 0.01 0.05 1/87 8641" > proc/loadavg
|
||||
|
||||
alias nproc="echo 4"
|
||||
local POWERLEVEL9K_LOAD_WHICH=1
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
local OS="Linux" # Fake Linux
|
||||
|
||||
assertEquals "%K{002} %F{000}L %F{000}1.00 " "$(prompt_load left 1 false ${FOLDER})"
|
||||
|
||||
unalias nproc
|
||||
}
|
||||
|
||||
# Test warning state. This test is not OS specific.
|
||||
# We test it as the Linux version, but that
|
||||
# does not matter here.
|
||||
function testLoadSegmentWarningState() {
|
||||
# Prepare loadavg
|
||||
mkdir proc
|
||||
echo "2.01 0.01 0.05 1/87 8641" > proc/loadavg
|
||||
|
||||
alias nproc="echo 4"
|
||||
local POWERLEVEL9K_LOAD_WHICH=1
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
local OS="Linux" # Fake Linux
|
||||
|
||||
assertEquals "%K{003} %F{000}L %F{000}2.01 " "$(prompt_load left 1 false ${FOLDER})"
|
||||
|
||||
unalias nproc
|
||||
}
|
||||
|
||||
# Test critical state. This test is not OS specific.
|
||||
# We test it as the Linux version, but that
|
||||
# does not matter here.
|
||||
function testLoadSegmentCriticalState() {
|
||||
# Prepare loadavg
|
||||
mkdir proc
|
||||
echo "2.81 0.01 0.05 1/87 8641" > proc/loadavg
|
||||
|
||||
alias nproc="echo 4"
|
||||
local POWERLEVEL9K_LOAD_WHICH=1
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
local OS="Linux" # Fake Linux
|
||||
|
||||
assertEquals "%K{001} %F{000}L %F{000}2.81 " "$(prompt_load left 1 false ${FOLDER})"
|
||||
|
||||
unalias nproc
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -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() {
|
||||
export TERM="xterm-256color"
|
||||
|
||||
P9K_HOME=$(pwd)
|
||||
### Test specific
|
||||
}
|
||||
|
||||
function testNewlineDoesNotCreateExtraSegmentSeparator() {
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
|
||||
local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 newline newline newline custom_world2)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
local OS="OSX" # Fake OSX
|
||||
|
||||
local newline=$'\n'
|
||||
|
||||
assertEquals "%K{007} %F{000}world1 %k%F{007}%f${newline}%k%f${newline}%k%f${newline}%K{007} %F{000}world2 %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testNewlineMakesPreviousSegmentEndWell() {
|
||||
local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 newline)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
local OS="OSX" # Fake OSX
|
||||
|
||||
local newline=$'\n'
|
||||
|
||||
assertEquals "%K{007} %F{000}world1 %k%F{007}%f${newline}%k%F{none}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,41 +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"
|
||||
}
|
||||
|
||||
function testNodeVersionSegmentPrintsNothingWithoutNode() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(node_version custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
alias node="nonode 2>/dev/null"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias node
|
||||
}
|
||||
|
||||
function testNodeVersionSegmentWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(node_version)
|
||||
node() {
|
||||
echo "v1.2.3"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{007}⬢ %F{007}1.2.3 %k%F{002}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction node
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,79 +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"
|
||||
|
||||
# Test specfic
|
||||
# unset all possible user specified variables
|
||||
unset NODE_VIRTUAL_ENV_DISABLE_PROMPT
|
||||
unset NODE_VIRTUAL_ENV
|
||||
}
|
||||
|
||||
function testNodeenvSegmentPrintsNothingWithoutNode() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
alias node="nonode 2>/dev/null"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias node
|
||||
}
|
||||
|
||||
function testNodeenvSegmentPrintsNothingIfNodeVirtualEnvIsNotSet() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
node() {
|
||||
echo "v1.2.3"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction node
|
||||
}
|
||||
|
||||
function testNodeenvSegmentPrintsAtLeastNodeEnvWithoutNode() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv)
|
||||
alias node="nonode 2>/dev/null"
|
||||
NODE_VIRTUAL_ENV="node-env"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{002}⬢ %F{002}[node-env] %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unset NODE_VIRTUAL_ENV
|
||||
unalias node
|
||||
}
|
||||
|
||||
function testNodeenvSegmentWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv)
|
||||
node() {
|
||||
echo "v1.2.3"
|
||||
}
|
||||
NODE_VIRTUAL_ENV="node-env"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{002}⬢ %F{002}v1.2.3[node-env] %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction node
|
||||
unset NODE_VIRTUAL_ENV
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,72 +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"
|
||||
|
||||
P9K_HOME=$(pwd)
|
||||
### Test specific
|
||||
# Create default folder and git init it.
|
||||
FOLDER=/tmp/powerlevel9k-test/nvm-test
|
||||
mkdir -p "${FOLDER}/bin"
|
||||
OLD_PATH=$PATH
|
||||
PATH=${FOLDER}/bin:$PATH
|
||||
cd $FOLDER
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
# Restore old path
|
||||
PATH="${OLD_PATH}"
|
||||
# Go back to powerlevel9k folder
|
||||
cd "${P9K_HOME}"
|
||||
# Remove eventually created test-specific folder
|
||||
rm -fr "${FOLDER}"
|
||||
# At least remove test folder completely
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testNvmSegmentPrintsNothingIfNvmIsNotAvailable() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testNvmSegmentWorksWithoutHavingADefaultAlias() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
function nvm_version() {
|
||||
[[ ${1} == 'current' ]] && echo 'v4.6.0' || echo 'v1.4.0'
|
||||
}
|
||||
|
||||
assertEquals "%K{005} %F{000}⬢ %F{000}4.6.0 %k%F{005}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testNvmSegmentPrintsNothingWhenOnDefaultVersion() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
function nvm_version() {
|
||||
[[ ${1} == 'current' ]] && echo 'v4.6.0' || echo 'v4.6.0'
|
||||
}
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -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() {
|
||||
export TERM="xterm-256color"
|
||||
}
|
||||
|
||||
function testPhpVersionSegmentPrintsNothingIfPhpIsNotAvailable() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(php_version custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
alias php="nophp"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias php
|
||||
}
|
||||
|
||||
function testPhpVersionSegmentWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(php_version)
|
||||
alias php="echo 'PHP 5.6.27 (cli) (built: Oct 23 2016 11:47:58)
|
||||
Copyright (c) 1997-2016 The PHP Group
|
||||
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
|
||||
'"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{013} %F{255}PHP 5.6.27 %k%F{013}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias php
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,222 +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"
|
||||
|
||||
# Test specific
|
||||
P9K_HOME=$(pwd)
|
||||
FOLDER=/tmp/powerlevel9k-test
|
||||
mkdir -p $FOLDER
|
||||
cd $FOLDER
|
||||
|
||||
# Change cache file, so that the users environment don't
|
||||
# interfere with the tests.
|
||||
POWERLEVEL9K_PUBLIC_IP_FILE=$FOLDER/public_ip_file
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
# Go back to powerlevel9k folder
|
||||
cd "${P9K_HOME}"
|
||||
# Remove eventually created test-specific folder
|
||||
rm -fr "${FOLDER}"
|
||||
# At least remove test folder completely
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
unset FOLDER
|
||||
unset P9K_HOME
|
||||
|
||||
# Unset cache file
|
||||
unset POWERLEVEL9K_PUBLIC_IP_FILE
|
||||
}
|
||||
|
||||
function testPublicIpSegmentPrintsNothingByDefaultIfHostIsNotAvailable() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip custom_world)
|
||||
local POWERLEVEL9K_PUBLIC_IP_HOST='http://unknown.xyz'
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
# We need to overwrite dig, as this is a fallback method that
|
||||
# uses an alternative host.
|
||||
alias dig='nodig'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias dig
|
||||
}
|
||||
|
||||
function testPublicIpSegmentPrintsNoticeIfNotConnected() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
|
||||
local POWERLEVEL9K_PUBLIC_IP_HOST='http://unknown.xyz'
|
||||
local POWERLEVEL9K_PUBLIC_IP_NONE="disconnected"
|
||||
# We need to overwrite dig, as this is a fallback method that
|
||||
# uses an alternative host.
|
||||
alias dig='nodig'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{007}disconnected %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias dig
|
||||
}
|
||||
|
||||
function testPublicIpSegmentWorksWithWget() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
|
||||
alias dig='nodig'
|
||||
alias curl='nocurl'
|
||||
wget() {
|
||||
echo "wget 1.2.3.4"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{007}wget 1.2.3.4 %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction wget
|
||||
unalias dig
|
||||
unalias curl
|
||||
}
|
||||
|
||||
function testPublicIpSegmentUsesCurlAsFallbackMethodIfWgetIsNotAvailable() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
|
||||
alias dig='nodig'
|
||||
alias wget='nowget'
|
||||
curl() {
|
||||
echo "curl 1.2.3.4"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{007}curl 1.2.3.4 %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction curl
|
||||
unalias dig
|
||||
unalias wget
|
||||
}
|
||||
|
||||
function testPublicIpSegmentUsesDigAsFallbackMethodIfWgetAndCurlAreNotAvailable() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
|
||||
alias curl='nocurl'
|
||||
alias wget='nowget'
|
||||
dig() {
|
||||
echo "dig 1.2.3.4"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{007}dig 1.2.3.4 %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction dig
|
||||
unalias curl
|
||||
unalias wget
|
||||
}
|
||||
|
||||
function testPublicIpSegmentCachesFile() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
|
||||
dig() {
|
||||
echo "first"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{007}first %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
dig() {
|
||||
echo "second"
|
||||
}
|
||||
|
||||
# Segment should not have changed!
|
||||
assertEquals "%K{000} %F{007}first %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction dig
|
||||
}
|
||||
|
||||
function testPublicIpSegmentRefreshesCachesFileAfterTimeout() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
|
||||
local POWERLEVEL9K_PUBLIC_IP_TIMEOUT=2
|
||||
dig() {
|
||||
echo "first"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{007}first %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
sleep 3
|
||||
dig() {
|
||||
echo "second"
|
||||
}
|
||||
|
||||
# Segment should not have changed!
|
||||
assertEquals "%K{000} %F{007}second %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction dig
|
||||
}
|
||||
|
||||
function testPublicIpSegmentRefreshesCachesFileIfEmpty() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
|
||||
dig() {
|
||||
echo "first"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{007}first %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
# Truncate cache file
|
||||
echo "" >! $POWERLEVEL9K_PUBLIC_IP_FILE
|
||||
|
||||
dig() {
|
||||
echo "second"
|
||||
}
|
||||
|
||||
# Segment should not have changed!
|
||||
assertEquals "%K{000} %F{007}second %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction dig
|
||||
}
|
||||
|
||||
function testPublicIpSegmentWhenGoingOnline() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
|
||||
local POWERLEVEL9K_PUBLIC_IP_METHODS="dig"
|
||||
local POWERLEVEL9K_PUBLIC_IP_NONE="disconnected"
|
||||
alias dig="nodig"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{007}disconnected %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias dig
|
||||
|
||||
dig() {
|
||||
echo "second"
|
||||
}
|
||||
|
||||
# Segment should not have changed!
|
||||
assertEquals "%K{000} %F{007}second %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction dig
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,66 +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"
|
||||
|
||||
P9K_HOME=$(pwd)
|
||||
### Test specific
|
||||
# Create default folder and git init it.
|
||||
FOLDER=/tmp/powerlevel9k-test/ram-test
|
||||
mkdir -p "${FOLDER}"
|
||||
cd $FOLDER
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
# Go back to powerlevel9k folder
|
||||
cd "${P9K_HOME}"
|
||||
# Remove eventually created test-specific folder
|
||||
rm -fr "${FOLDER}"
|
||||
# At least remove test folder completely
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testRamSegmentWorksOnOsx() {
|
||||
alias vm_stat="echo 'Mach Virtual Memory Statistics: (page size of 4096 bytes)
|
||||
Pages free: 299687.
|
||||
Pages active: 1623792.
|
||||
Pages inactive: 1313411.
|
||||
'"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
local OS="OSX" # Fake OSX
|
||||
|
||||
assertEquals "%K{003} %F{000}RAM %F{000}6.15G " "$(prompt_ram left 1 false ${FOLDER})"
|
||||
|
||||
unalias vm_stat
|
||||
}
|
||||
|
||||
function testRamSegmentWorksOnBsd() {
|
||||
mkdir -p var/run
|
||||
echo "avail memory 5678B 299687 4444G 299" > var/run/dmesg.boot
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
local OS="BSD" # Fake BSD
|
||||
|
||||
assertEquals "%K{003} %F{000}RAM %F{000}0.29M " "$(prompt_ram left 1 false ${FOLDER})"
|
||||
}
|
||||
|
||||
function testRamSegmentWorksOnLinux() {
|
||||
mkdir proc
|
||||
echo "MemAvailable: 299687" > proc/meminfo
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
local OS="Linux" # Fake Linux
|
||||
|
||||
assertEquals "%K{003} %F{000}RAM %F{000}0.29G " "$(prompt_ram left 1 false ${FOLDER})"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,51 +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
|
||||
|
||||
TEST_BASE_FOLDER=/tmp/powerlevel9k-test
|
||||
RUST_TEST_FOLDER="${TEST_BASE_FOLDER}/rust-test"
|
||||
|
||||
function setUp() {
|
||||
OLDPATH="${PATH}"
|
||||
mkdir -p "${RUST_TEST_FOLDER}"
|
||||
PATH="${RUST_TEST_FOLDER}:${PATH}"
|
||||
|
||||
export TERM="xterm-256color"
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
PATH="${OLDPATH}"
|
||||
rm -fr "${TEST_BASE_FOLDER}"
|
||||
}
|
||||
|
||||
function mockRust() {
|
||||
echo "#!/bin/sh\n\necho 'rustc 0.4.1a-alpha'" > "${RUST_TEST_FOLDER}/rustc"
|
||||
chmod +x "${RUST_TEST_FOLDER}/rustc"
|
||||
}
|
||||
|
||||
function testRust() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version)
|
||||
mockRust
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{208} %F{000}Rust %F{000}0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testRustPrintsNothingIfRustIsNotAvailable() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world rust_version)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,80 +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"
|
||||
}
|
||||
|
||||
function testSshSegmentPrintsNothingIfNoSshConnection() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo "world"'
|
||||
local POWERLEVEL9K_SSH_ICON="ssh-icon"
|
||||
# Weak test: Emulate No SSH connection by unsetting
|
||||
# $SSH_CLIENT and $SSH_TTY
|
||||
unset SSH_CLIENT
|
||||
unset SSH_TTY
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testSshSegmentWorksIfOnlySshClientIsSet() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh)
|
||||
local POWERLEVEL9K_SSH_ICON="ssh-icon"
|
||||
# Weak test: Emulate No SSH connection by unsetting
|
||||
# $SSH_CLIENT and $SSH_TTY
|
||||
SSH_CLIENT='ssh-client'
|
||||
unset SSH_TTY
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{003}ssh-icon %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unset SSH_CLIENT
|
||||
}
|
||||
|
||||
function testSshSegmentWorksIfOnlySshTtyIsSet() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh)
|
||||
local POWERLEVEL9K_SSH_ICON="ssh-icon"
|
||||
# Weak test: Emulate No SSH connection by unsetting
|
||||
# $SSH_CLIENT and $SSH_TTY
|
||||
SSH_TTY='ssh-tty'
|
||||
unset SSH_CLIENT
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{003}ssh-icon %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unset SSH_TTY
|
||||
}
|
||||
|
||||
function testSshSegmentWorksIfAllNecessaryVariablesAreSet() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh)
|
||||
local POWERLEVEL9K_SSH_ICON="ssh-icon"
|
||||
# Weak test: Emulate No SSH connection by unsetting
|
||||
# $SSH_CLIENT and $SSH_TTY
|
||||
SSH_CLIENT='ssh-client'
|
||||
SSH_TTY='ssh-tty'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{003}ssh-icon %k%F{000}%f " "$(build_left_prompt)"
|
||||
|
||||
unset SSH_TTY
|
||||
unset SSH_CLIENT
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,113 +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"
|
||||
|
||||
### Test specific
|
||||
# Resets if someone has set these in his/hers env
|
||||
unset POWERLEVEL9K_STATUS_VERBOSE
|
||||
unset POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE
|
||||
}
|
||||
|
||||
function testStatusPrintsNothingIfReturnCodeIsZeroAndVerboseIsUnset() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
local POWERLEVEL9K_STATUS_VERBOSE=false
|
||||
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testStatusWorksAsExpectedIfReturnCodeIsZeroAndVerboseIsSet() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
|
||||
local POWERLEVEL9K_STATUS_VERBOSE=true
|
||||
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
|
||||
local POWERLEVEL9K_STATUS_HIDE_SIGNAME=true
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{000} %F{002}✔ %k%F{000}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testStatusInGeneralErrorCase() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
|
||||
local POWERLEVEL9K_STATUS_VERBOSE=true
|
||||
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
local RETVAL=1
|
||||
|
||||
assertEquals "%K{001} %F{226}↵ %F{226}1 %k%F{001}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testPipestatusInErrorCase() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
|
||||
local POWERLEVEL9K_STATUS_VERBOSE=true
|
||||
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=true
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
local -a RETVALS
|
||||
RETVALS=(0 0 1 0)
|
||||
|
||||
assertEquals "%K{001} %F{226}↵ %F{226}0|0|1|0 %k%F{001}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testStatusCrossWinsOverVerbose() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
|
||||
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
|
||||
local POWERLEVEL9K_STATUS_VERBOSE=true
|
||||
local POWERLEVEL9K_STATUS_CROSS=true
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
local RETVAL=1
|
||||
|
||||
assertEquals "%K{000} %F{001}✘ %k%F{000}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testStatusShowsSignalNameInErrorCase() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
|
||||
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
|
||||
local POWERLEVEL9K_STATUS_VERBOSE=true
|
||||
local POWERLEVEL9K_STATUS_HIDE_SIGNAME=false
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
local RETVAL=132
|
||||
|
||||
assertEquals "%K{001} %F{226}↵ %F{226}SIGILL(4) %k%F{001}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testStatusSegmentIntegrated() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
|
||||
local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
|
||||
local POWERLEVEL9K_STATUS_CROSS=true
|
||||
|
||||
# Load Powerlevel9k
|
||||
source powerlevel9k.zsh-theme
|
||||
|
||||
false; powerlevel9k_prepare_prompts
|
||||
|
||||
assertEquals "%f%b%k%K{000} %F{001}✘ %k%F{000}%f " "${(e)PROMPT}"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,58 +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"
|
||||
|
||||
P9K_HOME=$(pwd)
|
||||
### Test specific
|
||||
# Create default folder and git init it.
|
||||
FOLDER=/tmp/powerlevel9k-test/swap-test
|
||||
mkdir -p "${FOLDER}"
|
||||
cd $FOLDER
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
# Go back to powerlevel9k folder
|
||||
cd "${P9K_HOME}"
|
||||
# Remove eventually created test-specific folder
|
||||
rm -fr "${FOLDER}"
|
||||
# At least remove test folder completely
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testSwapSegmentWorksOnOsx() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swap)
|
||||
sysctl() {
|
||||
echo "vm.swapusage: total = 3072,00M used = 1620,50M free = 1451,50M (encrypted)"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
local OS="OSX" # Fake OSX
|
||||
|
||||
assertEquals "%K{003} %F{000}SWP %F{000}1.58G " "$(prompt_swap left 1 false ${FOLDER})"
|
||||
|
||||
unfunction sysctl
|
||||
}
|
||||
|
||||
function testSwapSegmentWorksOnLinux() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swap)
|
||||
mkdir proc
|
||||
echo "SwapTotal: 1000000" > proc/meminfo
|
||||
echo "SwapFree: 1000" >> proc/meminfo
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
local OS="Linux" # Fake Linux
|
||||
|
||||
assertEquals "%K{003} %F{000}SWP %F{000}0.95G " "$(prompt_swap left 1 false ${FOLDER})"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,57 +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"
|
||||
|
||||
P9K_HOME=$(pwd)
|
||||
### Test specific
|
||||
# Create default folder and git init it.
|
||||
FOLDER=/tmp/powerlevel9k-test
|
||||
mkdir -p "${FOLDER}"
|
||||
cd $FOLDER
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
# Go back to powerlevel9k folder
|
||||
cd "${P9K_HOME}"
|
||||
# Remove eventually created test-specific folder
|
||||
rm -fr "${FOLDER}"
|
||||
# At least remove test folder completely
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testSwiftSegmentPrintsNothingIfSwiftIsNotAvailable() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swift_version custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
alias swift="noswift"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
|
||||
unalias swift
|
||||
}
|
||||
|
||||
function testSwiftSegmentWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swift_version)
|
||||
function swift() {
|
||||
echo "Apple Swift version 3.0.1 (swiftlang-800.0.58.6 clang-800.0.42.1)\nTarget: x86_64-apple-macosx10.9"
|
||||
}
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{005} %F{007}Swift %F{007}3.0.1 %k%F{005}%f " "$(build_left_prompt)"
|
||||
|
||||
unfunction swift
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,58 +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"
|
||||
|
||||
P9K_HOME=$(pwd)
|
||||
### Test specific
|
||||
# Create default folder and git init it.
|
||||
FOLDER=/tmp/powerlevel9k-test
|
||||
mkdir -p "${FOLDER}"
|
||||
mkdir ${FOLDER}/bin
|
||||
OLD_PATH=$PATH
|
||||
PATH=${FOLDER}/bin:$PATH
|
||||
cd $FOLDER
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
# Reset PATH
|
||||
PATH=$OLD_PATH
|
||||
# Go back to powerlevel9k folder
|
||||
cd "${P9K_HOME}"
|
||||
# Remove eventually created test-specific folder
|
||||
rm -fr "${FOLDER}"
|
||||
# At least remove test folder completely
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
}
|
||||
|
||||
function testTodoSegmentPrintsNothingIfTodoShIsNotInstalled() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(todo custom_world)
|
||||
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testTodoSegmentWorksAsExpected() {
|
||||
# TODO: Skript in den PATH legen!
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(todo)
|
||||
echo '#!/bin/sh' > ${FOLDER}/bin/todo.sh
|
||||
echo 'echo "TODO: 34 of 100 tasks shown";' >> ${FOLDER}/bin/todo.sh
|
||||
chmod +x ${FOLDER}/bin/todo.sh
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{244} %F{000}☑ %F{000}100 %k%F{244}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
@ -1,535 +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"
|
||||
|
||||
P9K_HOME=$(pwd)
|
||||
### Test specific
|
||||
# Create default folder and git init it.
|
||||
FOLDER=/tmp/powerlevel9k-test/vcs-test
|
||||
mkdir -p "${FOLDER}"
|
||||
cd $FOLDER
|
||||
|
||||
# Set username and email
|
||||
OLD_GIT_AUTHOR_NAME=$GIT_AUTHOR_NAME
|
||||
GIT_AUTHOR_NAME="Testing Tester"
|
||||
OLD_GIT_AUTHOR_EMAIL=$GIT_AUTHOR_EMAIL
|
||||
GIT_AUTHOR_EMAIL="test@powerlevel9k.theme"
|
||||
|
||||
# Set default username if not already set!
|
||||
if [[ -z $(git config user.name) ]]; then
|
||||
GIT_AUTHOR_NAME_SET_BY_TEST=true
|
||||
git config --global user.name "${GIT_AUTHOR_NAME}"
|
||||
fi
|
||||
# Set default email if not already set!
|
||||
if [[ -z $(git config user.email) ]]; then
|
||||
GIT_AUTHOR_EMAIL_SET_BY_TEST=true
|
||||
git config --global user.email "${GIT_AUTHOR_EMAIL}"
|
||||
fi
|
||||
|
||||
# Initialize FOLDER as git repository
|
||||
git init 1>/dev/null
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
if [[ -n "${OLD_GIT_AUTHOR_NAME}" ]]; then
|
||||
GIT_AUTHOR_NAME=$OLD_GIT_AUTHOR
|
||||
unset OLD_GIT_AUTHOR_NAME
|
||||
else
|
||||
unset GIT_AUTHOR_NAME
|
||||
fi
|
||||
|
||||
if [[ -n "${OLD_GIT_AUTHOR_EMAIL}" ]]; then
|
||||
GIT_AUTHOR_EMAIL=$OLD_GIT_AUTHOR_EMAIL
|
||||
unset OLD_GIT_AUTHOR_EMAIL
|
||||
else
|
||||
unset GIT_AUTHOR_EMAIL
|
||||
fi
|
||||
|
||||
if [[ "${GIT_AUTHOR_NAME_SET_BY_TEST}" == "true" ]]; then
|
||||
git config --global --unset user.name
|
||||
fi
|
||||
if [[ "${GIT_AUTHOR_EMAIL_SET_BY_TEST}" == "true" ]]; then
|
||||
git config --global --unset user.email
|
||||
fi
|
||||
|
||||
# Go back to powerlevel9k folder
|
||||
cd "${P9K_HOME}"
|
||||
# Remove eventually created test-specific folder
|
||||
rm -fr "${FOLDER}"
|
||||
# At least remove test folder completely
|
||||
rm -fr /tmp/powerlevel9k-test
|
||||
unset FOLDER
|
||||
}
|
||||
|
||||
function testColorOverridingForCleanStateWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan'
|
||||
local POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{006} master %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testColorOverridingForModifiedStateWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='red'
|
||||
local POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='yellow'
|
||||
|
||||
touch testfile
|
||||
git add testfile
|
||||
git commit -m "test" 1>/dev/null
|
||||
echo "test" > testfile
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{003} %F{001} master ● %k%F{003}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testColorOverridingForUntrackedStateWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='cyan'
|
||||
local POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='yellow'
|
||||
|
||||
touch testfile
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{003} %F{006} master ? %k%F{003}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testGitIconWorks() {
|
||||
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_GIT_ICON='Git-Icon'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000}Git-Icon %F{000} master %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testGitlabIconWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_GIT_GITLAB_ICON='GL-Icon'
|
||||
|
||||
# Add a GitLab project as remote origin. This is
|
||||
# sufficient to show the GitLab-specific icon.
|
||||
git remote add origin https://gitlab.com/dritter/gitlab-test-project.git
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000}GL-Icon %F{000} master %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testBitbucketIconWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_GIT_BITBUCKET_ICON='BB-Icon'
|
||||
|
||||
# Add a BitBucket project as remote origin. This is
|
||||
# sufficient to show the BitBucket-specific icon.
|
||||
git remote add origin https://dritter@bitbucket.org/dritter/dr-test.git
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000}BB-Icon %F{000} master %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testGitHubIconWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_GIT_GITHUB_ICON='GH-Icon'
|
||||
|
||||
# Add a GitHub project as remote origin. This is
|
||||
# sufficient to show the GitHub-specific icon.
|
||||
git remote add origin https://github.com/dritter/test.git
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000}GH-Icon %F{000} master %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testUntrackedFilesIconWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_UNTRACKED_ICON='?'
|
||||
|
||||
# Create untracked file
|
||||
touch "i-am-untracked.txt"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000} master ? %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testStagedFilesIconWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_STAGED_ICON='+'
|
||||
|
||||
# Create staged file
|
||||
touch "i-am-added.txt"
|
||||
git add i-am-added.txt &>/dev/null
|
||||
git commit -m "initial commit" &>/dev/null
|
||||
echo "xx" >> i-am-added.txt
|
||||
git add i-am-added.txt &>/dev/null
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{003} %F{000} master + %k%F{003}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testUnstagedFilesIconWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_UNSTAGED_ICON='M'
|
||||
|
||||
# Create unstaged (modified, but not added to index) file
|
||||
touch "i-am-modified.txt"
|
||||
git add i-am-modified.txt
|
||||
git commit -m "Add File" 1>/dev/null
|
||||
echo "xx" > i-am-modified.txt
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{003} %F{000} master M %k%F{003}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testStashIconWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_STASH_ICON='S'
|
||||
|
||||
# Create modified file
|
||||
touch "i-am-modified.txt"
|
||||
git add i-am-modified.txt
|
||||
git commit -m "Add File" 1>/dev/null
|
||||
echo "xx" > i-am-modified.txt
|
||||
git stash 1>/dev/null
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000} master S1 %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testTagIconWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_TAG_ICON='T'
|
||||
|
||||
touch "file.txt"
|
||||
git add file.txt
|
||||
git commit -m "Add File" 1>/dev/null
|
||||
git tag "v0.0.1"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000} master Tv0.0.1 %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testTagIconInDetachedHeadState() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_TAG_ICON='T'
|
||||
|
||||
touch "file.txt"
|
||||
git add file.txt
|
||||
git commit -m "Add File" &>/dev/null
|
||||
git tag "v0.0.1"
|
||||
touch "file2.txt"
|
||||
git add file2.txt
|
||||
git commit -m "Add File2" &>/dev/null
|
||||
git checkout v0.0.1 &>/dev/null
|
||||
local hash=$(git rev-list -n 1 --abbrev-commit --abbrev=8 HEAD)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000} ${hash} Tv0.0.1 %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testActionHintWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
|
||||
touch "i-am-modified.txt"
|
||||
git add i-am-modified.txt
|
||||
git commit -m "Add File" &>/dev/null
|
||||
|
||||
git clone . ../vcs-test2 &>/dev/null
|
||||
echo "xx" >> i-am-modified.txt
|
||||
git commit -a -m "Modified file" &>/dev/null
|
||||
|
||||
cd ../vcs-test2
|
||||
echo "yy" >> i-am-modified.txt
|
||||
git commit -a -m "Provoke conflict" &>/dev/null
|
||||
git pull &>/dev/null
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{003} %F{000} master %F{red}| merge%f %k%F{003}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testIncomingHintWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON='I'
|
||||
|
||||
touch "i-am-modified.txt"
|
||||
git add i-am-modified.txt
|
||||
git commit -m "Add File" &>/dev/null
|
||||
|
||||
git clone . ../vcs-test2 &>/dev/null
|
||||
echo "xx" >> i-am-modified.txt
|
||||
git commit -a -m "Modified file" &>/dev/null
|
||||
|
||||
cd ../vcs-test2
|
||||
git fetch &>/dev/null
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000} master I1 %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testOutgoingHintWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON='o'
|
||||
|
||||
touch "i-am-modified.txt"
|
||||
git add i-am-modified.txt
|
||||
git commit -m "Add File" &>/dev/null
|
||||
|
||||
git clone . ../vcs-test2 &>/dev/null
|
||||
|
||||
cd ../vcs-test2
|
||||
|
||||
echo "xx" >> i-am-modified.txt
|
||||
git commit -a -m "Modified file" &>/dev/null
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000} master o1 %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testShorteningCommitHashWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_SHOW_CHANGESET=true
|
||||
local POWERLEVEL9K_CHANGESET_HASH_LENGTH='4'
|
||||
|
||||
touch "file.txt"
|
||||
git add file.txt
|
||||
git commit -m "Add File" 1>/dev/null
|
||||
local hash=$(git rev-list -n 1 --abbrev-commit --abbrev=3 HEAD)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
# This test needs to call powerlevel9k_vcs_init, where
|
||||
# the changeset is truncated.
|
||||
powerlevel9k_vcs_init
|
||||
assertEquals "%K{002} %F{000}${hash} master %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testShorteningCommitHashIsNotShownIfShowChangesetIsFalse() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_SHOW_CHANGESET=false
|
||||
local POWERLEVEL9K_CHANGESET_HASH_LENGTH='4'
|
||||
|
||||
touch "file.txt"
|
||||
git add file.txt
|
||||
git commit -m "Add File" 1>/dev/null
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
# This test needs to call powerlevel9k_vcs_init, where
|
||||
# the changeset is truncated.
|
||||
powerlevel9k_vcs_init
|
||||
assertEquals "%K{002} %F{000} master %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testDetectingUntrackedFilesInSubmodulesWork() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY="true"
|
||||
unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND
|
||||
|
||||
mkdir ../submodule
|
||||
cd ../submodule
|
||||
git init 1>/dev/null
|
||||
touch "i-am-tracked.txt"
|
||||
git add . 1>/dev/null && git commit -m "Initial Commit" 1>/dev/null
|
||||
|
||||
local submodulePath="${PWD}"
|
||||
|
||||
cd -
|
||||
git submodule add "${submodulePath}" 2>/dev/null
|
||||
git commit -m "Add submodule" 1>/dev/null
|
||||
|
||||
# Go into checked-out submodule path
|
||||
cd submodule
|
||||
# Create untracked file
|
||||
touch "i-am-untracked.txt"
|
||||
cd -
|
||||
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000} master ? %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testDetectinUntrackedFilesInMainRepoWithDirtySubmodulesWork() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY="true"
|
||||
unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND
|
||||
|
||||
mkdir ../submodule
|
||||
cd ../submodule
|
||||
git init 1>/dev/null
|
||||
touch "i-am-tracked.txt"
|
||||
git add . 1>/dev/null && git commit -m "Initial Commit" 1>/dev/null
|
||||
|
||||
local submodulePath="${PWD}"
|
||||
|
||||
cd -
|
||||
git submodule add "${submodulePath}" 2>/dev/null
|
||||
git commit -m "Add submodule" 1>/dev/null
|
||||
|
||||
# Create untracked file
|
||||
touch "i-am-untracked.txt"
|
||||
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000} master ? %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testDetectingUntrackedFilesInNestedSubmodulesWork() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY="true"
|
||||
unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND
|
||||
|
||||
local mainRepo="${PWD}"
|
||||
|
||||
mkdir ../submodule
|
||||
cd ../submodule
|
||||
git init 1>/dev/null
|
||||
touch "i-am-tracked.txt"
|
||||
git add . 1>/dev/null && git commit -m "Initial Commit" 1>/dev/null
|
||||
|
||||
local submodulePath="${PWD}"
|
||||
|
||||
mkdir ../subsubmodule
|
||||
cd ../subsubmodule
|
||||
git init 1>/dev/null
|
||||
touch "i-am-tracked-too.txt"
|
||||
git add . 1>/dev/null && git commit -m "Initial Commit" 1>/dev/null
|
||||
|
||||
local subsubmodulePath="${PWD}"
|
||||
|
||||
cd "${submodulePath}"
|
||||
git submodule add "${subsubmodulePath}" 2>/dev/null
|
||||
git commit -m "Add subsubmodule" 1>/dev/null
|
||||
cd "${mainRepo}"
|
||||
git submodule add "${submodulePath}" 2>/dev/null
|
||||
git commit -m "Add submodule" 1>/dev/null
|
||||
|
||||
git submodule update --init --recursive 2>/dev/null
|
||||
|
||||
cd submodule/subsubmodule
|
||||
# Create untracked file
|
||||
touch "i-am-untracked.txt"
|
||||
cd -
|
||||
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000} master ? %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testDetectingUntrackedFilesInCleanSubdirectoryWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY="true"
|
||||
unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND
|
||||
mkdir clean-folder
|
||||
touch clean-folder/file.txt
|
||||
mkdir dirty-folder
|
||||
touch dirty-folder/file.txt
|
||||
git add . 2>/dev/null
|
||||
git commit -m "Initial commit" >/dev/null
|
||||
touch dirty-folder/new-file.txt
|
||||
cd clean-folder
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
assertEquals "%K{002} %F{000} master ? %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testBranchNameScriptingVulnerability() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
echo "#!/bin/sh\n\necho 'hacked'\n" > evil_script.sh
|
||||
chmod +x evil_script.sh
|
||||
|
||||
git checkout -b '$(./evil_script.sh)' 2>/dev/null
|
||||
git add . 2>/dev/null
|
||||
git commit -m "Initial commit" >/dev/null
|
||||
|
||||
assertEquals '%K{002} %F{000} $(./evil_script.sh) %k%F{002}%f ' "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testGitSubmoduleWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY="true"
|
||||
unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND
|
||||
|
||||
mkdir ../submodule
|
||||
cd ../submodule
|
||||
git init 1>/dev/null
|
||||
touch "i-am-tracked.txt"
|
||||
git add . 1>/dev/null && git commit -m "Initial Commit" 1>/dev/null
|
||||
|
||||
local submodulePath="${PWD}"
|
||||
|
||||
cd -
|
||||
git submodule add "${submodulePath}" 2>/dev/null
|
||||
git commit -m "Add submodule" 1>/dev/null
|
||||
|
||||
cd submodule
|
||||
|
||||
source "${P9K_HOME}/powerlevel9k.zsh-theme"
|
||||
|
||||
local result="$(build_left_prompt)"
|
||||
[[ "$result" =~ ".*(is outside repository)+" ]] && return 1
|
||||
|
||||
assertEquals "%K{002} %F{000} master %k%F{002}%f " "$result"
|
||||
}
|
||||
|
||||
|
||||
source shunit2/shunit2
|
@ -1,220 +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"
|
||||
|
||||
P9K_HOME=$(pwd)
|
||||
### Test specific
|
||||
# Create default folder and hg init it.
|
||||
FOLDER=/tmp/powerlevel9k-test/vcs-test
|
||||
mkdir -p "${FOLDER}"
|
||||
cd $FOLDER
|
||||
|
||||
export HGUSER="Test bot <bot@example.com>"
|
||||
|
||||
hg init 1>/dev/null
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
# Go back to powerlevel9k folder
|
||||
cd "${P9K_HOME}"
|
||||
# Remove eventually created test-specific folder
|
||||
rm -fr "${FOLDER}" &>/dev/null
|
||||
# At least remove test folder completely
|
||||
rm -fr /tmp/powerlevel9k-test &>/dev/null
|
||||
unset FOLDER
|
||||
unset HGUSER
|
||||
}
|
||||
|
||||
function testColorOverridingForCleanStateWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan'
|
||||
local POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{007} %F{006} default %k%F{007}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testColorOverridingForModifiedStateWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='red'
|
||||
local POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='yellow'
|
||||
|
||||
touch testfile
|
||||
hg add testfile
|
||||
hg commit -m "test" 1>/dev/null
|
||||
echo "test" > testfile
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{003} %F{001} default ● %k%F{003}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
# There is no staging area in mercurial, therefore there are no "untracked"
|
||||
# files.. In case there are added files, we show the VCS segment with a
|
||||
# yellow background.
|
||||
# This may be improved in future versions, to be a bit more consistent with
|
||||
# the git part.
|
||||
function testAddedFilesIconWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
touch "myfile.txt"
|
||||
hg add myfile.txt
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{003} %F{000} default ● %k%F{003}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
# We don't support tagging in mercurial right now..
|
||||
function testTagIconWorks() {
|
||||
startSkipping # Skip test
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_TAG_ICON='T'
|
||||
|
||||
touch "file.txt"
|
||||
hg add file.txt
|
||||
hg commit -m "Add File" 1>/dev/null
|
||||
hg tag "v0.0.1"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000} default Tv0.0.1 %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testTagIconInDetachedHeadState() {
|
||||
startSkipping # Skip test
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_TAG_ICON='T'
|
||||
|
||||
touch "file.txt"
|
||||
hg add file.txt
|
||||
hg commit -m "Add File" &>/dev/null
|
||||
hg tag "v0.0.1"
|
||||
touch "file2.txt"
|
||||
hg add file2.txt
|
||||
hg commit -m "Add File2" &>/dev/null
|
||||
hg checkout v0.0.1 &>/dev/null
|
||||
local hash=$(hg id)
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000} ${hash} Tv0.0.1 %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testActionHintWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
touch "i-am-modified.txt"
|
||||
hg add i-am-modified.txt
|
||||
hg commit -m "Add File" &>/dev/null
|
||||
|
||||
hg clone . ../vcs-test2 &>/dev/null
|
||||
echo "xx" >> i-am-modified.txt
|
||||
hg commit -m "Modified file" &>/dev/null
|
||||
|
||||
cd ../vcs-test2
|
||||
echo "yy" >> i-am-modified.txt
|
||||
hg commit -m "Provoke conflict" 2>/dev/null
|
||||
hg pull 1>/dev/null
|
||||
hg merge --tool internal:merge >/dev/null 2>&1
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{003} %F{000} default %F{red}| merging%f %k%F{003}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testShorteningCommitHashWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_SHOW_CHANGESET=true
|
||||
local POWERLEVEL9K_CHANGESET_HASH_LENGTH='4'
|
||||
|
||||
touch "file.txt"
|
||||
hg add file.txt
|
||||
hg commit -m "Add File" 1>/dev/null
|
||||
local hash=$(hg id | head -c ${POWERLEVEL9K_CHANGESET_HASH_LENGTH})
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
# This test needs to call powerlevel9k_vcs_init, where
|
||||
# the changeset is truncated.
|
||||
powerlevel9k_vcs_init
|
||||
|
||||
assertEquals "%K{002} %F{000}${hash} default %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testShorteningCommitHashIsNotShownIfShowChangesetIsFalse() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_SHOW_CHANGESET=false
|
||||
local POWERLEVEL9K_CHANGESET_HASH_LENGTH='4'
|
||||
|
||||
touch "file.txt"
|
||||
hg add file.txt
|
||||
hg commit -m "Add File" 1>/dev/null
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
# This test needs to call powerlevel9k_vcs_init, where
|
||||
# the changeset is truncated.
|
||||
powerlevel9k_vcs_init
|
||||
|
||||
assertEquals "%K{002} %F{000} default %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testMercurialIconWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_HG_ICON='HG-Icon'
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000}HG-Icon %F{000} default %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testBookmarkIconWorks() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
local POWERLEVEL9K_VCS_BOOKMARK_ICON='B'
|
||||
hg bookmark "initial"
|
||||
|
||||
# Load Powerlevel9k
|
||||
source ${P9K_HOME}/powerlevel9k.zsh-theme
|
||||
|
||||
assertEquals "%K{002} %F{000} default Binitial %k%F{002}%f " "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
function testBranchNameScriptingVulnerability() {
|
||||
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
|
||||
echo "#!/bin/sh\n\necho 'hacked'\n" > evil_script.sh
|
||||
chmod +x evil_script.sh
|
||||
|
||||
hg branch '$(./evil_script.sh)' >/dev/null
|
||||
hg add . >/dev/null
|
||||
hg commit -m "Initial commit" >/dev/null
|
||||
|
||||
assertEquals '%K{002} %F{000} $(./evil_script.sh) %k%F{002}%f ' "$(build_left_prompt)"
|
||||
}
|
||||
|
||||
source shunit2/shunit2
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue