From c9291ffcbff017e45572ce8b41d7a4d6f7ecd04e Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Wed, 19 Feb 2020 12:07:52 +0000 Subject: [PATCH] Moves includes into includes folder --- .../aliases.zsh | 2 +- .../completion.zsh | 0 .../functions.zsh | 0 .../{oh-my-zsh-custom => includes}/fzf.zsh | 2 +- .../globals.zsh | 0 shells/zsh/includes/lfcd.zsh | 12 + .../promptconfig.zsh | 8 +- .../rangercd.zsh | 2 +- .../shortcuts.zsh | 0 shells/zsh/oh-my-zsh-custom/completion/_pass | 144 -- .../themes/powerlevel9k/.gitignore | 1 - .../themes/powerlevel9k/.gitmodules | 3 - .../themes/powerlevel9k/.travis.yml | 30 - .../themes/powerlevel9k/CHANGELOG.md | 362 ----- .../themes/powerlevel9k/LICENSE | 20 - .../themes/powerlevel9k/README.md | 514 ------ .../themes/powerlevel9k/TESTS.md | 22 - .../themes/powerlevel9k/debug/font-issues.zsh | 182 --- .../themes/powerlevel9k/debug/iterm.zsh | 86 - .../themes/powerlevel9k/functions/colors.zsh | 56 - .../themes/powerlevel9k/functions/icons.zsh | 342 ---- .../powerlevel9k/functions/utilities.zsh | 234 --- .../themes/powerlevel9k/functions/vcs.zsh | 152 -- .../powerlevel9k/powerlevel9k.zsh-theme | 1402 ----------------- .../powerlevel9k/prompt_powerlevel9k_setup | 1 - .../powerlevel9k/test-bsd-vm/Vagrantfile | 87 - .../test-bsd-vm/bootstrap-zero.sh | 3 - .../powerlevel9k/test-bsd-vm/bootstrap.sh | 13 - .../powerlevel9k/test-vm-providers/plain.sh | 9 - .../test-vm-providers/setup-environment.sh | 44 - .../themes/powerlevel9k/test-vm/README.md | 25 - .../themes/powerlevel9k/test-vm/Vagrantfile | 82 - .../themes/powerlevel9k/test-vm/antigen.sh | 30 - .../themes/powerlevel9k/test-vm/bootstrap.sh | 19 - .../themes/powerlevel9k/test-vm/omz.sh | 33 - .../themes/powerlevel9k/test-vm/prezto.sh | 29 - .../powerlevel9k/test/functions/colors.spec | 42 - .../powerlevel9k/test/functions/icons.spec | 362 ----- .../test/functions/utilities.spec | 109 -- .../powerlevel9k/test/powerlevel9k.spec | 117 -- .../test/segments/command_execution_time.spec | 96 -- .../powerlevel9k/test/segments/dir.spec | 364 ----- .../test/segments/go_version.spec | 86 - .../test/segments/rust_version.spec | 40 - .../powerlevel9k/test/segments/vcs.spec | 81 - 45 files changed, 19 insertions(+), 5229 deletions(-) rename shells/zsh/{oh-my-zsh-custom => includes}/aliases.zsh (97%) rename shells/zsh/{oh-my-zsh-custom => includes}/completion.zsh (100%) rename shells/zsh/{oh-my-zsh-custom => includes}/functions.zsh (100%) rename shells/zsh/{oh-my-zsh-custom => includes}/fzf.zsh (98%) rename shells/zsh/{oh-my-zsh-custom => includes}/globals.zsh (100%) create mode 100644 shells/zsh/includes/lfcd.zsh rename shells/zsh/{oh-my-zsh-custom => includes}/promptconfig.zsh (96%) rename shells/zsh/{oh-my-zsh-custom => includes}/rangercd.zsh (91%) rename shells/zsh/{oh-my-zsh-custom => includes}/shortcuts.zsh (100%) delete mode 100644 shells/zsh/oh-my-zsh-custom/completion/_pass delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/.gitignore delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/.gitmodules delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/.travis.yml delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/CHANGELOG.md delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/LICENSE delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/README.md delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/TESTS.md delete mode 100755 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/debug/font-issues.zsh delete mode 100755 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/debug/iterm.zsh delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/colors.zsh delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/icons.zsh delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/utilities.zsh delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/vcs.zsh delete mode 100755 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/powerlevel9k.zsh-theme delete mode 120000 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/prompt_powerlevel9k_setup delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-bsd-vm/Vagrantfile delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-bsd-vm/bootstrap-zero.sh delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-bsd-vm/bootstrap.sh delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm-providers/plain.sh delete mode 100755 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm-providers/setup-environment.sh delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/README.md delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/Vagrantfile delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/antigen.sh delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/bootstrap.sh delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/omz.sh delete mode 100644 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/prezto.sh delete mode 100755 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/functions/colors.spec delete mode 100755 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/functions/icons.spec delete mode 100755 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/functions/utilities.spec delete mode 100755 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/powerlevel9k.spec delete mode 100755 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/command_execution_time.spec delete mode 100755 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/dir.spec delete mode 100755 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/go_version.spec delete mode 100755 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/rust_version.spec delete mode 100755 shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/vcs.spec diff --git a/shells/zsh/oh-my-zsh-custom/aliases.zsh b/shells/zsh/includes/aliases.zsh similarity index 97% rename from shells/zsh/oh-my-zsh-custom/aliases.zsh rename to shells/zsh/includes/aliases.zsh index abbb4fbb..93e7b7cb 100644 --- a/shells/zsh/oh-my-zsh-custom/aliases.zsh +++ b/shells/zsh/includes/aliases.zsh @@ -21,4 +21,4 @@ alias -s gitignore=$EDITOR alias -s json=$EDITOR -unalias gf +#unalias gf diff --git a/shells/zsh/oh-my-zsh-custom/completion.zsh b/shells/zsh/includes/completion.zsh similarity index 100% rename from shells/zsh/oh-my-zsh-custom/completion.zsh rename to shells/zsh/includes/completion.zsh diff --git a/shells/zsh/oh-my-zsh-custom/functions.zsh b/shells/zsh/includes/functions.zsh similarity index 100% rename from shells/zsh/oh-my-zsh-custom/functions.zsh rename to shells/zsh/includes/functions.zsh diff --git a/shells/zsh/oh-my-zsh-custom/fzf.zsh b/shells/zsh/includes/fzf.zsh similarity index 98% rename from shells/zsh/oh-my-zsh-custom/fzf.zsh rename to shells/zsh/includes/fzf.zsh index fca9413e..1111a9df 100644 --- a/shells/zsh/oh-my-zsh-custom/fzf.zsh +++ b/shells/zsh/includes/fzf.zsh @@ -1,5 +1,5 @@ # this rg command will get a list of files that are not in gitignore or similar -export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git" +export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git --exclude .PlayOnLinux --exclude \"PlayOnLinux\'s virtual drives\"" export FZF_DEFAULT_OPTS="--preview '[[ \$(file -L --mime {}) =~ binary ]] && echo {} is a binary file || ( bat --style=numbers --color=always {} || cat {}) 2> /dev/null | head -500'" export FZF_CTRL_R_OPTS="--no-preview" # this is the argument completeion optionm, use the same command diff --git a/shells/zsh/oh-my-zsh-custom/globals.zsh b/shells/zsh/includes/globals.zsh similarity index 100% rename from shells/zsh/oh-my-zsh-custom/globals.zsh rename to shells/zsh/includes/globals.zsh diff --git a/shells/zsh/includes/lfcd.zsh b/shells/zsh/includes/lfcd.zsh new file mode 100644 index 00000000..ee16f193 --- /dev/null +++ b/shells/zsh/includes/lfcd.zsh @@ -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' diff --git a/shells/zsh/oh-my-zsh-custom/promptconfig.zsh b/shells/zsh/includes/promptconfig.zsh similarity index 96% rename from shells/zsh/oh-my-zsh-custom/promptconfig.zsh rename to shells/zsh/includes/promptconfig.zsh index 9093297c..e84c2f1e 100644 --- a/shells/zsh/oh-my-zsh-custom/promptconfig.zsh +++ b/shells/zsh/includes/promptconfig.zsh @@ -104,12 +104,12 @@ function prompt_project() { local parent_process="$(ps -ocommand -p $PPID | grep -v 'COMMAND' | cut -d' ' -f1)" local current_project_full="$(project current --path)" local current_project_name="$(project current)" + if [[ "$parent_process" == "/usr/bin/script" ]]; then + segment_content="辶" + fi # If there is a current project if [ -n "$current_project_name" ]; then - segment_content="$current_project_name" - if [[ "$parent_process" == "/usr/bin/script" ]]; then - segment_content="辶$segment_content" - fi + segment_content="${segment_content}$current_project_name" # If in the current project if echo "$PWD" | grep -q "$current_project_full"; then state="INSIDE" diff --git a/shells/zsh/oh-my-zsh-custom/rangercd.zsh b/shells/zsh/includes/rangercd.zsh similarity index 91% rename from shells/zsh/oh-my-zsh-custom/rangercd.zsh rename to shells/zsh/includes/rangercd.zsh index 6e5275ee..710eed43 100644 --- a/shells/zsh/oh-my-zsh-custom/rangercd.zsh +++ b/shells/zsh/includes/rangercd.zsh @@ -9,4 +9,4 @@ rangercd () { fi } alias ranger="rangercd" -bindkey -s '^o' 'ranger\n' +#bindkey -s '^o' 'ranger\n' diff --git a/shells/zsh/oh-my-zsh-custom/shortcuts.zsh b/shells/zsh/includes/shortcuts.zsh similarity index 100% rename from shells/zsh/oh-my-zsh-custom/shortcuts.zsh rename to shells/zsh/includes/shortcuts.zsh diff --git a/shells/zsh/oh-my-zsh-custom/completion/_pass b/shells/zsh/oh-my-zsh-custom/completion/_pass deleted file mode 100644 index 27ce15a1..00000000 --- a/shells/zsh/oh-my-zsh-custom/completion/_pass +++ /dev/null @@ -1,144 +0,0 @@ -#compdef pass -#autoload - -# Copyright (C) 2012 - 2014: -# Johan Venant -# Brian Mattern -# Jason A. Donenfeld . -# 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 diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/.gitignore b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/.gitignore deleted file mode 100644 index 8f6423fa..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/.gitignore +++ /dev/null @@ -1 +0,0 @@ -test-vm/.vagrant diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/.gitmodules b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/.gitmodules deleted file mode 100644 index 743b8e91..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "shunit2"] - path = shunit2 - url = https://github.com/kward/shunit2.git diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/.travis.yml b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/.travis.yml deleted file mode 100644 index 134f31f1..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/.travis.yml +++ /dev/null @@ -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 diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/CHANGELOG.md b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/CHANGELOG.md deleted file mode 100644 index 6257416b..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/CHANGELOG.md +++ /dev/null @@ -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__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 diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/LICENSE b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/LICENSE deleted file mode 100644 index 812d306a..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2014-2017 Ben Hilburn - -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. diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/README.md b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/README.md deleted file mode 100644 index 1f7dcadb..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/README.md +++ /dev/null @@ -1,514 +0,0 @@ -![](https://raw.githubusercontent.com/bhilburn/powerlevel9k-logo/master/logo-banner.png) ---- -[![Build Status](https://travis-ci.org/bhilburn/powerlevel9k.svg?branch=next)](https://travis-ci.org/bhilburn/powerlevel9k) -[![Join the chat at https://gitter.im/bhilburn/powerlevel9k](https://badges.gitter.im/bhilburn/powerlevel9k.svg)](https://gitter.im/bhilburn/powerlevel9k?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - -Powerlevel9k is a theme for ZSH which uses [Powerline -Fonts](https://github.com/powerline/fonts). It can be used with vanilla ZSH or -ZSH frameworks such as [Oh-My-Zsh](https://github.com/robbyrussell/oh-my-zsh), -[Prezto](https://github.com/sorin-ionescu/prezto), -[Antigen](https://github.com/zsh-users/antigen), and [many -others](https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions). - -Get more out of your terminal. Be a badass. Impress everyone in 'Screenshot Your -Desktop' threads. Use powerlevel9k. - -![](http://bhilburn.org/content/images/2015/01/pl9k-improved.png) - -You can check out some other users' configurations in our wiki: [Show Off Your -Config](https://github.com/bhilburn/powerlevel9k/wiki/Show-Off-Your-Config). - -There are a number of Powerline ZSH themes available, now. The developers of -this theme focus on four primary goals: - -1. Give users a great out-of-the-box configuration with no additional - configuration required. -2. Make customization easy for users who do want to tweak their prompt. -3. Provide useful segments that you can enable to make your prompt even more - effective and helpful. We have prompt segments for everything from unit test - coverage to your AWS instance. -4. Optimize the code for execution speed as much as possible. A snappy terminal - is a happy terminal. - -Powerlevel9k can be used to create both very useful and beautiful terminal environments: - -![](https://camo.githubusercontent.com/b5d7eb49a30bfe6bdb5706fa3c9be95fe8e5956e/687474703a2f2f67696679752e636f6d2f696d616765732f70396b6e65772e676966) - -### Table of Contents - -1. [Installation](#installation) -2. [Customization](#prompt-customization) - 1. [Stylizing Your Prompt](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt) - 2. [Customizing Prompt Segments](#customizing-prompt-segments) - 3. [Available Prompt Segments](#available-prompt-segments) -3. [Troubleshooting](https://github.com/bhilburn/powerlevel9k/wiki/Troubleshooting) - -Be sure to also [check out the Wiki](https://github.com/bhilburn/powerlevel9k/wiki)! - -### Installation -There are two installation steps to go from a vanilla terminal to a PL9k -terminal. Once you are done, you can optionally customize your prompt. - -[Installation Instructions](https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions) - -1. [Install the Powerlevel9k Theme](https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions#step-1-install-powerlevel9k) -2. [Install Powerline Fonts](https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions#step-2-install-a-powerline-font) - -No configuration is necessary post-installation if you like the default -settings, but there are plenty of segment customization options available if you -are interested. - -### Prompt Customization - -Be sure to check out the wiki page on the additional prompt customization -options, including color and icon settings: [Stylizing Your Prompt](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt) - -#### Customizing Prompt Segments -Customizing your prompt is easy! Select the segments you want to have displayed, -and then assign them to either the left or right prompt by adding the following -variables to your `~/.zshrc`. - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`POWERLEVEL9K_LEFT_PROMPT_ELEMENTS`|`(context dir rbenv vcs)`|Segment list for left prompt| -|`POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS`|`(status root_indicator background_jobs history time)`|Segment list for right prompt| - - -The table above shows the default values, so if you wanted to set these -variables manually, you would put the following in -your `~/.zshrc`: -```zsh -POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) -POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time) -``` -#### Available Prompt Segments -The segments that are currently available are: - -**System Status Segments:** -* [`background_jobs`](#background_jobs) - Indicator for background jobs. -* [`battery`](#battery) - Current battery status. -* [`context`](#context) - Your username and host, conditionalized based on $USER and SSH status. -* [`dir`](#dir) - Your current working directory. -* `dir_writable` - Displays a lock icon, if you do not have write permissions on the current folder. -* [`disk_usage`](#disk_usage) - Disk usage of your current partition. -* `history` - The command number for the current line. -* [`ip`](#ip) - Shows the current IP address. -* [`public_ip`](#public_ip) - Shows your public IP address. -* `load` - Your machine's load averages. -* `os_icon` - Display a nice little icon, depending on your operating system. -* `ram` - Show free RAM. -* `root_indicator` - An indicator if the user has superuser status. -* [`status`](#status) - The return code of the previous command. -* `swap` - Prints the current swap size. -* [`time`](#time) - System time. -* [`vi_mode`](#vi_mode)- Your prompt's Vi editing mode (NORMAL|INSERT). -* `ssh` - Indicates whether or not you are in an SSH session. - -**Development Environment Segments:** -* [`vcs`](#vcs) - Information about this `git` or `hg` repository (if you are in one). - -**Language Segments:** -* **GoLang Segments:** - * `go_version` - Show the current GO version. -* **Javascript / Node.js Segments:** - * `node_version` - Show the version number of the installed Node.js. - * `nodeenv` - [nodeenv](https://github.com/ekalinin/nodeenv) prompt for displaying node version and environment name. - * `nvm` - Show the version of Node that is currently active, if it differs from the version used by NVM -* **PHP Segments:** - * `php_version` - Show the current PHP version. - * [`symfony2_tests`](#symfony2_tests) - Show a ratio of test classes vs code classes for Symfony2. - * `symfony2_version` - Show the current Symfony2 version, if you are in a Symfony2-Project dir. -* **Python Segments:** - * `virtualenv` - Your Python [VirtualEnv](https://virtualenv.pypa.io/en/latest/). - * [`anaconda`](#anaconda) - Your active [Anaconda](https://www.continuum.io/why-anaconda) environment. - * `pyenv` - Your active python version as reported by the first word of [`pyenv version`](https://github.com/yyuu/pyenv). Note that the segment is not displayed if that word is _system_ i.e. the segment is inactive if you are using system python. -* **Ruby Segments:** - * [`chruby`](#chruby) - Ruby environment information using `chruby` (if one is active). - * [`rbenv`](#rbenv) - Ruby environment information using `rbenv` (if one is active). - * [`rspec_stats`](#rspec_stats) - Show a ratio of test classes vs code classes for RSpec. -* **Rust Segments:** - * `rust_version` - Display the current rust version and [logo](https://www.rust-lang.org/logos/rust-logo-blk.svg). -* **Swift Segments:** - * `swift_version` - Show the version number of the installed Swift. - -**Cloud Segments:** -* **AWS Segments:** - * [`aws`](#aws) - The current AWS profile, if active. - * `aws_eb_env` - The current Elastic Beanstalk Environment. -* `docker_machine` - The current Docker Machine. - -**Other:** -* [`custom_command`](#custom_command) - Create a custom segment to display the - output of an arbitrary command. -* [`command_execution_time`](#command_execution_time) - Display the time the current command took to execute. -* [`todo`](http://todotxt.com/) - Shows the number of tasks in your todo.txt tasks file. -* `detect_virt` - Virtualization detection with systemd - ---------------------------------------------------------------------------------- - - -##### anaconda - -This segment shows your active anaconda environment. It relies on either the -`CONDA_ENV_PATH` or the `CONDA_PREFIX` (depending on the `conda` version) -environment variable to be set which happens when you properly `source -activate` an environment. - -Special configuration variables: - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`POWERLEVEL9K_ANACONDA_LEFT_DELIMITER`|"("|The left delimiter just before the environment name.| -|`POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER`|")"|The right delimiter just after the environment name.| - -Additionally the following segment specific parameters can be used to customize -it: `POWERLEVEL9K_PYTHON_ICON`, `POWERLEVEL9K_ANACONDA_BACKGROUND`, and -`POWERLEVEL9K_ANACONDA_FOREGROUND`. - -##### aws - -If you would like to display the [current AWS -profile](http://docs.aws.amazon.com/cli/latest/userguide/installing.html), add -the `aws` segment to one of the prompts, and define `AWS_DEFAULT_PROFILE` in -your `~/.zshrc`: - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`AWS_DEFAULT_PROFILE`|None|Your AWS profile name| - -##### background_jobs - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE`|`true`|If there is more than one background job, this segment will show the number of jobs. Set this to `false` to turn this feature off.| - -##### battery - -This segment will display your current battery status (fails gracefully on -systems without a battery). It is supported on both OSX and Linux (note that it -requires `acpi` on Linux). - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`POWERLEVEL9K_BATTERY_CHARGING`|`"yellow"`|Color to indicate a charging battery.| -|`POWERLEVEL9K_BATTERY_CHARGED`|`"green"`|Color to indicate a charged battery.| -|`POWERLEVEL9K_BATTERY_DISCONNECTED`|`$DEFAULT_COLOR`|Color to indicate absence of battery.| -|`POWERLEVEL9K_BATTERY_LOW_THRESHOLD`|`10`|Threshold to consider battery level critical.| -|`POWERLEVEL9K_BATTERY_LOW_COLOR`|`"red"`|Color to indicate critically low charge level.| -|`POWERLEVEL9K_BATTERY_VERBOSE`|`true`|Display time remaining next to battery level.| - -Note that you can [modify the `_FOREGROUND` -color](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt#segment-color-customization) -without affecting the icon color. - -##### command_execution_time - -Display the time the previous command took to execute if the time is above -`POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD`. The time is formatted to be -"human readable", and so scales the units based on the length of execution time. -If you want more precision, just set the -`POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION` field. - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD`|3|Threshold above which to print this segment. Can be set to `0` to always print.| -|`POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION`|2|Number of digits to use in the fractional part of the time value.| - -##### custom_command - -The `custom_...` segment allows you to turn the output of a custom command into -a prompt segment. As an example, if you wanted to create a custom segment to -display your WiFi signal strength, you might define a custom segment called -`custom_wifi_signal` like this: -```zsh -POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal) -POWERLEVEL9K_CUSTOM_WIFI_SIGNAL="echo signal: \$(nmcli device wifi | grep yes | awk '{print \$8}')" -POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_BACKGROUND="blue" -POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_FOREGROUND="yellow" -``` -If you prefer, you can also define the function in your `.zshrc` rather than -putting it in-line with the variable export, as shown above. Just don't forget -to invoke your function from your segment! Example code that achieves the same -result as the above: -```zsh -zsh_wifi_signal(){ - local signal=$(nmcli device wifi | grep yes | awk '{print $8}') - local color='%F{yellow}' - [[ $signal -gt 75 ]] && color='%F{green}' - [[ $signal -lt 50 ]] && color='%F{red}' - echo -n "%{$color%}\uf230 $signal%{%f%}" # \uf230 is  -} - -POWERLEVEL9K_CUSTOM_WIFI_SIGNAL="zsh_wifi_signal" -POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal) -``` -The command, above, gives you the wireless signal segment shown below: - -![signal](http://i.imgur.com/hviMATC.png) - -You can define as many custom segments as you wish. If you think you have -a segment that others would find useful, please consider upstreaming it to the -main theme distribution so that everyone can use it! - -##### context - -The `context` segment (user@host string) is conditional. By default, it will -only print if you are not your 'normal' user (including if you are root), or if -you are SSH'd to a remote host. - -To use this feature, make sure the `context` segment is enabled in your prompt -elements (it is by default), and define a `DEFAULT_USER` in your `~/.zshrc`. - -You can customize the `context` segment. For example, you can make it to print the -full hostname by setting -``` -POWERLEVEL9K_CONTEXT_TEMPLATE="%n@`hostname -f`" -``` - - -You can set the `POWERLEVEL9K_CONTEXT_HOST_DEPTH` variable to change how the -hostname is displayed. See (ZSH Manual)[http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Login-information] -for details. The default is set to %m which will show the hostname up to the first ‘.’ -You can set it to %{N}m where N is an integer to show that many segments of system -hostname. Setting N to a negative integer will show that many segments from the -end of the hostname. - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`DEFAULT_USER`|None|Username to consider a "default context" (you can also set `$USER`).| -|`POWERLEVEL9K_ALWAYS_SHOW_CONTEXT`|false|Always show this segment, including $USER and hostname.| -|`POWERLEVEL9K_ALWAYS_SHOW_USER`|false|Always show the username, but conditionalize the hostname.| -|`POWERLEVEL9K_CONTEXT_TEMPLATE`|%n@%m|Default context prompt (username@machine). Refer to the [ZSH Documentation](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) for all possible expansions, including deeper host depths.| - -##### dir - -The `dir` segment shows the current working directory. When using the "Awesome -Powerline" fonts, there are additional glyphs, as well: - -| `Compatible` | `Powerline` | `Awesome Powerline` | Situation -|------------|-----------|-------------------|---------------------------- -| None | None | ![](https://cloud.githubusercontent.com/assets/1544760/12183451/40ec4016-b58f-11e5-9b9e-74e2b2f0b8b3.png) | At the root of your home folder | -| None | None | ![](https://cloud.githubusercontent.com/assets/1544760/12369315/8a5d762c-bbf5-11e5-8a20-ca1179f48d6c.png) | Within a subfolder of your home directory | -| None | None | ![](https://cloud.githubusercontent.com/assets/1544760/12183452/40f79286-b58f-11e5-9b8c-ed1343a07b08.png) | Outside of your home folder | - -To turn off these icons you could set these variables to an empty string. -```zsh -POWERLEVEL9K_HOME_ICON='' -POWERLEVEL9K_HOME_SUB_ICON='' -POWERLEVEL9K_FOLDER_ICON='' -``` -You can limit the output to a certain length by truncating long paths. -Customizations available are: - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`POWERLEVEL9K_SHORTEN_DIR_LENGTH`|`2`|If your shorten strategy, below, is entire directories, this field determines how many directories to leave at the end. If your shorten strategy is by character count, this field determines how many characters to allow per directory string.| -|`POWERLEVEL9K_SHORTEN_STRATEGY`|None|How the directory strings should be truncated. See the table below for more informations.| -|`POWERLEVEL9K_SHORTEN_DELIMITER`|`..`|Delimiter to use in truncated strings. This can be any string you choose, including an empty string if you wish to have no delimiter.| - -| Strategy Name | Description | -|---------------|-------------| -|Default|Truncate whole directories from left. How many is defined by `POWERLEVEL9K_SHORTEN_DIR_LENGTH`| -|`truncate_middle`|Truncates the middle part of a folder. E.g. you are in a folder named "~/MySuperProjects/AwesomeFiles/BoringOffice", then it will truncated to "~/MyS..cts/Awe..les/BoringOffice", if `POWERLEVEL9K_SHORTEN_DIR_LENGTH=3` is also set (controls the amount of characters to be left).| -|`truncate_from_right`|Just leaves the beginning of a folder name untouched. E.g. your folders will be truncated like so: "/ro../Pr../office". How many characters will be untouched is controlled by `POWERLEVEL9K_SHORTEN_DIR_LENGTH`.| -|`truncate_with_package_name`|Search for a `package.json` or `composer.json` and prints the `name` field to abbreviate the directory path. The precedence and/or files could be set by `POWERLEVEL9K_DIR_PACKAGE_FILES=(package.json composer.json)`. If you have [jq](https://stedolan.github.io/jq/) installed, it will dramatically improve the speed of this strategy.| -|`truncate_with_folder_marker`|Search for a file that is specified by `POWERLEVEL9K_SHORTEN_FOLDER_MARKER` and truncate everything before that (if found, otherwise stop on $HOME and ROOT).| - -For example, if you wanted the truncation behavior of the `fish` shell, which -truncates `/usr/share/plasma` to `/u/s/plasma`, you would use the following: -```zsh -POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 -POWERLEVEL9K_SHORTEN_DELIMITER="" -POWERLEVEL9K_SHORTEN_STRATEGY="truncate_from_right" -``` -In each case you have to specify the length you want to shorten the directory -to. So in some cases `POWERLEVEL9K_SHORTEN_DIR_LENGTH` means characters, in -others whole directories. - -The `truncate_with_package_name` strategy gives your directory path relative to the root of your project. For example, if you have a project inside `$HOME/projects/my-project` with a `package.json` that looks like: - -```json -{ - "name": "my-cool-project" -} -``` - -the path shown would be `my-cool-project`. If you navigate to `$HOME/projects/my-project/src`, then the path shown would be `my-cool-project/src`. Please note that this currently looks for `.git` directory to determine the root of the project. - -If you want to customize the directory separator, you could set: -```zsh -# Double quotes are important here! -POWERLEVEL9K_DIR_PATH_SEPARATOR="%F{red} $(print_icon 'LEFT_SUBSEGMENT_SEPARATOR') %F{black}" -``` -To omit the first character (usually a slash that gets replaced if you set `POWERLEVEL9K_DIR_PATH_SEPARATOR`), -you could set `POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true`. - -You can also customize the leading tilde character when you are in `$HOME` using: -```zsh -# Double quotes are important here! -POWERLEVEL9K_HOME_FOLDER_ABBREVIATION="%F{red} $(print_icon 'HOME_ICON') %F{black}" -``` - - -##### disk_usage - -The `disk_usage` segment will show the usage level of the partition that your current working directory resides in. It can be configured with the following variables. - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|POWERLEVEL9K_DISK_USAGE_ONLY_WARNING|false|Hide the segment except when usage levels have hit warning or critical levels.| -|POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL|90|The usage level that triggers a warning state.| -|POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL|95|The usage level that triggers a critical state.| - -##### ip - -This segment tries to examine all currently used network interfaces and prints -the first address it finds. In the case that this is not the right NIC, you can -specify the correct network interface by setting: - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`POWERLEVEL9K_IP_INTERFACE`|None|The NIC for which you wish to display the IP address. Example: `eth0`.| - -##### public_ip - -This segment will display your public IP address. There are several methods of obtaining this -information and by default it will try all of them starting with the most efficient. You can -also specify which method you would like it to use. The methods available are dig using opendns, -curl, or wget. The host used for wget and curl is http://ident.me by default but can be set to -another host if you prefer. - -The public_ip segment will attempt to update your public IP address every 5 minutes by default(also -configurable by the user). If you lose connection your cached IP address will be displayed until -your timeout expires at which point every time your prompt is generated a new attempt will be made. -Until an IP is successfully pulled the value of $POWERLEVEL9K_PUBLIC_IP_NONE will be displayed for -this segment. If this value is empty(the default)and $POWERLEVEL9K_PUBLIC_IP_FILE is empty the -segment will not be displayed. - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`POWERLEVEL9K_PUBLIC_IP_FILE`|'/tmp/p8k_public_ip'|This is the file your public IP is cached in.| -|`POWERLEVEL9K_PUBLIC_IP_HOST`|'http://ident.me'|This is the default host to get your public IP.| -|`POWERLEVEL9K_PUBLIC_IP_TIMEOUT`|300|The amount of time in seconds between refreshing your cached IP.| -|`POWERLEVEL9K_PUBLIC_IP_METHODS`|(dig curl wget)| These methods in that order are used to refresh your IP.| -|`POWERLEVEL9K_PUBLIC_IP_NONE`|None|The string displayed when an IP was not obtained| - -##### rbenv - -This segment shows the version of Ruby being used when using `rbenv` to change your current Ruby stack. - -It figures out the version being used by taking the output of the `rbenv version-name` command. - -* If `rbenv` is not in $PATH, nothing will be shown. -* If the current Ruby version is the same as the global Ruby version, nothing will be shown. - -##### rspec_stats - -See [Unit Test Ratios](#unit-test-ratios), below. - -##### status - -This segment shows the return code of the last command. - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`POWERLEVEL9K_STATUS_VERBOSE`|`true`|Set to false if you wish to not show the error code when the last command returned an error and optionally hide this segment when the last command completed successfully by setting `POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE` to false.| -|`POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE`|`false`|Set to true if you wish to show this segment when the last command completed successfully in non-verbose mode.| - -##### ram - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`POWERLEVEL9K_RAM_ELEMENTS`|Both|Specify `ram_free` or `swap_used` to only show one or the other rather than both.| - -##### symfony2_tests - -See [Unit Test Ratios](#unit-test-ratios), below. - -##### time - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`POWERLEVEL9K_TIME_FORMAT`|`'H:M:S'`|ZSH time format to use in this segment.| - -As an example, if you wanted a reversed time format, you would use this: -```zsh -# Reversed time format -POWERLEVEL9K_TIME_FORMAT='%D{%S:%M:%H}' -``` -If you are using an "Awesome Powerline Font", you can add a time symbol to this -segment, as well: -```zsh -# Output time, date, and a symbol from the "Awesome Powerline Font" set -POWERLEVEL9K_TIME_FORMAT="%D{%H:%M:%S \uE868 %d.%m.%y}" -``` -##### vcs - -By default, the `vcs` segment will provide quite a bit of information. Further -customization is provided via: - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`POWERLEVEL9K_HIDE_BRANCH_ICON`|`false`|Set to `true` to hide the branch icon from the segment.| -|`POWERLEVEL9K_SHOW_CHANGESET`|`false`|Set to `true` to display the hash / changeset in the segment.| -|`POWERLEVEL9K_CHANGESET_HASH_LENGTH`|`12`|How many characters of the hash / changeset to display in the segment.| -|`POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY`|`true`|Set to `false` to not reflect submodule status in the top-level repository prompt.| -|`POWERLEVEL9K_VCS_HIDE_TAGS`|`false`|Set to `true` to stop tags being displayed in the segment.| - - -##### vcs symbols - -The `vcs` segment uses various symbols to tell you the state of your repository. -These symbols depend on your installed font and selected `POWERLEVEL9K_MODE` -from the [Installation](#Installation) section above. - -| `Compatible` | `Powerline` | `Awesome Powerline` | Explanation -|--------------|---------------------|-------------------|-------------------------- -| `↑4` | `↑4` | ![icon_outgoing](https://cloud.githubusercontent.com/assets/1544760/7976089/b5904d6e-0a76-11e5-8147-5e873ac52d79.gif)4 | Number of commits your repository is ahead of your remote branch -| `↓5` | `↓5` | ![icon_incoming](https://cloud.githubusercontent.com/assets/1544760/7976091/b5909c9c-0a76-11e5-9cad-9bf0a28a897c.gif)5 | Number of commits your repository is behind of your remote branch -| `⍟3` | `⍟3` | ![icon_stash](https://cloud.githubusercontent.com/assets/1544760/7976094/b5ae9346-0a76-11e5-8cc7-e98b81824118.gif)3 | Number of stashes, here 3. -| `●` | `●` | ![icon_unstaged](https://cloud.githubusercontent.com/assets/1544760/7976096/b5aefa98-0a76-11e5-9408-985440471215.gif) | There are unstaged changes in your working copy -| `✚` | `✚` | ![icon_staged](https://cloud.githubusercontent.com/assets/1544760/7976095/b5aecc8a-0a76-11e5-8988-221afc6e8982.gif) | There are staged changes in your working copy -| `?` | `?` | ![icon_untracked](https://cloud.githubusercontent.com/assets/1544760/7976098/b5c7a2e6-0a76-11e5-8c5b-315b595b2bc4.gif) | There are files in your working copy, that are unknown to your repository -| `→` | `→` | ![icon_remote_tracking_branch](https://cloud.githubusercontent.com/assets/1544760/7976093/b5ad2c0e-0a76-11e5-9cd3-62a077b1b0c7.gif) | The name of your branch differs from its tracking branch. -| `☿` | `☿` | ![icon_bookmark](https://cloud.githubusercontent.com/assets/1544760/7976197/546cfac6-0a78-11e5-88a6-ce3a1e0a174e.gif) | A mercurial bookmark is active. -| `@` | ![icon_branch_powerline](https://cloud.githubusercontent.com/assets/1544760/8000852/e7e8d8a0-0b5f-11e5-9834-de9b25c92284.gif) | ![](https://cloud.githubusercontent.com/assets/1544760/7976087/b58bbe3e-0a76-11e5-8d0d-7a5c1bc7f730.gif) | Branch Icon -| None | None | ![icon_commit](https://cloud.githubusercontent.com/assets/1544760/7976088/b58f4e50-0a76-11e5-9e70-86450d937030.gif)2c3705 | The current commit hash. Here "2c3705" -| None | None | ![icon_git](https://cloud.githubusercontent.com/assets/1544760/7976092/b5909f80-0a76-11e5-9950-1438b9d72465.gif) | Repository is a git repository -| None | None | ![icon_mercurial](https://cloud.githubusercontent.com/assets/1544760/7976090/b5908da6-0a76-11e5-8c91-452b6e73f631.gif) | Repository is a Mercurial repository - -##### vi_mode - -This segment shows ZSH's current input mode. Note that this is only useful if -you are using the [ZSH Line Editor](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html) -(VI mode). You can enable this either by `.zshrc` configuration or using a plugin, like -[Oh-My-Zsh's vi-mode plugin](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/vi-mode/vi-mode.plugin.zsh). - -| Variable | Default Value | Description | -|----------|---------------|-------------| -|`POWERLEVEL9K_VI_INSERT_MODE_STRING`|`"INSERT"`|String to display while in 'Insert' mode.| -|`POWERLEVEL9K_VI_COMMAND_MODE_STRING`|`"NORMAL"`|String to display while in 'Command' mode.| - -#### Unit Test Ratios - -The `symfony2_tests` and `rspec_stats` segments both show a ratio of "real" -classes vs test classes in your source code. This is just a very simple ratio, -and does not show your code coverage or any sophisticated stats. All this does -is count your source files and test files, and calculate the ratio between them. -Just enough to give you a quick overview about the test situation of the project -you are dealing with. - -### tl; dr - -Want to just get a quick start? Check out the [Show Off Your -Config](https://github.com/bhilburn/powerlevel9k/wiki/Show-Off-Your-Config) -portion of the wiki to get going. - -[The Wiki also has a ton of other useful -information!](https://github.com/bhilburn/powerlevel9k/wiki) - -### License - -Project: MIT - -Logo: CC-BY-SA. Source repository: https://github.com/bhilburn/powerlevel9k-logo diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/TESTS.md b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/TESTS.md deleted file mode 100644 index d51051c5..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/TESTS.md +++ /dev/null @@ -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). \ No newline at end of file diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/debug/font-issues.zsh b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/debug/font-issues.zsh deleted file mode 100755 index 166a6ac5..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/debug/font-issues.zsh +++ /dev/null @@ -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 diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/debug/iterm.zsh b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/debug/iterm.zsh deleted file mode 100755 index 702175ff..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/debug/iterm.zsh +++ /dev/null @@ -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 diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/colors.zsh b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/colors.zsh deleted file mode 100644 index c82af9ea..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/colors.zsh +++ /dev/null @@ -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 )) -} - diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/icons.zsh b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/icons.zsh deleted file mode 100644 index 5e719be1..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/icons.zsh +++ /dev/null @@ -1,342 +0,0 @@ -# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 -################################################################ -# icons -# This file holds the icon definitions and -# icon-functions for the powerlevel9k-ZSH-theme -# https://github.com/bhilburn/powerlevel9k -################################################################ - -# These characters require the Powerline fonts to work properly. If you see -# boxes or bizarre characters below, your fonts are not correctly installed. If -# you do not want to install a special font, you can set `POWERLEVEL9K_MODE` to -# `compatible`. This shows all icons in regular symbols. - -# Initialize the icon list according to the user's `POWERLEVEL9K_MODE`. -typeset -gAH icons -case $POWERLEVEL9K_MODE in - 'flat'|'awesome-patched') - # Awesome-Patched Font required! See: - # https://github.com/gabrielelana/awesome-terminal-fonts/tree/patching-strategy/patched - # Set the right locale to protect special characters - local LC_ALL="" LC_CTYPE="en_US.UTF-8" - icons=( - LEFT_SEGMENT_SEPARATOR $'\uE0B0' #  - RIGHT_SEGMENT_SEPARATOR $'\uE0B2' #  - LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace - LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  - RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  - CARRIAGE_RETURN_ICON $'\u21B5' # ↵ - ROOT_ICON $'\uE801' #  - RUBY_ICON $'\uE847 ' #  - AWS_ICON $'\uE895' #  - AWS_EB_ICON $'\U1F331 ' # 🌱 - BACKGROUND_JOBS_ICON $'\uE82F ' #  - TEST_ICON $'\uE891' #  - TODO_ICON $'\u2611' # ☑ - BATTERY_ICON $'\uE894' #  - DISK_ICON $'\uE1AE ' #  - OK_ICON $'\u2713' # ✓ - FAIL_ICON $'\u2718' # ✘ - SYMFONY_ICON 'SF' - NODE_ICON $'\u2B22' # ⬢ - MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' - MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' - APPLE_ICON $'\uE26E' #  - FREEBSD_ICON $'\U1F608 ' # 😈 - ANDROID_ICON $'\uE270' #  - LINUX_ICON $'\uE271' #  - SUNOS_ICON $'\U1F31E ' # 🌞 - HOME_ICON $'\uE12C' #  - HOME_SUB_ICON $'\uE18D' #  - FOLDER_ICON $'\uE818' #  - NETWORK_ICON $'\uE1AD' #  - LOAD_ICON $'\uE190 ' #  - SWAP_ICON $'\uE87D' #  - RAM_ICON $'\uE1E2 ' #  - SERVER_ICON $'\uE895' #  - VCS_UNTRACKED_ICON $'\uE16C' #  - VCS_UNSTAGED_ICON $'\uE17C' #  - VCS_STAGED_ICON $'\uE168' #  - VCS_STASH_ICON $'\uE133 ' #  - #VCS_INCOMING_CHANGES_ICON $'\uE1EB ' #  - #VCS_INCOMING_CHANGES_ICON $'\uE80D ' #  - VCS_INCOMING_CHANGES_ICON $'\uE131 ' #  - #VCS_OUTGOING_CHANGES_ICON $'\uE1EC ' #  - #VCS_OUTGOING_CHANGES_ICON $'\uE80E ' #  - VCS_OUTGOING_CHANGES_ICON $'\uE132 ' #  - VCS_TAG_ICON $'\uE817 ' #  - VCS_BOOKMARK_ICON $'\uE87B' #  - VCS_COMMIT_ICON $'\uE821 ' #  - VCS_BRANCH_ICON $'\uE220' #  - VCS_REMOTE_BRANCH_ICON $'\u2192' # → - VCS_GIT_ICON $'\uE20E ' #  - VCS_GIT_GITHUB_ICON $'\uE20E ' # - VCS_GIT_BITBUCKET_ICON $'\uE20E ' # - VCS_GIT_GITLAB_ICON $'\uE20E ' # - VCS_HG_ICON $'\uE1C3 ' #  - VCS_SVN_ICON '(svn) ' - RUST_ICON '' - PYTHON_ICON $'\U1F40D' # 🐍 - SWIFT_ICON '' - GO_ICON '' - PUBLIC_IP_ICON '' - LOCK_ICON $'\UE138' #  - EXECUTION_TIME_ICON $'\UE89C' #  - SSH_ICON '(ssh)' - ) - ;; - 'awesome-fontconfig') - # fontconfig with awesome-font required! See - # https://github.com/gabrielelana/awesome-terminal-fonts - # Set the right locale to protect special characters - local LC_ALL="" LC_CTYPE="en_US.UTF-8" - icons=( - LEFT_SEGMENT_SEPARATOR $'\uE0B0' #  - RIGHT_SEGMENT_SEPARATOR $'\uE0B2' #  - LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace - LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  - RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  - CARRIAGE_RETURN_ICON $'\u21B5' # ↵ - ROOT_ICON $'\uF201' #  - RUBY_ICON $'\uF219 ' #  - AWS_ICON $'\uF270' #  - AWS_EB_ICON $'\U1F331 ' # 🌱 - BACKGROUND_JOBS_ICON $'\uF013 ' #  - TEST_ICON $'\uF291' #  - TODO_ICON $'\u2611' # ☑ - BATTERY_ICON $'\U1F50B' # 🔋 - DISK_ICON $'\uF0A0 ' #  - OK_ICON $'\u2713' # ✓ - FAIL_ICON $'\u2718' # ✘ - SYMFONY_ICON 'SF' - NODE_ICON $'\u2B22' # ⬢ - MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ - MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ - APPLE_ICON $'\uF179' #  - FREEBSD_ICON $'\U1F608 ' # 😈 - ANDROID_ICON $'\uE17B' #  - LINUX_ICON $'\uF17C' #  - SUNOS_ICON $'\uF185 ' #  - HOME_ICON $'\uF015' #  - HOME_SUB_ICON $'\uF07C' #  - FOLDER_ICON $'\uF115' #  - NETWORK_ICON $'\uF09E' #  - LOAD_ICON $'\uF080 ' #  - SWAP_ICON $'\uF0E4' #  - RAM_ICON $'\uF0E4' #  - SERVER_ICON $'\uF233' #  - VCS_UNTRACKED_ICON $'\uF059' #  - VCS_UNSTAGED_ICON $'\uF06A' #  - VCS_STAGED_ICON $'\uF055' #  - VCS_STASH_ICON $'\uF01C ' #  - VCS_INCOMING_CHANGES_ICON $'\uF01A ' #  - VCS_OUTGOING_CHANGES_ICON $'\uF01B ' #  - VCS_TAG_ICON $'\uF217 ' #  - VCS_BOOKMARK_ICON $'\uF27B' #  - VCS_COMMIT_ICON $'\uF221 ' #  - VCS_BRANCH_ICON $'\uF126' #  - VCS_REMOTE_BRANCH_ICON $'\u2192' # → - VCS_GIT_ICON $'\uF1D3 ' #  - VCS_GIT_GITHUB_ICON $'\uF113 ' #  - VCS_GIT_BITBUCKET_ICON $'\uF171 ' #  - VCS_GIT_GITLAB_ICON $'\uF296 ' #  - VCS_HG_ICON $'\uF0C3 ' #  - VCS_SVN_ICON '(svn) ' - RUST_ICON $'\uE6A8' #  - PYTHON_ICON $'\U1F40D' # 🐍 - SWIFT_ICON '' - GO_ICON '' - PUBLIC_IP_ICON '' - LOCK_ICON $'\UE138' #  - EXECUTION_TIME_ICON $'\uF253' - SSH_ICON '(ssh)' - ) - ;; - 'nerdfont-complete'|'nerdfont-fontconfig') - # nerd-font patched (complete) font required! See - # https://github.com/ryanoasis/nerd-fonts - # Set the right locale to protect special characters - local LC_ALL="" LC_CTYPE="en_US.UTF-8" - icons=( - LEFT_SEGMENT_SEPARATOR $'\uE0B0' #  - RIGHT_SEGMENT_SEPARATOR $'\uE0B2' #  - LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace - LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  - RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  - CARRIAGE_RETURN_ICON $'\u21B5' # ↵ - ROOT_ICON $'\uE614 ' #  - RUBY_ICON $'\uF219 ' #  - AWS_ICON $'\uF270' #  - AWS_EB_ICON $'\UF1BD ' #  - BACKGROUND_JOBS_ICON $'\uF013 ' #  - TEST_ICON $'\uF188' #  - TODO_ICON $'\uF133' #  - BATTERY_ICON $'\UF240 ' #  - DISK_ICON $'\uF0A0' #  - OK_ICON $'\uF00C' #  - FAIL_ICON $'\uF00D' #  - SYMFONY_ICON $'\uE757' #  - NODE_ICON $'\uE617 ' #  - MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ - MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ - APPLE_ICON $'\uF179' #  - FREEBSD_ICON $'\UF30E ' #  - ANDROID_ICON $'\uF17B' #  - LINUX_ICON $'\uF17C' #  - SUNOS_ICON $'\uF185 ' #  - HOME_ICON $'\uF015' #  - HOME_SUB_ICON $'\uF07C' #  - FOLDER_ICON $'\uF115' #  - NETWORK_ICON $'\uF1EB' #  - LOAD_ICON $'\uF080 ' #  - SWAP_ICON $'\uF464' #  - RAM_ICON $'\uF0E4' #  - SERVER_ICON $'\uF0AE' #  - VCS_UNTRACKED_ICON $'\uF059' #  - VCS_UNSTAGED_ICON $'\uF06A' #  - VCS_STAGED_ICON $'\uF055' #  - VCS_STASH_ICON $'\uF01C ' #  - VCS_INCOMING_CHANGES_ICON $'\uF01A ' #  - VCS_OUTGOING_CHANGES_ICON $'\uF01B ' #  - VCS_TAG_ICON $'\uF02B ' #  - VCS_BOOKMARK_ICON $'\uF461 ' #  - VCS_COMMIT_ICON $'\uE729 ' #  - VCS_BRANCH_ICON $'\uF126 ' #  - VCS_REMOTE_BRANCH_ICON $'\uE728 ' #  - VCS_GIT_ICON $'\uF113 ' #  - VCS_GIT_GITHUB_ICON $'\uE709 ' #  - VCS_GIT_BITBUCKET_ICON $'\uE703 ' #  - VCS_GIT_GITLAB_ICON $'\uF296 ' #  - VCS_HG_ICON $'\uF0C3 ' #  - VCS_SVN_ICON $'\uE72D ' #  - RUST_ICON $'\uE7A8 ' #  - PYTHON_ICON $'\UE73C ' #  - SWIFT_ICON $'\uE755' #  - GO_ICON $'\uE626' #  - PUBLIC_IP_ICON $'\UF0AC' #  - LOCK_ICON $'\UF023' #  - EXECUTION_TIME_ICON $'\uF252' #  - SSH_ICON $'\uF489' #  - ) - ;; - *) - # Powerline-Patched Font required! - # See https://github.com/Lokaltog/powerline-fonts - # Set the right locale to protect special characters - local LC_ALL="" LC_CTYPE="en_US.UTF-8" - icons=( - LEFT_SEGMENT_SEPARATOR $'\uE0B0' #  - RIGHT_SEGMENT_SEPARATOR $'\uE0B2' #  - LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace - LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' #  - RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  - CARRIAGE_RETURN_ICON $'\u21B5' # ↵ - ROOT_ICON $'\u26A1' # ⚡ - RUBY_ICON '' - AWS_ICON 'AWS:' - AWS_EB_ICON $'\U1F331 ' # 🌱 - BACKGROUND_JOBS_ICON $'\u2699' # ⚙ - TEST_ICON '' - TODO_ICON $'\u2611' # ☑ - BATTERY_ICON $'\U1F50B' # 🔋 - DISK_ICON $'hdd ' - OK_ICON $'\u2713' # ✓ - FAIL_ICON $'\u2718' # ✘ - SYMFONY_ICON 'SF' - NODE_ICON $'\u2B22' # ⬢ - MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\u2500' - MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\u2500 ' - APPLE_ICON 'OSX' - FREEBSD_ICON 'BSD' - ANDROID_ICON 'And' - LINUX_ICON 'Lx' - SUNOS_ICON 'Sun' - HOME_ICON '' - HOME_SUB_ICON '' - FOLDER_ICON '' - NETWORK_ICON 'IP' - LOAD_ICON 'L' - SWAP_ICON 'SWP' - RAM_ICON 'RAM' - SERVER_ICON '' - VCS_UNTRACKED_ICON '?' - VCS_UNSTAGED_ICON $'\u25CF' # ● - VCS_STAGED_ICON $'\u271A' # ✚ - VCS_STASH_ICON $'\u235F' # ⍟ - VCS_INCOMING_CHANGES_ICON $'\u2193' # ↓ - VCS_OUTGOING_CHANGES_ICON $'\u2191' # ↑ - VCS_TAG_ICON '' - VCS_BOOKMARK_ICON $'\u263F' # ☿ - VCS_COMMIT_ICON '' - VCS_BRANCH_ICON $'\uE0A0' #  - VCS_REMOTE_BRANCH_ICON $'\u2192' # → - VCS_GIT_ICON '' - VCS_GIT_GITHUB_ICON '' - VCS_GIT_BITBUCKET_ICON '' - VCS_GIT_GITLAB_ICON '' - VCS_HG_ICON '' - VCS_SVN_ICON '' - RUST_ICON '' - PYTHON_ICON '' - SWIFT_ICON 'Swift' - GO_ICON 'Go' - PUBLIC_IP_ICON '' - LOCK_ICON $'\UE0A2' - EXECUTION_TIME_ICON 'Dur' - SSH_ICON '(ssh)' - ) - ;; -esac - -# Override the above icon settings with any user-defined variables. -case $POWERLEVEL9K_MODE in - 'flat') - # Set the right locale to protect special characters - local LC_ALL="" LC_CTYPE="en_US.UTF-8" - icons[LEFT_SEGMENT_SEPARATOR]='' - icons[RIGHT_SEGMENT_SEPARATOR]='' - icons[LEFT_SUBSEGMENT_SEPARATOR]='|' - icons[RIGHT_SUBSEGMENT_SEPARATOR]='|' - ;; - 'compatible') - # Set the right locale to protect special characters - local LC_ALL="" LC_CTYPE="en_US.UTF-8" - icons[LEFT_SEGMENT_SEPARATOR]=$'\u2B80' # ⮀ - icons[RIGHT_SEGMENT_SEPARATOR]=$'\u2B82' # ⮂ - icons[VCS_BRANCH_ICON]='@' - ;; -esac - -if [[ "$POWERLEVEL9K_HIDE_BRANCH_ICON" == true ]]; then - icons[VCS_BRANCH_ICON]='' -fi - -# Safety function for printing icons -# Prints the named icon, or if that icon is undefined, the string name. -function print_icon() { - local icon_name=$1 - local ICON_USER_VARIABLE=POWERLEVEL9K_${icon_name} - if defined "$ICON_USER_VARIABLE"; then - echo -n "${(P)ICON_USER_VARIABLE}" - else - echo -n "${icons[$icon_name]}" - fi -} - -# Get a list of configured icons -# * $1 string - If "original", then the original icons are printed, -# otherwise "print_icon" is used, which takes the users -# overrides into account. -get_icon_names() { - # Iterate over a ordered list of keys of the icons array - for key in ${(@kon)icons}; do - echo -n "POWERLEVEL9K_$key: " - if [[ "${1}" == "original" ]]; then - # print the original icons as they are defined in the array above - echo "${icons[$key]}" - else - # print the icons as they are configured by the user - echo "$(print_icon "$key")" - fi - done -} diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/utilities.zsh b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/utilities.zsh deleted file mode 100644 index 86e5ba0e..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/utilities.zsh +++ /dev/null @@ -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 -} diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/vcs.zsh b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/vcs.zsh deleted file mode 100644 index c3e507b9..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/functions/vcs.zsh +++ /dev/null @@ -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 -} diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/powerlevel9k.zsh-theme b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/powerlevel9k.zsh-theme deleted file mode 100755 index 26ab9cd5..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/powerlevel9k.zsh-theme +++ /dev/null @@ -1,1402 +0,0 @@ -# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 -################################################################ -# powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# This theme was inspired by agnoster's Theme: -# https://gist.github.com/3712874 -################################################################ - -################################################################ -# For basic documentation, please refer to the README.md in the top-level -# directory. For more detailed documentation, refer to the project wiki, hosted -# on Github: https://github.com/bhilburn/powerlevel9k/wiki -# -# There are a lot of easy ways you can customize your prompt segments and -# theming with simple variables defined in your `~/.zshrc`. -################################################################ - -## Turn on for Debugging -#zstyle ':vcs_info:*+*:*' debug true -#set -o xtrace - -# Try to set the installation path -if [[ -n "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then - # If an installation path was set manually, - # it should trump any other location found. - # Do nothing. This is all right, as we use the - # POWERLEVEL9K_INSTALLATION_PATH for further processing. -elif [[ $(whence -w prompt_powerlevel9k_setup) =~ "function" ]]; then - # Check if the theme was called as a function (e.g., from prezto) - autoload -U is-at-least - if is-at-least 5.0.8; then - # Try to find the correct path of the script. - POWERLEVEL9K_INSTALLATION_PATH=$(whence -v $0 | sed "s/$0 is a shell function from //") - elif [[ -f "${ZDOTDIR:-$HOME}/.zprezto/modules/prompt/init.zsh" ]]; then - # If there is an prezto installation, we assume that powerlevel9k is linked there. - POWERLEVEL9K_INSTALLATION_PATH="${ZDOTDIR:-$HOME}/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup" - fi -else - # Last resort: Set installation path is script path - POWERLEVEL9K_INSTALLATION_PATH="$0" -fi - -# Resolve the installation path -if [[ -L "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then - # If this theme is sourced as a symlink, we need to locate the real URL - filename="${POWERLEVEL9K_INSTALLATION_PATH:A}" -elif [[ -d "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then - # Directory - filename="${POWERLEVEL9K_INSTALLATION_PATH}/powerlevel9k.zsh-theme" -elif [[ -f "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then - # Script is a file - filename="$POWERLEVEL9K_INSTALLATION_PATH" -elif [[ -z "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then - # Fallback: specify an installation path! - print -P "%F{red}We could not locate the installation path of powerlevel9k.%f" - print -P "Please specify by setting %F{blue}POWERLEVEL9K_INSTALLATION_PATH%f (full path incl. file name) at the very beginning of your ~/.zshrc" - return 1 -else - print -P "%F{red}Script location could not be found! Maybe your %F{blue}POWERLEVEL9K_INSTALLATION_PATH%F{red} is not correct?%f" - return 1 -fi -script_location="$(dirname $filename)" - -################################################################ -# Source icon functions -################################################################ - -source $script_location/functions/icons.zsh - -################################################################ -# Source utility functions -################################################################ - -source $script_location/functions/utilities.zsh - -################################################################ -# Source color functions -################################################################ - -source $script_location/functions/colors.zsh - -################################################################ -# Source VCS_INFO hooks / helper functions -################################################################ - -source $script_location/functions/vcs.zsh - -################################################################ -# Color Scheme -################################################################ - -if [[ "$POWERLEVEL9K_COLOR_SCHEME" == "light" ]]; then - DEFAULT_COLOR=white - DEFAULT_COLOR_INVERTED=black -else - DEFAULT_COLOR=black - DEFAULT_COLOR_INVERTED=white -fi - -################################################################ -# Prompt Segment Constructors -# -# Methodology behind user-defined variables overwriting colors: -# The first parameter to the segment constructors is the calling function's -# name. From this function name, we strip the "prompt_"-prefix and -# uppercase it. This is then prefixed with "POWERLEVEL9K_" and suffixed -# with either "_BACKGROUND" or "_FOREGROUND", thus giving us the variable -# name. So each new segment is user-overwritten by a variable following -# this naming convention. -################################################################ - -# The `CURRENT_BG` variable is used to remember what the last BG color used was -# when building the left-hand prompt. Because the RPROMPT is created from -# right-left but reads the opposite, this isn't necessary for the other side. -CURRENT_BG='NONE' - -# Begin a left prompt segment -# Takes four arguments: -# * $1: Name of the function that was originally invoked (mandatory). -# Necessary, to make the dynamic color-overwrite mechanism work. -# * $2: The array index of the current segment -# * $3: Background color -# * $4: Foreground color -# * $5: The segment content -# * $6: An identifying icon (must be a key of the icons array) -# The latter three can be omitted, -set_default last_left_element_index 1 -set_default POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS " " -left_prompt_segment() { - local current_index=$2 - # Check if the segment should be joined with the previous one - local joined - segmentShouldBeJoined $current_index $last_left_element_index "$POWERLEVEL9K_LEFT_PROMPT_ELEMENTS" && joined=true || joined=false - - # Overwrite given background-color by user defined variable for this segment. - local BACKGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_BACKGROUND - local BG_COLOR_MODIFIER=${(P)BACKGROUND_USER_VARIABLE} - [[ -n $BG_COLOR_MODIFIER ]] && 3="$BG_COLOR_MODIFIER" - - # Overwrite given foreground-color by user defined variable for this segment. - local FOREGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_FOREGROUND - local FG_COLOR_MODIFIER=${(P)FOREGROUND_USER_VARIABLE} - [[ -n $FG_COLOR_MODIFIER ]] && 4="$FG_COLOR_MODIFIER" - - local bg fg - [[ -n "$3" ]] && bg="%K{$3}" || bg="%k" - [[ -n "$4" ]] && fg="%F{$4}" || fg="%f" - - if [[ $CURRENT_BG != 'NONE' ]] && ! isSameColor "$3" "$CURRENT_BG"; then - echo -n "$bg%F{$CURRENT_BG}" - if [[ $joined == false ]]; then - # Middle segment - echo -n "$(print_icon 'LEFT_SEGMENT_SEPARATOR')$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" - fi - elif isSameColor "$CURRENT_BG" "$3"; then - # Middle segment with same color as previous segment - # We take the current foreground color as color for our - # subsegment (or the default color). This should have - # enough contrast. - local complement - [[ -n "$4" ]] && complement="$4" || complement=$DEFAULT_COLOR - echo -n "$bg%F{$complement}" - if [[ $joined == false ]]; then - echo -n "$(print_icon 'LEFT_SUBSEGMENT_SEPARATOR')$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" - fi - else - # First segment - echo -n "${bg}$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" - fi - - local visual_identifier - if [[ -n $6 ]]; then - visual_identifier="$(print_icon $6)" - if [[ -n "$visual_identifier" ]]; then - # Allow users to overwrite the color for the visual identifier only. - local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR - set_default $visual_identifier_color_variable $4 - visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" - # Add an whitespace if we print more than just the visual identifier - [[ -n "$5" ]] && visual_identifier="$visual_identifier " - fi - fi - - # Print the visual identifier - echo -n "${visual_identifier}" - # Print the content of the segment, if there is any - [[ -n "$5" ]] && echo -n "${fg}${5}" - echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS}" - - CURRENT_BG=$3 - last_left_element_index=$current_index -} - -# End the left prompt, closes the final segment. -left_prompt_end() { - if [[ -n $CURRENT_BG ]]; then - echo -n "%k%F{$CURRENT_BG}$(print_icon 'LEFT_SEGMENT_SEPARATOR')" - else - echo -n "%k" - fi - echo -n "%f$(print_icon 'LEFT_SEGMENT_END_SEPARATOR')" - CURRENT_BG='' -} - -CURRENT_RIGHT_BG='NONE' - -# Begin a right prompt segment -# Takes four arguments: -# * $1: Name of the function that was originally invoked (mandatory). -# Necessary, to make the dynamic color-overwrite mechanism work. -# * $2: The array index of the current segment -# * $3: Background color -# * $4: Foreground color -# * $5: The segment content -# * $6: An identifying icon (must be a key of the icons array) -# No ending for the right prompt segment is needed (unlike the left prompt, above). -set_default last_right_element_index 1 -set_default POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS " " -right_prompt_segment() { - local current_index=$2 - - # Check if the segment should be joined with the previous one - local joined - segmentShouldBeJoined $current_index $last_right_element_index "$POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS" && joined=true || joined=false - - # Overwrite given background-color by user defined variable for this segment. - local BACKGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_BACKGROUND - local BG_COLOR_MODIFIER=${(P)BACKGROUND_USER_VARIABLE} - [[ -n $BG_COLOR_MODIFIER ]] && 3="$BG_COLOR_MODIFIER" - - # Overwrite given foreground-color by user defined variable for this segment. - local FOREGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_FOREGROUND - local FG_COLOR_MODIFIER=${(P)FOREGROUND_USER_VARIABLE} - [[ -n $FG_COLOR_MODIFIER ]] && 4="$FG_COLOR_MODIFIER" - - local bg fg - [[ -n "$3" ]] && bg="%K{$3}" || bg="%k" - [[ -n "$4" ]] && fg="%F{$4}" || fg="%f" - - # If CURRENT_RIGHT_BG is "NONE", we are the first right segment. - if [[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]]; then - if isSameColor "$CURRENT_RIGHT_BG" "$3"; then - # Middle segment with same color as previous segment - # We take the current foreground color as color for our - # subsegment (or the default color). This should have - # enough contrast. - local complement - [[ -n "$4" ]] && complement="$4" || complement=$DEFAULT_COLOR - echo -n "%F{$complement}$(print_icon 'RIGHT_SUBSEGMENT_SEPARATOR')%f" - else - echo -n "%F{$3}$(print_icon 'RIGHT_SEGMENT_SEPARATOR')%f" - fi - fi - - local visual_identifier - if [[ -n "$6" ]]; then - visual_identifier="$(print_icon $6)" - if [[ -n "$visual_identifier" ]]; then - # Allow users to overwrite the color for the visual identifier only. - local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR - set_default $visual_identifier_color_variable $4 - visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" - # Add an whitespace if we print more than just the visual identifier - [[ -n "$5" ]] && visual_identifier=" $visual_identifier" - fi - fi - - echo -n "${bg}${fg}" - - # Print whitespace only if segment is not joined or first right segment - [[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]] && echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}" - - # Print segment content if there is any - [[ -n "$5" ]] && echo -n "${5}" - # Print the visual identifier - echo -n "${visual_identifier}${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f" - - CURRENT_RIGHT_BG=$3 - last_right_element_index=$current_index -} - -################################################################ -# Prompt Segment Definitions -################################################################ - -# The `CURRENT_BG` variable is used to remember what the last BG color used was -# when building the left-hand prompt. Because the RPROMPT is created from -# right-left but reads the opposite, this isn't necessary for the other side. -CURRENT_BG='NONE' - -# Anaconda Environment -prompt_anaconda() { - # Depending on the conda version, either might be set. This - # variant works even if both are set. - _path=$CONDA_ENV_PATH$CONDA_PREFIX - if ! [ -z "$_path" ]; then - # config - can be overwritten in users' zshrc file. - set_default POWERLEVEL9K_ANACONDA_LEFT_DELIMITER "(" - set_default POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER ")" - "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" 'PYTHON_ICON' - fi -} - -# AWS Profile -prompt_aws() { - local aws_profile="$AWS_DEFAULT_PROFILE" - - if [[ -n "$aws_profile" ]]; then - "$1_prompt_segment" "$0" "$2" red white "$aws_profile" 'AWS_ICON' - fi -} - -# Current Elastic Beanstalk environment -prompt_aws_eb_env() { - local eb_env=$(grep environment .elasticbeanstalk/config.yml 2> /dev/null | awk '{print $2}') - - if [[ -n "$eb_env" ]]; then - "$1_prompt_segment" "$0" "$2" black green "$eb_env" 'AWS_EB_ICON' - fi -} - -# Segment to indicate background jobs with an icon. -set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE true -prompt_background_jobs() { - local background_jobs_number=${$(jobs -l | wc -l)// /} - local wrong_lines=`jobs -l | awk '/pwd now/{ count++ } END {print count}'` - if [[ wrong_lines -gt 0 ]]; then - background_jobs_number=$(( $background_jobs_number - $wrong_lines )) - fi - if [[ background_jobs_number -gt 0 ]]; then - local background_jobs_number_print="" - if [[ "$POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE" == "true" ]] && [[ "$background_jobs_number" -gt 1 ]]; then - background_jobs_number_print="$background_jobs_number" - fi - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "cyan" "$background_jobs_number_print" 'BACKGROUND_JOBS_ICON' - fi -} - -# Segment that indicates usage level of current partition. -set_default POWERLEVEL9K_DISK_USAGE_ONLY_WARNING false -set_default POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL 90 -set_default POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL 95 -prompt_disk_usage() { - local current_state="unknown" - typeset -AH hdd_usage_forecolors - hdd_usage_forecolors=( - 'normal' 'yellow' - 'warning' "$DEFAULT_COLOR" - 'critical' 'white' - ) - typeset -AH hdd_usage_backcolors - hdd_usage_backcolors=( - 'normal' $DEFAULT_COLOR - 'warning' 'yellow' - 'critical' 'red' - ) - - local disk_usage="${$(\df -P . | sed -n '2p' | awk '{ print $5 }')%%\%}" - - if [ "$disk_usage" -ge "$POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL" ]; then - current_state='warning' - if [ "$disk_usage" -ge "$POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL" ]; then - current_state='critical' - fi - else - if [[ "$POWERLEVEL9K_DISK_USAGE_ONLY_WARNING" == true ]]; then - current_state='' - return - fi - current_state='normal' - fi - - local message="${disk_usage}%%" - - # Draw the prompt_segment - if [[ -n $disk_usage ]]; then - "$1_prompt_segment" "${0}_${current_state}" "$2" "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'DISK_ICON' - fi -} - -prompt_battery() { - # The battery can have four different states - default to 'unknown'. - local current_state='unknown' - typeset -AH battery_states - battery_states=( - 'low' 'red' - 'charging' 'yellow' - 'charged' 'green' - 'disconnected' "$DEFAULT_COLOR_INVERTED" - ) - # Set default values if the user did not configure them - set_default POWERLEVEL9K_BATTERY_LOW_THRESHOLD 10 - - if [[ $OS =~ OSX && -f /usr/bin/pmset && -x /usr/bin/pmset ]]; then - # obtain battery information from system - local raw_data="$(pmset -g batt | awk 'FNR==2{print}')" - # return if there is no battery on system - [[ -z $(echo $raw_data | grep "InternalBattery") ]] && return - - # Time remaining on battery operation (charging/discharging) - local tstring=$(echo $raw_data | awk -F ';' '{print $3}' | awk '{print $1}') - # If time has not been calculated by system yet - [[ $tstring =~ '(\(no|not)' ]] && tstring="..." - - # percent of battery charged - typeset -i 10 bat_percent - bat_percent=$(echo $raw_data | grep -o '[0-9]*%' | sed 's/%//') - - local remain="" - # Logic for string output - case $(echo $raw_data | awk -F ';' '{print $2}' | awk '{$1=$1};1') in - # for a short time after attaching power, status will be 'AC attached;' - 'charging'|'finishing charge'|'AC attached') - current_state="charging" - remain=" ($tstring)" - ;; - 'discharging') - [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" - remain=" ($tstring)" - ;; - *) - current_state="charged" - ;; - esac - fi - - if [[ "$OS" == 'Linux' ]] || [[ "$OS" == 'Android' ]]; then - local sysp="/sys/class/power_supply" - - # Reported BAT0 or BAT1 depending on kernel version - [[ -a $sysp/BAT0 ]] && local bat=$sysp/BAT0 - [[ -a $sysp/BAT1 ]] && local bat=$sysp/BAT1 - - # Android-related - # Tested on: Moto G falcon (CM 13.0) - [[ -a $sysp/battery ]] && local bat=$sysp/battery - - # Return if no battery found - [[ -z $bat ]] && return - local capacity=$(cat $bat/capacity) - local battery_status=$(cat $bat/status) - [[ $capacity -gt 100 ]] && local bat_percent=100 || local bat_percent=$capacity - [[ $battery_status =~ Charging || $battery_status =~ Full ]] && local connected=true - if [[ -z $connected ]]; then - [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" - else - [[ $bat_percent =~ 100 ]] && current_state="charged" - [[ $bat_percent -lt 100 ]] && current_state="charging" - fi - if [[ -f /usr/bin/acpi ]]; then - local time_remaining=$(acpi | awk '{ print $5 }') - if [[ $time_remaining =~ rate ]]; then - local tstring="..." - elif [[ $time_remaining =~ "[[:digit:]]+" ]]; then - local tstring=${(f)$(date -u -d "$(echo $time_remaining)" +%k:%M 2> /dev/null)} - fi - fi - [[ -n $tstring ]] && local remain=" ($tstring)" - fi - - local message - # Default behavior: Be verbose! - set_default POWERLEVEL9K_BATTERY_VERBOSE true - if [[ "$POWERLEVEL9K_BATTERY_VERBOSE" == true ]]; then - message="$bat_percent%%$remain" - else - message="$bat_percent%%" - fi - - # Draw the prompt_segment - if [[ -n $bat_percent ]]; then - "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${battery_states[$current_state]}" "$message" 'BATTERY_ICON' - fi -} - -# Public IP segment -# Parameters: -# * $1 Alignment: string - left|right -# * $2 Index: integer -# * $3 Joined: bool - If the segment should be joined -prompt_public_ip() { - # set default values for segment - set_default POWERLEVEL9K_PUBLIC_IP_TIMEOUT "300" - set_default POWERLEVEL9K_PUBLIC_IP_NONE "" - set_default POWERLEVEL9K_PUBLIC_IP_FILE "/tmp/p9k_public_ip" - set_default POWERLEVEL9K_PUBLIC_IP_HOST "http://ident.me" - defined POWERLEVEL9K_PUBLIC_IP_METHODS || POWERLEVEL9K_PUBLIC_IP_METHODS=(dig curl wget) - - # Do we need a fresh IP? - local refresh_ip=false - if [[ -f $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then - typeset -i timediff - # if saved IP is more than - timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) - [[ $timediff -gt $POWERLEVEL9K_PUBLIC_IP_TIMEOUT ]] && refresh_ip=true - # If tmp file is empty get a fresh IP - [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=true - [[ -n $POWERLEVEL9K_PUBLIC_IP_NONE ]] && [[ $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) =~ "$POWERLEVEL9K_PUBLIC_IP_NONE" ]] && refresh_ip=true - else - touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=true - fi - - # grab a fresh IP if needed - local fresh_ip - if [[ $refresh_ip =~ true && -w $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then - for method in "${POWERLEVEL9K_PUBLIC_IP_METHODS[@]}"; do - case $method in - 'dig') - fresh_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2> /dev/null)" - [[ "$fresh_ip" =~ ^\; ]] && unset fresh_ip - ;; - 'curl') - fresh_ip="$(curl --max-time 10 -w '\n' "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" - ;; - 'wget') - fresh_ip="$(wget -T 10 -qO- "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" - ;; - esac - # If we found a fresh IP, break loop. - if [[ -n "${fresh_ip}" ]]; then - break; - fi - done - - # write IP to tmp file or clear tmp file if an IP was not retrieved - # Redirection with `>!`. From the manpage: Same as >, except that the file - # is truncated to zero length if it exists, even if CLOBBER is unset. - # If the file already exists, and a simple `>` redirection and CLOBBER - # unset, ZSH will produce an error. - [[ -n "${fresh_ip}" ]] && echo $fresh_ip >! $POWERLEVEL9K_PUBLIC_IP_FILE || echo $POWERLEVEL9K_PUBLIC_IP_NONE >! $POWERLEVEL9K_PUBLIC_IP_FILE - fi - - # read public IP saved to tmp file - local public_ip="$(cat $POWERLEVEL9K_PUBLIC_IP_FILE)" - - # Draw the prompt segment - if [[ -n $public_ip ]]; then - $1_prompt_segment "$0" "$2" "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${public_ip}" 'PUBLIC_IP_ICON' - fi -} - -# Context: user@hostname (who am I and where am I) -# Note that if $DEFAULT_USER is not set, this prompt segment will always print -set_default POWERLEVEL9K_ALWAYS_SHOW_CONTEXT false -set_default POWERLEVEL9K_ALWAYS_SHOW_USER false -set_default POWERLEVEL9K_CONTEXT_TEMPLATE "%n@%m" -prompt_context() { - local current_state="DEFAULT" - typeset -AH context_states - context_states=( - "ROOT" "yellow" - "DEFAULT" "011" - ) - - local content="" - - if [[ "$POWERLEVEL9K_ALWAYS_SHOW_CONTEXT" == true ]] || [[ "$USER" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then - - if [[ $(print -P "%#") == '#' ]]; then - current_state="ROOT" - fi - - content="${POWERLEVEL9K_CONTEXT_TEMPLATE}" - - elif [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]]; then - content="$USER" - else - return - fi - - "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" -} - -# The 'custom` prompt provides a way for users to invoke commands and display -# the output in a segment. -prompt_custom() { - local command=POWERLEVEL9K_CUSTOM_$3:u - local segment_content="$(eval ${(P)command})" - - if [[ -n $segment_content ]]; then - "$1_prompt_segment" "${0}_${3:u}" "$2" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content" - fi -} - -# Display the duration the command needed to run. -prompt_command_execution_time() { - set_default POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD 3 - set_default POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION 2 - - # Print time in human readable format - # For that use `strftime` and convert - # the duration (float) to an seconds - # (integer). - # See http://unix.stackexchange.com/a/89748 - local humanReadableDuration - if (( _P9K_COMMAND_DURATION > 3600 )); then - humanReadableDuration=$(TZ=GMT; strftime '%H:%M:%S' $(( int(rint(_P9K_COMMAND_DURATION)) ))) - elif (( _P9K_COMMAND_DURATION > 60 )); then - humanReadableDuration=$(TZ=GMT; strftime '%M:%S' $(( int(rint(_P9K_COMMAND_DURATION)) ))) - else - # If the command executed in seconds, print as float. - # Convert to float - if [[ "${POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION}" == "0" ]]; then - # If user does not want microseconds, then we need to convert - # the duration to an integer. - typeset -i humanReadableDuration - else - typeset -F ${POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION} humanReadableDuration - fi - humanReadableDuration=$_P9K_COMMAND_DURATION - fi - - if (( _P9K_COMMAND_DURATION >= POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD )); then - "$1_prompt_segment" "$0" "$2" "red" "226" "${humanReadableDuration}" 'EXECUTION_TIME_ICON' - fi -} - -# Dir: current working directory -set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/" -set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" -prompt_dir() { - local current_path="$(print -P "%~")" - if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" ]]; then - set_default POWERLEVEL9K_SHORTEN_DELIMITER $'\U2026' - - case "$POWERLEVEL9K_SHORTEN_STRATEGY" in - truncate_middle) - current_path=$(pwd | sed -e "s,^$HOME,~," | sed $SED_EXTENDED_REGEX_PARAMETER "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})\//\1$POWERLEVEL9K_SHORTEN_DELIMITER\2\//g") - ;; - truncate_from_right) - current_path=$(truncatePathFromRight "$(pwd | sed -e "s,^$HOME,~,")" ) - ;; - truncate_with_package_name) - local name repo_path package_path current_dir zero - - # Get the path of the Git repo, which should have the package.json file - if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == "true" ]]; then - # Get path from the root of the git repository to the current dir - local gitPath=$(git rev-parse --show-prefix) - # Remove trailing slash from git path, so that we can - # remove that git path from the pwd. - gitPath=${gitPath%/} - package_path=${$(pwd)%%$gitPath} - # Remove trailing slash - package_path=${package_path%/} - elif [[ $(git rev-parse --is-inside-git-dir 2> /dev/null) == "true" ]]; then - package_path=${$(pwd)%%/.git*} - fi - - # Replace the shortest possible match of the marked folder from - # the current path. Remove the amount of characters up to the - # folder marker from the left. Count only the visible characters - # in the path (this is done by the "zero" pattern; see - # http://stackoverflow.com/a/40855342/5586433). - local zero='%([BSUbfksu]|([FB]|){*})' - current_dir=$(pwd) - # Then, find the length of the package_path string, and save the - # subdirectory path as a substring of the current directory's path from 0 - # to the length of the package path's string - subdirectory_path=$(truncatePathFromRight "${current_dir:${#${(S%%)package_path//$~zero/}}}") - # Parse the 'name' from the package.json; if there are any problems, just - # print the file path - defined POWERLEVEL9K_DIR_PACKAGE_FILES || POWERLEVEL9K_DIR_PACKAGE_FILES=(package.json composer.json) - - local pkgFile="unknown" - for file in "${POWERLEVEL9K_DIR_PACKAGE_FILES[@]}"; do - if [[ -f "${package_path}/${file}" ]]; then - pkgFile="${package_path}/${file}" - break; - fi - done - - local packageName=$(jq '.name' ${pkgFile} 2> /dev/null \ - || node -e 'console.log(require(process.argv[1]).name);' ${pkgFile} 2>/dev/null \ - || cat "${pkgFile}" 2> /dev/null | grep -m 1 "\"name\"" | awk -F ':' '{print $2}' | awk -F '"' '{print $2}' 2>/dev/null \ - ) - if [[ -n "${packageName}" ]]; then - # Instead of printing out the full path, print out the name of the package - # from the package.json and append the current subdirectory - current_path="`echo $packageName | tr -d '"'`$subdirectory_path" - else - current_path=$(truncatePathFromRight "$(pwd | sed -e "s,^$HOME,~,")" ) - fi - ;; - truncate_with_folder_marker) - local last_marked_folder marked_folder - set_default POWERLEVEL9K_SHORTEN_FOLDER_MARKER ".shorten_folder_marker" - - # Search for the folder marker in the parent directories and - # buildup a pattern that is removed from the current path - # later on. - for marked_folder in $(upsearch $POWERLEVEL9K_SHORTEN_FOLDER_MARKER); do - if [[ "$marked_folder" == "/" ]]; then - # If we reached root folder, stop upsearch. - current_path="/" - elif [[ "$marked_folder" == "$HOME" ]]; then - # If we reached home folder, stop upsearch. - current_path="~" - elif [[ "${marked_folder%/*}" == $last_marked_folder ]]; then - current_path="${current_path%/}/${marked_folder##*/}" - else - current_path="${current_path%/}/$POWERLEVEL9K_SHORTEN_DELIMITER/${marked_folder##*/}" - fi - last_marked_folder=$marked_folder - done - - # Replace the shortest possible match of the marked folder from - # the current path. - current_path=$current_path${PWD#${last_marked_folder}*} - ;; - *) - current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" - ;; - esac - fi - - if [[ "${POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER}" == "true" ]]; then - current_path="${current_path[2,-1]}" - fi - - if [[ "${POWERLEVEL9K_DIR_PATH_SEPARATOR}" != "/" ]]; then - current_path="$( echo "${current_path}" | sed "s/\//${POWERLEVEL9K_DIR_PATH_SEPARATOR}/g")" - fi - - if [[ "${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}" != "~" ]]; then - current_path="$( echo "${current_path}" | sed "s/^~/${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}/")" - fi - - typeset -AH dir_states - dir_states=( - "DEFAULT" "FOLDER_ICON" - "HOME" "HOME_ICON" - "HOME_SUBFOLDER" "HOME_SUB_ICON" - ) - local current_state="DEFAULT" - if [[ $(print -P "%~") == '~' ]]; then - current_state="HOME" - elif [[ $(print -P "%~") == '~'* ]]; then - current_state="HOME_SUBFOLDER" - fi - "$1_prompt_segment" "$0_${current_state}" "$2" "blue" "$DEFAULT_COLOR" "${current_path}" "${dir_states[$current_state]}" -} - -# Docker machine -prompt_docker_machine() { - local docker_machine="$DOCKER_MACHINE_NAME" - - if [[ -n "$docker_machine" ]]; then - "$1_prompt_segment" "$0" "$2" "magenta" "$DEFAULT_COLOR" "$docker_machine" 'SERVER_ICON' - fi -} - -# GO prompt -prompt_go_version() { - local go_version - local go_path - go_version=$(go version 2>/dev/null | sed -E "s/.*(go[0-9.]*).*/\1/") - go_path=$(go env GOPATH 2>/dev/null) - - if [[ -n "$go_version" && "${PWD##$go_path}" != "$PWD" ]]; then - "$1_prompt_segment" "$0" "$2" "green" "255" "$go_version" "GO_ICON" - fi -} - -# Command number (in local history) -prompt_history() { - "$1_prompt_segment" "$0" "$2" "244" "$DEFAULT_COLOR" '%h' -} - -# Detection for virtualization (systemd based systems only) -prompt_detect_virt() { - if ! command -v systemd-detect-virt > /dev/null; then - return - fi - local virt=$(systemd-detect-virt) - if [[ "$virt" == "none" ]]; then - if [[ "$(ls -di / | grep -o 2)" != "2" ]]; then - virt="chroot" - "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$virt" - else - ; - fi - else - "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$virt" - fi -} - - -prompt_icons_test() { - for key in ${(@k)icons}; do - # The lower color spectrum in ZSH makes big steps. Choosing - # the next color has enough contrast to read. - local random_color=$((RANDOM % 8)) - local next_color=$((random_color+1)) - "$1_prompt_segment" "$0" "$2" "$random_color" "$next_color" "$key" "$key" - done -} - -prompt_ip() { - if [[ "$OS" == "OSX" ]]; then - if defined POWERLEVEL9K_IP_INTERFACE; then - # Get the IP address of the specified interface. - ip=$(ipconfig getifaddr "$POWERLEVEL9K_IP_INTERFACE") - else - local interfaces callback - # Get network interface names ordered by service precedence. - interfaces=$(networksetup -listnetworkserviceorder | grep -o "Device:\s*[a-z0-9]*" | grep -o -E '[a-z0-9]*$') - callback='ipconfig getifaddr $item' - - ip=$(getRelevantItem "$interfaces" "$callback") - fi - else - if defined POWERLEVEL9K_IP_INTERFACE; then - # Get the IP address of the specified interface. - ip=$(ip -4 a show "$POWERLEVEL9K_IP_INTERFACE" | grep -o "inet\s*[0-9.]*" | grep -o "[0-9.]*") - else - local interfaces callback - # Get all network interface names that are up - interfaces=$(ip link ls up | grep -o -E ":\s+[a-z0-9]+:" | grep -v "lo" | grep -o "[a-z0-9]*") - callback='ip -4 a show $item | grep -o "inet\s*[0-9.]*" | grep -o "[0-9.]*"' - - ip=$(getRelevantItem "$interfaces" "$callback") - fi - fi - - "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON' -} - -prompt_load() { - # The load segment can have three different states - local current_state="unknown" - local cores - - typeset -AH load_states - load_states=( - 'critical' 'red' - 'warning' 'yellow' - 'normal' 'green' - ) - - if [[ "$OS" == "OSX" ]] || [[ "$OS" == "BSD" ]]; then - load_avg_1min=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | head -n 1) - if [[ "$OS" == "OSX" ]]; then - cores=$(sysctl -n hw.logicalcpu) - else - cores=$(sysctl -n hw.ncpu) - fi - else - load_avg_1min=$(grep -o "[0-9.]*" /proc/loadavg | head -n 1) - cores=$(nproc) - fi - - # Replace comma - load_avg_1min=${load_avg_1min//,/.} - - if [[ "$load_avg_1min" -gt $(bc -l <<< "${cores} * 0.7") ]]; then - current_state="critical" - elif [[ "$load_avg_1min" -gt $(bc -l <<< "${cores} * 0.5") ]]; then - current_state="warning" - else - current_state="normal" - fi - - "$1_prompt_segment" "${0}_${current_state}" "$2" "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg_1min" 'LOAD_ICON' -} - -# Node version -prompt_node_version() { - local node_version=$(node -v 2>/dev/null) - [[ -z "${node_version}" ]] && return - - "$1_prompt_segment" "$0" "$2" "green" "white" "${node_version:1}" 'NODE_ICON' -} - -# Node version from NVM -# Only prints the segment if different than the default value -prompt_nvm() { - [[ ! $(type nvm) =~ 'nvm is a shell function'* ]] && return - local node_version=$(nvm current) - [[ -z "${node_version}" ]] || [[ ${node_version} = "none" ]] && return - local nvm_default=$(cat $NVM_DIR/alias/default) - [[ "$node_version" =~ "$nvm_default" ]] && return - - $1_prompt_segment "$0" "$2" "green" "011" "${node_version:1}" 'NODE_ICON' -} - -# NodeEnv Prompt -prompt_nodeenv() { - local nodeenv_path="$NODE_VIRTUAL_ENV" - if [[ -n "$nodeenv_path" && "$NODE_VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then - local info="$(node -v)[$(basename "$nodeenv_path")]" - "$1_prompt_segment" "$0" "$2" "black" "green" "$info" 'NODE_ICON' - fi -} - -# print a little OS icon -prompt_os_icon() { - "$1_prompt_segment" "$0" "$2" "black" "255" "$OS_ICON" -} - -# print PHP version number -prompt_php_version() { - local php_version - php_version=$(php -v 2>&1 | grep -oe "^PHP\s*[0-9.]*") - - if [[ -n "$php_version" ]]; then - "$1_prompt_segment" "$0" "$2" "013" "255" "$php_version" - fi -} - -# Show free RAM and used Swap -prompt_ram() { - local base='' - local ramfree=0 - if [[ "$OS" == "OSX" ]]; then - # Available = Free + Inactive - # See https://support.apple.com/en-us/HT201538 - ramfree=$(vm_stat | grep "Pages free" | grep -o -E '[0-9]+') - ramfree=$((ramfree + $(vm_stat | grep "Pages inactive" | grep -o -E '[0-9]+'))) - # Convert pages into Bytes - ramfree=$(( ramfree * 4096 )) - else - if [[ "$OS" == "BSD" ]]; then - ramfree=$(grep 'avail memory' /var/run/dmesg.boot | awk '{print $4}') - else - ramfree=$(grep -o -E "MemAvailable:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*") - base='K' - fi - fi - - "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON' -} - -# rbenv information -prompt_rbenv() { - if which rbenv 2>/dev/null >&2; then - local rbenv_version_name="$(rbenv version-name)" - local rbenv_global="$(rbenv global)" - - # Don't show anything if the current Ruby is the same as the global Ruby. - if [[ $rbenv_version_name == $rbenv_global ]]; then - return - fi - - "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' - fi -} - -# chruby information -# see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH -prompt_chruby() { - local chruby_env - chrb_env="$(chruby 2> /dev/null | grep \* | tr -d '* ')" - # Don't show anything if the chruby did not change the default ruby - if [[ "${chrb_env:-system}" != "system" ]]; then - "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "${chrb_env}" 'RUBY_ICON' - fi -} - -# Print an icon if user is root. -prompt_root_indicator() { - if [[ "$UID" -eq 0 ]]; then - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "" 'ROOT_ICON' - fi -} - -# Print Rust version number -prompt_rust_version() { - local rust_version - rust_version=$(rustc --version 2>&1 | grep -oe "^rustc\s*[^ ]*" | grep -o '[0-9.a-z\\\-]*$') - - if [[ -n "$rust_version" ]]; then - "$1_prompt_segment" "$0" "$2" "208" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON' - fi -} -# RSpec test ratio -prompt_rspec_stats() { - if [[ (-d app && -d spec) ]]; then - local code_amount tests_amount - code_amount=$(ls -1 app/**/*.rb | wc -l) - tests_amount=$(ls -1 spec/**/*.rb | wc -l) - - build_test_stats "$1" "$0" "$2" "$code_amount" "$tests_amount" "RSpec" 'TEST_ICON' - fi -} - -# Ruby Version Manager information -prompt_rvm() { - local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') - [ "$gemset" != "" ] && gemset="@$gemset" - - local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') - - if [[ -n "$version$gemset" ]]; then - "$1_prompt_segment" "$0" "$2" "240" "$DEFAULT_COLOR" "$version$gemset" 'RUBY_ICON' - fi -} - -prompt_ssh() { - if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "" 'SSH_ICON' - fi -} - -# Status: return code if verbose, otherwise just an icon if an error occurred -set_default POWERLEVEL9K_STATUS_VERBOSE true -set_default POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE false -prompt_status() { - if [[ "$RETVAL" -ne 0 ]]; then - if [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then - "$1_prompt_segment" "$0_ERROR" "$2" "red" "226" "$RETVAL" 'CARRIAGE_RETURN_ICON' - else - "$1_prompt_segment" "$0_ERROR" "$2" "$DEFAULT_COLOR" "red" "" 'FAIL_ICON' - fi - elif [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true || "$POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE" == true ]]; then - "$1_prompt_segment" "$0_OK" "$2" "$DEFAULT_COLOR" "green" "" 'OK_ICON' - fi -} - -prompt_swap() { - local swap_used=0 - local base='' - - if [[ "$OS" == "OSX" ]]; then - local raw_swap_used - raw_swap_used=$(sysctl vm.swapusage | grep -o "used\s*=\s*[0-9,.A-Z]*" | grep -o "[0-9,.A-Z]*$") - - typeset -F 2 swap_used - swap_used=${$(echo $raw_swap_used | grep -o "[0-9,.]*")//,/.} - # Replace comma - swap_used=${swap_used//,/.} - - base=$(echo "$raw_swap_used" | grep -o "[A-Z]*$") - else - swap_total=$(grep -o -E "SwapTotal:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*") - swap_free=$(grep -o -E "SwapFree:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*") - swap_used=$(( swap_total - swap_free )) - base='K' - fi - - "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$swap_used" $base)" 'SWAP_ICON' -} - -# Symfony2-PHPUnit test ratio -prompt_symfony2_tests() { - if [[ (-d src && -d app && -f app/AppKernel.php) ]]; then - local code_amount tests_amount - code_amount=$(ls -1 src/**/*.php | grep -vc Tests) - tests_amount=$(ls -1 src/**/*.php | grep -c Tests) - - build_test_stats "$1" "$0" "$2" "$code_amount" "$tests_amount" "SF2" 'TEST_ICON' - fi -} - -# Symfony2-Version -prompt_symfony2_version() { - if [[ -f app/bootstrap.php.cache ]]; then - local symfony2_version - symfony2_version=$(grep " VERSION " app/bootstrap.php.cache | sed -e 's/[^.0-9]*//g') - "$1_prompt_segment" "$0" "$2" "240" "$DEFAULT_COLOR" "$symfony2_version" 'SYMFONY_ICON' - fi -} - -# Show a ratio of tests vs code -build_test_stats() { - local code_amount="$4" - local tests_amount="$5"+0.00001 - local headline="$6" - - # Set float precision to 2 digits: - typeset -F 2 ratio - local ratio=$(( (tests_amount/code_amount) * 100 )) - - (( ratio >= 75 )) && "$1_prompt_segment" "${2}_GOOD" "$3" "cyan" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" - (( ratio >= 50 && ratio < 75 )) && "$1_prompt_segment" "$2_AVG" "$3" "yellow" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" - (( ratio < 50 )) && "$1_prompt_segment" "$2_BAD" "$3" "red" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" -} - -# System time -prompt_time() { - local time_format="%D{%H:%M:%S}" - if [[ -n "$POWERLEVEL9K_TIME_FORMAT" ]]; then - time_format="$POWERLEVEL9K_TIME_FORMAT" - fi - - "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$time_format" -} - -# todo.sh: shows the number of tasks in your todo.sh file -prompt_todo() { - if $(hash todo.sh 2>&-); then - count=$(todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+) tasks shown" | awk '{ print $4 }') - if [[ "$count" = <-> ]]; then - "$1_prompt_segment" "$0" "$2" "244" "$DEFAULT_COLOR" "$count" 'TODO_ICON' - fi - fi -} - -# VCS segment: shows the state of your repository, if you are in a folder under -# version control -set_default POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND "red" -# Default: Just display the first 8 characters of our changeset-ID. -set_default POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH "8" -powerlevel9k_vcs_init() { - if [[ -n "$POWERLEVEL9K_CHANGESET_HASH_LENGTH" ]]; then - POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH="$POWERLEVEL9K_CHANGESET_HASH_LENGTH" - fi - - # Load VCS_INFO - autoload -Uz vcs_info - - VCS_WORKDIR_DIRTY=false - VCS_WORKDIR_HALF_DIRTY=false - - # The vcs segment can have three different states - defaults to 'clean'. - typeset -gAH vcs_states - vcs_states=( - 'clean' 'green' - 'modified' 'yellow' - 'untracked' 'green' - ) - - VCS_CHANGESET_PREFIX='' - if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then - VCS_CHANGESET_PREFIX="$(print_icon 'VCS_COMMIT_ICON')%0.$POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH""i " - fi - - zstyle ':vcs_info:*' enable git hg svn - zstyle ':vcs_info:*' check-for-changes true - - VCS_DEFAULT_FORMAT="$VCS_CHANGESET_PREFIX%b%c%u%m" - zstyle ':vcs_info:*' formats "$VCS_DEFAULT_FORMAT" - - zstyle ':vcs_info:*' actionformats "%b %F{${POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND}}| %a%f" - - zstyle ':vcs_info:*' stagedstr " $(print_icon 'VCS_STAGED_ICON')" - zstyle ':vcs_info:*' unstagedstr " $(print_icon 'VCS_UNSTAGED_ICON')" - - defined POWERLEVEL9K_VCS_GIT_HOOKS || POWERLEVEL9K_VCS_GIT_HOOKS=(vcs-detect-changes git-untracked git-aheadbehind git-stash git-remotebranch git-tagname) - zstyle ':vcs_info:git*+set-message:*' hooks $POWERLEVEL9K_VCS_GIT_HOOKS - defined POWERLEVEL9K_VCS_HG_HOOKS || POWERLEVEL9K_VCS_HG_HOOKS=(vcs-detect-changes) - zstyle ':vcs_info:hg*+set-message:*' hooks $POWERLEVEL9K_VCS_HG_HOOKS - defined POWERLEVEL9K_VCS_SVN_HOOKS || POWERLEVEL9K_VCS_SVN_HOOKS=(vcs-detect-changes svn-detect-changes) - zstyle ':vcs_info:svn*+set-message:*' hooks $POWERLEVEL9K_VCS_SVN_HOOKS - - # For Hg, only show the branch name - zstyle ':vcs_info:hg*:*' branchformat "$(print_icon 'VCS_BRANCH_ICON')%b" - # The `get-revision` function must be turned on for dirty-check to work for Hg - zstyle ':vcs_info:hg*:*' get-revision true - zstyle ':vcs_info:hg*:*' get-bookmarks true - zstyle ':vcs_info:hg*+gen-hg-bookmark-string:*' hooks hg-bookmarks - - # For svn, only - # TODO fix the %b (branch) format for svn. Using %b breaks - # color-encoding of the foreground for the rest of the powerline. - zstyle ':vcs_info:svn*:*' formats "$VCS_CHANGESET_PREFIX%c%u" - zstyle ':vcs_info:svn*:*' actionformats "$VCS_CHANGESET_PREFIX%c%u %F{${POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND}}| %a%f" - - if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then - zstyle ':vcs_info:*' get-revision true - fi -} - -prompt_vcs() { - VCS_WORKDIR_DIRTY=false - VCS_WORKDIR_HALF_DIRTY=false - current_state="" - - # Actually invoke vcs_info manually to gather all information. - vcs_info - local vcs_prompt="${vcs_info_msg_0_}" - - if [[ -n "$vcs_prompt" ]]; then - if [[ "$VCS_WORKDIR_DIRTY" == true ]]; then - # $vcs_visual_identifier gets set in +vi-vcs-detect-changes in functions/vcs.zsh, - # as we have there access to vcs_info internal hooks. - current_state='modified' - else - if [[ "$VCS_WORKDIR_HALF_DIRTY" == true ]]; then - current_state='untracked' - else - current_state='clean' - fi - fi - "$1_prompt_segment" "${0}_${(U)current_state}" "$2" "${vcs_states[$current_state]}" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier" - fi -} - -# Vi Mode: show editing mode (NORMAL|INSERT) -set_default POWERLEVEL9K_VI_INSERT_MODE_STRING "INSERT" -set_default POWERLEVEL9K_VI_COMMAND_MODE_STRING "NORMAL" -prompt_vi_mode() { - case ${KEYMAP} in - main|viins) - "$1_prompt_segment" "$0_INSERT" "$2" "$DEFAULT_COLOR" "blue" "$POWERLEVEL9K_VI_INSERT_MODE_STRING" - ;; - vicmd) - "$1_prompt_segment" "$0_NORMAL" "$2" "$DEFAULT_COLOR" "default" "$POWERLEVEL9K_VI_COMMAND_MODE_STRING" - ;; - esac -} - -# Virtualenv: current working virtualenv -# More information on virtualenv (Python): -# https://virtualenv.pypa.io/en/latest/ -prompt_virtualenv() { - local virtualenv_path="$VIRTUAL_ENV" - if [[ -n "$virtualenv_path" && "$VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then - "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" 'PYTHON_ICON' - fi -} - -# pyenv: current active python version (with restrictions) -# More information on pyenv (Python version manager like rbenv and rvm): -# https://github.com/yyuu/pyenv -# the prompt parses output of pyenv version and only displays the first word -prompt_pyenv() { - local pyenv_version="$(pyenv version 2>/dev/null)" - pyenv_version="${pyenv_version%% *}" - # XXX: The following should return the same as above. - # This reads better for devs familiar with sed/awk/grep/cut utilities - # Using shell expansion/substitution may hamper future maintainability - #local pyenv_version="$(pyenv version 2>/dev/null | head -n1 | cut -d' ' -f1)" - if [[ -n "$pyenv_version" && "$pyenv_version" != "system" ]]; then - "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$pyenv_version" 'PYTHON_ICON' - fi -} - -# Swift version -prompt_swift_version() { - # Get the first number as this is probably the "main" version number.. - local swift_version=$(swift --version 2>/dev/null | grep -o -E "[0-9.]+" | head -n 1) - [[ -z "${swift_version}" ]] && return - - "$1_prompt_segment" "$0" "$2" "magenta" "white" "${swift_version}" 'SWIFT_ICON' -} - -# dir_writable: Display information about the user's permission to write in the current directory -prompt_dir_writable() { - if [[ ! -w "$PWD" ]]; then - "$1_prompt_segment" "$0_FORBIDDEN" "$2" "red" "226" "" 'LOCK_ICON' - fi -} - -################################################################ -# Prompt processing and drawing -################################################################ -# Main prompt -build_left_prompt() { - local index=1 - for element in "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[@]}"; do - # Remove joined information in direct calls - element=${element%_joined} - - # Check if it is a custom command, otherwise interpet it as - # a prompt. - if [[ $element[0,7] =~ "custom_" ]]; then - "prompt_custom" "left" "$index" $element[8,-1] - else - "prompt_$element" "left" "$index" - fi - - index=$((index + 1)) - done - - left_prompt_end -} - -# Right prompt -build_right_prompt() { - local index=1 - for element in "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[@]}"; do - # Remove joined information in direct calls - element=${element%_joined} - - # Check if it is a custom command, otherwise interpet it as - # a prompt. - if [[ $element[0,7] =~ "custom_" ]]; then - "prompt_custom" "right" "$index" $element[8,-1] - else - "prompt_$element" "right" "$index" - fi - - index=$((index + 1)) - done -} - -powerlevel9k_preexec() { - _P9K_TIMER_START=$EPOCHREALTIME -} - -set_default POWERLEVEL9K_PROMPT_ADD_NEWLINE false -powerlevel9k_prepare_prompts() { - RETVAL=$? - - _P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START)) - - # Reset start time - _P9K_TIMER_START=0xFFFFFFFF - - if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then - PROMPT='$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt) -$(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')' - if [[ "$POWERLEVEL9K_RPROMPT_ON_NEWLINE" != true ]]; then - # The right prompt should be on the same line as the first line of the left - # prompt. To do so, there is just a quite ugly workaround: Before zsh draws - # the RPROMPT, we advise it, to go one line up. At the end of RPROMPT, we - # advise it to go one line down. See: - # http://superuser.com/questions/357107/zsh-right-justify-in-ps1 - local LC_ALL="" LC_CTYPE="en_US.UTF-8" # Set the right locale to protect special characters - RPROMPT_PREFIX='%{'$'\e[1A''%}' # one line up - RPROMPT_SUFFIX='%{'$'\e[1B''%}' # one line down - else - RPROMPT_PREFIX='' - RPROMPT_SUFFIX='' - fi - else - PROMPT='%f%b%k$(build_left_prompt)' - RPROMPT_PREFIX='' - RPROMPT_SUFFIX='' - fi - - if [[ "$POWERLEVEL9K_DISABLE_RPROMPT" != true ]]; then - RPROMPT='$RPROMPT_PREFIX%f%b%k$(build_right_prompt)%{$reset_color%}$RPROMPT_SUFFIX' - fi -NEWLINE=' -' - [[ $POWERLEVEL9K_PROMPT_ADD_NEWLINE == true ]] && PROMPT="$NEWLINE$PROMPT" -} - -prompt_powerlevel9k_setup() { - # I decided to use the value below for better supporting 32-bit CPUs, since the previous value "99999999999" was causing issues on my Android phone, which is powered by an armv7l - # We don't have to change that until 19 January of 2038! :) - - # Disable false display of command execution time - # Maximum integer on 32-bit CPUs - _P9K_TIMER_START=2147483647 - - # The prompt function will set these prompt_* options after the setup function - # returns. We need prompt_subst so we can safely run commands in the prompt - # without them being double expanded and we need prompt_percent to expand the - # common percent escape sequences. - prompt_opts=(subst percent cr) - - # Borrowed from promptinit, sets the prompt options in case the theme was - # not initialized via promptinit. - setopt noprompt{bang,cr,percent,subst} "prompt${^prompt_opts[@]}" - - # Display a warning if the terminal does not support 256 colors - local term_colors - term_colors=$(echotc Co 2>/dev/null) - if (( ! $? && ${term_colors:-0} < 256 )); then - print -P "%F{red}WARNING!%f Your terminal appears to support less than 256 colors!" - print -P "If your terminal supports 256 colors, please export the appropriate environment variable" - print -P "_before_ loading this theme in your \~\/.zshrc. In most terminal emulators, putting" - print -P "%F{blue}export TERM=\"xterm-256color\"%f at the top of your \~\/.zshrc is sufficient." - fi - - # If the terminal `LANG` is set to `C`, this theme will not work at all. - local term_lang - term_lang=$(echo $LANG) - if [[ $term_lang == 'C' ]]; then - print -P "\t%F{red}WARNING!%f Your terminal's 'LANG' is set to 'C', which breaks this theme!" - print -P "\t%F{red}WARNING!%f Please set your 'LANG' to a UTF-8 language, like 'en_US.UTF-8'" - print -P "\t%F{red}WARNING!%f _before_ loading this theme in your \~\.zshrc. Putting" - print -P "\t%F{red}WARNING!%f %F{blue}export LANG=\"en_US.UTF-8\"%f at the top of your \~\/.zshrc is sufficient." - fi - - defined POWERLEVEL9K_LEFT_PROMPT_ELEMENTS || POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) - defined POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS || POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time) - - # Display a warning if deprecated segments are in use. - typeset -AH deprecated_segments - # old => new - deprecated_segments=( - 'longstatus' 'status' - ) - print_deprecation_warning deprecated_segments - - # initialize colors - autoload -U colors && colors - - if segment_in_use "vcs"; then - powerlevel9k_vcs_init - fi - - # initialize timing functions - zmodload zsh/datetime - - # Initialize math functions - zmodload zsh/mathfunc - - # initialize hooks - autoload -Uz add-zsh-hook - - # prepare prompts - add-zsh-hook precmd powerlevel9k_prepare_prompts - add-zsh-hook preexec powerlevel9k_preexec -} - -prompt_powerlevel9k_setup "$@" diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/prompt_powerlevel9k_setup b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/prompt_powerlevel9k_setup deleted file mode 120000 index 311575f4..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/prompt_powerlevel9k_setup +++ /dev/null @@ -1 +0,0 @@ -powerlevel9k.zsh-theme \ No newline at end of file diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-bsd-vm/Vagrantfile b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-bsd-vm/Vagrantfile deleted file mode 100644 index 7df512a3..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-bsd-vm/Vagrantfile +++ /dev/null @@ -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 diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-bsd-vm/bootstrap-zero.sh b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-bsd-vm/bootstrap-zero.sh deleted file mode 100644 index 35dcd7f3..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-bsd-vm/bootstrap-zero.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -pkg install -y sudo \ No newline at end of file diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-bsd-vm/bootstrap.sh b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-bsd-vm/bootstrap.sh deleted file mode 100644 index ba27ffb3..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-bsd-vm/bootstrap.sh +++ /dev/null @@ -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 \ No newline at end of file diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm-providers/plain.sh b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm-providers/plain.sh deleted file mode 100644 index b827a0c4..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm-providers/plain.sh +++ /dev/null @@ -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 \ No newline at end of file diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm-providers/setup-environment.sh b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm-providers/setup-environment.sh deleted file mode 100755 index 0e8beb6d..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm-providers/setup-environment.sh +++ /dev/null @@ -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 " -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 \ No newline at end of file diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/README.md b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/README.md deleted file mode 100644 index 9f0861e9..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/README.md +++ /dev/null @@ -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 `. `-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. diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/Vagrantfile b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/Vagrantfile deleted file mode 100644 index a421c706..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/Vagrantfile +++ /dev/null @@ -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 diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/antigen.sh b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/antigen.sh deleted file mode 100644 index 2c563322..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/antigen.sh +++ /dev/null @@ -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 -) diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/bootstrap.sh b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/bootstrap.sh deleted file mode 100644 index f680d4b8..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/bootstrap.sh +++ /dev/null @@ -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 \ No newline at end of file diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/omz.sh b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/omz.sh deleted file mode 100644 index 73b659f3..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/omz.sh +++ /dev/null @@ -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 -) diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/prezto.sh b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/prezto.sh deleted file mode 100644 index 3ac38503..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test-vm/prezto.sh +++ /dev/null @@ -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 -) diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/functions/colors.spec b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/functions/colors.spec deleted file mode 100755 index 61a40087..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/functions/colors.spec +++ /dev/null @@ -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 diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/functions/icons.spec b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/functions/icons.spec deleted file mode 100755 index c8d88644..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/functions/icons.spec +++ /dev/null @@ -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 \ No newline at end of file diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/functions/utilities.spec b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/functions/utilities.spec deleted file mode 100755 index a9bd67e3..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/functions/utilities.spec +++ /dev/null @@ -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 diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/powerlevel9k.spec b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/powerlevel9k.spec deleted file mode 100755 index 5f6b6f27..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/powerlevel9k.spec +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env zsh -#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 - -# Required for shunit2 to run correctly -setopt shwordsplit -SHUNIT_PARENT=$0 - -function setUp() { - export TERM="xterm-256color" - # Load Powerlevel9k - source powerlevel9k.zsh-theme - source functions/* - - # Unset mode, so that user settings - # do not interfere with tests - unset POWERLEVEL9K_MODE -} - -function testJoinedSegments() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir dir_joined) - cd /tmp - - assertEquals "%K{blue} %F{black}/tmp %K{blue}%F{black}%F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - cd - -} - -function testTransitiveJoinedSegments() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir root_indicator_joined dir_joined) - cd /tmp - - assertEquals "%K{blue} %F{black}/tmp %K{blue}%F{black}%F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - cd - -} - -function testJoiningWithConditionalSegment() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir background_jobs dir_joined) - cd /tmp - - assertEquals "%K{blue} %F{black}/tmp %K{blue}%F{black} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - cd - -} - -function testDynamicColoringOfSegmentsWork() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_DIR_DEFAULT_BACKGROUND='red' - cd /tmp - - assertEquals "%K{red} %F{black}/tmp %k%F{red}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_DIR_DEFAULT_BACKGROUND - cd - -} - -function testDynamicColoringOfVisualIdentifiersWork() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR='green' - POWERLEVEL9K_FOLDER_ICON="icon-here" - - cd /tmp - - assertEquals "%K{blue} %F{green%}icon-here%f %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR - unset POWERLEVEL9K_FOLDER_ICON - cd - -} - -function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR='green' - POWERLEVEL9K_DIR_DEFAULT_FOREGROUND='red' - POWERLEVEL9K_DIR_DEFAULT_BACKGROUND='yellow' - POWERLEVEL9K_FOLDER_ICON="icon-here" - - # Re-Source the icons, as the POWERLEVEL9K_MODE is directly - # evaluated there. - source functions/icons.zsh - - cd /tmp - - assertEquals "%K{yellow} %F{green%}icon-here%f %F{red}/tmp %k%F{yellow}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR - unset POWERLEVEL9K_DIR_DEFAULT_FOREGROUND - unset POWERLEVEL9K_DIR_DEFAULT_BACKGROUND - unset POWERLEVEL9K_FOLDER_ICON - cd - -} - -function testOverwritingIconsWork() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_FOLDER_ICON='icon-here' - #local testFolder=$(mktemp -d -p p9k) - # Move testFolder under home folder - #mv testFolder ~ - # Go into testFolder - #cd ~/$testFolder - - cd /tmp - assertEquals "%K{blue} %F{black%}icon-here%f %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_DIR_FOLDER_ICON - cd - - # rm -fr ~/$testFolder -} - -source shunit2/source/2.1/src/shunit2 diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/command_execution_time.spec b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/command_execution_time.spec deleted file mode 100755 index 09738859..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/command_execution_time.spec +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env zsh -#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 - -# Required for shunit2 to run correctly -setopt shwordsplit -SHUNIT_PARENT=$0 - -function setUp() { - export TERM="xterm-256color" - # Load Powerlevel9k - source powerlevel9k.zsh-theme -} - -function testCommandExecutionTimeIsNotShownIfTimeIsBelowThreshold() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world command_execution_time) - POWERLEVEL9K_CUSTOM_WORLD='echo world' - _P9K_COMMAND_DURATION=2 - - assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_CUSTOM_WORLD - unset _P9K_COMMAND_DURATION -} - -function testCommandExecutionTimeThresholdCouldBeChanged() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) - POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=1 - _P9K_COMMAND_DURATION=2.03 - - assertEquals "%K{red} %F{226%}Dur%f %F{226}2.03 %k%F{red}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset _P9K_COMMAND_DURATION - unset POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD -} - -function testCommandExecutionTimeThresholdCouldBeSetToZero() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) - POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0 - _P9K_COMMAND_DURATION=0.03 - - assertEquals "%K{red} %F{226%}Dur%f %F{226}0.03 %k%F{red}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset _P9K_COMMAND_DURATION - unset POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD -} - -function testCommandExecutionTimePrecisionCouldBeChanged() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) - POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0 - POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=4 - _P9K_COMMAND_DURATION=0.0001 - - assertEquals "%K{red} %F{226%}Dur%f %F{226}0.0001 %k%F{red}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset _P9K_COMMAND_DURATION - unset POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION - unset POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD -} - -function testCommandExecutionTimePrecisionCouldBeSetToZero() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) - POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 - _P9K_COMMAND_DURATION=23.5001 - - assertEquals "%K{red} %F{226%}Dur%f %F{226}23 %k%F{red}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset _P9K_COMMAND_DURATION - unset POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION -} - -function testCommandExecutionTimeIsFormattedHumandReadbleForMinuteLongCommand() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) - _P9K_COMMAND_DURATION=180 - - assertEquals "%K{red} %F{226%}Dur%f %F{226}03:00 %k%F{red}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset _P9K_COMMAND_DURATION -} - -function testCommandExecutionTimeIsFormattedHumandReadbleForHourLongCommand() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) - _P9K_COMMAND_DURATION=7200 - - assertEquals "%K{red} %F{226%}Dur%f %F{226}02:00:00 %k%F{red}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset _P9K_COMMAND_DURATION -} - -source shunit2/source/2.1/src/shunit2 \ No newline at end of file diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/dir.spec b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/dir.spec deleted file mode 100755 index b2991175..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/dir.spec +++ /dev/null @@ -1,364 +0,0 @@ -#!/usr/bin/env zsh -#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 - -# Required for shunit2 to run correctly -setopt shwordsplit -SHUNIT_PARENT=$0 - -function setUp() { - export TERM="xterm-256color" - # Load Powerlevel9k - source powerlevel9k.zsh-theme - - # Every test should at least use the dir segment - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) -} - -function tearDown() { - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS -} - -function testTruncateFoldersWorks() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders' - - FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 - mkdir -p $FOLDER - cd $FOLDER - - assertEquals "%K{blue} %F{black}…/12345678/123456789 %k%F{blue}%f " "$(build_left_prompt)" - - cd - - rm -fr /tmp/powerlevel9k-test - - unset FOLDER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY -} - -function testTruncateMiddleWorks() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle' - - FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 - mkdir -p $FOLDER - cd $FOLDER - - assertEquals "%K{blue} %F{black}/tmp/po…st/1/12/123/1234/12…45/12…56/12…67/12…78/123456789 %k%F{blue}%f " "$(build_left_prompt)" - - cd - - rm -fr /tmp/powerlevel9k-test - - unset FOLDER - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_SHORTEN_STRATEGY -} - -function testTruncationFromRightWorks() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' - - FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 - mkdir -p $FOLDER - cd $FOLDER - - assertEquals "%K{blue} %F{black}/tmp/po…/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{blue}%f " "$(build_left_prompt)" - - cd - - rm -fr /tmp/powerlevel9k-test - - unset FOLDER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY -} - -function testTruncateWithFolderMarkerWorks() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker" - - local BASEFOLDER=/tmp/powerlevel9k-test - local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567 - mkdir -p $FOLDER - # Setup folder marker - touch $BASEFOLDER/1/12/.shorten_folder_marker - cd $FOLDER - assertEquals "%K{blue} %F{black}/…/12/123/1234/12345/123456/1234567 %k%F{blue}%f " "$(build_left_prompt)" - - cd - - rm -fr $BASEFOLDER - unset BASEFOLDER - unset FOLDER - unset POWERLEVEL9K_SHORTEN_STRATEGY - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS -} - -function testTruncateWithFolderMarkerWithChangedFolderMarker() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker" - POWERLEVEL9K_SHORTEN_FOLDER_MARKER='.xxx' - - local BASEFOLDER=/tmp/powerlevel9k-test - local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567 - mkdir -p $FOLDER - # Setup folder marker - touch $BASEFOLDER/1/12/.xxx - cd $FOLDER - assertEquals "%K{blue} %F{black}/…/12/123/1234/12345/123456/1234567 %k%F{blue}%f " "$(build_left_prompt)" - - cd - - rm -fr $BASEFOLDER - unset BASEFOLDER - unset FOLDER - unset POWERLEVEL9K_SHORTEN_FOLDER_MARKER - unset POWERLEVEL9K_SHORTEN_STRATEGY - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS -} - -function testTruncateWithPackageNameWorks() { - local p9kFolder=$(pwd) - local BASEFOLDER=/tmp/powerlevel9k-test - local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567/12345678/123456789 - mkdir -p $FOLDER - - cd /tmp/powerlevel9k-test - echo ' -{ - "name": "My_Package" -} -' > package.json - # Unfortunately: The main folder must be a git repo.. - git init &>/dev/null - - # Go back to deeper folder - cd "${FOLDER}" - - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name' - - assertEquals "%K{blue} %F{black}My_Package/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{blue}%f " "$(build_left_prompt)" - - # Go back - cd $p9kFolder - rm -fr $BASEFOLDER - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_SHORTEN_STRATEGY - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH -} - -function testTruncateWithPackageNameIfRepoIsSymlinkedInsideDeepFolder() { - local p9kFolder=$(pwd) - local BASEFOLDER=/tmp/powerlevel9k-test - local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567/12345678/123456789 - mkdir -p $FOLDER - cd $FOLDER - - # Unfortunately: The main folder must be a git repo.. - git init &>/dev/null - - echo ' -{ - "name": "My_Package" -} -' > package.json - - # Create a subdir inside the repo - mkdir -p asdfasdf/qwerqwer - - cd $BASEFOLDER - ln -s ${FOLDER} linked-repo - - # Go to deep folder inside linked repo - cd linked-repo/asdfasdf/qwerqwer - - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name' - - assertEquals "%K{blue} %F{black}My_Package/as…/qwerqwer %k%F{blue}%f " "$(build_left_prompt)" - - # Go back - cd $p9kFolder - rm -fr $BASEFOLDER - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_SHORTEN_STRATEGY - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH -} - -function testTruncateWithPackageNameIfRepoIsSymlinkedInsideGitDir() { - local p9kFolder=$(pwd) - local BASEFOLDER=/tmp/powerlevel9k-test - local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567/12345678/123456789 - mkdir -p $FOLDER - cd $FOLDER - - # Unfortunately: The main folder must be a git repo.. - git init &>/dev/null - - echo ' -{ - "name": "My_Package" -} -' > package.json - - cd $BASEFOLDER - ln -s ${FOLDER} linked-repo - - cd linked-repo/.git/refs/heads - - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name' - - assertEquals "%K{blue} %F{black}My_Package/.g…/re…/heads %k%F{blue}%f " "$(build_left_prompt)" - - # Go back - cd $p9kFolder - rm -fr $BASEFOLDER - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_SHORTEN_STRATEGY - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH -} - -function testHomeFolderDetectionWorks() { - POWERLEVEL9K_HOME_ICON='home-icon' - - cd ~ - assertEquals "%K{blue} %F{black%}home-icon%f %F{black}~ %k%F{blue}%f " "$(build_left_prompt)" - - cd - - unset POWERLEVEL9K_HOME_ICON -} - -function testHomeSubfolderDetectionWorks() { - POWERLEVEL9K_HOME_SUB_ICON='sub-icon' - - FOLDER=~/powerlevel9k-test - mkdir $FOLDER - cd $FOLDER - assertEquals "%K{blue} %F{black%}sub-icon%f %F{black}~/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" - - cd - - rm -fr $FOLDER - unset FOLDER - unset POWERLEVEL9K_HOME_SUB_ICON -} - -function testOtherFolderDetectionWorks() { - POWERLEVEL9K_FOLDER_ICON='folder-icon' - - FOLDER=/tmp/powerlevel9k-test - mkdir $FOLDER - cd $FOLDER - assertEquals "%K{blue} %F{black%}folder-icon%f %F{black}/tmp/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" - - cd - - rm -fr $FOLDER - unset FOLDER - unset POWERLEVEL9K_FOLDER_ICON -} - -function testChangingDirPathSeparator() { - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' - local FOLDER="/tmp/powerlevel9k-test/1/2" - mkdir -p $FOLDER - cd $FOLDER - - assertEquals "%K{blue} %F{black}xXxtmpxXxpowerlevel9k-testxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" - - cd - - unset FOLDER - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR -} - -function testOmittingFirstCharacterWorks() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_FOLDER_ICON='folder-icon' - cd /tmp - - assertEquals "%K{blue} %F{black%}folder-icon%f %F{black}tmp %k%F{blue}%f " "$(build_left_prompt)" - - cd - - unset POWERLEVEL9K_FOLDER_ICON - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER -} - -function testOmittingFirstCharacterWorksWithChangingPathSeparator() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' - POWERLEVEL9K_FOLDER_ICON='folder-icon' - mkdir -p /tmp/powerlevel9k-test/1/2 - cd /tmp/powerlevel9k-test/1/2 - - assertEquals "%K{blue} %F{black%}folder-icon%f %F{black}tmpxXxpowerlevel9k-testxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" - - cd - - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_FOLDER_ICON - unset POWERLEVEL9K_DIR_PATH_SEPARATOR - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER -} - -# This test makes it obvious that combining a truncation strategy -# that cuts off folders from the left and omitting the the first -# character does not make much sense. The truncation strategy -# comes first, prints an ellipsis and that gets then cut off by -# POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER.. -# But it does more sense in combination with other truncation -# strategies. -function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndDefaultTruncation() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders' - mkdir -p /tmp/powerlevel9k-test/1/2 - cd /tmp/powerlevel9k-test/1/2 - - assertEquals "%K{blue} %F{black}xXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" - - cd - - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY -} - -function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndMiddleTruncation() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle' - mkdir -p /tmp/powerlevel9k-test/1/2 - cd /tmp/powerlevel9k-test/1/2 - - assertEquals "%K{blue} %F{black}tmpxXxpo…stxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" - - cd - - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY -} - -function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndRightTruncation() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' - mkdir -p /tmp/powerlevel9k-test/1/2 - cd /tmp/powerlevel9k-test/1/2 - - assertEquals "%K{blue} %F{black}tmpxXxpo…xXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" - - cd - - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY -} - -source shunit2/source/2.1/src/shunit2 diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/go_version.spec b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/go_version.spec deleted file mode 100755 index 2aac460b..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/go_version.spec +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env zsh -#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 - -# Required for shunit2 to run correctly -setopt shwordsplit -SHUNIT_PARENT=$0 - -function setUp() { - export TERM="xterm-256color" - # Load Powerlevel9k - source powerlevel9k.zsh-theme -} - -function mockGo() { - case "$1" in - 'version') - echo 'go version go1.5.3 darwin/amd64' - ;; - 'env') - echo "$HOME/go" - ;; - esac -} - -function mockGoEmptyGopath() { - case "$1" in - 'version') - echo 'go version go1.5.3 darwin/amd64' - ;; - 'env') - echo "" - ;; - esac -} - -function testGo() { - alias go=mockGo - POWERLEVEL9K_GO_ICON="" - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(go_version) - - PWD="$HOME/go/src/github.com/bhilburn/powerlevel9k" - - assertEquals "%K{green} %F{255%}%f %F{255}go1.5.3 %k%F{green}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_GO_ICON - unset PWD - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unalias go -} - -function testGoSegmentPrintsNothingIfEmptyGopath() { - alias go=mockGoEmptyGopath - POWERLEVEL9K_CUSTOM_WORLD='echo world' - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version) - - assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_CUSTOM_WORLD - -} - -function testGoSegmentPrintsNothingIfNotInGopath() { - alias go=mockGo - POWERLEVEL9K_CUSTOM_WORLD='echo world' - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version) - - assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_CUSTOM_WORLD -} - -function testGoSegmentPrintsNothingIfGoIsNotAvailable() { - alias go=noGo - POWERLEVEL9K_CUSTOM_WORLD='echo world' - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version) - - assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_CUSTOM_WORLD - unalias go -} - -source shunit2/source/2.1/src/shunit2 diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/rust_version.spec b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/rust_version.spec deleted file mode 100755 index 49b06bcf..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/rust_version.spec +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env zsh -#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 - -# Required for shunit2 to run correctly -setopt shwordsplit -SHUNIT_PARENT=$0 - -function setUp() { - export TERM="xterm-256color" - # Load Powerlevel9k - source powerlevel9k.zsh-theme -} - -function mockRust() { - echo 'rustc 0.4.1a-alpha' -} - -function testRust() { - alias rustc=mockRust - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version) - - assertEquals "%K{208} %F{black}Rust 0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unalias rustc -} - -function testRustPrintsNothingIfRustIsNotAvailable() { - alias rustc=noRust - POWERLEVEL9K_CUSTOM_WORLD='echo world' - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world rust_version) - - assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_CUSTOM_WORLD - unalias rustc -} - -source shunit2/source/2.1/src/shunit2 diff --git a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/vcs.spec b/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/vcs.spec deleted file mode 100755 index 4467145e..00000000 --- a/shells/zsh/oh-my-zsh-custom/themes/powerlevel9k/test/segments/vcs.spec +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env zsh -#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 - -# Required for shunit2 to run correctly -setopt shwordsplit -SHUNIT_PARENT=$0 - -function setUp() { - export TERM="xterm-256color" - # Load Powerlevel9k - source powerlevel9k.zsh-theme -} - -function testColorOverridingForCleanStateWorks() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) - POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan' - POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white' - - FOLDER=/tmp/powerlevel9k-test/vcs-test - mkdir -p $FOLDER - cd $FOLDER - git init 1>/dev/null - - assertEquals "%K{white} %F{cyan}master %k%F{white}%f " "$(build_left_prompt)" - - cd - - rm -fr /tmp/powerlevel9k-test - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_VCS_CLEAN_FOREGROUND - unset POWERLEVEL9K_VCS_CLEAN_BACKGROUND -} - -function testColorOverridingForModifiedStateWorks() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) - POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='red' - POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='yellow' - - FOLDER=/tmp/powerlevel9k-test/vcs-test - mkdir -p $FOLDER - cd $FOLDER - git init 1>/dev/null - git config user.email "test@powerlevel9k.theme" - git config user.name "Testing Tester" - touch testfile - git add testfile - git commit -m "test" 1>/dev/null - echo "test" > testfile - - assertEquals "%K{yellow} %F{red}master ● %k%F{yellow}%f " "$(build_left_prompt)" - - cd - - rm -fr /tmp/powerlevel9k-test - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_VCS_MODIFIED_FOREGROUND - unset POWERLEVEL9K_VCS_MODIFIED_BACKGROUND -} - -function testColorOverridingForUntrackedStateWorks() { - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) - POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='cyan' - POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='yellow' - - FOLDER=/tmp/powerlevel9k-test/vcs-test - mkdir -p $FOLDER - cd $FOLDER - git init 1>/dev/null - touch testfile - - assertEquals "%K{yellow} %F{cyan}master ? %k%F{yellow}%f " "$(build_left_prompt)" - - cd - - rm -fr /tmp/powerlevel9k-test - - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND - unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND -} - -source shunit2/source/2.1/src/shunit2