parent
3933e1b17b
commit
c9291ffcbf
45 changed files with 19 additions and 5229 deletions
@ -1,5 +1,5 @@ |
|||||||
# this rg command will get a list of files that are not in gitignore or similar |
# this rg command will get a list of files that are not in gitignore or similar |
||||||
export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git" |
export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git --exclude .PlayOnLinux --exclude \"PlayOnLinux\'s virtual drives\"" |
||||||
export FZF_DEFAULT_OPTS="--preview '[[ \$(file -L --mime {}) =~ binary ]] && echo {} is a binary file || ( bat --style=numbers --color=always {} || cat {}) 2> /dev/null | head -500'" |
export FZF_DEFAULT_OPTS="--preview '[[ \$(file -L --mime {}) =~ binary ]] && echo {} is a binary file || ( bat --style=numbers --color=always {} || cat {}) 2> /dev/null | head -500'" |
||||||
export FZF_CTRL_R_OPTS="--no-preview" |
export FZF_CTRL_R_OPTS="--no-preview" |
||||||
# this is the argument completeion optionm, use the same command |
# this is the argument completeion optionm, use the same command |
@ -0,0 +1,12 @@ |
|||||||
|
# Use lf to switch directories and bind it to ctrl-o |
||||||
|
lfcd () { |
||||||
|
tmp="$(mktemp)" |
||||||
|
lf -last-dir-path="$tmp" "$@" |
||||||
|
if [ -f "$tmp" ]; then |
||||||
|
dir="$(cat "$tmp")" |
||||||
|
rm -f "$tmp" |
||||||
|
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" |
||||||
|
fi |
||||||
|
} |
||||||
|
alias lf="lfcd" |
||||||
|
bindkey -s '^o' 'lf\n' |
@ -1,144 +0,0 @@ |
|||||||
#compdef pass |
|
||||||
#autoload |
|
||||||
|
|
||||||
# Copyright (C) 2012 - 2014: |
|
||||||
# Johan Venant <jvenant@invicem.pro> |
|
||||||
# Brian Mattern <rephorm@rephorm.com> |
|
||||||
# Jason A. Donenfeld <Jason@zx2c4.com>. |
|
||||||
# All Rights Reserved. |
|
||||||
# This file is licensed under the GPLv2+. Please see COPYING for more information. |
|
||||||
|
|
||||||
|
|
||||||
# If you use multiple repositories, you can configure completion like this: |
|
||||||
# |
|
||||||
# compdef _pass workpass |
|
||||||
# zstyle ':completion::complete:workpass::' prefix "$HOME/work/pass" |
|
||||||
# workpass() { |
|
||||||
# PASSWORD_STORE_DIR=$HOME/work/pass pass $@ |
|
||||||
# } |
|
||||||
|
|
||||||
|
|
||||||
_pass () { |
|
||||||
local cmd |
|
||||||
if (( CURRENT > 2)); then |
|
||||||
cmd=${words[2]} |
|
||||||
# Set the context for the subcommand. |
|
||||||
curcontext="${curcontext%:*:*}:pass-$cmd" |
|
||||||
# Narrow the range of words we are looking at to exclude `pass' |
|
||||||
(( CURRENT-- )) |
|
||||||
shift words |
|
||||||
# Run the completion for the subcommand |
|
||||||
case "${cmd}" in |
|
||||||
init) |
|
||||||
_arguments : \ |
|
||||||
"-p[gpg-id will only be applied to this subfolder]" \ |
|
||||||
"--path[gpg-id will only be applied to this subfolder]" |
|
||||||
_pass_complete_keys |
|
||||||
;; |
|
||||||
ls|list|edit) |
|
||||||
_pass_complete_entries_with_subdirs |
|
||||||
;; |
|
||||||
insert) |
|
||||||
_arguments : \ |
|
||||||
"-e[echo password to console]" \ |
|
||||||
"--echo[echo password to console]" \ |
|
||||||
"-m[multiline]" \ |
|
||||||
"--multiline[multiline]" |
|
||||||
_pass_complete_entries_with_subdirs |
|
||||||
;; |
|
||||||
generate) |
|
||||||
_arguments : \ |
|
||||||
"-n[don't include symbols in password]" \ |
|
||||||
"--no-symbols[don't include symbols in password]" \ |
|
||||||
"-c[copy password to the clipboard]" \ |
|
||||||
"--clip[copy password to the clipboard]" \ |
|
||||||
"-f[force overwrite]" \ |
|
||||||
"--force[force overwrite]" \ |
|
||||||
"-i[replace first line]" \ |
|
||||||
"--in-place[replace first line]" |
|
||||||
_pass_complete_entries_with_subdirs |
|
||||||
;; |
|
||||||
cp|copy|mv|rename) |
|
||||||
_arguments : \ |
|
||||||
"-f[force rename]" \ |
|
||||||
"--force[force rename]" |
|
||||||
_pass_complete_entries_with_subdirs |
|
||||||
;; |
|
||||||
rm) |
|
||||||
_arguments : \ |
|
||||||
"-f[force deletion]" \ |
|
||||||
"--force[force deletion]" \ |
|
||||||
"-r[recursively delete]" \ |
|
||||||
"--recursive[recursively delete]" |
|
||||||
_pass_complete_entries_with_subdirs |
|
||||||
;; |
|
||||||
git) |
|
||||||
local -a subcommands |
|
||||||
subcommands=( |
|
||||||
"init:Initialize git repository" |
|
||||||
"push:Push to remote repository" |
|
||||||
"pull:Pull from remote repository" |
|
||||||
"config:Show git config" |
|
||||||
"log:Show git log" |
|
||||||
"reflog:Show git reflog" |
|
||||||
) |
|
||||||
_describe -t commands 'pass git' subcommands |
|
||||||
;; |
|
||||||
show|*) |
|
||||||
_pass_cmd_show |
|
||||||
;; |
|
||||||
esac |
|
||||||
else |
|
||||||
local -a subcommands |
|
||||||
subcommands=( |
|
||||||
"init:Initialize new password storage" |
|
||||||
"ls:List passwords" |
|
||||||
"find:Find password files or directories based on pattern" |
|
||||||
"grep:Search inside decrypted password files for matching pattern" |
|
||||||
"show:Decrypt and print a password" |
|
||||||
"insert:Insert a new password" |
|
||||||
"generate:Generate a new password using pwgen" |
|
||||||
"edit:Edit a password with \$EDITOR" |
|
||||||
"mv:Rename the password" |
|
||||||
"cp:Copy the password" |
|
||||||
"rm:Remove the password" |
|
||||||
"git:Call git on the password store" |
|
||||||
"version:Output version information" |
|
||||||
"help:Output help message" |
|
||||||
) |
|
||||||
_describe -t commands 'pass' subcommands |
|
||||||
_arguments : \ |
|
||||||
"--version[Output version information]" \ |
|
||||||
"--help[Output help message]" |
|
||||||
_pass_cmd_show |
|
||||||
fi |
|
||||||
} |
|
||||||
|
|
||||||
_pass_cmd_show () { |
|
||||||
_arguments : \ |
|
||||||
"-c[put it on the clipboard]" \ |
|
||||||
"--clip[put it on the clipboard]" |
|
||||||
_pass_complete_entries |
|
||||||
} |
|
||||||
_pass_complete_entries_helper () { |
|
||||||
local IFS=$'\n' |
|
||||||
local prefix |
|
||||||
zstyle -s ":completion:${curcontext}:" prefix prefix || prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}" |
|
||||||
_values -C 'passwords' ${$(find -L "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print 2>/dev/null | sed -e "s#${prefix}/\{0,1\}##" -e 's#\.gpg##' -e 's#\\#\\\\#' | sort):-""} |
|
||||||
} |
|
||||||
|
|
||||||
_pass_complete_entries_with_subdirs () { |
|
||||||
_pass_complete_entries_helper |
|
||||||
} |
|
||||||
|
|
||||||
_pass_complete_entries () { |
|
||||||
_pass_complete_entries_helper -type f |
|
||||||
} |
|
||||||
|
|
||||||
_pass_complete_keys () { |
|
||||||
local IFS=$'\n' |
|
||||||
# Extract names and email addresses from gpg --list-keys |
|
||||||
_values 'gpg keys' $(gpg2 --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d') |
|
||||||
} |
|
||||||
|
|
||||||
_pass |
|
@ -1 +0,0 @@ |
|||||||
test-vm/.vagrant |
|
@ -1,3 +0,0 @@ |
|||||||
[submodule "shunit2"] |
|
||||||
path = shunit2 |
|
||||||
url = https://github.com/kward/shunit2.git |
|
@ -1,30 +0,0 @@ |
|||||||
sudo: true |
|
||||||
dist: trusty |
|
||||||
language: sh |
|
||||||
addons: |
|
||||||
apt: |
|
||||||
packages: |
|
||||||
- build-essential |
|
||||||
|
|
||||||
before_script: |
|
||||||
# Show the git version being used to test. |
|
||||||
- "git --version" |
|
||||||
# Show the zsh version being used to test. |
|
||||||
- "zsh --version" |
|
||||||
|
|
||||||
install: |
|
||||||
- "sudo apt-get update -qq" |
|
||||||
- "sudo apt-get install -y zsh" |
|
||||||
- "sudo chsh -s $(which zsh)" |
|
||||||
- "sudo apt-get install -y git mercurial subversion jq node golang ruby python python-virtualenv" |
|
||||||
|
|
||||||
script: |
|
||||||
- test/powerlevel9k.spec |
|
||||||
- test/functions/utilities.spec |
|
||||||
- test/functions/colors.spec |
|
||||||
- test/functions/icons.spec |
|
||||||
- test/segments/command_execution_time.spec |
|
||||||
- test/segments/dir.spec |
|
||||||
- test/segments/rust_version.spec |
|
||||||
- test/segments/go_version.spec |
|
||||||
- test/segments/vcs.spec |
|
@ -1,362 +0,0 @@ |
|||||||
## v0.6.3 |
|
||||||
|
|
||||||
- Fixed susceptibility to [pw3nage exploit](https://github.com/njhartwell/pw3nage). |
|
||||||
- Added support for Android |
|
||||||
- The abbreviation for $HOME is now configurable (doesn't have to be `~`). |
|
||||||
- Fixed colorization of VCS segment in Subversion repos. |
|
||||||
- Improved handling of symlinks in installation paths. |
|
||||||
|
|
||||||
## v0.6.2 |
|
||||||
|
|
||||||
- Fixed some issues with the new `nerdfont-fontconfig` option. |
|
||||||
- Fixed typo in README. |
|
||||||
- The `get_icon_names` function can now print sorted output, and show which |
|
||||||
icons users have overridden. |
|
||||||
- Added a FreeBSD VM for testing. |
|
||||||
|
|
||||||
### Add debug script for iTerm2 issues |
|
||||||
|
|
||||||
A new script `debug/iterm.zsh` was added for easier spotting problems with your iTerm2 configuration. |
|
||||||
|
|
||||||
### Add debug script for font issues |
|
||||||
|
|
||||||
A new script `debug/font-issues.zsh` was added, so that problems with your font could be spotted easier. |
|
||||||
|
|
||||||
### `ram` changes |
|
||||||
|
|
||||||
The `ram` segment now shows the available ram instead of free. |
|
||||||
|
|
||||||
## v0.6.0 |
|
||||||
|
|
||||||
- Fixed a bug where the tag display was broken on detached HEADs. |
|
||||||
- Fixed a bug where SVN detection sometimes failed. |
|
||||||
- Fixed the `load` and `ram` segments for BSD. |
|
||||||
- Fixed code-points that changed in Awesome fonts. |
|
||||||
- Fixed display of "OK_ICON" in `status` segment in non-verbose mode. |
|
||||||
- Fixed an issue where dir name truncation that was very short sometimes failed. |
|
||||||
- Speed & accuracy improvements to the battery segment. |
|
||||||
- Added Github syntax highlighting to README. |
|
||||||
- Various documentation cleanup. |
|
||||||
|
|
||||||
### New Font Option: nerd-fonts |
|
||||||
|
|
||||||
There is now an option to use [nerd-fonts](https://github.com/ryanoasis/nerd-fonts) with P9k. Simply configure the `nerdfont-fontconfig`, and you'll be set! |
|
||||||
|
|
||||||
### `vcs` changes |
|
||||||
|
|
||||||
The VCS segment can now display icons for remote repo hosting services, including Github, Gitlab, and 'other'. |
|
||||||
|
|
||||||
### `dir` changes |
|
||||||
|
|
||||||
Added an option to configure the path separator. If you want something |
|
||||||
else than an ordinary slash, you could set |
|
||||||
`POWERLEVEL9K_DIR_PATH_SEPARATOR` to whatever you want. |
|
||||||
|
|
||||||
#### `truncate_with_package_name` now searches for `composer.json` as well |
|
||||||
|
|
||||||
Now `composer.json` files are searched as well. By default `package.json` still takes |
|
||||||
precedence. If you want to change that, set `POWERLEVEL9K_DIR_PACKAGE_FILES=(composer.json package.json)`. |
|
||||||
|
|
||||||
### New segment `command_execution_time` added |
|
||||||
|
|
||||||
Shows the duration a command needed to run. By default only durations over 3 seconds |
|
||||||
are shown (can be adjusted by setting POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD). |
|
||||||
|
|
||||||
### New segment `dir_writable` added |
|
||||||
|
|
||||||
This segment displays a lock icon if your user has no write permissions in the current folder. |
|
||||||
|
|
||||||
### New segment `disk_usage` added |
|
||||||
|
|
||||||
This segment will show the usage level of your current partition. |
|
||||||
|
|
||||||
### New segment `public_ip` added |
|
||||||
|
|
||||||
Fetches your Public IP (using ident.me) and displays it in your prompt. |
|
||||||
|
|
||||||
### New segment `swift_version` added |
|
||||||
|
|
||||||
This segment displays the version of Swift that is installed / in your path. |
|
||||||
|
|
||||||
### New segment `detect_virt` added |
|
||||||
|
|
||||||
Detects and reports if you are in a virtualized session using `systemd`. |
|
||||||
|
|
||||||
## v0.5.0 |
|
||||||
|
|
||||||
### `load` and `ram` changes |
|
||||||
|
|
||||||
These two segments now support BSD. |
|
||||||
|
|
||||||
### `vcs` changes |
|
||||||
|
|
||||||
- We implemented a huge speed improvement for this segment. |
|
||||||
- Now this segment supports Subversion repositories. |
|
||||||
- Add ability to hide tags by setting `POWERLEVEL9K_VCS_HIDE_TAGS` to true. |
|
||||||
|
|
||||||
## `anaconda` changes |
|
||||||
|
|
||||||
Speed improvements for `anaconda` segment. |
|
||||||
|
|
||||||
## v0.4.0 |
|
||||||
|
|
||||||
### Development changes |
|
||||||
|
|
||||||
From now on, development makes use of a CI system "travis". |
|
||||||
|
|
||||||
### `vcs` changes |
|
||||||
|
|
||||||
The default state was renamed to `clean`. If you overrode foreground |
|
||||||
or background color in the past, you need to rename your variables to: |
|
||||||
|
|
||||||
```zsh |
|
||||||
POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan' |
|
||||||
POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white' |
|
||||||
``` |
|
||||||
|
|
||||||
Additionaly the vcs segment now has an `untracked` state which |
|
||||||
indicates that you have untracked files in your repository. |
|
||||||
|
|
||||||
The foreground color of actionformat is now configurable via: |
|
||||||
```zsh |
|
||||||
POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND='green' |
|
||||||
``` |
|
||||||
|
|
||||||
Also, the vcs segment uses the foreground color it was configured to. |
|
||||||
That said, the variables `POWERLEVEL9K_VCS_FOREGROUND` and |
|
||||||
`POWERLEVEL9K_VCS_DARK_FOREGROUND` are no longer used. Instead use |
|
||||||
the proper variable `POWERLEVEL9K_VCS_<STATE>_FOREGROUND` to change |
|
||||||
foreground color. |
|
||||||
|
|
||||||
### `dir` Shortening Strategies |
|
||||||
|
|
||||||
There is now a path shortening strategy that will use the `package.json` file to |
|
||||||
shorten your directory path. See the documentation for the `dir` segment for more |
|
||||||
details. |
|
||||||
|
|
||||||
Also, the shorten delimiter was changed to an unicode ellipsis. It is configurable |
|
||||||
via `POWERLEVEL9K_SHORTEN_DELIMITER`. |
|
||||||
|
|
||||||
### `rbenv` changes |
|
||||||
|
|
||||||
The `rbenv` segment now makes use of the full rbenv command, so the correct |
|
||||||
ruby version is now shown if it differs from the globally one. |
|
||||||
|
|
||||||
### `node`, `nvm` Segments |
|
||||||
|
|
||||||
Improvements to speed / reliability. |
|
||||||
|
|
||||||
### `ram` changes |
|
||||||
|
|
||||||
The `ram` segment was split up into `ram` and `swap`. The |
|
||||||
`POWERLEVEL9K_RAM_ELEMENTS` variable is obsolete. |
|
||||||
|
|
||||||
### New segment `swap` added |
|
||||||
|
|
||||||
Due to the split up of the ram segment, this one was created. It |
|
||||||
shows the currently used swap size. |
|
||||||
|
|
||||||
### New segment `nodeenv` added |
|
||||||
|
|
||||||
Added new `nodeenv` segment that shows the currently used node environment. |
|
||||||
|
|
||||||
### New segment `aws_eb_env` added |
|
||||||
|
|
||||||
This segment displays the current Elastic Beanstalk environment. |
|
||||||
|
|
||||||
### New segment `chruby` added |
|
||||||
|
|
||||||
Added new `chruby` segment to support this version manager. |
|
||||||
|
|
||||||
### New segment `docker_machine` added |
|
||||||
|
|
||||||
Added new `docker_machine` segment that will show your Docker machine. |
|
||||||
|
|
||||||
### New segment `anaconda` added |
|
||||||
|
|
||||||
A new segment `anaconda` was added that shows the current used |
|
||||||
anaconda environment. |
|
||||||
|
|
||||||
## New segment `pyenv` added |
|
||||||
|
|
||||||
This segment shows your active python version as reported by `pyenv`. |
|
||||||
|
|
||||||
|
|
||||||
## v0.3.2 |
|
||||||
|
|
||||||
### `vcs` changes |
|
||||||
|
|
||||||
A new state `UNTRACKED` was added to the `vcs` segment. So we now |
|
||||||
have 3 states for repositories: `UNTRACKED`, `MODIFIED`, and the |
|
||||||
default state. The `UNTRACKED` state is active when there are files |
|
||||||
in the repository directory which have not been added to the repo |
|
||||||
(the same as when the `+` icon appears). The default color for the |
|
||||||
`UNTRACKED` state is now yellow, and the default color for the |
|
||||||
`MODIFIED` state is now read, but those colors can be changed by |
|
||||||
setting these variables, for example: |
|
||||||
|
|
||||||
```zsh |
|
||||||
POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='black' |
|
||||||
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='white' |
|
||||||
POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='green' |
|
||||||
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='blue' |
|
||||||
``` |
|
||||||
|
|
||||||
## v0.3.1 |
|
||||||
|
|
||||||
### `dir` changes |
|
||||||
|
|
||||||
A new state `HOME_SUBFOLDER` was added. So if you want to overwrite |
|
||||||
colors for this segment, also set this variables: |
|
||||||
```zsh |
|
||||||
POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND='black' |
|
||||||
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND='white' |
|
||||||
``` |
|
||||||
|
|
||||||
### `background_jobs` changes |
|
||||||
Now displays the number of background jobs if there's more than 1. |
|
||||||
You can disable it by setting : |
|
||||||
```zsh |
|
||||||
POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false |
|
||||||
``` |
|
||||||
|
|
||||||
## v0.3.0 |
|
||||||
|
|
||||||
### Introduced "visual identifiers" to the segments |
|
||||||
|
|
||||||
Now almost every segment can have a visual identifier, which is an |
|
||||||
icon whose color could be adjusted by users. |
|
||||||
|
|
||||||
### Added ability for "joined" segments |
|
||||||
|
|
||||||
You can now merge segments together by suffixing the segment name with "_joined". |
|
||||||
For Developers: Be aware that the order of parameters in left/right_prompt_segment |
|
||||||
has changed. Now a boolean parameter must be set as second parameter (true if joined). |
|
||||||
|
|
||||||
### `dir` changes |
|
||||||
|
|
||||||
This segment now has "state", which means you now can change the colors seperatly |
|
||||||
depending if you are in your homefolder or not. |
|
||||||
Your variables for that should now look like: |
|
||||||
```zsh |
|
||||||
POWERLEVEL9K_DIR_HOME_BACKGROUND='green' |
|
||||||
POWERLEVEL9K_DIR_HOME_FOREGROUND='cyan' |
|
||||||
POWERLEVEL9K_DIR_DEFAULT_BACKGROUND='red' |
|
||||||
POWERLEVEL9K_DIR_DEFAULT_FOREGROUND='yellow' |
|
||||||
``` |
|
||||||
|
|
||||||
### `status` changes |
|
||||||
|
|
||||||
The `status` segment was split up into three segments. `background_jobs` prints |
|
||||||
an icon if there are background jobs. `root_indicator` prints an icon if the user |
|
||||||
is root. The `status` segment focuses now on the status only. |
|
||||||
The `status` segment also now has "state". If you want to overwrite the colors, |
|
||||||
you have to add the state to your variables: |
|
||||||
```zsh |
|
||||||
POWERLEVEL9K_STATUS_ERROR_BACKGROUND='green' |
|
||||||
POWERLEVEL9K_STATUS_ERROR_FOREGROUND='cyan' |
|
||||||
POWERLEVEL9K_STATUS_OK_BACKGROUND='red' |
|
||||||
POWERLEVEL9K_STATUS_OK_FOREGROUND='yellow' |
|
||||||
``` |
|
||||||
|
|
||||||
### New segment `custom_command` added |
|
||||||
|
|
||||||
A new segment that allows users to define a custom command was added. |
|
||||||
|
|
||||||
### `virtualenv` changes |
|
||||||
|
|
||||||
This segment now respects `VIRTUAL_ENV_DISABLE_PROMPT`. If this variable is set |
|
||||||
to `true`, the segments does not get rendered. |
|
||||||
|
|
||||||
### `load` changes |
|
||||||
|
|
||||||
The `load` segement was split and a new segment `ram` was extracted. This new |
|
||||||
segment is able to show the free ram and used swap. |
|
||||||
|
|
||||||
### `vcs` changes |
|
||||||
|
|
||||||
This prompt uses the `VCS_INFO` subsystem by ZSH. From now on this subsystem |
|
||||||
is only invoked if a `vcs` segment was configured. |
|
||||||
|
|
||||||
### `rvm` changes |
|
||||||
|
|
||||||
This segment now does not invoke RVM directly anymore. Instead, is relys on the |
|
||||||
circumstance that RVM was invoked beforehand and just reads the environment |
|
||||||
variables '$GEM_HOME' and '$MY_RUBY_HOME'. It also now displays the used gemset. |
|
||||||
|
|
||||||
### New segment `battery` added |
|
||||||
|
|
||||||
A new segment that shows the battery status of your laptop was added. |
|
||||||
|
|
||||||
### New segment `go_version` added |
|
||||||
|
|
||||||
This segment shows the GO version. |
|
||||||
|
|
||||||
### New segment `nvm` added |
|
||||||
|
|
||||||
This segment shows your NodeJS version by using NVM (and if it is not 'default'). |
|
||||||
|
|
||||||
### New segment `todo` added |
|
||||||
|
|
||||||
This segment shows your ToDos from [todo.sh](http://todotxt.com/). |
|
||||||
|
|
||||||
### New segment `rust_version` added |
|
||||||
|
|
||||||
This segment shows your local rust version. |
|
||||||
|
|
||||||
## v0.2.0 |
|
||||||
|
|
||||||
### `longstatus` is now `status` |
|
||||||
|
|
||||||
The segments got merged together. To show the segment only if an error occurred, |
|
||||||
set `POWERLEVEL9K_STATUS_VERBOSE=false` (this is the same behavior as the old |
|
||||||
`status` segment. |
|
||||||
|
|
||||||
### Icon overriding mechanism added |
|
||||||
|
|
||||||
All icons can now be overridden by setting a variable named by the internal icon |
|
||||||
name. You can get a full list of icon name by calling `get_icon_names`. |
|
||||||
|
|
||||||
### Same color segements get visual separator |
|
||||||
|
|
||||||
This separator can be controlled by setting `POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR` |
|
||||||
or `POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR`. By default this separator is |
|
||||||
printed in the foreground color. |
|
||||||
|
|
||||||
### `dir` segment has different strategies for truncation |
|
||||||
|
|
||||||
Now you can choose between `truncate_middle` or `truncate_from_right` by setting |
|
||||||
`POWERLEVEL9K_SHORTEN_STRATEGY`. Default behavior is unchanged (truncate whole |
|
||||||
directories). `POWERLEVEL9K_SHORTEN_DIR_LENGTH` can be used to influence how |
|
||||||
much will be truncated (either direcories or chars). |
|
||||||
|
|
||||||
### New segment `ip` added |
|
||||||
|
|
||||||
This segment shows your internal IP address. You can define which interfaces IP |
|
||||||
will be shown by specifying it via `POWERLEVEL9K_IP_INTERFACE`. |
|
||||||
|
|
||||||
### New segment `load` added |
|
||||||
|
|
||||||
This segment shows your computers 5min load average. |
|
||||||
|
|
||||||
### New segment `os_icon` added |
|
||||||
|
|
||||||
This segment shows a little indicator which OS you are running. |
|
||||||
|
|
||||||
### New segment `php_version` added |
|
||||||
|
|
||||||
This segment shows your PHP version. |
|
||||||
|
|
||||||
### New segment `vi_mode` added |
|
||||||
|
|
||||||
This segment gives you a hint in which VI-mode you currently are. This |
|
||||||
segment requires a proper configured VI-mode. |
|
||||||
|
|
||||||
### Added the ability to have empty left or right prompts |
|
||||||
|
|
||||||
By setting the according variable to an empty array, the left or right |
|
||||||
prompt will be empty. |
|
||||||
|
|
||||||
## v0.1.0 |
|
||||||
|
|
||||||
This is the first release |
|
@ -1,20 +0,0 @@ |
|||||||
Copyright (c) 2014-2017 Ben Hilburn <bhilburn@gmail.com> |
|
||||||
|
|
||||||
MIT LICENSE |
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of |
|
||||||
this software and associated documentation files (the "Software"), to deal in |
|
||||||
the Software without restriction, including without limitation the rights to |
|
||||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
|
||||||
the Software, and to permit persons to whom the Software is furnished to do so, |
|
||||||
subject to the following conditions: |
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all |
|
||||||
copies or substantial portions of the Software. |
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
|
||||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|
||||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
|
||||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
||||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
@ -1,22 +0,0 @@ |
|||||||
# Structure |
|
||||||
|
|
||||||
The Unit-Tests do not follow exactly the file structure of Powerlevel9k itself. |
|
||||||
|
|
||||||
## Basic Tests |
|
||||||
|
|
||||||
Basic Tests belong in `test/powerlevel9k.spec` if they test basic functionality of |
|
||||||
Powerlevel9k itself. Basic functions from the `functions` directory have their |
|
||||||
Tests in separate files under `test/functions`. |
|
||||||
|
|
||||||
## Segment Tests |
|
||||||
|
|
||||||
These Tests tend to be more complex in setup than the basic tests. To avoid ending |
|
||||||
up in a huge single file, there is one file per segment in `test/segments`. |
|
||||||
|
|
||||||
# Test-VMs |
|
||||||
|
|
||||||
If unit tests are not sufficient (e.g. you have an issue with your prompt that |
|
||||||
occurs only in a specific ZSH framework), then you could use our Test-VMs! |
|
||||||
Currently there are two test VMs. `test-vm` is an Ubuntu machine with several |
|
||||||
pre-installed ZSH frameworks. And there is `test-bsd-vm` which is a FreeBSD! |
|
||||||
For how to run the machines see [here](test-vm/README.md). |
|
@ -1,182 +0,0 @@ |
|||||||
#!/usr/bin/env zsh |
|
||||||
#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 |
|
||||||
|
|
||||||
# Taken from NeoFetch (slightly modified) |
|
||||||
get_term() { |
|
||||||
local term |
|
||||||
# If function was run, stop here. |
|
||||||
#((term_run == 1)) && return |
|
||||||
|
|
||||||
# Workaround for macOS systems that |
|
||||||
# don't support the block below. |
|
||||||
case "$TERM_PROGRAM" in |
|
||||||
"iTerm.app") term="iTerm2" ;; |
|
||||||
"Terminal.app") term="Apple Terminal" ;; |
|
||||||
"Hyper") term="HyperTerm" ;; |
|
||||||
*) term="${TERM_PROGRAM/\.app}" ;; |
|
||||||
esac |
|
||||||
|
|
||||||
# Check $PPID for terminal emulator. |
|
||||||
while [[ -z "$term" ]]; do |
|
||||||
parent="$(get_ppid "$parent")" |
|
||||||
name="$(get_process_name "$parent")" |
|
||||||
|
|
||||||
case "${name// }" in |
|
||||||
"${SHELL/*\/}" | *"sh" | "tmux"* | "screen" | "su"*) ;; |
|
||||||
"login"* | *"Login"* | "init" | "(init)") term="$(tty)" ;; |
|
||||||
"ruby" | "1" | "systemd" | "sshd"* | "python"* | "USER"*"PID"*) break ;; |
|
||||||
"gnome-terminal-") term="gnome-terminal" ;; |
|
||||||
*) term="${name##*/}" ;; |
|
||||||
esac |
|
||||||
done |
|
||||||
|
|
||||||
# Log that the function was run. |
|
||||||
#term_run=1 |
|
||||||
|
|
||||||
echo "${term}" |
|
||||||
} |
|
||||||
|
|
||||||
get_term_font() { |
|
||||||
local term="${1}" |
|
||||||
#((term_run != 1)) && get_term |
|
||||||
|
|
||||||
case "$term" in |
|
||||||
"alacritty"*) |
|
||||||
term_font="$(awk -F ':|#' '/normal:/ {getline; print}' "${XDG_CONFIG_HOME}/alacritty/alacritty.yml")" |
|
||||||
term_font="${term_font/*family:}" |
|
||||||
term_font="${term_font/$'\n'*}" |
|
||||||
term_font="${term_font/\#*}" |
|
||||||
;; |
|
||||||
|
|
||||||
"Apple_Terminal") |
|
||||||
term_font="$(osascript -e 'tell application "Terminal" to font name of window frontmost')" |
|
||||||
;; |
|
||||||
"iTerm2") |
|
||||||
# Unfortunately the profile name is not unique, but it seems to be the only thing |
|
||||||
# that identifies an active profile. There is the "id of current session of current window" |
|
||||||
# thou, but that does not match to a guid in the plist. |
|
||||||
# So, be warned! Collisions may occur! |
|
||||||
# See: https://groups.google.com/forum/#!topic/iterm2-discuss/0tO3xZ4Zlwg |
|
||||||
# and: https://gitlab.com/gnachman/iterm2/issues/5586 |
|
||||||
local currentProfileName=$(osascript -e 'tell application "iTerm2" to profile name of current session of current window') |
|
||||||
|
|
||||||
# Warning: Dynamic profiles are not taken into account here! |
|
||||||
# https://www.iterm2.com/documentation-dynamic-profiles.html |
|
||||||
|
|
||||||
local nonAsciiFont |
|
||||||
|
|
||||||
# Count Guids in "New Bookmarks"; they should be unique |
|
||||||
local profilesCount=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:" ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null | grep -c "Guid") |
|
||||||
for idx in $(seq 0 "${profilesCount}"); do |
|
||||||
local profileName=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Name:" ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null) |
|
||||||
if [[ "${profileName}" == "${currentProfileName}" ]]; then |
|
||||||
# "Normal Font" |
|
||||||
term_font=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Normal\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist) |
|
||||||
|
|
||||||
# Font for non-ascii characters |
|
||||||
# Only check for a different non-ascii font, if the user checked |
|
||||||
# the "use a different font for non-ascii text" switch. |
|
||||||
local useDifferentFont=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Use\ Non-ASCII\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist) |
|
||||||
if [[ "$useDifferentFont" == "true" ]]; then |
|
||||||
local nonAsciiFont=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Non\ Ascii\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist) |
|
||||||
if [[ "$term_font" != "$nonAsciiFont" ]]; then |
|
||||||
term_font="$term_font (normal) / $nonAsciiFont (non-ascii)" |
|
||||||
fi |
|
||||||
fi |
|
||||||
fi |
|
||||||
done |
|
||||||
;; |
|
||||||
|
|
||||||
"deepin-terminal"*) |
|
||||||
term_font="$(awk -F '=' '/font=/ {a=$2} /font_size/ {b=$2} END{print a " " b}' "${XDG_CONFIG_HOME}/deepin/deepin-terminal/config.conf")" |
|
||||||
;; |
|
||||||
|
|
||||||
"Hyper"*) |
|
||||||
term_font="$(awk -F "," '/fontFamily/ {a=$1} END{print a}' "${HOME}/.hyper.js" | awk -F "'" '{a=$2} END{print a}')" |
|
||||||
;; |
|
||||||
|
|
||||||
"konsole"*) |
|
||||||
# Get Process ID of current konsole window / tab |
|
||||||
child="$(get_ppid "$$")" |
|
||||||
|
|
||||||
konsole_instances=($(qdbus | grep 'org.kde.konsole')) |
|
||||||
|
|
||||||
for i in "${konsole_instances[@]}"; do |
|
||||||
konsole_sessions=($(qdbus "${i}" | grep '/Sessions/')) |
|
||||||
for session in "${konsole_sessions[@]}"; do |
|
||||||
if ((child == "$(qdbus "${i}" "${session}" processId)")); then |
|
||||||
profile="$(qdbus "${i}" "${session}" environment | awk -F '=' '/KONSOLE_PROFILE_NAME/ {print $2}')" |
|
||||||
break |
|
||||||
fi |
|
||||||
done |
|
||||||
[[ "$profile" ]] && break |
|
||||||
done |
|
||||||
|
|
||||||
# We could have two profile files for the same profile name, take first match |
|
||||||
profile_filename="$(grep -l "Name=${profile}" "${HOME}"/.local/share/konsole/*.profile)" |
|
||||||
profile_filename="${profile_filename/$'\n'*}" |
|
||||||
[[ "$profile_filename" ]] && term_font="$(awk -F '=|,' '/Font=/ {print $2 " " $3}' "$profile_filename")" |
|
||||||
;; |
|
||||||
|
|
||||||
"mintty") |
|
||||||
term_font="$(awk -F '=' '!/^($|#)/ && /Font/ {printf $2; exit}' "${HOME}/.minttyrc")" |
|
||||||
;; |
|
||||||
|
|
||||||
"pantheon"*) |
|
||||||
term_font="$(gsettings get org.pantheon.terminal.settings font)" |
|
||||||
[[ -z "${term_font//\'}" ]] && term_font="$(gsettings get org.gnome.desktop.interface monospace-font-name)" |
|
||||||
term_font="$(trim_quotes "$term_font")" |
|
||||||
;; |
|
||||||
|
|
||||||
"sakura"*) |
|
||||||
term_font="$(awk -F '=' '/^font=/ {a=$2} END{print a}' "${XDG_CONFIG_HOME}/sakura/sakura.conf")" |
|
||||||
;; |
|
||||||
|
|
||||||
"terminology") |
|
||||||
term_font="$(strings "${XDG_CONFIG_HOME}/terminology/config/standard/base.cfg" | awk '/^font\.name$/{print a}{a=$0}')" |
|
||||||
term_font="${term_font/.pcf}" |
|
||||||
term_font="${term_font/:*}" |
|
||||||
;; |
|
||||||
|
|
||||||
"termite") |
|
||||||
[[ -f "${XDG_CONFIG_HOME}/termite/config" ]] && termite_config="${XDG_CONFIG_HOME}/termite/config" |
|
||||||
term_font="$(awk -F '= ' '/\[options\]/ {opt=1} /^font/ {if(opt==1) a=$2; opt=0} END{print a}' "/etc/xdg/termite/config" "$termite_config")" |
|
||||||
;; |
|
||||||
|
|
||||||
"urxvt" | "urxvtd" | "rxvt-unicode" | "xterm") |
|
||||||
term_font="$(grep -i -F "${term/d}*font" < <(xrdb -query))" |
|
||||||
term_font="${term_font/*font:}" |
|
||||||
term_font="$(trim "$term_font")" |
|
||||||
|
|
||||||
# Xresources has two different font formats, this checks which |
|
||||||
# one is in use and formats it accordingly. |
|
||||||
case "$term_font" in |
|
||||||
*"xft:"*) |
|
||||||
term_font="${term_font/xft:}" |
|
||||||
term_font="${term_font/:*}" |
|
||||||
;; |
|
||||||
|
|
||||||
"-"*) term_font="$(awk -F '\\-' '{printf $3}' <<< "$term_font")" ;; |
|
||||||
esac |
|
||||||
;; |
|
||||||
|
|
||||||
"xfce4-terminal") |
|
||||||
term_font="$(awk -F '=' '/^FontName/ {a=$2} END{print a}' "${XDG_CONFIG_HOME}/xfce4/terminal/terminalrc")" |
|
||||||
;; |
|
||||||
esac |
|
||||||
|
|
||||||
echo "${term_font}" |
|
||||||
} |
|
||||||
|
|
||||||
local currentTerminal=$(get_term) |
|
||||||
local currentFont=$(get_term_font "${currentTerminal}") |
|
||||||
print -P "===== Font debugging =====" |
|
||||||
print -P "You are using %F{blue}${currentTerminal}%f with Font %F{blue}${currentFont}%f\n" |
|
||||||
|
|
||||||
if [[ $(echo "${currentFont}" | grep -c -E "Powerline|Awesome|Nerd") -eq 0 ]]; then |
|
||||||
print -P "%F{yellow}WARNING%f It does not seem like you use an Powerline-enabled or Awesome Terminal Font!" |
|
||||||
print -P "Please make sure that your font settings are correct!" |
|
||||||
else |
|
||||||
print -P "Your font settings seem to be all right. If you still have issues," |
|
||||||
print -P "it is more likely to be a font issue than a Powerlevel9k related one." |
|
||||||
fi |
|
@ -1,86 +0,0 @@ |
|||||||
#!/usr/bin/env zsh |
|
||||||
#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 |
|
||||||
|
|
||||||
if [[ "$TERM_PROGRAM" != "iTerm.app" ]]; then |
|
||||||
print "Your Terminal Emulator does not appear to be iTerm2!" |
|
||||||
print "This debug script is intended only for iTerm2 terminals." |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
|
|
||||||
if [[ ! -x "/usr/libexec/PlistBuddy" ]]; then |
|
||||||
print "To use this debug script, you need to install XCode!" |
|
||||||
exit 2 |
|
||||||
fi |
|
||||||
|
|
||||||
local normalFont |
|
||||||
local type |
|
||||||
local command |
|
||||||
local ambiguousDoubleWidth |
|
||||||
local minimumContrast |
|
||||||
local useDifferentFont |
|
||||||
|
|
||||||
# Unfortunately the profile name is not unique, but it seems to be the only |
|
||||||
# thing that identifies an active profile. There is the "ID of current session |
|
||||||
# of current window" though, but that does not match to a `guid` in the plist. |
|
||||||
# So, be warned - collisions may occur! |
|
||||||
# See: https://groups.google.com/forum/#!topic/iterm2-discuss/0tO3xZ4Zlwg |
|
||||||
local currentProfileName=$(osascript -e 'tell application "iTerm2" to profile name of current session of current window') |
|
||||||
|
|
||||||
# Warning: Dynamic profiles are not taken into account here! |
|
||||||
# https://www.iterm2.com/documentation-dynamic-profiles.html |
|
||||||
|
|
||||||
# Count `guids` in "New Bookmarks"; they should be unique |
|
||||||
local profilesCount=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:" ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null | grep -c "Guid") |
|
||||||
for idx in $(seq 0 "${profilesCount}"); do |
|
||||||
local profileName=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Name:" ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null) |
|
||||||
if [[ "${profileName}" == "${currentProfileName}" ]]; then |
|
||||||
# "Normal Font" |
|
||||||
normalFont=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Normal\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist) |
|
||||||
type=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Terminal\ Type:" ~/Library/Preferences/com.googlecode.iterm2.plist) |
|
||||||
command=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Command:" ~/Library/Preferences/com.googlecode.iterm2.plist) |
|
||||||
ambiguousDoubleWidth=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Ambiguous\ Double\ Width:" ~/Library/Preferences/com.googlecode.iterm2.plist) |
|
||||||
minimumContrast=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Minimum\ Contrast:" ~/Library/Preferences/com.googlecode.iterm2.plist) |
|
||||||
|
|
||||||
# Font for non-ascii characters |
|
||||||
# Only check for a different non-ASCII font, if the user checked |
|
||||||
# the "use a different font for non-ascii text" switch. |
|
||||||
useDifferentFont=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Use\ Non-ASCII\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist) |
|
||||||
if [[ "$useDifferentFont" == "true" ]]; then |
|
||||||
nonAsciiFont=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Non\ Ascii\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist) |
|
||||||
if [[ "$normalFont" != "$nonAsciiFont" ]]; then |
|
||||||
normalFont="$normalFont (normal) / $nonAsciiFont (non-ascii)" |
|
||||||
fi |
|
||||||
fi |
|
||||||
break |
|
||||||
fi |
|
||||||
done |
|
||||||
|
|
||||||
print -P "You use %F{blue}iTerm2%f with the following settings:" |
|
||||||
print -P " Font: ${normalFont}" |
|
||||||
print -P " Terminal-Type: ${type}" |
|
||||||
print -P " Command: ${command}" |
|
||||||
|
|
||||||
############################# |
|
||||||
# Analyse possible problems # |
|
||||||
############################# |
|
||||||
local problemsFound |
|
||||||
if [[ "${ambiguousDoubleWidth}" == "true" ]]; then |
|
||||||
problemsFound="${problemsFound}\n * Please uncheck 'Treat ambiguous characters as double-width'." |
|
||||||
fi |
|
||||||
if (( minimumContrast > 0 )); then |
|
||||||
problemsFound="${problemsFound}\n * Please set minimum contrast to zero." |
|
||||||
fi |
|
||||||
if [[ $(echo "${normalFont}" | grep -c -E "Powerline|Awesome|Nerd|Source Code Pro") -eq 0 ]]; then |
|
||||||
problemsFound="${problemsFound}\n * It does not seem like you use an Powerline-enabled or Awesome Terminal Font!" |
|
||||||
fi |
|
||||||
|
|
||||||
############################# |
|
||||||
# Output problems # |
|
||||||
############################# |
|
||||||
if [[ -n "${problemsFound}" ]]; then |
|
||||||
print -P "\n" |
|
||||||
print -P "%F{yellow}Possible Problems found:%f" |
|
||||||
print -P "${problemsFound}" |
|
||||||
else |
|
||||||
print -P "%F{green}No Problems found%f. Yay!" |
|
||||||
fi |
|
@ -1,56 +0,0 @@ |
|||||||
# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 |
|
||||||
################################################################ |
|
||||||
# Color functions |
|
||||||
# This file holds some color-functions for |
|
||||||
# the powerlevel9k-ZSH-theme |
|
||||||
# https://github.com/bhilburn/powerlevel9k |
|
||||||
################################################################ |
|
||||||
|
|
||||||
# Get numerical color codes. That way we translate ANSI codes |
|
||||||
# into ZSH-Style color codes. |
|
||||||
function getColorCode() { |
|
||||||
# Check if given value is already numerical |
|
||||||
if [[ "$1" = <-> ]]; then |
|
||||||
# ANSI color codes distinguish between "foreground" |
|
||||||
# and "background" colors. We don't need to do that, |
|
||||||
# as ZSH uses a 256 color space anyway. |
|
||||||
if [[ "$1" = <8-15> ]]; then |
|
||||||
echo $(($1 - 8)) |
|
||||||
else |
|
||||||
echo "$1" |
|
||||||
fi |
|
||||||
else |
|
||||||
typeset -A codes |
|
||||||
codes=( |
|
||||||
'black' '000' |
|
||||||
'red' '001' |
|
||||||
'green' '002' |
|
||||||
'yellow' '003' |
|
||||||
'blue' '004' |
|
||||||
'magenta' '005' |
|
||||||
'cyan' '006' |
|
||||||
'white' '007' |
|
||||||
) |
|
||||||
|
|
||||||
# Strip eventual "bg-" prefixes |
|
||||||
1=${1#bg-} |
|
||||||
# Strip eventual "fg-" prefixes |
|
||||||
1=${1#fg-} |
|
||||||
# Strip eventual "br" prefixes ("bright" colors) |
|
||||||
1=${1#br} |
|
||||||
echo $codes[$1] |
|
||||||
fi |
|
||||||
} |
|
||||||
|
|
||||||
# Check if two colors are equal, even if one is specified as ANSI code. |
|
||||||
function isSameColor() { |
|
||||||
if [[ "$1" == "NONE" || "$2" == "NONE" ]]; then |
|
||||||
return 1 |
|
||||||
fi |
|
||||||
|
|
||||||
local color1=$(getColorCode "$1") |
|
||||||
local color2=$(getColorCode "$2") |
|
||||||
|
|
||||||
return $(( color1 != color2 )) |
|
||||||
} |
|
||||||
|
|
@ -1,234 +0,0 @@ |
|||||||
# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 |
|
||||||
################################################################ |
|
||||||
# Utility functions |
|
||||||
# This file holds some utility-functions for |
|
||||||
# the powerlevel9k-ZSH-theme |
|
||||||
# https://github.com/bhilburn/powerlevel9k |
|
||||||
################################################################ |
|
||||||
|
|
||||||
# Exits with 0 if a variable has been previously defined (even if empty) |
|
||||||
# Takes the name of a variable that should be checked. |
|
||||||
function defined() { |
|
||||||
local varname="$1" |
|
||||||
|
|
||||||
typeset -p "$varname" > /dev/null 2>&1 |
|
||||||
} |
|
||||||
|
|
||||||
# Given the name of a variable and a default value, sets the variable |
|
||||||
# value to the default only if it has not been defined. |
|
||||||
# |
|
||||||
# Typeset cannot set the value for an array, so this will only work |
|
||||||
# for scalar values. |
|
||||||
function set_default() { |
|
||||||
local varname="$1" |
|
||||||
local default_value="$2" |
|
||||||
|
|
||||||
defined "$varname" || typeset -g "$varname"="$default_value" |
|
||||||
} |
|
||||||
|
|
||||||
# Converts large memory values into a human-readable unit (e.g., bytes --> GB) |
|
||||||
# Takes two arguments: |
|
||||||
# * $size - The number which should be prettified |
|
||||||
# * $base - The base of the number (default Bytes) |
|
||||||
printSizeHumanReadable() { |
|
||||||
typeset -F 2 size |
|
||||||
size="$1"+0.00001 |
|
||||||
local extension |
|
||||||
extension=('B' 'K' 'M' 'G' 'T' 'P' 'E' 'Z' 'Y') |
|
||||||
local index=1 |
|
||||||
|
|
||||||
# if the base is not Bytes |
|
||||||
if [[ -n $2 ]]; then |
|
||||||
for idx in "${extension[@]}"; do |
|
||||||
if [[ "$2" == "$idx" ]]; then |
|
||||||
break |
|
||||||
fi |
|
||||||
index=$(( index + 1 )) |
|
||||||
done |
|
||||||
fi |
|
||||||
|
|
||||||
while (( (size / 1024) > 0.1 )); do |
|
||||||
size=$(( size / 1024 )) |
|
||||||
index=$(( index + 1 )) |
|
||||||
done |
|
||||||
|
|
||||||
echo "$size${extension[$index]}" |
|
||||||
} |
|
||||||
|
|
||||||
# Gets the first value out of a list of items that is not empty. |
|
||||||
# The items are examined by a callback-function. |
|
||||||
# Takes two arguments: |
|
||||||
# * $list - A list of items |
|
||||||
# * $callback - A callback function to examine if the item is |
|
||||||
# worthy. The callback function has access to |
|
||||||
# the inner variable $item. |
|
||||||
function getRelevantItem() { |
|
||||||
local -a list |
|
||||||
local callback |
|
||||||
# Explicitly split the elements by whitespace. |
|
||||||
list=(${=1}) |
|
||||||
callback=$2 |
|
||||||
|
|
||||||
for item in $list; do |
|
||||||
# The first non-empty item wins |
|
||||||
try=$(eval "$callback") |
|
||||||
if [[ -n "$try" ]]; then |
|
||||||
echo "$try" |
|
||||||
break; |
|
||||||
fi |
|
||||||
done |
|
||||||
} |
|
||||||
|
|
||||||
# OS detection |
|
||||||
case $(uname) in |
|
||||||
Darwin) |
|
||||||
OS='OSX' |
|
||||||
OS_ICON=$(print_icon 'APPLE_ICON') |
|
||||||
;; |
|
||||||
FreeBSD) |
|
||||||
OS='BSD' |
|
||||||
OS_ICON=$(print_icon 'FREEBSD_ICON') |
|
||||||
;; |
|
||||||
OpenBSD) |
|
||||||
OS='BSD' |
|
||||||
OS_ICON=$(print_icon 'FREEBSD_ICON') |
|
||||||
;; |
|
||||||
DragonFly) |
|
||||||
OS='BSD' |
|
||||||
OS_ICON=$(print_icon 'FREEBSD_ICON') |
|
||||||
;; |
|
||||||
Linux) |
|
||||||
OS='Linux' |
|
||||||
OS_ICON=$(print_icon 'LINUX_ICON') |
|
||||||
|
|
||||||
# Check if we're running on Android |
|
||||||
case $(uname -o 2>/dev/null) in |
|
||||||
Android) |
|
||||||
OS='Android' |
|
||||||
OS_ICON=$(print_icon 'ANDROID_ICON') |
|
||||||
;; |
|
||||||
esac |
|
||||||
;; |
|
||||||
SunOS) |
|
||||||
OS='Solaris' |
|
||||||
OS_ICON=$(print_icon 'SUNOS_ICON') |
|
||||||
;; |
|
||||||
*) |
|
||||||
OS='' |
|
||||||
OS_ICON='' |
|
||||||
;; |
|
||||||
esac |
|
||||||
|
|
||||||
# Determine the correct sed parameter. |
|
||||||
# |
|
||||||
# `sed` is unfortunately not consistent across OSes when it comes to flags. |
|
||||||
SED_EXTENDED_REGEX_PARAMETER="-r" |
|
||||||
if [[ "$OS" == 'OSX' ]]; then |
|
||||||
local IS_BSD_SED="$(sed --version &>> /dev/null || echo "BSD sed")" |
|
||||||
if [[ -n "$IS_BSD_SED" ]]; then |
|
||||||
SED_EXTENDED_REGEX_PARAMETER="-E" |
|
||||||
fi |
|
||||||
fi |
|
||||||
|
|
||||||
# Determine if the passed segment is used in the prompt |
|
||||||
# |
|
||||||
# Pass the name of the segment to this function to test for its presence in |
|
||||||
# either the LEFT or RIGHT prompt arrays. |
|
||||||
# * $1: The segment to be tested. |
|
||||||
segment_in_use() { |
|
||||||
local key=$1 |
|
||||||
if [[ -n "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[(r)$key]}" ]] || [[ -n "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[(r)$key]}" ]]; then |
|
||||||
return 0 |
|
||||||
else |
|
||||||
return 1 |
|
||||||
fi |
|
||||||
} |
|
||||||
|
|
||||||
# Print a deprecation warning if an old segment is in use. |
|
||||||
# Takes the name of an associative array that contains the |
|
||||||
# deprecated segments as keys, the values contain the new |
|
||||||
# segment names. |
|
||||||
print_deprecation_warning() { |
|
||||||
typeset -AH raw_deprecated_segments |
|
||||||
raw_deprecated_segments=(${(kvP@)1}) |
|
||||||
|
|
||||||
for key in ${(@k)raw_deprecated_segments}; do |
|
||||||
if segment_in_use $key; then |
|
||||||
# segment is deprecated |
|
||||||
print -P "%F{yellow}Warning!%f The '$key' segment is deprecated. Use '%F{blue}${raw_deprecated_segments[$key]}%f' instead. For more informations, have a look at the CHANGELOG.md." |
|
||||||
fi |
|
||||||
done |
|
||||||
} |
|
||||||
|
|
||||||
# A helper function to determine if a segment should be |
|
||||||
# joined or promoted to a full one. |
|
||||||
# Takes three arguments: |
|
||||||
# * $1: The array index of the current segment |
|
||||||
# * $2: The array index of the last printed segment |
|
||||||
# * $3: The array of segments of the left or right prompt |
|
||||||
function segmentShouldBeJoined() { |
|
||||||
local current_index=$1 |
|
||||||
local last_segment_index=$2 |
|
||||||
# Explicitly split the elements by whitespace. |
|
||||||
local -a elements |
|
||||||
elements=(${=3}) |
|
||||||
|
|
||||||
local current_segment=${elements[$current_index]} |
|
||||||
local joined=false |
|
||||||
if [[ ${current_segment[-7,-1]} == '_joined' ]]; then |
|
||||||
joined=true |
|
||||||
# promote segment to a full one, if the predecessing full segment |
|
||||||
# was conditional. So this can only be the case for segments that |
|
||||||
# are not our direct predecessor. |
|
||||||
if (( $(($current_index - $last_segment_index)) > 1)); then |
|
||||||
# Now we have to examine every previous segment, until we reach |
|
||||||
# the last printed one (found by its index). This is relevant if |
|
||||||
# all previous segments are joined. Then we want to join our |
|
||||||
# segment as well. |
|
||||||
local examined_index=$((current_index - 1)) |
|
||||||
while (( $examined_index > $last_segment_index )); do |
|
||||||
local previous_segment=${elements[$examined_index]} |
|
||||||
# If one of the examined segments is not joined, then we know |
|
||||||
# that the current segment should not be joined, as the target |
|
||||||
# segment is the wrong one. |
|
||||||
if [[ ${previous_segment[-7,-1]} != '_joined' ]]; then |
|
||||||
joined=false |
|
||||||
break |
|
||||||
fi |
|
||||||
examined_index=$((examined_index - 1)) |
|
||||||
done |
|
||||||
fi |
|
||||||
fi |
|
||||||
|
|
||||||
# Return 1 means error; return 0 means no error. So we have |
|
||||||
# to invert $joined |
|
||||||
if [[ "$joined" == "true" ]]; then |
|
||||||
return 0 |
|
||||||
else |
|
||||||
return 1 |
|
||||||
fi |
|
||||||
} |
|
||||||
|
|
||||||
# Given a directory path, truncate it according to the settings for |
|
||||||
# `truncate_from_right` |
|
||||||
function truncatePathFromRight() { |
|
||||||
local delim_len=${#POWERLEVEL9K_SHORTEN_DELIMITER} |
|
||||||
echo $1 | sed $SED_EXTENDED_REGEX_PARAMETER \ |
|
||||||
"s@(([^/]{$((POWERLEVEL9K_SHORTEN_DIR_LENGTH))})([^/]{$delim_len}))[^/]+/@\2$POWERLEVEL9K_SHORTEN_DELIMITER/@g" |
|
||||||
} |
|
||||||
|
|
||||||
# Search recursively in parent folders for given file. |
|
||||||
function upsearch () { |
|
||||||
if [[ "$PWD" == "$HOME" || "$PWD" == "/" ]]; then |
|
||||||
echo "$PWD" |
|
||||||
elif test -e "$1"; then |
|
||||||
pushd .. > /dev/null |
|
||||||
upsearch "$1" |
|
||||||
popd > /dev/null |
|
||||||
echo "$PWD" |
|
||||||
else |
|
||||||
pushd .. > /dev/null |
|
||||||
upsearch "$1" |
|
||||||
popd > /dev/null |
|
||||||
fi |
|
||||||
} |
|
@ -1,152 +0,0 @@ |
|||||||
# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 |
|
||||||
################################################################ |
|
||||||
# vcs |
|
||||||
# This file holds supplemental VCS functions |
|
||||||
# for the powerlevel9k-ZSH-theme |
|
||||||
# https://github.com/bhilburn/powerlevel9k |
|
||||||
################################################################ |
|
||||||
|
|
||||||
set_default POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY true |
|
||||||
function +vi-git-untracked() { |
|
||||||
# TODO: check git >= 1.7.2 - see function git_compare_version() |
|
||||||
local FLAGS |
|
||||||
FLAGS=('--porcelain') |
|
||||||
|
|
||||||
if [[ "$POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY" == "false" ]]; then |
|
||||||
FLAGS+='--ignore-submodules=dirty' |
|
||||||
fi |
|
||||||
|
|
||||||
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \ |
|
||||||
-n $(git status ${FLAGS} | grep -E '^\?\?' 2> /dev/null | tail -n1) ]]; then |
|
||||||
hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')" |
|
||||||
VCS_WORKDIR_HALF_DIRTY=true |
|
||||||
else |
|
||||||
VCS_WORKDIR_HALF_DIRTY=false |
|
||||||
fi |
|
||||||
} |
|
||||||
|
|
||||||
function +vi-git-aheadbehind() { |
|
||||||
local ahead behind branch_name |
|
||||||
local -a gitstatus |
|
||||||
|
|
||||||
branch_name=$(git symbolic-ref --short HEAD 2>/dev/null) |
|
||||||
|
|
||||||
# for git prior to 1.7 |
|
||||||
# ahead=$(git rev-list origin/${branch_name}..HEAD | wc -l) |
|
||||||
ahead=$(git rev-list "${branch_name}"@{upstream}..HEAD 2>/dev/null | wc -l) |
|
||||||
(( ahead )) && gitstatus+=( " $(print_icon 'VCS_OUTGOING_CHANGES_ICON')${ahead// /}" ) |
|
||||||
|
|
||||||
# for git prior to 1.7 |
|
||||||
# behind=$(git rev-list HEAD..origin/${branch_name} | wc -l) |
|
||||||
behind=$(git rev-list HEAD.."${branch_name}"@{upstream} 2>/dev/null | wc -l) |
|
||||||
(( behind )) && gitstatus+=( " $(print_icon 'VCS_INCOMING_CHANGES_ICON')${behind// /}" ) |
|
||||||
|
|
||||||
hook_com[misc]+=${(j::)gitstatus} |
|
||||||
} |
|
||||||
|
|
||||||
function +vi-git-remotebranch() { |
|
||||||
local remote branch_name |
|
||||||
|
|
||||||
# Are we on a remote-tracking branch? |
|
||||||
remote=${$(git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/} |
|
||||||
branch_name=$(git symbolic-ref --short HEAD 2>/dev/null) |
|
||||||
|
|
||||||
hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${hook_com[branch]}" |
|
||||||
# Always show the remote |
|
||||||
#if [[ -n ${remote} ]] ; then |
|
||||||
# Only show the remote if it differs from the local |
|
||||||
if [[ -n ${remote} ]] && [[ "${remote#*/}" != "${branch_name}" ]] ; then |
|
||||||
hook_com[branch]+="$(print_icon 'VCS_REMOTE_BRANCH_ICON')${remote// /}" |
|
||||||
fi |
|
||||||
} |
|
||||||
|
|
||||||
set_default POWERLEVEL9K_VCS_HIDE_TAGS false |
|
||||||
function +vi-git-tagname() { |
|
||||||
if [[ "$POWERLEVEL9K_VCS_HIDE_TAGS" == "false" ]]; then |
|
||||||
# If we are on a tag, append the tagname to the current branch string. |
|
||||||
local tag |
|
||||||
tag=$(git describe --tags --exact-match HEAD 2>/dev/null) |
|
||||||
|
|
||||||
if [[ -n "${tag}" ]] ; then |
|
||||||
# There is a tag that points to our current commit. Need to determine if we |
|
||||||
# are also on a branch, or are in a DETACHED_HEAD state. |
|
||||||
if [[ -z $(git symbolic-ref HEAD 2>/dev/null) ]]; then |
|
||||||
# DETACHED_HEAD state. We want to append the tag name to the commit hash |
|
||||||
# and print it. Unfortunately, `vcs_info` blows away the hash when a tag |
|
||||||
# exists, so we have to manually retrieve it and clobber the branch |
|
||||||
# string. |
|
||||||
local revision |
|
||||||
revision=$(git rev-list -n 1 --abbrev-commit --abbrev=${POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH} HEAD) |
|
||||||
hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${revision} $(print_icon 'VCS_TAG_ICON')${tag}" |
|
||||||
else |
|
||||||
# We are on both a tag and a branch; print both by appending the tag name. |
|
||||||
hook_com[branch]+=" $(print_icon 'VCS_TAG_ICON')${tag}" |
|
||||||
fi |
|
||||||
fi |
|
||||||
fi |
|
||||||
} |
|
||||||
|
|
||||||
# Show count of stashed changes |
|
||||||
# Port from https://github.com/whiteinge/dotfiles/blob/5dfd08d30f7f2749cfc60bc55564c6ea239624d9/.zsh_shouse_prompt#L268 |
|
||||||
function +vi-git-stash() { |
|
||||||
local -a stashes |
|
||||||
|
|
||||||
if [[ -s $(git rev-parse --git-dir)/refs/stash ]] ; then |
|
||||||
stashes=$(git stash list 2>/dev/null | wc -l) |
|
||||||
hook_com[misc]+=" $(print_icon 'VCS_STASH_ICON')${stashes// /}" |
|
||||||
fi |
|
||||||
} |
|
||||||
|
|
||||||
function +vi-hg-bookmarks() { |
|
||||||
if [[ -n "${hgbmarks[@]}" ]]; then |
|
||||||
hook_com[hg-bookmark-string]=" $(print_icon 'VCS_BOOKMARK_ICON')${hgbmarks[@]}" |
|
||||||
|
|
||||||
# To signal that we want to use the sting we just generated, set the special |
|
||||||
# variable `ret' to something other than the default zero: |
|
||||||
ret=1 |
|
||||||
return 0 |
|
||||||
fi |
|
||||||
} |
|
||||||
|
|
||||||
function +vi-vcs-detect-changes() { |
|
||||||
if [[ "${hook_com[vcs]}" == "git" ]]; then |
|
||||||
|
|
||||||
local remote=$(git ls-remote --get-url 2> /dev/null) |
|
||||||
if [[ "$remote" =~ "github" ]] then |
|
||||||
vcs_visual_identifier='VCS_GIT_GITHUB_ICON' |
|
||||||
elif [[ "$remote" =~ "bitbucket" ]] then |
|
||||||
vcs_visual_identifier='VCS_GIT_BITBUCKET_ICON' |
|
||||||
elif [[ "$remote" =~ "gitlab" ]] then |
|
||||||
vcs_visual_identifier='VCS_GIT_GITLAB_ICON' |
|
||||||
else |
|
||||||
vcs_visual_identifier='VCS_GIT_ICON' |
|
||||||
fi |
|
||||||
|
|
||||||
elif [[ "${hook_com[vcs]}" == "hg" ]]; then |
|
||||||
vcs_visual_identifier='VCS_HG_ICON' |
|
||||||
elif [[ "${hook_com[vcs]}" == "svn" ]]; then |
|
||||||
vcs_visual_identifier='VCS_SVN_ICON' |
|
||||||
fi |
|
||||||
|
|
||||||
if [[ -n "${hook_com[staged]}" ]] || [[ -n "${hook_com[unstaged]}" ]]; then |
|
||||||
VCS_WORKDIR_DIRTY=true |
|
||||||
else |
|
||||||
VCS_WORKDIR_DIRTY=false |
|
||||||
fi |
|
||||||
} |
|
||||||
|
|
||||||
function +vi-svn-detect-changes() { |
|
||||||
local svn_status="$(svn status)" |
|
||||||
if [[ -n "$(echo "$svn_status" | grep \^\?)" ]]; then |
|
||||||
hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')" |
|
||||||
VCS_WORKDIR_HALF_DIRTY=true |
|
||||||
fi |
|
||||||
if [[ -n "$(echo "$svn_status" | grep \^\M)" ]]; then |
|
||||||
hook_com[unstaged]+=" $(print_icon 'VCS_UNSTAGED_ICON')" |
|
||||||
VCS_WORKDIR_DIRTY=true |
|
||||||
fi |
|
||||||
if [[ -n "$(echo "$svn_status" | grep \^\A)" ]]; then |
|
||||||
hook_com[staged]+=" $(print_icon 'VCS_STAGED_ICON')" |
|
||||||
VCS_WORKDIR_DIRTY=true |
|
||||||
fi |
|
||||||
} |
|
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@ |
|||||||
powerlevel9k.zsh-theme |
|
@ -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,9 +0,0 @@ |
|||||||
#!/usr/bin/zsh |
|
||||||
|
|
||||||
echo 'LANG=en_US.UTF-8' >! ~/.zshrc |
|
||||||
echo 'source /vagrant_data/powerlevel9k.zsh-theme' >> ~/.zshrc |
|
||||||
|
|
||||||
echo 'echo "Have a look at the ~/p9k folder for prepared test setups."' >> ~/.zshrc |
|
||||||
|
|
||||||
# setup environment |
|
||||||
/vagrant_data/test-vm-providers/setup-environment.sh |
|
@ -1,44 +0,0 @@ |
|||||||
#!/usr/bin/zsh |
|
||||||
|
|
||||||
OLDPWD="$(pwd)" |
|
||||||
cd $HOME |
|
||||||
|
|
||||||
TESTFOLDER="${HOME}/p9k" |
|
||||||
mkdir -p $TESTFOLDER |
|
||||||
cd $TESTFOLDER |
|
||||||
|
|
||||||
# Make a deep test folder |
|
||||||
mkdir -p deep-folder/1/12/123/1234/12345/123456/1234567/123455678/123456789 |
|
||||||
|
|
||||||
# Make a git repo |
|
||||||
mkdir git-repo |
|
||||||
cd git-repo |
|
||||||
git config --global user.email "test@powerlevel9k.theme" |
|
||||||
git config --global user.name "Testing Tester" |
|
||||||
git init |
|
||||||
echo "TEST" >> testfile |
|
||||||
git add testfile |
|
||||||
git commit -m "Initial commit" |
|
||||||
cd $TESTFOLDER |
|
||||||
|
|
||||||
# Make a Mercurial repo |
|
||||||
mkdir hg-repo |
|
||||||
cd hg-repo |
|
||||||
export HGUSER="Test bot <bot@example.com>" |
|
||||||
hg init |
|
||||||
echo "TEST" >> testfile |
|
||||||
hg add testfile |
|
||||||
hg ci -m "Initial commit" |
|
||||||
cd $TESTFOLDER |
|
||||||
|
|
||||||
# Setup a SVN folder |
|
||||||
svnadmin create ~/.svn-repo |
|
||||||
mkdir svn-repo |
|
||||||
svn checkout "file://${HOME}/.svn-repo" "svn-repo" |
|
||||||
cd svn-repo |
|
||||||
echo "TEST" >> testfile |
|
||||||
svn add testfile |
|
||||||
svn commit -m "Initial commit" |
|
||||||
cd $TESTFOLDER |
|
||||||
|
|
||||||
cd $OLDPWD |
|
@ -1,25 +0,0 @@ |
|||||||
# Test-VM for powerlevel9k |
|
||||||
|
|
||||||
In this virtual machine you will find a recent ubuntu with preinstalled ZSH, oh-my-zsh, antigen, prezto and - of course - powerlevel9k. The main use-case is to test the powerlevel9k theme. |
|
||||||
|
|
||||||
## Installation |
|
||||||
|
|
||||||
In order to run this virtual machine, you need [vagrant](https://www.vagrantup.com/) and [VirtualBox](http://www.virtualbox.org/). |
|
||||||
|
|
||||||
## Running |
|
||||||
|
|
||||||
`vagrant` is a quite easy to use command line tool to configure a virtual machine. To fire the machine up, just run `vagrant up`. At the first run, it will install a whole ubuntu. With `vagrant ssh` you can log in into the machine. |
|
||||||
|
|
||||||
## Testing |
|
||||||
|
|
||||||
Once you have SSH'd into the machine, you'll see a plain ZSH. To test the other frameworks, you just have to switch to one of the following users: |
|
||||||
|
|
||||||
* `vagrant-antigen` |
|
||||||
* `vagrant-prezto` |
|
||||||
* `vagrant-omz` |
|
||||||
|
|
||||||
To switch use `sudo -i -H -u <USERNAME>`. `-i` stands for "simulate initial login", `-H` sets the "$HOME" variable to the directory of the user , `-u` for the username. |
|
||||||
|
|
||||||
All users have `vagrant` as password and are in the /etc/sudoers. |
|
||||||
|
|
||||||
The regular `vagrant` user has a plain ZSH with the powerlevel9k theme. |
|
@ -1,82 +0,0 @@ |
|||||||
# -*- mode: ruby -*- |
|
||||||
# vi: set ft=ruby : |
|
||||||
|
|
||||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure |
|
||||||
# configures the configuration version (we support older styles for |
|
||||||
# backwards compatibility). Please don't change it unless you know what |
|
||||||
# you're doing. |
|
||||||
Vagrant.configure(2) do |config| |
|
||||||
# The most common configuration options are documented and commented below. |
|
||||||
# For a complete reference, please see the online documentation at |
|
||||||
# https://docs.vagrantup.com. |
|
||||||
|
|
||||||
# Every Vagrant development environment requires a box. You can search for |
|
||||||
# boxes at https://atlas.hashicorp.com/search. |
|
||||||
config.vm.box = "ubuntu/precise64" |
|
||||||
|
|
||||||
# Bootstrap |
|
||||||
config.vm.provision :shell, path: "bootstrap.sh", privileged: false |
|
||||||
config.vm.provision :shell, path: "../test-vm-providers/plain.sh", privileged: false |
|
||||||
config.vm.provision :shell, path: "antigen.sh" |
|
||||||
config.vm.provision :shell, path: "prezto.sh" |
|
||||||
config.vm.provision :shell, path: "omz.sh" |
|
||||||
|
|
||||||
# Disable automatic box update checking. If you disable this, then |
|
||||||
# boxes will only be checked for updates when the user runs |
|
||||||
# `vagrant box outdated`. This is not recommended. |
|
||||||
# config.vm.box_check_update = false |
|
||||||
|
|
||||||
# Create a forwarded port mapping which allows access to a specific port |
|
||||||
# within the machine from a port on the host machine. In the example below, |
|
||||||
# accessing "localhost:8080" will access port 80 on the guest machine. |
|
||||||
# config.vm.network "forwarded_port", guest: 80, host: 8080 |
|
||||||
|
|
||||||
# Create a private network, which allows host-only access to the machine |
|
||||||
# using a specific IP. |
|
||||||
# config.vm.network "private_network", ip: "192.168.33.10" |
|
||||||
|
|
||||||
# Create a public network, which generally matched to bridged network. |
|
||||||
# Bridged networks make the machine appear as another physical device on |
|
||||||
# your network. |
|
||||||
# config.vm.network "public_network" |
|
||||||
|
|
||||||
# Share an additional folder to the guest VM. The first argument is |
|
||||||
# the path on the host to the actual folder. The second argument is |
|
||||||
# the path on the guest to mount the folder. And the optional third |
|
||||||
# argument is a set of non-required options. |
|
||||||
config.vm.synced_folder "..", "/vagrant_data" |
|
||||||
|
|
||||||
# Provider-specific configuration so you can fine-tune various |
|
||||||
# backing providers for Vagrant. These expose provider-specific options. |
|
||||||
# Example for VirtualBox: |
|
||||||
|
|
||||||
config.vm.provider "virtualbox" do |vb| |
|
||||||
|
|
||||||
# Change name to "powerlevel9k" |
|
||||||
vb.name = "powerlevel9k" |
|
||||||
|
|
||||||
# Display the VirtualBox GUI when booting the machine |
|
||||||
#vb.gui = true |
|
||||||
|
|
||||||
# Customize the amount of memory on the VM: |
|
||||||
vb.memory = "256" |
|
||||||
end |
|
||||||
# |
|
||||||
# View the documentation for the provider you are using for more |
|
||||||
# information on available options. |
|
||||||
|
|
||||||
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies |
|
||||||
# such as FTP and Heroku are also available. See the documentation at |
|
||||||
# https://docs.vagrantup.com/v2/push/atlas.html for more information. |
|
||||||
# config.push.define "atlas" do |push| |
|
||||||
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" |
|
||||||
# end |
|
||||||
|
|
||||||
# Enable provisioning with a shell script. Additional provisioners such as |
|
||||||
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the |
|
||||||
# documentation for more information about their specific syntax and use. |
|
||||||
# config.vm.provision "shell", inline: <<-SHELL |
|
||||||
# sudo apt-get update |
|
||||||
# sudo apt-get install -y apache2 |
|
||||||
# SHELL |
|
||||||
end |
|
@ -1,30 +0,0 @@ |
|||||||
#!/usr/bin/zsh |
|
||||||
# We need to run this script in ZSH, so that switching user works! |
|
||||||
NEW_USER=vagrant-antigen |
|
||||||
# Create User |
|
||||||
PASSWORD='$6$OgLg9v2Z$Db38Jr9inZG7y8BzL8kqFK23fF5jZ7FU1oiIBLFjNYR9XVX03fwQayMgA6Rm1rzLbXaf.gkZaTWhB9pv5XLq11' |
|
||||||
useradd -p $PASSWORD -g vagrant -s $(which zsh) -m $NEW_USER |
|
||||||
echo "$NEW_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$NEW_USER |
|
||||||
chmod 440 /etc/sudoers.d/$NEW_USER |
|
||||||
|
|
||||||
( |
|
||||||
# Change User (See http://unix.stackexchange.com/questions/86778/why-cant-we-execute-a-list-of-commands-as-different-user-without-sudo) |
|
||||||
USERNAME=$NEW_USER |
|
||||||
#UID=$(id -u $NEW_USER) |
|
||||||
#EUID=$(id -u $NEW_USER) |
|
||||||
HOME=/home/$NEW_USER |
|
||||||
|
|
||||||
echo " |
|
||||||
source ~/antigen/antigen.zsh\n |
|
||||||
antigen theme /vagrant_data powerlevel9k --no-local-clone\n |
|
||||||
antigen apply |
|
||||||
" > ~/.zshrc |
|
||||||
|
|
||||||
# install antigen |
|
||||||
mkdir ~/antigen |
|
||||||
curl -qL https://raw.githubusercontent.com/zsh-users/antigen/master/antigen.zsh > ~/antigen/antigen.zsh |
|
||||||
source ~/antigen/antigen.zsh |
|
||||||
|
|
||||||
# setup environment |
|
||||||
/vagrant_data/test-vm-providers/setup-environment.sh |
|
||||||
) |
|
@ -1,19 +0,0 @@ |
|||||||
#!/bin/sh |
|
||||||
|
|
||||||
#sudo apt-get update |
|
||||||
|
|
||||||
sudo apt-get install -y curl |
|
||||||
sudo apt-get install -y git |
|
||||||
|
|
||||||
sudo apt-get install -y zsh |
|
||||||
sudo chsh -s $(which zsh) vagrant |
|
||||||
|
|
||||||
# Install mercurial |
|
||||||
sudo apt-get install -y mercurial |
|
||||||
# Install Subversion |
|
||||||
sudo apt-get install -y subversion |
|
||||||
# install golang |
|
||||||
echo 'golang-go golang-go/dashboard boolean false' | sudo debconf-set-selections |
|
||||||
sudo apt-get install -y golang |
|
||||||
# Install dependencies for tests |
|
||||||
sudo apt-get install -y jq node ruby python python-virtualenv |
|
@ -1,33 +0,0 @@ |
|||||||
#!/usr/bin/zsh |
|
||||||
# We need to run this script in ZSH, so that switching user works! |
|
||||||
NEW_USER=vagrant-omz |
|
||||||
# Create User |
|
||||||
PASSWORD='$6$OgLg9v2Z$Db38Jr9inZG7y8BzL8kqFK23fF5jZ7FU1oiIBLFjNYR9XVX03fwQayMgA6Rm1rzLbXaf.gkZaTWhB9pv5XLq11' |
|
||||||
useradd -p $PASSWORD -g vagrant -s $(which zsh) -m $NEW_USER |
|
||||||
echo "$NEW_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$NEW_USER |
|
||||||
chmod 440 /etc/sudoers.d/$NEW_USER |
|
||||||
|
|
||||||
( |
|
||||||
# Change User (See http://unix.stackexchange.com/questions/86778/why-cant-we-execute-a-list-of-commands-as-different-user-without-sudo) |
|
||||||
USERNAME=$NEW_USER |
|
||||||
#UID=$(id -u $NEW_USER) |
|
||||||
#EUID=$(id -u $NEW_USER) |
|
||||||
HOME=/home/$NEW_USER |
|
||||||
SHELL=$(which zsh) |
|
||||||
|
|
||||||
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" |
|
||||||
|
|
||||||
mkdir -p ~/.oh-my-zsh/custom/themes |
|
||||||
ln -s /vagrant_data ~/.oh-my-zsh/custom/themes/powerlevel9k |
|
||||||
|
|
||||||
echo ' |
|
||||||
export ZSH=$HOME/.oh-my-zsh |
|
||||||
ZSH_THEME="powerlevel9k/powerlevel9k" |
|
||||||
plugins=(git rake ruby) |
|
||||||
|
|
||||||
source $ZSH/oh-my-zsh.sh |
|
||||||
' > $HOME/.zshrc |
|
||||||
|
|
||||||
# setup environment |
|
||||||
/vagrant_data/test-vm-providers/setup-environment.sh |
|
||||||
) |
|
@ -1,29 +0,0 @@ |
|||||||
#!/usr/bin/zsh |
|
||||||
# We need to run this script in ZSH, so that switching user works! |
|
||||||
NEW_USER=vagrant-prezto |
|
||||||
# Create User |
|
||||||
PASSWORD='$6$OgLg9v2Z$Db38Jr9inZG7y8BzL8kqFK23fF5jZ7FU1oiIBLFjNYR9XVX03fwQayMgA6Rm1rzLbXaf.gkZaTWhB9pv5XLq11' |
|
||||||
useradd -p $PASSWORD -g vagrant -s $(which zsh) -m $NEW_USER |
|
||||||
echo "$NEW_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$NEW_USER |
|
||||||
chmod 440 /etc/sudoers.d/$NEW_USER |
|
||||||
|
|
||||||
( |
|
||||||
# Change User (See http://unix.stackexchange.com/questions/86778/why-cant-we-execute-a-list-of-commands-as-different-user-without-sudo) |
|
||||||
USERNAME=$NEW_USER |
|
||||||
#UID=$(id -u $NEW_USER) |
|
||||||
#EUID=$(id -u $NEW_USER) |
|
||||||
HOME=/home/$NEW_USER |
|
||||||
|
|
||||||
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto" |
|
||||||
|
|
||||||
setopt EXTENDED_GLOB |
|
||||||
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do |
|
||||||
ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}" |
|
||||||
done |
|
||||||
|
|
||||||
ln -s /vagrant_data/powerlevel9k.zsh-theme ~/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup |
|
||||||
sed -i "s/theme\ 'sorin'/theme\ 'powerlevel9k'/g" ~/.zpreztorc |
|
||||||
|
|
||||||
# setup environment |
|
||||||
/vagrant_data/test-vm-providers/setup-environment.sh |
|
||||||
) |
|
@ -1,42 +0,0 @@ |
|||||||
#!/usr/bin/env zsh |
|
||||||
#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 |
|
||||||
|
|
||||||
# Required for shunit2 to run correctly |
|
||||||
setopt shwordsplit |
|
||||||
SHUNIT_PARENT=$0 |
|
||||||
|
|
||||||
function setUp() { |
|
||||||
# Load Powerlevel9k |
|
||||||
source functions/colors.zsh |
|
||||||
} |
|
||||||
|
|
||||||
function testGetColorCodeWithAnsiForegroundColor() { |
|
||||||
assertEquals '002' "$(getColorCode 'green')" |
|
||||||
} |
|
||||||
|
|
||||||
function testGetColorCodeWithAnsiBackgroundColor() { |
|
||||||
assertEquals '002' "$(getColorCode 'bg-green')" |
|
||||||
} |
|
||||||
|
|
||||||
function testGetColorCodeWithNumericalColor() { |
|
||||||
assertEquals '002' "$(getColorCode '002')" |
|
||||||
} |
|
||||||
|
|
||||||
function testIsSameColorComparesAnsiForegroundAndNumericalColorCorrectly() { |
|
||||||
assertTrue "isSameColor 'green' '002'" |
|
||||||
} |
|
||||||
|
|
||||||
function testIsSameColorComparesAnsiBackgroundAndNumericalColorCorrectly() { |
|
||||||
assertTrue "isSameColor 'bg-green' '002'" |
|
||||||
} |
|
||||||
|
|
||||||
function testIsSameColorComparesNumericalBackgroundAndNumericalColorCorrectly() { |
|
||||||
assertTrue "isSameColor '010' '2'" |
|
||||||
} |
|
||||||
|
|
||||||
function testIsSameColorDoesNotYieldNotEqualColorsTruthy() { |
|
||||||
assertFalse "isSameColor 'green' '003'" |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
source shunit2/source/2.1/src/shunit2 |
|
@ -1,362 +0,0 @@ |
|||||||
#!/usr/bin/env zsh |
|
||||||
#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 |
|
||||||
|
|
||||||
# Required for shunit2 to run correctly |
|
||||||
setopt shwordsplit |
|
||||||
SHUNIT_PARENT=$0 |
|
||||||
|
|
||||||
function setUp() { |
|
||||||
# Store old value for LC_CTYPE |
|
||||||
_OLD_LC_CTYPE="${LC_CTYPE}" |
|
||||||
# Reset actual LC_CTYPE |
|
||||||
unset LC_CTYPE |
|
||||||
|
|
||||||
# Store old P9K mode |
|
||||||
_OLD_P9K_MODE="${POWERLEVEL9K_MODE}" |
|
||||||
} |
|
||||||
|
|
||||||
function tearDown() { |
|
||||||
# Restore LC_CTYPE |
|
||||||
LC_CTYPE="${_OLD_LC_CTYPE}" |
|
||||||
|
|
||||||
# Restore old P9K mode |
|
||||||
POWERLEVEL9K_MODE="${_OLD_P9K_MODE}" |
|
||||||
} |
|
||||||
|
|
||||||
function testLcCtypeIsSetCorrectlyInDefaultMode() { |
|
||||||
POWERLEVEL9K_MODE="default" |
|
||||||
# Load Powerlevel9k |
|
||||||
source functions/icons.zsh |
|
||||||
|
|
||||||
assertEquals 'en_US.UTF-8' "${LC_CTYPE}" |
|
||||||
} |
|
||||||
|
|
||||||
function testLcCtypeIsSetCorrectlyInAwesomePatchedMode() { |
|
||||||
POWERLEVEL9K_MODE="awesome-patched" |
|
||||||
# Load Powerlevel9k |
|
||||||
source functions/icons.zsh |
|
||||||
|
|
||||||
assertEquals 'en_US.UTF-8' "${LC_CTYPE}" |
|
||||||
} |
|
||||||
|
|
||||||
function testLcCtypeIsSetCorrectlyInAwesomeFontconfigMode() { |
|
||||||
POWERLEVEL9K_MODE="awesome-fontconfig" |
|
||||||
# Load Powerlevel9k |
|
||||||
source functions/icons.zsh |
|
||||||
|
|
||||||
assertEquals 'en_US.UTF-8' "${LC_CTYPE}" |
|
||||||
} |
|
||||||
|
|
||||||
function testLcCtypeIsSetCorrectlyInNerdfontFontconfigMode() { |
|
||||||
POWERLEVEL9K_MODE="nerdfont-fontconfig" |
|
||||||
# Load Powerlevel9k |
|
||||||
source functions/icons.zsh |
|
||||||
|
|
||||||
assertEquals 'en_US.UTF-8' "${LC_CTYPE}" |
|
||||||
} |
|
||||||
|
|
||||||
function testLcCtypeIsSetCorrectlyInFlatMode() { |
|
||||||
POWERLEVEL9K_MODE="flat" |
|
||||||
# Load Powerlevel9k |
|
||||||
source functions/icons.zsh |
|
||||||
|
|
||||||
assertEquals 'en_US.UTF-8' "${LC_CTYPE}" |
|
||||||
} |
|
||||||
|
|
||||||
function testLcCtypeIsSetCorrectlyInCompatibleMode() { |
|
||||||
POWERLEVEL9K_MODE="compatible" |
|
||||||
# Load Powerlevel9k |
|
||||||
source functions/icons.zsh |
|
||||||
|
|
||||||
assertEquals 'en_US.UTF-8' "${LC_CTYPE}" |
|
||||||
} |
|
||||||
|
|
||||||
# Go through all icons defined in default mode, and |
|
||||||
# check if all of them are defined in the other modes. |
|
||||||
function testAllIconsAreDefinedLikeInDefaultMode() { |
|
||||||
# Always compare against this mode |
|
||||||
local _P9K_TEST_MODE="default" |
|
||||||
POWERLEVEL9K_MODE="${_P9K_TEST_MODE}" |
|
||||||
source functions/icons.zsh |
|
||||||
# _ICONS_UNDER_TEST is an array of just the keys of $icons. |
|
||||||
# We later check via (r) "subscript" flag that our key |
|
||||||
# is in the values of our flat array. |
|
||||||
typeset -ah _ICONS_UNDER_TEST |
|
||||||
_ICONS_UNDER_TEST=(${(k)icons[@]}) |
|
||||||
|
|
||||||
# Switch to "awesome-patched" mode |
|
||||||
POWERLEVEL9K_MODE="awesome-patched" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
# Iterate over all keys found in the _ICONS_UNDER_TEST |
|
||||||
# array and compare it with the icons array of the |
|
||||||
# current POWERLEVEL9K_MODE. |
|
||||||
# Use parameter expansion, to directly check if the |
|
||||||
# key exists in the flat current array of keys. That |
|
||||||
# is quite complicated, but there seems no easy way |
|
||||||
# to check the mere existance of a key in an array. |
|
||||||
# The usual way would always return the value, so that |
|
||||||
# would do the wrong thing as we have some (on purpose) |
|
||||||
# empty values. |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
# Switch to "awesome-fontconfig" mode |
|
||||||
POWERLEVEL9K_MODE="awesome-fontconfig" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
# Switch to "nerdfont-fontconfig" mode |
|
||||||
POWERLEVEL9K_MODE="nerdfont-fontconfig" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
# Switch to "flat" mode |
|
||||||
POWERLEVEL9K_MODE="flat" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
# Switch to "compatible" mode |
|
||||||
POWERLEVEL9K_MODE="compatible" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
unset current_icons |
|
||||||
unset _ICONS_UNDER_TEST |
|
||||||
} |
|
||||||
|
|
||||||
# Go through all icons defined in awesome-patched mode, and |
|
||||||
# check if all of them are defined in the other modes. |
|
||||||
function testAllIconsAreDefinedLikeInAwesomePatchedMode() { |
|
||||||
# Always compare against this mode |
|
||||||
local _P9K_TEST_MODE="awesome-patched" |
|
||||||
POWERLEVEL9K_MODE="$_P9K_TEST_MODE" |
|
||||||
source functions/icons.zsh |
|
||||||
# _ICONS_UNDER_TEST is an array of just the keys of $icons. |
|
||||||
# We later check via (r) "subscript" flag that our key |
|
||||||
# is in the values of our flat array. |
|
||||||
typeset -ah _ICONS_UNDER_TEST |
|
||||||
_ICONS_UNDER_TEST=(${(k)icons[@]}) |
|
||||||
|
|
||||||
# Switch to "default" mode |
|
||||||
POWERLEVEL9K_MODE="default" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
# Iterate over all keys found in the _ICONS_UNDER_TEST |
|
||||||
# array and compare it with the icons array of the |
|
||||||
# current POWERLEVEL9K_MODE. |
|
||||||
# Use parameter expansion, to directly check if the |
|
||||||
# key exists in the flat current array of keys. That |
|
||||||
# is quite complicated, but there seems no easy way |
|
||||||
# to check the mere existance of a key in an array. |
|
||||||
# The usual way would always return the value, so that |
|
||||||
# would do the wrong thing as we have some (on purpose) |
|
||||||
# empty values. |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
# Switch to "awesome-fontconfig" mode |
|
||||||
POWERLEVEL9K_MODE="awesome-fontconfig" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
# Switch to "nerdfont-fontconfig" mode |
|
||||||
POWERLEVEL9K_MODE="nerdfont-fontconfig" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
# Switch to "flat" mode |
|
||||||
POWERLEVEL9K_MODE="flat" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
# Switch to "compatible" mode |
|
||||||
POWERLEVEL9K_MODE="compatible" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
unset current_icons |
|
||||||
unset _ICONS_UNDER_TEST |
|
||||||
} |
|
||||||
|
|
||||||
# Go through all icons defined in awesome-fontconfig mode, and |
|
||||||
# check if all of them are defined in the other modes. |
|
||||||
function testAllIconsAreDefinedLikeInAwesomeFontconfigMode() { |
|
||||||
# Always compare against this mode |
|
||||||
local _P9K_TEST_MODE="awesome-fontconfig" |
|
||||||
POWERLEVEL9K_MODE="$_P9K_TEST_MODE" |
|
||||||
source functions/icons.zsh |
|
||||||
# _ICONS_UNDER_TEST is an array of just the keys of $icons. |
|
||||||
# We later check via (r) "subscript" flag that our key |
|
||||||
# is in the values of our flat array. |
|
||||||
typeset -ah _ICONS_UNDER_TEST |
|
||||||
_ICONS_UNDER_TEST=(${(k)icons[@]}) |
|
||||||
|
|
||||||
# Switch to "default" mode |
|
||||||
POWERLEVEL9K_MODE="default" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
# Iterate over all keys found in the _ICONS_UNDER_TEST |
|
||||||
# array and compare it with the icons array of the |
|
||||||
# current POWERLEVEL9K_MODE. |
|
||||||
# Use parameter expansion, to directly check if the |
|
||||||
# key exists in the flat current array of keys. That |
|
||||||
# is quite complicated, but there seems no easy way |
|
||||||
# to check the mere existance of a key in an array. |
|
||||||
# The usual way would always return the value, so that |
|
||||||
# would do the wrong thing as we have some (on purpose) |
|
||||||
# empty values. |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
# Switch to "awesome-patched" mode |
|
||||||
POWERLEVEL9K_MODE="awesome-patched" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
# Switch to "nerdfont-fontconfig" mode |
|
||||||
POWERLEVEL9K_MODE="nerdfont-fontconfig" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
# Switch to "flat" mode |
|
||||||
POWERLEVEL9K_MODE="flat" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
# Switch to "compatible" mode |
|
||||||
POWERLEVEL9K_MODE="compatible" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
unset current_icons |
|
||||||
unset _ICONS_UNDER_TEST |
|
||||||
} |
|
||||||
|
|
||||||
# Go through all icons defined in nerdfont-fontconfig mode, and |
|
||||||
# check if all of them are defined in the other modes. |
|
||||||
function testAllIconsAreDefinedLikeInNerdfontFontconfigMode() { |
|
||||||
# Always compare against this mode |
|
||||||
local _P9K_TEST_MODE="nerdfont-fontconfig" |
|
||||||
POWERLEVEL9K_MODE="$_P9K_TEST_MODE" |
|
||||||
source functions/icons.zsh |
|
||||||
# _ICONS_UNDER_TEST is an array of just the keys of $icons. |
|
||||||
# We later check via (r) "subscript" flag that our key |
|
||||||
# is in the values of our flat array. |
|
||||||
typeset -ah _ICONS_UNDER_TEST |
|
||||||
_ICONS_UNDER_TEST=(${(k)icons[@]}) |
|
||||||
|
|
||||||
# Switch to "default" mode |
|
||||||
POWERLEVEL9K_MODE="default" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
# Iterate over all keys found in the _ICONS_UNDER_TEST |
|
||||||
# array and compare it with the icons array of the |
|
||||||
# current POWERLEVEL9K_MODE. |
|
||||||
# Use parameter expansion, to directly check if the |
|
||||||
# key exists in the flat current array of keys. That |
|
||||||
# is quite complicated, but there seems no easy way |
|
||||||
# to check the mere existance of a key in an array. |
|
||||||
# The usual way would always return the value, so that |
|
||||||
# would do the wrong thing as we have some (on purpose) |
|
||||||
# empty values. |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
# Switch to "awesome-patched" mode |
|
||||||
POWERLEVEL9K_MODE="awesome-patched" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
# Switch to "awesome-fontconfig" mode |
|
||||||
POWERLEVEL9K_MODE="awesome-fontconfig" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
# Switch to "flat" mode |
|
||||||
POWERLEVEL9K_MODE="flat" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
# Switch to "compatible" mode |
|
||||||
POWERLEVEL9K_MODE="compatible" |
|
||||||
source functions/icons.zsh |
|
||||||
typeset -ah current_icons |
|
||||||
current_icons=(${(k)icons[@]}) |
|
||||||
for key in ${_ICONS_UNDER_TEST}; do |
|
||||||
assertTrue "The key ${key} does exist in ${_P9K_TEST_MODE} mode, but not in ${POWERLEVEL9K_MODE}!" "(( ${+current_icons[(r)$key]} ))" |
|
||||||
done |
|
||||||
|
|
||||||
unset current_icons |
|
||||||
unset _ICONS_UNDER_TEST |
|
||||||
} |
|
||||||
|
|
||||||
source shunit2/source/2.1/src/shunit2 |
|
@ -1,109 +0,0 @@ |
|||||||
#!/usr/bin/env zsh |
|
||||||
#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 |
|
||||||
|
|
||||||
# Required for shunit2 to run correctly |
|
||||||
setopt shwordsplit |
|
||||||
SHUNIT_PARENT=$0 |
|
||||||
|
|
||||||
function setUp() { |
|
||||||
# Load Powerlevel9k |
|
||||||
source functions/icons.zsh |
|
||||||
source functions/utilities.zsh |
|
||||||
} |
|
||||||
|
|
||||||
function testDefinedFindsDefinedVariable() { |
|
||||||
my_var='X' |
|
||||||
|
|
||||||
assertTrue "defined 'my_var'" |
|
||||||
unset my_var |
|
||||||
} |
|
||||||
|
|
||||||
function testDefinedDoesNotFindUndefinedVariable() { |
|
||||||
assertFalse "defined 'my_var'" |
|
||||||
} |
|
||||||
|
|
||||||
function testSetDefaultSetsVariable() { |
|
||||||
set_default 'my_var' 'x' |
|
||||||
|
|
||||||
assertEquals 'x' "$my_var" |
|
||||||
unset my_var |
|
||||||
} |
|
||||||
|
|
||||||
function testPrintSizeHumanReadableWithBigNumber() { |
|
||||||
# Interesting: Currently we can't support numbers bigger than that. |
|
||||||
assertEquals '0.87E' "$(printSizeHumanReadable 1000000000000000000)" |
|
||||||
} |
|
||||||
|
|
||||||
function testPrintSizeHumanReadableWithExabytesAsBase() { |
|
||||||
assertEquals '9.77Z' "$(printSizeHumanReadable 10000 'E')" |
|
||||||
} |
|
||||||
|
|
||||||
function testGetRelevantItem() { |
|
||||||
typeset -a list |
|
||||||
list=(a b c) |
|
||||||
local callback='[[ "$item" == "b" ]] && echo "found"' |
|
||||||
|
|
||||||
local result=$(getRelevantItem "$list" "$callback") |
|
||||||
assertEquals 'found' "$result" |
|
||||||
|
|
||||||
unset list |
|
||||||
} |
|
||||||
|
|
||||||
function testGetRelevantItemDoesNotReturnNotFoundItems() { |
|
||||||
typeset -a list |
|
||||||
list=(a b c) |
|
||||||
local callback='[[ "$item" == "d" ]] && echo "found"' |
|
||||||
|
|
||||||
local result=$(getRelevantItem "$list" "$callback") |
|
||||||
assertEquals '' '' |
|
||||||
|
|
||||||
unset list |
|
||||||
} |
|
||||||
|
|
||||||
function testSegmentShouldBeJoinedIfDirectPredecessingSegmentIsJoined() { |
|
||||||
typeset -a segments |
|
||||||
segments=(a b_joined c_joined) |
|
||||||
# Look at the third segment |
|
||||||
local current_index=3 |
|
||||||
local last_element_index=2 |
|
||||||
|
|
||||||
local joined |
|
||||||
segmentShouldBeJoined $current_index $last_element_index "$segments" && joined=true || joined=false |
|
||||||
assertTrue "$joined" |
|
||||||
|
|
||||||
unset segments |
|
||||||
} |
|
||||||
|
|
||||||
function testSegmentShouldBeJoinedIfPredecessingSegmentIsJoinedTransitivley() { |
|
||||||
typeset -a segments |
|
||||||
segments=(a b_joined c_joined) |
|
||||||
# Look at the third segment |
|
||||||
local current_index=3 |
|
||||||
# The last printed segment was the first one, |
|
||||||
# the second segmend was conditional. |
|
||||||
local last_element_index=1 |
|
||||||
|
|
||||||
local joined |
|
||||||
segmentShouldBeJoined $current_index $last_element_index "$segments" && joined=true || joined=false |
|
||||||
assertTrue "$joined" |
|
||||||
|
|
||||||
unset segments |
|
||||||
} |
|
||||||
|
|
||||||
function testSegmentShouldNotBeJoinedIfPredecessingSegmentIsNotJoinedButConditional() { |
|
||||||
typeset -a segments |
|
||||||
segments=(a b_joined c d_joined) |
|
||||||
# Look at the fourth segment |
|
||||||
local current_index=4 |
|
||||||
# The last printed segment was the first one, |
|
||||||
# the second segmend was conditional. |
|
||||||
local last_element_index=1 |
|
||||||
|
|
||||||
local joined |
|
||||||
segmentShouldBeJoined $current_index $last_element_index "$segments" && joined=true || joined=false |
|
||||||
assertFalse "$joined" |
|
||||||
|
|
||||||
unset segments |
|
||||||
} |
|
||||||
|
|
||||||
source shunit2/source/2.1/src/shunit2 |
|
Loading…
Reference in new issue