Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into fix-rprompt-icons-cut-off
Browse files Browse the repository at this point in the history
  • Loading branch information
ytang authored Oct 12, 2018
2 parents 24bbbfc + b16c0d5 commit a98fa7f
Show file tree
Hide file tree
Showing 60 changed files with 4,899 additions and 1,136 deletions.
84 changes: 64 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,77 @@
sudo: true
dist: trusty
language: sh

os:
- linux
- osx

osx_image: xcode9.4

addons:
apt:
packages:
- build-essential
- git
- mercurial
- subversion
- jq
- node
- golang
- ruby
- python
- python-virtualenv

before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi

env:
global:
- ZSH_DIST=$HOME/.zshdist
matrix:
# Use _ZSH_VERSION since if ZSH_VERSION is present, travis cacher thinks it
# is running in zsh and tries to use zsh specific functions.
- _ZSH_VERSION=5.5.1
- _ZSH_VERSION=5.5
- _ZSH_VERSION=5.4.2
- _ZSH_VERSION=5.4.1
- _ZSH_VERSION=5.3.1
- _ZSH_VERSION=5.3
- _ZSH_VERSION=5.2
- _ZSH_VERSION=5.1.1

cache:
directories:
- $ZSH_DIST

before_script:
- >
setup_zsh() {
dest="$ZSH_DIST/$1"
if [[ ! -d $dest/bin ]]; then
coreutils_mktemp="mktemp"
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
coreutils_mktemp="gmktemp"
fi
tmp="$(${coreutils_mktemp} --directory --tmpdir="${TMPDIR:/tmp}" zshbuild.XXXXXX)"
(
cd "$tmp" &&
curl -L http://downloads.sourceforge.net/zsh/zsh-${1}.tar.gz | tar zx &&
cd zsh-$1 &&
./configure --prefix="$dest" &&
make &&
mkdir -p "$dest" &&
make install ||
echo "Failed to build zsh-${1}!"
)
fi
export PATH="$dest/bin:$PATH"
}
- setup_zsh $_ZSH_VERSION
# Show the git version being used to test.
- "git --version"
# Show the mercurial version being used to test.
- "hg --version"
# Show the zsh version being used to test.
- "zsh --version"

install:
- "sudo apt-get update -qq"
- "sudo apt-get install -y zsh"
- "sudo chsh -s $(which zsh)"
- "sudo apt-get install -y git mercurial subversion jq node golang ruby python python-virtualenv"

script:
- test/powerlevel9k.spec
- test/functions/utilities.spec
- test/functions/colors.spec
- test/functions/icons.spec
- test/segments/command_execution_time.spec
- test/segments/dir.spec
- test/segments/rust_version.spec
- test/segments/go_version.spec
- test/segments/vcs.spec
- test/segments/kubecontext.spec
- test/segments/laravel_version.spec
- test/segments/status.spec
- test/suite.spec
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## 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.
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ variables to your `~/.zshrc`.

| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_LEFT_PROMPT_ELEMENTS`|`(context dir rbenv vcs)`|Segment list for left prompt|
|`POWERLEVEL9K_LEFT_PROMPT_ELEMENTS`|`(context dir vcs)`|Segment list for left prompt|
|`POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS`|`(status root_indicator background_jobs history time)`|Segment list for right prompt|


The table above shows the default values, so if you wanted to set these
variables manually, you would put the following in
your `~/.zshrc`:
```zsh
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs)
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time)
```
#### Available Prompt Segments
Expand Down Expand Up @@ -374,7 +374,7 @@ The `date` segment shows the current system date.

| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_DATE_FORMAT`|`%D{%d.%m.%y}`|[ZSH time format](http://zsh.sourceforge.net/Doc/Release Prompt-Expansion.html) to use in this segment.|
|`POWERLEVEL9K_DATE_FORMAT`|`%D{%d.%m.%y}`|[ZSH time format](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Date-and-time) to use in this segment.|

##### dir

Expand All @@ -386,12 +386,14 @@ Powerline" fonts, there are additional glyphs, as well:
| None | None | ![](https://cloud.githubusercontent.com/assets/1544760/12183451/40ec4016-b58f-11e5-9b9e-74e2b2f0b8b3.png) | At the root of your home folder |
| None | None | ![](https://cloud.githubusercontent.com/assets/1544760/12369315/8a5d762c-bbf5-11e5-8a20-ca1179f48d6c.png) | Within a subfolder of your home directory |
| None | None | ![](https://cloud.githubusercontent.com/assets/1544760/12183452/40f79286-b58f-11e5-9b8c-ed1343a07b08.png) | Outside of your home folder |
| None | None || Within the `/etc` directory |

To turn off these icons you could set these variables to an empty string.
```zsh
POWERLEVEL9K_HOME_ICON=''
POWERLEVEL9K_HOME_SUB_ICON=''
POWERLEVEL9K_FOLDER_ICON=''
POWERLEVEL9K_ETC_ICON=''
```
You can limit the output to a certain length by truncating long paths.
Customizations available are:
Expand All @@ -411,7 +413,7 @@ Customizations available are:
|`truncate_from_right`|Just leaves the beginning of a folder name untouched. E.g. your folders will be truncated like so: "/ro../Pr../office". How many characters will be untouched is controlled by `POWERLEVEL9K_SHORTEN_DIR_LENGTH`.|
|`truncate_absolute`|Truncates everything exept the last few characters in the path. E.g. if you are in a folder named "~/Projects/powerlevel9k" and you have set `POWERLEVEL9K_SHORTEN_DIR_LENGTH=3`, you will get "..l9k".|
|`truncate_to_last`|Truncates everything before the last folder in the path.|
|`truncate_to_first_and_last|Truncate middle directories from the path. How many directories will be untouched is controlled by POWERLEVEL9K_SHORTER_DIR_LENGTH. E.g. if you are in a folder named "~/Projects/powerlevel9k" and you have set `POWERLEVEL9K_SHORTEN_DIR_LENGTH=1`, you will get "~/../powerlevel9k".||
|`truncate_to_first_and_last`|Truncate middle directories from the path. How many directories will be untouched is controlled by POWERLEVEL9K_SHORTER_DIR_LENGTH. E.g. if you are in a folder named "~/Projects/powerlevel9k" and you have set `POWERLEVEL9K_SHORTEN_DIR_LENGTH=1`, you will get "~/../powerlevel9k".||
|`truncate_to_unique`|Parse all parent path components and truncate them to the shortest unique length. If you copy & paste the result to a shell, after hitting `TAB` it should expand to the original path unambiguously.|
|`truncate_with_package_name`|Search for a `package.json` or `composer.json` and prints the `name` field to abbreviate the directory path. The precedence and/or files could be set by `POWERLEVEL9K_DIR_PACKAGE_FILES=(package.json composer.json)`. If you have [jq](https://stedolan.github.io/jq/) installed, it will dramatically improve the speed of this strategy.|
|`truncate_with_folder_marker`|Search for a file that is specified by `POWERLEVEL9K_SHORTEN_FOLDER_MARKER` and truncate everything before that (if found, otherwise stop on $HOME and ROOT).|
Expand Down
44 changes: 32 additions & 12 deletions TESTS.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
# Structure
# Tests

The Unit-Tests do not follow exactly the file structure of Powerlevel9k itself.
## Automated Tests

## Basic 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).

Basic Tests belong in `test/powerlevel9k.spec` if they test basic functionality of
Powerlevel9k itself. Basic functions from the `functions` directory have their
Tests in separate files under `test/functions`.
### Installation

## Segment Tests
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`.

These Tests tend to be more complex in setup than the basic tests. To avoid ending
up in a huge single file, there is one file per segment in `test/segments`.
### Executing tests

# Manual Testing
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
### Docker

This is the easiest to use _if_ you have Docker already installed and running.

Expand All @@ -42,7 +62,7 @@ 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
### 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!
Expand Down
Loading

0 comments on commit a98fa7f

Please sign in to comment.