diff --git a/.zalias b/.zalias deleted file mode 120000 index 5a3fd9c..0000000 --- a/.zalias +++ /dev/null @@ -1 +0,0 @@ -.zprezto/runcoms/zalias \ No newline at end of file diff --git a/.zlogin b/.zlogin index 5765ab0..3701292 120000 --- a/.zlogin +++ b/.zlogin @@ -1 +1 @@ -.zprezto/runcoms/zlogin \ No newline at end of file +/Users/svxf/.zprezto/runcoms/zlogin \ No newline at end of file diff --git a/.zlogout b/.zlogout index 8f76c74..9baa093 120000 --- a/.zlogout +++ b/.zlogout @@ -1 +1 @@ -.zprezto/runcoms/zlogout \ No newline at end of file +/Users/svxf/.zprezto/runcoms/zlogout \ No newline at end of file diff --git a/.zprezto/.editorconfig_backup b/.zprezto/.editorconfig_backup new file mode 100644 index 0000000..42dd37a --- /dev/null +++ b/.zprezto/.editorconfig_backup @@ -0,0 +1,9 @@ +[*] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +[{.gitattributes,.gitignore,.gitmodules}] +indent_style = tab diff --git a/.zprezto/.git_backup/HEAD b/.zprezto/.git_backup/HEAD new file mode 100644 index 0000000..cb089cd --- /dev/null +++ b/.zprezto/.git_backup/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/.zprezto/.git_backup/config b/.zprezto/.git_backup/config new file mode 100644 index 0000000..369d018 --- /dev/null +++ b/.zprezto/.git_backup/config @@ -0,0 +1,35 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true +[submodule] + active = . +[remote "origin"] + url = https://github.com/sorin-ionescu/prezto.git + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master +[submodule "modules/autosuggestions/external"] + url = https://github.com/zsh-users/zsh-autosuggestions.git +[submodule "modules/completion/external"] + url = https://github.com/zsh-users/zsh-completions.git +[submodule "modules/fasd/external"] + url = https://github.com/clvv/fasd.git +[submodule "modules/history-substring-search/external"] + url = https://github.com/zsh-users/zsh-history-substring-search.git +[submodule "modules/prompt/external/agnoster"] + url = https://github.com/agnoster/agnoster-zsh-theme.git +[submodule "modules/prompt/external/async"] + url = https://github.com/mafredri/zsh-async.git +[submodule "modules/prompt/external/powerlevel9k"] + url = https://github.com/bhilburn/powerlevel9k.git +[submodule "modules/prompt/external/powerline"] + url = https://github.com/davidjrice/prezto_powerline.git +[submodule "modules/prompt/functions/pure"] + url = https://github.com/sindresorhus/pure.git +[submodule "modules/syntax-highlighting/external"] + url = https://github.com/zsh-users/zsh-syntax-highlighting.git diff --git a/.zprezto/.git_backup/description b/.zprezto/.git_backup/description new file mode 100644 index 0000000..498b267 --- /dev/null +++ b/.zprezto/.git_backup/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/.zprezto/.git_backup/hooks/applypatch-msg.sample b/.zprezto/.git_backup/hooks/applypatch-msg.sample new file mode 100755 index 0000000..a5d7b84 --- /dev/null +++ b/.zprezto/.git_backup/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/hooks/commit-msg.sample b/.zprezto/.git_backup/hooks/commit-msg.sample new file mode 100755 index 0000000..b58d118 --- /dev/null +++ b/.zprezto/.git_backup/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/.zprezto/.git_backup/hooks/fsmonitor-watchman.sample b/.zprezto/.git_backup/hooks/fsmonitor-watchman.sample new file mode 100755 index 0000000..e673bb3 --- /dev/null +++ b/.zprezto/.git_backup/hooks/fsmonitor-watchman.sample @@ -0,0 +1,114 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use IPC::Open2; + +# An example hook script to integrate Watchman +# (https://facebook.github.io/watchman/) with git to speed up detecting +# new and modified files. +# +# The hook is passed a version (currently 1) and a time in nanoseconds +# formatted as a string and outputs to stdout all files that have been +# modified since the given time. Paths must be relative to the root of +# the working tree and separated by a single NUL. +# +# To enable this hook, rename this file to "query-watchman" and set +# 'git config core.fsmonitor .git/hooks/query-watchman' +# +my ($version, $time) = @ARGV; + +# Check the hook interface version + +if ($version == 1) { + # convert nanoseconds to seconds + $time = int $time / 1000000000; +} else { + die "Unsupported query-fsmonitor hook version '$version'.\n" . + "Falling back to scanning...\n"; +} + +my $git_work_tree; +if ($^O =~ 'msys' || $^O =~ 'cygwin') { + $git_work_tree = Win32::GetCwd(); + $git_work_tree =~ tr/\\/\//; +} else { + require Cwd; + $git_work_tree = Cwd::cwd(); +} + +my $retry = 1; + +launch_watchman(); + +sub launch_watchman { + + my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') + or die "open2() failed: $!\n" . + "Falling back to scanning...\n"; + + # In the query expression below we're asking for names of files that + # changed since $time but were not transient (ie created after + # $time but no longer exist). + # + # To accomplish this, we're using the "since" generator to use the + # recency index to select candidate nodes and "fields" to limit the + # output to file names only. Then we're using the "expression" term to + # further constrain the results. + # + # The category of transient files that we want to ignore will have a + # creation clock (cclock) newer than $time_t value and will also not + # currently exist. + + my $query = <<" END"; + ["query", "$git_work_tree", { + "since": $time, + "fields": ["name"], + "expression": ["not", ["allof", ["since", $time, "cclock"], ["not", "exists"]]] + }] + END + + print CHLD_IN $query; + close CHLD_IN; + my $response = do {local $/; }; + + die "Watchman: command returned no output.\n" . + "Falling back to scanning...\n" if $response eq ""; + die "Watchman: command returned invalid output: $response\n" . + "Falling back to scanning...\n" unless $response =~ /^\{/; + + my $json_pkg; + eval { + require JSON::XS; + $json_pkg = "JSON::XS"; + 1; + } or do { + require JSON::PP; + $json_pkg = "JSON::PP"; + }; + + my $o = $json_pkg->new->utf8->decode($response); + + if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) { + print STDERR "Adding '$git_work_tree' to watchman's watch list.\n"; + $retry--; + qx/watchman watch "$git_work_tree"/; + die "Failed to make watchman watch '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + + # Watchman will always return all files on the first query so + # return the fast "everything is dirty" flag to git and do the + # Watchman query just to get it over with now so we won't pay + # the cost in git to look up each individual file. + print "/\0"; + eval { launch_watchman() }; + exit 0; + } + + die "Watchman: $o->{error}.\n" . + "Falling back to scanning...\n" if $o->{error}; + + binmode STDOUT, ":utf8"; + local $, = "\0"; + print @{$o->{files}}; +} diff --git a/.zprezto/.git_backup/hooks/post-update.sample b/.zprezto/.git_backup/hooks/post-update.sample new file mode 100755 index 0000000..ec17ec1 --- /dev/null +++ b/.zprezto/.git_backup/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/.zprezto/.git_backup/hooks/pre-applypatch.sample b/.zprezto/.git_backup/hooks/pre-applypatch.sample new file mode 100755 index 0000000..4142082 --- /dev/null +++ b/.zprezto/.git_backup/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/hooks/pre-commit.sample b/.zprezto/.git_backup/hooks/pre-commit.sample new file mode 100755 index 0000000..6a75641 --- /dev/null +++ b/.zprezto/.git_backup/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/.zprezto/.git_backup/hooks/pre-push.sample b/.zprezto/.git_backup/hooks/pre-push.sample new file mode 100755 index 0000000..6187dbf --- /dev/null +++ b/.zprezto/.git_backup/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo >&2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/.zprezto/.git_backup/hooks/pre-rebase.sample b/.zprezto/.git_backup/hooks/pre-rebase.sample new file mode 100755 index 0000000..6cbef5c --- /dev/null +++ b/.zprezto/.git_backup/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up to date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/.zprezto/.git_backup/hooks/pre-receive.sample b/.zprezto/.git_backup/hooks/pre-receive.sample new file mode 100755 index 0000000..a1fd29e --- /dev/null +++ b/.zprezto/.git_backup/hooks/pre-receive.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to make use of push options. +# The example simply echoes all push options that start with 'echoback=' +# and rejects all pushes when the "reject" push option is used. +# +# To enable this hook, rename this file to "pre-receive". + +if test -n "$GIT_PUSH_OPTION_COUNT" +then + i=0 + while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" + do + eval "value=\$GIT_PUSH_OPTION_$i" + case "$value" in + echoback=*) + echo "echo from the pre-receive-hook: ${value#*=}" >&2 + ;; + reject) + exit 1 + esac + i=$((i + 1)) + done +fi diff --git a/.zprezto/.git_backup/hooks/prepare-commit-msg.sample b/.zprezto/.git_backup/hooks/prepare-commit-msg.sample new file mode 100755 index 0000000..10fa14c --- /dev/null +++ b/.zprezto/.git_backup/hooks/prepare-commit-msg.sample @@ -0,0 +1,42 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first one removes the +# "# Please enter the commit message..." help message. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 + +/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" + +# case "$COMMIT_SOURCE,$SHA1" in +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; +# *) ;; +# esac + +# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" +# if test -z "$COMMIT_SOURCE" +# then +# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" +# fi diff --git a/.zprezto/.git_backup/hooks/update.sample b/.zprezto/.git_backup/hooks/update.sample new file mode 100755 index 0000000..80ba941 --- /dev/null +++ b/.zprezto/.git_backup/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to block unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/.zprezto/.git_backup/index b/.zprezto/.git_backup/index new file mode 100644 index 0000000..0cb793b Binary files /dev/null and b/.zprezto/.git_backup/index differ diff --git a/.zprezto/.git_backup/info/exclude b/.zprezto/.git_backup/info/exclude new file mode 100644 index 0000000..a5196d1 --- /dev/null +++ b/.zprezto/.git_backup/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/.zprezto/.git_backup/logs/HEAD b/.zprezto/.git_backup/logs/HEAD new file mode 100644 index 0000000..cc83364 --- /dev/null +++ b/.zprezto/.git_backup/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 f2042a29cc7613e8f797044948b0238916b2a234 Andrey Anurin 1534073683 +0300 clone: from https://github.com/sorin-ionescu/prezto.git diff --git a/.zprezto/.git_backup/logs/refs/heads/master b/.zprezto/.git_backup/logs/refs/heads/master new file mode 100644 index 0000000..cc83364 --- /dev/null +++ b/.zprezto/.git_backup/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 f2042a29cc7613e8f797044948b0238916b2a234 Andrey Anurin 1534073683 +0300 clone: from https://github.com/sorin-ionescu/prezto.git diff --git a/.zprezto/.git_backup/logs/refs/remotes/origin/HEAD b/.zprezto/.git_backup/logs/refs/remotes/origin/HEAD new file mode 100644 index 0000000..cc83364 --- /dev/null +++ b/.zprezto/.git_backup/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 f2042a29cc7613e8f797044948b0238916b2a234 Andrey Anurin 1534073683 +0300 clone: from https://github.com/sorin-ionescu/prezto.git diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/HEAD b/.zprezto/.git_backup/modules/modules/autosuggestions/external/HEAD new file mode 100644 index 0000000..842f01b --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/HEAD @@ -0,0 +1 @@ +d7c796719e6352666f7a9c94da9ddaed10f3217d diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/config b/.zprezto/.git_backup/modules/modules/autosuggestions/external/config new file mode 100644 index 0000000..5329358 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/config @@ -0,0 +1,14 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true + worktree = ../../../../../modules/autosuggestions/external +[remote "origin"] + url = https://github.com/zsh-users/zsh-autosuggestions.git + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/description b/.zprezto/.git_backup/modules/modules/autosuggestions/external/description new file mode 100644 index 0000000..498b267 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/applypatch-msg.sample b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/applypatch-msg.sample new file mode 100755 index 0000000..a5d7b84 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/commit-msg.sample b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/commit-msg.sample new file mode 100755 index 0000000..b58d118 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/fsmonitor-watchman.sample b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/fsmonitor-watchman.sample new file mode 100755 index 0000000..e673bb3 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/fsmonitor-watchman.sample @@ -0,0 +1,114 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use IPC::Open2; + +# An example hook script to integrate Watchman +# (https://facebook.github.io/watchman/) with git to speed up detecting +# new and modified files. +# +# The hook is passed a version (currently 1) and a time in nanoseconds +# formatted as a string and outputs to stdout all files that have been +# modified since the given time. Paths must be relative to the root of +# the working tree and separated by a single NUL. +# +# To enable this hook, rename this file to "query-watchman" and set +# 'git config core.fsmonitor .git/hooks/query-watchman' +# +my ($version, $time) = @ARGV; + +# Check the hook interface version + +if ($version == 1) { + # convert nanoseconds to seconds + $time = int $time / 1000000000; +} else { + die "Unsupported query-fsmonitor hook version '$version'.\n" . + "Falling back to scanning...\n"; +} + +my $git_work_tree; +if ($^O =~ 'msys' || $^O =~ 'cygwin') { + $git_work_tree = Win32::GetCwd(); + $git_work_tree =~ tr/\\/\//; +} else { + require Cwd; + $git_work_tree = Cwd::cwd(); +} + +my $retry = 1; + +launch_watchman(); + +sub launch_watchman { + + my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') + or die "open2() failed: $!\n" . + "Falling back to scanning...\n"; + + # In the query expression below we're asking for names of files that + # changed since $time but were not transient (ie created after + # $time but no longer exist). + # + # To accomplish this, we're using the "since" generator to use the + # recency index to select candidate nodes and "fields" to limit the + # output to file names only. Then we're using the "expression" term to + # further constrain the results. + # + # The category of transient files that we want to ignore will have a + # creation clock (cclock) newer than $time_t value and will also not + # currently exist. + + my $query = <<" END"; + ["query", "$git_work_tree", { + "since": $time, + "fields": ["name"], + "expression": ["not", ["allof", ["since", $time, "cclock"], ["not", "exists"]]] + }] + END + + print CHLD_IN $query; + close CHLD_IN; + my $response = do {local $/; }; + + die "Watchman: command returned no output.\n" . + "Falling back to scanning...\n" if $response eq ""; + die "Watchman: command returned invalid output: $response\n" . + "Falling back to scanning...\n" unless $response =~ /^\{/; + + my $json_pkg; + eval { + require JSON::XS; + $json_pkg = "JSON::XS"; + 1; + } or do { + require JSON::PP; + $json_pkg = "JSON::PP"; + }; + + my $o = $json_pkg->new->utf8->decode($response); + + if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) { + print STDERR "Adding '$git_work_tree' to watchman's watch list.\n"; + $retry--; + qx/watchman watch "$git_work_tree"/; + die "Failed to make watchman watch '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + + # Watchman will always return all files on the first query so + # return the fast "everything is dirty" flag to git and do the + # Watchman query just to get it over with now so we won't pay + # the cost in git to look up each individual file. + print "/\0"; + eval { launch_watchman() }; + exit 0; + } + + die "Watchman: $o->{error}.\n" . + "Falling back to scanning...\n" if $o->{error}; + + binmode STDOUT, ":utf8"; + local $, = "\0"; + print @{$o->{files}}; +} diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/post-update.sample b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/post-update.sample new file mode 100755 index 0000000..ec17ec1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/pre-applypatch.sample b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/pre-applypatch.sample new file mode 100755 index 0000000..4142082 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/pre-commit.sample b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/pre-commit.sample new file mode 100755 index 0000000..6a75641 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/pre-push.sample b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/pre-push.sample new file mode 100755 index 0000000..6187dbf --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo >&2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/pre-rebase.sample b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/pre-rebase.sample new file mode 100755 index 0000000..6cbef5c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up to date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/pre-receive.sample b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/pre-receive.sample new file mode 100755 index 0000000..a1fd29e --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/pre-receive.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to make use of push options. +# The example simply echoes all push options that start with 'echoback=' +# and rejects all pushes when the "reject" push option is used. +# +# To enable this hook, rename this file to "pre-receive". + +if test -n "$GIT_PUSH_OPTION_COUNT" +then + i=0 + while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" + do + eval "value=\$GIT_PUSH_OPTION_$i" + case "$value" in + echoback=*) + echo "echo from the pre-receive-hook: ${value#*=}" >&2 + ;; + reject) + exit 1 + esac + i=$((i + 1)) + done +fi diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/prepare-commit-msg.sample b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/prepare-commit-msg.sample new file mode 100755 index 0000000..10fa14c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/prepare-commit-msg.sample @@ -0,0 +1,42 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first one removes the +# "# Please enter the commit message..." help message. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 + +/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" + +# case "$COMMIT_SOURCE,$SHA1" in +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; +# *) ;; +# esac + +# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" +# if test -z "$COMMIT_SOURCE" +# then +# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" +# fi diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/update.sample b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/update.sample new file mode 100755 index 0000000..80ba941 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to block unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/index b/.zprezto/.git_backup/modules/modules/autosuggestions/external/index new file mode 100644 index 0000000..c7860a1 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/autosuggestions/external/index differ diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/info/exclude b/.zprezto/.git_backup/modules/modules/autosuggestions/external/info/exclude new file mode 100644 index 0000000..a5196d1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/logs/HEAD b/.zprezto/.git_backup/modules/modules/autosuggestions/external/logs/HEAD new file mode 100644 index 0000000..3d74b07 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 ebaf409002be498a681267a75f5efcaf45cd0ccc Andrey Anurin 1534073685 +0300 clone: from https://github.com/zsh-users/zsh-autosuggestions.git +ebaf409002be498a681267a75f5efcaf45cd0ccc d7c796719e6352666f7a9c94da9ddaed10f3217d Andrey Anurin 1534073716 +0300 checkout: moving from master to d7c796719e6352666f7a9c94da9ddaed10f3217d diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/logs/refs/heads/master b/.zprezto/.git_backup/modules/modules/autosuggestions/external/logs/refs/heads/master new file mode 100644 index 0000000..78e9416 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 ebaf409002be498a681267a75f5efcaf45cd0ccc Andrey Anurin 1534073685 +0300 clone: from https://github.com/zsh-users/zsh-autosuggestions.git diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/logs/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/autosuggestions/external/logs/refs/remotes/origin/HEAD new file mode 100644 index 0000000..78e9416 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 ebaf409002be498a681267a75f5efcaf45cd0ccc Andrey Anurin 1534073685 +0300 clone: from https://github.com/zsh-users/zsh-autosuggestions.git diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/objects/pack/pack-7a0ff375357d686cfeda163c121233156ad6df37.idx b/.zprezto/.git_backup/modules/modules/autosuggestions/external/objects/pack/pack-7a0ff375357d686cfeda163c121233156ad6df37.idx new file mode 100644 index 0000000..9419bf0 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/autosuggestions/external/objects/pack/pack-7a0ff375357d686cfeda163c121233156ad6df37.idx differ diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/objects/pack/pack-7a0ff375357d686cfeda163c121233156ad6df37.pack b/.zprezto/.git_backup/modules/modules/autosuggestions/external/objects/pack/pack-7a0ff375357d686cfeda163c121233156ad6df37.pack new file mode 100644 index 0000000..279c1a7 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/autosuggestions/external/objects/pack/pack-7a0ff375357d686cfeda163c121233156ad6df37.pack differ diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/packed-refs b/.zprezto/.git_backup/modules/modules/autosuggestions/external/packed-refs new file mode 100644 index 0000000..696fd23 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/packed-refs @@ -0,0 +1,37 @@ +# pack-refs with: peeled fully-peeled sorted +fa5d9c0ff5fb202545e12c98dae086d91d70ba50 refs/remotes/origin/develop +1ec43c7291db3327391360e466907329b36c6770 refs/remotes/origin/features/completion-suggestions +9fb96753069b919deaaacb6f659be2339dfeb4d2 refs/remotes/origin/fixes/slow_bracketed_paste_magic +df0f27b3a1404ba7e4210d6038c48194faf992e5 refs/remotes/origin/fixes/vi-delete +ebaf409002be498a681267a75f5efcaf45cd0ccc refs/remotes/origin/master +20c0ea841bafa78d8fb75c767e780248bfdf11a4 refs/remotes/origin/no-server +5f13490bae58bc42045b2a19fc3e446df75417a5 refs/tags/0.0.1 +7dc9e0f92631d03d289bdcf67530c84e72b18aa3 refs/tags/pre-v0.1.0 +6a4b2b386534461d479155c7f9503b1063800398 refs/tags/v0.1.0 +f154d25fb3b734235bff7d508d885e7db851c4ca refs/tags/v0.1.1 +0ae590729428a0b6aea682a04d74404a124cb909 refs/tags/v0.2.0 +31452887d20069d882e31eafaf46890e6500b4af refs/tags/v0.2.1 +2b449a62f8b6fc69e44db3eaf46c5c36c1853bfa refs/tags/v0.2.10 +ba029e83d0aa2d859d7ac46299462fa5b5a43a68 refs/tags/v0.2.11 +aa859a282dddf97cadce45255fad95930fc3f503 refs/tags/v0.2.12 +2a5791710a9038ad21b9f528e6923f33fe3b8edd refs/tags/v0.2.13 +9d100f4f321000b80b73638a6406e8486c35ce16 refs/tags/v0.2.14 +c761dc81509b137748190d254e8beb6845dedf21 refs/tags/v0.2.15 +0a42f872b84ecdd17b2d4d4e4422f3af8bf8959b refs/tags/v0.2.16 +f0a745576ff69fa608421ee7214d4cd77b43e62f refs/tags/v0.2.17 +011f5420fcc61d1c8fdd7510c4b560b0ca7f6412 refs/tags/v0.2.2 +266437c98a7e3d9b24fa82e6a35d8dc54946f1d2 refs/tags/v0.2.3 +cd71081303287498f940e6158cfce13583d4293f refs/tags/v0.2.4 +76f415bf4360705a819c92787b188ddd813d374c refs/tags/v0.2.5 +3ce1adb55dfb558c7f9b60056356fdb7d3567403 refs/tags/v0.2.6 +45ab49d1f2024f9422ab9eb41178e4d9edf2e91c refs/tags/v0.2.7 +dd9a8789a758966eed6943adad5338b2213df4a2 refs/tags/v0.2.8 +0faa2b6584928a17fef8904e8439d1268729f37a refs/tags/v0.2.9 +1ed9155f89956310eb0cfce59f95e6f3e2ecbcd2 refs/tags/v0.3.0 +87facd9b85630f288433aa0a20a963cffc612ee5 refs/tags/v0.3.1 +cce68de46d37697f561a23c51db629ee2bbd18db refs/tags/v0.3.2 +9cfaf5d3424ceb5fedd2c7e3253f823faae74383 refs/tags/v0.3.3 +2cb6eb6e29852e64a146b0284275ecdc0661b082 refs/tags/v0.4.0 +9f9237ab8a530eeff389161202bbc7283ad6af3e refs/tags/v0.4.1 +15931f04ffac91a2f9a1a044b6b3ee4050751064 refs/tags/v0.4.2 +d7c796719e6352666f7a9c94da9ddaed10f3217d refs/tags/v0.4.3 diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/refs/heads/master b/.zprezto/.git_backup/modules/modules/autosuggestions/external/refs/heads/master new file mode 100644 index 0000000..8a4db70 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/refs/heads/master @@ -0,0 +1 @@ +ebaf409002be498a681267a75f5efcaf45cd0ccc diff --git a/.zprezto/.git_backup/modules/modules/autosuggestions/external/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/autosuggestions/external/refs/remotes/origin/HEAD new file mode 100644 index 0000000..6efe28f --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/autosuggestions/external/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/.zprezto/.git_backup/modules/modules/completion/external/HEAD b/.zprezto/.git_backup/modules/modules/completion/external/HEAD new file mode 100644 index 0000000..23ff048 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/HEAD @@ -0,0 +1 @@ +7ec52769d3a0dd505d33d857511866d2b90d0eec diff --git a/.zprezto/.git_backup/modules/modules/completion/external/config b/.zprezto/.git_backup/modules/modules/completion/external/config new file mode 100644 index 0000000..7b2eb71 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/config @@ -0,0 +1,14 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true + worktree = ../../../../../modules/completion/external +[remote "origin"] + url = https://github.com/zsh-users/zsh-completions.git + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/.zprezto/.git_backup/modules/modules/completion/external/description b/.zprezto/.git_backup/modules/modules/completion/external/description new file mode 100644 index 0000000..498b267 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/.zprezto/.git_backup/modules/modules/completion/external/hooks/applypatch-msg.sample b/.zprezto/.git_backup/modules/modules/completion/external/hooks/applypatch-msg.sample new file mode 100755 index 0000000..a5d7b84 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/completion/external/hooks/commit-msg.sample b/.zprezto/.git_backup/modules/modules/completion/external/hooks/commit-msg.sample new file mode 100755 index 0000000..b58d118 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/.zprezto/.git_backup/modules/modules/completion/external/hooks/fsmonitor-watchman.sample b/.zprezto/.git_backup/modules/modules/completion/external/hooks/fsmonitor-watchman.sample new file mode 100755 index 0000000..e673bb3 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/hooks/fsmonitor-watchman.sample @@ -0,0 +1,114 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use IPC::Open2; + +# An example hook script to integrate Watchman +# (https://facebook.github.io/watchman/) with git to speed up detecting +# new and modified files. +# +# The hook is passed a version (currently 1) and a time in nanoseconds +# formatted as a string and outputs to stdout all files that have been +# modified since the given time. Paths must be relative to the root of +# the working tree and separated by a single NUL. +# +# To enable this hook, rename this file to "query-watchman" and set +# 'git config core.fsmonitor .git/hooks/query-watchman' +# +my ($version, $time) = @ARGV; + +# Check the hook interface version + +if ($version == 1) { + # convert nanoseconds to seconds + $time = int $time / 1000000000; +} else { + die "Unsupported query-fsmonitor hook version '$version'.\n" . + "Falling back to scanning...\n"; +} + +my $git_work_tree; +if ($^O =~ 'msys' || $^O =~ 'cygwin') { + $git_work_tree = Win32::GetCwd(); + $git_work_tree =~ tr/\\/\//; +} else { + require Cwd; + $git_work_tree = Cwd::cwd(); +} + +my $retry = 1; + +launch_watchman(); + +sub launch_watchman { + + my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') + or die "open2() failed: $!\n" . + "Falling back to scanning...\n"; + + # In the query expression below we're asking for names of files that + # changed since $time but were not transient (ie created after + # $time but no longer exist). + # + # To accomplish this, we're using the "since" generator to use the + # recency index to select candidate nodes and "fields" to limit the + # output to file names only. Then we're using the "expression" term to + # further constrain the results. + # + # The category of transient files that we want to ignore will have a + # creation clock (cclock) newer than $time_t value and will also not + # currently exist. + + my $query = <<" END"; + ["query", "$git_work_tree", { + "since": $time, + "fields": ["name"], + "expression": ["not", ["allof", ["since", $time, "cclock"], ["not", "exists"]]] + }] + END + + print CHLD_IN $query; + close CHLD_IN; + my $response = do {local $/; }; + + die "Watchman: command returned no output.\n" . + "Falling back to scanning...\n" if $response eq ""; + die "Watchman: command returned invalid output: $response\n" . + "Falling back to scanning...\n" unless $response =~ /^\{/; + + my $json_pkg; + eval { + require JSON::XS; + $json_pkg = "JSON::XS"; + 1; + } or do { + require JSON::PP; + $json_pkg = "JSON::PP"; + }; + + my $o = $json_pkg->new->utf8->decode($response); + + if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) { + print STDERR "Adding '$git_work_tree' to watchman's watch list.\n"; + $retry--; + qx/watchman watch "$git_work_tree"/; + die "Failed to make watchman watch '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + + # Watchman will always return all files on the first query so + # return the fast "everything is dirty" flag to git and do the + # Watchman query just to get it over with now so we won't pay + # the cost in git to look up each individual file. + print "/\0"; + eval { launch_watchman() }; + exit 0; + } + + die "Watchman: $o->{error}.\n" . + "Falling back to scanning...\n" if $o->{error}; + + binmode STDOUT, ":utf8"; + local $, = "\0"; + print @{$o->{files}}; +} diff --git a/.zprezto/.git_backup/modules/modules/completion/external/hooks/post-update.sample b/.zprezto/.git_backup/modules/modules/completion/external/hooks/post-update.sample new file mode 100755 index 0000000..ec17ec1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/.zprezto/.git_backup/modules/modules/completion/external/hooks/pre-applypatch.sample b/.zprezto/.git_backup/modules/modules/completion/external/hooks/pre-applypatch.sample new file mode 100755 index 0000000..4142082 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/completion/external/hooks/pre-commit.sample b/.zprezto/.git_backup/modules/modules/completion/external/hooks/pre-commit.sample new file mode 100755 index 0000000..6a75641 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/.zprezto/.git_backup/modules/modules/completion/external/hooks/pre-push.sample b/.zprezto/.git_backup/modules/modules/completion/external/hooks/pre-push.sample new file mode 100755 index 0000000..6187dbf --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo >&2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/completion/external/hooks/pre-rebase.sample b/.zprezto/.git_backup/modules/modules/completion/external/hooks/pre-rebase.sample new file mode 100755 index 0000000..6cbef5c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up to date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/.zprezto/.git_backup/modules/modules/completion/external/hooks/pre-receive.sample b/.zprezto/.git_backup/modules/modules/completion/external/hooks/pre-receive.sample new file mode 100755 index 0000000..a1fd29e --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/hooks/pre-receive.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to make use of push options. +# The example simply echoes all push options that start with 'echoback=' +# and rejects all pushes when the "reject" push option is used. +# +# To enable this hook, rename this file to "pre-receive". + +if test -n "$GIT_PUSH_OPTION_COUNT" +then + i=0 + while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" + do + eval "value=\$GIT_PUSH_OPTION_$i" + case "$value" in + echoback=*) + echo "echo from the pre-receive-hook: ${value#*=}" >&2 + ;; + reject) + exit 1 + esac + i=$((i + 1)) + done +fi diff --git a/.zprezto/.git_backup/modules/modules/completion/external/hooks/prepare-commit-msg.sample b/.zprezto/.git_backup/modules/modules/completion/external/hooks/prepare-commit-msg.sample new file mode 100755 index 0000000..10fa14c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/hooks/prepare-commit-msg.sample @@ -0,0 +1,42 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first one removes the +# "# Please enter the commit message..." help message. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 + +/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" + +# case "$COMMIT_SOURCE,$SHA1" in +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; +# *) ;; +# esac + +# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" +# if test -z "$COMMIT_SOURCE" +# then +# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" +# fi diff --git a/.zprezto/.git_backup/modules/modules/completion/external/hooks/update.sample b/.zprezto/.git_backup/modules/modules/completion/external/hooks/update.sample new file mode 100755 index 0000000..80ba941 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to block unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/completion/external/index b/.zprezto/.git_backup/modules/modules/completion/external/index new file mode 100644 index 0000000..3b52aaf Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/completion/external/index differ diff --git a/.zprezto/.git_backup/modules/modules/completion/external/info/exclude b/.zprezto/.git_backup/modules/modules/completion/external/info/exclude new file mode 100644 index 0000000..a5196d1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/.zprezto/.git_backup/modules/modules/completion/external/logs/HEAD b/.zprezto/.git_backup/modules/modules/completion/external/logs/HEAD new file mode 100644 index 0000000..93d310d --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 df7e44c685c9a60d83a3760aa373d3864779aeeb Andrey Anurin 1534073689 +0300 clone: from https://github.com/zsh-users/zsh-completions.git +df7e44c685c9a60d83a3760aa373d3864779aeeb 7ec52769d3a0dd505d33d857511866d2b90d0eec Andrey Anurin 1534073716 +0300 checkout: moving from master to 7ec52769d3a0dd505d33d857511866d2b90d0eec diff --git a/.zprezto/.git_backup/modules/modules/completion/external/logs/refs/heads/master b/.zprezto/.git_backup/modules/modules/completion/external/logs/refs/heads/master new file mode 100644 index 0000000..1c98e95 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 df7e44c685c9a60d83a3760aa373d3864779aeeb Andrey Anurin 1534073689 +0300 clone: from https://github.com/zsh-users/zsh-completions.git diff --git a/.zprezto/.git_backup/modules/modules/completion/external/logs/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/completion/external/logs/refs/remotes/origin/HEAD new file mode 100644 index 0000000..1c98e95 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 df7e44c685c9a60d83a3760aa373d3864779aeeb Andrey Anurin 1534073689 +0300 clone: from https://github.com/zsh-users/zsh-completions.git diff --git a/.zprezto/.git_backup/modules/modules/completion/external/objects/pack/pack-6648c890311d15584dcd3ef92937ef6caaef8774.idx b/.zprezto/.git_backup/modules/modules/completion/external/objects/pack/pack-6648c890311d15584dcd3ef92937ef6caaef8774.idx new file mode 100644 index 0000000..45960fa Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/completion/external/objects/pack/pack-6648c890311d15584dcd3ef92937ef6caaef8774.idx differ diff --git a/.zprezto/.git_backup/modules/modules/completion/external/objects/pack/pack-6648c890311d15584dcd3ef92937ef6caaef8774.pack b/.zprezto/.git_backup/modules/modules/completion/external/objects/pack/pack-6648c890311d15584dcd3ef92937ef6caaef8774.pack new file mode 100644 index 0000000..a08d0a5 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/completion/external/objects/pack/pack-6648c890311d15584dcd3ef92937ef6caaef8774.pack differ diff --git a/.zprezto/.git_backup/modules/modules/completion/external/packed-refs b/.zprezto/.git_backup/modules/modules/completion/external/packed-refs new file mode 100644 index 0000000..643993a --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/packed-refs @@ -0,0 +1,34 @@ +# pack-refs with: peeled fully-peeled sorted +df7e44c685c9a60d83a3760aa373d3864779aeeb refs/remotes/origin/master +1f8a0c9d92efb2da0c476e395d5ed5050f06399b refs/tags/0.1.0 +662229f6f0ce391ef7c1a41c398e28a31e847182 refs/tags/0.10.0 +c75296de9cafeb360066065acbf2935964d70431 refs/tags/0.11.0 +5e3151d03a91954102e8a4d661d65f9604aabbfa refs/tags/0.12.0 +0e525e909316fb8e0f2a7bbb05d7bfc6fddbcfd1 refs/tags/0.13.0 +173ae7249a6ab4a5b70bebb283f3f156eb79f908 refs/tags/0.14.0 +6953a4f892df1095e48d43751ccaf9e3ece02190 refs/tags/0.15.0 +3a2bb8781d32d05d1bf05deeeb476beb651e8272 refs/tags/0.16.0 +2082c7573fc1cd393ea0b2948aff6f0bdf3798cd refs/tags/0.17.0 +17743e1e174830693026d3adbba265922440f48c refs/tags/0.18.0 +4195d4f6ee8f68f231766fa33285d8cfce9c1164 refs/tags/0.19.0 +649c6cea337b71bd85f7b7a223bc21f810239775 refs/tags/0.2.0 +9e443566686ee574b9d66e445d73fd74c3e88c5d refs/tags/0.2.1 +0713143ec8ffc55da4c9f81e475cd5e21f2771f4 refs/tags/0.20.0 +2d1f793d9473d1b572fe43136422a3dcc9851765 refs/tags/0.21.0 +7a24a5e561a086c430ed4774cc194b3c91b3b31c refs/tags/0.22.0 +72af5d08f1c07507d74103af039e98a2791fccb5 refs/tags/0.23.0 +fa1c72058439015e74b914325f43cfca94866f1f refs/tags/0.24.0 +89dcaeb5624eeceabf41cfc00e79cce35cfd722b refs/tags/0.25.0 +2a30b05a5cf724a2d1c4c140c302dbf93f6aa6f6 refs/tags/0.26.0 +7ec52769d3a0dd505d33d857511866d2b90d0eec refs/tags/0.27.0 +acf27d00448ef62ae6901b59afc5718c829c337e refs/tags/0.3.0 +^62436acb8acbc3db4993142e84b4e851ab744213 +b5d080b9eefa456c7cd1ab1d61f4350fe1b23cd0 refs/tags/0.4.0 +f6108b8c4250565611a08b164cfdc85e6c76ee88 refs/tags/0.5.0 +3497b4841cb961e7db04e2a3bfe69b2dbec66427 refs/tags/0.5.1 +d54358a43ccec2323d012192aa213a189d877156 refs/tags/0.5.2 +f09394f71c27c76788785d851ab093ded1593705 refs/tags/0.6.0 +b0e171924ee20e38e2ecc2dc0f3ec7edf700f2c9 refs/tags/0.6.1 +9cca892132219e89299750d501d4693a98f5f5ee refs/tags/0.7.0 +13715a7e50f67458b2eb2d9b4125810c3102ad94 refs/tags/0.8.0 +53dd086f56f4d947be3a4b97c57f6c1f8a61900d refs/tags/0.9.0 diff --git a/.zprezto/.git_backup/modules/modules/completion/external/refs/heads/master b/.zprezto/.git_backup/modules/modules/completion/external/refs/heads/master new file mode 100644 index 0000000..37e0eaa --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/refs/heads/master @@ -0,0 +1 @@ +df7e44c685c9a60d83a3760aa373d3864779aeeb diff --git a/.zprezto/.git_backup/modules/modules/completion/external/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/completion/external/refs/remotes/origin/HEAD new file mode 100644 index 0000000..6efe28f --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/completion/external/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/HEAD b/.zprezto/.git_backup/modules/modules/fasd/external/HEAD new file mode 100644 index 0000000..cf6b018 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/HEAD @@ -0,0 +1 @@ +90b531a5daaa545c74c7d98974b54cbdb92659fc diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/config b/.zprezto/.git_backup/modules/modules/fasd/external/config new file mode 100644 index 0000000..79574d5 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/config @@ -0,0 +1,14 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true + worktree = ../../../../../modules/fasd/external +[remote "origin"] + url = https://github.com/clvv/fasd.git + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/description b/.zprezto/.git_backup/modules/modules/fasd/external/description new file mode 100644 index 0000000..498b267 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/hooks/applypatch-msg.sample b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/applypatch-msg.sample new file mode 100755 index 0000000..a5d7b84 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/hooks/commit-msg.sample b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/commit-msg.sample new file mode 100755 index 0000000..b58d118 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/hooks/fsmonitor-watchman.sample b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/fsmonitor-watchman.sample new file mode 100755 index 0000000..e673bb3 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/fsmonitor-watchman.sample @@ -0,0 +1,114 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use IPC::Open2; + +# An example hook script to integrate Watchman +# (https://facebook.github.io/watchman/) with git to speed up detecting +# new and modified files. +# +# The hook is passed a version (currently 1) and a time in nanoseconds +# formatted as a string and outputs to stdout all files that have been +# modified since the given time. Paths must be relative to the root of +# the working tree and separated by a single NUL. +# +# To enable this hook, rename this file to "query-watchman" and set +# 'git config core.fsmonitor .git/hooks/query-watchman' +# +my ($version, $time) = @ARGV; + +# Check the hook interface version + +if ($version == 1) { + # convert nanoseconds to seconds + $time = int $time / 1000000000; +} else { + die "Unsupported query-fsmonitor hook version '$version'.\n" . + "Falling back to scanning...\n"; +} + +my $git_work_tree; +if ($^O =~ 'msys' || $^O =~ 'cygwin') { + $git_work_tree = Win32::GetCwd(); + $git_work_tree =~ tr/\\/\//; +} else { + require Cwd; + $git_work_tree = Cwd::cwd(); +} + +my $retry = 1; + +launch_watchman(); + +sub launch_watchman { + + my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') + or die "open2() failed: $!\n" . + "Falling back to scanning...\n"; + + # In the query expression below we're asking for names of files that + # changed since $time but were not transient (ie created after + # $time but no longer exist). + # + # To accomplish this, we're using the "since" generator to use the + # recency index to select candidate nodes and "fields" to limit the + # output to file names only. Then we're using the "expression" term to + # further constrain the results. + # + # The category of transient files that we want to ignore will have a + # creation clock (cclock) newer than $time_t value and will also not + # currently exist. + + my $query = <<" END"; + ["query", "$git_work_tree", { + "since": $time, + "fields": ["name"], + "expression": ["not", ["allof", ["since", $time, "cclock"], ["not", "exists"]]] + }] + END + + print CHLD_IN $query; + close CHLD_IN; + my $response = do {local $/; }; + + die "Watchman: command returned no output.\n" . + "Falling back to scanning...\n" if $response eq ""; + die "Watchman: command returned invalid output: $response\n" . + "Falling back to scanning...\n" unless $response =~ /^\{/; + + my $json_pkg; + eval { + require JSON::XS; + $json_pkg = "JSON::XS"; + 1; + } or do { + require JSON::PP; + $json_pkg = "JSON::PP"; + }; + + my $o = $json_pkg->new->utf8->decode($response); + + if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) { + print STDERR "Adding '$git_work_tree' to watchman's watch list.\n"; + $retry--; + qx/watchman watch "$git_work_tree"/; + die "Failed to make watchman watch '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + + # Watchman will always return all files on the first query so + # return the fast "everything is dirty" flag to git and do the + # Watchman query just to get it over with now so we won't pay + # the cost in git to look up each individual file. + print "/\0"; + eval { launch_watchman() }; + exit 0; + } + + die "Watchman: $o->{error}.\n" . + "Falling back to scanning...\n" if $o->{error}; + + binmode STDOUT, ":utf8"; + local $, = "\0"; + print @{$o->{files}}; +} diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/hooks/post-update.sample b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/post-update.sample new file mode 100755 index 0000000..ec17ec1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/hooks/pre-applypatch.sample b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/pre-applypatch.sample new file mode 100755 index 0000000..4142082 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/hooks/pre-commit.sample b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/pre-commit.sample new file mode 100755 index 0000000..6a75641 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/hooks/pre-push.sample b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/pre-push.sample new file mode 100755 index 0000000..6187dbf --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo >&2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/hooks/pre-rebase.sample b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/pre-rebase.sample new file mode 100755 index 0000000..6cbef5c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up to date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/hooks/pre-receive.sample b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/pre-receive.sample new file mode 100755 index 0000000..a1fd29e --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/pre-receive.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to make use of push options. +# The example simply echoes all push options that start with 'echoback=' +# and rejects all pushes when the "reject" push option is used. +# +# To enable this hook, rename this file to "pre-receive". + +if test -n "$GIT_PUSH_OPTION_COUNT" +then + i=0 + while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" + do + eval "value=\$GIT_PUSH_OPTION_$i" + case "$value" in + echoback=*) + echo "echo from the pre-receive-hook: ${value#*=}" >&2 + ;; + reject) + exit 1 + esac + i=$((i + 1)) + done +fi diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/hooks/prepare-commit-msg.sample b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/prepare-commit-msg.sample new file mode 100755 index 0000000..10fa14c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/prepare-commit-msg.sample @@ -0,0 +1,42 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first one removes the +# "# Please enter the commit message..." help message. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 + +/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" + +# case "$COMMIT_SOURCE,$SHA1" in +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; +# *) ;; +# esac + +# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" +# if test -z "$COMMIT_SOURCE" +# then +# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" +# fi diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/hooks/update.sample b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/update.sample new file mode 100755 index 0000000..80ba941 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to block unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/index b/.zprezto/.git_backup/modules/modules/fasd/external/index new file mode 100644 index 0000000..1aea1a7 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/fasd/external/index differ diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/info/exclude b/.zprezto/.git_backup/modules/modules/fasd/external/info/exclude new file mode 100644 index 0000000..a5196d1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/logs/HEAD b/.zprezto/.git_backup/modules/modules/fasd/external/logs/HEAD new file mode 100644 index 0000000..60bddb1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 90b531a5daaa545c74c7d98974b54cbdb92659fc Andrey Anurin 1534073691 +0300 clone: from https://github.com/clvv/fasd.git +90b531a5daaa545c74c7d98974b54cbdb92659fc 90b531a5daaa545c74c7d98974b54cbdb92659fc Andrey Anurin 1534073716 +0300 checkout: moving from master to 90b531a5daaa545c74c7d98974b54cbdb92659fc diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/logs/refs/heads/master b/.zprezto/.git_backup/modules/modules/fasd/external/logs/refs/heads/master new file mode 100644 index 0000000..05755d4 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 90b531a5daaa545c74c7d98974b54cbdb92659fc Andrey Anurin 1534073691 +0300 clone: from https://github.com/clvv/fasd.git diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/logs/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/fasd/external/logs/refs/remotes/origin/HEAD new file mode 100644 index 0000000..05755d4 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 90b531a5daaa545c74c7d98974b54cbdb92659fc Andrey Anurin 1534073691 +0300 clone: from https://github.com/clvv/fasd.git diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/objects/pack/pack-45716ea69b41320c4dcd15c9d5bdfb167b23e3b2.idx b/.zprezto/.git_backup/modules/modules/fasd/external/objects/pack/pack-45716ea69b41320c4dcd15c9d5bdfb167b23e3b2.idx new file mode 100644 index 0000000..a695d72 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/fasd/external/objects/pack/pack-45716ea69b41320c4dcd15c9d5bdfb167b23e3b2.idx differ diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/objects/pack/pack-45716ea69b41320c4dcd15c9d5bdfb167b23e3b2.pack b/.zprezto/.git_backup/modules/modules/fasd/external/objects/pack/pack-45716ea69b41320c4dcd15c9d5bdfb167b23e3b2.pack new file mode 100644 index 0000000..be57614 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/fasd/external/objects/pack/pack-45716ea69b41320c4dcd15c9d5bdfb167b23e3b2.pack differ diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/packed-refs b/.zprezto/.git_backup/modules/modules/fasd/external/packed-refs new file mode 100644 index 0000000..f1462c0 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/packed-refs @@ -0,0 +1,41 @@ +# pack-refs with: peeled fully-peeled sorted +7bbf15b2a87d585b3fa255d1563a4b2b5ee5fabf refs/remotes/origin/asdf +c4109fb5fe928f2f97fc99fb506960ff7f664015 refs/remotes/origin/getopt +d1e22cedbe707ec97c8df4d0da5182e3a204588a refs/remotes/origin/gh-11 +ab9325ec45b034b31bbff2efc4b8052886f27219 refs/remotes/origin/issue-15 +d0db8ce2044c31efee4f1c081086fff9ef83cd56 refs/remotes/origin/issue-5 +0457dd1c38b78d60696df40301bbacdf5161c9c1 refs/remotes/origin/magic-completion +90b531a5daaa545c74c7d98974b54cbdb92659fc refs/remotes/origin/master +2669a25d363237b8cf6b34dbf8b9c7f3b782841d refs/remotes/origin/multiple-backends +1019217918e864da0361df5ba43ad6db50bb2453 refs/remotes/origin/new-alg +78a7dd7e6231b2867ca3d1163016e4a4a3710345 refs/remotes/origin/nolocal +497a10d7c5aec15c0ac882b6440e8060f856c547 refs/remotes/origin/posix +8de06a30cf08eaac04fc9b88c4abce0fa10ec1db refs/remotes/origin/sedcheck +3ea0a195c0f4acd0f5deafec4bac4dc5be9eeb1d refs/remotes/origin/zsh-comp +f197bcdd62e5ed162436d6b5a488f967ebff8897 refs/tags/0.1.0 +19ce32c0f9f4f1c1c3bc30e2872421d8dd35c0d2 refs/tags/0.1.1 +05d34dcc563b047b37badb7d481285732e6d0293 refs/tags/0.1.2 +a32312650a69f143d83b4c051d6f1c64ac2ea968 refs/tags/0.1.3 +68b9cd29ae781b5028c8e79aaefdbcbcc7648273 refs/tags/0.1.4 +15056d968f0ed20756d7c03a400c7ddc3bb3414d refs/tags/0.1.5 +30855dee12cb447703bb64d4a7ce0f51f6f1ff84 refs/tags/0.1.6 +bf8e0b6ece94f5f64ceb7e7252740c0da5188a71 refs/tags/0.3.0 +58ab442348d355c516c2828b009aa80ddfaee18d refs/tags/0.3.1 +701384ee4dc661f9899aa761c41c460ea39e8793 refs/tags/0.3.2 +bbb1ae6b7a6cdab56782a78c971bd7b2e5b7fccc refs/tags/0.3.3 +0457dd1c38b78d60696df40301bbacdf5161c9c1 refs/tags/0.3.4 +758c6caa13c10e55bb13055a30249568083f5f54 refs/tags/0.3.5 +497a10d7c5aec15c0ac882b6440e8060f856c547 refs/tags/0.3.6 +0e7661cec069449154f8189b5d840d76e35641b6 refs/tags/0.3.7 +5a7b2c306845c30527d5096d148a17a398fc3853 refs/tags/0.3.8 +9e3da8d551caf576fb4ccd6c7fbbac055d6fb79b refs/tags/0.5.0 +4cea2f197af959c41cc83e66016a8a6b1605785a refs/tags/0.5.1 +3be72702095b12c0d6a4a1db65b2611a09230f40 refs/tags/0.5.2 +2892c2bfaf5a0bc87fe5c01e94deacad43f16c0e refs/tags/0.5.3 +ade011352021d5489acb9936c32c223f26e1662e refs/tags/0.5.4 +2fd03e48b8dcec7ddb9407c2ba137d7470c7910d refs/tags/0.5.5 +c6dce481caa1a52d5a225947e9cfdef17bae2970 refs/tags/0.5.6 +0e29bb9a94cc2634210b64e5ed2373efb1096416 refs/tags/0.7.0 +0a2abd1d87724c769faf7192840e3452af286503 refs/tags/0.7.1 +5f3454ebf9104506ee40ebd5803bc7f157174afe refs/tags/1.0.0 +48220241e764fdf46b075cd7fe723468aaadde58 refs/tags/1.0.1 diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/refs/heads/master b/.zprezto/.git_backup/modules/modules/fasd/external/refs/heads/master new file mode 100644 index 0000000..cf6b018 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/refs/heads/master @@ -0,0 +1 @@ +90b531a5daaa545c74c7d98974b54cbdb92659fc diff --git a/.zprezto/.git_backup/modules/modules/fasd/external/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/fasd/external/refs/remotes/origin/HEAD new file mode 100644 index 0000000..6efe28f --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/fasd/external/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/HEAD b/.zprezto/.git_backup/modules/modules/history-substring-search/external/HEAD new file mode 100644 index 0000000..09b766d --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/HEAD @@ -0,0 +1 @@ +aae3388491c2312c4efb2e86bcb999927bb2900e diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/config b/.zprezto/.git_backup/modules/modules/history-substring-search/external/config new file mode 100644 index 0000000..a2c545a --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/config @@ -0,0 +1,14 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true + worktree = ../../../../../modules/history-substring-search/external +[remote "origin"] + url = https://github.com/zsh-users/zsh-history-substring-search.git + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/description b/.zprezto/.git_backup/modules/modules/history-substring-search/external/description new file mode 100644 index 0000000..498b267 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/applypatch-msg.sample b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/applypatch-msg.sample new file mode 100755 index 0000000..a5d7b84 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/commit-msg.sample b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/commit-msg.sample new file mode 100755 index 0000000..b58d118 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/fsmonitor-watchman.sample b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/fsmonitor-watchman.sample new file mode 100755 index 0000000..e673bb3 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/fsmonitor-watchman.sample @@ -0,0 +1,114 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use IPC::Open2; + +# An example hook script to integrate Watchman +# (https://facebook.github.io/watchman/) with git to speed up detecting +# new and modified files. +# +# The hook is passed a version (currently 1) and a time in nanoseconds +# formatted as a string and outputs to stdout all files that have been +# modified since the given time. Paths must be relative to the root of +# the working tree and separated by a single NUL. +# +# To enable this hook, rename this file to "query-watchman" and set +# 'git config core.fsmonitor .git/hooks/query-watchman' +# +my ($version, $time) = @ARGV; + +# Check the hook interface version + +if ($version == 1) { + # convert nanoseconds to seconds + $time = int $time / 1000000000; +} else { + die "Unsupported query-fsmonitor hook version '$version'.\n" . + "Falling back to scanning...\n"; +} + +my $git_work_tree; +if ($^O =~ 'msys' || $^O =~ 'cygwin') { + $git_work_tree = Win32::GetCwd(); + $git_work_tree =~ tr/\\/\//; +} else { + require Cwd; + $git_work_tree = Cwd::cwd(); +} + +my $retry = 1; + +launch_watchman(); + +sub launch_watchman { + + my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') + or die "open2() failed: $!\n" . + "Falling back to scanning...\n"; + + # In the query expression below we're asking for names of files that + # changed since $time but were not transient (ie created after + # $time but no longer exist). + # + # To accomplish this, we're using the "since" generator to use the + # recency index to select candidate nodes and "fields" to limit the + # output to file names only. Then we're using the "expression" term to + # further constrain the results. + # + # The category of transient files that we want to ignore will have a + # creation clock (cclock) newer than $time_t value and will also not + # currently exist. + + my $query = <<" END"; + ["query", "$git_work_tree", { + "since": $time, + "fields": ["name"], + "expression": ["not", ["allof", ["since", $time, "cclock"], ["not", "exists"]]] + }] + END + + print CHLD_IN $query; + close CHLD_IN; + my $response = do {local $/; }; + + die "Watchman: command returned no output.\n" . + "Falling back to scanning...\n" if $response eq ""; + die "Watchman: command returned invalid output: $response\n" . + "Falling back to scanning...\n" unless $response =~ /^\{/; + + my $json_pkg; + eval { + require JSON::XS; + $json_pkg = "JSON::XS"; + 1; + } or do { + require JSON::PP; + $json_pkg = "JSON::PP"; + }; + + my $o = $json_pkg->new->utf8->decode($response); + + if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) { + print STDERR "Adding '$git_work_tree' to watchman's watch list.\n"; + $retry--; + qx/watchman watch "$git_work_tree"/; + die "Failed to make watchman watch '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + + # Watchman will always return all files on the first query so + # return the fast "everything is dirty" flag to git and do the + # Watchman query just to get it over with now so we won't pay + # the cost in git to look up each individual file. + print "/\0"; + eval { launch_watchman() }; + exit 0; + } + + die "Watchman: $o->{error}.\n" . + "Falling back to scanning...\n" if $o->{error}; + + binmode STDOUT, ":utf8"; + local $, = "\0"; + print @{$o->{files}}; +} diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/post-update.sample b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/post-update.sample new file mode 100755 index 0000000..ec17ec1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/pre-applypatch.sample b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/pre-applypatch.sample new file mode 100755 index 0000000..4142082 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/pre-commit.sample b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/pre-commit.sample new file mode 100755 index 0000000..6a75641 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/pre-push.sample b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/pre-push.sample new file mode 100755 index 0000000..6187dbf --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo >&2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/pre-rebase.sample b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/pre-rebase.sample new file mode 100755 index 0000000..6cbef5c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up to date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/pre-receive.sample b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/pre-receive.sample new file mode 100755 index 0000000..a1fd29e --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/pre-receive.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to make use of push options. +# The example simply echoes all push options that start with 'echoback=' +# and rejects all pushes when the "reject" push option is used. +# +# To enable this hook, rename this file to "pre-receive". + +if test -n "$GIT_PUSH_OPTION_COUNT" +then + i=0 + while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" + do + eval "value=\$GIT_PUSH_OPTION_$i" + case "$value" in + echoback=*) + echo "echo from the pre-receive-hook: ${value#*=}" >&2 + ;; + reject) + exit 1 + esac + i=$((i + 1)) + done +fi diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/prepare-commit-msg.sample b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/prepare-commit-msg.sample new file mode 100755 index 0000000..10fa14c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/prepare-commit-msg.sample @@ -0,0 +1,42 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first one removes the +# "# Please enter the commit message..." help message. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 + +/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" + +# case "$COMMIT_SOURCE,$SHA1" in +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; +# *) ;; +# esac + +# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" +# if test -z "$COMMIT_SOURCE" +# then +# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" +# fi diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/update.sample b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/update.sample new file mode 100755 index 0000000..80ba941 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to block unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/index b/.zprezto/.git_backup/modules/modules/history-substring-search/external/index new file mode 100644 index 0000000..b53efd7 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/history-substring-search/external/index differ diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/info/exclude b/.zprezto/.git_backup/modules/modules/history-substring-search/external/info/exclude new file mode 100644 index 0000000..a5196d1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/logs/HEAD b/.zprezto/.git_backup/modules/modules/history-substring-search/external/logs/HEAD new file mode 100644 index 0000000..7f5b866 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 47a7d416c652a109f6e8856081abc042b50125f4 Andrey Anurin 1534073693 +0300 clone: from https://github.com/zsh-users/zsh-history-substring-search.git +47a7d416c652a109f6e8856081abc042b50125f4 aae3388491c2312c4efb2e86bcb999927bb2900e Andrey Anurin 1534073716 +0300 checkout: moving from master to aae3388491c2312c4efb2e86bcb999927bb2900e diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/logs/refs/heads/master b/.zprezto/.git_backup/modules/modules/history-substring-search/external/logs/refs/heads/master new file mode 100644 index 0000000..8360a91 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 47a7d416c652a109f6e8856081abc042b50125f4 Andrey Anurin 1534073693 +0300 clone: from https://github.com/zsh-users/zsh-history-substring-search.git diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/logs/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/history-substring-search/external/logs/refs/remotes/origin/HEAD new file mode 100644 index 0000000..8360a91 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 47a7d416c652a109f6e8856081abc042b50125f4 Andrey Anurin 1534073693 +0300 clone: from https://github.com/zsh-users/zsh-history-substring-search.git diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/objects/pack/pack-b3c7101732e06012fae83c45c7f37615dbc87b26.idx b/.zprezto/.git_backup/modules/modules/history-substring-search/external/objects/pack/pack-b3c7101732e06012fae83c45c7f37615dbc87b26.idx new file mode 100644 index 0000000..4a16bcb Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/history-substring-search/external/objects/pack/pack-b3c7101732e06012fae83c45c7f37615dbc87b26.idx differ diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/objects/pack/pack-b3c7101732e06012fae83c45c7f37615dbc87b26.pack b/.zprezto/.git_backup/modules/modules/history-substring-search/external/objects/pack/pack-b3c7101732e06012fae83c45c7f37615dbc87b26.pack new file mode 100644 index 0000000..4ba1e1b Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/history-substring-search/external/objects/pack/pack-b3c7101732e06012fae83c45c7f37615dbc87b26.pack differ diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/packed-refs b/.zprezto/.git_backup/modules/modules/history-substring-search/external/packed-refs new file mode 100644 index 0000000..94b401a --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/packed-refs @@ -0,0 +1,4 @@ +# pack-refs with: peeled fully-peeled sorted +47a7d416c652a109f6e8856081abc042b50125f4 refs/remotes/origin/master +1e7680405239a835aa403a7457cad23750f98e72 refs/tags/v1.0.0 +aae3388491c2312c4efb2e86bcb999927bb2900e refs/tags/v1.0.1 diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/refs/heads/master b/.zprezto/.git_backup/modules/modules/history-substring-search/external/refs/heads/master new file mode 100644 index 0000000..a800863 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/refs/heads/master @@ -0,0 +1 @@ +47a7d416c652a109f6e8856081abc042b50125f4 diff --git a/.zprezto/.git_backup/modules/modules/history-substring-search/external/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/history-substring-search/external/refs/remotes/origin/HEAD new file mode 100644 index 0000000..6efe28f --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/history-substring-search/external/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/HEAD new file mode 100644 index 0000000..f937b56 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/HEAD @@ -0,0 +1 @@ +3ad94b659910c775a6560c45b1524d23d8c83b09 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/config b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/config new file mode 100644 index 0000000..bd2a53f --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/config @@ -0,0 +1,14 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true + worktree = ../../../../../../modules/prompt/external/agnoster +[remote "origin"] + url = https://github.com/agnoster/agnoster-zsh-theme.git + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/description b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/description new file mode 100644 index 0000000..498b267 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/applypatch-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/applypatch-msg.sample new file mode 100755 index 0000000..a5d7b84 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/commit-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/commit-msg.sample new file mode 100755 index 0000000..b58d118 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/fsmonitor-watchman.sample b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/fsmonitor-watchman.sample new file mode 100755 index 0000000..e673bb3 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/fsmonitor-watchman.sample @@ -0,0 +1,114 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use IPC::Open2; + +# An example hook script to integrate Watchman +# (https://facebook.github.io/watchman/) with git to speed up detecting +# new and modified files. +# +# The hook is passed a version (currently 1) and a time in nanoseconds +# formatted as a string and outputs to stdout all files that have been +# modified since the given time. Paths must be relative to the root of +# the working tree and separated by a single NUL. +# +# To enable this hook, rename this file to "query-watchman" and set +# 'git config core.fsmonitor .git/hooks/query-watchman' +# +my ($version, $time) = @ARGV; + +# Check the hook interface version + +if ($version == 1) { + # convert nanoseconds to seconds + $time = int $time / 1000000000; +} else { + die "Unsupported query-fsmonitor hook version '$version'.\n" . + "Falling back to scanning...\n"; +} + +my $git_work_tree; +if ($^O =~ 'msys' || $^O =~ 'cygwin') { + $git_work_tree = Win32::GetCwd(); + $git_work_tree =~ tr/\\/\//; +} else { + require Cwd; + $git_work_tree = Cwd::cwd(); +} + +my $retry = 1; + +launch_watchman(); + +sub launch_watchman { + + my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') + or die "open2() failed: $!\n" . + "Falling back to scanning...\n"; + + # In the query expression below we're asking for names of files that + # changed since $time but were not transient (ie created after + # $time but no longer exist). + # + # To accomplish this, we're using the "since" generator to use the + # recency index to select candidate nodes and "fields" to limit the + # output to file names only. Then we're using the "expression" term to + # further constrain the results. + # + # The category of transient files that we want to ignore will have a + # creation clock (cclock) newer than $time_t value and will also not + # currently exist. + + my $query = <<" END"; + ["query", "$git_work_tree", { + "since": $time, + "fields": ["name"], + "expression": ["not", ["allof", ["since", $time, "cclock"], ["not", "exists"]]] + }] + END + + print CHLD_IN $query; + close CHLD_IN; + my $response = do {local $/; }; + + die "Watchman: command returned no output.\n" . + "Falling back to scanning...\n" if $response eq ""; + die "Watchman: command returned invalid output: $response\n" . + "Falling back to scanning...\n" unless $response =~ /^\{/; + + my $json_pkg; + eval { + require JSON::XS; + $json_pkg = "JSON::XS"; + 1; + } or do { + require JSON::PP; + $json_pkg = "JSON::PP"; + }; + + my $o = $json_pkg->new->utf8->decode($response); + + if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) { + print STDERR "Adding '$git_work_tree' to watchman's watch list.\n"; + $retry--; + qx/watchman watch "$git_work_tree"/; + die "Failed to make watchman watch '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + + # Watchman will always return all files on the first query so + # return the fast "everything is dirty" flag to git and do the + # Watchman query just to get it over with now so we won't pay + # the cost in git to look up each individual file. + print "/\0"; + eval { launch_watchman() }; + exit 0; + } + + die "Watchman: $o->{error}.\n" . + "Falling back to scanning...\n" if $o->{error}; + + binmode STDOUT, ":utf8"; + local $, = "\0"; + print @{$o->{files}}; +} diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/post-update.sample b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/post-update.sample new file mode 100755 index 0000000..ec17ec1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/pre-applypatch.sample b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/pre-applypatch.sample new file mode 100755 index 0000000..4142082 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/pre-commit.sample b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/pre-commit.sample new file mode 100755 index 0000000..6a75641 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/pre-push.sample b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/pre-push.sample new file mode 100755 index 0000000..6187dbf --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo >&2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/pre-rebase.sample b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/pre-rebase.sample new file mode 100755 index 0000000..6cbef5c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up to date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/pre-receive.sample b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/pre-receive.sample new file mode 100755 index 0000000..a1fd29e --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/pre-receive.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to make use of push options. +# The example simply echoes all push options that start with 'echoback=' +# and rejects all pushes when the "reject" push option is used. +# +# To enable this hook, rename this file to "pre-receive". + +if test -n "$GIT_PUSH_OPTION_COUNT" +then + i=0 + while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" + do + eval "value=\$GIT_PUSH_OPTION_$i" + case "$value" in + echoback=*) + echo "echo from the pre-receive-hook: ${value#*=}" >&2 + ;; + reject) + exit 1 + esac + i=$((i + 1)) + done +fi diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/prepare-commit-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/prepare-commit-msg.sample new file mode 100755 index 0000000..10fa14c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/prepare-commit-msg.sample @@ -0,0 +1,42 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first one removes the +# "# Please enter the commit message..." help message. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 + +/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" + +# case "$COMMIT_SOURCE,$SHA1" in +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; +# *) ;; +# esac + +# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" +# if test -z "$COMMIT_SOURCE" +# then +# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" +# fi diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/update.sample b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/update.sample new file mode 100755 index 0000000..80ba941 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to block unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/index b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/index new file mode 100644 index 0000000..4e1c4fa Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/index differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/info/exclude b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/info/exclude new file mode 100644 index 0000000..a5196d1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/logs/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/logs/HEAD new file mode 100644 index 0000000..486e0bf --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 3ad94b659910c775a6560c45b1524d23d8c83b09 Andrey Anurin 1534073695 +0300 clone: from https://github.com/agnoster/agnoster-zsh-theme.git +3ad94b659910c775a6560c45b1524d23d8c83b09 3ad94b659910c775a6560c45b1524d23d8c83b09 Andrey Anurin 1534073716 +0300 checkout: moving from master to 3ad94b659910c775a6560c45b1524d23d8c83b09 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/logs/refs/heads/master b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/logs/refs/heads/master new file mode 100644 index 0000000..9f9ee55 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 3ad94b659910c775a6560c45b1524d23d8c83b09 Andrey Anurin 1534073695 +0300 clone: from https://github.com/agnoster/agnoster-zsh-theme.git diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/logs/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/logs/refs/remotes/origin/HEAD new file mode 100644 index 0000000..9f9ee55 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 3ad94b659910c775a6560c45b1524d23d8c83b09 Andrey Anurin 1534073695 +0300 clone: from https://github.com/agnoster/agnoster-zsh-theme.git diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/07/6b60b49a451844c269a03f04c9573434774284 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/07/6b60b49a451844c269a03f04c9573434774284 new file mode 100644 index 0000000..7550651 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/07/6b60b49a451844c269a03f04c9573434774284 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/1a/d50fb48edd750f2d0a6e7b224adc59b2796383 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/1a/d50fb48edd750f2d0a6e7b224adc59b2796383 new file mode 100644 index 0000000..54996d1 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/1a/d50fb48edd750f2d0a6e7b224adc59b2796383 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/1d/b92fd843030079cd43585712cc3465fd098f95 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/1d/b92fd843030079cd43585712cc3465fd098f95 new file mode 100644 index 0000000..fd7aff6 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/1d/b92fd843030079cd43585712cc3465fd098f95 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/22/bb0cb709b54cfa3b17827d79238c34386b5cc2 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/22/bb0cb709b54cfa3b17827d79238c34386b5cc2 new file mode 100644 index 0000000..8bda6a2 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/22/bb0cb709b54cfa3b17827d79238c34386b5cc2 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/2e/108c5441f4c1b2339cfb76469fb7382209bdb9 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/2e/108c5441f4c1b2339cfb76469fb7382209bdb9 new file mode 100644 index 0000000..1cd9aa4 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/2e/108c5441f4c1b2339cfb76469fb7382209bdb9 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/31/4691c41c200dfb71841c2b3969c253a6e77d2f b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/31/4691c41c200dfb71841c2b3969c253a6e77d2f new file mode 100644 index 0000000..2dd7515 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/31/4691c41c200dfb71841c2b3969c253a6e77d2f differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/33/58b1fc98b0d29de1ba3066351e4b3d3b0ac027 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/33/58b1fc98b0d29de1ba3066351e4b3d3b0ac027 new file mode 100644 index 0000000..7fc83d9 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/33/58b1fc98b0d29de1ba3066351e4b3d3b0ac027 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/36/f8f55e71aa4dcd5d668a7061330d88a4a02fc4 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/36/f8f55e71aa4dcd5d668a7061330d88a4a02fc4 new file mode 100644 index 0000000..3f2337b --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/36/f8f55e71aa4dcd5d668a7061330d88a4a02fc4 @@ -0,0 +1,2 @@ +xKn0 D)x((&6[rfn۶*Lߴ@HHKX̝ +H5B.2Ri1Md2Хu:~W_I׽*~K>pZϗ{%ߘ_ &Si \ No newline at end of file diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/37/b4f00a5be9b61a79e144d659cc6b39189589a9 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/37/b4f00a5be9b61a79e144d659cc6b39189589a9 new file mode 100644 index 0000000..e8820eb --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/37/b4f00a5be9b61a79e144d659cc6b39189589a9 @@ -0,0 +1,3 @@ +xJ1ayt A +"d2KɎ烟:)q.`@9 "uT3Kc2 JL.B*X.)͑} m#&WyC_zn+[/WmJ@*v;`LAhӛUxx?@ Pׇ|",mX&]^Ð&8m!q7eWq}cM=Z\{` 桏0IdJrmac >׷S}}QTTc7 \ No newline at end of file diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/40/f851bb9204488227dcaa7fe1d7433be72ee5a1 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/40/f851bb9204488227dcaa7fe1d7433be72ee5a1 new file mode 100644 index 0000000..b090386 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/40/f851bb9204488227dcaa7fe1d7433be72ee5a1 @@ -0,0 +1 @@ +xM! @aל hu kO,w|#("PE08wNNmb4<ӑ+J8O2 +!7L(=1 `}O +荕؄J;¢aD|!ЄD @y)~ġcj,Pr*,+fGڀ%.XNXϦ(2q|Y!n oNwQopWW@Rw[qbnKnY"V|qŮ?3%bu9lf}]1힎C=dBS@jo@̦_3+i:xqXQ6%𩈠I̲f$XKLI +i}biUCv}̶%*h \ No newline at end of file diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/9d/5e1cd98c1b8c3f66dbb31eea78092d21e80223 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/9d/5e1cd98c1b8c3f66dbb31eea78092d21e80223 new file mode 100644 index 0000000..cbea9cd Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/9d/5e1cd98c1b8c3f66dbb31eea78092d21e80223 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/9e/c9c8f7d3c48e3f8c97d2e5a3b1867b21e72efc b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/9e/c9c8f7d3c48e3f8c97d2e5a3b1867b21e72efc new file mode 100644 index 0000000..1084d78 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/9e/c9c8f7d3c48e3f8c97d2e5a3b1867b21e72efc differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/a0/1d483f88b0105004f82b0e0ec100264a9a4cc1 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/a0/1d483f88b0105004f82b0e0ec100264a9a4cc1 new file mode 100644 index 0000000..57b0161 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/a0/1d483f88b0105004f82b0e0ec100264a9a4cc1 @@ -0,0 +1,3 @@ +xj1E]+Vn hf^V,T8xϻT!b%:R`(" +'5]:hP+1@~b_09,s%b/mkmnK]o3:k ?}sy +uS#:+ O \ No newline at end of file diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/a4/5667e4dbf7a849cf22bb6c94853ad9d673d080 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/a4/5667e4dbf7a849cf22bb6c94853ad9d673d080 new file mode 100644 index 0000000..602da1b Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/a4/5667e4dbf7a849cf22bb6c94853ad9d673d080 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/aa/f15a5a3d8fb438b512c74979b05a40b4aac81e b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/aa/f15a5a3d8fb438b512c74979b05a40b4aac81e new file mode 100644 index 0000000..de6505e Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/aa/f15a5a3d8fb438b512c74979b05a40b4aac81e differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/ad/04a7c45a5f8f58b996cb73bceb7548d7849d6e b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/ad/04a7c45a5f8f58b996cb73bceb7548d7849d6e new file mode 100644 index 0000000..152443d --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/ad/04a7c45a5f8f58b996cb73bceb7548d7849d6e @@ -0,0 +1,2 @@ +xJ@E]W^~BٹNuH!,{7=p9ئ&`L:1cO>8{fv.D9'|j}.E.9ؿ5QeLؖ}aM'!PIBc6bd~xi;=MZ&-1G#%(@:ksM5k}>mbֺukɡ w#Ey \ No newline at end of file diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/b6/c212c7f7898e6dc20303b2b3b5975213d2510f b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/b6/c212c7f7898e6dc20303b2b3b5975213d2510f new file mode 100644 index 0000000..af8c387 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/b6/c212c7f7898e6dc20303b2b3b5975213d2510f differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/c3/107c06c04fb42b0ca27b0a81b15854819969c6 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/c3/107c06c04fb42b0ca27b0a81b15854819969c6 new file mode 100644 index 0000000..13cc56e Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/c3/107c06c04fb42b0ca27b0a81b15854819969c6 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/d0/9b10eb70b4e0ee203260e8f56151f152311abc b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/d0/9b10eb70b4e0ee203260e8f56151f152311abc new file mode 100644 index 0000000..f52a239 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/d0/9b10eb70b4e0ee203260e8f56151f152311abc differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/d3/8db2157b0fa3419636494ab383dde949498b50 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/d3/8db2157b0fa3419636494ab383dde949498b50 new file mode 100644 index 0000000..f160ade Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/d3/8db2157b0fa3419636494ab383dde949498b50 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/de/4828056ec1f04b03dbf4940f1b61e525ec9799 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/de/4828056ec1f04b03dbf4940f1b61e525ec9799 new file mode 100644 index 0000000..ff18603 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/de/4828056ec1f04b03dbf4940f1b61e525ec9799 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/e0/dda1072741235e4f0d8f54a1d97f17b6f61f8c b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/e0/dda1072741235e4f0d8f54a1d97f17b6f61f8c new file mode 100644 index 0000000..b361b8e Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/e0/dda1072741235e4f0d8f54a1d97f17b6f61f8c differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/e2/371ecbc2aea85e4cde37cef71c148834e71766 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/e2/371ecbc2aea85e4cde37cef71c148834e71766 new file mode 100644 index 0000000..4f730e2 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/e2/371ecbc2aea85e4cde37cef71c148834e71766 @@ -0,0 +1 @@ +xMj0)f(IFSW4'<j[E@ NgkXƤ\wa&h=ŔSTwe` '"\=I.!Wt۶W.u%8?B/ymTwf4 A.ə1QVxԽqJxW \ No newline at end of file diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/e5/e0d66885db05a4fc4b963857bc19302e3ecd64 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/e5/e0d66885db05a4fc4b963857bc19302e3ecd64 new file mode 100644 index 0000000..eb9e15d Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/e5/e0d66885db05a4fc4b963857bc19302e3ecd64 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/e8/adb46f5f99339c7c62eb2a5b2583fcece8d08c b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/e8/adb46f5f99339c7c62eb2a5b2583fcece8d08c new file mode 100644 index 0000000..f8b7687 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/e8/adb46f5f99339c7c62eb2a5b2583fcece8d08c differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/e8/f0fe7ff0bfb52705b1bc42f236cc759325bd64 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/e8/f0fe7ff0bfb52705b1bc42f236cc759325bd64 new file mode 100644 index 0000000..c99e3b1 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/e8/f0fe7ff0bfb52705b1bc42f236cc759325bd64 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/ea/0f9e7ea310d3f42328479dca010247ec9908db b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/ea/0f9e7ea310d3f42328479dca010247ec9908db new file mode 100644 index 0000000..9f2deda Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/ea/0f9e7ea310d3f42328479dca010247ec9908db differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/ec/30014d9095976071287d03e819c1a5897015af b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/ec/30014d9095976071287d03e819c1a5897015af new file mode 100644 index 0000000..01a2b63 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/ec/30014d9095976071287d03e819c1a5897015af differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/ed/99c88f49137e45c4fd4d631bb0d25e3a77d9a4 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/ed/99c88f49137e45c4fd4d631bb0d25e3a77d9a4 new file mode 100644 index 0000000..d03faeb Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/ed/99c88f49137e45c4fd4d631bb0d25e3a77d9a4 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/ef/9da422ce30cdf177642e8ddd63681f40ddb8f5 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/ef/9da422ce30cdf177642e8ddd63681f40ddb8f5 new file mode 100644 index 0000000..fab2d3a Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/ef/9da422ce30cdf177642e8ddd63681f40ddb8f5 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/f2/dca9212d61c3da86a38a74fb39f240e0b1a779 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/f2/dca9212d61c3da86a38a74fb39f240e0b1a779 new file mode 100644 index 0000000..1690886 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/f2/dca9212d61c3da86a38a74fb39f240e0b1a779 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/f3/ff367cbf983856cd2579387fa962f3ff9b6c71 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/f3/ff367cbf983856cd2579387fa962f3ff9b6c71 new file mode 100644 index 0000000..49c6d12 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/f3/ff367cbf983856cd2579387fa962f3ff9b6c71 @@ -0,0 +1 @@ +xm=k0;Wt,և- BICE:Yvd)_Rtzye}ѱkdN"\Ϊ^8onV(fP̉9Ѡ20 YO4_x -rCfHHB!9Ue9 BbSyI -/Q?).[_Iժ -mUWߊ}\~|>?c͉D ѵЖ1pil(z ϛO@4q 6/0{s \ No newline at end of file diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/f4/5ade34d581e6fa88fc8fcbe6f2f3fbe3c23ddf b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/f4/5ade34d581e6fa88fc8fcbe6f2f3fbe3c23ddf new file mode 100644 index 0000000..5cb6a54 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/f4/5ade34d581e6fa88fc8fcbe6f2f3fbe3c23ddf differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/f8/ffdbfbe2c2d8cd1350eae1b68367802fe6df26 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/f8/ffdbfbe2c2d8cd1350eae1b68367802fe6df26 new file mode 100644 index 0000000..8e26f9b Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/f8/ffdbfbe2c2d8cd1350eae1b68367802fe6df26 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/f9/6ea53a6b1a1fabcc724fb17ae27aa9605ec29e b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/f9/6ea53a6b1a1fabcc724fb17ae27aa9605ec29e new file mode 100644 index 0000000..21f8e2a Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/f9/6ea53a6b1a1fabcc724fb17ae27aa9605ec29e differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/fb/f4af19197cef6465e1deedd882a1d4f5174376 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/fb/f4af19197cef6465e1deedd882a1d4f5174376 new file mode 100644 index 0000000..3a047d4 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/fb/f4af19197cef6465e1deedd882a1d4f5174376 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/fe/1b065c7f6a7c7046ff05b9cb2c3f9d50311b45 b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/fe/1b065c7f6a7c7046ff05b9cb2c3f9d50311b45 new file mode 100644 index 0000000..8b18987 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/objects/fe/1b065c7f6a7c7046ff05b9cb2c3f9d50311b45 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/packed-refs b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/packed-refs new file mode 100644 index 0000000..46e9694 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled fully-peeled sorted +3ad94b659910c775a6560c45b1524d23d8c83b09 refs/remotes/origin/master diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/refs/heads/master b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/refs/heads/master new file mode 100644 index 0000000..f937b56 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/refs/heads/master @@ -0,0 +1 @@ +3ad94b659910c775a6560c45b1524d23d8c83b09 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/refs/remotes/origin/HEAD new file mode 100644 index 0000000..6efe28f --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/agnoster/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/async/HEAD new file mode 100644 index 0000000..4c627ba --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/HEAD @@ -0,0 +1 @@ +da48ccb0e2ade777a10decfe214b5433d990d0d9 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/config b/.zprezto/.git_backup/modules/modules/prompt/external/async/config new file mode 100644 index 0000000..4bd57e4 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/config @@ -0,0 +1,14 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true + worktree = ../../../../../../modules/prompt/external/async +[remote "origin"] + url = https://github.com/mafredri/zsh-async.git + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/description b/.zprezto/.git_backup/modules/modules/prompt/external/async/description new file mode 100644 index 0000000..498b267 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/applypatch-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/applypatch-msg.sample new file mode 100755 index 0000000..a5d7b84 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/commit-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/commit-msg.sample new file mode 100755 index 0000000..b58d118 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/fsmonitor-watchman.sample b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/fsmonitor-watchman.sample new file mode 100755 index 0000000..e673bb3 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/fsmonitor-watchman.sample @@ -0,0 +1,114 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use IPC::Open2; + +# An example hook script to integrate Watchman +# (https://facebook.github.io/watchman/) with git to speed up detecting +# new and modified files. +# +# The hook is passed a version (currently 1) and a time in nanoseconds +# formatted as a string and outputs to stdout all files that have been +# modified since the given time. Paths must be relative to the root of +# the working tree and separated by a single NUL. +# +# To enable this hook, rename this file to "query-watchman" and set +# 'git config core.fsmonitor .git/hooks/query-watchman' +# +my ($version, $time) = @ARGV; + +# Check the hook interface version + +if ($version == 1) { + # convert nanoseconds to seconds + $time = int $time / 1000000000; +} else { + die "Unsupported query-fsmonitor hook version '$version'.\n" . + "Falling back to scanning...\n"; +} + +my $git_work_tree; +if ($^O =~ 'msys' || $^O =~ 'cygwin') { + $git_work_tree = Win32::GetCwd(); + $git_work_tree =~ tr/\\/\//; +} else { + require Cwd; + $git_work_tree = Cwd::cwd(); +} + +my $retry = 1; + +launch_watchman(); + +sub launch_watchman { + + my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') + or die "open2() failed: $!\n" . + "Falling back to scanning...\n"; + + # In the query expression below we're asking for names of files that + # changed since $time but were not transient (ie created after + # $time but no longer exist). + # + # To accomplish this, we're using the "since" generator to use the + # recency index to select candidate nodes and "fields" to limit the + # output to file names only. Then we're using the "expression" term to + # further constrain the results. + # + # The category of transient files that we want to ignore will have a + # creation clock (cclock) newer than $time_t value and will also not + # currently exist. + + my $query = <<" END"; + ["query", "$git_work_tree", { + "since": $time, + "fields": ["name"], + "expression": ["not", ["allof", ["since", $time, "cclock"], ["not", "exists"]]] + }] + END + + print CHLD_IN $query; + close CHLD_IN; + my $response = do {local $/; }; + + die "Watchman: command returned no output.\n" . + "Falling back to scanning...\n" if $response eq ""; + die "Watchman: command returned invalid output: $response\n" . + "Falling back to scanning...\n" unless $response =~ /^\{/; + + my $json_pkg; + eval { + require JSON::XS; + $json_pkg = "JSON::XS"; + 1; + } or do { + require JSON::PP; + $json_pkg = "JSON::PP"; + }; + + my $o = $json_pkg->new->utf8->decode($response); + + if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) { + print STDERR "Adding '$git_work_tree' to watchman's watch list.\n"; + $retry--; + qx/watchman watch "$git_work_tree"/; + die "Failed to make watchman watch '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + + # Watchman will always return all files on the first query so + # return the fast "everything is dirty" flag to git and do the + # Watchman query just to get it over with now so we won't pay + # the cost in git to look up each individual file. + print "/\0"; + eval { launch_watchman() }; + exit 0; + } + + die "Watchman: $o->{error}.\n" . + "Falling back to scanning...\n" if $o->{error}; + + binmode STDOUT, ":utf8"; + local $, = "\0"; + print @{$o->{files}}; +} diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/post-update.sample b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/post-update.sample new file mode 100755 index 0000000..ec17ec1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/pre-applypatch.sample b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/pre-applypatch.sample new file mode 100755 index 0000000..4142082 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/pre-commit.sample b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/pre-commit.sample new file mode 100755 index 0000000..6a75641 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/pre-push.sample b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/pre-push.sample new file mode 100755 index 0000000..6187dbf --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo >&2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/pre-rebase.sample b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/pre-rebase.sample new file mode 100755 index 0000000..6cbef5c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up to date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/pre-receive.sample b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/pre-receive.sample new file mode 100755 index 0000000..a1fd29e --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/pre-receive.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to make use of push options. +# The example simply echoes all push options that start with 'echoback=' +# and rejects all pushes when the "reject" push option is used. +# +# To enable this hook, rename this file to "pre-receive". + +if test -n "$GIT_PUSH_OPTION_COUNT" +then + i=0 + while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" + do + eval "value=\$GIT_PUSH_OPTION_$i" + case "$value" in + echoback=*) + echo "echo from the pre-receive-hook: ${value#*=}" >&2 + ;; + reject) + exit 1 + esac + i=$((i + 1)) + done +fi diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/prepare-commit-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/prepare-commit-msg.sample new file mode 100755 index 0000000..10fa14c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/prepare-commit-msg.sample @@ -0,0 +1,42 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first one removes the +# "# Please enter the commit message..." help message. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 + +/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" + +# case "$COMMIT_SOURCE,$SHA1" in +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; +# *) ;; +# esac + +# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" +# if test -z "$COMMIT_SOURCE" +# then +# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" +# fi diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/update.sample b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/update.sample new file mode 100755 index 0000000..80ba941 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to block unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/index b/.zprezto/.git_backup/modules/modules/prompt/external/async/index new file mode 100644 index 0000000..d3b1c86 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/async/index differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/info/exclude b/.zprezto/.git_backup/modules/modules/prompt/external/async/info/exclude new file mode 100644 index 0000000..a5196d1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/logs/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/async/logs/HEAD new file mode 100644 index 0000000..95700f4 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 da48ccb0e2ade777a10decfe214b5433d990d0d9 Andrey Anurin 1534073697 +0300 clone: from https://github.com/mafredri/zsh-async.git +da48ccb0e2ade777a10decfe214b5433d990d0d9 da48ccb0e2ade777a10decfe214b5433d990d0d9 Andrey Anurin 1534073716 +0300 checkout: moving from master to da48ccb0e2ade777a10decfe214b5433d990d0d9 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/logs/refs/heads/master b/.zprezto/.git_backup/modules/modules/prompt/external/async/logs/refs/heads/master new file mode 100644 index 0000000..c7926ad --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 da48ccb0e2ade777a10decfe214b5433d990d0d9 Andrey Anurin 1534073697 +0300 clone: from https://github.com/mafredri/zsh-async.git diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/logs/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/async/logs/refs/remotes/origin/HEAD new file mode 100644 index 0000000..c7926ad --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 da48ccb0e2ade777a10decfe214b5433d990d0d9 Andrey Anurin 1534073697 +0300 clone: from https://github.com/mafredri/zsh-async.git diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/objects/pack/pack-fe2b865356151c471672fd48750bbef8647bc801.idx b/.zprezto/.git_backup/modules/modules/prompt/external/async/objects/pack/pack-fe2b865356151c471672fd48750bbef8647bc801.idx new file mode 100644 index 0000000..553ef2c Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/async/objects/pack/pack-fe2b865356151c471672fd48750bbef8647bc801.idx differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/objects/pack/pack-fe2b865356151c471672fd48750bbef8647bc801.pack b/.zprezto/.git_backup/modules/modules/prompt/external/async/objects/pack/pack-fe2b865356151c471672fd48750bbef8647bc801.pack new file mode 100644 index 0000000..83452d2 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/async/objects/pack/pack-fe2b865356151c471672fd48750bbef8647bc801.pack differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/packed-refs b/.zprezto/.git_backup/modules/modules/prompt/external/async/packed-refs new file mode 100644 index 0000000..144501c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/packed-refs @@ -0,0 +1,27 @@ +# pack-refs with: peeled fully-peeled sorted +da48ccb0e2ade777a10decfe214b5433d990d0d9 refs/remotes/origin/master +b15ecf9cde10901c2fbdc91f65c84d7378a04b66 refs/remotes/origin/null-prefix +6f30a8fd128f5211efc673e91d05c2dfb12518e9 refs/remotes/origin/worker-eval +cf68dd99c9dcb2a5b87508abafbb8b024e817280 refs/tags/v0.2.2 +f0a74ce7ea8dede84616edfb0b034e1e66fa1a21 refs/tags/v0.2.3 +c46c1604ca020185e22f83da1ff6b0984d20f96f refs/tags/v1.0.0 +032703d9773381ee35db87601a88493c5b54d79c refs/tags/v1.1.0 +4e0e6024641afdd315f5ee941693c9d3091bd694 refs/tags/v1.2.0 +^9855030ed0017ffd32c74388e956a407994dd8d1 +6ee085fda37e09b2d0ea5cbf5d496c0c7b64b477 refs/tags/v1.3.0 +^bb7af9c05ae8265e03545b682c850ed23fca895f +3927315257f5a6c09ecaba653e32efcc0687dc07 refs/tags/v1.3.1 +^a4b2f81c966a00eeb38876d505d97423cc8addfd +55660e339d2047f16b6a5039b94dfd238b525adb refs/tags/v1.4.0 +^10d2220b2b30751ae98feef673ba9f12e4da8969 +e702ec4697ab6469b8948d599768227304d146b1 refs/tags/v1.5.0 +11a97ec35281efbd536612a56f4d57aeec3108f0 refs/tags/v1.5.1 +^d95adb7cb58ec9d45bf024951770d975e089ef1d +7677145f9275b26d98cf2260df5b068b4287dcf7 refs/tags/v1.5.2 +^371fafb5f890ed82c449a5d2f052dc27e89052da +352d85a0f01c4d7f3ed6cec8a961615f3816d012 refs/tags/v1.6.0 +^b001fa529a874fbe8bd22a9d4526153138645289 +fbfd3a617343d708b9165e391a14aefe0c60bbea refs/tags/v1.6.1 +^2fa0f6b69e3ed4a3c314d4d568148846814cdb54 +e9eb91b978aa16ad35d94cce590fe8c574b29ee8 refs/tags/v1.6.2 +^da48ccb0e2ade777a10decfe214b5433d990d0d9 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/refs/heads/master b/.zprezto/.git_backup/modules/modules/prompt/external/async/refs/heads/master new file mode 100644 index 0000000..4c627ba --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/refs/heads/master @@ -0,0 +1 @@ +da48ccb0e2ade777a10decfe214b5433d990d0d9 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/async/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/async/refs/remotes/origin/HEAD new file mode 100644 index 0000000..6efe28f --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/async/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/HEAD new file mode 100644 index 0000000..2b34553 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/HEAD @@ -0,0 +1 @@ +d031b3e03522d47607173ebda89e7558b622a322 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/config b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/config new file mode 100644 index 0000000..19ddae8 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/config @@ -0,0 +1,17 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true + worktree = ../../../../../../modules/prompt/external/powerlevel9k +[remote "origin"] + url = https://github.com/bhilburn/powerlevel9k.git + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master +[submodule "shunit2"] + active = true + url = https://github.com/kward/shunit2.git diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/description b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/description new file mode 100644 index 0000000..498b267 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/applypatch-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/applypatch-msg.sample new file mode 100755 index 0000000..a5d7b84 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/commit-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/commit-msg.sample new file mode 100755 index 0000000..b58d118 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/fsmonitor-watchman.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/fsmonitor-watchman.sample new file mode 100755 index 0000000..e673bb3 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/fsmonitor-watchman.sample @@ -0,0 +1,114 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use IPC::Open2; + +# An example hook script to integrate Watchman +# (https://facebook.github.io/watchman/) with git to speed up detecting +# new and modified files. +# +# The hook is passed a version (currently 1) and a time in nanoseconds +# formatted as a string and outputs to stdout all files that have been +# modified since the given time. Paths must be relative to the root of +# the working tree and separated by a single NUL. +# +# To enable this hook, rename this file to "query-watchman" and set +# 'git config core.fsmonitor .git/hooks/query-watchman' +# +my ($version, $time) = @ARGV; + +# Check the hook interface version + +if ($version == 1) { + # convert nanoseconds to seconds + $time = int $time / 1000000000; +} else { + die "Unsupported query-fsmonitor hook version '$version'.\n" . + "Falling back to scanning...\n"; +} + +my $git_work_tree; +if ($^O =~ 'msys' || $^O =~ 'cygwin') { + $git_work_tree = Win32::GetCwd(); + $git_work_tree =~ tr/\\/\//; +} else { + require Cwd; + $git_work_tree = Cwd::cwd(); +} + +my $retry = 1; + +launch_watchman(); + +sub launch_watchman { + + my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') + or die "open2() failed: $!\n" . + "Falling back to scanning...\n"; + + # In the query expression below we're asking for names of files that + # changed since $time but were not transient (ie created after + # $time but no longer exist). + # + # To accomplish this, we're using the "since" generator to use the + # recency index to select candidate nodes and "fields" to limit the + # output to file names only. Then we're using the "expression" term to + # further constrain the results. + # + # The category of transient files that we want to ignore will have a + # creation clock (cclock) newer than $time_t value and will also not + # currently exist. + + my $query = <<" END"; + ["query", "$git_work_tree", { + "since": $time, + "fields": ["name"], + "expression": ["not", ["allof", ["since", $time, "cclock"], ["not", "exists"]]] + }] + END + + print CHLD_IN $query; + close CHLD_IN; + my $response = do {local $/; }; + + die "Watchman: command returned no output.\n" . + "Falling back to scanning...\n" if $response eq ""; + die "Watchman: command returned invalid output: $response\n" . + "Falling back to scanning...\n" unless $response =~ /^\{/; + + my $json_pkg; + eval { + require JSON::XS; + $json_pkg = "JSON::XS"; + 1; + } or do { + require JSON::PP; + $json_pkg = "JSON::PP"; + }; + + my $o = $json_pkg->new->utf8->decode($response); + + if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) { + print STDERR "Adding '$git_work_tree' to watchman's watch list.\n"; + $retry--; + qx/watchman watch "$git_work_tree"/; + die "Failed to make watchman watch '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + + # Watchman will always return all files on the first query so + # return the fast "everything is dirty" flag to git and do the + # Watchman query just to get it over with now so we won't pay + # the cost in git to look up each individual file. + print "/\0"; + eval { launch_watchman() }; + exit 0; + } + + die "Watchman: $o->{error}.\n" . + "Falling back to scanning...\n" if $o->{error}; + + binmode STDOUT, ":utf8"; + local $, = "\0"; + print @{$o->{files}}; +} diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/post-update.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/post-update.sample new file mode 100755 index 0000000..ec17ec1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/pre-applypatch.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/pre-applypatch.sample new file mode 100755 index 0000000..4142082 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/pre-commit.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/pre-commit.sample new file mode 100755 index 0000000..6a75641 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/pre-push.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/pre-push.sample new file mode 100755 index 0000000..6187dbf --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo >&2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/pre-rebase.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/pre-rebase.sample new file mode 100755 index 0000000..6cbef5c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up to date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/pre-receive.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/pre-receive.sample new file mode 100755 index 0000000..a1fd29e --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/pre-receive.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to make use of push options. +# The example simply echoes all push options that start with 'echoback=' +# and rejects all pushes when the "reject" push option is used. +# +# To enable this hook, rename this file to "pre-receive". + +if test -n "$GIT_PUSH_OPTION_COUNT" +then + i=0 + while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" + do + eval "value=\$GIT_PUSH_OPTION_$i" + case "$value" in + echoback=*) + echo "echo from the pre-receive-hook: ${value#*=}" >&2 + ;; + reject) + exit 1 + esac + i=$((i + 1)) + done +fi diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/prepare-commit-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/prepare-commit-msg.sample new file mode 100755 index 0000000..10fa14c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/prepare-commit-msg.sample @@ -0,0 +1,42 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first one removes the +# "# Please enter the commit message..." help message. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 + +/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" + +# case "$COMMIT_SOURCE,$SHA1" in +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; +# *) ;; +# esac + +# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" +# if test -z "$COMMIT_SOURCE" +# then +# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" +# fi diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/update.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/update.sample new file mode 100755 index 0000000..80ba941 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to block unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/index b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/index new file mode 100644 index 0000000..f7f2a5f Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/index differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/info/exclude b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/info/exclude new file mode 100644 index 0000000..a5196d1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/logs/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/logs/HEAD new file mode 100644 index 0000000..98582f4 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 571a859413866897cf962396f02f65a288f677ac Andrey Anurin 1534073705 +0300 clone: from https://github.com/bhilburn/powerlevel9k.git +571a859413866897cf962396f02f65a288f677ac d031b3e03522d47607173ebda89e7558b622a322 Andrey Anurin 1534073717 +0300 checkout: moving from master to d031b3e03522d47607173ebda89e7558b622a322 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/logs/refs/heads/master b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/logs/refs/heads/master new file mode 100644 index 0000000..d71c1a2 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 571a859413866897cf962396f02f65a288f677ac Andrey Anurin 1534073705 +0300 clone: from https://github.com/bhilburn/powerlevel9k.git diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/logs/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/logs/refs/remotes/origin/HEAD new file mode 100644 index 0000000..d71c1a2 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 571a859413866897cf962396f02f65a288f677ac Andrey Anurin 1534073705 +0300 clone: from https://github.com/bhilburn/powerlevel9k.git diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/HEAD new file mode 100644 index 0000000..93faee6 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/HEAD @@ -0,0 +1 @@ +60dd60bcd1573befe38465010263ab242e55811d diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/config b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/config new file mode 100644 index 0000000..f0964be --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/config @@ -0,0 +1,14 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true + worktree = ../../../../../../../../modules/prompt/external/powerlevel9k/shunit2 +[remote "origin"] + url = https://github.com/kward/shunit2.git + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/description b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/description new file mode 100644 index 0000000..498b267 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/applypatch-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/applypatch-msg.sample new file mode 100755 index 0000000..a5d7b84 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/commit-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/commit-msg.sample new file mode 100755 index 0000000..b58d118 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/fsmonitor-watchman.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/fsmonitor-watchman.sample new file mode 100755 index 0000000..e673bb3 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/fsmonitor-watchman.sample @@ -0,0 +1,114 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use IPC::Open2; + +# An example hook script to integrate Watchman +# (https://facebook.github.io/watchman/) with git to speed up detecting +# new and modified files. +# +# The hook is passed a version (currently 1) and a time in nanoseconds +# formatted as a string and outputs to stdout all files that have been +# modified since the given time. Paths must be relative to the root of +# the working tree and separated by a single NUL. +# +# To enable this hook, rename this file to "query-watchman" and set +# 'git config core.fsmonitor .git/hooks/query-watchman' +# +my ($version, $time) = @ARGV; + +# Check the hook interface version + +if ($version == 1) { + # convert nanoseconds to seconds + $time = int $time / 1000000000; +} else { + die "Unsupported query-fsmonitor hook version '$version'.\n" . + "Falling back to scanning...\n"; +} + +my $git_work_tree; +if ($^O =~ 'msys' || $^O =~ 'cygwin') { + $git_work_tree = Win32::GetCwd(); + $git_work_tree =~ tr/\\/\//; +} else { + require Cwd; + $git_work_tree = Cwd::cwd(); +} + +my $retry = 1; + +launch_watchman(); + +sub launch_watchman { + + my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') + or die "open2() failed: $!\n" . + "Falling back to scanning...\n"; + + # In the query expression below we're asking for names of files that + # changed since $time but were not transient (ie created after + # $time but no longer exist). + # + # To accomplish this, we're using the "since" generator to use the + # recency index to select candidate nodes and "fields" to limit the + # output to file names only. Then we're using the "expression" term to + # further constrain the results. + # + # The category of transient files that we want to ignore will have a + # creation clock (cclock) newer than $time_t value and will also not + # currently exist. + + my $query = <<" END"; + ["query", "$git_work_tree", { + "since": $time, + "fields": ["name"], + "expression": ["not", ["allof", ["since", $time, "cclock"], ["not", "exists"]]] + }] + END + + print CHLD_IN $query; + close CHLD_IN; + my $response = do {local $/; }; + + die "Watchman: command returned no output.\n" . + "Falling back to scanning...\n" if $response eq ""; + die "Watchman: command returned invalid output: $response\n" . + "Falling back to scanning...\n" unless $response =~ /^\{/; + + my $json_pkg; + eval { + require JSON::XS; + $json_pkg = "JSON::XS"; + 1; + } or do { + require JSON::PP; + $json_pkg = "JSON::PP"; + }; + + my $o = $json_pkg->new->utf8->decode($response); + + if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) { + print STDERR "Adding '$git_work_tree' to watchman's watch list.\n"; + $retry--; + qx/watchman watch "$git_work_tree"/; + die "Failed to make watchman watch '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + + # Watchman will always return all files on the first query so + # return the fast "everything is dirty" flag to git and do the + # Watchman query just to get it over with now so we won't pay + # the cost in git to look up each individual file. + print "/\0"; + eval { launch_watchman() }; + exit 0; + } + + die "Watchman: $o->{error}.\n" . + "Falling back to scanning...\n" if $o->{error}; + + binmode STDOUT, ":utf8"; + local $, = "\0"; + print @{$o->{files}}; +} diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/post-update.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/post-update.sample new file mode 100755 index 0000000..ec17ec1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/pre-applypatch.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/pre-applypatch.sample new file mode 100755 index 0000000..4142082 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/pre-commit.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/pre-commit.sample new file mode 100755 index 0000000..6a75641 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/pre-push.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/pre-push.sample new file mode 100755 index 0000000..6187dbf --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo >&2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/pre-rebase.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/pre-rebase.sample new file mode 100755 index 0000000..6cbef5c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up to date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/pre-receive.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/pre-receive.sample new file mode 100755 index 0000000..a1fd29e --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/pre-receive.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to make use of push options. +# The example simply echoes all push options that start with 'echoback=' +# and rejects all pushes when the "reject" push option is used. +# +# To enable this hook, rename this file to "pre-receive". + +if test -n "$GIT_PUSH_OPTION_COUNT" +then + i=0 + while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" + do + eval "value=\$GIT_PUSH_OPTION_$i" + case "$value" in + echoback=*) + echo "echo from the pre-receive-hook: ${value#*=}" >&2 + ;; + reject) + exit 1 + esac + i=$((i + 1)) + done +fi diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/prepare-commit-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/prepare-commit-msg.sample new file mode 100755 index 0000000..10fa14c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/prepare-commit-msg.sample @@ -0,0 +1,42 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first one removes the +# "# Please enter the commit message..." help message. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 + +/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" + +# case "$COMMIT_SOURCE,$SHA1" in +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; +# *) ;; +# esac + +# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" +# if test -z "$COMMIT_SOURCE" +# then +# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" +# fi diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/update.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/update.sample new file mode 100755 index 0000000..80ba941 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to block unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/index b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/index new file mode 100644 index 0000000..55e2fba Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/index differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/info/exclude b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/info/exclude new file mode 100644 index 0000000..a5196d1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/logs/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/logs/HEAD new file mode 100644 index 0000000..c8121b0 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 07bb3292048a4982aad7247bdd7890f2bf532ece Andrey Anurin 1534073719 +0300 clone: from https://github.com/kward/shunit2.git +07bb3292048a4982aad7247bdd7890f2bf532ece 60dd60bcd1573befe38465010263ab242e55811d Andrey Anurin 1534073719 +0300 checkout: moving from master to 60dd60bcd1573befe38465010263ab242e55811d diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/logs/refs/heads/master b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/logs/refs/heads/master new file mode 100644 index 0000000..d898dbb --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 07bb3292048a4982aad7247bdd7890f2bf532ece Andrey Anurin 1534073719 +0300 clone: from https://github.com/kward/shunit2.git diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/logs/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/logs/refs/remotes/origin/HEAD new file mode 100644 index 0000000..d898dbb --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 07bb3292048a4982aad7247bdd7890f2bf532ece Andrey Anurin 1534073719 +0300 clone: from https://github.com/kward/shunit2.git diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/objects/pack/pack-c3be31a3e9ca30a2164653daea6167d39597f403.idx b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/objects/pack/pack-c3be31a3e9ca30a2164653daea6167d39597f403.idx new file mode 100644 index 0000000..7f27666 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/objects/pack/pack-c3be31a3e9ca30a2164653daea6167d39597f403.idx differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/objects/pack/pack-c3be31a3e9ca30a2164653daea6167d39597f403.pack b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/objects/pack/pack-c3be31a3e9ca30a2164653daea6167d39597f403.pack new file mode 100644 index 0000000..14de529 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/objects/pack/pack-c3be31a3e9ca30a2164653daea6167d39597f403.pack differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/packed-refs b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/packed-refs new file mode 100644 index 0000000..90832ea --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/packed-refs @@ -0,0 +1,8 @@ +# pack-refs with: peeled fully-peeled sorted +764458e5d109ce6b4fece39b9314aefb087641a6 refs/remotes/origin/2.0.x +07bb3292048a4982aad7247bdd7890f2bf532ece refs/remotes/origin/master +46973db9df87bd5fdadea74cb472a99f212a0d3a refs/tags/source +1a26843113f3be945ce4f5a04786b20ea83ae8a6 refs/tags/v2.1.6 +da2169c1789fc10b713d26dba0d7b6adfb8526a2 refs/tags/v2.1.7 +^ec73522ba7e6bca10ebfaa9cf8f2e6b276d81745 +154242e5712e73770bed3ccd141f6eda6ba9eaac refs/tags/website diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/refs/heads/master b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/refs/heads/master new file mode 100644 index 0000000..bb9bdc0 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/refs/heads/master @@ -0,0 +1 @@ +07bb3292048a4982aad7247bdd7890f2bf532ece diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/refs/remotes/origin/HEAD new file mode 100644 index 0000000..6efe28f --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/modules/shunit2/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/objects/pack/pack-35317f319af074058201a2a4083456d33bf98da4.idx b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/objects/pack/pack-35317f319af074058201a2a4083456d33bf98da4.idx new file mode 100644 index 0000000..9d253fc Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/objects/pack/pack-35317f319af074058201a2a4083456d33bf98da4.idx differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/objects/pack/pack-35317f319af074058201a2a4083456d33bf98da4.pack b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/objects/pack/pack-35317f319af074058201a2a4083456d33bf98da4.pack new file mode 100644 index 0000000..70540c9 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/objects/pack/pack-35317f319af074058201a2a4083456d33bf98da4.pack differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/packed-refs b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/packed-refs new file mode 100644 index 0000000..328b170 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/packed-refs @@ -0,0 +1,37 @@ +# pack-refs with: peeled fully-peeled sorted +18eddbe72ab2efcd374d4cb543beeaa79342dd34 refs/remotes/origin/debug-svn-icon-color +571a859413866897cf962396f02f65a288f677ac refs/remotes/origin/master +348178fd8d6f0c3005b13641eca09a0231122f55 refs/remotes/origin/master-test +286ae7c45f484086260b7017894c4d6d5c7430d0 refs/remotes/origin/merging-awesome-font-fix +67ef7892de7a5a4319c82cc878fb83998696fd0f refs/remotes/origin/nerdfont-complete +054970e8b3622d3f8f6748ce92201a46f96a71a3 refs/remotes/origin/new-adobe-scp-iconset +571a859413866897cf962396f02f65a288f677ac refs/remotes/origin/next +fd291d99f2d4ac1d5c8bc24287165aa234f3c307 refs/remotes/origin/next-staging +553c788e8382a222463a1594d6a99c62de19a737 refs/remotes/origin/onaforeignshore-code_separation +5332c30430eccd328dd737d5010911bcab2f0985 refs/remotes/origin/onaforeignshore-date +44b9ad05a3f28de5ca657dbf586db1a01aacac52 refs/remotes/origin/zsh-async-integration +1c5a349cfaf070973ab9a38f214a3b46b071b78c refs/tags/v0.1.0 +^4e2b1137d4ad3a83664b4b24bc11936d65a6a744 +d085b80c9f281616e81977f7afe5eaf280619dab refs/tags/v0.2.0 +^62dee9824b6de724b4fa0d2b43c30fa194eb9280 +cf68dd99c9dcb2a5b87508abafbb8b024e817280 refs/tags/v0.2.2 +f0a74ce7ea8dede84616edfb0b034e1e66fa1a21 refs/tags/v0.2.3 +7a54e03e60d5b69a1787b79c91a4954ef18f208f refs/tags/v0.3.0 +^c84da5e744db960a17c09485720ff1c094b1f6e8 +7c68b93047d509b91584f793e2aa698a782d98f7 refs/tags/v0.3.1 +^472fb6f674d315f372bc3480b2f1aba8d772a680 +0b57ee3669dd2d6d536ecff116345a929f6b068c refs/tags/v0.4.0 +6d1827381b44ac21b050378a7fe892915b14b2e2 refs/tags/v0.5.0 +^c4fdc8f70804fea6f543e6bbf3964301e2537e36 +b9205506b525cfc2488165e485c81d72754e8f7a refs/tags/v0.6.0 +^5be53ec6484f951b7301f164ea52d3ce86746ba9 +25792306e0601d0378ac7c1db43b08ad9644db7a refs/tags/v0.6.1 +^2f387376aaad69953a8d13324de794bc87772642 +563b5fa9adb7f751eafe40ad71d0c90c27750b86 refs/tags/v0.6.2 +^6761124e70ac65e197b7485bf0cbdaee390b5d72 +bd5c154784314a075af67b0f2ddb44b5df53e7d2 refs/tags/v0.6.3 +^954c8697e70841f6c2bcc11257d1b42859e22d66 +53fb7cc0eac54c59a5e12c9e94f146628b22a5ab refs/tags/v0.6.4 +^17c069d25ac7b24af6b5dc7ecb9597cef881f582 +434d7f1088bfa0c31fd980bd9222651d831b8a74 refs/tags/v0.6.5 +^d031b3e03522d47607173ebda89e7558b622a322 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/refs/heads/master b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/refs/heads/master new file mode 100644 index 0000000..a6c30c0 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/refs/heads/master @@ -0,0 +1 @@ +571a859413866897cf962396f02f65a288f677ac diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/refs/remotes/origin/HEAD new file mode 100644 index 0000000..6efe28f --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerlevel9k/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/HEAD new file mode 100644 index 0000000..a7f41cf --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/HEAD @@ -0,0 +1 @@ +c48e4c69ef5c368ea7cda961ed9d0e298a5ae1fc diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/config b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/config new file mode 100644 index 0000000..00dd2d2 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/config @@ -0,0 +1,14 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true + worktree = ../../../../../../modules/prompt/external/powerline +[remote "origin"] + url = https://github.com/davidjrice/prezto_powerline.git + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/description b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/description new file mode 100644 index 0000000..498b267 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/applypatch-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/applypatch-msg.sample new file mode 100755 index 0000000..a5d7b84 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/commit-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/commit-msg.sample new file mode 100755 index 0000000..b58d118 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/fsmonitor-watchman.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/fsmonitor-watchman.sample new file mode 100755 index 0000000..e673bb3 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/fsmonitor-watchman.sample @@ -0,0 +1,114 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use IPC::Open2; + +# An example hook script to integrate Watchman +# (https://facebook.github.io/watchman/) with git to speed up detecting +# new and modified files. +# +# The hook is passed a version (currently 1) and a time in nanoseconds +# formatted as a string and outputs to stdout all files that have been +# modified since the given time. Paths must be relative to the root of +# the working tree and separated by a single NUL. +# +# To enable this hook, rename this file to "query-watchman" and set +# 'git config core.fsmonitor .git/hooks/query-watchman' +# +my ($version, $time) = @ARGV; + +# Check the hook interface version + +if ($version == 1) { + # convert nanoseconds to seconds + $time = int $time / 1000000000; +} else { + die "Unsupported query-fsmonitor hook version '$version'.\n" . + "Falling back to scanning...\n"; +} + +my $git_work_tree; +if ($^O =~ 'msys' || $^O =~ 'cygwin') { + $git_work_tree = Win32::GetCwd(); + $git_work_tree =~ tr/\\/\//; +} else { + require Cwd; + $git_work_tree = Cwd::cwd(); +} + +my $retry = 1; + +launch_watchman(); + +sub launch_watchman { + + my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') + or die "open2() failed: $!\n" . + "Falling back to scanning...\n"; + + # In the query expression below we're asking for names of files that + # changed since $time but were not transient (ie created after + # $time but no longer exist). + # + # To accomplish this, we're using the "since" generator to use the + # recency index to select candidate nodes and "fields" to limit the + # output to file names only. Then we're using the "expression" term to + # further constrain the results. + # + # The category of transient files that we want to ignore will have a + # creation clock (cclock) newer than $time_t value and will also not + # currently exist. + + my $query = <<" END"; + ["query", "$git_work_tree", { + "since": $time, + "fields": ["name"], + "expression": ["not", ["allof", ["since", $time, "cclock"], ["not", "exists"]]] + }] + END + + print CHLD_IN $query; + close CHLD_IN; + my $response = do {local $/; }; + + die "Watchman: command returned no output.\n" . + "Falling back to scanning...\n" if $response eq ""; + die "Watchman: command returned invalid output: $response\n" . + "Falling back to scanning...\n" unless $response =~ /^\{/; + + my $json_pkg; + eval { + require JSON::XS; + $json_pkg = "JSON::XS"; + 1; + } or do { + require JSON::PP; + $json_pkg = "JSON::PP"; + }; + + my $o = $json_pkg->new->utf8->decode($response); + + if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) { + print STDERR "Adding '$git_work_tree' to watchman's watch list.\n"; + $retry--; + qx/watchman watch "$git_work_tree"/; + die "Failed to make watchman watch '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + + # Watchman will always return all files on the first query so + # return the fast "everything is dirty" flag to git and do the + # Watchman query just to get it over with now so we won't pay + # the cost in git to look up each individual file. + print "/\0"; + eval { launch_watchman() }; + exit 0; + } + + die "Watchman: $o->{error}.\n" . + "Falling back to scanning...\n" if $o->{error}; + + binmode STDOUT, ":utf8"; + local $, = "\0"; + print @{$o->{files}}; +} diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/post-update.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/post-update.sample new file mode 100755 index 0000000..ec17ec1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/pre-applypatch.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/pre-applypatch.sample new file mode 100755 index 0000000..4142082 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/pre-commit.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/pre-commit.sample new file mode 100755 index 0000000..6a75641 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/pre-push.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/pre-push.sample new file mode 100755 index 0000000..6187dbf --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo >&2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/pre-rebase.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/pre-rebase.sample new file mode 100755 index 0000000..6cbef5c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up to date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/pre-receive.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/pre-receive.sample new file mode 100755 index 0000000..a1fd29e --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/pre-receive.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to make use of push options. +# The example simply echoes all push options that start with 'echoback=' +# and rejects all pushes when the "reject" push option is used. +# +# To enable this hook, rename this file to "pre-receive". + +if test -n "$GIT_PUSH_OPTION_COUNT" +then + i=0 + while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" + do + eval "value=\$GIT_PUSH_OPTION_$i" + case "$value" in + echoback=*) + echo "echo from the pre-receive-hook: ${value#*=}" >&2 + ;; + reject) + exit 1 + esac + i=$((i + 1)) + done +fi diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/prepare-commit-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/prepare-commit-msg.sample new file mode 100755 index 0000000..10fa14c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/prepare-commit-msg.sample @@ -0,0 +1,42 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first one removes the +# "# Please enter the commit message..." help message. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 + +/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" + +# case "$COMMIT_SOURCE,$SHA1" in +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; +# *) ;; +# esac + +# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" +# if test -z "$COMMIT_SOURCE" +# then +# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" +# fi diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/update.sample b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/update.sample new file mode 100755 index 0000000..80ba941 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to block unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/index b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/index new file mode 100644 index 0000000..da17dee Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/index differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/info/exclude b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/info/exclude new file mode 100644 index 0000000..a5196d1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/logs/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/logs/HEAD new file mode 100644 index 0000000..558a747 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 c48e4c69ef5c368ea7cda961ed9d0e298a5ae1fc Andrey Anurin 1534073708 +0300 clone: from https://github.com/davidjrice/prezto_powerline.git +c48e4c69ef5c368ea7cda961ed9d0e298a5ae1fc c48e4c69ef5c368ea7cda961ed9d0e298a5ae1fc Andrey Anurin 1534073719 +0300 checkout: moving from master to c48e4c69ef5c368ea7cda961ed9d0e298a5ae1fc diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/logs/refs/heads/master b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/logs/refs/heads/master new file mode 100644 index 0000000..efb6db0 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 c48e4c69ef5c368ea7cda961ed9d0e298a5ae1fc Andrey Anurin 1534073708 +0300 clone: from https://github.com/davidjrice/prezto_powerline.git diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/logs/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/logs/refs/remotes/origin/HEAD new file mode 100644 index 0000000..efb6db0 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 c48e4c69ef5c368ea7cda961ed9d0e298a5ae1fc Andrey Anurin 1534073708 +0300 clone: from https://github.com/davidjrice/prezto_powerline.git diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/16/fe64fbc80ac2e5a9c46f874e635f72676f7f28 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/16/fe64fbc80ac2e5a9c46f874e635f72676f7f28 new file mode 100644 index 0000000..891ca31 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/16/fe64fbc80ac2e5a9c46f874e635f72676f7f28 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/17/e4b6b11ade0508cc4b3fbe5f54731bffdbf62b b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/17/e4b6b11ade0508cc4b3fbe5f54731bffdbf62b new file mode 100644 index 0000000..00de598 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/17/e4b6b11ade0508cc4b3fbe5f54731bffdbf62b differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/1f/13956be47a14f9f51edd93341ed6af9a9d690b b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/1f/13956be47a14f9f51edd93341ed6af9a9d690b new file mode 100644 index 0000000..7a5bdc4 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/1f/13956be47a14f9f51edd93341ed6af9a9d690b differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/2c/31f8d2bae45c17c36f1869e1d1d55d55b89048 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/2c/31f8d2bae45c17c36f1869e1d1d55d55b89048 new file mode 100644 index 0000000..8aa9d81 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/2c/31f8d2bae45c17c36f1869e1d1d55d55b89048 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/31/102e15f358389bcb600eb7d4685af0b16d8af0 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/31/102e15f358389bcb600eb7d4685af0b16d8af0 new file mode 100644 index 0000000..6dc8fea --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/31/102e15f358389bcb600eb7d4685af0b16d8af0 @@ -0,0 +1,3 @@ +xT]o09JS[IBcZ@qnoκεٴ>:s33x7zF +Ph'K$Y W6YuXm &C~//(k (RDUkg 3L*4yc #S9T:cVBBqǬ͏KK&KAk,(z.YUKlXd&ك!{>ڡw zαFMB}a_gɔ0-MNP' EcR2GDg[ +OT$ xrxc0Ie'W"tzHk?g rK6ɖqv'[(I 045;O}EV ^0R!7 ZOu93ݣ)UC do,eCתTc5~8:' sI jGOii-_y>.53dX߿1A),aA( ^o[4CDj*d$w\PE`/}ǙQ\/%wI>%XD<їHH]*Q؎_72m%amZ#æP+\NǓyD \ No newline at end of file diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/67/65ebec0ab529ceaa3a45323944acbb7cc7d0db b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/67/65ebec0ab529ceaa3a45323944acbb7cc7d0db new file mode 100644 index 0000000..f94c915 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/67/65ebec0ab529ceaa3a45323944acbb7cc7d0db differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/6d/4da4d8ee7acb5cc207059dd0882073496b4ce2 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/6d/4da4d8ee7acb5cc207059dd0882073496b4ce2 new file mode 100644 index 0000000..593fb0c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/6d/4da4d8ee7acb5cc207059dd0882073496b4ce2 @@ -0,0 +1 @@ +xON uݯPhK1ufBv i^L|9&'|z㸎2ٱRJMbI:c P5ɇ^HfKog+|%FbW|B8}Fs7}V(Kbƴ}WOXZgpfu8?V6jBH9.)0o> -57U`ژW^&Z,pGnqMicv(ԭ1Pd\-m<ӎ \ No newline at end of file diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/6f/565bd0ad6ffd4fffd2132550cead10af29d4fe b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/6f/565bd0ad6ffd4fffd2132550cead10af29d4fe new file mode 100644 index 0000000..3d0178e Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/6f/565bd0ad6ffd4fffd2132550cead10af29d4fe differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/6f/900c28def19ea2debc1c6f8406750d0a94a054 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/6f/900c28def19ea2debc1c6f8406750d0a94a054 new file mode 100644 index 0000000..a045f11 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/6f/900c28def19ea2debc1c6f8406750d0a94a054 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/6f/fb547c0fb2ac21b131a1248c1a570edbe8cd76 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/6f/fb547c0fb2ac21b131a1248c1a570edbe8cd76 new file mode 100644 index 0000000..fd059fc --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/6f/fb547c0fb2ac21b131a1248c1a570edbe8cd76 @@ -0,0 +1 @@ +xm=O0E+Ĉ(cK ^@Rq=w!\@d"0Lk=j2;ZNɞ2$1te:0佐 7@>!}?_B .>[DfLRYU ѹZ}Os خ3军7FJ3 W3օG2zc|soYH@@JWx5Jy׽$tKee>D0phP \ No newline at end of file diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/72/a25138b92ecc4c2fcf8b7b2b2c16d8399786f5 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/72/a25138b92ecc4c2fcf8b7b2b2c16d8399786f5 new file mode 100644 index 0000000..72a3ebb Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/72/a25138b92ecc4c2fcf8b7b2b2c16d8399786f5 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/76/4b341998288c67ea1b0bbe2bb0f0a37c2c991d b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/76/4b341998288c67ea1b0bbe2bb0f0a37c2c991d new file mode 100644 index 0000000..08fc8dc Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/76/4b341998288c67ea1b0bbe2bb0f0a37c2c991d differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/80/666f6e81ddba24b7d625a435e948e3a88737d8 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/80/666f6e81ddba24b7d625a435e948e3a88737d8 new file mode 100644 index 0000000..e0889e2 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/80/666f6e81ddba24b7d625a435e948e3a88737d8 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/83/27f8a1ff577776d5a0e9ff5b513d0d3a2fb058 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/83/27f8a1ff577776d5a0e9ff5b513d0d3a2fb058 new file mode 100644 index 0000000..9191797 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/83/27f8a1ff577776d5a0e9ff5b513d0d3a2fb058 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/85/0f3df81e1dbb9cacea270000c58f8dc9f2c0c4 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/85/0f3df81e1dbb9cacea270000c58f8dc9f2c0c4 new file mode 100644 index 0000000..200f234 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/85/0f3df81e1dbb9cacea270000c58f8dc9f2c0c4 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/86/e26fda1b18714387bac664025706d35d3d3bcb b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/86/e26fda1b18714387bac664025706d35d3d3bcb new file mode 100644 index 0000000..fe378a5 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/86/e26fda1b18714387bac664025706d35d3d3bcb differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/8a/3ed7381bc4e012049ba09145fc83fe51bf6926 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/8a/3ed7381bc4e012049ba09145fc83fe51bf6926 new file mode 100644 index 0000000..cec63a9 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/8a/3ed7381bc4e012049ba09145fc83fe51bf6926 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/8b/2b6df7f022718f15085b58a72516d5fd4dcd8f b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/8b/2b6df7f022718f15085b58a72516d5fd4dcd8f new file mode 100644 index 0000000..bdc5a55 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/8b/2b6df7f022718f15085b58a72516d5fd4dcd8f differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/8b/a30e8928eec396c37c193552837832a18aa52a b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/8b/a30e8928eec396c37c193552837832a18aa52a new file mode 100644 index 0000000..8c5fd9d Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/8b/a30e8928eec396c37c193552837832a18aa52a differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/8e/81152340c4beb2d941340d1feb2dc29bbcc309 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/8e/81152340c4beb2d941340d1feb2dc29bbcc309 new file mode 100644 index 0000000..c3d3538 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/8e/81152340c4beb2d941340d1feb2dc29bbcc309 @@ -0,0 +1 @@ +xMj0F)f_Y?B&3cǮ<]>>ǣuYfV1HJ,e3>C5[rW`o{{BLGlZCB|En׷#`lUCl;Tns~Lh`;բ4_oX \ No newline at end of file diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/8e/ed97618cdb0ab3c467231d0ea26f36f9fbb382 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/8e/ed97618cdb0ab3c467231d0ea26f36f9fbb382 new file mode 100644 index 0000000..9521caf Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/8e/ed97618cdb0ab3c467231d0ea26f36f9fbb382 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/9c/6e4b571e4dc9b92435471ba8bf421bdbbeecb3 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/9c/6e4b571e4dc9b92435471ba8bf421bdbbeecb3 new file mode 100644 index 0000000..d70c3ae --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/9c/6e4b571e4dc9b92435471ba8bf421bdbbeecb3 @@ -0,0 +1,3 @@ +x+)JMU042e040031QrutuMaA_#:bտg +s J +pB.S|DQT䗧d0,Nߜ%\+E2 \ No newline at end of file diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/a2/7b67b3625a192372228afc38e4df5c8421efa9 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/a2/7b67b3625a192372228afc38e4df5c8421efa9 new file mode 100644 index 0000000..291ed73 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/a2/7b67b3625a192372228afc38e4df5c8421efa9 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/ab/b9899eab1e56951200a4f29c41936ddbb50784 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/ab/b9899eab1e56951200a4f29c41936ddbb50784 new file mode 100644 index 0000000..de0db2b Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/ab/b9899eab1e56951200a4f29c41936ddbb50784 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/b1/e6047cb345e93b6faea7cb4824294e392740a2 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/b1/e6047cb345e93b6faea7cb4824294e392740a2 new file mode 100644 index 0000000..157079f Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/b1/e6047cb345e93b6faea7cb4824294e392740a2 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/b6/2616d845f0a81e51fd3ae51dbf45d04d50153b b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/b6/2616d845f0a81e51fd3ae51dbf45d04d50153b new file mode 100644 index 0000000..6b176bc Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/b6/2616d845f0a81e51fd3ae51dbf45d04d50153b differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/bb/d68345e2b51698be23605c67a3f20e37242cbe b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/bb/d68345e2b51698be23605c67a3f20e37242cbe new file mode 100644 index 0000000..e272dc4 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/bb/d68345e2b51698be23605c67a3f20e37242cbe differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/c4/8e4c69ef5c368ea7cda961ed9d0e298a5ae1fc b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/c4/8e4c69ef5c368ea7cda961ed9d0e298a5ae1fc new file mode 100644 index 0000000..8e5597c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/c4/8e4c69ef5c368ea7cda961ed9d0e298a5ae1fc @@ -0,0 +1,4 @@ +xmPJ1On6?MHŊ^KMľ 33. C,EwV2H\24R,ZAt ="Cm +RI*/ 㝔#YkCgf9̒õZ)Hzml-ac?V}3];`Bi΍[ֶ]T(S,a5LŲ8b͖X2}T +/!4c#NsmӠuaH8 +@..^Lدownl \ No newline at end of file diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/cc/381a39a0b3662e5b5068c410232822e6c90caf b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/cc/381a39a0b3662e5b5068c410232822e6c90caf new file mode 100644 index 0000000..a235f53 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/cc/381a39a0b3662e5b5068c410232822e6c90caf @@ -0,0 +1 @@ +xSMk0ٿbBX/xՏ[@’ -)AǶY2esoH&d{g{޸P?~z1;JjX7lob-L˜Rghtg]Kf-I.ޢKlBDi;OůCa H]XZsZSJb s.k"8q灤2] =릳a-!۹~K ]隔}ѼP@8`="Ypb'hu#ݸ!@bgJsd>m22ŷ-Kx^ղhskBGac0u!{<>YA5gȐN$O<eI \ No newline at end of file diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/cd/138e33d2e8dda02927277b7d3e4de1837ba36c b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/cd/138e33d2e8dda02927277b7d3e4de1837ba36c new file mode 100644 index 0000000..f9ef5b8 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/cd/138e33d2e8dda02927277b7d3e4de1837ba36c differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/cf/698ac86264e33139d013a52ce579b07bc0b778 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/cf/698ac86264e33139d013a52ce579b07bc0b778 new file mode 100644 index 0000000..6fde566 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/cf/698ac86264e33139d013a52ce579b07bc0b778 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/d4/08248c117db75d0d2f0c61e1c3126b3ed14d35 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/d4/08248c117db75d0d2f0c61e1c3126b3ed14d35 new file mode 100644 index 0000000..e421ec9 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/d4/08248c117db75d0d2f0c61e1c3126b3ed14d35 @@ -0,0 +1,2 @@ +xM F]sٛ4$Ƹ0P"CV[/+(v0C"eDNv#Jcsp葌M OlNw$D{'AK۪9.yz +Gpx/6anF +[?7i~~[P<-[-Jb \ No newline at end of file diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/d7/1ea101c9928a08ef0117de740ac0642df77494 b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/d7/1ea101c9928a08ef0117de740ac0642df77494 new file mode 100644 index 0000000..60dff22 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/d7/1ea101c9928a08ef0117de740ac0642df77494 differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/f8/17c81c22153b35bde9c0f2930f59ef83aedf6f b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/f8/17c81c22153b35bde9c0f2930f59ef83aedf6f new file mode 100644 index 0000000..0385927 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/f8/17c81c22153b35bde9c0f2930f59ef83aedf6f differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/f9/26f14ef2689de5baed4155a779745bada4956f b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/f9/26f14ef2689de5baed4155a779745bada4956f new file mode 100644 index 0000000..2d1bb34 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/objects/f9/26f14ef2689de5baed4155a779745bada4956f differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/packed-refs b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/packed-refs new file mode 100644 index 0000000..727b6a4 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled fully-peeled sorted +c48e4c69ef5c368ea7cda961ed9d0e298a5ae1fc refs/remotes/origin/master diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/refs/heads/master b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/refs/heads/master new file mode 100644 index 0000000..a7f41cf --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/refs/heads/master @@ -0,0 +1 @@ +c48e4c69ef5c368ea7cda961ed9d0e298a5ae1fc diff --git a/.zprezto/.git_backup/modules/modules/prompt/external/powerline/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/refs/remotes/origin/HEAD new file mode 100644 index 0000000..6efe28f --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/external/powerline/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/HEAD b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/HEAD new file mode 100644 index 0000000..77c93a4 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/HEAD @@ -0,0 +1 @@ +fa9137ecec76d23fe76fd6fabe9c2f8ae0de9cf5 diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/config b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/config new file mode 100644 index 0000000..8b9ddbe --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/config @@ -0,0 +1,14 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true + worktree = ../../../../../../modules/prompt/external/pure +[remote "origin"] + url = https://github.com/sindresorhus/pure.git + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/description b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/description new file mode 100644 index 0000000..498b267 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/applypatch-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/applypatch-msg.sample new file mode 100755 index 0000000..a5d7b84 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/commit-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/commit-msg.sample new file mode 100755 index 0000000..b58d118 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/fsmonitor-watchman.sample b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/fsmonitor-watchman.sample new file mode 100755 index 0000000..e673bb3 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/fsmonitor-watchman.sample @@ -0,0 +1,114 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use IPC::Open2; + +# An example hook script to integrate Watchman +# (https://facebook.github.io/watchman/) with git to speed up detecting +# new and modified files. +# +# The hook is passed a version (currently 1) and a time in nanoseconds +# formatted as a string and outputs to stdout all files that have been +# modified since the given time. Paths must be relative to the root of +# the working tree and separated by a single NUL. +# +# To enable this hook, rename this file to "query-watchman" and set +# 'git config core.fsmonitor .git/hooks/query-watchman' +# +my ($version, $time) = @ARGV; + +# Check the hook interface version + +if ($version == 1) { + # convert nanoseconds to seconds + $time = int $time / 1000000000; +} else { + die "Unsupported query-fsmonitor hook version '$version'.\n" . + "Falling back to scanning...\n"; +} + +my $git_work_tree; +if ($^O =~ 'msys' || $^O =~ 'cygwin') { + $git_work_tree = Win32::GetCwd(); + $git_work_tree =~ tr/\\/\//; +} else { + require Cwd; + $git_work_tree = Cwd::cwd(); +} + +my $retry = 1; + +launch_watchman(); + +sub launch_watchman { + + my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') + or die "open2() failed: $!\n" . + "Falling back to scanning...\n"; + + # In the query expression below we're asking for names of files that + # changed since $time but were not transient (ie created after + # $time but no longer exist). + # + # To accomplish this, we're using the "since" generator to use the + # recency index to select candidate nodes and "fields" to limit the + # output to file names only. Then we're using the "expression" term to + # further constrain the results. + # + # The category of transient files that we want to ignore will have a + # creation clock (cclock) newer than $time_t value and will also not + # currently exist. + + my $query = <<" END"; + ["query", "$git_work_tree", { + "since": $time, + "fields": ["name"], + "expression": ["not", ["allof", ["since", $time, "cclock"], ["not", "exists"]]] + }] + END + + print CHLD_IN $query; + close CHLD_IN; + my $response = do {local $/; }; + + die "Watchman: command returned no output.\n" . + "Falling back to scanning...\n" if $response eq ""; + die "Watchman: command returned invalid output: $response\n" . + "Falling back to scanning...\n" unless $response =~ /^\{/; + + my $json_pkg; + eval { + require JSON::XS; + $json_pkg = "JSON::XS"; + 1; + } or do { + require JSON::PP; + $json_pkg = "JSON::PP"; + }; + + my $o = $json_pkg->new->utf8->decode($response); + + if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) { + print STDERR "Adding '$git_work_tree' to watchman's watch list.\n"; + $retry--; + qx/watchman watch "$git_work_tree"/; + die "Failed to make watchman watch '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + + # Watchman will always return all files on the first query so + # return the fast "everything is dirty" flag to git and do the + # Watchman query just to get it over with now so we won't pay + # the cost in git to look up each individual file. + print "/\0"; + eval { launch_watchman() }; + exit 0; + } + + die "Watchman: $o->{error}.\n" . + "Falling back to scanning...\n" if $o->{error}; + + binmode STDOUT, ":utf8"; + local $, = "\0"; + print @{$o->{files}}; +} diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/post-update.sample b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/post-update.sample new file mode 100755 index 0000000..ec17ec1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/pre-applypatch.sample b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/pre-applypatch.sample new file mode 100755 index 0000000..4142082 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/pre-commit.sample b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/pre-commit.sample new file mode 100755 index 0000000..6a75641 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/pre-push.sample b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/pre-push.sample new file mode 100755 index 0000000..6187dbf --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo >&2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/pre-rebase.sample b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/pre-rebase.sample new file mode 100755 index 0000000..6cbef5c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up to date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/pre-receive.sample b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/pre-receive.sample new file mode 100755 index 0000000..a1fd29e --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/pre-receive.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to make use of push options. +# The example simply echoes all push options that start with 'echoback=' +# and rejects all pushes when the "reject" push option is used. +# +# To enable this hook, rename this file to "pre-receive". + +if test -n "$GIT_PUSH_OPTION_COUNT" +then + i=0 + while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" + do + eval "value=\$GIT_PUSH_OPTION_$i" + case "$value" in + echoback=*) + echo "echo from the pre-receive-hook: ${value#*=}" >&2 + ;; + reject) + exit 1 + esac + i=$((i + 1)) + done +fi diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/prepare-commit-msg.sample b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/prepare-commit-msg.sample new file mode 100755 index 0000000..10fa14c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/prepare-commit-msg.sample @@ -0,0 +1,42 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first one removes the +# "# Please enter the commit message..." help message. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 + +/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" + +# case "$COMMIT_SOURCE,$SHA1" in +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; +# *) ;; +# esac + +# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" +# if test -z "$COMMIT_SOURCE" +# then +# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" +# fi diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/update.sample b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/update.sample new file mode 100755 index 0000000..80ba941 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to block unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/index b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/index new file mode 100644 index 0000000..2af3a10 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/index differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/info/exclude b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/info/exclude new file mode 100644 index 0000000..a5196d1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/logs/HEAD b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/logs/HEAD new file mode 100644 index 0000000..be2ac3b --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 872153f44678d8084ce41753fe6a92b92040b411 Andrey Anurin 1534073712 +0300 clone: from https://github.com/sindresorhus/pure.git +872153f44678d8084ce41753fe6a92b92040b411 fa9137ecec76d23fe76fd6fabe9c2f8ae0de9cf5 Andrey Anurin 1534073719 +0300 checkout: moving from master to fa9137ecec76d23fe76fd6fabe9c2f8ae0de9cf5 diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/logs/refs/heads/master b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/logs/refs/heads/master new file mode 100644 index 0000000..b5f45cc --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 872153f44678d8084ce41753fe6a92b92040b411 Andrey Anurin 1534073712 +0300 clone: from https://github.com/sindresorhus/pure.git diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/logs/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/logs/refs/remotes/origin/HEAD new file mode 100644 index 0000000..b5f45cc --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 872153f44678d8084ce41753fe6a92b92040b411 Andrey Anurin 1534073712 +0300 clone: from https://github.com/sindresorhus/pure.git diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/objects/pack/pack-baea91a8ba78b323655e7a4c47b44dfd1b10d0ca.idx b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/objects/pack/pack-baea91a8ba78b323655e7a4c47b44dfd1b10d0ca.idx new file mode 100644 index 0000000..df37e0f Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/objects/pack/pack-baea91a8ba78b323655e7a4c47b44dfd1b10d0ca.idx differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/objects/pack/pack-baea91a8ba78b323655e7a4c47b44dfd1b10d0ca.pack b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/objects/pack/pack-baea91a8ba78b323655e7a4c47b44dfd1b10d0ca.pack new file mode 100644 index 0000000..1651335 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/objects/pack/pack-baea91a8ba78b323655e7a4c47b44dfd1b10d0ca.pack differ diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/packed-refs b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/packed-refs new file mode 100644 index 0000000..19a31d6 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/packed-refs @@ -0,0 +1,50 @@ +# pack-refs with: peeled fully-peeled sorted +872153f44678d8084ce41753fe6a92b92040b411 refs/remotes/origin/master +d594336f92875112e2b6eefc9493589e7deaeb46 refs/remotes/origin/ps2-improvements +93e6c95990caccab65b90fb406d4ab93646131db refs/tags/0.2.0 +46ad34b6b593c2f3d2f31f7e16806b158917dc62 refs/tags/1.0.0 +^8132bc5efd3b4bd06eda4113885deba4ebe259de +de2658dfc3a215881f727ea98085ff999bd7ae04 refs/tags/1.1.0 +^77e0633639e4ff16e720a5f8f9db3a4aa9dfe93c +fb03bab80d1b23ff2e384280df639b2bda4e4293 refs/tags/1.1.1 +^29ab6e737fea1e4aa02f1f35568e2d111eee6771 +ddacfa937ae63c41bd5515829e04ed8d3302a847 refs/tags/1.2.0 +^49cd9360a2b474304ad0e7bdededc72694126b1a +d08153277971caf4593b2e93a99799f9d61a3213 refs/tags/v0.1.1 +^e06908b5d484d026083a2830ac3f69dc7c89172c +16416d13617954c573098e0afc23367a6896e1af refs/tags/v0.1.2 +^ef8e2c41f71e378039cd3bb45c144d17c5cbcdf4 +3604d29b966d22c2d28e2121fdc6510719c1ea05 refs/tags/v0.1.3 +^0ee92943c97f062bd24ee5604335cd1489800aa0 +570ade87e1100bd2786da9dcdd36cfec1b959b0f refs/tags/v0.2.0 +^93e6c95990caccab65b90fb406d4ab93646131db +c5abed3e846f0a818b568e62381f97c63c51fe82 refs/tags/v0.2.1 +^aa058b9da3fe64b04b2a579c2f517f65d86c20e1 +44b75e7be3d1417405fedca77cfb685d4ffdc6b9 refs/tags/v0.2.2 +^9854eaffda8c3681869a54557c2572c7b9bdb27f +cffa93d1e54548708e305c5c2befeee1ecf9c8b3 refs/tags/v0.3.0 +^6426a71178385d2342cc297bdc79072d11f31ce3 +443c25ed38ee8d5e8be4ab78e248d2fb794bce9e refs/tags/v0.3.1 +^2577a4cc078d05c51d9d8e4278b8d16ab348a1b9 +46d3e700da3cdc82fb3e1c6aa49f0efdc2e38408 refs/tags/v0.4.0 +^2367f4f8644aec568c9171cc538d3b47d7169899 +4eeb7806b806678af475f92320b230a6ef053aff refs/tags/v0.5.0 +^f1371d50745e0b91c7a1ad4ff08e7bfc2d4485ce +320e26b8a29f3a4e203820881bfb20c52bc75ffe refs/tags/v0.5.1 +^b76a0efe742775b7efeb4f262ca86d6d05163797 +7cf9282d31b182ec666574b909b63d4539bb085d refs/tags/v1.3.0 +^22c4f0b4039db47e928a4c530c222b1bf6be6631 +002cee1ef9633eb507bd386b3cf5fb2f73e50863 refs/tags/v1.4.0 +^211b49481e1279f1747622e3885d405a977362ff +ff84ea6217d5859a0ca5194661e1d5902e377be4 refs/tags/v1.4.1 +^26fff0cefaa2fbdafbc2cac47e898e29bfd4c30b +8dc9a07cf4830a7e9daf920df5da8263f753ead0 refs/tags/v1.5.0 +^fcd942622d39d611419947507b6b004b540d7287 +e7b8aba6b4b9fb5dc966396892d5a39030b084b8 refs/tags/v1.5.1 +^ef16a59a474c816bb58cce342f028beeedeb7588 +1a8b9dc6678d2d058c1724894ac60f0cc6455979 refs/tags/v1.5.2 +^04fa7495cf8fe3aff8ce286d4517df15066b820a +7ebc7d2368e7d925642e36e5258774aad99e25f3 refs/tags/v1.6.0 +^a95d55cc7d3a73fc562ac11e23c26113ed6d58cf +0fac6a9fc727a87956abae63bccd757d53c5d265 refs/tags/v1.7.0 +^fa9137ecec76d23fe76fd6fabe9c2f8ae0de9cf5 diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/refs/heads/master b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/refs/heads/master new file mode 100644 index 0000000..efbe921 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/refs/heads/master @@ -0,0 +1 @@ +872153f44678d8084ce41753fe6a92b92040b411 diff --git a/.zprezto/.git_backup/modules/modules/prompt/functions/pure/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/refs/remotes/origin/HEAD new file mode 100644 index 0000000..6efe28f --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/prompt/functions/pure/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/HEAD b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/HEAD new file mode 100644 index 0000000..09d1cd4 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/HEAD @@ -0,0 +1 @@ +db6cac391bee957c20ff3175b2f03c4817253e60 diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/config b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/config new file mode 100644 index 0000000..9b2c169 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/config @@ -0,0 +1,14 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true + worktree = ../../../../../modules/syntax-highlighting/external +[remote "origin"] + url = https://github.com/zsh-users/zsh-syntax-highlighting.git + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/description b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/description new file mode 100644 index 0000000..498b267 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/applypatch-msg.sample b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/applypatch-msg.sample new file mode 100755 index 0000000..a5d7b84 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/commit-msg.sample b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/commit-msg.sample new file mode 100755 index 0000000..b58d118 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/fsmonitor-watchman.sample b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/fsmonitor-watchman.sample new file mode 100755 index 0000000..e673bb3 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/fsmonitor-watchman.sample @@ -0,0 +1,114 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use IPC::Open2; + +# An example hook script to integrate Watchman +# (https://facebook.github.io/watchman/) with git to speed up detecting +# new and modified files. +# +# The hook is passed a version (currently 1) and a time in nanoseconds +# formatted as a string and outputs to stdout all files that have been +# modified since the given time. Paths must be relative to the root of +# the working tree and separated by a single NUL. +# +# To enable this hook, rename this file to "query-watchman" and set +# 'git config core.fsmonitor .git/hooks/query-watchman' +# +my ($version, $time) = @ARGV; + +# Check the hook interface version + +if ($version == 1) { + # convert nanoseconds to seconds + $time = int $time / 1000000000; +} else { + die "Unsupported query-fsmonitor hook version '$version'.\n" . + "Falling back to scanning...\n"; +} + +my $git_work_tree; +if ($^O =~ 'msys' || $^O =~ 'cygwin') { + $git_work_tree = Win32::GetCwd(); + $git_work_tree =~ tr/\\/\//; +} else { + require Cwd; + $git_work_tree = Cwd::cwd(); +} + +my $retry = 1; + +launch_watchman(); + +sub launch_watchman { + + my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') + or die "open2() failed: $!\n" . + "Falling back to scanning...\n"; + + # In the query expression below we're asking for names of files that + # changed since $time but were not transient (ie created after + # $time but no longer exist). + # + # To accomplish this, we're using the "since" generator to use the + # recency index to select candidate nodes and "fields" to limit the + # output to file names only. Then we're using the "expression" term to + # further constrain the results. + # + # The category of transient files that we want to ignore will have a + # creation clock (cclock) newer than $time_t value and will also not + # currently exist. + + my $query = <<" END"; + ["query", "$git_work_tree", { + "since": $time, + "fields": ["name"], + "expression": ["not", ["allof", ["since", $time, "cclock"], ["not", "exists"]]] + }] + END + + print CHLD_IN $query; + close CHLD_IN; + my $response = do {local $/; }; + + die "Watchman: command returned no output.\n" . + "Falling back to scanning...\n" if $response eq ""; + die "Watchman: command returned invalid output: $response\n" . + "Falling back to scanning...\n" unless $response =~ /^\{/; + + my $json_pkg; + eval { + require JSON::XS; + $json_pkg = "JSON::XS"; + 1; + } or do { + require JSON::PP; + $json_pkg = "JSON::PP"; + }; + + my $o = $json_pkg->new->utf8->decode($response); + + if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) { + print STDERR "Adding '$git_work_tree' to watchman's watch list.\n"; + $retry--; + qx/watchman watch "$git_work_tree"/; + die "Failed to make watchman watch '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + + # Watchman will always return all files on the first query so + # return the fast "everything is dirty" flag to git and do the + # Watchman query just to get it over with now so we won't pay + # the cost in git to look up each individual file. + print "/\0"; + eval { launch_watchman() }; + exit 0; + } + + die "Watchman: $o->{error}.\n" . + "Falling back to scanning...\n" if $o->{error}; + + binmode STDOUT, ":utf8"; + local $, = "\0"; + print @{$o->{files}}; +} diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/post-update.sample b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/post-update.sample new file mode 100755 index 0000000..ec17ec1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/pre-applypatch.sample b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/pre-applypatch.sample new file mode 100755 index 0000000..4142082 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/pre-commit.sample b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/pre-commit.sample new file mode 100755 index 0000000..6a75641 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/pre-push.sample b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/pre-push.sample new file mode 100755 index 0000000..6187dbf --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo >&2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/pre-rebase.sample b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/pre-rebase.sample new file mode 100755 index 0000000..6cbef5c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up to date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/pre-receive.sample b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/pre-receive.sample new file mode 100755 index 0000000..a1fd29e --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/pre-receive.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to make use of push options. +# The example simply echoes all push options that start with 'echoback=' +# and rejects all pushes when the "reject" push option is used. +# +# To enable this hook, rename this file to "pre-receive". + +if test -n "$GIT_PUSH_OPTION_COUNT" +then + i=0 + while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" + do + eval "value=\$GIT_PUSH_OPTION_$i" + case "$value" in + echoback=*) + echo "echo from the pre-receive-hook: ${value#*=}" >&2 + ;; + reject) + exit 1 + esac + i=$((i + 1)) + done +fi diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/prepare-commit-msg.sample b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/prepare-commit-msg.sample new file mode 100755 index 0000000..10fa14c --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/prepare-commit-msg.sample @@ -0,0 +1,42 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first one removes the +# "# Please enter the commit message..." help message. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 + +/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" + +# case "$COMMIT_SOURCE,$SHA1" in +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; +# *) ;; +# esac + +# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" +# if test -z "$COMMIT_SOURCE" +# then +# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" +# fi diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/update.sample b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/update.sample new file mode 100755 index 0000000..80ba941 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to block unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/index b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/index new file mode 100644 index 0000000..baec378 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/index differ diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/info/exclude b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/info/exclude new file mode 100644 index 0000000..a5196d1 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/logs/HEAD b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/logs/HEAD new file mode 100644 index 0000000..8d22965 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 db6cac391bee957c20ff3175b2f03c4817253e60 Andrey Anurin 1534073716 +0300 clone: from https://github.com/zsh-users/zsh-syntax-highlighting.git +db6cac391bee957c20ff3175b2f03c4817253e60 db6cac391bee957c20ff3175b2f03c4817253e60 Andrey Anurin 1534073720 +0300 checkout: moving from master to db6cac391bee957c20ff3175b2f03c4817253e60 diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/logs/refs/heads/master b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/logs/refs/heads/master new file mode 100644 index 0000000..80eb368 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 db6cac391bee957c20ff3175b2f03c4817253e60 Andrey Anurin 1534073716 +0300 clone: from https://github.com/zsh-users/zsh-syntax-highlighting.git diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/logs/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/logs/refs/remotes/origin/HEAD new file mode 100644 index 0000000..80eb368 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 db6cac391bee957c20ff3175b2f03c4817253e60 Andrey Anurin 1534073716 +0300 clone: from https://github.com/zsh-users/zsh-syntax-highlighting.git diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/objects/pack/pack-d40a3316e4eb643e7177e9bbb1ce2f7211cbeeb5.idx b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/objects/pack/pack-d40a3316e4eb643e7177e9bbb1ce2f7211cbeeb5.idx new file mode 100644 index 0000000..c5060b6 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/objects/pack/pack-d40a3316e4eb643e7177e9bbb1ce2f7211cbeeb5.idx differ diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/objects/pack/pack-d40a3316e4eb643e7177e9bbb1ce2f7211cbeeb5.pack b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/objects/pack/pack-d40a3316e4eb643e7177e9bbb1ce2f7211cbeeb5.pack new file mode 100644 index 0000000..40033a2 Binary files /dev/null and b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/objects/pack/pack-d40a3316e4eb643e7177e9bbb1ce2f7211cbeeb5.pack differ diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/packed-refs b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/packed-refs new file mode 100644 index 0000000..32c408d --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/packed-refs @@ -0,0 +1,21 @@ +# pack-refs with: peeled fully-peeled sorted +7ac72a57bc7e5cc0ad84ef005d75c39d101b32a0 refs/remotes/origin/0.4.x +eb67c0b84f56f33cd34e3e40fa88c346d20211bc refs/remotes/origin/0.5.x +3ff17a08917a57cbe28ec7dcaf053a0a12345088 refs/remotes/origin/feature/redrawhook +db6cac391bee957c20ff3175b2f03c4817253e60 refs/remotes/origin/master +8cb89b9cf69bfe21312df6ca599cf7c62c4ef500 refs/remotes/origin/themes +d2715e2cb3294880bbc6a75b91288243054218d0 refs/tags/0.1.0 +bb0d575942760fe483790fe878ea43b1f781e2ca refs/tags/0.1.1 +732b7d6e65c0349ee1d89b698bf9cd8a30c1015d refs/tags/0.1.2 +a0862053f57e3d8d6e0dbc34e55be13d9e4fb668 refs/tags/0.1.3 +dbd27cb30a710809dd070669c331574fdc15b397 refs/tags/0.2.0 +3dc574190071ef59054f6d693132410b37aa3ae4 refs/tags/0.2.1 +fee52920ae0b29e30bf5413151263faed20f5123 refs/tags/0.3.0 +2d792b03bb715b1cd4c550aba48e2ca10be6a447 refs/tags/0.4.0 +c19ee583138ebab416b0d2efafbad7dc9f3f7c4f refs/tags/0.4.1 +c5523c757192c9d9fffde1219c0f8d60f9af9a22 refs/tags/0.5.0 +^15d4587514a3beaa13972093e335bf685b6726a9 +f7a963b078820de3be822c62333f68067efd9a29 refs/tags/0.6.0 +^434af7b11dd33641231f1b48b8432e68eb472e46 +0f26070068b25b97b47693adf87c438c40a0756e refs/tags/0.6.0-rc1 +^dc2673155594f1de815802ca674bc7741ccda60f diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/refs/heads/master b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/refs/heads/master new file mode 100644 index 0000000..09d1cd4 --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/refs/heads/master @@ -0,0 +1 @@ +db6cac391bee957c20ff3175b2f03c4817253e60 diff --git a/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/refs/remotes/origin/HEAD b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/refs/remotes/origin/HEAD new file mode 100644 index 0000000..6efe28f --- /dev/null +++ b/.zprezto/.git_backup/modules/modules/syntax-highlighting/external/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/.zprezto/.git_backup/objects/pack/pack-bb41e06a36633ac0fc6287a6762584c87dc0ae70.idx b/.zprezto/.git_backup/objects/pack/pack-bb41e06a36633ac0fc6287a6762584c87dc0ae70.idx new file mode 100644 index 0000000..0089b1c Binary files /dev/null and b/.zprezto/.git_backup/objects/pack/pack-bb41e06a36633ac0fc6287a6762584c87dc0ae70.idx differ diff --git a/.zprezto/.git_backup/objects/pack/pack-bb41e06a36633ac0fc6287a6762584c87dc0ae70.pack b/.zprezto/.git_backup/objects/pack/pack-bb41e06a36633ac0fc6287a6762584c87dc0ae70.pack new file mode 100644 index 0000000..609c1c8 Binary files /dev/null and b/.zprezto/.git_backup/objects/pack/pack-bb41e06a36633ac0fc6287a6762584c87dc0ae70.pack differ diff --git a/.zprezto/.git_backup/packed-refs b/.zprezto/.git_backup/packed-refs new file mode 100644 index 0000000..48fc58c --- /dev/null +++ b/.zprezto/.git_backup/packed-refs @@ -0,0 +1,33 @@ +# pack-refs with: peeled fully-peeled sorted +3524cc20f08a6b662c2a983743ec02adbcf877a2 refs/remotes/origin/belak/zdebuglog +d541eef923c24bf0983465c57c93504db3476985 refs/remotes/origin/issue/231-installer +5be4a78b55acba1fbfcb6a7767d7d0743623660d refs/remotes/origin/issue/276-readme-to-man-page +113f6763c22c31dff15a7f776c991596e150e4a1 refs/remotes/origin/issue/306-default-zstyle-function +2d1881c4660d012a0cb0c2c98a4a4cdf07f5ba5c refs/remotes/origin/issue/656-readd-z +f2042a29cc7613e8f797044948b0238916b2a234 refs/remotes/origin/master +5f675b0c670b5d2c24c79378962b78c391ec10a9 refs/remotes/origin/module/completion +729fd07ab03b0b9d070c63d6f4972960103294ba refs/remotes/origin/module/git/hub +5ecbb49630d8a9b74a66aa31d9f79d69bd355ec0 refs/remotes/origin/module/update +8e95c547d6b8d3207ba7d20065c69a3aa7f78257 refs/remotes/origin/module/zaw +e3696d2c2862a9c5cb57723dba2133b97cb7ab87 refs/remotes/origin/pull/517-auto-virtualenv +d196c6a15a2b7226a7b950996a707b6ee0c040d0 refs/remotes/origin/pull/533-git-branch-verbose +a97e8de21b162335fc33c119e2cbd903fee429b7 refs/remotes/origin/pull/539-pacman-list-explicit +36e24eeb08579316bb19cd6dd42c9c15d450e71b refs/remotes/origin/pull/552-git-hub-shorten-url +72f8d15b21dd82603d548531d62ae30ded5d24e7 refs/remotes/origin/pull/556-perlbrew-path-zstyle +9852150123d0bf24dc7b496873b1b8af0f41a299 refs/remotes/origin/pull/562-ignored-user-completion +c2d6b378a6b8fb5ad914b88134a05d121af4250a refs/remotes/origin/pull/563-control-arrow-key-bindings +5e6adf89b99c407d5961a7e30a201dcdd8aa9391 refs/remotes/origin/pull/582-tmux-attach-behaviour +b2d84afacf4e3477120e7397354457e58b3e3d4b refs/remotes/origin/pull/598-skip-virtualenv-init +5590b56a877e29bb49832f1bb00a89d7f034af40 refs/remotes/origin/pull/599-terminal-title +9dd65d3982c1265d5cca67edecf8a2a8067dd7a5 refs/remotes/origin/pull/607-tmux-session-name +9ab6ab0d6645b74ee81f5ab6610d093615beb6f5 refs/remotes/origin/pull/628-explainshell +55190ffb428aaf24eb43a960368aa152faf944e8 refs/remotes/origin/pull/636-vim-text-objects +729fd07ab03b0b9d070c63d6f4972960103294ba refs/remotes/origin/pull/638-execute-command-git +c3bd8a47088a1d9f1c1fe2bda023462d656dce80 refs/remotes/origin/pull/651-git-gpg-aliases +72328d0eedac99e1fe342ec31b0e1f4e85a0dc7b refs/remotes/origin/pull/715-git-ignore-template +fb13aa332738c8c414bc4cb602a9bc2378da2a27 refs/remotes/origin/revision/do-not-use +5c7bd2009cc3598e25b8cc607c199b75040e0f34 refs/remotes/origin/revision/prezto +8d9ec24335400a1796937bc8e9caa9830767a762 refs/remotes/origin/revision/use-command_not_found_handler +f5f295cc99d65edbcfeba24d992286bf7e76000f refs/remotes/origin/revision/zdotdir-prezto +b948e3630bb293993e314bcf2691a3ab5a9b23bc refs/remotes/origin/stashes +f2a826e963f06a204dc0e09c05fc3e5419799f52 refs/remotes/origin/theme/sorin diff --git a/.zprezto/.git_backup/refs/heads/master b/.zprezto/.git_backup/refs/heads/master new file mode 100644 index 0000000..231da69 --- /dev/null +++ b/.zprezto/.git_backup/refs/heads/master @@ -0,0 +1 @@ +f2042a29cc7613e8f797044948b0238916b2a234 diff --git a/.zprezto/.git_backup/refs/remotes/origin/HEAD b/.zprezto/.git_backup/refs/remotes/origin/HEAD new file mode 100644 index 0000000..6efe28f --- /dev/null +++ b/.zprezto/.git_backup/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/.zprezto/.github_backup/ISSUE_TEMPLATE.md b/.zprezto/.github_backup/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..e39ca09 --- /dev/null +++ b/.zprezto/.github_backup/ISSUE_TEMPLATE.md @@ -0,0 +1,24 @@ + + +### Description + + +### Expected behavior + + + +### Actual behavior + + + +### Steps to Reproduce + +1. [First Step] +2. [Second Step] +3. [and so on...] + +### Versions + + - Prezto commit: + - ZSH version: + - OS information: diff --git a/.zprezto/.github_backup/PULL_REQUEST_TEMPLATE.md b/.zprezto/.github_backup/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..b8548b6 --- /dev/null +++ b/.zprezto/.github_backup/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,10 @@ +Please be sure to check out our [contributing guidelines](https://github.com/sorin-ionescu/prezto/blob/master/CONTRIBUTING.md) +before submitting your pull request. + +Fixes # + +## Proposed Changes + + - + - + - diff --git a/.zprezto/.gitignore b/.zprezto/.gitignore_backup similarity index 81% rename from .zprezto/.gitignore rename to .zprezto/.gitignore_backup index e05465f..05e53b6 100644 --- a/.zprezto/.gitignore +++ b/.zprezto/.gitignore_backup @@ -1,3 +1,4 @@ *.zwc *.zwc.old modules/*/cache.zsh +contrib diff --git a/.zprezto/.gitmodules b/.zprezto/.gitmodules_backup similarity index 68% rename from .zprezto/.gitmodules rename to .zprezto/.gitmodules_backup index 518a279..051f263 100644 --- a/.zprezto/.gitmodules +++ b/.zprezto/.gitmodules_backup @@ -1,3 +1,6 @@ +[submodule "modules/autosuggestions/external"] + path = modules/autosuggestions/external + url = https://github.com/zsh-users/zsh-autosuggestions.git [submodule "modules/history-substring-search/external"] path = modules/history-substring-search/external url = https://github.com/zsh-users/zsh-history-substring-search.git @@ -16,6 +19,12 @@ [submodule "modules/prompt/functions/pure"] path = modules/prompt/external/pure url = https://github.com/sindresorhus/pure.git -[submodule "modules/autosuggestions/external"] - path = modules/autosuggestions/external - url = https://github.com/tarruda/zsh-autosuggestions +[submodule "modules/fasd/external"] + path = modules/fasd/external + url = https://github.com/clvv/fasd.git +[submodule "modules/prompt/external/async"] + path = modules/prompt/external/async + url = https://github.com/mafredri/zsh-async.git +[submodule "modules/prompt/external/powerlevel9k"] + path = modules/prompt/external/powerlevel9k + url = https://github.com/bhilburn/powerlevel9k.git diff --git a/.zprezto/CONTRIBUTING.md b/.zprezto/CONTRIBUTING.md index eec4c16..f4dc0d6 100644 --- a/.zprezto/CONTRIBUTING.md +++ b/.zprezto/CONTRIBUTING.md @@ -23,6 +23,39 @@ improve its performance, do not hesitate to fork and send pull requests. - Open a [pull request][4] that relates to but one subject with a clear title and description in grammatically correct, complete sentences. +#### Code Style + +This project follows the [Google Shell Style Guide][5] when possible. However, +there are a number of additional things to keep in mind. + + - Local variables should be used whenever possible. + - Prefer `zstyle` over environment variables for configuration. + - Prefer (( ... )) over [[ ... ]] for arithmetic expression. + - Use the function keyword to define functions. + - The 80 character hard limit can be waived for readability. + +#### Using an Alternative zprezto Directory + +To work on zprezto without messing with your current configuration: + +```sh +mkdir devel-zprezto +cd devel-zprezto +git clone --recursive https://github.com/sorin-ionescu/prezto.git .zprezto +ZDOTDIR=$(pwd) +echo "Your development ZDOTDIR is $ZDOTDIR" +setopt EXTENDED_GLOB +for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do + ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}" +done +``` + +Then to start zsh in this development environment you will run: + +```sh +ZDOTDIR=/path/to/devel-zprezto zsh +``` + #### Modules - A *README.md* must be present. @@ -32,10 +65,11 @@ improve its performance, do not hesitate to fork and send pull requests. #### Themes - A screenshots section must be present in the file header. - - The pull request description must have [embedded screenshots][5]. + - The pull request description must have [embedded screenshots][6]. [1]: https://github.com/sorin-ionescu/prezto/contributors [2]: http://gun.io/blog/how-to-github-fork-branch-and-pull-request [3]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html [4]: https://help.github.com/articles/using-pull-requests -[5]: http://daringfireball.net/projects/markdown/syntax#img +[5]: https://google.github.io/styleguide/shell.xml +[6]: http://daringfireball.net/projects/markdown/syntax#img diff --git a/.zprezto/LICENSE b/.zprezto/LICENSE new file mode 100644 index 0000000..d417147 --- /dev/null +++ b/.zprezto/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2009-2011 Robby Russell and contributors +Copyright (c) 2011-2017 Sorin Ionescu and contributors + +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/.zprezto/README.md b/.zprezto/README.md index d6b40af..2f94cd6 100644 --- a/.zprezto/README.md +++ b/.zprezto/README.md @@ -9,27 +9,41 @@ Installation ------------ Prezto will work with any recent release of Zsh, but the minimum required -version is 4.3.17. +version is 4.3.11. 1. Launch Zsh: - zsh + ```console + zsh + ``` 2. Clone the repository: - git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto" + ```console + git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto" + ``` 3. Create a new Zsh configuration by copying the Zsh configuration files provided: - setopt EXTENDED_GLOB - for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do - ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}" - done + ```sh + setopt EXTENDED_GLOB + for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do + ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}" + done + ``` + + Note: If you already have any of the given config files, ln will error. In + simple cases you can add `source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"` to + the bottom of your `.zshrc` to load prezto but keep your config intact. For + more complicated setups, it is recommended that you back up your original + configs and replace them with the provided prezto runcoms. 4. Set Zsh as your default shell: - chsh -s /bin/zsh + ```console + chsh -s /bin/zsh + ``` 5. Open a new Zsh terminal window or tab. @@ -42,9 +56,18 @@ window or tab. Updating -------- -Pull the latest changes and update submodules. +Run `zprezto-update` to automatically check if there is an update to zprezto. +If there are no file conflicts, zprezto and its submodules will be +automatically updated. If there are conflicts you will instructed to go into +the `$ZPREZTODIR` directory and resolve them yourself. - git pull && git submodule update --init --recursive +To pull the latest changes and update submodules manually: + +```console +cd $ZPREZTODIR +git pull +git submodule update --init --recursive +``` Usage ----- @@ -67,6 +90,19 @@ accompanying README files to learn of what is available. ![sorin theme][2] +### External Modules + + 1. By default modules will be loaded from */modules* and */contrib*. + 2. Additional module directories can be added to the + `:prezto:load:pmodule-dirs` setting in *~/.zpreztorc*. + + Note that module names need to be unique or they will cause an error when + loading. + + ```console + zstyle ':prezto:load' pmodule-dirs $HOME/.zprezto-contrib + ``` + Customization ------------- @@ -83,35 +119,13 @@ The [Zsh Reference Card][7] and the [zsh-lovers][8] man page are indispensable. License ------- -(The MIT License) - -Copyright (c) 2009-2011 Robby Russell and contributors. - -Copyright (c) 2011-2015 Sorin Ionescu and contributors. - -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. +This project is licensed under the MIT License. [1]: http://www.zsh.org [2]: http://i.imgur.com/nrGV6pg.png "sorin theme" [3]: http://git-scm.com [4]: https://github.com [5]: http://gitimmersion.com -[6]: http://gitref.org +[6]: https://git.github.io/git-reference/ [7]: http://www.bash2zsh.com/zsh_refcard/refcard.pdf [8]: http://grml.org/zsh/zsh-lovers.html diff --git a/.zprezto/runcoms/zalias b/.zprezto/abra/aliases.zsh similarity index 96% rename from .zprezto/runcoms/zalias rename to .zprezto/abra/aliases.zsh index 4f104e8..5a5c1c9 100644 --- a/.zprezto/runcoms/zalias +++ b/.zprezto/abra/aliases.zsh @@ -1,5 +1,3 @@ -# ===== ALIASES ===== - alias g="git" alias a="git add --all :/" alias b="git branch" @@ -55,8 +53,4 @@ alias -g LATEST='*(om[1])' # remote tmux on server alias tmuxr="tmux new -ADs auto-session" - -# ===== FUNCTIONS ===== - alias FUNCTION_PRELUDE="setopt LOCAL_OPTIONS PIPE_FAIL XTRACE ERR_RETURN" - diff --git a/.zfunc b/.zprezto/abra/functions.zsh similarity index 86% rename from .zfunc rename to .zprezto/abra/functions.zsh index c4f777b..b6253bb 100644 --- a/.zfunc +++ b/.zprezto/abra/functions.zsh @@ -1,20 +1,22 @@ -is_local() { - [[ $(hostname) =~ '^abra0' ]] +function is_local { + local HOSTNAME=$(hostname) + + [[ "$HOSTNAME" =~ '^abra0' || "$HOSTNAME" == "svxf2-osx" ]] } -publish() { +function publish { FUNCTION_PRELUDE rsync2 "$@" "dedi:/var/www/abra.me/list/" } -twitch() { +function twitch { FUNCTION_PRELUDE livestreamer "http://www.twitch.tv/${1}" "${${@:2}:-best}" } -dcp() { +function dcp { FUNCTION_PRELUDE git add --all :/ @@ -25,7 +27,7 @@ dcp() { } -.dcp() { +function .dcp { FUNCTION_PRELUDE .g add -u @@ -35,7 +37,7 @@ dcp() { .g push } -strip-tags() { +function strip-tags { FUNCTION_PRELUDE find . -type f -name '*.mp3' \ @@ -43,13 +45,13 @@ strip-tags() { | xargs -0 -n1 mid3v2 --delete-frames=TXXX,USLT,TIPL,UFID,APIC,TBPM,TCMP,TDOR,TDRC,TLAN,TMED,TPOS,TPUB,TRCK,TCON } -dedi-beet() { +function dedi-beet { FUNCTION_PRELUDE ssh dedi -- sudo -u torrent-user beet "$@" } -beet-comments() { +function beet-comments { FUNCTION_PRELUDE : "${1:?who?}" @@ -58,7 +60,7 @@ beet-comments() { dedi-beet modify \'"comments=$2"\' \'"albumartist::$1"\' } -rsync2() { +function rsync2 { rsync \ --info=PROGRESS2 \ --progress \ @@ -75,7 +77,7 @@ rsync2() { "${(@)@}" } -sync-music() { +function sync-music { FUNCTION_PRELUDE # if ! is_local; then @@ -120,7 +122,7 @@ sync-music() { # echo -n ("${(@f)$(ls *(om[1,$1]))}") # } -testo() { +function testo { local A="${@[2,3]}" ./t.py ${(t)A} "$A" ${A[@]} unset A @@ -134,7 +136,7 @@ testo() { # testo 1 "2 3" 4 # shit shit shit s hist h is htisthsi 2018-06-30 -ffmpeg_timelapse() { +function ffmpeg_timelapse { FUNCTION_PRELUDE local DATE="$1" @@ -152,25 +154,19 @@ ffmpeg_timelapse() { rm -rf "/mnt/a/snaps/$DATE" } -ffmpeg_timelapse_today() { +function ffmpeg_timelapse_today { local TODAY=$(date '+%Y-%m-%d') ffmpeg_timelapse "$TODAY" -preset ultrafast -crf 20 } -add_dir_to_path() { - if [[ -d $1 ]]; then - export PATH="$1:$PATH" - fi -} - -update_.g() { +function update_.g { if [[ ! -d "$HOME/.dotgit" ]]; then # no git to update return fi - local RES=$(.g pull 2>&1) + local RES=$(.g pull --no-stat 2>&1) if [[ $? != 0 ]]; then # something went wrong diff --git a/.zprezto/abra/main.zsh b/.zprezto/abra/main.zsh new file mode 100644 index 0000000..a36e2af --- /dev/null +++ b/.zprezto/abra/main.zsh @@ -0,0 +1,8 @@ +zsource_if_exists "${ZDOTDIR:-$HOME}/.zprezto/abra/options.zsh" +zsource_if_exists "${ZDOTDIR:-$HOME}/.zprezto/abra/aliases.zsh" +zsource_if_exists "${ZDOTDIR:-$HOME}/.zprezto/abra/functions.zsh" + +zsource_if_exists "$HOME/.iterm2_shell_integration.zsh" + +# update, background+disown +update_.g &! diff --git a/.zoptions b/.zprezto/abra/options.zsh similarity index 100% rename from .zoptions rename to .zprezto/abra/options.zsh diff --git a/.zprezto/abra/prompt_abra_setup.zsh b/.zprezto/abra/prompt_abra_setup.zsh new file mode 100644 index 0000000..6e76ed8 --- /dev/null +++ b/.zprezto/abra/prompt_abra_setup.zsh @@ -0,0 +1,89 @@ +pmodload 'helper' + +# %F{color}...%f -- foreground colors +# %B...%b -- bold +# %(x.a.b) -- if + +# color chart: https://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg +# COLOR_PWD='141' +# COLOR_PWD_ROOT='201' +# COLOR_PROMPT_STARTER='85' +# COLOR_TIME='244' +# COLOR_USERNAME='34' +# COLOR_AT='244' +# COLOR_HOSTNAME='162' + +COLOR_PWD='cyan' +COLOR_PWD_ROOT='red' +COLOR_PROMPT_STARTER='green' +COLOR_TIME='green' +COLOR_USERNAME='blue' +COLOR_AT=$COLOR_USERNAME +COLOR_HOSTNAME=$COLOR_USERNAME + +NEWLINE=$'\n' + +function prompt_abra_precmd { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + + # Get Git repository information. + if [[ -z $NOGIT ]] && (( $+functions[git-info] )); then + git-info || true + fi + + PRE_LENGTH=$(($COLUMNS*2/3)) + + PRE='%$PRE_LENGTH<...<%~ %<<' + PRE=$(print -P $PRE) + PRE=$(print ${(l:$COLUMNS:)PRE}) + print -P '%(!.%F{$COLOR_PWD_ROOT}.%F{$COLOR_PWD})$PRE%f' +} + +function prompt_abra_setup { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + prompt_opts=(cr percent subst) + + # Load required functions. + autoload -Uz add-zsh-hook + + # Add hook for calling git-info before each command. + add-zsh-hook precmd prompt_abra_precmd + + # Set git-info parameters. + zstyle ':prezto:module:git:info' verbose 'yes' + zstyle ':prezto:module:git:info:action' format ':%%B%F{yellow}%s%f%%b' + zstyle ':prezto:module:git:info:added' format ' %%B%F{green}✚%f%%b' + zstyle ':prezto:module:git:info:ahead' format ' %%B%F{yellow}⬆%f%%b' + zstyle ':prezto:module:git:info:behind' format ' %%B%F{yellow}⬇%f%%b' + zstyle ':prezto:module:git:info:branch' format ':%F{green}%b%f' + zstyle ':prezto:module:git:info:commit' format ':%F{green}%.7c%f' + zstyle ':prezto:module:git:info:deleted' format ' %%B%F{red}✖%f%%b' + zstyle ':prezto:module:git:info:modified' format ' %%B%F{blue}✱%f%%b' + zstyle ':prezto:module:git:info:position' format ':%F{red}%p%f' + zstyle ':prezto:module:git:info:renamed' format ' %%B%F{magenta}➜%f%%b' + zstyle ':prezto:module:git:info:stashed' format ' %%B%F{cyan}✭%f%%b' + zstyle ':prezto:module:git:info:unmerged' format ' %%B%F{yellow}═%f%%b' + zstyle ':prezto:module:git:info:untracked' format ' %%B%F{white}◼%f%%b' + zstyle ':prezto:module:git:info:keys' format \ + 'prompt' '%b ' \ + 'rprompt' '%A%B%S%a%d%m%r%U%u' + + + + PROMPT='' + PROMPT=$PROMPT'${git_info:+${(e)git_info[prompt]}}' + PROMPT=$PROMPT'%(?.%F{$COLOR_PROMPT_STARTER}.%F{red})➤ %f' + + RPROMPT='' + RPROMPT=$RPROMPT'%(?::%F{red}%?%f )' # last command code if nonzero + RPROMPT=$RPROMPT'%B%F{$COLOR_USERNAME}%n%f%b' + RPROMPT=$RPROMPT'%B%F{$COLOR_AT}@%f%b' + RPROMPT=$RPROMPT'%B%F{$COLOR_HOSTNAME}%2m%f%b' + RPROMPT=$RPROMPT'${git_info[rprompt]} ' + RPROMPT=$RPROMPT'%F{$COLOR_TIME}%*%f' +} + +prompt_abra_setup "$@" + diff --git a/.zprezto/init.zsh b/.zprezto/init.zsh index 6b5254f..99254bd 100644 --- a/.zprezto/init.zsh +++ b/.zprezto/init.zsh @@ -10,13 +10,61 @@ # # Check for the minimum supported version. -min_zsh_version='4.3.17' +min_zsh_version='4.3.11' if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then - print "prezto: old shell detected, minimum required: $min_zsh_version" >&2 + printf "prezto: old shell detected, minimum required: %s\n" "$min_zsh_version" >&2 return 1 fi unset min_zsh_version +# zprezto convenience updater +# The function is surrounded by ( ) instead of { } so it starts in a subshell +# and won't affect the environment of the calling shell +function zprezto-update { + ( + function cannot-fast-forward { + local STATUS="$1" + [[ -n "${STATUS}" ]] && printf "%s\n" "${STATUS}" + printf "Unable to fast-forward the changes. You can fix this by " + printf "running\ncd '%s' and then\n'git pull' " "${ZPREZTODIR}" + printf "to manually pull and possibly merge in changes\n" + } + cd -q -- "${ZPREZTODIR}" || return 7 + local orig_branch="$(git symbolic-ref HEAD 2> /dev/null | cut -d '/' -f 3)" + if [[ "$orig_branch" == "master" ]]; then + git fetch || return "$?" + local UPSTREAM=$(git rev-parse '@{u}') + local LOCAL=$(git rev-parse HEAD) + local REMOTE=$(git rev-parse "$UPSTREAM") + local BASE=$(git merge-base HEAD "$UPSTREAM") + if [[ $LOCAL == $REMOTE ]]; then + printf "There are no updates.\n" + return 0 + elif [[ $LOCAL == $BASE ]]; then + printf "There is an update available. Trying to pull.\n\n" + if git pull --ff-only; then + printf "Syncing submodules\n" + git submodule update --recursive + return $? + else + cannot-fast-forward + return 1 + fi + elif [[ $REMOTE == $BASE ]]; then + cannot-fast-forward "Commits in master that aren't in upstream." + return 1 + else + cannot-fast-forward "Upstream and local have diverged." + return 1 + fi + else + printf "zprezto install at '%s' is not on the master branch " "${ZPREZTODIR}" + printf "(you're on '%s')\nUnable to automatically update.\n" "${orig_branch}" + return 1 + fi + return 1 + ) +} # # Module Loader # @@ -24,44 +72,68 @@ unset min_zsh_version # Loads Prezto modules. function pmodload { local -a pmodules + local -a pmodule_dirs + local -a locations local pmodule - local pfunction_glob='^([_.]*|prompt_*_setup|README*)(-.N:t)' + local pmodule_location + local pfunction_glob='^([_.]*|prompt_*_setup|README*|*~)(-.N:t)' + + # Load in any additional directories and warn if they don't exist + zstyle -a ':prezto:load' pmodule-dirs 'user_pmodule_dirs' + for user_dir in "$user_pmodule_dirs[@]"; do + if [[ ! -d "$user_dir" ]]; then + echo "$0: Missing user module dir: $user_dir" + fi + done + + pmodule_dirs=("$ZPREZTODIR/modules" "$ZPREZTODIR/contrib" "$user_pmodule_dirs[@]") # $argv is overridden in the anonymous function. pmodules=("$argv[@]") - # Add functions to $fpath. - fpath=(${pmodules:+${ZDOTDIR:-$HOME}/.zprezto/modules/${^pmodules}/functions(/FN)} $fpath) - - function { - local pfunction - - # Extended globbing is needed for listing autoloadable function directories. - setopt LOCAL_OPTIONS EXTENDED_GLOB - - # Load Prezto functions. - for pfunction in ${ZDOTDIR:-$HOME}/.zprezto/modules/${^pmodules}/functions/$~pfunction_glob; do - autoload -Uz "$pfunction" - done - } - # Load Prezto modules. for pmodule in "$pmodules[@]"; do if zstyle -t ":prezto:module:$pmodule" loaded 'yes' 'no'; then continue - elif [[ ! -d "${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule" ]]; then - print "$0: no such module: $pmodule" >&2 - continue else - if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule/init.zsh" ]]; then - source "${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule/init.zsh" + locations=(${pmodule_dirs:+${^pmodule_dirs}/$pmodule(-/FN)}) + if (( ${#locations} > 1 )); then + print "$0: conflicting module locations: $locations" + continue + elif (( ${#locations} < 1 )); then + print "$0: no such module: $pmodule" + continue + fi + + # Grab the full path to this module + pmodule_location=${locations[1]} + + # Add functions to $fpath. + fpath=(${pmodule_location}/functions(/FN) $fpath) + + function { + local pfunction + + # Extended globbing is needed for listing autoloadable function directories. + setopt LOCAL_OPTIONS EXTENDED_GLOB + + # Load Prezto functions. + for pfunction in ${pmodule_location}/functions/$~pfunction_glob; do + autoload -Uz "$pfunction" + done + } + + if [[ -s "${pmodule_location}/init.zsh" ]]; then + source "${pmodule_location}/init.zsh" + elif [[ -s "${pmodule_location}/${pmodule}.plugin.zsh" ]]; then + source "${pmodule_location}/${pmodule}.plugin.zsh" fi if (( $? == 0 )); then zstyle ":prezto:module:$pmodule" loaded 'yes' else # Remove the $fpath entry. - fpath[(r)${ZDOTDIR:-$HOME}/.zprezto/modules/${pmodule}/functions]=() + fpath[(r)${pmodule_location}/functions]=() function { local pfunction @@ -71,7 +143,7 @@ function pmodload { setopt LOCAL_OPTIONS EXTENDED_GLOB # Unload Prezto functions. - for pfunction in ${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule/functions/$~pfunction_glob; do + for pfunction in ${pmodule_location}/functions/$~pfunction_glob; do unfunction "$pfunction" done } @@ -86,6 +158,12 @@ function pmodload { # Prezto Initialization # +# This finds the directory prezto is installed to so plugin managers don't need +# to rely on dirty hacks to force prezto into a directory. Additionally, it +# needs to be done here because inside the pmodload function ${0:h} evaluates to +# the current directory of the shell rather than the prezto dir. +ZPREZTODIR=${0:h} + # Source the Prezto configuration file. if [[ -s "${ZDOTDIR:-$HOME}/.zpreztorc" ]]; then source "${ZDOTDIR:-$HOME}/.zpreztorc" diff --git a/.zprezto/modules/README.md b/.zprezto/modules/README.md index db851f3..1ff4e61 100644 --- a/.zprezto/modules/README.md +++ b/.zprezto/modules/README.md @@ -3,7 +3,9 @@ Modules Load modules in *zpreztorc*. The order matters. - zstyle ':prezto:load' pmodule 'environment' 'terminal' +```sh +zstyle ':prezto:load' pmodule 'environment' 'terminal' +``` Archive ------- @@ -18,7 +20,7 @@ Integrates zsh-autosuggestions into Prezto. Command-Not-Found ----------------- -Loads the command-not-found tool on Debian-based distributions. +Loads the command-not-found tool on macOS or Debian-based distributions. Completion ---------- @@ -120,7 +122,7 @@ Initializes OCaml package management. OSX --- -Defines Mac OS X aliases and functions. +Defines macOS aliases and functions. Pacman ------ @@ -130,7 +132,7 @@ Provides aliases and functions for the Pacman package manager and frontends. Perl ---- -Enables local Perl module installation on Mac OS X and defines alises. +Enables local Perl module installation on macOS and defines alises. Prompt ------ diff --git a/.zprezto/modules/archive/README.md b/.zprezto/modules/archive/README.md index a1d4901..600ff15 100644 --- a/.zprezto/modules/archive/README.md +++ b/.zprezto/modules/archive/README.md @@ -1,11 +1,12 @@ Archive ======= -Provides functions to list and extract archives. +Provides functions to create, list, and extract archives. Functions --------- + - `archive` creates an archive based on the provided archive name. - `lsarchive` lists the contents of one or more archives. - `unarchive` extracts the contents of one or more archives. @@ -15,8 +16,8 @@ Supported Formats The following archive formats are supported when the required utilities are installed: - - *.tar.gz*, *.tgz* require `tar`. - - *.tar.bz2*, *.tbz* require `tar`. + - *.tar.gz*, *.tgz* require `tar` (optionally `pigz`). + - *.tar.bz2*, *.tbz* require `tar` (optionally `pbzip2`). - *.tar.xz*, *.txz* require `tar` with *xz* support. - *.tar.zma*, *.tlz* require `tar` with *lzma* support. - *.tar* requires `tar`. @@ -25,16 +26,27 @@ installed: - *.xz* requires `unxz`. - *.lzma* requires `unlzma`. - *.Z* requires `uncompress`. - - *.zip* requires `unzip`. - - *.rar* requires `unrar` or `rar`. + - *.zip*, *.jar* requires `unzip`. + - *.rar* requires `rar` (needed for `archive` support), `unrar` or `lsar` and `unar`. - *.7z* requires `7za`. - *.deb* requires `ar`, `tar`. +Additionally, if `pigz` and/or `pbzip2` are installed, `archive` will use them over +their traditional counterparts, `gzip` and `bzip2` respectively, to take full advantage +of all available CPU cores for compression. + +Alternatives +------------ + +Specifically on macOS, [The Unarchiver][1] provides a similar command line tool +which doesn't depend on a number of other programs being installed. + Authors ------- *The authors of this module should be contacted via the [issue tracker][1].* - [Sorin Ionescu](https://github.com/sorin-ionescu) + - [Matt Hamilton](https://github.com/Eriner) -[1]: https://github.com/sorin-ionescu/prezto/issues +[1]: https://theunarchiver.com/command-line diff --git a/.zprezto/modules/archive/functions/_lsarchive b/.zprezto/modules/archive/functions/_lsarchive index 00f83e0..f2cee88 100644 --- a/.zprezto/modules/archive/functions/_lsarchive +++ b/.zprezto/modules/archive/functions/_lsarchive @@ -10,4 +10,4 @@ _arguments \ '(-v --verbose)'{-v,--remove}'[verbose archive listing]' \ - "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|rar|7z)(-.)'" && return 0 + "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|jar|rar|7z)(-.)'" && return 0 diff --git a/.zprezto/modules/archive/functions/_unarchive b/.zprezto/modules/archive/functions/_unarchive index aceb27b..90e32f1 100644 --- a/.zprezto/modules/archive/functions/_unarchive +++ b/.zprezto/modules/archive/functions/_unarchive @@ -10,4 +10,4 @@ _arguments \ '(-r --remove)'{-r,--remove}'[remove archive]' \ - "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|rar|7z|deb)(-.)'" && return 0 + "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|jar|rar|7z|deb)(-.)'" && return 0 diff --git a/.zprezto/modules/archive/functions/archive b/.zprezto/modules/archive/functions/archive new file mode 100644 index 0000000..0e3bb61 --- /dev/null +++ b/.zprezto/modules/archive/functions/archive @@ -0,0 +1,71 @@ +#!/usr/bin/env zsh +# +# Creates archive file +# +# Authors: +# Matt Hamilton +# + +# function archive { + +local archive_name dir_to_archive _gzip_bin _bzip2_bin + +if (( $# != 2 )); then + cat >&2 <&2 + return 1 +fi + +# here, we check for dropin/multi-threaded replacements +# this should eventually be moved to modules/archive/init.zsh +# as a global alias +if (( $+commands[pigz] )); then + _gzip_bin='pigz' +else + _gzip_bin='gzip' +fi + +if (( $+commands[pbzip2] )); then + _bzip2_bin='pbzip2' +else + _bzip2_bin='bzip2' +fi + +case "${archive_name}" in + (*.tar.gz|*.tgz) tar -cvf "${archive_name}" --use-compress-program="${_gzip_bin}" "${dir_to_archive}" ;; + (*.tar.bz2|*.tbz|*.tbz2) tar -cvf "${archive_name}" --use-compress-program="${_bzip2_bin}" "${dir_to_archive}" ;; + (*.tar.xz|*.txz) tar -cvJf "${archive_name}" "${dir_to_archive}" ;; + (*.tar.lzma|*.tlz) tar -cvf "${archive_name}" --lzma "${dir_to_archive}" ;; + (*.tar) tar -cvf "${archive_name}" "${dir_to_archive}" ;; + (*.zip|*.jar) zip -r "${archive_name}" "${dir_to_archive}" ;; + (*.rar) rar a "${archive_name}" "${dir_to_archive}" ;; + (*.7z) 7za a "${archive_name}" "${dir_to_archive}" ;; + (*.gz) print "\n.gz is only useful for single files, and does not capture permissions. Use .tar.gz" ;; + (*.bz2) print "\n.bzip2 is only useful for single files, and does not capture permissions. Use .tar.bz2" ;; + (*.xz) print "\n.xz is only useful for single files, and does not capture permissions. Use .tar.xz" ;; + (*.lzma) print "\n.lzma is only useful for single files, and does not capture permissions. Use .tar.lzma" ;; + (*) print "\nunknown archive type for archive: ${archive_name}" ;; +esac + +# } diff --git a/.zprezto/modules/archive/functions/lsarchive b/.zprezto/modules/archive/functions/lsarchive index 7ac6145..7f892d1 100644 --- a/.zprezto/modules/archive/functions/lsarchive +++ b/.zprezto/modules/archive/functions/lsarchive @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function lsarchive { + local verbose if (( $# == 0 )); then @@ -40,10 +42,12 @@ while (( $# > 0 )); do && tar --lzma -t${verbose:+v}f "$1" \ || lzcat "$1" | tar x${verbose:+v}f - ;; (*.tar) tar t${verbose:+v}f "$1" ;; - (*.zip) unzip -l${verbose:+v} "$1" ;; - (*.rar) unrar &> /dev/null \ - && unrar ${${verbose:+v}:-l} "$1" \ - || rar ${${verbose:+v}:-l} "$1" ;; + (*.zip|*.jar) unzip -l${verbose:+v} "$1" ;; + (*.rar) ( (( $+commands[unrar] )) \ + && unrar ${${verbose:+v}:-l} "$1" ) \ + || ( (( $+commands[rar] )) \ + && rar ${${verbose:+v}:-l} "$1" ) \ + || lsar ${verbose:+-l} "$1" ;; (*.7z) 7za l "$1" ;; (*) print "$0: cannot list: $1" >&2 @@ -53,3 +57,5 @@ while (( $# > 0 )); do shift done + +# } diff --git a/.zprezto/modules/archive/functions/unarchive b/.zprezto/modules/archive/functions/unarchive index 72dfbd1..53a24dd 100644 --- a/.zprezto/modules/archive/functions/unarchive +++ b/.zprezto/modules/archive/functions/unarchive @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function unarchive { + local remove_archive local success local file_name @@ -54,10 +56,12 @@ while (( $# > 0 )); do (*.xz) unxz "$1" ;; (*.lzma) unlzma "$1" ;; (*.Z) uncompress "$1" ;; - (*.zip) unzip "$1" -d $extract_dir ;; - (*.rar) unrar &> /dev/null \ - && unrar x -ad "$1" \ - || rar x -ad "$1" ;; + (*.zip|*.jar) unzip "$1" -d $extract_dir ;; + (*.rar) ( (( $+commands[unrar] )) \ + && unrar x -ad "$1" ) \ + || ( (( $+commands[rar] )) \ + && rar x -ad "$1" ) \ + || unar -d "$1" ;; (*.7z) 7za x "$1" ;; (*.deb) mkdir -p "$extract_dir/control" @@ -78,3 +82,5 @@ while (( $# > 0 )); do (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" shift done + +# } diff --git a/.zprezto/modules/autosuggestions/README.md b/.zprezto/modules/autosuggestions/README.md index 7024379..c3e90a4 100644 --- a/.zprezto/modules/autosuggestions/README.md +++ b/.zprezto/modules/autosuggestions/README.md @@ -11,11 +11,12 @@ Integrates [zsh-autosuggestions][1] into Prezto, which implements the of a previously entered command and Zsh suggests commands as you type based on history and completions. -If this module is used in conjuncture with the *syntax-highlighting* module, it -must be loaded **after** it. +If this module is used in conjunction with the *syntax-highlighting* module, +this module must be loaded **after** the *syntax-highlighting* module. -If this module is used in conjuncture with the *history-substring-search* -module, it must be loaded **after** it. +If this module is used in conjunction with the *history-substring-search* +module, this module must be loaded **after** the *history-substring-search* +module. Contributors ------------ @@ -35,11 +36,23 @@ positive results. To enable highlighting for this module only, add the following line to *zpreztorc*: - zstyle ':prezto:module:autosuggestions' color 'yes' +```sh +zstyle ':prezto:module:autosuggestions' color 'yes' +``` To set the query found color, add the following line to *zpreztorc*: - zstyle ':prezto:module:autosuggestions:color' found '' +```sh +zstyle ':prezto:module:autosuggestions:color' found '' +``` + +Troubleshooting +--------------- + +### Autosuggestions from previous sessions don't show up + +For autosuggestions from previous shell sessions to work, please make sure you +also have the `history` module enabled. Authors ------- diff --git a/.zprezto/modules/autosuggestions/external/.editorconfig_backup b/.zprezto/modules/autosuggestions/external/.editorconfig_backup new file mode 100644 index 0000000..ddabb17 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/.editorconfig_backup @@ -0,0 +1,18 @@ +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab +indent_size = 4 + +[*.md] +indent_style = space + +[*.rb] +indent_style = space +indent_size = 2 + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/.zprezto/modules/autosuggestions/external/.git_backup b/.zprezto/modules/autosuggestions/external/.git_backup new file mode 100644 index 0000000..709b2c6 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/.git_backup @@ -0,0 +1 @@ +gitdir: ../../../.git/modules/modules/autosuggestions/external diff --git a/.zprezto/modules/autosuggestions/external/.rspec_backup b/.zprezto/modules/autosuggestions/external/.rspec_backup new file mode 100644 index 0000000..43ae203 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/.rspec_backup @@ -0,0 +1,3 @@ +--color +--require spec_helper +--format documentation diff --git a/.zprezto/modules/autosuggestions/external/.rubocop.yml_backup b/.zprezto/modules/autosuggestions/external/.rubocop.yml_backup new file mode 100644 index 0000000..97facac --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/.rubocop.yml_backup @@ -0,0 +1,30 @@ +# Rails: +# Enabled: true + +AllCops: + TargetRubyVersion: 2.3 + Include: + - '**/Rakefile' + - '**/config.ru' + - '**/Gemfile' + +Metrics/LineLength: + Max: 120 + +Style/Documentation: + Enabled: false + +Style/DotPosition: + EnforcedStyle: trailing + +Style/FrozenStringLiteralComment: + Enabled: false + +Style/Lambda: + Enabled: false + +Style/MultilineMethodCallIndentation: + EnforcedStyle: indented + +Style/TrailingUnderscoreVariable: + Enabled: false diff --git a/.zprezto/modules/autosuggestions/external/.ruby-version_backup b/.zprezto/modules/autosuggestions/external/.ruby-version_backup new file mode 100644 index 0000000..2bf1c1c --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/.ruby-version_backup @@ -0,0 +1 @@ +2.3.1 diff --git a/.zprezto/modules/autosuggestions/external/CHANGELOG.md b/.zprezto/modules/autosuggestions/external/CHANGELOG.md new file mode 100644 index 0000000..f017be2 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/CHANGELOG.md @@ -0,0 +1,69 @@ +# Changelog + +## v0.4.3 +- Avoid bell when accepting suggestions with `autosuggest-accept` (#228) +- Don't fetch suggestions after [up,down]-line-or-beginning-search (#227, #241) +- We are now running CI against new 5.5.1 version +- Fix partial-accept in vi mode (#188) +- Fix suggestion disappearing on fast movement after switching to `vicmd` mode (#290) +- Fix issue rotating through kill ring with `yank-pop` (#301) +- Fix issue creating new pty for async mode when previous pty is not properly cleaned up (#249) + +## v0.4.2 +- Fix bug in zsh versions older than 5.0.8 (#296) +- Officially support back to zsh v4.3.11 + +## v0.4.1 +- Switch to [[ and (( conditionals instead of [ (#257) +- Avoid warnnestedvar warnings with `typeset -g` (#275) +- Replace tabs with spaces in yaml (#268) +- Clean up and fix escaping of special characters (#267) +- Add `emacs-forward-word` to default list of partial accept widgets (#246) + +## v0.4.0 +- High-level integration tests using RSpec and tmux +- Add continuous integration with Circle CI +- Experimental support for asynchronous suggestions (#170) +- Fix problems with multi-line suggestions (#225) +- Optimize case where manually typing in suggestion +- Avoid wrapping any zle-* widgets (#206) +- Remove support for deprecated options from v0.0.x +- Handle history entries that begin with dashes +- Gracefully handle being sourced multiple times (#126) +- Add enable/disable/toggle widgets to disable/enable suggestions (#219) + + +## v0.3.3 +- Switch from $history array to fc builtin for better performance with large HISTFILEs (#164) +- Fix tilde handling when extended_glob is set (#168) +- Add config option for maximum buffer length to fetch suggestions for (#178) +- Add config option for list of widgets to ignore (#184) +- Don't fetch a new suggestion unless a modification widget actually modifies the buffer (#183) + +## v0.3.2 +- Test runner now supports running specific tests and choosing zsh binary +- Return code from original widget is now correctly passed through (#135) +- Add `vi-add-eol` to list of accept widgets (#143) +- Escapes widget names within evals to fix problems with irregular widget names (#152) +- Plugin now clears suggestion while within a completion menu (#149) +- .plugin file no longer relies on symbolic link support, fixing issues on Windows (#156) + +## v0.3.1 + +- Fixes issue with `vi-next-char` not accepting suggestion (#137). +- Fixes global variable warning when WARN_CREATE_GLOBAL option enabled (#133). +- Split out a separate test file for each widget. + +## v0.3.0 + +- Adds `autosuggest-execute` widget (PR #124). +- Adds concept of suggestion "strategies" for different ways of fetching suggestions. +- Adds "match_prev_cmd" strategy (PR #131). +- Uses git submodules for testing dependencies. +- Lots of test cleanup. +- Various bug fixes for zsh 5.0.x and `sh_word_split` option. + + +## v0.2.17 + +Start of changelog. diff --git a/.zprezto/modules/autosuggestions/external/DESCRIPTION b/.zprezto/modules/autosuggestions/external/DESCRIPTION new file mode 100644 index 0000000..b69200f --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/DESCRIPTION @@ -0,0 +1 @@ +Fish-like fast/unobtrusive autosuggestions for zsh. diff --git a/.zprezto/modules/autosuggestions/external/Gemfile b/.zprezto/modules/autosuggestions/external/Gemfile new file mode 100644 index 0000000..8b5deec --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/Gemfile @@ -0,0 +1,5 @@ +source 'https://rubygems.org' + +gem 'rspec' +gem 'rspec-wait' +gem 'pry-byebug' diff --git a/.zprezto/modules/autosuggestions/external/Gemfile.lock b/.zprezto/modules/autosuggestions/external/Gemfile.lock new file mode 100644 index 0000000..63ee778 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/Gemfile.lock @@ -0,0 +1,41 @@ +GEM + remote: https://rubygems.org/ + specs: + byebug (9.0.5) + coderay (1.1.1) + diff-lcs (1.3) + method_source (0.8.2) + pry (0.10.4) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + pry-byebug (3.4.0) + byebug (~> 9.0) + pry (~> 0.10) + rspec (3.5.0) + rspec-core (~> 3.5.0) + rspec-expectations (~> 3.5.0) + rspec-mocks (~> 3.5.0) + rspec-core (3.5.4) + rspec-support (~> 3.5.0) + rspec-expectations (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-mocks (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-support (3.5.0) + rspec-wait (0.0.9) + rspec (>= 3, < 4) + slop (3.6.0) + +PLATFORMS + ruby + +DEPENDENCIES + pry-byebug + rspec + rspec-wait + +BUNDLED WITH + 1.13.6 diff --git a/.zprezto/modules/autosuggestions/external/INSTALL.md b/.zprezto/modules/autosuggestions/external/INSTALL.md new file mode 100644 index 0000000..945cec7 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/INSTALL.md @@ -0,0 +1,67 @@ +## Installation + +### Manual (Git Clone) + +1. Clone this repository somewhere on your machine. This guide will assume `~/.zsh/zsh-autosuggestions`. + + ```sh + git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions + ``` + +2. Add the following to your `.zshrc`: + + ```sh + source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh + ``` + +3. Start a new terminal session. + +### Oh My Zsh + +1. Clone this repository into `$ZSH_CUSTOM/plugins` (by default `~/.oh-my-zsh/custom/plugins`) + + ```sh + git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions + ``` + +2. Add the plugin to the list of plugins for Oh My Zsh to load: + + ```sh + plugins=(zsh-autosuggestions) + ``` + +3. Start a new terminal session. + +### Arch Linux + +1. Install [`zsh-autosuggestions`](https://www.archlinux.org/packages/community/any/zsh-autosuggestions/) from the `community` repository. + + ```sh + pacman -S zsh-autosuggestions + ``` + + or, to use a package based on the `master` branch, install [`zsh-autosuggestions-git`](https://aur.archlinux.org/packages/zsh-autosuggestions-git/) from the [AUR](https://wiki.archlinux.org/index.php/Arch_User_Repository). + +2. Add the following to your `.zshrc`: + + ```sh + source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh + ``` + +3. Start a new terminal session. + +### macOS via Homebrew +1. Install the `zsh-autosuggestions` package using [Homebrew](https://brew.sh/). + + ```sh + brew install zsh-autosuggestions + ``` + +2. Add the following to your `.zshrc`: + + ```sh + source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh + ``` + +3. Start a new terminal session. + diff --git a/.zprezto/modules/autosuggestions/external/LICENSE b/.zprezto/modules/autosuggestions/external/LICENSE new file mode 100644 index 0000000..bcbc8b9 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2013 Thiago de Arruda +Copyright (c) 2016-2018 Eric Freese + +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/.zprezto/modules/autosuggestions/external/Makefile b/.zprezto/modules/autosuggestions/external/Makefile new file mode 100644 index 0000000..d5d162c --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/Makefile @@ -0,0 +1,36 @@ +SRC_DIR := ./src + +SRC_FILES := \ + $(SRC_DIR)/setup.zsh \ + $(SRC_DIR)/config.zsh \ + $(SRC_DIR)/util.zsh \ + $(SRC_DIR)/features.zsh \ + $(SRC_DIR)/bind.zsh \ + $(SRC_DIR)/highlight.zsh \ + $(SRC_DIR)/widgets.zsh \ + $(SRC_DIR)/strategies/*.zsh \ + $(SRC_DIR)/async.zsh \ + $(SRC_DIR)/start.zsh + +HEADER_FILES := \ + DESCRIPTION \ + URL \ + VERSION \ + LICENSE + +PLUGIN_TARGET := zsh-autosuggestions.zsh + +all: $(PLUGIN_TARGET) + +$(PLUGIN_TARGET): $(HEADER_FILES) $(SRC_FILES) + cat $(HEADER_FILES) | sed -e 's/^/# /g' > $@ + cat $(SRC_FILES) >> $@ + +.PHONY: clean +clean: + rm $(PLUGIN_TARGET) + +.PHONY: test +test: all + @test -n "$$TEST_ZSH_BIN" && echo "Testing zsh binary: $(TEST_ZSH_BIN)" || true + bundle exec rspec $(TESTS) diff --git a/.zprezto/modules/autosuggestions/external/README.md b/.zprezto/modules/autosuggestions/external/README.md new file mode 100644 index 0000000..4ad07d8 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/README.md @@ -0,0 +1,146 @@ +# zsh-autosuggestions + +_[Fish](http://fishshell.com/)-like fast/unobtrusive autosuggestions for zsh._ + +It suggests commands as you type, based on command history. + +Requirements: Zsh v4.3.11 or later + +[![CircleCI](https://circleci.com/gh/zsh-users/zsh-autosuggestions.svg?style=svg)](https://circleci.com/gh/zsh-users/zsh-autosuggestions) + + + + +## Installation + +See [INSTALL.md](INSTALL.md). + + +## Usage + +As you type commands, you will see a completion offered after the cursor in a muted gray color. This color can be changed by setting the `ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE` variable. See [configuration](#configuration). + +If you press the key (`forward-char` widget) or End (`end-of-line` widget) with the cursor at the end of the buffer, it will accept the suggestion, replacing the contents of the command line buffer with the suggestion. + +If you invoke the `forward-word` widget, it will partially accept the suggestion up to the point that the cursor moves to. + + +## Configuration + +You may want to override the default global config variables after sourcing the plugin. Default values of these variables can be found [here](src/config.zsh). + +**Note:** If you are using Oh My Zsh, you can put this configuration in a file in the `$ZSH_CUSTOM` directory. See their comments on [overriding internals](https://github.com/robbyrussell/oh-my-zsh/wiki/Customization#overriding-internals). + + +### Suggestion Highlight Style + +Set `ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE` to configure the style that the suggestion is shown with. The default is `fg=8`. + + +### Suggestion Strategy + +Set `ZSH_AUTOSUGGEST_STRATEGY` to choose the strategy for generating suggestions. There are currently two to choose from: + +- `default`: Chooses the most recent match. +- `match_prev_cmd`: Chooses the most recent match whose preceding history item matches the most recently executed command ([more info](src/strategies/match_prev_cmd.zsh)). Note that this strategy won't work as expected with ZSH options that don't preserve the history order such as `HIST_IGNORE_ALL_DUPS` or `HIST_EXPIRE_DUPS_FIRST`. + + +### Widget Mapping + +This plugin works by triggering custom behavior when certain [zle widgets](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Widgets) are invoked. You can add and remove widgets from these arrays to change the behavior of this plugin: + +- `ZSH_AUTOSUGGEST_CLEAR_WIDGETS`: Widgets in this array will clear the suggestion when invoked. +- `ZSH_AUTOSUGGEST_ACCEPT_WIDGETS`: Widgets in this array will accept the suggestion when invoked. +- `ZSH_AUTOSUGGEST_EXECUTE_WIDGETS`: Widgets in this array will execute the suggestion when invoked. +- `ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS`: Widgets in this array will partially accept the suggestion when invoked. +- `ZSH_AUTOSUGGEST_IGNORE_WIDGETS`: Widgets in this array will not trigger any custom behavior. + +Widgets that modify the buffer and are not found in any of these arrays will fetch a new suggestion after they are invoked. + +**Note:** A widget shouldn't belong to more than one of the above arrays. + + +### Disabling suggestion for large buffers + +Set `ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE` to an integer value to disable autosuggestion for large buffers. The default is unset, which means that autosuggestion will be tried for any buffer size. Recommended value is 20. +This can be useful when pasting large amount of text in the terminal, to avoid triggering autosuggestion for too long strings. + +### Enable Asynchronous Mode + +As of `v0.4.0`, suggestions can be fetched asynchronously using the `zsh/zpty` module. To enable this behavior, set the `ZSH_AUTOSUGGEST_USE_ASYNC` variable (it can be set to anything). + + +### Key Bindings + +This plugin provides a few widgets that you can use with `bindkey`: + +1. `autosuggest-accept`: Accepts the current suggestion. +2. `autosuggest-execute`: Accepts and executes the current suggestion. +3. `autosuggest-clear`: Clears the current suggestion. +4. `autosuggest-fetch`: Fetches a suggestion (works even when suggestions are disabled). +5. `autosuggest-disable`: Disables suggestions. +6. `autosuggest-enable`: Re-enables suggestions. +7. `autosuggest-toggle`: Toggles between enabled/disabled suggestions. + +For example, this would bind ctrl + space to accept the current suggestion. + +```sh +bindkey '^ ' autosuggest-accept +``` + + +## Troubleshooting + +If you have a problem, please search through [the list of issues on GitHub](https://github.com/zsh-users/zsh-autosuggestions/issues) to see if someone else has already reported it. + + +### Reporting an Issue + +Before reporting an issue, please try temporarily disabling sections of your configuration and other plugins that may be conflicting with this plugin to isolate the problem. + +When reporting an issue, please include: + +- The smallest, simplest `.zshrc` configuration that will reproduce the problem. See [this comment](https://github.com/zsh-users/zsh-autosuggestions/issues/102#issuecomment-180944764) for a good example of what this means. +- The version of zsh you're using (`zsh --version`) +- Which operating system you're running + + +## Uninstallation + +1. Remove the code referencing this plugin from `~/.zshrc`. + +2. Remove the git repository from your hard drive + + ```sh + rm -rf ~/.zsh/zsh-autosuggestions # Or wherever you installed + ``` + + +## Development + +### Build Process + +Edit the source files in `src/`. Run `make` to build `zsh-autosuggestions.zsh` from those source files. + + +### Pull Requests + +Pull requests are welcome! If you send a pull request, please: + +- Request to merge into the `develop` branch (*NOT* `master`) +- Match the existing coding conventions. +- Include helpful comments to keep the barrier-to-entry low for people new to the project. +- Write tests that cover your code as much as possible. + + +### Testing + +Tests are written in ruby using the [`rspec`](http://rspec.info/) framework. They use [`tmux`](https://tmux.github.io/) to drive a pseudoterminal, sending simulated keystrokes and making assertions on the terminal content. + +Test files live in `spec/`. To run the tests, run `make test`. To run a specific test, run `TESTS=spec/some_spec.rb make test`. You can also specify a `zsh` binary to use by setting the `TEST_ZSH_BIN` environment variable (ex: `TEST_ZSH_BIN=/bin/zsh make test`). + + +## License + +This project is licensed under [MIT license](http://opensource.org/licenses/MIT). +For the full text of the license, see the [LICENSE](LICENSE) file. diff --git a/.zprezto/modules/autosuggestions/external/URL b/.zprezto/modules/autosuggestions/external/URL new file mode 100644 index 0000000..4e2bd94 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/URL @@ -0,0 +1 @@ +https://github.com/zsh-users/zsh-autosuggestions diff --git a/.zprezto/modules/autosuggestions/external/VERSION b/.zprezto/modules/autosuggestions/external/VERSION new file mode 100644 index 0000000..f87d474 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/VERSION @@ -0,0 +1 @@ +v0.4.3 diff --git a/.zprezto/modules/autosuggestions/external/circle.yml b/.zprezto/modules/autosuggestions/external/circle.yml new file mode 100644 index 0000000..c804ae1 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/circle.yml @@ -0,0 +1,12 @@ +machine: + environment: + ZSH_VERSIONS: zsh-dev/4.3.11 zsh/5.0.2 zsh/5.0.8 zsh/5.1.1 zsh/5.2 zsh/5.3.1 zsh/5.4.2 zsh/5.5.1 + +dependencies: + pre: + - for v in $(echo $ZSH_VERSIONS | awk "{ for (i=$((1+CIRCLE_NODE_INDEX));i<=NF;i+=$CIRCLE_NODE_TOTAL) print \$i }"); do wget https://sourceforge.net/projects/zsh/files/$v/zsh-${v#*/}.tar.gz && tar xzf zsh-${v#*/}.tar.gz && pushd zsh-${v#*/} && ./configure && sudo make install && popd || exit 1; done + +test: + override: + - for v in $(echo $ZSH_VERSIONS | awk "{ for (i=$((1+CIRCLE_NODE_INDEX));i<=NF;i+=$CIRCLE_NODE_TOTAL) print \$i }"); do TEST_ZSH_BIN=/usr/local/bin/zsh-${v#*/} make test || exit 1; done: + parallel: true diff --git a/.zprezto/modules/autosuggestions/external/spec/async_spec.rb b/.zprezto/modules/autosuggestions/external/spec/async_spec.rb new file mode 100644 index 0000000..0bcbaa1 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/async_spec.rb @@ -0,0 +1,41 @@ +context 'with asynchronous suggestions enabled' do + let(:options) { ["ZSH_AUTOSUGGEST_USE_ASYNC="] } + + describe '`up-line-or-beginning-search`' do + let(:before_sourcing) do + -> do + session. + run_command('autoload -U up-line-or-beginning-search'). + run_command('zle -N up-line-or-beginning-search'). + send_string('bindkey "'). + send_keys('C-v').send_keys('up'). + send_string('" up-line-or-beginning-search'). + send_keys('enter') + end + end + + it 'should show previous history entries' do + with_history( + 'echo foo', + 'echo bar', + 'echo baz' + ) do + session.clear_screen + 3.times { session.send_keys('up') } + wait_for { session.content }.to eq("echo foo") + end + end + end + + describe 'exiting a subshell' do + it 'should not cause error messages to be printed' do + session.run_command('$(exit)') + + sleep 1 + + expect(session.content).to eq('$(exit)') + end + end +end + + diff --git a/.zprezto/modules/autosuggestions/external/spec/integrations/bracketed_paste_magic_spec.rb b/.zprezto/modules/autosuggestions/external/spec/integrations/bracketed_paste_magic_spec.rb new file mode 100644 index 0000000..64092ad --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/integrations/bracketed_paste_magic_spec.rb @@ -0,0 +1,27 @@ +describe 'pasting using bracketed-paste-magic' do + let(:before_sourcing) do + -> do + session. + run_command('autoload -Uz bracketed-paste-magic'). + run_command('zle -N bracketed-paste bracketed-paste-magic') + end + end + + context 'with suggestions disabled while pasting' do + before do + session. + run_command('bpm_init() { zle autosuggest-disable }'). + run_command('bpm_finish() { zle autosuggest-enable }'). + run_command('zstyle :bracketed-paste-magic paste-init bpm_init'). + run_command('zstyle :bracketed-paste-magic paste-finish bpm_finish') + end + + it 'does not show an incorrect suggestion' do + with_history('echo hello') do + session.paste_string("echo #{'a' * 60}") + sleep 1 + expect(session.content).to eq("echo #{'a' * 60}") + end + end + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/integrations/client_zpty_spec.rb b/.zprezto/modules/autosuggestions/external/spec/integrations/client_zpty_spec.rb new file mode 100644 index 0000000..8f1550e --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/integrations/client_zpty_spec.rb @@ -0,0 +1,10 @@ +describe 'a running zpty command' do + let(:before_sourcing) { -> { session.run_command('zmodload zsh/zpty && zpty -b kitty cat') } } + + it 'is not affected by running zsh-autosuggestions' do + sleep 1 # Give a little time for precmd hooks to run + session.run_command('zpty -t kitty; echo $?') + + wait_for { session.content }.to end_with("\n0") + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/integrations/rebound_bracket_spec.rb b/.zprezto/modules/autosuggestions/external/spec/integrations/rebound_bracket_spec.rb new file mode 100644 index 0000000..8b420f0 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/integrations/rebound_bracket_spec.rb @@ -0,0 +1,13 @@ +describe 'rebinding [' do + context 'initialized before sourcing the plugin' do + before do + session.run_command("function [ { $commands[\\[] \"$@\" }") + session.clear_screen + end + + it 'executes the custom behavior and the built-in behavior' do + session.send_string('asdf') + wait_for { session.content }.to eq('asdf') + end + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/integrations/vi_mode_spec.rb b/.zprezto/modules/autosuggestions/external/spec/integrations/vi_mode_spec.rb new file mode 100644 index 0000000..cf471b5 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/integrations/vi_mode_spec.rb @@ -0,0 +1,67 @@ +describe 'when using vi mode' do + let(:before_sourcing) do + -> do + session.run_command('bindkey -v') + end + end + + describe 'moving the cursor after exiting insert mode' do + it 'should not clear the current suggestion' do + with_history('foobar foo') do + session. + send_string('foo'). + send_keys('escape'). + send_keys('h') + + wait_for { session.content }.to eq('foobar foo') + end + end + end + + describe '`vi-forward-word-end`' do + it 'should accept through the end of the current word' do + with_history('foobar foo') do + session. + send_string('foo'). + send_keys('escape'). + send_keys('e'). # vi-forward-word-end + send_keys('a'). # vi-add-next + send_string('baz') + + wait_for { session.content }.to eq('foobarbaz') + end + end + end + + describe '`vi-forward-word`' do + it 'should accept through the first character of the next word' do + with_history('foobar foo') do + session. + send_string('foo'). + send_keys('escape'). + send_keys('w'). # vi-forward-word + send_keys('a'). # vi-add-next + send_string('az') + + wait_for { session.content }.to eq('foobar faz') + end + end + end + + describe '`vi-find-next-char`' do + it 'should accept through the next occurrence of the character' do + with_history('foobar foo') do + session. + send_string('foo'). + send_keys('escape'). + send_keys('f'). # vi-find-next-char + send_keys('o'). + send_keys('a'). # vi-add-next + send_string('b') + + wait_for { session.content }.to eq('foobar fob') + end + end + end +end + diff --git a/.zprezto/modules/autosuggestions/external/spec/integrations/wrapped_widget_spec.rb b/.zprezto/modules/autosuggestions/external/spec/integrations/wrapped_widget_spec.rb new file mode 100644 index 0000000..61dfc2d --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/integrations/wrapped_widget_spec.rb @@ -0,0 +1,39 @@ +describe 'a wrapped widget' do + let(:widget) { 'backward-delete-char' } + + context 'initialized before sourcing the plugin' do + let(:before_sourcing) do + -> do + session. + run_command("_orig_#{widget}() { zle .#{widget} }"). + run_command("zle -N orig-#{widget} _orig_#{widget}"). + run_command("#{widget}-magic() { zle orig-#{widget}; BUFFER+=b }"). + run_command("zle -N #{widget} #{widget}-magic") + end + end + + it 'executes the custom behavior and the built-in behavior' do + with_history('foobar', 'foodar') do + session.send_string('food').send_keys('C-h') + wait_for { session.content }.to eq('foobar') + end + end + end + + context 'initialized after sourcing the plugin' do + before do + session. + run_command("zle -N orig-#{widget} ${widgets[#{widget}]#*:}"). + run_command("#{widget}-magic() { zle orig-#{widget}; BUFFER+=b }"). + run_command("zle -N #{widget} #{widget}-magic"). + clear_screen + end + + it 'executes the custom behavior and the built-in behavior' do + with_history('foobar', 'foodar') do + session.send_string('food').send_keys('C-h') + wait_for { session.content }.to eq('foobar') + end + end + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/integrations/zle_input_stack_spec.rb b/.zprezto/modules/autosuggestions/external/spec/integrations/zle_input_stack_spec.rb new file mode 100644 index 0000000..8a2c990 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/integrations/zle_input_stack_spec.rb @@ -0,0 +1,24 @@ +describe 'using `zle -U`' do + let(:before_sourcing) do + -> do + session. + run_command('_zsh_autosuggest_strategy_test() { sleep 1; _zsh_autosuggest_strategy_default "$1" }'). + run_command('foo() { zle -U - "echo hello" }; zle -N foo; bindkey ^B foo') + end + end + + let(:options) { ['unset ZSH_AUTOSUGGEST_USE_ASYNC', 'ZSH_AUTOSUGGEST_STRATEGY=test'] } + + # TODO: This is only possible with the $KEYS_QUEUED_COUNT widget parameter, coming soon... + xit 'does not fetch a suggestion for every inserted character' do + session.send_keys('C-b') + wait_for { session.content }.to eq('echo hello') + end + + it 'shows a suggestion when the widget completes' do + with_history('echo hello world') do + session.send_keys('C-b') + wait_for { session.content(esc_seqs: true) }.to match(/\Aecho hello\e\[[0-9]+m world/) + end + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/kill_ring_spec.rb b/.zprezto/modules/autosuggestions/external/spec/kill_ring_spec.rb new file mode 100644 index 0000000..4d0178f --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/kill_ring_spec.rb @@ -0,0 +1,23 @@ +context 'with some items in the kill ring' do + before do + session. + send_string('echo foo'). + send_keys('C-u'). + send_string('echo bar'). + send_keys('C-u') + end + + describe '`yank-pop`' do + it 'should cycle through all items in the kill ring' do + session.send_keys('C-y') + wait_for { session.content }.to eq('echo bar') + + session.send_keys('escape').send_keys('y') + wait_for { session.content }.to eq('echo foo') + + session.send_keys('escape').send_keys('y') + wait_for { session.content }.to eq('echo bar') + end + end +end + diff --git a/.zprezto/modules/autosuggestions/external/spec/multi_line_spec.rb b/.zprezto/modules/autosuggestions/external/spec/multi_line_spec.rb new file mode 100644 index 0000000..4ff2ae1 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/multi_line_spec.rb @@ -0,0 +1,13 @@ +describe 'a multi-line suggestion' do + it 'should be displayed on multiple lines' do + with_history(-> { + session.send_string('echo "') + session.send_keys('enter') + session.send_string('"') + session.send_keys('enter') + }) do + session.send_keys('e') + wait_for { session.content }.to eq("echo \"\n\"") + end + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/options/async_zpty_name_spec.rb b/.zprezto/modules/autosuggestions/external/spec/options/async_zpty_name_spec.rb new file mode 100644 index 0000000..407ee70 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/options/async_zpty_name_spec.rb @@ -0,0 +1,19 @@ +context 'when async suggestions are enabled' do + let(:options) { ["ZSH_AUTOSUGGEST_USE_ASYNC="] } + + describe 'the zpty for async suggestions' do + it 'is created with the default name' do + session.run_command('zpty -t zsh_autosuggest_pty &>/dev/null; echo $?') + wait_for { session.content }.to end_with("\n0") + end + + context 'when ZSH_AUTOSUGGEST_ASYNC_PTY_NAME is set' do + let(:options) { super() + ['ZSH_AUTOSUGGEST_ASYNC_PTY_NAME=foo_pty'] } + + it 'is created with the specified name' do + session.run_command('zpty -t foo_pty &>/dev/null; echo $?') + wait_for { session.content }.to end_with("\n0") + end + end + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/options/buffer_max_size_spec.rb b/.zprezto/modules/autosuggestions/external/spec/options/buffer_max_size_spec.rb new file mode 100644 index 0000000..29ca8bc --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/options/buffer_max_size_spec.rb @@ -0,0 +1,30 @@ +describe 'a suggestion' do + let(:term_opts) { { width: 200 } } + let(:long_command) { "echo #{'a' * 100}" } + + around do |example| + with_history(long_command) { example.run } + end + + it 'is provided for any buffer length' do + session.send_string(long_command[0...-1]) + wait_for { session.content }.to eq(long_command) + end + + context 'when ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE is specified' do + let(:buffer_max_size) { 10 } + let(:options) { ["ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=#{buffer_max_size}"] } + + it 'is provided when the buffer is shorter than the specified length' do + session.send_string(long_command[0...(buffer_max_size - 1)]) + wait_for { session.content }.to eq(long_command) + end + + it 'is provided when the buffer is equal to the specified length' do + session.send_string(long_command[0...(buffer_max_size)]) + wait_for { session.content }.to eq(long_command) + end + + it 'is not provided when the buffer is longer than the specified length' + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/options/highlight_style_spec.rb b/.zprezto/modules/autosuggestions/external/spec/options/highlight_style_spec.rb new file mode 100644 index 0000000..a7e39b3 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/options/highlight_style_spec.rb @@ -0,0 +1,7 @@ +describe 'a displayed suggestion' do + it 'is shown in the default style' + + describe 'when ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE is set to a zle_highlight string' do + it 'is shown in the specified style' + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/options/original_widget_prefix_spec.rb b/.zprezto/modules/autosuggestions/external/spec/options/original_widget_prefix_spec.rb new file mode 100644 index 0000000..a4b6e98 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/options/original_widget_prefix_spec.rb @@ -0,0 +1,7 @@ +describe 'an original zle widget' do + context 'is accessible with the default prefix' + + context 'when ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX is set' do + it 'is accessible with the specified prefix' + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/options/strategy_spec.rb b/.zprezto/modules/autosuggestions/external/spec/options/strategy_spec.rb new file mode 100644 index 0000000..c9f01e1 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/options/strategy_spec.rb @@ -0,0 +1,20 @@ +describe 'a suggestion for a given prefix' do + let(:options) { ['_zsh_autosuggest_strategy_default() { suggestion="echo foo" }'] } + + it 'is determined by calling the default strategy function' do + session.send_string('e') + wait_for { session.content }.to eq('echo foo') + end + + context 'when ZSH_AUTOSUGGEST_STRATEGY is set' do + let(:options) { [ + '_zsh_autosuggest_strategy_custom() { suggestion="echo foo" }', + 'ZSH_AUTOSUGGEST_STRATEGY=custom' + ] } + + it 'is determined by calling the specified strategy function' do + session.send_string('e') + wait_for { session.content }.to eq('echo foo') + end + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/options/use_async_spec.rb b/.zprezto/modules/autosuggestions/external/spec/options/use_async_spec.rb new file mode 100644 index 0000000..420dcc3 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/options/use_async_spec.rb @@ -0,0 +1,7 @@ +describe 'suggestion fetching' do + it 'is performed synchronously' + + context 'when ZSH_AUTOSUGGEST_USE_ASYNC is set' do + it 'is performed asynchronously' + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/options/widget_lists_spec.rb b/.zprezto/modules/autosuggestions/external/spec/options/widget_lists_spec.rb new file mode 100644 index 0000000..c207c0c --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/options/widget_lists_spec.rb @@ -0,0 +1,97 @@ +describe 'a zle widget' do + let(:widget) { 'my-widget' } + let(:before_sourcing) { -> { session.run_command("#{widget}() {}; zle -N #{widget}; bindkey ^B #{widget}") } } + + context 'when added to ZSH_AUTOSUGGEST_ACCEPT_WIDGETS' do + let(:options) { ["ZSH_AUTOSUGGEST_ACCEPT_WIDGETS+=(#{widget})"] } + + it 'accepts the suggestion when invoked' do + with_history('echo hello') do + session.send_string('e') + wait_for { session.content }.to eq('echo hello') + session.send_keys('C-b') + wait_for { session.content(esc_seqs: true) }.to eq('echo hello') + end + end + end + + context 'when added to ZSH_AUTOSUGGEST_CLEAR_WIDGETS' do + let(:options) { ["ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(#{widget})"] } + + it 'clears the suggestion when invoked' do + with_history('echo hello') do + session.send_string('e') + wait_for { session.content }.to eq('echo hello') + session.send_keys('C-b') + wait_for { session.content }.to eq('e') + end + end + end + + context 'when added to ZSH_AUTOSUGGEST_EXECUTE_WIDGETS' do + let(:options) { ["ZSH_AUTOSUGGEST_EXECUTE_WIDGETS+=(#{widget})"] } + + it 'executes the suggestion when invoked' do + with_history('echo hello') do + session.send_string('e') + wait_for { session.content }.to eq('echo hello') + session.send_keys('C-b') + wait_for { session.content }.to end_with("\nhello") + end + end + end + + context 'when added to ZSH_AUTOSUGGEST_IGNORE_WIDGETS' do + let(:options) { ["ZSH_AUTOSUGGEST_IGNORE_WIDGETS=(#{widget})"] } + + it 'should not be wrapped with an autosuggest widget' do + session.run_command("echo $widgets[#{widget}]") + wait_for { session.content }.to end_with("\nuser:#{widget}") + end + end + + context 'that moves the cursor forward' do + before { session.run_command("#{widget}() { zle forward-char }") } + + context 'when added to ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS' do + let(:options) { ["ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(#{widget})"] } + + it 'accepts the suggestion as far as the cursor is moved when invoked' do + with_history('echo hello') do + session.send_string('e') + wait_for { session.content }.to start_with('echo hello') + session.send_keys('C-b') + wait_for { session.content(esc_seqs: true) }.to match(/\Aec\e\[[0-9]+mho hello/) + end + end + end + end + + context 'that modifies the buffer' do + before { session.run_command("#{widget}() { BUFFER=\"foo\" }") } + + context 'when not added to any of the widget lists' do + it 'modifies the buffer and fetches a new suggestion' do + with_history('foobar') do + session.send_keys('C-b') + wait_for { session.content }.to eq('foobar') + end + end + end + end +end + +describe 'a modification to the widget lists' do + let(:widget) { 'my-widget' } + let(:before_sourcing) { -> { session.run_command("#{widget}() {}; zle -N #{widget}; bindkey ^B #{widget}") } } + before { session.run_command("ZSH_AUTOSUGGEST_ACCEPT_WIDGETS+=(#{widget})") } + + it 'takes effect on the next cmd line' do + with_history('echo hello') do + session.send_string('e') + wait_for { session.content }.to eq('echo hello') + session.send_keys('C-b') + wait_for { session.content(esc_seqs: true) }.to eq('echo hello') + end + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/spec_helper.rb b/.zprezto/modules/autosuggestions/external/spec/spec_helper.rb new file mode 100644 index 0000000..64115d2 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/spec_helper.rb @@ -0,0 +1,50 @@ +require 'pry' +require 'rspec/wait' +require 'terminal_session' + +RSpec.shared_context 'terminal session' do + let(:term_opts) { {} } + let(:session) { TerminalSession.new(term_opts) } + let(:before_sourcing) { -> {} } + let(:options) { [] } + + around do |example| + before_sourcing.call + + session.run_command((['source zsh-autosuggestions.zsh'] + options).join('; ')) + session.clear_screen + + example.run + + session.destroy + end + + def with_history(*commands, &block) + session.run_command('fc -p') + + commands.each do |c| + c.respond_to?(:call) ? c.call : session.run_command(c) + end + + session.clear_screen + + yield block + + session.send_keys('C-c') + session.run_command('fc -P') + end +end + +RSpec.configure do |config| + config.expect_with :rspec do |expectations| + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + config.mock_with :rspec do |mocks| + mocks.verify_partial_doubles = true + end + + config.wait_timeout = 2 + + config.include_context 'terminal session' +end diff --git a/.zprezto/modules/autosuggestions/external/spec/strategies/default_spec.rb b/.zprezto/modules/autosuggestions/external/spec/strategies/default_spec.rb new file mode 100644 index 0000000..89321f3 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/strategies/default_spec.rb @@ -0,0 +1,12 @@ +require 'strategies/special_characters_helper' + +describe 'the default suggestion strategy' do + it 'suggests the last matching history entry' do + with_history('ls foo', 'ls bar', 'echo baz') do + session.send_string('ls') + wait_for { session.content }.to eq('ls bar') + end + end + + include_examples 'special characters' +end diff --git a/.zprezto/modules/autosuggestions/external/spec/strategies/match_prev_cmd_spec.rb b/.zprezto/modules/autosuggestions/external/spec/strategies/match_prev_cmd_spec.rb new file mode 100644 index 0000000..f1596ba --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/strategies/match_prev_cmd_spec.rb @@ -0,0 +1,21 @@ +require 'strategies/special_characters_helper' + +describe 'the match_prev_cmd strategy' do + let(:options) { ['ZSH_AUTOSUGGEST_STRATEGY=match_prev_cmd'] } + + it 'suggests the last matching history entry after the previous command' do + with_history( + 'echo what', + 'ls foo', + 'echo what', + 'ls bar', + 'ls baz', + 'echo what' + ) do + session.send_string('ls') + wait_for { session.content }.to eq('ls bar') + end + end + + include_examples 'special characters' +end diff --git a/.zprezto/modules/autosuggestions/external/spec/strategies/special_characters_helper.rb b/.zprezto/modules/autosuggestions/external/spec/strategies/special_characters_helper.rb new file mode 100644 index 0000000..8771861 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/strategies/special_characters_helper.rb @@ -0,0 +1,62 @@ +shared_examples 'special characters' do + describe 'a special character in the buffer' do + it 'should be treated like any other character' do + with_history('echo "hello*"', 'echo "hello."') do + session.send_string('echo "hello*') + wait_for { session.content }.to eq('echo "hello*"') + end + + with_history('echo "hello?"', 'echo "hello."') do + session.send_string('echo "hello?') + wait_for { session.content }.to eq('echo "hello?"') + end + + with_history('echo "hello\nworld"') do + session.send_string('echo "hello\\') + wait_for { session.content }.to eq('echo "hello\nworld"') + end + + with_history('echo "\\\\"') do + session.send_string('echo "\\\\') + wait_for { session.content }.to eq('echo "\\\\"') + end + + with_history('echo ~/foo') do + session.send_string('echo ~') + wait_for { session.content }.to eq('echo ~/foo') + end + + with_history('echo "$(ls foo)"') do + session.send_string('echo "$(') + wait_for { session.content }.to eq('echo "$(ls foo)"') + end + + with_history('echo "$history[123]"') do + session.send_string('echo "$history[') + wait_for { session.content }.to eq('echo "$history[123]"') + session.send_string('123]') + wait_for { session.content }.to eq('echo "$history[123]"') + end + + with_history('echo "#yolo"') do + session.send_string('echo "#') + wait_for { session.content }.to eq('echo "#yolo"') + end + + with_history('echo "#foo"', 'echo $#abc') do + session.send_string('echo "#') + wait_for { session.content }.to eq('echo "#foo"') + end + + with_history('echo "^A"', 'echo "^B"') do + session.send_string('echo "^A') + wait_for { session.content }.to eq('echo "^A"') + end + + with_history('-foo() {}') do + session.send_string('-') + wait_for { session.content }.to eq('-foo() {}') + end + end + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/terminal_session.rb b/.zprezto/modules/autosuggestions/external/spec/terminal_session.rb new file mode 100644 index 0000000..2d9468f --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/terminal_session.rb @@ -0,0 +1,95 @@ +require 'securerandom' + +class TerminalSession + ZSH_BIN = ENV['TEST_ZSH_BIN'] || 'zsh' + + def initialize(opts = {}) + opts = { + width: 80, + height: 24, + prompt: '', + term: 'xterm-256color', + zsh_bin: ZSH_BIN + }.merge(opts) + + @opts = opts + + cmd="PS1=\"#{opts[:prompt]}\" TERM=#{opts[:term]} #{ZSH_BIN} -f" + tmux_command("new-session -d -x #{opts[:width]} -y #{opts[:height]} '#{cmd}'") + end + + def tmux_socket_name + @tmux_socket_name ||= SecureRandom.hex(6) + end + + def run_command(command) + send_string(command) + send_keys('enter') + + self + end + + def send_string(str) + tmux_command("send-keys -t 0 -l -- '#{str.gsub("'", "\\'")}'") + + self + end + + def send_keys(*keys) + tmux_command("send-keys -t 0 #{keys.join(' ')}") + + self + end + + def paste_string(str) + tmux_command("set-buffer -- '#{str}'") + tmux_command("paste-buffer -dpr -t 0") + + self + end + + def content(esc_seqs: false) + cmd = 'capture-pane -p -t 0' + cmd += ' -e' if esc_seqs + tmux_command(cmd).strip + end + + def clear_screen + send_keys('C-l') + + i = 0 + until content == opts[:prompt] || i > 20 do + sleep(0.1) + i = i + 1 + end + + self + end + + def destroy + tmux_command('kill-session') + end + + def cursor + tmux_command("display-message -t 0 -p '\#{cursor_x},\#{cursor_y}'"). + strip. + split(','). + map(&:to_i) + end + + def attach! + tmux_command('attach-session') + end + + private + + attr_reader :opts + + def tmux_command(cmd) + out = `tmux -u -L #{tmux_socket_name} #{cmd}` + + raise("tmux error running: '#{cmd}'") unless $?.success? + + out + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/widgets/disable_spec.rb b/.zprezto/modules/autosuggestions/external/spec/widgets/disable_spec.rb new file mode 100644 index 0000000..b387a59 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/widgets/disable_spec.rb @@ -0,0 +1,19 @@ +describe 'the `autosuggest-disable` widget' do + before do + session.run_command('bindkey ^B autosuggest-disable') + end + + it 'disables suggestions and clears the suggestion' do + with_history('echo hello') do + session.send_string('echo') + wait_for { session.content }.to eq('echo hello') + + session.send_keys('C-b') + wait_for { session.content }.to eq('echo') + + session.send_string(' h') + sleep 1 + expect(session.content).to eq('echo h') + end + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/widgets/enable_spec.rb b/.zprezto/modules/autosuggestions/external/spec/widgets/enable_spec.rb new file mode 100644 index 0000000..3ad35a8 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/widgets/enable_spec.rb @@ -0,0 +1,42 @@ +describe 'the `autosuggest-enable` widget' do + before do + session. + run_command('typeset -g _ZSH_AUTOSUGGEST_DISABLED'). + run_command('bindkey ^B autosuggest-enable') + end + + it 'enables suggestions and fetches a suggestion' do + with_history('echo hello') do + session.send_string('e') + sleep 1 + expect(session.content).to eq('e') + + session.send_keys('C-b') + session.send_string('c') + wait_for { session.content }.to eq('echo hello') + end + end + + context 'invoked on an empty buffer' do + it 'does not fetch a suggestion' do + with_history('echo hello') do + session.send_keys('C-b') + sleep 1 + expect(session.content).to eq('') + end + end + end + + context 'invoked on a non-empty buffer' do + it 'fetches a suggestion' do + with_history('echo hello') do + session.send_string('e') + sleep 1 + expect(session.content).to eq('e') + + session.send_keys('C-b') + wait_for { session.content }.to eq('echo hello') + end + end + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/widgets/fetch_spec.rb b/.zprezto/modules/autosuggestions/external/spec/widgets/fetch_spec.rb new file mode 100644 index 0000000..eb8f2ba --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/widgets/fetch_spec.rb @@ -0,0 +1,24 @@ +describe 'the `autosuggest-fetch` widget' do + context 'when suggestions are disabled' do + before do + session. + run_command('bindkey ^B autosuggest-disable'). + run_command('bindkey ^F autosuggest-fetch'). + send_keys('C-b') + end + + it 'will fetch and display a suggestion' do + with_history('echo hello') do + session.send_string('echo h') + sleep 1 + expect(session.content).to eq('echo h') + + session.send_keys('C-f') + wait_for { session.content }.to eq('echo hello') + + session.send_string('e') + wait_for { session.content }.to eq('echo hello') + end + end + end +end diff --git a/.zprezto/modules/autosuggestions/external/spec/widgets/toggle_spec.rb b/.zprezto/modules/autosuggestions/external/spec/widgets/toggle_spec.rb new file mode 100644 index 0000000..8f9f3c3 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/spec/widgets/toggle_spec.rb @@ -0,0 +1,26 @@ +describe 'the `autosuggest-toggle` widget' do + before do + session.run_command('bindkey ^B autosuggest-toggle') + end + + it 'toggles suggestions' do + with_history('echo world', 'echo hello') do + session.send_string('echo') + wait_for { session.content }.to eq('echo hello') + + session.send_keys('C-b') + wait_for { session.content }.to eq('echo') + + session.send_string(' h') + sleep 1 + expect(session.content).to eq('echo h') + + session.send_keys('C-b') + wait_for { session.content }.to eq('echo hello') + + session.send_keys('C-h') + session.send_string('w') + wait_for { session.content }.to eq('echo world') + end + end +end diff --git a/.zprezto/modules/autosuggestions/external/src/async.zsh b/.zprezto/modules/autosuggestions/external/src/async.zsh new file mode 100644 index 0000000..9a0cfaa --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/src/async.zsh @@ -0,0 +1,106 @@ + +#--------------------------------------------------------------------# +# Async # +#--------------------------------------------------------------------# + +# Zpty process is spawned running this function +_zsh_autosuggest_async_server() { + emulate -R zsh + + # There is a bug in zpty module (fixed in zsh/master) by which a + # zpty that exits will kill all zpty processes that were forked + # before it. Here we set up a zsh exit hook to SIGKILL the zpty + # process immediately, before it has a chance to kill any other + # zpty processes. + zshexit() { + kill -KILL $$ + sleep 1 # Block for long enough for the signal to come through + } + + # Output only newlines (not carriage return + newline) + stty -onlcr + + # Silence any error messages + exec 2>/dev/null + + local last_pid + + while IFS='' read -r -d $'\0' query; do + # Kill last bg process + kill -KILL $last_pid &>/dev/null + + # Run suggestion search in the background + ( + local suggestion + _zsh_autosuggest_strategy_$ZSH_AUTOSUGGEST_STRATEGY "$query" + echo -n -E "$suggestion"$'\0' + ) & + + last_pid=$! + done +} + +_zsh_autosuggest_async_request() { + # Write the query to the zpty process to fetch a suggestion + zpty -w -n $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME "${1}"$'\0' +} + +# Called when new data is ready to be read from the pty +# First arg will be fd ready for reading +# Second arg will be passed in case of error +_zsh_autosuggest_async_response() { + setopt LOCAL_OPTIONS EXTENDED_GLOB + + local suggestion + + zpty -rt $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME suggestion '*'$'\0' 2>/dev/null + zle autosuggest-suggest -- "${suggestion%%$'\0'##}" +} + +_zsh_autosuggest_async_pty_create() { + # With newer versions of zsh, REPLY stores the fd to read from + typeset -h REPLY + + # If we won't get a fd back from zpty, try to guess it + if (( ! $_ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD )); then + integer -l zptyfd + exec {zptyfd}>&1 # Open a new file descriptor (above 10). + exec {zptyfd}>&- # Close it so it's free to be used by zpty. + fi + + # Fork a zpty process running the server function + zpty -b $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME _zsh_autosuggest_async_server + + # Store the fd so we can remove the handler later + if (( REPLY )); then + _ZSH_AUTOSUGGEST_PTY_FD=$REPLY + else + _ZSH_AUTOSUGGEST_PTY_FD=$zptyfd + fi + + # Set up input handler from the zpty + zle -F $_ZSH_AUTOSUGGEST_PTY_FD _zsh_autosuggest_async_response +} + +_zsh_autosuggest_async_pty_destroy() { + # Remove the input handler + zle -F $_ZSH_AUTOSUGGEST_PTY_FD &>/dev/null + + # Destroy the zpty + zpty -d $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME &>/dev/null +} + +_zsh_autosuggest_async_pty_recreate() { + _zsh_autosuggest_async_pty_destroy + _zsh_autosuggest_async_pty_create +} + +_zsh_autosuggest_async_start() { + typeset -g _ZSH_AUTOSUGGEST_PTY_FD + + _zsh_autosuggest_feature_detect_zpty_returns_fd + _zsh_autosuggest_async_pty_recreate + + # We recreate the pty to get a fresh list of history events + add-zsh-hook precmd _zsh_autosuggest_async_pty_recreate +} diff --git a/.zprezto/modules/autosuggestions/external/src/bind.zsh b/.zprezto/modules/autosuggestions/external/src/bind.zsh new file mode 100644 index 0000000..42a0dd0 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/src/bind.zsh @@ -0,0 +1,118 @@ + +#--------------------------------------------------------------------# +# Widget Helpers # +#--------------------------------------------------------------------# + +_zsh_autosuggest_incr_bind_count() { + if ((${+_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]})); then + ((_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]++)) + else + _ZSH_AUTOSUGGEST_BIND_COUNTS[$1]=1 + fi + + typeset -gi bind_count=$_ZSH_AUTOSUGGEST_BIND_COUNTS[$1] +} + +_zsh_autosuggest_get_bind_count() { + if ((${+_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]})); then + typeset -gi bind_count=$_ZSH_AUTOSUGGEST_BIND_COUNTS[$1] + else + typeset -gi bind_count=0 + fi +} + +# Bind a single widget to an autosuggest widget, saving a reference to the original widget +_zsh_autosuggest_bind_widget() { + typeset -gA _ZSH_AUTOSUGGEST_BIND_COUNTS + + local widget=$1 + local autosuggest_action=$2 + local prefix=$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX + + local -i bind_count + + # Save a reference to the original widget + case $widgets[$widget] in + # Already bound + user:_zsh_autosuggest_(bound|orig)_*);; + + # User-defined widget + user:*) + _zsh_autosuggest_incr_bind_count $widget + zle -N $prefix${bind_count}-$widget ${widgets[$widget]#*:} + ;; + + # Built-in widget + builtin) + _zsh_autosuggest_incr_bind_count $widget + eval "_zsh_autosuggest_orig_${(q)widget}() { zle .${(q)widget} }" + zle -N $prefix${bind_count}-$widget _zsh_autosuggest_orig_$widget + ;; + + # Completion widget + completion:*) + _zsh_autosuggest_incr_bind_count $widget + eval "zle -C $prefix${bind_count}-${(q)widget} ${${(s.:.)widgets[$widget]}[2,3]}" + ;; + esac + + _zsh_autosuggest_get_bind_count $widget + + # Pass the original widget's name explicitly into the autosuggest + # function. Use this passed in widget name to call the original + # widget instead of relying on the $WIDGET variable being set + # correctly. $WIDGET cannot be trusted because other plugins call + # zle without the `-w` flag (e.g. `zle self-insert` instead of + # `zle self-insert -w`). + eval "_zsh_autosuggest_bound_${bind_count}_${(q)widget}() { + _zsh_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@ + }" + + # Create the bound widget + zle -N $widget _zsh_autosuggest_bound_${bind_count}_$widget +} + +# Map all configured widgets to the right autosuggest widgets +_zsh_autosuggest_bind_widgets() { + local widget + local ignore_widgets + + ignore_widgets=( + .\* + _\* + zle-\* + autosuggest-\* + $ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX\* + $ZSH_AUTOSUGGEST_IGNORE_WIDGETS + ) + + # Find every widget we might want to bind and bind it appropriately + for widget in ${${(f)"$(builtin zle -la)"}:#${(j:|:)~ignore_widgets}}; do + if [[ -n ${ZSH_AUTOSUGGEST_CLEAR_WIDGETS[(r)$widget]} ]]; then + _zsh_autosuggest_bind_widget $widget clear + elif [[ -n ${ZSH_AUTOSUGGEST_ACCEPT_WIDGETS[(r)$widget]} ]]; then + _zsh_autosuggest_bind_widget $widget accept + elif [[ -n ${ZSH_AUTOSUGGEST_EXECUTE_WIDGETS[(r)$widget]} ]]; then + _zsh_autosuggest_bind_widget $widget execute + elif [[ -n ${ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS[(r)$widget]} ]]; then + _zsh_autosuggest_bind_widget $widget partial_accept + else + # Assume any unspecified widget might modify the buffer + _zsh_autosuggest_bind_widget $widget modify + fi + done +} + +# Given the name of an original widget and args, invoke it, if it exists +_zsh_autosuggest_invoke_original_widget() { + # Do nothing unless called with at least one arg + (( $# )) || return 0 + + local original_widget_name="$1" + + shift + + if (( ${+widgets[$original_widget_name]} )); then + zle $original_widget_name -- $@ + fi +} diff --git a/.zprezto/modules/autosuggestions/external/src/config.zsh b/.zprezto/modules/autosuggestions/external/src/config.zsh new file mode 100644 index 0000000..597307f --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/src/config.zsh @@ -0,0 +1,71 @@ + +#--------------------------------------------------------------------# +# Global Configuration Variables # +#--------------------------------------------------------------------# + +# Color to use when highlighting suggestion +# Uses format of `region_highlight` +# More info: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Widgets +ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8' + +# Prefix to use when saving original versions of bound widgets +ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig- + +ZSH_AUTOSUGGEST_STRATEGY=default + +# Widgets that clear the suggestion +ZSH_AUTOSUGGEST_CLEAR_WIDGETS=( + history-search-forward + history-search-backward + history-beginning-search-forward + history-beginning-search-backward + history-substring-search-up + history-substring-search-down + up-line-or-beginning-search + down-line-or-beginning-search + up-line-or-history + down-line-or-history + accept-line +) + +# Widgets that accept the entire suggestion +ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=( + forward-char + end-of-line + vi-forward-char + vi-end-of-line + vi-add-eol +) + +# Widgets that accept the entire suggestion and execute it +ZSH_AUTOSUGGEST_EXECUTE_WIDGETS=( +) + +# Widgets that accept the suggestion as far as the cursor moves +ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=( + forward-word + emacs-forward-word + vi-forward-word + vi-forward-word-end + vi-forward-blank-word + vi-forward-blank-word-end + vi-find-next-char + vi-find-next-char-skip +) + +# Widgets that should be ignored (globbing supported but must be escaped) +ZSH_AUTOSUGGEST_IGNORE_WIDGETS=( + orig-\* + beep + run-help + set-local-history + which-command + yank + yank-pop +) + +# Max size of buffer to trigger autosuggestion. Leave undefined for no upper bound. +ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE= + +# Pty name for calculating autosuggestions asynchronously +ZSH_AUTOSUGGEST_ASYNC_PTY_NAME=zsh_autosuggest_pty diff --git a/.zprezto/modules/autosuggestions/external/src/features.zsh b/.zprezto/modules/autosuggestions/external/src/features.zsh new file mode 100644 index 0000000..7a5248f --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/src/features.zsh @@ -0,0 +1,19 @@ + +#--------------------------------------------------------------------# +# Feature Detection # +#--------------------------------------------------------------------# + +_zsh_autosuggest_feature_detect_zpty_returns_fd() { + typeset -g _ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD + typeset -h REPLY + + zpty zsh_autosuggest_feature_detect '{ zshexit() { kill -KILL $$; sleep 1 } }' + + if (( REPLY )); then + _ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD=1 + else + _ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD=0 + fi + + zpty -d zsh_autosuggest_feature_detect +} diff --git a/.zprezto/modules/autosuggestions/external/src/highlight.zsh b/.zprezto/modules/autosuggestions/external/src/highlight.zsh new file mode 100644 index 0000000..273c03d --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/src/highlight.zsh @@ -0,0 +1,26 @@ + +#--------------------------------------------------------------------# +# Highlighting # +#--------------------------------------------------------------------# + +# If there was a highlight, remove it +_zsh_autosuggest_highlight_reset() { + typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT + + if [[ -n "$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT" ]]; then + region_highlight=("${(@)region_highlight:#$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT}") + unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT + fi +} + +# If there's a suggestion, highlight it +_zsh_autosuggest_highlight_apply() { + typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT + + if (( $#POSTDISPLAY )); then + typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT="$#BUFFER $(($#BUFFER + $#POSTDISPLAY)) $ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE" + region_highlight+=("$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT") + else + unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT + fi +} diff --git a/.zprezto/modules/autosuggestions/external/src/setup.zsh b/.zprezto/modules/autosuggestions/external/src/setup.zsh new file mode 100644 index 0000000..c74489f --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/src/setup.zsh @@ -0,0 +1,10 @@ + +#--------------------------------------------------------------------# +# Setup # +#--------------------------------------------------------------------# + +# Precmd hooks for initializing the library and starting pty's +autoload -Uz add-zsh-hook + +# Asynchronous suggestions are generated in a pty +zmodload zsh/zpty diff --git a/.zprezto/modules/autosuggestions/external/src/start.zsh b/.zprezto/modules/autosuggestions/external/src/start.zsh new file mode 100644 index 0000000..6f48ab6 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/src/start.zsh @@ -0,0 +1,24 @@ + +#--------------------------------------------------------------------# +# Start # +#--------------------------------------------------------------------# + +# Start the autosuggestion widgets +_zsh_autosuggest_start() { + add-zsh-hook -d precmd _zsh_autosuggest_start + + _zsh_autosuggest_bind_widgets + + # Re-bind widgets on every precmd to ensure we wrap other wrappers. + # Specifically, highlighting breaks if our widgets are wrapped by + # zsh-syntax-highlighting widgets. This also allows modifications + # to the widget list variables to take effect on the next precmd. + add-zsh-hook precmd _zsh_autosuggest_bind_widgets + + if [[ -n "${ZSH_AUTOSUGGEST_USE_ASYNC+x}" ]]; then + _zsh_autosuggest_async_start + fi +} + +# Start the autosuggestion widgets on the next precmd +add-zsh-hook precmd _zsh_autosuggest_start diff --git a/.zprezto/modules/autosuggestions/external/src/strategies/default.zsh b/.zprezto/modules/autosuggestions/external/src/strategies/default.zsh new file mode 100644 index 0000000..0e85fb5 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/src/strategies/default.zsh @@ -0,0 +1,25 @@ + +#--------------------------------------------------------------------# +# Default Suggestion Strategy # +#--------------------------------------------------------------------# +# Suggests the most recent history item that matches the given +# prefix. +# + +_zsh_autosuggest_strategy_default() { + # Reset options to defaults and enable LOCAL_OPTIONS + emulate -L zsh + + # Enable globbing flags so that we can use (#m) + setopt EXTENDED_GLOB + + # Escape backslashes and all of the glob operators so we can use + # this string as a pattern to search the $history associative array. + # - (#m) globbing flag enables setting references for match data + # TODO: Use (b) flag when we can drop support for zsh older than v5.0.8 + local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}" + + # Get the history items that match + # - (r) subscript flag makes the pattern match on values + typeset -g suggestion="${history[(r)${prefix}*]}" +} diff --git a/.zprezto/modules/autosuggestions/external/src/strategies/match_prev_cmd.zsh b/.zprezto/modules/autosuggestions/external/src/strategies/match_prev_cmd.zsh new file mode 100644 index 0000000..f76d3c1 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/src/strategies/match_prev_cmd.zsh @@ -0,0 +1,59 @@ + +#--------------------------------------------------------------------# +# Match Previous Command Suggestion Strategy # +#--------------------------------------------------------------------# +# Suggests the most recent history item that matches the given +# prefix and whose preceding history item also matches the most +# recently executed command. +# +# For example, suppose your history has the following entries: +# - pwd +# - ls foo +# - ls bar +# - pwd +# +# Given the history list above, when you type 'ls', the suggestion +# will be 'ls foo' rather than 'ls bar' because your most recently +# executed command (pwd) was previously followed by 'ls foo'. +# +# Note that this strategy won't work as expected with ZSH options that don't +# preserve the history order such as `HIST_IGNORE_ALL_DUPS` or +# `HIST_EXPIRE_DUPS_FIRST`. + +_zsh_autosuggest_strategy_match_prev_cmd() { + # Reset options to defaults and enable LOCAL_OPTIONS + emulate -L zsh + + # Enable globbing flags so that we can use (#m) + setopt EXTENDED_GLOB + + # TODO: Use (b) flag when we can drop support for zsh older than v5.0.8 + local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}" + + # Get all history event numbers that correspond to history + # entries that match pattern $prefix* + local history_match_keys + history_match_keys=(${(k)history[(R)$prefix*]}) + + # By default we use the first history number (most recent history entry) + local histkey="${history_match_keys[1]}" + + # Get the previously executed command + local prev_cmd="$(_zsh_autosuggest_escape_command "${history[$((HISTCMD-1))]}")" + + # Iterate up to the first 200 history event numbers that match $prefix + for key in "${(@)history_match_keys[1,200]}"; do + # Stop if we ran out of history + [[ $key -gt 1 ]] || break + + # See if the history entry preceding the suggestion matches the + # previous command, and use it if it does + if [[ "${history[$((key - 1))]}" == "$prev_cmd" ]]; then + histkey="$key" + break + fi + done + + # Give back the matched history entry + typeset -g suggestion="$history[$histkey]" +} diff --git a/.zprezto/modules/autosuggestions/external/src/util.zsh b/.zprezto/modules/autosuggestions/external/src/util.zsh new file mode 100644 index 0000000..1f55d36 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/src/util.zsh @@ -0,0 +1,11 @@ + +#--------------------------------------------------------------------# +# Utility Functions # +#--------------------------------------------------------------------# + +_zsh_autosuggest_escape_command() { + setopt localoptions EXTENDED_GLOB + + # Escape special chars in the string (requires EXTENDED_GLOB) + echo -E "${1//(#m)[\"\'\\()\[\]|*?~]/\\$MATCH}" +} diff --git a/.zprezto/modules/autosuggestions/external/src/widgets.zsh b/.zprezto/modules/autosuggestions/external/src/widgets.zsh new file mode 100644 index 0000000..87bb62e --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/src/widgets.zsh @@ -0,0 +1,213 @@ + +#--------------------------------------------------------------------# +# Autosuggest Widget Implementations # +#--------------------------------------------------------------------# + +# Disable suggestions +_zsh_autosuggest_disable() { + typeset -g _ZSH_AUTOSUGGEST_DISABLED + _zsh_autosuggest_clear +} + +# Enable suggestions +_zsh_autosuggest_enable() { + unset _ZSH_AUTOSUGGEST_DISABLED + + if (( $#BUFFER )); then + _zsh_autosuggest_fetch + fi +} + +# Toggle suggestions (enable/disable) +_zsh_autosuggest_toggle() { + if [[ -n "${_ZSH_AUTOSUGGEST_DISABLED+x}" ]]; then + _zsh_autosuggest_enable + else + _zsh_autosuggest_disable + fi +} + +# Clear the suggestion +_zsh_autosuggest_clear() { + # Remove the suggestion + unset POSTDISPLAY + + _zsh_autosuggest_invoke_original_widget $@ +} + +# Modify the buffer and get a new suggestion +_zsh_autosuggest_modify() { + local -i retval + + # Only available in zsh >= 5.4 + local -i KEYS_QUEUED_COUNT + + # Save the contents of the buffer/postdisplay + local orig_buffer="$BUFFER" + local orig_postdisplay="$POSTDISPLAY" + + # Clear suggestion while waiting for next one + unset POSTDISPLAY + + # Original widget may modify the buffer + _zsh_autosuggest_invoke_original_widget $@ + retval=$? + + # Don't fetch a new suggestion if there's more input to be read immediately + if (( $PENDING > 0 )) || (( $KEYS_QUEUED_COUNT > 0 )); then + POSTDISPLAY="$orig_postdisplay" + return $retval + fi + + # Optimize if manually typing in the suggestion + if (( $#BUFFER > $#orig_buffer )); then + local added=${BUFFER#$orig_buffer} + + # If the string added matches the beginning of the postdisplay + if [[ "$added" = "${orig_postdisplay:0:$#added}" ]]; then + POSTDISPLAY="${orig_postdisplay:$#added}" + return $retval + fi + fi + + # Don't fetch a new suggestion if the buffer hasn't changed + if [[ "$BUFFER" = "$orig_buffer" ]]; then + POSTDISPLAY="$orig_postdisplay" + return $retval + fi + + # Bail out if suggestions are disabled + if [[ -n "${_ZSH_AUTOSUGGEST_DISABLED+x}" ]]; then + return $? + fi + + # Get a new suggestion if the buffer is not empty after modification + if (( $#BUFFER > 0 )); then + if [[ -z "$ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" ]] || (( $#BUFFER <= $ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE )); then + _zsh_autosuggest_fetch + fi + fi + + return $retval +} + +# Fetch a new suggestion based on what's currently in the buffer +_zsh_autosuggest_fetch() { + if zpty -t "$ZSH_AUTOSUGGEST_ASYNC_PTY_NAME" &>/dev/null; then + _zsh_autosuggest_async_request "$BUFFER" + else + local suggestion + _zsh_autosuggest_strategy_$ZSH_AUTOSUGGEST_STRATEGY "$BUFFER" + _zsh_autosuggest_suggest "$suggestion" + fi +} + +# Offer a suggestion +_zsh_autosuggest_suggest() { + local suggestion="$1" + + if [[ -n "$suggestion" ]] && (( $#BUFFER )); then + POSTDISPLAY="${suggestion#$BUFFER}" + else + unset POSTDISPLAY + fi +} + +# Accept the entire suggestion +_zsh_autosuggest_accept() { + local -i max_cursor_pos=$#BUFFER + + # When vicmd keymap is active, the cursor can't move all the way + # to the end of the buffer + if [[ "$KEYMAP" = "vicmd" ]]; then + max_cursor_pos=$((max_cursor_pos - 1)) + fi + + # Only accept if the cursor is at the end of the buffer + if [[ $CURSOR = $max_cursor_pos ]]; then + # Add the suggestion to the buffer + BUFFER="$BUFFER$POSTDISPLAY" + + # Remove the suggestion + unset POSTDISPLAY + + # Move the cursor to the end of the buffer + CURSOR=${#BUFFER} + fi + + _zsh_autosuggest_invoke_original_widget $@ +} + +# Accept the entire suggestion and execute it +_zsh_autosuggest_execute() { + # Add the suggestion to the buffer + BUFFER="$BUFFER$POSTDISPLAY" + + # Remove the suggestion + unset POSTDISPLAY + + # Call the original `accept-line` to handle syntax highlighting or + # other potential custom behavior + _zsh_autosuggest_invoke_original_widget "accept-line" +} + +# Partially accept the suggestion +_zsh_autosuggest_partial_accept() { + local -i retval cursor_loc + + # Save the contents of the buffer so we can restore later if needed + local original_buffer="$BUFFER" + + # Temporarily accept the suggestion. + BUFFER="$BUFFER$POSTDISPLAY" + + # Original widget moves the cursor + _zsh_autosuggest_invoke_original_widget $@ + retval=$? + + # Normalize cursor location across vi/emacs modes + cursor_loc=$CURSOR + if [[ "$KEYMAP" = "vicmd" ]]; then + cursor_loc=$((cursor_loc + 1)) + fi + + # If we've moved past the end of the original buffer + if (( $cursor_loc > $#original_buffer )); then + # Set POSTDISPLAY to text right of the cursor + POSTDISPLAY="${BUFFER[$(($cursor_loc + 1)),$#BUFFER]}" + + # Clip the buffer at the cursor + BUFFER="${BUFFER[1,$cursor_loc]}" + else + # Restore the original buffer + BUFFER="$original_buffer" + fi + + return $retval +} + +for action in clear modify fetch suggest accept partial_accept execute enable disable toggle; do + eval "_zsh_autosuggest_widget_$action() { + local -i retval + + _zsh_autosuggest_highlight_reset + + _zsh_autosuggest_$action \$@ + retval=\$? + + _zsh_autosuggest_highlight_apply + + zle -R + + return \$retval + }" +done + +zle -N autosuggest-fetch _zsh_autosuggest_widget_fetch +zle -N autosuggest-suggest _zsh_autosuggest_widget_suggest +zle -N autosuggest-accept _zsh_autosuggest_widget_accept +zle -N autosuggest-clear _zsh_autosuggest_widget_clear +zle -N autosuggest-execute _zsh_autosuggest_widget_execute +zle -N autosuggest-enable _zsh_autosuggest_widget_enable +zle -N autosuggest-disable _zsh_autosuggest_widget_disable +zle -N autosuggest-toggle _zsh_autosuggest_widget_toggle diff --git a/.zprezto/modules/autosuggestions/external/zsh-autosuggestions.plugin.zsh b/.zprezto/modules/autosuggestions/external/zsh-autosuggestions.plugin.zsh new file mode 100644 index 0000000..16c2256 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/zsh-autosuggestions.plugin.zsh @@ -0,0 +1 @@ +source ${0:A:h}/zsh-autosuggestions.zsh diff --git a/.zprezto/modules/autosuggestions/external/zsh-autosuggestions.zsh b/.zprezto/modules/autosuggestions/external/zsh-autosuggestions.zsh new file mode 100644 index 0000000..1c3eab5 --- /dev/null +++ b/.zprezto/modules/autosuggestions/external/zsh-autosuggestions.zsh @@ -0,0 +1,708 @@ +# Fish-like fast/unobtrusive autosuggestions for zsh. +# https://github.com/zsh-users/zsh-autosuggestions +# v0.4.3 +# Copyright (c) 2013 Thiago de Arruda +# Copyright (c) 2016-2018 Eric Freese +# +# 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. + +#--------------------------------------------------------------------# +# Setup # +#--------------------------------------------------------------------# + +# Precmd hooks for initializing the library and starting pty's +autoload -Uz add-zsh-hook + +# Asynchronous suggestions are generated in a pty +zmodload zsh/zpty + +#--------------------------------------------------------------------# +# Global Configuration Variables # +#--------------------------------------------------------------------# + +# Color to use when highlighting suggestion +# Uses format of `region_highlight` +# More info: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Widgets +ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8' + +# Prefix to use when saving original versions of bound widgets +ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig- + +ZSH_AUTOSUGGEST_STRATEGY=default + +# Widgets that clear the suggestion +ZSH_AUTOSUGGEST_CLEAR_WIDGETS=( + history-search-forward + history-search-backward + history-beginning-search-forward + history-beginning-search-backward + history-substring-search-up + history-substring-search-down + up-line-or-beginning-search + down-line-or-beginning-search + up-line-or-history + down-line-or-history + accept-line +) + +# Widgets that accept the entire suggestion +ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=( + forward-char + end-of-line + vi-forward-char + vi-end-of-line + vi-add-eol +) + +# Widgets that accept the entire suggestion and execute it +ZSH_AUTOSUGGEST_EXECUTE_WIDGETS=( +) + +# Widgets that accept the suggestion as far as the cursor moves +ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=( + forward-word + emacs-forward-word + vi-forward-word + vi-forward-word-end + vi-forward-blank-word + vi-forward-blank-word-end + vi-find-next-char + vi-find-next-char-skip +) + +# Widgets that should be ignored (globbing supported but must be escaped) +ZSH_AUTOSUGGEST_IGNORE_WIDGETS=( + orig-\* + beep + run-help + set-local-history + which-command + yank + yank-pop +) + +# Max size of buffer to trigger autosuggestion. Leave undefined for no upper bound. +ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE= + +# Pty name for calculating autosuggestions asynchronously +ZSH_AUTOSUGGEST_ASYNC_PTY_NAME=zsh_autosuggest_pty + +#--------------------------------------------------------------------# +# Utility Functions # +#--------------------------------------------------------------------# + +_zsh_autosuggest_escape_command() { + setopt localoptions EXTENDED_GLOB + + # Escape special chars in the string (requires EXTENDED_GLOB) + echo -E "${1//(#m)[\"\'\\()\[\]|*?~]/\\$MATCH}" +} + +#--------------------------------------------------------------------# +# Feature Detection # +#--------------------------------------------------------------------# + +_zsh_autosuggest_feature_detect_zpty_returns_fd() { + typeset -g _ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD + typeset -h REPLY + + zpty zsh_autosuggest_feature_detect '{ zshexit() { kill -KILL $$; sleep 1 } }' + + if (( REPLY )); then + _ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD=1 + else + _ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD=0 + fi + + zpty -d zsh_autosuggest_feature_detect +} + +#--------------------------------------------------------------------# +# Widget Helpers # +#--------------------------------------------------------------------# + +_zsh_autosuggest_incr_bind_count() { + if ((${+_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]})); then + ((_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]++)) + else + _ZSH_AUTOSUGGEST_BIND_COUNTS[$1]=1 + fi + + typeset -gi bind_count=$_ZSH_AUTOSUGGEST_BIND_COUNTS[$1] +} + +_zsh_autosuggest_get_bind_count() { + if ((${+_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]})); then + typeset -gi bind_count=$_ZSH_AUTOSUGGEST_BIND_COUNTS[$1] + else + typeset -gi bind_count=0 + fi +} + +# Bind a single widget to an autosuggest widget, saving a reference to the original widget +_zsh_autosuggest_bind_widget() { + typeset -gA _ZSH_AUTOSUGGEST_BIND_COUNTS + + local widget=$1 + local autosuggest_action=$2 + local prefix=$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX + + local -i bind_count + + # Save a reference to the original widget + case $widgets[$widget] in + # Already bound + user:_zsh_autosuggest_(bound|orig)_*);; + + # User-defined widget + user:*) + _zsh_autosuggest_incr_bind_count $widget + zle -N $prefix${bind_count}-$widget ${widgets[$widget]#*:} + ;; + + # Built-in widget + builtin) + _zsh_autosuggest_incr_bind_count $widget + eval "_zsh_autosuggest_orig_${(q)widget}() { zle .${(q)widget} }" + zle -N $prefix${bind_count}-$widget _zsh_autosuggest_orig_$widget + ;; + + # Completion widget + completion:*) + _zsh_autosuggest_incr_bind_count $widget + eval "zle -C $prefix${bind_count}-${(q)widget} ${${(s.:.)widgets[$widget]}[2,3]}" + ;; + esac + + _zsh_autosuggest_get_bind_count $widget + + # Pass the original widget's name explicitly into the autosuggest + # function. Use this passed in widget name to call the original + # widget instead of relying on the $WIDGET variable being set + # correctly. $WIDGET cannot be trusted because other plugins call + # zle without the `-w` flag (e.g. `zle self-insert` instead of + # `zle self-insert -w`). + eval "_zsh_autosuggest_bound_${bind_count}_${(q)widget}() { + _zsh_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@ + }" + + # Create the bound widget + zle -N $widget _zsh_autosuggest_bound_${bind_count}_$widget +} + +# Map all configured widgets to the right autosuggest widgets +_zsh_autosuggest_bind_widgets() { + local widget + local ignore_widgets + + ignore_widgets=( + .\* + _\* + zle-\* + autosuggest-\* + $ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX\* + $ZSH_AUTOSUGGEST_IGNORE_WIDGETS + ) + + # Find every widget we might want to bind and bind it appropriately + for widget in ${${(f)"$(builtin zle -la)"}:#${(j:|:)~ignore_widgets}}; do + if [[ -n ${ZSH_AUTOSUGGEST_CLEAR_WIDGETS[(r)$widget]} ]]; then + _zsh_autosuggest_bind_widget $widget clear + elif [[ -n ${ZSH_AUTOSUGGEST_ACCEPT_WIDGETS[(r)$widget]} ]]; then + _zsh_autosuggest_bind_widget $widget accept + elif [[ -n ${ZSH_AUTOSUGGEST_EXECUTE_WIDGETS[(r)$widget]} ]]; then + _zsh_autosuggest_bind_widget $widget execute + elif [[ -n ${ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS[(r)$widget]} ]]; then + _zsh_autosuggest_bind_widget $widget partial_accept + else + # Assume any unspecified widget might modify the buffer + _zsh_autosuggest_bind_widget $widget modify + fi + done +} + +# Given the name of an original widget and args, invoke it, if it exists +_zsh_autosuggest_invoke_original_widget() { + # Do nothing unless called with at least one arg + (( $# )) || return 0 + + local original_widget_name="$1" + + shift + + if (( ${+widgets[$original_widget_name]} )); then + zle $original_widget_name -- $@ + fi +} + +#--------------------------------------------------------------------# +# Highlighting # +#--------------------------------------------------------------------# + +# If there was a highlight, remove it +_zsh_autosuggest_highlight_reset() { + typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT + + if [[ -n "$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT" ]]; then + region_highlight=("${(@)region_highlight:#$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT}") + unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT + fi +} + +# If there's a suggestion, highlight it +_zsh_autosuggest_highlight_apply() { + typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT + + if (( $#POSTDISPLAY )); then + typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT="$#BUFFER $(($#BUFFER + $#POSTDISPLAY)) $ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE" + region_highlight+=("$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT") + else + unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT + fi +} + +#--------------------------------------------------------------------# +# Autosuggest Widget Implementations # +#--------------------------------------------------------------------# + +# Disable suggestions +_zsh_autosuggest_disable() { + typeset -g _ZSH_AUTOSUGGEST_DISABLED + _zsh_autosuggest_clear +} + +# Enable suggestions +_zsh_autosuggest_enable() { + unset _ZSH_AUTOSUGGEST_DISABLED + + if (( $#BUFFER )); then + _zsh_autosuggest_fetch + fi +} + +# Toggle suggestions (enable/disable) +_zsh_autosuggest_toggle() { + if [[ -n "${_ZSH_AUTOSUGGEST_DISABLED+x}" ]]; then + _zsh_autosuggest_enable + else + _zsh_autosuggest_disable + fi +} + +# Clear the suggestion +_zsh_autosuggest_clear() { + # Remove the suggestion + unset POSTDISPLAY + + _zsh_autosuggest_invoke_original_widget $@ +} + +# Modify the buffer and get a new suggestion +_zsh_autosuggest_modify() { + local -i retval + + # Only available in zsh >= 5.4 + local -i KEYS_QUEUED_COUNT + + # Save the contents of the buffer/postdisplay + local orig_buffer="$BUFFER" + local orig_postdisplay="$POSTDISPLAY" + + # Clear suggestion while waiting for next one + unset POSTDISPLAY + + # Original widget may modify the buffer + _zsh_autosuggest_invoke_original_widget $@ + retval=$? + + # Don't fetch a new suggestion if there's more input to be read immediately + if (( $PENDING > 0 )) || (( $KEYS_QUEUED_COUNT > 0 )); then + POSTDISPLAY="$orig_postdisplay" + return $retval + fi + + # Optimize if manually typing in the suggestion + if (( $#BUFFER > $#orig_buffer )); then + local added=${BUFFER#$orig_buffer} + + # If the string added matches the beginning of the postdisplay + if [[ "$added" = "${orig_postdisplay:0:$#added}" ]]; then + POSTDISPLAY="${orig_postdisplay:$#added}" + return $retval + fi + fi + + # Don't fetch a new suggestion if the buffer hasn't changed + if [[ "$BUFFER" = "$orig_buffer" ]]; then + POSTDISPLAY="$orig_postdisplay" + return $retval + fi + + # Bail out if suggestions are disabled + if [[ -n "${_ZSH_AUTOSUGGEST_DISABLED+x}" ]]; then + return $? + fi + + # Get a new suggestion if the buffer is not empty after modification + if (( $#BUFFER > 0 )); then + if [[ -z "$ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" ]] || (( $#BUFFER <= $ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE )); then + _zsh_autosuggest_fetch + fi + fi + + return $retval +} + +# Fetch a new suggestion based on what's currently in the buffer +_zsh_autosuggest_fetch() { + if zpty -t "$ZSH_AUTOSUGGEST_ASYNC_PTY_NAME" &>/dev/null; then + _zsh_autosuggest_async_request "$BUFFER" + else + local suggestion + _zsh_autosuggest_strategy_$ZSH_AUTOSUGGEST_STRATEGY "$BUFFER" + _zsh_autosuggest_suggest "$suggestion" + fi +} + +# Offer a suggestion +_zsh_autosuggest_suggest() { + local suggestion="$1" + + if [[ -n "$suggestion" ]] && (( $#BUFFER )); then + POSTDISPLAY="${suggestion#$BUFFER}" + else + unset POSTDISPLAY + fi +} + +# Accept the entire suggestion +_zsh_autosuggest_accept() { + local -i max_cursor_pos=$#BUFFER + + # When vicmd keymap is active, the cursor can't move all the way + # to the end of the buffer + if [[ "$KEYMAP" = "vicmd" ]]; then + max_cursor_pos=$((max_cursor_pos - 1)) + fi + + # Only accept if the cursor is at the end of the buffer + if [[ $CURSOR = $max_cursor_pos ]]; then + # Add the suggestion to the buffer + BUFFER="$BUFFER$POSTDISPLAY" + + # Remove the suggestion + unset POSTDISPLAY + + # Move the cursor to the end of the buffer + CURSOR=${#BUFFER} + fi + + _zsh_autosuggest_invoke_original_widget $@ +} + +# Accept the entire suggestion and execute it +_zsh_autosuggest_execute() { + # Add the suggestion to the buffer + BUFFER="$BUFFER$POSTDISPLAY" + + # Remove the suggestion + unset POSTDISPLAY + + # Call the original `accept-line` to handle syntax highlighting or + # other potential custom behavior + _zsh_autosuggest_invoke_original_widget "accept-line" +} + +# Partially accept the suggestion +_zsh_autosuggest_partial_accept() { + local -i retval cursor_loc + + # Save the contents of the buffer so we can restore later if needed + local original_buffer="$BUFFER" + + # Temporarily accept the suggestion. + BUFFER="$BUFFER$POSTDISPLAY" + + # Original widget moves the cursor + _zsh_autosuggest_invoke_original_widget $@ + retval=$? + + # Normalize cursor location across vi/emacs modes + cursor_loc=$CURSOR + if [[ "$KEYMAP" = "vicmd" ]]; then + cursor_loc=$((cursor_loc + 1)) + fi + + # If we've moved past the end of the original buffer + if (( $cursor_loc > $#original_buffer )); then + # Set POSTDISPLAY to text right of the cursor + POSTDISPLAY="${BUFFER[$(($cursor_loc + 1)),$#BUFFER]}" + + # Clip the buffer at the cursor + BUFFER="${BUFFER[1,$cursor_loc]}" + else + # Restore the original buffer + BUFFER="$original_buffer" + fi + + return $retval +} + +for action in clear modify fetch suggest accept partial_accept execute enable disable toggle; do + eval "_zsh_autosuggest_widget_$action() { + local -i retval + + _zsh_autosuggest_highlight_reset + + _zsh_autosuggest_$action \$@ + retval=\$? + + _zsh_autosuggest_highlight_apply + + zle -R + + return \$retval + }" +done + +zle -N autosuggest-fetch _zsh_autosuggest_widget_fetch +zle -N autosuggest-suggest _zsh_autosuggest_widget_suggest +zle -N autosuggest-accept _zsh_autosuggest_widget_accept +zle -N autosuggest-clear _zsh_autosuggest_widget_clear +zle -N autosuggest-execute _zsh_autosuggest_widget_execute +zle -N autosuggest-enable _zsh_autosuggest_widget_enable +zle -N autosuggest-disable _zsh_autosuggest_widget_disable +zle -N autosuggest-toggle _zsh_autosuggest_widget_toggle + +#--------------------------------------------------------------------# +# Default Suggestion Strategy # +#--------------------------------------------------------------------# +# Suggests the most recent history item that matches the given +# prefix. +# + +_zsh_autosuggest_strategy_default() { + # Reset options to defaults and enable LOCAL_OPTIONS + emulate -L zsh + + # Enable globbing flags so that we can use (#m) + setopt EXTENDED_GLOB + + # Escape backslashes and all of the glob operators so we can use + # this string as a pattern to search the $history associative array. + # - (#m) globbing flag enables setting references for match data + # TODO: Use (b) flag when we can drop support for zsh older than v5.0.8 + local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}" + + # Get the history items that match + # - (r) subscript flag makes the pattern match on values + typeset -g suggestion="${history[(r)${prefix}*]}" +} + +#--------------------------------------------------------------------# +# Match Previous Command Suggestion Strategy # +#--------------------------------------------------------------------# +# Suggests the most recent history item that matches the given +# prefix and whose preceding history item also matches the most +# recently executed command. +# +# For example, suppose your history has the following entries: +# - pwd +# - ls foo +# - ls bar +# - pwd +# +# Given the history list above, when you type 'ls', the suggestion +# will be 'ls foo' rather than 'ls bar' because your most recently +# executed command (pwd) was previously followed by 'ls foo'. +# +# Note that this strategy won't work as expected with ZSH options that don't +# preserve the history order such as `HIST_IGNORE_ALL_DUPS` or +# `HIST_EXPIRE_DUPS_FIRST`. + +_zsh_autosuggest_strategy_match_prev_cmd() { + # Reset options to defaults and enable LOCAL_OPTIONS + emulate -L zsh + + # Enable globbing flags so that we can use (#m) + setopt EXTENDED_GLOB + + # TODO: Use (b) flag when we can drop support for zsh older than v5.0.8 + local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}" + + # Get all history event numbers that correspond to history + # entries that match pattern $prefix* + local history_match_keys + history_match_keys=(${(k)history[(R)$prefix*]}) + + # By default we use the first history number (most recent history entry) + local histkey="${history_match_keys[1]}" + + # Get the previously executed command + local prev_cmd="$(_zsh_autosuggest_escape_command "${history[$((HISTCMD-1))]}")" + + # Iterate up to the first 200 history event numbers that match $prefix + for key in "${(@)history_match_keys[1,200]}"; do + # Stop if we ran out of history + [[ $key -gt 1 ]] || break + + # See if the history entry preceding the suggestion matches the + # previous command, and use it if it does + if [[ "${history[$((key - 1))]}" == "$prev_cmd" ]]; then + histkey="$key" + break + fi + done + + # Give back the matched history entry + typeset -g suggestion="$history[$histkey]" +} + +#--------------------------------------------------------------------# +# Async # +#--------------------------------------------------------------------# + +# Zpty process is spawned running this function +_zsh_autosuggest_async_server() { + emulate -R zsh + + # There is a bug in zpty module (fixed in zsh/master) by which a + # zpty that exits will kill all zpty processes that were forked + # before it. Here we set up a zsh exit hook to SIGKILL the zpty + # process immediately, before it has a chance to kill any other + # zpty processes. + zshexit() { + kill -KILL $$ + sleep 1 # Block for long enough for the signal to come through + } + + # Output only newlines (not carriage return + newline) + stty -onlcr + + # Silence any error messages + exec 2>/dev/null + + local last_pid + + while IFS='' read -r -d $'\0' query; do + # Kill last bg process + kill -KILL $last_pid &>/dev/null + + # Run suggestion search in the background + ( + local suggestion + _zsh_autosuggest_strategy_$ZSH_AUTOSUGGEST_STRATEGY "$query" + echo -n -E "$suggestion"$'\0' + ) & + + last_pid=$! + done +} + +_zsh_autosuggest_async_request() { + # Write the query to the zpty process to fetch a suggestion + zpty -w -n $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME "${1}"$'\0' +} + +# Called when new data is ready to be read from the pty +# First arg will be fd ready for reading +# Second arg will be passed in case of error +_zsh_autosuggest_async_response() { + setopt LOCAL_OPTIONS EXTENDED_GLOB + + local suggestion + + zpty -rt $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME suggestion '*'$'\0' 2>/dev/null + zle autosuggest-suggest -- "${suggestion%%$'\0'##}" +} + +_zsh_autosuggest_async_pty_create() { + # With newer versions of zsh, REPLY stores the fd to read from + typeset -h REPLY + + # If we won't get a fd back from zpty, try to guess it + if (( ! $_ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD )); then + integer -l zptyfd + exec {zptyfd}>&1 # Open a new file descriptor (above 10). + exec {zptyfd}>&- # Close it so it's free to be used by zpty. + fi + + # Fork a zpty process running the server function + zpty -b $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME _zsh_autosuggest_async_server + + # Store the fd so we can remove the handler later + if (( REPLY )); then + _ZSH_AUTOSUGGEST_PTY_FD=$REPLY + else + _ZSH_AUTOSUGGEST_PTY_FD=$zptyfd + fi + + # Set up input handler from the zpty + zle -F $_ZSH_AUTOSUGGEST_PTY_FD _zsh_autosuggest_async_response +} + +_zsh_autosuggest_async_pty_destroy() { + # Remove the input handler + zle -F $_ZSH_AUTOSUGGEST_PTY_FD &>/dev/null + + # Destroy the zpty + zpty -d $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME &>/dev/null +} + +_zsh_autosuggest_async_pty_recreate() { + _zsh_autosuggest_async_pty_destroy + _zsh_autosuggest_async_pty_create +} + +_zsh_autosuggest_async_start() { + typeset -g _ZSH_AUTOSUGGEST_PTY_FD + + _zsh_autosuggest_feature_detect_zpty_returns_fd + _zsh_autosuggest_async_pty_recreate + + # We recreate the pty to get a fresh list of history events + add-zsh-hook precmd _zsh_autosuggest_async_pty_recreate +} + +#--------------------------------------------------------------------# +# Start # +#--------------------------------------------------------------------# + +# Start the autosuggestion widgets +_zsh_autosuggest_start() { + add-zsh-hook -d precmd _zsh_autosuggest_start + + _zsh_autosuggest_bind_widgets + + # Re-bind widgets on every precmd to ensure we wrap other wrappers. + # Specifically, highlighting breaks if our widgets are wrapped by + # zsh-syntax-highlighting widgets. This also allows modifications + # to the widget list variables to take effect on the next precmd. + add-zsh-hook precmd _zsh_autosuggest_bind_widgets + + if [[ -n "${ZSH_AUTOSUGGEST_USE_ASYNC+x}" ]]; then + _zsh_autosuggest_async_start + fi +} + +# Start the autosuggestion widgets on the next precmd +add-zsh-hook precmd _zsh_autosuggest_start diff --git a/.zprezto/modules/command-not-found/README.md b/.zprezto/modules/command-not-found/README.md index e969b71..7775c92 100644 --- a/.zprezto/modules/command-not-found/README.md +++ b/.zprezto/modules/command-not-found/README.md @@ -1,15 +1,23 @@ Command-Not-Found ================= -Displays installation information for not found commands by loading the -[command-not-found][1] tool on Debian-based and Arch Linux-based distributions. +When you try to use a command that is not available locally, searches +the package manager for a package offering that command and suggests +the proper install command. + +Debian-based and Arch Linux-based distributions use the [`command-not-found`][1] tool. + +macOS uses Homebrew's [`command-not-found` clone][2]. Note that you also need to [follow the instructions to tap the `command-not-found` homebrew repository][3]. + Authors ------- -*The authors of this module should be contacted via the [issue tracker][2].* +*The authors of this module should be contacted via the [issue tracker][4].* - [Joseph Booker](https://github.com/sargas) [1]: https://code.launchpad.net/command-not-found -[2]: https://github.com/sorin-ionescu/prezto/issues +[2]: https://github.com/Homebrew/homebrew-command-not-found +[3]: https://github.com/Homebrew/homebrew-command-not-found#install +[4]: https://github.com/sorin-ionescu/prezto/issues diff --git a/.zprezto/modules/command-not-found/init.zsh b/.zprezto/modules/command-not-found/init.zsh index 2d9236a..2c59a4b 100644 --- a/.zprezto/modules/command-not-found/init.zsh +++ b/.zprezto/modules/command-not-found/init.zsh @@ -3,6 +3,7 @@ # # Authors: # Joseph Jon Booker +# Indrajit Raychaudhuri # # Load command-not-found on Debian-based distributions. @@ -11,6 +12,9 @@ if [[ -s '/etc/zsh_command_not_found' ]]; then # Load command-not-found on Arch Linux-based distributions. elif [[ -s '/usr/share/doc/pkgfile/command-not-found.zsh' ]]; then source '/usr/share/doc/pkgfile/command-not-found.zsh' +# Load command-not-found on macOS when homebrew tap is configured. +elif [[ -s '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh' ]]; then + source '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh' # Return if requirements are not found. else return 1 diff --git a/.zprezto/modules/completion/README.md b/.zprezto/modules/completion/README.md index aaa86fd..7efb3d9 100644 --- a/.zprezto/modules/completion/README.md +++ b/.zprezto/modules/completion/README.md @@ -6,6 +6,23 @@ the [zsh-completions][1] project. This module must be loaded **after** the *utility* module. +Settings +-------- + +### Ignore */etc/hosts* Entries + +To ignore certain entries from static */etc/hosts* for host completion, add the +following lines in *zpreztorc* with the IP addresses of the hosts as they +appear in */etc/hosts*. Both IP address and the corresponding hostname will be +ignored during host completion. However, some of the entries ignored from +*/etc/hosts* still might appear during completion because of their presence in +*ssh* configuration or history). + +```sh +zstyle ':prezto:module:completion:*:hosts' etc-host-ignores \ + '0.0.0.0' '127.0.0.1' +``` + Contributors ------------ diff --git a/.zprezto/modules/completion/external/.editorconfig b/.zprezto/modules/completion/external/.editorconfig_backup similarity index 100% rename from .zprezto/modules/completion/external/.editorconfig rename to .zprezto/modules/completion/external/.editorconfig_backup diff --git a/.zprezto/modules/completion/external/.git_backup b/.zprezto/modules/completion/external/.git_backup new file mode 100644 index 0000000..da60063 --- /dev/null +++ b/.zprezto/modules/completion/external/.git_backup @@ -0,0 +1 @@ +gitdir: ../../../.git/modules/modules/completion/external diff --git a/.zprezto/modules/completion/external/.gitignore b/.zprezto/modules/completion/external/.gitignore_backup similarity index 100% rename from .zprezto/modules/completion/external/.gitignore rename to .zprezto/modules/completion/external/.gitignore_backup diff --git a/.zprezto/modules/completion/external/LICENSE b/.zprezto/modules/completion/external/LICENSE new file mode 100644 index 0000000..d275ca9 --- /dev/null +++ b/.zprezto/modules/completion/external/LICENSE @@ -0,0 +1,25 @@ +The Z Shell is copyright (c) 1992-2017 Paul Falstad, Richard Coleman, +Zoltán Hidvégi, Andrew Main, Peter Stephenson, Sven Wischnowsky, and +others. All rights reserved. Individual authors, whether or not +specifically named, retain copyright in all changes; in what follows, they +are referred to as `the Zsh Development Group'. This is for convenience +only and this body has no legal status. The Z shell is distributed under +the following licence; any provisions made in individual files take +precedence. + +Permission is hereby granted, without written agreement and without +licence or royalty fees, to use, copy, modify, and distribute this +software and to distribute modified versions of this software for any +purpose, provided that the above copyright notice and the following +two paragraphs appear in all copies of this software. + +In no event shall the Zsh Development Group be liable to any party for +direct, indirect, special, incidental, or consequential damages arising out +of the use of this software and its documentation, even if the Zsh +Development Group have been advised of the possibility of such damage. + +The Zsh Development Group specifically disclaim any warranties, including, +but not limited to, the implied warranties of merchantability and fitness +for a particular purpose. The software provided hereunder is on an "as is" +basis, and the Zsh Development Group have no obligation to provide +maintenance, support, updates, enhancements, or modifications. diff --git a/.zprezto/modules/completion/external/README.md b/.zprezto/modules/completion/external/README.md index 741fbc3..57ba687 100644 --- a/.zprezto/modules/completion/external/README.md +++ b/.zprezto/modules/completion/external/README.md @@ -1,34 +1,49 @@ -zsh-completions -=============== +zsh-completions ![GitHub release](https://img.shields.io/github/release/zsh-users/zsh-completions.svg) ![GitHub contributors](https://img.shields.io/github/contributors/zsh-users/zsh-completions.svg) [![IRC](https://img.shields.io/badge/IRC-%23zsh--completions-yellow.svg)](irc://irc.freenode.net/#zsh-completions) [![Gitter](https://badges.gitter.im/zsh-users/zsh-completions.svg)](https://gitter.im/zsh-users/zsh-completions?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) +============= **Additional completion definitions for [Zsh](http://www.zsh.org).** -*This projects aims at gathering/developing new completion scripts that are not available in Zsh yet. The scripts are meant to be contributed to the Zsh project when stable enough.* +*This projects aims at gathering/developing new completion scripts that are not available in Zsh yet. The scripts may be contributed to the Zsh project when stable enough.* -Status ------- +## Status + See [issues](https://github.com/zsh-users/zsh-completions/issues) for details on each completion definition. -Gentoo's completions have been removed, as they are maintained upstream. See: [Gentoo zsh-completions](https://github.com/radhermit/gentoo-zsh-completions) -Usage ------ +## Usage -#### Using packages +### Using packages -* Arch Linux: [community/zsh-completions](https://www.archlinux.org/packages/zsh-completions) / [AUR/zsh-completions-git](https://aur.archlinux.org/packages/zsh-completions-git/) -* [Gentoo](http://packages.gentoo.org/package/app-shells/zsh-completions) -* Mac OS: [Homebrew](https://github.com/mxcl/homebrew/blob/master/Library/Formula/zsh-completions.rb) -* Debian based distributions (Debian/Ubuntu/Linux Mint...): Packager needed, please get in touch ! -* RPM based distributions (Fedora/RHEL/CentOS...): Packager needed, please get in touch ! +| System | Package | +| ------------- | ------------- | +| Debian / Ubuntu | [zsh-completions OBS repository](https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-completions&package=zsh-completions) | +| Fedora / CentOS / RHEL / Scientific Linux | [zsh-completions OBS repository](https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-completions&package=zsh-completions) | +| OpenSUSE / SLE | [zsh-completions OBS repository](https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-completions&package=zsh-completions) | +| Arch Linux | [zsh-completions](https://www.archlinux.org/packages/zsh-completions), [zsh-completions-git](https://aur.archlinux.org/packages/zsh-completions-git) | +| Gentoo | [app-shells/zsh-completions](http://packages.gentoo.org/package/app-shells/zsh-completions) | +| NixOS | [zsh-completions](https://github.com/NixOS/nixpkgs/blob/master/pkgs/shells/zsh-completions/default.nix) | +| Void Linux | [zsh-completions](https://github.com/voidlinux/void-packages/tree/master/srcpkgs/zsh-completions) | +| Mac OS | [homebrew](https://github.com/Homebrew/homebrew-core/blob/master/Formula/zsh-completions.rb) | -#### Using frameworks +### Using zsh frameworks -* If you're using [antigen](https://github.com/zsh-users/antigen), just add `antigen bundle zsh-users/zsh-completions src` to your .zshrc where you're loading your other zsh plugins. +#### [antigen](https://github.com/zsh-users/antigen) +Add `antigen bundle zsh-users/zsh-completions` to your `~/.zshrc`. -#### Manual installation +#### [oh-my-zsh](http://github.com/robbyrussell/oh-my-zsh) + +* Clone the repository inside your oh-my-zsh repo: + + git clone https://github.com/zsh-users/zsh-completions ~/.oh-my-zsh/custom/plugins/zsh-completions + +* Enable it in your `.zshrc` by adding it to your plugin list and reloading the completion: + + plugins=(… zsh-completions) + autoload -U compinit && compinit + +### Manual installation * Clone the repository: @@ -42,36 +57,20 @@ Usage rm -f ~/.zcompdump; compinit -#### oh-my-zsh - -If you use [oh-my-zsh][] then just clone the repository inside your oh-my-zsh repo: - -```Shell -git clone https://github.com/zsh-users/zsh-completions ~/.oh-my-zsh/custom/plugins/zsh-completions -``` - -and enable it in your `.zshrc`: - -```zsh -plugins+=(zsh-completions) -autoload -U compinit && compinit -``` - -[oh-my-zsh]: http://github.com/robbyrussell/oh-my-zsh - -Contributing ------------- +### Contributing Contributions are welcome, just make sure you follow the guidelines: + * Completions are not accepted when already available in zsh. * Completions are not accepted when already available in their original project. * Please do not just copy/paste someone else completion, ask before. * Completions only partially implemented are not accepted. - * Please add a header containing authors, license info, status and origin of the script (example [here](src/_ack)). + * Please add a header containing authors, status and origin of the script and license header if you do not wish to use the Zsh license (example [here](src/_ack)). * Please try to follow [Zsh completion style guide](https://github.com/zsh-users/zsh/blob/master/Etc/completion-style-guide). + * Please send one separate pull request per file. * Send a pull request or ask for committer access. -License -------- -See each file for license details. +## License +Completions use the Zsh license, unless explicitely mentionned in the file header. +See [LICENSE](https://github.com/zsh-users/zsh-completions/blob/master/LICENSE) for more information. diff --git a/.zprezto/modules/completion/external/src/_ack b/.zprezto/modules/completion/external/src/_ack index 55a38b8..d624209 100644 --- a/.zprezto/modules/completion/external/src/_ack +++ b/.zprezto/modules/completion/external/src/_ack @@ -1,30 +1,5 @@ #compdef ack ack2 ack-grep ack-standalone # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_adb b/.zprezto/modules/completion/external/src/_adb deleted file mode 100644 index 6e252e7..0000000 --- a/.zprezto/modules/completion/external/src/_adb +++ /dev/null @@ -1,422 +0,0 @@ -#compdef adb -# ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for adb (Android Debug Bridge) 1.0.26 -# (http://developer.android.com/guide/developing/tools/adb.html). -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Julien Nicoulaud -# -# ------------------------------------------------------------------------------ - - -_adb() { - typeset -A opt_args - local context state line curcontext="$curcontext" adb_args - - local ret=1 - - _arguments -C \ - '(-e -s)-d[directs command to the only connected USB device, returns an error if more than one USB device is present]' \ - '(-d -s)-e[directs command to the only running emulator, returns an error if more than one emulator is running]' \ - '(-d -e)-s[directs command to the USB device or emulator with the given serial number]: :_adb_serial_numbers' \ - '-p[simple product name or a relative/absolute path to a product out directory]: :_adb_products' \ - '1: :_adb_cmds' \ - '*::arg:->args' \ - && ret=0 - - adb_args="${(fkv)opt_args[(I)-d|-e|-s|-p]}" - - case "$state" in - (args) - curcontext="${curcontext%:*:*}:adb-cmd-$words[1]:" - case $words[1] in - (help|version|devices|jdwp|bugreport|wait-for-device|start-server|kill-server|get-state|get-serialno|status-window|remount|reboot-bootloader|root|usb) - _message 'no more arguments' && ret=0 - ;; - (connect|disconnect) - _arguments \ - '1: :_adb_host_colon_ports' \ - && ret=0 - ;; - (push) - _arguments \ - '1:local directory:_files -/' \ - '2: :_adb_remote_files -/' \ - && ret=0 - ;; - (pull) - _arguments \ - '1: :_adb_remote_files -/' \ - '2:local directory:_files -/' \ - && ret=0 - ;; - (sideload) - _arguments \ - '1:local directory:_files -/' \ - && ret=0 - ;; - (sync) - _arguments \ - '-l[list but do not copy]' \ - '1: :_adb_sync_directories' \ - && ret=0 - ;; - (shell|emu) - _arguments -C \ - '1: :_adb_remote_commands' \ - '*::remote-command-arg:->remote-command-args' \ - && ret=0 - case "$state" in - (remote-command-args) - curcontext="${curcontext%:*:*}:adb-remote-cmd-$words[1]:" - if (( $+functions[_adb_remote_command_$words[1]_args] )); then - _adb_remote_command_$words[1] && ret=0 - # TODO Write handlers for following commands: - # * am (Activity Manager) - # * pm (Package Manager) - # TODO Reuse existing compdefs for standard commands (ls, id, ifconfig, kill, etc) ? - # How do we tell them to use _remote_ files/pids/users/etc ? - else - _adb_remote_command_default && ret=0 - fi - ;; - esac - ;; - (logcat) - local -a rotation_opts - [[ -n ${(M)words:#"-f"} ]] && rotation_opts+=('-r[rotates the log file every kbytes of output. The default value is 16]:value (in kb)') - [[ -n ${(M)words:#"-r"} ]] && rotation_opts+=('-n[sets the maximum number of rotated logs. The default value is 4]:count') - _arguments \ - '-b[loads an alternate log buffer for viewing, such as event or radio. The main buffer is used by default]: :_adb_logcat_buffers' \ - '-c[clears (flushes) the entire log and exits]' \ - '-d[dumps the log to the screen and exits]' \ - '-f[writes log message output to file. The default is stdout]: :_files' \ - '-g[prints the size of the specified log buffer and exits]' \ - '-s[sets the default filter spec to silent]' \ - '-v[sets the output format for log messages]: :_adb_logcat_output_formats' \ - "${rotation_opts[@]}" \ - '*: :_adb_logcat_filter_specs' \ - && ret=0 - ;; - (forward) - _arguments \ - '1: :_adb_local_forward_specs' \ - '2: :_adb_remote_forward_specs' \ - && ret=0 - ;; - (install) - _arguments \ - '-l[forward-lock the app]' \ - '-r[reinstall the app, keeping its data]' \ - '-s[install on SD card instead of internal storage]' \ - '1: :_files' \ - && ret=0 - ;; - (uninstall) - _arguments \ - '-k[keep the data and cache directories]' \ - '1: :_adb_packages' \ - && ret=0 - ;; - (reboot) - _arguments \ - '1:program:((bootloader:reboot\ into\ the\ bootloader\ program recovery:reboot\ into\ the\ recovery\ program))' \ - && ret=0 - ;; - (tcpip) - _arguments \ - '1::port' \ - && ret=0 - ;; - (ppp) - # TODO Complete tty (See http://developer.android.com/guide/developing/tools/adb.html#commandsummary) - # TODO Complete PPP parameters (See http://ppp.samba.org/pppd.html) - _arguments \ - '1::tty' \ - '*::parameters' \ - && ret=0 - ;; - esac - ;; - esac - - return ret -} - -(( $+functions[_adb_cmds] )) || -_adb_cmds() { - _alternative \ - 'general-commands:general command:_adb_general_cmds' \ - 'device-commands:device command:_adb_device_cmds' \ - 'scripting-commands:scripting command:_adb_scripting_cmds' -} - -(( $+functions[_adb_general_cmds] )) || -_adb_general_cmds() { - local commands; commands=( - 'help:show help message' - 'version:show version number' - 'devices:list all connected devices' - 'connect:connect to a device via TCP/IP' - 'disconnect:disconnect from a TCP/IP device' - ) - _describe -t general-commands 'general command' commands "$@" -} - -(( $+functions[_adb_device_cmds] )) || -_adb_device_cmds() { - local commands; commands=( - 'push:copy file/dir to device' - 'pull:copy file/dir from device' - 'sync:copy host->device only if changed' - 'shell:run remote shell interactively or command' - 'emu:run emulator console command' - 'logcat:view device log' - 'forward:forward socket connections' - 'jdwp:list PIDs of processes hosting a JDWP transport' - 'install:push this padbage file to the device and install it' - 'uninstall:remove this app padbage from the device' - 'bugreport:return all information from the device' - ) - _describe -t device-commands 'device command' commands "$@" -} - -(( $+functions[_adb_scripting_cmds] )) || -_adb_scripting_cmds() { - local commands; commands=( - 'wait-for-device:block until device is online' - 'start-server:ensure that there is a server running' - 'kill-server:kill the server if it is running' - 'get-state:prints\: offline | bootloader | device' - 'get-serialno:prints\: ' - 'status-window:continuously print device status for a specified device' - 'remount:remounts the /system partition on the device read-write' - 'reboot:reboots the device, optionally into the bootloader or recovery program' - 'reboot-bootloader:reboots the device into the bootloader' - 'root:restarts the adbd daemon with root permissions' - 'usb:restarts the adbd daemon listening on USB' - 'tcpip:restarts the adbd daemon listening on TCP on the specified port' - 'ppp:run PPP over USB' - ) - _describe -t scripting-commands 'scripting command' commands "$@" -} - -(( $+functions[_adb_products] )) || -_adb_products() { - _alternative \ - 'product-names:product name:_adb_product_names' \ - 'directories:directory:_files -/' -} - -(( $+functions[_adb_product_names] )) || -_adb_product_names() { - local ret=1 - if [[ -n "$ANDROID_PRODUCT_OUT" ]]; then - local product_names; product_names=("$ANDROID_PRODUCT_OUT:default value set in ANDROID_PRODUCT_OUT environment variable") - _describe -t product-names 'product name' product_names && ret=0 - else - _message -e product-names 'product name' && ret=0 - fi - return ret -} - -(( $+functions[_adb_serial_numbers] )) || -_adb_serial_numbers() { - local serial_numbers; serial_numbers=(${${(M)${(f)"$(_call_program devices $service devices)"//:/\\:}:#*device}%%[[:space:]]*}":connected device") - [[ -n "$ANDROID_SERIAL" ]] && serial_numbers+=("$ANDROID_SERIAL:default value set in ANDROID_SERIAL environment variable") - _describe -t serial-numbers 'serial number' serial_numbers "$@" && ret=0 -} - -(( $+functions[_adb_packages] )) || -_adb_packages() { - local packages; packages=(${${(ps:\r\n:)"$(_call_program packages $service $adb_args shell 'ls /data/data 2>/dev/null')"}:#\**\*}) - _multi_parts . packages -} - -(( $+functions[_adb_host_colon_ports] )) || -_adb_host_colon_ports() { - local ret=1 - if compset -P '*:'; then - _message -e ports 'port' && ret=0 - else - _wanted hosts expl 'host' _hosts -qS: && ret=0 - fi - return ret -} - -(( $+functions[_adb_remote_files] )) || -_adb_remote_files() { - local dirsonly command="ls -d ${(S)words[CURRENT]/\/*//}*/ 2>/dev/null" - zparseopts -D -E '/=dirsonly' - (( ! $#dirsonly )) && command+="; ls -d ${words[CURRENT]}* 2>/dev/null" - local files; files=(${${(ps:\r\n:)"$(_call_program files $service $adb_args shell "'$command'" 2>/dev/null)"}:#\**\*}) - _multi_parts "$@" / files -} - -(( $+functions[_adb_remote_commands] )) || -_adb_remote_commands() { - local commands; commands=(${${(ps:\r\n:)"$(_call_program commands $service $adb_args shell "'IFS=:;for path_dir in \$PATH; do ls \$path_dir 2>/dev/null; done'" 2>/dev/null)"}:#\**\*}) - _describe -t remote-commands 'remote command' commands && ret=0 -} - -(( $+functions[_adb_local_forward_specs] )) || -_adb_local_forward_specs() { - local ret=1 - if compset -P '*:'; then - case ${IPREFIX%:} in - (tcp) - _message -e ports 'port' && ret=0 - ;; - (localabstract|localreserved) - _wanted sockets expl 'socket' _socket && ret=0 - ;; - (localfilesystem) - _wanted socket-files expl 'socket file' _files && ret=0 - ;; - (dev) - _wanted devices expl 'device' _files -g "/dev/**" && ret=0 - ;; - esac - else - local modes; modes=( - 'tcp:TCP socket' - 'localabstract:local abstract socket' - 'localreserved:local reserved socket' - 'localfilesystem:local filesystem socket' - 'dev:device' - ) - _describe -t forward-modes 'forward mode' modes -qS: && ret=0 - fi - return ret -} - -(( $+functions[_adb_remote_forward_specs] )) || -_adb_remote_forward_specs() { - local ret=1 - if compset -P '*:'; then - case ${IPREFIX%:} in - (tcp) - _message -e ports 'remote port' && ret=0 - ;; - (localabstract|localreserved|localfilesystem) - _message -e sockets 'remote socket' && ret=0 - ;; - (dev) - _message -e devices 'remote device' && ret=0 - ;; - (jdwp) - local pids; pids=(${${(f)"$(_call_program pids $service $adb_args jdwp 2>/dev/null)"}:#\**\*}) - _describe -t remote-pids 'remote pid' pids && ret=0 - ;; - esac - else - local modes; modes=( - 'tcp:TCP socket' - 'localabstract:local abstract socket' - 'localreserved:local reserved socket' - 'localfilesystem:local filesystem socket' - 'dev:device' - 'jdwp:Java Debug Wire Protocol' - ) - _describe -t forward-modes 'forward mode' modes -qS: && ret=0 - fi - return ret -} - -(( $+functions[_adb_sync_directories] )) || -_adb_sync_directories() { - _alternative \ - 'partitions:partition:((system:the\ /system\ partition data:the\ /data\ partition))' \ - 'directories:directory:_adb_remote_files -/' -} - -(( $+functions[_adb_logcat_filter_specs] )) || -_adb_logcat_filter_specs() { - local ret=1 - if compset -P '*:'; then - local priorities; priorities=( - 'V:verbose (lowest priority)' - 'D:debug' - 'I:info' - 'W:warning' - 'E:error' - 'F:fatal' - 'S:silent (highest priority, on which nothing is ever printed)' - ) - _describe -t log-priorities 'log priority' priorities "$@" && ret=0 - else - local tags; tags=(${(u)${${${(f)"$(_call_program tags $service $adb_args logcat -d 2>/dev/null)"}%%[[:space:]]#\(*}##*\/}:#\**\*}) - _describe -t log-tags 'log tag' tags -qS: "$@" && ret=0 - fi - return ret -} - -(( $+functions[_adb_logcat_output_formats] )) || -_adb_logcat_output_formats() { - local formats; formats=( - 'brief:display priority/tag and PID of originating process (the default format)' - 'process:display PID only' - 'tag:display the priority/tag only' - 'thread:display process:thread and priority/tag only' - 'raw:display the raw log message, with no other metadata fields' - 'time:display the date, invocation time, priority/tag, and PID of the originating process' - 'long:display all metadata fields and separate messages with a blank lines' - ) - _describe -t log-formats 'log format' formats "$@" && ret=0 -} - -(( $+functions[_adb_logcat_buffers] )) || -_adb_logcat_buffers() { - local buffers; buffers=( - 'main:view the main log buffer (default)' - 'radio:view the buffer that contains radio/telephony related messages' - 'events:view the buffer containing events-related messages' - ) - _describe -t log-buffers 'log buffer' buffers "$@" && ret=0 -} - -(( $+functions[_adb_remote_command_default] )) || -_adb_remote_command_default() { - _wanted remote-files expl 'remote file' _adb_remote_files -} - -_adb "$@" - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_afew b/.zprezto/modules/completion/external/src/_afew new file mode 100644 index 0000000..15a9ab7 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_afew @@ -0,0 +1,72 @@ +#compdef afew +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for afew an initial tagging script for notmuch mail. (https://github.com/teythoon/afew) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + +_afew() { + + _arguments -C \ + '(- 1 *)'-h"[Show help and exit]" \ + "(-c --classify -l --learn= -t --tag -u --update -U --update-reference -m --move-mails)"{-w,--watch}"[Continuously monitor the mailbox for new messages matching the given query]" \ + "(-c --classify -l --learn= -u --update -U --update-reference -m --move-mails -w --watch)"{-t,--tag}"[Run the tag filters]" \ + "(-c --classify -t --tag -u --update -U --update-reference -m --move-mails -w --watch)"{-l,--learn=}"[Train category with the messages matching query]" \ + "(-c --classify -l --learn= -t --tag -U --update-reference -m --move-mails -w --watch)"{-u,--update}"[Update the categories (requires no query)]" \ + "(-c --classify -l --learn= -t --tag -u --update -m --move-mails -w --watch)"{-U,--update-reference}"[Update the reference category (takes quite some time) (requires no query)]" \ + "(-l --learn= -t --tag -u --update -U --update-reference -m --move-mails -w --watch)"{-c,--classify}"[Classify each message matching the iven query]" \ + "(-c --classify -l --learn= -t --tag -u --update -U --update-reference -w --watch)"{-m,--move-mails}"[Move mail files between maildir folders]" \ + "(-n --all)"{-a,--all}"[Operate on all email]" \ + "(-a --new)"{-n,--new}"[Operate on all new email]" \ + {-C,--notmuch-config=}"[Path to notmuch configuration file]:files:_files" \ + {-e,--enable-filters=}"[Flter classes to use]:filters" \ + {-d,--dry-run}"[Dont change the DB]" \ + {-R,--reference-set-size=}"[Size of the reference set (default: 1000)]:size:" \ + {-T,--reference-set-timeframe-days=}"[Do not use emails older than DAYS days (default: 30)]:days:" \ + {--verbose,-v}"[Be more verbose]" \ + '*:Query:' \ + +} + +_afew + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_ag b/.zprezto/modules/completion/external/src/_ag deleted file mode 100644 index 6a41710..0000000 --- a/.zprezto/modules/completion/external/src/_ag +++ /dev/null @@ -1,217 +0,0 @@ -#compdef ag -# ------------------------------------------------------------------------------ -# Copyright (c) 2015 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for ag (https://github.com/ggreer/the_silver_searcher) -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Akira Maeda -# -# ------------------------------------------------------------------------------ -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------ -_ag_version() { - local version - version=( $($words[1] --version) ) - version=${version[@]:2:1} - version=( "${(@s/./)version}" ) - echo "${version[2]}" -} - -# Dynamically build the file type completion -# Modifies the global $AG_OPTS array -_ag_add_file_types() { - local typ exts - for i in $($words[1] --list-file-types); do - if [[ "${i:0:2}" = '--' ]]; then - if [[ "${typ}x" != "x" ]]; then - AG_OPTS+="${typ}[${exts}]" - fi - typ=$i - exts= - else - exts+=$i - fi - done - AG_OPTS+="${typ}[${exts}]" -} - -# Add version appropriate options above base -# Modifies the global $AG_OPTS array -_ag_add_version_opts() { - local minor=$(_ag_version) - - if [[ $minor -gt 21 ]];then - _ag_add_file_types - AG_OPTS+=( - '(- 1 *)--list-file-types[list supported filetypes to search]' - '--silent[suppress all log messages, including errors]' - ) - fi - - if [[ $minor -gt 22 ]];then - AG_OPTS+=( - '(-z --search-zip)'{-z,--search-zip}'[search contents of compressed files]' - ) - fi - - if [[ $minor -le 24 ]];then - AG_OPTS+=( - '(-s --case-sensitive)'{-s,--case-sensitive}'[match case sensitively]' - '(--noheading --heading)'{--noheading,--heading}'[print file names above matching contents]' - ) - fi - if [[ $minor -gt 24 ]];then - AG_OPTS+=( - '(-s --case-sensitive)'{-s,--case-sensitive}'[Match case sensitively. Default on.]' - '(-H --noheading --heading)'{-H,--noheading,--heading}'[print file names above matching contents]' - '--vimgrep[output results like vim''s, :vimgrep /pattern/g would (report every match on the line)]' - ) - fi - - if [[ $minor -gt 26 ]];then - AG_OPTS+=( - '(-0 --null --print0)'{-0,--null,--print0}'[separate the filenames with \\0, rather than \\n]' - ) - fi - - if [[ $minor -le 27 ]];then - AG_OPTS+=( - '--depth[Search up to NUM directories deep. Default is 25.]:number' - ) - fi - if [[ $minor -gt 27 ]];then - AG_OPTS+=( - '(-c --count)'{-c,--count}'[only print the number of matches in each file]' - '--depth[Search up to NUM directories deep, -1 for unlimited. Default is 25.]:number' - '(-F --fixed-strings)'{-F,--fixed-strings}'[alias for --literal for compatibility with grep]' - ) - fi - - if [[ $minor -le 28 ]];then - AG_OPTS+=( - '(--no-numbers)--no-numbers[don´t show line numbers]' - ) - fi - if [[ $minor -gt 28 ]];then - AG_OPTS+=( - '(--nofilename --filename)'{--nofilename,--filename}'[Print file names. Default on, except when searching a single file.]' - '(--nonumbers --numbers)'{--nonumbers,--numbers}'[Print line numbers. Default is to omit line numbers when searching streams]' - '(-o --only-matching)'{-o,--only-matching}'[print only the matching part of the lines]' - ) - fi -} - -_ag() { - local curcontext="$curcontext" state line cmds update_policy ret=1 - - zstyle -s ":completion:${curcontext}:" cache-policy update_policy - [[ -z "$update_policy" ]] && zstyle ":completion:${curcontext}:" cache-policy _ag_types_caching_policy - - # Don't complete if command doesn't exist - [[ ${+commands[${words[1]}]} -eq 0 ]] && return 0 - - if ( [[ ${+AG_OPTS} -eq 0 ]] || _cache_invalid "_AG_OPTS" ) && ! _retrieve_cache "_AG_OPTS"; then - # Base opts starts at ag version 0.20 - AG_OPTS=( - '(- 1 *)--help[print a short help statement]' - '(- 1 *)--man[print the manual page]' - '(- 1 *)--version[display version and copyright information]' - '--ackmate[output results in a format parseable by AckMate]' - '(-A --after)'{-A,--after}'[Print NUM lines before match. Default is 2]:number' - '(-t --all-text -a --all-types -u --unrestricted)'{-t,--all-text}"[search all text files, excluding hidden ones]" - '(-a --all-types -t --all-text -u --unrestricted)'{-a,--all-types}"[search all text files, excluding hidden ones and not obeying ignore files (.agignore, .gitignore...)]" - '(-B --before)'{-B,--before}'[Print NUM lines after match. Defaults is 2]:number' - '(--nobreak --break)'{--nobreak,--break}'[Print a newline between matches in different files. Default on.]' - '(--color --nocolor)--color[Print color codes in results. Default on.]' - '(--nocolor --color --color-line-number --color-match --color-path)--nocolor[Do not print color codes in results. Default on.]' - '(--nocolor)--color-line-number[Color codes for line numbers. Default is 1;33.]' - '(--nocolor)--color-match[Color codes for result match numbers. Default is 30;43.]' - '(--nocolor)--color-path[Color codes for path names. Default is 1;32.]' - '--column[print column numbers in results]' - '(-C --context)'{-C,--context}'[Print NUM lines before and after matches. Default is 2.]:number' - '(-D --debug)'{-D,--debug}'[enable debug logging]' - '(-G --file-search-regex)'{-G,--file-search-regex}'[only search file names matching PATTERN]:pattern' - '(-l --files-with-matches)'{-l,--files-with-matches}'[only print filenames containing matches, not matching lines]' - '(-L --files-without-matches)'{-L,--files-without-matches}"[only print filenames that don't contain matches]" - '(-f --follow)'{-f,--follow}'[follow symlinks]' - '(-g)-g[print filenames that match PATTERN]:pattern' - '(--nogroup --group)'{--nogroup,--group}'[same as --\[no\]break --\[no\]heading]' - '--hidden[search hidden files, still obeys ignore files.]' - '*--ignore[Ignore files/directories matching this pattern. Literal file and directory names are also allowed.]:files:_files' - '(-i --ignore-case)'{-i,--ignore-case}'[match case insensitively]:pattern' - '*--ignore-dir[alias for --ignore for compatibility with ack]:files:_files' - '(-v --invert-match)'{-v,--invert-match}'[invert match]' - '(-Q --literal)'{-Q,--literal}'[match PATTERN literally, no regular expression]' - '(-m --max-count)'{-m,--max-count}'[Skip the rest of a file after NUM matches. Default is 10,000.]:number' - '(--pager --nopager)'{--pager,--nopager}'[Display results with PAGER. Disabled by default.]:pager program:_command_names' - '(--passthrough)--passthrough[when searching a stream, print all lines even if they don''t match]' - '(-p --path-to-agignore)'{-p,--path-to-agignore}'[provide a path to a specific .agignore file]:files:_files' - '--print-long-lines[print matches on very long lines, > 2k characters by default]' - '--search-binary[search binary files]' - '(-U --skip-vcs-ignores)'{-U,--skip-vcs-ignores}'[ignore VCS ignore files (.gitigore, .hgignore, svn:ignore), but still use .agignore]' - '(-S --smart-case)'{-S,--smart-case}'[match case sensitively if PATTERN contains any uppercase letters, else match case insensitively]' - '--stats[print stats (files scanned, time taken, etc)]' - '(-u --unrestricted -t --all-text -a --all-types)'{-u,--unrestricted}'[search ALL files, includes: hidden, binary & ignored files (.agignore, .gitignore...)]' - '(-w --word-regexp)'{-w,--word-regexp}'[only match whole words]' - ) - _ag_add_version_opts - AG_OPTS+=( - '*: :_files' - ) - [[ $#AG_OPTS -gt 0 ]] && _store_cache '_AG_OPTS' AG_OPTS - fi - - _arguments -C -s -S ${AG_OPTS} && ret=0 - unset AG_OPTS - - case $state in - # placeholder - esac - - return ret -} - -_ag_types_caching_policy() { - # Rebuild if .agignore more recent than cache. - [[ -f $HOME/.agignore && $$HOME/.agignore -nt "$1" ]] && return 0 - - # Rebuild if cache is older than one week. - local -a oldp - oldp=( "$1"(Nmw+1) ) - (( $#oldp )) && return 0 - - return 1 -} - -_ag "$@" diff --git a/.zprezto/modules/completion/external/src/_android b/.zprezto/modules/completion/external/src/_android index fcad746..c26e2f8 100644 --- a/.zprezto/modules/completion/external/src/_android +++ b/.zprezto/modules/completion/external/src/_android @@ -1,30 +1,5 @@ #compdef android # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # @@ -238,6 +213,8 @@ _android_cmds() { 'update:update a virtual device, project, SDK or adb' 'move:move a virtual device' 'delete:delete a virtual device' + 'avd:displays the AVD Manager window' + 'sdk:displays the SDK Manager window' 'display:display manager windows' ) _describe -t commands 'command' commands "$@" diff --git a/.zprezto/modules/completion/external/src/_ansible b/.zprezto/modules/completion/external/src/_ansible index faabf04..e3a1d0c 100644 --- a/.zprezto/modules/completion/external/src/_ansible +++ b/.zprezto/modules/completion/external/src/_ansible @@ -28,13 +28,14 @@ # Description # ----------- # -# Completion script for ansible v1.8.4 (http://ansible.org) +# Completion script for ansible v2.0.0.2 (http://ansible.org) # # ------------------------------------------------------------------------------ # Authors # ------- # # * Romain Bossart (https://github.com/bosr) +# * Adam Stevko (https://github.com/xen0l) # # ------------------------------------------------------------------------------ # @@ -61,6 +62,7 @@ __host_file_location () { [[ "$OSTYPE" == darwin* ]] && FALLBACK="/usr/local/etc/ansible/hosts" [[ "$OSTYPE" == linux* ]] && FALLBACK="/etc/ansible/hosts" HOST_FILE=${ANSIBLE_HOSTS:=${FALLBACK}} + [[ -f ${HOST_FILE} ]] || HOST_FILE="$PWD/ansible/inventory/hosts" [[ -f ${HOST_FILE} ]] || HOST_FILE=/dev/null echo ${HOST_FILE} @@ -91,7 +93,7 @@ __host_list () local -a mixed_host_list mixed_host_list=$(command \ cat ${HOST_FILE} \ - | awk 'NF && $1 !~ /[\[:=]/ { print $1 }' \ + | awk 'NF && $1 !~ /^[[:space:]]*#|[\[:=]/ { print $1 }' \ | sort | uniq) # compute set difference h1 - h2 @@ -120,15 +122,16 @@ __group_list () _modules=( -'a10_server:(E) Manage A10 Networks AX/SoftAX/Thunder/vThunder devices' -'a10_service_group:(E) Manage A10 Networks AX/SoftAX/Thunder/vThunder devices' -'a10_virtual_server:(E) Manage A10 Networks AX/SoftAX/Thunder/vThunder devices' +'a10_server:Manage A10 Networks AX/SoftAX/Thunder/vThunder devices' +'a10_service_group:Manage A10 Networks devices’ service groups' +'a10_virtual_server:Manage A10 Networks devices’ virtual servers' 'accelerate:Enable accelerated mode on remote node' 'acl:Sets and retrieves file ACL information.' 'add_host:add a host (and alternatively a group) to the ansible-playbook in-memory inventory' -'airbrake_deployment:(E) Notify airbrake about app deployments' -'alternatives:(E) Manages alternative programs for common commands' +'airbrake_deployment:Notify airbrake about app deployments' +'alternatives:Manages alternative programs for common commands' 'apache2_module:enables/disables a module of the Apache2 webserver' +'apk:Manages apk packages' 'apt:Manages apt-packages' 'apt_key:Add or remove an apt key' 'apt_repository:Add and remove APT repositories' @@ -136,165 +139,334 @@ _modules=( 'assemble:Assembles a configuration file from fragments' 'assert:Fail with custom message' 'async_status:Obtain status of asynchronous task' -'at:(E) Schedule the execution of a command or script file via the at command.' +'at:Schedule the execution of a command or script file via the at command.' 'authorized_key:Adds or removes an SSH authorized key' 'azure:create or terminate a virtual machine in azure' -'bigip_facts:(E) Collect facts from F5 BIG-IP devices' -'bigip_monitor_http:(E) Manages F5 BIG-IP LTM http monitors' -'bigip_monitor_tcp:(E) Manages F5 BIG-IP LTM tcp monitors' -'bigip_node:(E) Manages F5 BIG-IP LTM nodes' -'bigip_pool:(E) Manages F5 BIG-IP LTM pools' -'bigip_pool_member:(E) Manages F5 BIG-IP LTM pool members' -'bigpanda:(E) Notify BigPanda about deployments' -'boundary_meter:(E) Manage boundary meters' -'bower:(E) Manage bower packages with bower' -'bzr:(E) Deploy software (or files) from bzr branches' -'campfire:(E) Send a message to Campfire' -'capabilities:(E) Manage Linux capabilities' -'cloudformation:create a AWS CloudFormation stack' +'bigip_facts:Collect facts from F5 BIG-IP devices' +'bigip_gtm_wide_ip:Manages F5 BIG-IP GTM wide ip' +'bigip_monitor_http:Manages F5 BIG-IP LTM http monitors' +'bigip_monitor_tcp:Manages F5 BIG-IP LTM tcp monitors' +'bigip_node:Manages F5 BIG-IP LTM nodes' +'bigip_pool:Manages F5 BIG-IP LTM pools' +'bigip_pool_member:Manages F5 BIG-IP LTM pool members' +'bigip_virtual_server:Manages F5 BIG-IP LTM virtual servers' +'bigpanda:Notify BigPanda about deployments' +'blockinfile:Insert/update/remove a text block surrounded by marker lines.' +'boundary_meter:Manage boundary meters' +'bower:Manage bower packages with bower' +'bundler:Manage Ruby Gem dependencies with Bundler' +'bzr:Deploy software (or files) from bzr branches' +'campfire:Send a message to Campfire' +'capabilities:Manage Linux capabilities' +'circonus_annotation:create an annotation in circonus' +'cl_bond:Configures a bond port on Cumulus Linux' +'cl_bridge:Configures a bridge port on Cumulus Linux' +'cl_img_install:Install a different Cumulus Linux version.' +'cl_interface:Configures a front panel port, loopback or management port on Cumulus Linux.' +'cl_interface_policy:Configure interface enforcement policy on Cumulus Linux' +'cl_license:Install Cumulus Linux license' +'cl_ports:Configure Cumulus Switch port attributes (ports.conf)' +'clc_aa_policy:Create or Delete Anti Affinity Policies at CenturyLink Cloud.' +'clc_alert_policy:Create or Delete Alert Policies at CenturyLink Cloud.' +'clc_blueprint_package:deploys a blue print package on a set of servers in CenturyLink Cloud.' +'clc_firewall_policy:Create/delete/update firewall policies' +'clc_group:Create/delete Server Groups at Centurylink Cloud' +'clc_loadbalancer:Create, Delete shared loadbalancers in CenturyLink Cloud.' +'clc_modify_server:modify servers in CenturyLink Cloud.' +'clc_publicip:Add and Delete public ips on servers in CenturyLink Cloud.' +'clc_server:Create, Delete, Start and Stop servers in CenturyLink Cloud.' +'clc_server_snapshot:Create, Delete and Restore server snapshots in CenturyLink Cloud.' +'cloudflare_dns:manage Cloudflare DNS records' +'cloudformation:Create or delete an AWS CloudFormation stack' +'cloudtrail:manage CloudTrail creation and deletion' 'command:Executes a command on a remote node' -'composer:(E) Dependency Manager for PHP' +'composer:Dependency Manager for PHP' +'consul:Add, modify & delete services within a consul cluster.' +'consul_acl:manipulate consul acl keys and rules' +'consul_kv:Manipulate entries in the key/value store of a consul cluster.' +'consul_session:manipulate consul sessions' 'copy:Copies files to remote locations.' -'cpanm:(E) Manages Perl library dependencies.' +'cpanm:Manages Perl library dependencies.' 'cron:Manage cron.d and crontab entries.' -'crypttab:(E) Encrypted Linux block devices' -'datadog_event:(E) Posts events to DataDog service' -'debconf:(E) Configure a .deb package' +'cronvar:Manage variables in crontabs' +'crypttab:Encrypted Linux block devices' +'cs_account:Manages accounts on Apache CloudStack based clouds.' +'cs_affinitygroup:Manages affinity groups on Apache CloudStack based clouds.' +'cs_cluster:Manages host clusters on Apache CloudStack based clouds.' +'cs_configuration:Manages configuration on Apache CloudStack based clouds.' +'cs_domain:Manages domains on Apache CloudStack based clouds.' +'cs_facts:Gather facts on instances of Apache CloudStack based clouds.' +'cs_firewall:Manages firewall rules on Apache CloudStack based clouds.' +'cs_instance:Manages instances and virtual machines on Apache CloudStack based clouds.' +'cs_instance_facts:Gathering facts from the API of instances from Apache CloudStack based clouds.' +'cs_instancegroup:Manages instance groups on Apache CloudStack based clouds.' +'cs_ip_address:Manages public IP address associations on Apache CloudStack based clouds.' +'cs_iso:Manages ISO images on Apache CloudStack based clouds.' +'cs_loadbalancer_rule:Manages load balancer rules on Apache CloudStack based clouds.' +'cs_loadbalancer_rule_member:Manages load balancer rule members on Apache CloudStack based clouds.' +'cs_network:Manages networks on Apache CloudStack based clouds.' +'cs_pod:Manages pods on Apache CloudStack based clouds.' +'cs_portforward:Manages port forwarding rules on Apache CloudStack based clouds.' +'cs_project:Manages projects on Apache CloudStack based clouds.' +'cs_resourcelimit:Manages resource limits on Apache CloudStack based clouds.' +'cs_securitygroup:Manages security groups on Apache CloudStack based clouds.' +'cs_securitygroup_rule:Manages security group rules on Apache CloudStack based clouds.' +'cs_sshkeypair:Manages SSH keys on Apache CloudStack based clouds.' +'cs_staticnat:Manages static NATs on Apache CloudStack based clouds.' +'cs_template:Manages templates on Apache CloudStack based clouds.' +'cs_user:Manages users on Apache CloudStack based clouds.' +'cs_vmsnapshot:Manages VM snapshots on Apache CloudStack based clouds.' +'cs_volume:Manages volumes on Apache CloudStack based clouds.' +'cs_zone:Manages zones on Apache CloudStack based clouds.' +'cs_zone_facts:Gathering facts of zones from Apache CloudStack based clouds.' +'datadog_event:Posts events to DataDog service' +'datadog_monitor:Manages Datadog monitors' +'debconf:Configure a .deb package' 'debug:Print statements during execution' +'deploy_helper:Manages some of the steps common in deploying projects.' 'digital_ocean:Create/delete a droplet/SSH_key in DigitalOcean' 'digital_ocean_domain:Create/delete a DNS record in DigitalOcean' 'digital_ocean_sshkey:Create/delete an SSH key in DigitalOcean' 'django_manage:Manages a Django application.' -'dnf:(E) Manages packages with the I(dnf) package manager' -'dnsimple:(E) Interface with dnsimple.com (a DNS hosting service).' -'dnsmadeeasy:(E) Interface with dnsmadeeasy.com (a DNS hosting service).' +'dnf:Manages packages with the *dnf* package manager' +'dnsimple:Interface with dnsimple.com (a DNS hosting service).' +'dnsmadeeasy:Interface with dnsmadeeasy.com (a DNS hosting service).' 'docker:manage docker containers' -'docker_image (D):manage docker images' +'docker_image:manage docker images' +'docker_login:Manage Docker registry logins' +'dpkg_selections:Dpkg package selection selections' +'dynamodb_table:Create, update or delete AWS Dynamo DB tables.' 'easy_install:Installs Python libraries' 'ec2:create, terminate, start or stop an instance in ec2' 'ec2_ami:create or destroy an image in ec2' -'ec2_ami_search:Retrieve AWS AMI information for a given operating system.' +'ec2_ami_copy:copies AMI between AWS regions, return new image id' +'ec2_ami_find:Searches for AMIs to obtain the AMI ID and other information' +'ec2_ami_search(D):Retrieve AWS AMI information for a given operating system.' 'ec2_asg:Create or delete AWS Autoscaling Groups' 'ec2_eip:associate an EC2 elastic IP with an instance.' 'ec2_elb:De-registers or registers instances from EC2 ELBs' +'ec2_elb_facts:Gather facts about EC2 Elastic Load Balancers in AWS' 'ec2_elb_lb:Creates or destroys Amazon ELB.' +'ec2_eni:Create and optionally attach an Elastic Network Interface (ENI) to an instance' +'ec2_eni_facts:Gather facts about ec2 ENI interfaces in AWS' 'ec2_facts:Gathers facts about remote hosts within ec2 (aws)' 'ec2_group:maintain an ec2 VPC security group.' 'ec2_key:maintain an ec2 key pair.' 'ec2_lc:Create or delete AWS Autoscaling Launch Configurations' 'ec2_metric_alarm:Create/update or delete AWS Cloudwatch ‘metric alarms’' +'ec2_remote_facts:Gather facts about ec2 instances in AWS' 'ec2_scaling_policy:Create or delete AWS scaling policies for Autoscaling groups' 'ec2_snapshot:creates a snapshot from an existing volume' 'ec2_tag:create and remove tag(s) to ec2 resources.' 'ec2_vol:create and attach a volume, return volume id and device map' +'ec2_vol_facts:Gather facts about ec2 volumes in AWS' 'ec2_vpc:configure AWS virtual private clouds' -'ejabberd_user:(E) Manages users for ejabberd servers' +'ec2_vpc_dhcp_options:Manages DHCP Options, and can ensure the DHCP options for the given VPC match what’s requested' +'ec2_vpc_igw:Manage an AWS VPC Internet gateway' +'ec2_vpc_net:Configure AWS virtual private clouds' +'ec2_vpc_net_facts:Gather facts about ec2 VPCs in AWS' +'ec2_vpc_route_table:Manage route tables for AWS virtual private clouds' +'ec2_vpc_route_table_facts:Gather facts about ec2 VPC route tables in AWS' +'ec2_vpc_subnet:Manage subnets in AWS virtual private clouds' +'ec2_vpc_subnet_facts:Gather facts about ec2 VPC subnets in AWS' +'ec2_win_password:gets the default administrator password for ec2 windows instances' +'ecs_cluster:create or terminate ecs clusters' +'ecs_service:create, terminate, start or stop a service in ecs' +'ecs_service_facts:list or describe services in ecs' +'ecs_task:run, start or stop a task in ecs' +'ecs_taskdefinition:register a task definition in ecs' +'ejabberd_user:Manages users for ejabberd servers' 'elasticache:Manage cache clusters in Amazon Elasticache.' -'facter:(E) Runs the discovery program I(facter) on the remote system' +'elasticache_subnet_group:manage Elasticache subnet groups' +'elasticsearch_plugin:Manage Elasticsearch plugins' +'eos_command:Run arbitrary command on EOS device' +'eos_config:Manage Arista EOS configuration sections' +'eos_eapi:Manage and configure EAPI. Requires EOS v4.12 or greater.' +'eos_template:Manage Arista EOS device configurations' +'expect:Executes a command and responds to prompts' +'facter:Runs the discovery program *facter* on the remote system' 'fail:Fail with custom message' 'fetch:Fetches a file from remote nodes' 'file:Sets attributes of files' -'filesystem:(E) Makes file system on block device' -'fireball:Enable fireball mode on remote node' -'firewalld:(E) Manage arbitrary ports/services with firewalld' -'flowdock:(E) Send a message to a flowdock' +'filesystem:Makes file system on block device' +'find:return a list of files based on specific criteria' +'fireball(D):Enable fireball mode on remote node' +'firewalld:Manage arbitrary ports/services with firewalld' +'flowdock:Send a message to a flowdock' 'gc_storage:This module manages objects/buckets in Google Cloud Storage.' 'gce:create or terminate GCE instances' -'gce_img:(E) utilize GCE image resources' +'gce_img:utilize GCE image resources' 'gce_lb:create/destroy GCE load-balancer resources' 'gce_net:create/destroy GCE networks and firewall rules' 'gce_pd:utilize GCE persistent disk resources' +'gce_tag:add or remove tag(s) to/from GCE instance' 'gem:Manage Ruby gems' 'get_url:Downloads files from HTTP, HTTPS, or FTP to node' -'getent:(E) a wrapper to the unix getent utility' +'getent:a wrapper to the unix getent utility' 'git:Deploy software (or files) from git checkouts' -'github_hooks:(E) Manages github service hooks.' -'glance_image:Add/Delete images from glance' -'gluster_volume:(E) Manage GlusterFS volumes' +'github_hooks:Manages github service hooks.' +'glance_image(D):Add/Delete images from glance' +'gluster_volume:Manage GlusterFS volumes' 'group:Add or remove groups' 'group_by:Create Ansible groups based on facts' -'grove:(E) Sends a notification to a grove.io channel' -'haproxy:(E) An Ansible module to handle states enable/disable server and set weight to backend host in haproxy using socket commands.' +'grove:Sends a notification to a grove.io channel' +'hall:Send notification to Hall' +'haproxy:Enable, disable, and set weights for HAProxy backend servers using socket commands.' 'hg:Manages Mercurial (hg) repositories.' -'hipchat:(E) Send a message to hipchat' -'homebrew:(E) Package manager for Homebrew' -'homebrew_cask:(E) Install/uninstall homebrew casks.' -'homebrew_tap:(E) Tap a Homebrew repository.' +'hipchat:Send a message to hipchat.' +'homebrew:Package manager for Homebrew' +'homebrew_cask:Install/uninstall homebrew casks.' +'homebrew_tap:Tap a Homebrew repository.' 'hostname:Manage hostname' 'htpasswd:manage user files for basic authentication' +'iam:Manage IAM users, groups, roles and keys' +'iam_cert:Manage server certificates for use on ELBs and CloudFront' +'iam_policy:Manage IAM policies for users, groups, and roles' 'include_vars:Load variables from files, dynamically within a task.' 'ini_file:Tweak settings in INI files' -'irc:(E) Send a message to an IRC channel' -'jabber:(E) Send a message to jabber user or chat room' -'jboss:(E) deploy applications to JBoss' -'jira:(E) create and modify issues in a JIRA instance' -'kernel_blacklist:(E) Blacklist kernel modules' -'keystone_user:Manage OpenStack Identity (keystone) users, tenants and roles' -'layman:(E) Manage Gentoo overlays' -'librato_annotation:(E) create an annotation in librato' +'ios_command:Run arbitrary commands on ios devices.' +'ios_config:Manage Cisco IOS configuration sections' +'ios_template:Manage Cisco IOS device configurations over SSH' +'iosxr_command:Run arbitrary commands on ios devices.' +'iosxr_config:Manage Cisco IOS XR configuration sections' +'iosxr_template:Manage Cisco IOS device configurations over SSH' +'ipify_facts:Retrieve the public IP of your internet gateway.' +'iptables:Modify the systems iptables' +'irc:Send a message to an IRC channel' +'jabber:Send a message to jabber user or chat room' +'jboss:deploy applications to JBoss' +'jira:create and modify issues in a JIRA instance' +'junos_command:Execute arbitrary commands on Juniper JUNOS devices' +'junos_config:Manage Juniper JUNOS configuration sections' +'junos_template:Manage Juniper JUNOS device configurations' +'kernel_blacklist:Blacklist kernel modules' +'keystone_user(D):Manage OpenStack Identity (keystone) users, tenants and roles' +'known_hosts:Add or remove a host from the ``known_hosts`` file' +'layman:Manage Gentoo overlays' +'librato_annotation:create an annotation in librato' 'lineinfile:Ensure a particular line is in a file, or replace an existing line using a back-referenced regular expression.' 'linode:create / delete / stop / restart an instance in Linode Public Cloud' -'lldp:(E) get details reported by lldp' -'locale_gen:(E) Creates or removes locales.' -'logentries:(E) Module for tracking logs via logentries.com' -'lvg:(E) Configure LVM volume groups' -'lvol:(E) Configure LVM logical volumes' -'macports:(E) Package manager for MacPorts' -'mail:(E) Send an email' -'modprobe:(E) Add or remove kernel modules' -'mongodb_user:(E) Adds or removes a user from a MongoDB database.' -'monit:(E) Manage the state of a program monitored via Monit' +'lldp:get details reported by lldp' +'locale_gen:Creates or removes locales.' +'logentries:Module for tracking logs via logentries.com' +'lvg:Configure LVM volume groups' +'lvol:Configure LVM logical volumes' +'lxc_container:Manage LXC Containers' +'macports:Package manager for MacPorts' +'mail:Send an email' +'maven_artifact:Downloads an Artifact from a Maven Repository' +'modprobe:Add or remove kernel modules' +'mongodb_user:Adds or removes a user from a MongoDB database.' +'monit:Manage the state of a program monitored via Monit' 'mount:Control active and configured mount points' -'mqtt:(E) Publish a message on an MQTT topic for the IoT' +'mqtt:Publish a message on an MQTT topic for the IoT' 'mysql_db:Add or remove MySQL databases from a remote host.' -'mysql_replication:(E) Manage MySQL replication' +'mysql_replication:Manage MySQL replication' 'mysql_user:Adds or removes a user from a MySQL database.' 'mysql_variables:Manage MySQL global variables' -'nagios:(E) Perform common tasks in Nagios related to downtime and notifications.' -'netscaler:(E) Manages Citrix NetScaler entities' -'newrelic_deployment:(E) Notify newrelic about app deployments' -'nexmo:(E) Send a SMS via nexmo' -'nova_compute:Create/Delete VMs from OpenStack' -'nova_keypair:Add/Delete key pair from nova' -'npm:(E) Manage node.js packages with npm' -'ohai:(E) Returns inventory data from I(Ohai)' -'open_iscsi:(E) Manage iscsi targets with open-iscsi' -'openbsd_pkg:(E) Manage packages on OpenBSD.' -'openvswitch_bridge:(E) Manage Open vSwitch bridges' -'openvswitch_port:(E) Manage Open vSwitch ports' -'opkg:(E) Package manager for OpenWrt' -'osx_say:(E) Makes an OSX computer to speak.' -'ovirt:(E) oVirt/RHEV platform management' -'pacman:(E) Manage packages with I(pacman)' -'pagerduty:(E) Create PagerDuty maintenance windows' -'patch:(E) Apply patch files using the GNU patch tool.' +'nagios:Perform common tasks in Nagios related to downtime and notifications.' +'netscaler:Manages Citrix NetScaler entities' +'newrelic_deployment:Notify newrelic about app deployments' +'nexmo:Send a SMS via nexmo' +'nmcli:Manage Networking' +'nova_compute(D):Create/Delete VMs from OpenStack' +'nova_keypair(D):Add/Delete key pair from nova' +'npm:Manage node.js packages with npm' +'nxos_command:Run arbitrary command on Cisco NXOS devices' +'nxos_config:Manage Cisco NXOS configuration sections' +'nxos_nxapi:Manage NXAPI configuration on an NXOS device.' +'nxos_template:Manage Cisco NXOS device configurations' +'ohai:Returns inventory data from *Ohai*' +'open_iscsi:Manage iscsi targets with open-iscsi' +'openbsd_pkg:Manage packages on OpenBSD.' +'openvswitch_bridge:Manage Open vSwitch bridges' +'openvswitch_db:Configure open vswitch database.' +'openvswitch_port:Manage Open vSwitch ports' +'opkg:Package manager for OpenWrt' +'ops_command:Run arbitrary commands on OpenSwitch devices.' +'ops_config:Manage OpenSwitch configuration using CLI' +'ops_template:Push configuration to OpenSwitch' +'os_auth:Retrieve an auth token' +'os_client_config:Get OpenStack Client config' +'os_flavor_facts:Retrieve facts about one or more flavors' +'os_floating_ip:Add/Remove floating IP from an instance' +'os_group:Manage OpenStack Identity Groups' +'os_image:Add/Delete images from OpenStack Cloud' +'os_image_facts:Retrieve facts about an image within OpenStack.' +'os_ironic:Create/Delete Bare Metal Resources from OpenStack' +'os_ironic_node:Activate/Deactivate Bare Metal Resources from OpenStack' +'os_keypair:Add/Delete a keypair from OpenStack' +'os_keystone_domain:Manage OpenStack Identity Domains' +'os_keystone_role:Manage OpenStack Identity Roles' +'os_network:Creates/removes networks from OpenStack' +'os_networks_facts:Retrieve facts about one or more OpenStack networks.' +'os_nova_flavor:Manage OpenStack compute flavors' +'os_object:Create or Delete objects and containers from OpenStack' +'os_port:Add/Update/Delete ports from an OpenStack cloud.' +'os_project:Manage OpenStack Projects' +'os_router:Create or delete routers from OpenStack' +'os_security_group:Add/Delete security groups from an OpenStack cloud.' +'os_security_group_rule:Add/Delete rule from an existing security group' +'os_server:Create/Delete Compute Instances from OpenStack' +'os_server_actions:Perform actions on Compute Instances from OpenStack' +'os_server_facts:Retrieve facts about one or more compute instances' +'os_server_volume:Attach/Detach Volumes from OpenStack VM’s' +'os_subnet:Add/Remove subnet to an OpenStack network' +'os_subnets_facts:Retrieve facts about one or more OpenStack subnets.' +'os_user:Manage OpenStack Identity Users' +'os_user_group:Associate OpenStack Identity users and groups' +'os_volume:Create/Delete Cinder Volumes' +'osx_defaults:osx_defaults allows users to read, write, and delete Mac OS X user defaults from Ansible' +'osx_say:Makes an OSX computer to speak.' +'ovirt:oVirt/RHEV platform management' +'package:Generic OS package manager' +'pacman:Manage packages with *pacman*' +'pagerduty:Create PagerDuty maintenance windows' +'pagerduty_alert:Trigger, acknowledge or resolve PagerDuty incidents' +'pam_limits:Modify Linux PAM limits' +'patch:Apply patch files using the GNU patch tool.' 'pause:Pause playbook execution' -'ping:Try to connect to host and return C(pong) on success.' -'pingdom:(E) Pause/unpause Pingdom alerts' +'pear:Manage pear/pecl packages' +'ping:Try to connect to host, verify a usable python and return ``pong`` on success.' +'pingdom:Pause/unpause Pingdom alerts' 'pip:Manages Python library dependencies.' -'pkg5:(E) Manages packages with the Solaris 11 Image Packaging System' -'pkg5_publisher:(E) Manages Solaris 11 Image Packaging System publishers' -'pkgin:(E) Package manager for SmartOS' -'pkgng:(E) Package manager for FreeBSD >= 9.0' -'pkgutil:(E) Manage CSW-Packages on Solaris' -'portage:(E) Package manager for Gentoo' -'portinstall:(E) Installing packages from FreeBSD’s ports system' +'pkg5:Manages packages with the Solaris 11 Image Packaging System' +'pkg5_publisher:Manages Solaris 11 Image Packaging System publishers' +'pkgin:Package manager for SmartOS, NetBSD, et al.' +'pkgng:Package manager for FreeBSD >= 9.0' +'pkgutil:Manage CSW-Packages on Solaris' +'portage:Package manager for Gentoo' +'portinstall:Installing packages from FreeBSD’s ports system' 'postgresql_db:Add or remove PostgreSQL databases from a remote host.' -'postgresql_lang:(E) Adds, removes or changes procedural languages with a PostgreSQL database.' +'postgresql_ext:Add or remove PostgreSQL extensions from a database.' +'postgresql_lang:Adds, removes or changes procedural languages with a PostgreSQL database.' 'postgresql_privs:Grant or revoke privileges on PostgreSQL database objects.' 'postgresql_user:Adds or removes a users (roles) from a PostgreSQL database.' -'quantum_floating_ip:Add/Remove floating IP from an instance' -'quantum_floating_ip_associate:Associate or disassociate a particular floating IP with an instance' -'quantum_network:Creates/Removes networks from OpenStack' -'quantum_router:Create or Remove router from openstack' -'quantum_router_gateway:set/unset a gateway interface for the router with the specified external network' -'quantum_router_interface:Attach/Dettach a subnet’s interface to a router' -'quantum_subnet:Add/remove subnet from a network' -'rabbitmq_parameter:(E) Adds or removes parameters to RabbitMQ' -'rabbitmq_plugin:(E) Adds or removes plugins to RabbitMQ' -'rabbitmq_policy:(E) Manage the state of policies in RabbitMQ.' -'rabbitmq_user:(E) Adds or removes users to RabbitMQ' -'rabbitmq_vhost:(E) Manage the state of a virtual host in RabbitMQ' +'profitbricks:Create, destroy, start, stop, and reboot a ProfitBricks virtual machine.' +'profitbricks_datacenter:Create or destroy a ProfitBricks Virtual Datacenter.' +'profitbricks_nic:Create or Remove a NIC.' +'profitbricks_volume:Create or destroy a volume.' +'profitbricks_volume_attachments:Attach or detach a volume.' +'proxmox:management of instances in Proxmox VE cluster' +'proxmox_template:management of OS templates in Proxmox VE cluster' +'puppet:Runs puppet' +'pushbullet:Sends notifications to Pushbullet' +'pushover:Send notifications via https' +'quantum_floating_ip(D):Add/Remove floating IP from an instance' +'quantum_floating_ip_associate(D):Associate or disassociate a particular floating IP with an instance' +'quantum_network(D):Creates/Removes networks from OpenStack' +'quantum_router(D):Create or Remove router from openstack' +'quantum_router_gateway(D):set/unset a gateway interface for the router with the specified external network' +'quantum_router_interface(D):Attach/Dettach a subnet’s interface to a router' +'quantum_subnet(D):Add/remove subnet from a network' +'rabbitmq_binding:This module manages rabbitMQ bindings' +'rabbitmq_exchange:This module manages rabbitMQ exchanges' +'rabbitmq_parameter:Adds or removes parameters to RabbitMQ' +'rabbitmq_plugin:Adds or removes plugins to RabbitMQ' +'rabbitmq_policy:Manage the state of policies in RabbitMQ.' +'rabbitmq_queue:This module manages rabbitMQ queues' +'rabbitmq_user:Adds or removes users to RabbitMQ' +'rabbitmq_vhost:Manage the state of a virtual host in RabbitMQ' 'raw:Executes a low-down and dirty SSH command' 'rax:create / delete an instance in Rackspace Public Cloud' 'rax_cbs:Manipulate Rackspace Cloud Block Storage Volumes' @@ -304,6 +476,7 @@ _modules=( 'rax_cdb_user:create / delete a Rackspace Cloud Database' 'rax_clb:create / delete a load balancer in Rackspace Public Cloud' 'rax_clb_nodes:add, modify and remove nodes from a Rackspace Cloud Load Balancer' +'rax_clb_ssl:Manage SSL termination for a Rackspace Cloud Load Balancer.' 'rax_dns:Manage domains on Rackspace Cloud DNS' 'rax_dns_record:Manage DNS records on Rackspace Cloud DNS' 'rax_facts:Gather facts for Rackspace Cloud Servers' @@ -312,6 +485,11 @@ _modules=( 'rax_identity:Load Rackspace Cloud Identity' 'rax_keypair:Create a keypair for use with Rackspace Cloud Servers' 'rax_meta:Manipulate metadata for Rackspace Cloud Servers' +'rax_mon_alarm:Create or delete a Rackspace Cloud Monitoring alarm.' +'rax_mon_check:Create or delete a Rackspace Cloud Monitoring check for an existing entity.' +'rax_mon_entity:Create or delete a Rackspace Cloud Monitoring entity' +'rax_mon_notification:Create or delete a Rackspace Cloud Monitoring notification.' +'rax_mon_notification_plan:Create or delete a Rackspace Cloud Monitoring notification plan.' 'rax_network:create / delete an isolated network in Rackspace Public Cloud' 'rax_queue:create / delete a queue in Rackspace Public Cloud' 'rax_scaling_group:Manipulate Rackspace Cloud Autoscale Groups' @@ -319,65 +497,144 @@ _modules=( 'rds:create, delete, or modify an Amazon rds instance' 'rds_param_group:manage RDS parameter groups' 'rds_subnet_group:manage RDS database subnet groups' -'redhat_subscription:Manage Red Hat Network registration and subscriptions using the C(subscription-manager) command' -'redis:(E) Various redis commands, slave and flush' +'redhat_subscription:Manage Red Hat Network registration and subscriptions using the ``subscription-manager`` command' +'redis:Various redis commands, slave and flush' 'replace:Replace all instances of a particular string in a file using a back-referenced regular expression.' 'rhn_channel:Adds or removes Red Hat software channels' -'rhn_register:Manage Red Hat Network registration using the C(rhnreg_ks) command' -'riak:(E) This module handles some common Riak operations' -'rollbar_deployment:(E) Notify Rollbar about app deployments' +'rhn_register:Manage Red Hat Network registration using the ``rhnreg_ks`` command' +'riak:This module handles some common Riak operations' +'rollbar_deployment:Notify Rollbar about app deployments' 'route53:add or delete entries in Amazons Route53 DNS service' +'route53_facts:Retrieves route53 details using AWS methods' +'route53_health_check:add or delete health-checks in Amazons Route53 DNS service' +'route53_zone:add or delete Route53 zones' 'rpm_key:Adds or removes a gpg key from the rpm db' -'s3:S3 module putting a file into S3.' +'s3:manage objects in S3.' +'s3_bucket:Manage s3 buckets in AWS' +'s3_lifecycle:Manage s3 bucket lifecycle rules in AWS' +'s3_logging:Manage logging facility of an s3 bucket in AWS' 'script:Runs a local script on a remote node after transferring it' 'seboolean:Toggles SELinux booleans.' 'selinux:Change policy and state of SELinux' +'selinux_permissive:Change permissive domain in SELinux policy' +'sendgrid:Sends an email with the SendGrid API' +'sensu_check:Manage Sensu checks' +'seport:Manages SELinux network port type definitions' 'service:Manage services.' 'set_fact:Set host facts from a task' 'setup:Gathers facts about remote hosts' 'shell:Execute commands in nodes.' -'slack:(E) Send Slack notifications' +'slack:Send Slack notifications' +'slackpkg:Package manager for Slackware >= 12.2' 'slurp:Slurps a file from remote nodes' -'snmp_facts:(E) Retrieve facts for a device using SNMP.' -'sns:(E) Send Amazon Simple Notification Service (SNS) messages' -'stackdriver:(E) Send code deploy and annotation events to stackdriver' +'snmp_facts:Retrieve facts for a device using SNMP.' +'sns:Send Amazon Simple Notification Service (SNS) messages' +'sns_topic:Manages AWS SNS topics and subscriptions' +'solaris_zone:Manage Solaris zones' +'sqs_queue:Creates or deletes AWS SQS queues.' +'stackdriver:Send code deploy and annotation events to stackdriver' 'stat:retrieve file or file system status' +'sts_assume_role:Assume a role using AWS Security Token Service and obtain temporary credentials' 'subversion:Deploys a subversion repository.' 'supervisorctl:Manage the state of a program or group of programs running via supervisord' -'svc:(E) Manage daemontools services.' -'svr4pkg:(E) Manage Solaris SVR4 packages' -'swdepot:(E) Manage packages with swdepot package manager (HP-UX)' +'svc:Manage daemontools services.' +'svr4pkg:Manage Solaris SVR4 packages' +'swdepot:Manage packages with swdepot package manager (HP-UX)' 'synchronize:Uses rsync to make synchronizing file paths in your playbooks quick and easy.' 'sysctl:Manage entries in sysctl.conf.' +'taiga_issue:Creates/deletes an issue in a Taiga Project Management Platform' 'template:Templates a file out to a remote server.' -'twilio:(E) Sends a text message to a mobile phone through Twilio.' -'typetalk:(E) Send a message to typetalk' -'ufw:(E) Manage firewall with UFW' -'unarchive:Copies an archive to a remote location and unpack it' -'uptimerobot:(E) Pause and start Uptime Robot monitoring' +'twilio:Sends a text message to a mobile phone through Twilio.' +'typetalk:Send a message to typetalk' +'ufw:Manage firewall with UFW' +'unarchive:Unpacks an archive after (optionally) copying it from the local machine.' +'uptimerobot:Pause and start Uptime Robot monitoring' 'uri:Interacts with webservices' -'urpmi:(E) Urpmi manager' +'urpmi:Urpmi manager' 'user:Manage user accounts' -'virt:(E) Manages virtual machines supported by libvirt' +'vca_fw:add remove firewall rules in a gateway in a vca' +'vca_nat:add remove nat rules in a gateway in a vca' +'vca_vapp:Manages vCloud Air vApp instances.' +'vertica_configuration:Updates Vertica configuration parameters.' +'vertica_facts:Gathers Vertica database facts.' +'vertica_role:Adds or removes Vertica database roles and assigns roles to them.' +'vertica_schema:Adds or removes Vertica database schema and roles.' +'vertica_user:Adds or removes Vertica database users and assigns roles.' +'virt:Manages virtual machines supported by libvirt' +'virt_net:Manage libvirt network configuration' +'virt_pool:Manage libvirt storage pools' +'vmware_cluster:Create VMware vSphere Cluster' +'vmware_datacenter:Manage VMware vSphere Datacenters' +'vmware_dns_config:Manage VMware ESXi DNS Configuration' +'vmware_dvs_host:Add or remove a host from distributed virtual switch' +'vmware_dvs_portgroup:Create or remove a Distributed vSwitch portgroup' +'vmware_dvswitch:Create or remove a distributed vSwitch' +'vmware_host:Add/remove ESXi host to/from vCenter' +'vmware_migrate_vmk:Migrate a VMK interface from VSS to VDS' +'vmware_portgroup:Create a VMware portgroup' +'vmware_target_canonical_facts:Return canonical (NAA) from an ESXi host' +'vmware_vm_facts:Return basic facts pertaining to a vSphere virtual machine guest' +'vmware_vm_shell:Execute a process in VM' +'vmware_vm_vss_dvs_migrate:Migrates a virtual machine from a standard vswitch to distributed' +'vmware_vmkernel:Create a VMware VMkernel Interface' +'vmware_vmkernel_ip_config:Configure the VMkernel IP Address' +'vmware_vsan_cluster:Configure VSAN clustering on an ESXi host' +'vmware_vswitch:Add a VMware Standard Switch to an ESXi host' +'vsphere_copy:Copy a file to a vCenter datastore' 'vsphere_guest:Create/delete/manage a guest VM through VMware vSphere.' 'wait_for:Waits for a condition before continuing.' -'win_chocolatey:(E) Installs packages using chocolatey' +'webfaction_app:Add or remove applications on a Webfaction host' +'webfaction_db:Add or remove a database on Webfaction' +'webfaction_domain:Add or remove domains and subdomains on Webfaction' +'webfaction_mailbox:Add or remove mailboxes on Webfaction' +'webfaction_site:Add or remove a website on a Webfaction host' +'win_acl:Set file/directory permissions for a system user or group.' +'win_chocolatey:Installs packages using chocolatey' +'win_copy:Copies files to remote locations on windows hosts.' +'win_dotnet_ngen:Runs ngen to recompile DLLs after .NET updates' +'win_environment:Modifies environment variables on windows hosts.' 'win_feature:Installs and uninstalls Windows Features' +'win_file:Creates, touches or removes files or directories.' +'win_file_version:Get DLL or EXE file build version' +'win_firewall_rule:Windows firewall automation' 'win_get_url:Fetches a file from a given URL' 'win_group:Add and remove local groups' +'win_iis_virtualdirectory:Configures a virtual directory in IIS.' +'win_iis_webapplication:Configures a IIS Web application.' +'win_iis_webapppool:Configures a IIS Web Application Pool.' +'win_iis_webbinding:Configures a IIS Web site.' +'win_iis_website:Configures a IIS Web site.' +'win_lineinfile:Ensure a particular line is in a file, or replace an existing line using a back-referenced regular expression.' 'win_msi:Installs and uninstalls Windows MSI files' +'win_nssm:NSSM ' +'win_package:Installs/Uninstalls a installable package, either from local file system or url' 'win_ping:A windows version of the classic ping module.' +'win_regedit:Add, Edit, or Remove Registry Keys and Values' +'win_regmerge:Merges the contents of a registry file into the windows registry' +'win_scheduled_task:Manage scheduled tasks' 'win_service:Manages Windows services' +'win_share:Manage Windows shares' 'win_stat:returns information about a Windows file' -'win_updates:(E) Lists / Installs windows updates' +'win_template:Templates a file out to a remote server.' +'win_timezone:Sets Windows machine timezone' +'win_unzip:Unzips compressed files and archives on the Windows node' +'win_updates:Download and install Windows updates' +'win_uri:Interacts with webservices.' 'win_user:Manages local Windows user accounts' +'win_webpicmd:Installs packages using Web Platform Installer command-line' 'xattr:set/retrieve extended attributes' -'yum:Manages packages with the I(yum) package manager' -'zabbix_group:(E) Add or remove a host group to Zabbix.' -'zabbix_maintenance:(E) Create Zabbix maintenance windows' -'zfs:(E) Manage zfs' -'zypper:(E) Manage packages on SUSE and openSUSE' -'zypper_repository:(E) Add and remove Zypper repositories' +'xenserver_facts:get facts reported on xenserver' +'yum:Manages packages with the *yum* package manager' +'yum_repository:Add and remove YUM repositories' +'zabbix_group:Zabbix host groups creates/deletes' +'zabbix_host:Zabbix host creates/updates/deletes' +'zabbix_hostmacro:Zabbix host macro creates/updates/deletes' +'zabbix_maintenance:Create Zabbix maintenance windows' +'zabbix_screen:Zabbix screen creates/updates/deletes' +'zfs:Manage zfs' +'znode:Create, delete, retrieve, and update znodes using ZooKeeper.' +'zypper:Manage packages on SUSE and openSUSE' +'zypper_repository:Add and remove Zypper repositories' ) @@ -389,13 +646,19 @@ _ansible () _arguments -C -W \ '1:pattern:->pattern'\ "(-a --args)"{-a,--args}"[ARGS module arguments]:arguments:(ARG)"\ - "(-k --ask-pass)"{-k,--ask-pass}"[ask for SSH password]"\ - '--ask-su-pass[ask for su password]'\ - "(-K --ask-sudo-pass)"{-K,--ask-sudo-pass}"[ask for sudo password]"\ + '--ask-become-pass[ask for privilege escalation password]'\ + "(-k --ask-pass)"{-k,--ask-pass}"[ask for connection password]"\ + '--ask-su-pass[ask for su password (deprecated, use become)]'\ + "(-K --ask-sudo-pass)"{-K,--ask-sudo-pass}"[ask for sudo password (deprecated, use become)]"\ '--ask-vault-pass[ask for vault password]'\ "(-B --background)"{-B,--background}"[DURATION run asynchronously for DURATION (s)]:duration:(DURATION)"\ + "(-b --become)"{-b,--become}"[run operations with become (nopasswd implied)]"\ + '--become-method[privilege escalation method to use (default=sudo)]:method:(sudo su pbrun pfexec runas doas)'\ + '--become-user[run operations as this user (default=root)]:user:(USER)'\ "(-C --check)"{-C,--check}"[don't make any changes]"\ "(-c --connection)"{-c,--connection}"[CONNECTION connection type to use (default=smart)]:connection type:(smart ssh local chroot)"\ + "(-D --diff)"{-D,--diff}"[show differences when changing (small) files and templates]"\ + "(-e --extra-vars)"{-e,--extra-vars}"[set additional variables as key=value or YAML/JSON]"\ "(-f --forks)"{-f,--forks}"[FORKS number of parallel processes to use (default=5)]:forks:(5)"\ "(-h --help)"{-h,--help}"[help message]"\ "(-i --inventory-file)"{-i,--inventory-file}"[INVENTORY specify inventory host file]:inventory file:_files"\ @@ -403,13 +666,20 @@ _ansible () '--list-hosts[outputs a list of matching hosts. Does not execute anything else]'\ "(-m --module-name)"{-m,--module-name}"[MODULE_NAME module name (default=command)]:module name:->module"\ "(-M --module-path)"{-M,--module-path}"[MODULE_PATH specify path to module library (default=None)]:module path:_files -/"\ + '--new-vault-password-file[new vault password file for rekey]:new vault password file:_files'\ "(-o --one-line)"{-o,--one-line}"[condense output]"\ + '--output[output file name for encrypt or decrypt; use - for stdout]:output file:_files'\ "(-P --poll)"{-P,--poll}"[POLL_INTERVAL set the poll interval (s) if using -B (default=15)]:poll interval:(15)"\ - "--private-key[PRIVATE_KEY_FILE use this file to authenticate the connection]:private key file:_files"\ - "(-S --su)"{-S,--su}"[run operations with su]"\ - "(-R --su-user)"{-R,--su-user}"[SU_USER run operations with su as this user (default=root)]:su user:(root)"\ - "(-s --sudo)"{-s,--sudo}"[run operations with sudo (nopasswd)]"\ - "(-U --sudo-user)"{-U,--sudo-user}"[SUDO_USER desired sudo user (default=root)]:su user:(root)"\ + '--private-key[PRIVATE_KEY_FILE use this file to authenticate the connection]:private key file:_files'\ + '--scp-extra-args[specify extra arguments to pass to scp only]'\ + '--sftp-extra-args[specify extra arguments to pass to sftp only]'\ + '--ssh-common-args[specify common arguments to pass to sftp/scp/ssh]'\ + '--ssh-extra-args[specify extra arguments to pass to ssh only]'\ + "(-S --su)"{-S,--su}"[run operations with su (deprecated, use become)]"\ + "(-R --su-user)"{-R,--su-user}"[SU_USER run operations with su as this user (default=root) (deprecated, use become)]:su user:(root)"\ + "(-s --sudo)"{-s,--sudo}"[run operations with sudo (nopasswd) (deprecated, use become)]"\ + "(-U --sudo-user)"{-U,--sudo-user}"[SUDO_USER desired sudo user (default=root) (deprecated, use become)]:su user:(root)"\ + '--syntax-check[perform a syntax check on the playbook, but do not execute it]'\ "(-T --timeout)"{-T,--timeout}"[TIMEOUT override the SSH timeout (s) (default=10)]:ssh timeout:(10)"\ "(-t --tree)"{-t,--tree}"[OUTPUT_DIRECTORY log output to this directory]:output directory:_files -/"\ "(-u --user)"{-u,--user}"[REMOTE_USER connect as this user (default=${USER})]:connect as user:(${USER})"\ diff --git a/.zprezto/modules/completion/external/src/_ansible-galaxy b/.zprezto/modules/completion/external/src/_ansible-galaxy index 792909d..53b8c64 100644 --- a/.zprezto/modules/completion/external/src/_ansible-galaxy +++ b/.zprezto/modules/completion/external/src/_ansible-galaxy @@ -28,13 +28,14 @@ # Description # ----------- # -# Completion script for ansible-galaxy v1.8.4 (http://ansible.org) +# Completion script for ansible-galaxy v2.0.0.2 (http://ansible.org) # # ------------------------------------------------------------------------------ # Authors # ------- # # * Romain Bossart (https://github.com/bosr) +# * Adam Stevko (https://github.com/xen0l) # # ------------------------------------------------------------------------------ # @@ -50,51 +51,122 @@ _ansible-galaxy () typeset -A opt_args _arguments -C \ - "1:command:(init info install list remove)" \ + "1:command:(delete import info init install list login remove search setup)" \ "*::option:->option" case $state in option) case $line[1] in - init) - _arguments \ + delete) + _arguments \ "(-h --help)"{-h,--help}"[help message]" \ - "(-p --init-path)"{-p,--init-path}"[INIT_PATH path in which the skeleton role will be created (default=./)]:init path:(./)" \ - "(--offline)--offline[Don't query the galaxy API when creating roles]" \ + "(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \ "(-s --server)"{-s,--server}"[API_SERVER The API server destination]:api server:(http://apiserver)" \ - "(-f --force)"{-f,--force}"[Force overwriting an existing role]" \ - ":role name:(ROLE)" + "(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \ + "--version[show program's version number and exit]" \ + ":github_user:(GITHUB_USER)" \ + ":github_repo:(GITHUB_REPO)" + ;; + import) + _arguments \ + "--branch[REFERENCE The name of a branch to import.]:reference:(master)" \ + "(-h --help)"{-h,--help}"[help message]" \ + "(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \ + "--no-wait[Don't wait for import results.]" \ + "(-s --server)"{-s,--server}"[API_SERVER The API server destination]:api server:(http://apiserver)" \ + "--status[Check the status of the most recent import request forgiven github_user/github_repo.]" \ + "(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \ + "--version[show program's version number and exit]" \ + ":github_user:(GITHUB_USER)" \ + ":github_repo:(GITHUB_REPO)" ;; info) _arguments \ "(-h --help)"{-h,--help}"[help message]" \ + "(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \ "(-p --roles-path)"{-p,--roles-path}"[ROLES_PATH The path to the directory containing your roles (default: from ansible.cfg)]:roles path:_files -/" \ "(-s --server)"{-s,--server}"[API_SERVER The API server destination]:api server:(http://apiserver)" \ + "(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \ + "--version[show program's version number and exit]" \ ":role name:(ROLE,version)" ;; + init) + _arguments \ + "(-f --force)"{-f,--force}"[ Force overwriting an existing role]" \ + "(-h --help)"{-h,--help}"[help message]" \ + "(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \ + "(-p --init-path)"{-p,--init-path}"[INIT_PATH path in which the skeleton role will be created (default=./)]:init path:(./)" \ + "(--offline)--offline[Don't query the galaxy API when creating roles]" \ + "(-s --server)"{-s,--server}"[API_SERVER The API server destination]:api server:(http://apiserver)" \ + "(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \ + "--version[show program's version number and exit]" \ + ":role name:(ROLE)" + ;; install) _arguments \ + "(-f --force)"{-f,--force}"[Force overwriting an existing role]" \ "(-h --help)"{-h,--help}"[help message]" \ + "(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \ "(-i --ignore-errors)"{-i,--ignore-errors}"[Ignore errors and continue with the next specified role]" \ "(-n --no-deps)"{-n,--no-deps}"[Don't download roles listed as dependencies]" \ "(-r --role-file)"{-r,--role-file}"[ROLE_FILE A file containing a list of roles to be imported]:role file:_files" \ "(-p --roles-path)"{-p,--roles-path}"[ROLES_PATH The path to the directory containing your roles (default: from ansible.cfg)]:roles path:_files -/" \ "(-s --server)"{-s,--server}"[API_SERVER The API server destination]:api server:(http://apiserver)" \ - "(-f --force)"{-f,--force}"[Force overwriting an existing role]" \ + "(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \ + "--version[show program's version number and exit]" \ ":role name:(ROLE)" ;; list) _arguments \ "(-h --help)"{-h,--help}"[help message]" \ "(-p --roles-path)"{-p,--roles-path}"[ROLES_PATH The path to the directory containing your roles (default: from ansible.cfg)]:roles path:_files -/" \ + "(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \ + "--version[show program's version number and exit]" \ ":role name:(ROLE)" ;; + login) + _arguments \ + "--github_token[TOKEN Identify with github token rather than username and password.]:token:(TOKEN)" \ + "(-h --help)"{-h,--help}"[help message]" \ + "(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \ + "(-s --server)"{-s,--server}"[API_SERVER The API server destination]:api server:(http://apiserver)" \ + "(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \ + "--version[show program's version number and exit]" + ;; remove) _arguments \ "(-h --help)"{-h,--help}"[help message]" \ "(-p --roles-path)"{-p,--roles-path}"[ROLES_PATH The path to the directory containing your roles (default: from ansible.cfg)]:roles path:_files -/" \ + "(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \ + "--version[show program's version number and exit]" \ "*:role name:(ROLE)" ;; + search) + _arguments \ + "--author[AUTHOR GitHub username]:author:(AUTHOR)" \ + "--galaxy-tags[TAGS list of galaxy tags to filter by]:tags:(TAGS)" \ + "(-h --help)"{-h,--help}"[help message]" \ + "(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \ + "--platforms[PLATFORMS list of OS platforms to filter by" \ + "(-p --roles-path)"{-p,--roles-path}"[ROLES_PATH The path to the directory containing your roles (default: from ansible.cfg)]:roles path:_files -/" \ + "(-s --server)"{-s,--server}"[API_SERVER The API server destination]:api server:(http://apiserver)" \ + "(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \ + "--version[show program's version number and exit]" + ;; + setup) + _arguments \ + "(-h --help)"{-h,--help}"[help message]" \ + "(-c --ignore-certs)"{-c,--ignore-certs}"[Ignore SSL certificate validation errors.]" \ + "--list[List all of your integrations.]" \ + "--remove[REMOVE_ID Remove the integration matching the provided ID value.]:id:(REMOVE_ID)" \ + "(-s --server)"{-s,--server}"[API_SERVER The API server destination]:api server:(http://apiserver)" \ + "(-v --verbose)"{-v,--verbose}"[verbose mode (-vvv for more, -vvvv to enable connection debugging)]" \ + "--version[show program's version number and exit]" \ + ":source:(travis)" \ + ":github_user:(GITHUB_USER)" \ + ":github_repo:(GITHUB_REPO)" \ + ":secret:(SECRET)" + ;; esac ;; esac diff --git a/.zprezto/modules/completion/external/src/_ansible-playbook b/.zprezto/modules/completion/external/src/_ansible-playbook index 690d925..e7c6b6a 100644 --- a/.zprezto/modules/completion/external/src/_ansible-playbook +++ b/.zprezto/modules/completion/external/src/_ansible-playbook @@ -28,13 +28,14 @@ # Description # ----------- # -# Completion script for ansible-playbook v1.8.4 (http://ansible.org) +# Completion script for ansible-playbook v2.0.0.2 (http://ansible.org) # # ------------------------------------------------------------------------------ # Authors # ------- # # * Romain Bossart (https://github.com/bosr) +# * Adam Stevko (https://github.com/xen0l) # # ------------------------------------------------------------------------------ # @@ -60,6 +61,7 @@ __host_file_location () { [[ "$OSTYPE" == darwin* ]] && FALLBACK="/usr/local/etc/ansible/hosts" [[ "$OSTYPE" == linux* ]] && FALLBACK="/etc/ansible/hosts" HOST_FILE=${ANSIBLE_HOSTS:=${FALLBACK}} + [[ -f ${HOST_FILE} ]] || HOST_FILE="$PWD/ansible/inventory/hosts" [[ -f ${HOST_FILE} ]] || HOST_FILE=/dev/null echo ${HOST_FILE} @@ -125,11 +127,15 @@ _ansible-playbook () typeset -A opt_args _arguments -C -W \ - "1:playbook yml file:_files -g '*.yml'"\ - "(-k --ask-pass)"{-k,--ask-pass}"[ask for SSH password]"\ - '--ask-su-pass[ask for su password]'\ - "(-K --ask-sudo-pass)"{-K,--ask-sudo-pass}"[ask for sudo password]"\ + "1:playbook yml file:_files -g '*.yml|*.yaml'"\ + '--ask-become-pass[ask for privilege escalation password]'\ + "(-k --ask-pass)"{-k,--ask-pass}"[ask for connection password]"\ + '--ask-su-pass[ask for su password (deprecated, use become)]'\ + "(-K --ask-sudo-pass)"{-K,--ask-sudo-pass}"[ask for sudo password (deprecated, use become)]"\ '--ask-vault-pass[ask for vault password]'\ + "(-b --become)"{-b,--become}"[run operations with become (nopasswd implied)]"\ + '--become-method[privilege escalation method to use (default=sudo)]:method:(sudo su pbrun pfexec runas doas)'\ + '--become-user[run operations as this user (default=root)]:user:(USER)'\ "(-C --check)"{-C,--check}"[don't make any changes]"\ "(-c --connection)"{-c,--connection}"[CONNECTION connection type to use (default=smart)]:connection type:(smart ssh local chroot)"\ "(-D --diff)"{-D,--diff}"[when changing (small files and templates, show the diff in those. Works great with --check)]"\ @@ -141,15 +147,23 @@ _ansible-playbook () "(-i --inventory-file)"{-i,--inventory-file}"[INVENTORY specify inventory host file]:inventory file:_files"\ "(-l --limit)"{-l,--limit}"[SUBSET further limit selected hosts to an additional pattern]:subset pattern:->pattern"\ '--list-hosts[outputs a list of matching hosts. Does not execute anything else]'\ + '--list-tags[list all available tags]'\ + '--list-tasks[list all tasks that would be executed]'\ "(-M --module-path)"{-M,--module-path}"[MODULE_PATH specify path to module library (default=None)]:module path:_files -/"\ - "--private-key[PRIVATE_KEY_FILE use this file to authenticate the connection]:private key file:_files"\ + '--new-vault-password-file[new vault password file for rekey]:new vault password file:_files'\ + '--output[output file name for encrypt or decrypt; use - for stdout]:output file:_files'\ + '--private-key[PRIVATE_KEY_FILE use this file to authenticate the connection]:private key file:_files'\ + '--scp-extra-args[specify extra arguments to pass to scp only]'\ + '--sftp-extra-args[specify extra arguments to pass to sftp only]'\ "--skip-tags[SKIP_TAGS only run plays and tasks whose tags do not match these values]:skip tags:(SKIP_TAGS)"\ + '--ssh-common-args[specify common arguments to pass to sftp/scp/ssh]'\ + '--ssh-extra-args[specify extra arguments to pass to ssh only]'\ "--start-at-task[START_AT start the playbook at the task matching this name]:name:(TASK_NAME)"\ '--step[one-step-at-a-time: confirm each task before running]'\ - "(-S --su)"{-S,--su}"[run operations with su]"\ - "(-R --su-user)"{-R,--su-user}"[SU_USER run operations with su as this user (default=root)]:su user:(root)"\ - "(-s --sudo)"{-s,--sudo}"[run operations with sudo (nopasswd)]"\ - "(-U --sudo-user)"{-U,--sudo-user}"[SUDO_USER desired sudo user (default=root)]:su user:(root)"\ + "(-S --su)"{-S,--su}"[run operations with su (deprecated, use become)]"\ + "(-R --su-user)"{-R,--su-user}"[SU_USER run operations with su as this user (default=root) (deprecated, use become)]:su user:(root)"\ + "(-s --sudo)"{-s,--sudo}"[run operations with sudo (nopasswd) (deprecated, use become)]"\ + "(-U --sudo-user)"{-U,--sudo-user}"[SUDO_USER desired sudo user (default=root) (deprecated, use become)]:su user:(root)"\ '--syntax-check[perform a syntax check on the playbook, but do not execute it]'\ "(-t --tags)"{-t,--tags}"[TAGS only run plays and tasks gagged with these values]:task tags:(TAGS)"\ "(-T --timeout)"{-T,--timeout}"[TIMEOUT override the SSH timeout (s) (default=10)]:ssh timeout:(10)"\ diff --git a/.zprezto/modules/completion/external/src/_ansible-vault b/.zprezto/modules/completion/external/src/_ansible-vault new file mode 100644 index 0000000..ede78d5 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_ansible-vault @@ -0,0 +1,94 @@ +#compdef ansible-vault +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for ansible v1.9.2 (http://ansible.org) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Rick van Hattem (https://github.com/wolph) +# +# ------------------------------------------------------------------------------ +# + +_ansible-vault-commands() { + local -a commands + + commands=( + 'create:Create new encrypted file' + 'decrypt:Decrypt encrypted file' + 'edit:Edit encrypted file' + 'encrypt:Encrypt unencrypted file' + 'rekey:Change password for encrypted file' + 'view:View encrypted file' + ) + + _arguments -s : $nul_args && ret=0 + _describe -t commands 'ansible-vault command' commands && ret=0 +} + +_ansible-vault-command(){ + args=( + '--debug[enable debugging]' \ + '--vault-password-file[vault password file]:password_file:_files' + $nul_args + "1::file_name:_files" + ) + _arguments -s : $args && ret=0 +} + +_ansible-vault() { + local -a nul_args + nul_args=( + '(-h --help)'{-h,--help}'[show help message and exit.]' + ) + + local curcontext=$curcontext ret=1 + + if ((CURRENT == 2)); then + _ansible-vault-commands + else + shift words + (( CURRENT -- )) + curcontext="${curcontext%:*:*}:ansible-vault-$words[1]:" + _call_function ret _ansible-vault-command + fi +} + +_ansible-vault "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_archlinux-java b/.zprezto/modules/completion/external/src/_archlinux-java new file mode 100644 index 0000000..a497f76 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_archlinux-java @@ -0,0 +1,85 @@ +#compdef archlinux-java +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for archlinux-java a tool for selecting default Java runtime (https://wiki.archlinux.org/index.php/java). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + + +_archlinux-java_command_arguments() { + case $words[1] in + (set) + local java_versions=("${(@f)$(archlinux-java status | tail -n +2 | tr -s ' ' | cut -d ' ' -f2)}") + _describe -t output 'Downloads to delete' java_versions + ;; + esac +} + +_archlinux-java() { + local -a commands + + commands=( + "status:List installed Java environments and enabled one" + "get:Return the short name of the Java environment set as default" + "set:Force as default" + "unset:Unset current default Java environment" + "fix:Fix an invalid/broken default Java environment configuration" + "help:Show help" + ) + + _arguments -C \ + '1:cmd:->cmds' \ + '*:: :->args' \ + + case "$state" in + (cmds) + _describe -t commands 'commands' commands + ;; + (*) + _archlinux-java_command_arguments + ;; + esac +} + +_archlinux-java + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_artisan b/.zprezto/modules/completion/external/src/_artisan index bbb72f8..1104a20 100644 --- a/.zprezto/modules/completion/external/src/_artisan +++ b/.zprezto/modules/completion/external/src/_artisan @@ -35,17 +35,27 @@ # ------- # # * loranger (https://github.com/loranger) +# * Yohan Tambè (https://github.com/Cronos87) # # ------------------------------------------------------------------------------ _artisan_get_command_list () { - php artisan --no-ansi | sed "1,/Available commands/d" | awk '/ [a-z]+/ { print $1 }' + IFS=" " + php artisan --no-ansi | \ + sed "1,/Available commands/d" | \ + awk '/ [a-z]+/ { print $1 }' | \ + sed -E 's/^[ ]+//g' | \ + sed -E 's/[:]+/\\:/g' | \ + sed -E 's/[ ]{2,}/\:/g' } _artisan () { if [ -f artisan ]; then - compadd `_artisan_get_command_list` + local -a commands + IFS=$'\n' + commands=(`_artisan_get_command_list`) + _describe 'commands' commands fi } diff --git a/.zprezto/modules/completion/external/src/_atach b/.zprezto/modules/completion/external/src/_atach index 3e6afde..5da9633 100644 --- a/.zprezto/modules/completion/external/src/_atach +++ b/.zprezto/modules/completion/external/src/_atach @@ -1,5 +1,26 @@ #compdef atach # ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# +# 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. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_bitcoin-cli b/.zprezto/modules/completion/external/src/_bitcoin-cli new file mode 100644 index 0000000..8b61503 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_bitcoin-cli @@ -0,0 +1,182 @@ +#compdef bitcoin-cli +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for bitcoin-cli (https://bitcoin.org). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Ian Ker-Seymer (https://github.com/ianks) +# +# ------------------------------------------------------------------------------ + +_bitcoin-cli() { + local context state line curcontext="$curcontext" + + _arguments -C \ + -?'[This help message]' \ + -conf='[Specify configuration file (default: bitcoin.conf)]:PATH:_files' \ + -datadir='[Specify data directory]:PATH:_directories' \ + -testnet'[Use the test chain]' \ + -regtest'[Enter regression test mode, which uses a special chain in which blocks can be solved instantly. This is intended for regression testing tools and app development.]' \ + -named'[Pass named instead of positional arguments (default: false)]' \ + -stdin'[Read extra arguments from standard input, one per line until EOF/Ctrl-D (recommended for sensitive information such as passphrases)]' \ + -rpcport='[Connect to JSON-RPC on (default: 8332 or testnet: 18332)]: :_guard "[[\:digit\:]]#" "PORT"' \ + -rpcwait'[Wait for RPC server to start]' \ + -rpcuser='[Username for JSON-RPC connections]:RPCUSER:()' \ + -rpcpassword='[Password for JSON-RPC connections]:RPCPASSWORD:()' \ + -rpcconnect='[Send commands to node running on (default: 127.0.0.1)]:RPCCONNECT:_hosts' \ + -rpcclienttimeout='[Timeout during HTTP requests (default: 900)]: :_guard "[[\:digit\:]]#" "RPCCLIENTTIMEOUT"' \ + ':subcommand:->subcommand' && ret=0 + + case $state in + subcommand) + subcommands=( + 'getbestblockhash' + 'getblock' + 'getblockchaininfo' + 'getblockcount' + 'getblockhash' + 'getblockheader' + 'getchaintips' + 'getdifficulty' + 'getmempoolancestors' + 'getmempooldescendants' + 'getmempoolentry' + 'getmempoolinfo' + 'getrawmempool' + 'gettxout' + 'gettxoutproof' + 'gettxoutsetinfo' + 'preciousblock' + 'pruneblockchain' + 'verifychain' + 'verifytxoutproof' + 'getinfo' + 'getmemoryinfo' + 'help' + 'stop' + 'generate' + 'generatetoaddress' + 'getblocktemplate' + 'getmininginfo' + 'getnetworkhashps' + 'prioritisetransaction' + 'submitblock' + 'addnode' + 'clearbanned' + 'disconnectnode' + 'getaddednodeinfo' + 'getconnectioncount' + 'getnettotals' + 'getnetworkinfo' + 'getpeerinfo' + 'listbanned' + 'ping' + 'setban' + 'setnetworkactive' + 'createrawtransaction' + 'decoderawtransaction' + 'decodescript' + 'fundrawtransaction' + 'getrawtransaction' + 'sendrawtransaction' + 'signrawtransaction' + 'createmultisig' + 'estimatefee' + 'estimatepriority' + 'estimatesmartfee' + 'estimatesmartpriority' + 'signmessagewithprivkey' + 'validateaddress' + 'verifymessage' + 'abandontransaction' + 'addmultisigaddress' + 'addwitnessaddress' + 'backupwallet' + 'bumpfee' + 'dumpprivkey' + 'dumpwallet' + 'getaccount' + 'getaccountaddress' + 'getaddressesbyaccount' + 'getbalance' + 'getnewaddress' + 'getrawchangeaddress' + 'getreceivedbyaccount' + 'getreceivedbyaddress' + 'gettransaction' + 'getunconfirmedbalance' + 'getwalletinfo' + 'importaddress' + 'importmulti' + 'importprivkey' + 'importprunedfunds' + 'importpubkey' + 'importwallet' + 'keypoolrefill' + 'listaccounts' + 'listaddressgroupings' + 'listlockunspent' + 'listreceivedbyaccount' + 'listreceivedbyaddress' + 'listsinceblock' + 'listtransactions' + 'listunspent' + 'lockunspent' + 'move' + 'removeprunedfunds' + 'sendfrom' + 'sendmany' + 'sendtoaddress' + 'setaccount' + 'settxfee' + 'signmessage' + 'walletlock' + 'walletpassphrase' + 'walletpassphrasechange' + ) + + _describe -t subcommands 'bitcoin-cli subcommands' subcommands && ret=0 + esac + + return ret +} + +_bitcoin-cli "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_boot2docker b/.zprezto/modules/completion/external/src/_boot2docker deleted file mode 100644 index 8f1a9c5..0000000 --- a/.zprezto/modules/completion/external/src/_boot2docker +++ /dev/null @@ -1,87 +0,0 @@ -#compdef boot2docker -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for boot2docker (https://github.com/boot2docker/boot2docker-cli). -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * hhatto (https://github.com/hhatto) -# -# ------------------------------------------------------------------------------ - - -_boot2docker() { - local context state line - - _arguments -C \ - --basevmdk'[Path to VMDK to use as base for persistent partition]:vmdk:' \ - --dhcp'[enable VirtualBox host-only network DHCP. default=true]' \ - --dhcpip'[VirtualBox host-only network DHCP server address. default=192.168.59.99]' \ - '(-s --disksize)'{-s,--disksize}'[boot2docker disk image size (in MB). default=20000.]:disksize:' \ - --dockerport'[host Docker port (forward to port 2375 in VM).]:PORT:' \ - --hostip'[VirtualBox host-only network IP address.]:IP:' \ - --iso'[path to boot2docker ISO image.]:FILE:_files' \ - --lowerip'[VirtualBox host-only network DHCP lower bound.]:IP:' \ - '(-m --memory)'{-m,--memory}'[virtual machine memory size (in MB). default=2048]' \ - --netmask'[VirtualBox host-only network mask.]' \ - --serial'[try serial console to get IP address (experimental) default=false]' \ - --serialfile'[path to the serial socket/pipe.]:FILE:_files' \ - --ssh'[path to SSH client utility. default="ssh"]:SSH:' \ - --ssh-keygen'[path to ssh-keygen utility. default="ssh-keygen"]:KEYGEN:' \ - --sshkey'[path to SSH key to use.]:FILE:_files' \ - --sshport'[host SSH port (forward to port 22 in VM). default=2022]:PORT:' \ - --upperip'[VirtualBox host-only network DHCP upper bound. default=192.168.59.254]:IP:' \ - --vbm'[path to VirtualBox management utility. default="VBoxManage"]' \ - '(-v --verbose)'{-v,--verbose}'[display verbose command invocations. default=false]' \ - --vm'[virtual machine name. default="boot2docker-vm"]' \ - '*::boot2docker commands:_boot2docker_command' -} - -(( $+functions[_boot2docker_command] )) || -_boot2docker_command() { - local _boot2docker_cmds - - _boot2docker_cmds=( - 'init:Create a new boot2docker VM.' \ - 'up:Start VM from any states.' \ - 'start:Start VM from any states.' \ - 'boot:Start VM from any states.' \ - 'ssh:Login to VM via SSH.' \ - 'save:Suspend VM and save state to disk.' \ - 'suspend:Suspend VM and save state to disk.' \ - "down:Gracefully shutdown the VM." \ - "stop:Gracefully shutdown the VM." \ - "halt:Gracefully shutdown the VM." \ - "restart:Gracefully reboot the VM." \ - "poweroff:Forcefully power off the VM (might corrupt disk image)." \ - "reset:Forcefully power cycle the VM (might corrupt disk image)." \ - "delete:Delete boot2docker VM and its disk image." \ - "destroy:Delete boot2docker VM and its disk image." \ - "config:Show selected profile file settings." \ - "cfg:Show selected profile file settings." \ - "info:Display detailed information of VM." \ - "ip:Display the IP address of the VM's Host-only network." \ - "status:Display current state of VM." \ - "download:Download boot2docker ISO image." \ - "upgrade:Upgrade the boot2docker ISO image (if vm is running it will be stopped and started)." \ - "version:Display version information." - ) - - if (( CURRENT == 1 )); then - _describe -t commands 'boot2docker subcommand' _boot2docker_cmds - fi -} - -_boot2docker "$@" - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_bower b/.zprezto/modules/completion/external/src/_bower index 303b976..0daa978 100644 --- a/.zprezto/modules/completion/external/src/_bower +++ b/.zprezto/modules/completion/external/src/_bower @@ -1,5 +1,30 @@ #compdef bower # ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_brew b/.zprezto/modules/completion/external/src/_brew deleted file mode 100644 index e51e99b..0000000 --- a/.zprezto/modules/completion/external/src/_brew +++ /dev/null @@ -1,215 +0,0 @@ -#compdef brew -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for brew (https://github.com/mxcl/homebrew). -# -# Source: https://github.com/mxcl/homebrew/blob/master/Library/Contributions/brew_zsh_completion.zsh -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * kulakowski (https://github.com/kulakowski) -# * Gabe Berke-Williams (https://github.com/gabebw) -# * James Conroy-Finn (https://github.com/jcf) -# * Daniel Schauenberg (https://github.com/mrtazz) -# * Adam Vandenberg (https://github.com/adamv) -# * Erik Kastner (https://github.com/kastner) -# * Katsunori Kanda (https://github.com/potix2) -# -# ------------------------------------------------------------------------------ - - -_brew_all_formulae() { - formulae=(${(f)"$(_call_program formulae brew search 2>/dev/null)"}) -} - -_brew_installed_formulae() { - installed_formulae=(${(f)"$(_call_program formulae brew list 2>/dev/null)"}) -} - -_brew_installed_taps() { - installed_taps=(${(f)"$(_call_program formulae brew tap 2>/dev/null)"}) -} - -_brew_outdated_formulae() { - outdated_formulae=(${(f)"$(_call_program formulae brew outdated 2>/dev/null)"}) -} - -_brew_cask() { - local -a _1st_arguments - _1st_arguments=( - "alfred:displays note about new built-in alfred support" - "audit:verifies installability of Casks" - "cat:dump raw source of the given Cask to the standard output" - "cleanup:cleans up cached downloads and tracker symlinks" - "create:creates the given Cask and opens it in an editor" - "doctor:checks for configuration issues" - "edit:edits the given Cask" - "fetch:downloads Cask resources to local cache" - "home:opens the homepage of the given Cask" - "info:displays information about the given Cask" - "install:installs the given Cask" - "list:with no args, lists installed Casks; given installed Casks, lists staged files" - "search:searches all known Casks" - "uninstall:uninstalls the given Cask" - "update:a synonym for 'brew update'" - "zap:zaps all files associated with the given Cask" - ) - - if (( CURRENT == 2 )); then - _describe -t commands "brew cask subcommand" _1st_arguments - return - fi - - local expl - local -a all_cask_formulae installed_cask_formulae - case "$words[2]" in - audit|cat|edit|info|install|search) - all_cask_formulae=( $(brew cask search 2>/dev/null) ) - _wanted all_cask_formulae expl 'all cask formulae' compadd -a all_cask_formulae ;; - uninstall|zap) - installed_cask_formulae=( $(brew cask list 2>/dev/null) ) - _wanted installed_cask_formulae expl 'installed cask formulae' compadd -a installed_cask_formulae ;; - *) ;; - esac -} - -local -a _1st_arguments -_1st_arguments=( - 'audit:check formulae for Homebrew coding style' - 'cat:display formula file for a formula' - 'cleanup:uninstall unused and old versions of packages' - 'create:create a new formula' - 'deps:list dependencies and dependants of a formula' - 'doctor:audits your installation for common issues' - 'diy:automatically determine the installation prefix for non-Homebrew software' - 'edit:edit a formula' - 'fetch:download the source packages for the given formulae' - 'home:visit the homepage of a formula or the brew project' - 'info:information about a formula' - 'install:install a formula' - 'link:link a formula' - 'list:list files in a formula or not-installed formulae' - 'log:git commit log for a formula' - 'missing:check all installed formulae for missing dependencies.' - 'options:display install options specific to formula' - 'outdated:list formulae for which a newer version is available' - 'prune:remove dead links' - 'reinstall:install a formula anew; re-using its current options' - 'remove:remove a formula' - 'search:search for a formula (/regex/ or string)' - 'server:start a local web app that lets you browse formulae (requires Sinatra)' - 'services:manage background services via launchctl' - 'tap:tap a new formula repository from GitHub, or list existing taps' - 'test:a few formulae provide a test method' - 'unlink:unlink a formula' - 'untap:remove a tapped repository' - 'unpin:unpin specified formulae' - 'update:freshen up links' - 'upgrade:upgrade outdated formulae' - 'uses:show formulae which depend on a formula' - 'versions:list previous versions of formulae' -) - -local expl -local -a formulae installed_formulae installed_taps outdated_formulae - -_arguments \ - '(-v)-v[verbose]' \ - '(--cellar)--cellar[brew cellar]' \ - '(--config)--config[brew configuration]' \ - '(--env)--env[brew environment]' \ - '(--repository)--repository[brew repository]' \ - '(--version)--version[version information]' \ - '(--prefix)--prefix[where brew lives on this system]' \ - '(--cache)--cache[brew cache]' \ - '*:: :->subcmds' && return 0 - -if (( CURRENT == 1 )); then - _describe -t commands "brew subcommand" _1st_arguments - return -fi - -case "$words[1]" in - search|-S) - _arguments \ - '(--debian)--debian[search the Debian repository]' \ - '(--fedora)--fedora[search the Fedora repository]' \ - '(--fink)--fink[search the Fink repository]' \ - '(--macports)--macports[search the Macports repository]' \ - '(--opensuse)--opensuse[search the OpenSuse repository]' \ - '(--ubuntu)--ubuntu[search the Ubuntu repository]' \ - '1: :->forms' && return 0 - - if [[ "$state" == forms ]]; then - _brew_all_formulae - _wanted formulae expl 'all formulae' compadd -a formulae - fi ;; - link|ln) - _arguments \ - '(-n --dry-run)'{-n,--dry-run}'[All files would be linked or be deleted will be listed, but no real linking or deletion will be done]' \ - '(--force)--force[Allow keg-only formulae to be linked]' \ - '(--overwrite)--overwrite[Also delete files which already exist in the prefix while linking]' \ - '1: :->forms' && return 0 - - if [[ "$state" == forms ]]; then - _brew_installed_formulae - _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae - fi ;; - list|ls) - _arguments \ - '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \ - '(--pinned)--pinned[list all versions of pinned formulae]' \ - '(--versions)--versions[list all installed versions of a formula]' \ - '1: :->forms' && return 0 - - if [[ "$state" == forms ]]; then - _brew_installed_formulae - _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae - fi ;; - install|reinstall) - _arguments \ - '(--devel)--devel[install the development version]' \ - '(--env=std)--env=std[use the standard build environment instead of superenv]' \ - '(--env=super)--env=super[use superenv even if the formula specifies the standard build environment]' \ - '(--fresh)--fresh[the installation process will not re-use any options from previous installs]' \ - '(--ignore-dependencies)--ignore-dependencies[skip any dependencies installation]' \ - '(--use-clang)--use-clang[attempt to compile using clang]' \ - '(--use-gcc)--use-gcc[attempt to compile using GCC]' \ - '(--use-llvm)--use-llvm[attempt to compile using the LLVM front-end to GCC]' \ - '1: :->forms' && return 0 - - if [[ "$state" == forms ]]; then - _brew_all_formulae - _wanted formulae expl 'all formulae' compadd -a formulae - fi ;; - audit|home|homepage|log|info|abv|uses|cat|deps|edit|options) - _brew_all_formulae - _wanted formulae expl 'all formulae' compadd -a formulae ;; - remove|rm|uninstall|unlink|cleanup|pin|unpin|test) - _brew_installed_formulae - _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;; - tap) - _arguments \ - '(--repair)--repair[repair all tap formula, i.e. symlinks and dead formula]' && return 0 ;; - upgrade) - _brew_outdated_formulae - _wanted outdated_formulae expl 'outdated formulae' compadd -a outdated_formulae ;; - untap) - _brew_installed_taps - _wanted installed_taps expl 'installed taps' compadd -a installed_taps ;; - cask) - _brew_cask ;; -esac - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et - diff --git a/.zprezto/modules/completion/external/src/_bundle b/.zprezto/modules/completion/external/src/_bundle index 89d9dcf..a630918 100644 --- a/.zprezto/modules/completion/external/src/_bundle +++ b/.zprezto/modules/completion/external/src/_bundle @@ -1,5 +1,30 @@ #compdef bundle # ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ # Description # ----------- # @@ -48,6 +73,7 @@ case $state in _values 'commands' 'install' 'update' 'package' 'exec' 'config' 'check' 'list' 'show' 'console' 'open' 'viz' 'init' 'gem' 'help' 'platform' 'outdated' && ret=0 ;; install) + _policies=('HighSecurity' 'MediumSecurity' 'LowSecurity' 'AlmostNoSecurity' 'NoSecurity') _arguments \ '(--no-color)--no-color[disable colorization in output]' \ '(--local)--local[do not attempt to connect to rubygems.org]' \ @@ -58,7 +84,18 @@ case $state in '(--frozen)--frozen[do not allow the Gemfile.lock to be updated after this install]' \ '(--path)--path=-[specify a different path than the system default]:path:_files' \ '(--binstubs)--binstubs=-[generate bin stubs for bundled gems to ./bin]:directory:_files' \ - '(--without)--without=-[exclude gems that are part of the specified named group]:groups' + '(--without)--without=-[exclude gems that are part of the specified named group]:groups' \ + '(--with)--with=-[include gems that are part of the specified named group]:groups' \ + '(--clean)--clean[remove any gems not present in the current Gemfile]' \ + '(--full-index)--full-index[download and cache the index file of all gems]' \ + '(--jobs)--jobs=-[install gems parallely]:number' \ + '(--force)--force[force download every gem]' \ + '(--no-cache)--no-cache[do not update the cache in vendor/cache with newly installed gems]' \ + '(--no-prune)--no-prune[do not remove stale gem from cache after installation]' \ + '(--retry)--retry=-[number of times to retry failed network or git requests]:number' \ + '(--sheband)--shebang=-[specify ruby executable to execute scripts]:ruby' \ + '(--standalone)--standalone=-[create standalone bundles]:groups' \ + "(--trust-policy)--trust-policy=-[apply the Rubygems security policy]:arg:($_policies)" ret=0 ;; exec) diff --git a/.zprezto/modules/completion/external/src/_cabal b/.zprezto/modules/completion/external/src/_cabal deleted file mode 100644 index a598f00..0000000 --- a/.zprezto/modules/completion/external/src/_cabal +++ /dev/null @@ -1,648 +0,0 @@ -#compdef cabal -# ------------------------------------------------------------------------------ -# Copyright (c) 2012 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for cabal-install (http://hackage.haskell.org/trac/hackage/wiki/CabalInstall) -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Gérard Milmeister -# * Matvey Aksenov -# -# ------------------------------------------------------------------------------ - -local WORDS - -_cabal () -{ - WORDS=() - for w in $words[1,(($CURRENT - 1))]; do - if [[ $w != -* ]]; then WORDS+=$w; fi - done - - if (( $#WORDS == 1 )); then - _arguments \ - {-h,--help}'[show help]' \ - {-V,--version}'[print version information]' \ - '--numeric-version[print just the version number]' \ - '--config-file=[set an alternate location for the config file]:config file:_files' \ - '--sandbox-config-file=[set an alternate location for the sandbox config file]:config file:_files' \ - '--require-sandbox[enable requiring the presence of a sandbox for sandbox-aware commands]' \ - '--no-require-sandbox[disable requiring the presence of a sandbox for sandbox-aware commands]' \ - '--ignore-sandbox[ignore any existing sandbox]' \ - '*::command:_cabal_command' - else - _arguments '*::command:_cabal_command' - fi -} - -_cabal_command () -{ - local -a _cabal_cmds - _cabal_cmds=( - 'install:installs a list of packages' - 'update:updates list of known packages' - 'list:list packages matching a search string' - 'info:display detailed information about a particular package' - 'fetch:downloads packages for later installation' - 'freeze:freeze dependencies' - "get:get a package's source code" - 'check:check the package for common mistakes' - 'sdist:generate a source distribution file (.tar.gz)' - 'upload:uploads source packages to Hackage' - 'report:upload build reports to a remote server' - 'run:runs the compiled executable' - 'init:interactively create a .cabal file' - 'configure:prepare to build the package' - 'build:compile all targets or specific targets' - 'repl:open an interpreter session for the given target' - 'sandbox:create/modify/delete a sandbox' - 'haddock:generate Haddock HTML documentation' - 'exec:run a command with the cabal environment' - 'copy:copy the files into the install locations' - 'clean:clean up after a build' - 'hscolour:generate HsColour colourised code, in HTML format' - 'register:register this package with the compiler' - 'test:run the test suite, if any (configure with UserHooks)' - 'bench:run the benchmark, if any (configure with UserHooks)' - 'help:help about commands' - ) - - local -a _cabal_programs - _cabal_programs=() - - programs=(alex ar c2hs cpphs ffihugs gcc ghc ghc-pkg greencard haddock - happy hmake hpc hsc2hs hscolour hugs jhc ld lhc lhc-pkg nhc98 pkg-config - ranlib strip tar uhc) - - for program in $programs; do - _cabal_programs+=( - "--with-${program}=[give the path to ${program}]:file:_files" - "--${program}-options=[give extra options to ${program}]" - "--${program}-option=[give an extra option to ${program}]" - ) - done - - if (( CURRENT == 1 )) then - _describe -t commands 'command' _cabal_cmds || compadd "$@" - else - local curcontext="$curcontext" - cmd="${${_cabal_cmds[(r)$WORDS[2]:*]%%:*}}" - if (( $#cmd )); then - _call_function ret _cabal_$cmd - else - _message "unknown cabal command: $WORDS[2]" - fi - fi -} - -_cabal_bench () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--builddir=[the directory where Cabal puts generated build files]:directory:_files -/' \ - '--benchmark-options=[give extra options to benchmark executables]' \ - '--benchmark-option=[give an extra option to benchmark executables (no need to quote options containing spaces)]' \ - {-j,--jobs=}'[run NUM jobs simultaneously]' \ - $_cabal_programs \ - "--only[don't reinstall add-source dependencies (sandbox-only)]" -} - -_cabal_build () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--builddir=[the directory where Cabal puts generated build files]:directory:_files -/' \ - $_cabal_programs \ - {-j,--jobs=}'[run NUM jobs simultaneously]' \ - "--only[don't reinstall add-source dependencies (sandbox-only)]" -} - -_cabal_check () -{ - _arguments {-h,--help}'[show help]' -} - -_cabal_clean () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--builddir=[the directory where Cabal puts generated build files]:directory:_files -/' \ - {-s,--save-configure}'[do not remove the configuration file]' -} - -_cabal_configure () -{ - local context state state_descr line - typeset -A opt_args - - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--builddir=[the directory where Cabal puts generated build files]:directory:_files -/' \ - {-g,--ghc}'[compile with GHC]' \ - '--nhc98[compile with NHC]' \ - '--jhc[compile with JHC]' \ - '--lhc[compile with LHC]' \ - '--hugs[compile with Hugs]' \ - '--uhc[compile with UHC]' \ - '--haskell-suite[compile with a haskell-suite compiler]' \ - {-w,--with-compiler=}'[give the path to a particular compiler]:file:_files' \ - '--with-hc-pkg=[give the path to the package tool]:file:_files' \ - '--prefix=[take this prefix in preparation of installation]:directory:_files -/' \ - '--bindir=[installation directory for executables]:directory:_files -/' \ - '--libdir=[installation directory for libraries]:directory:_files -/' \ - '--libsubdir=[subdirectory of libdir in which libs are installed]:directory:_files -/' \ - '--libexecdir=[installation directory for program executables]:directory:_files -/' \ - '--datadir=[installation directory for read-only data]:directory:_files -/' \ - '--datasubdir=[subdirectory of datadir in which data files are installed]:directory:_files -/' \ - '--docdir=[installation directory for documentation]:directory:_files -/' \ - '--htmldir=[installation directory for HTML]:directory:_files -/' \ - '--haddockdir=[installation directory for haddock interfaces]:directory:_files -/' \ - '--sysconfdir=[installation directory for configuration files]:directory:_files -/' \ - {-b,--scratchdir=}'[directory to receive the built package]:directory:_files -/' \ - '--program-prefix=[prefix to be applied to installed executables]' \ - '--program-suffix=[suffix to be applied to installed executables]' \ - '--enable-library-vanilla[enable Vanilla libraries]' \ - '--disable-library-vanilla[disable Vanilla libraries]' \ - {-p,--enable-library-profiling}'[enable Library profiling]' \ - '--disable-library-profiling[disable Library profiling]' \ - '--enable-shared[enable Shared library]' \ - '--disable-shared[disable Shared library]' \ - '--enable-executable-dynamic[enable Executable dynamic linking]' \ - '--disable-executable-dynamic[disable Executable dynamic linking]' \ - '--enable-executable-profiling[enable Executable profiling]' \ - '--disable-executable-profiling[disable Executable profiling]' \ - {-O-,--enable-optimization=}'[build with optimization]:level:(0 1 2)' \ - '--disable-optimization[build without optimization]' \ - '--enable-library-for-ghci[enable compile library for use with GHCi]' \ - '--disable-library-for-ghci[disable compile library for use with GHCi]' \ - '--enable-split-objs[enable split library into smaller objects]' \ - '--disable-split-objs[disable split library into smaller objects]' \ - '--enable-executable-stripping[enable strip executables upon installation]' \ - '--disable-executable-stripping[disable strip executables upon installation]' \ - '--configure-option=[extra option for configure]' \ - '--user[enable doing a per-user installation]' \ - '--global[disable doing a per-user installation]' \ - '--package-db=[use a given package database]:: :->default-db-or-filepath' \ - {-f,--flags=}'[force values for the given flags]:flags:' \ - '--extra-include-dirs=[a list of directories to search for header files]:directory:_files -/' \ - '--extra-lib-dirs=[a list of directories to search for externallibraries]:directory:_files -/' \ - '--extra-prog-path=[A list of directories to search for required programs]:directory:_files -/' \ - '--enable-tests[enable dependency checking and compilation for test suites listed in the package description file]' \ - '--disable-tests[disable dependency checking and compilation for test suites listed in the package description file]' \ - '--enable-library-coverage[enable build library and test suites with, Haskell Program Coverage enabled. (GHC only)]' \ - '--disable-library-coverage[disable build library and test suites with, Haskell Program Coverage enabled. (GHC only)]' \ - '--enable-benchmarks[enable dependency checking and compilation, for benchmarks listed in the package]' \ - '--disable-benchmarks[disable dependency checking and compilation, for benchmarks listed in the package]' \ - $_cabal_programs \ - '--cabal-lib-version=[select which version of the Cabal lib to use]' \ - '--constraint=[a list of additional constraints on the dependencies]' \ - '--preference=[specify preferences on the version of a package]' \ - '--solver=[select dependency solver to use]:solver:(topdown modular choose)' \ - '--allow-newer=[ignore upper bounds in dependencies on some or all packages]' - - case $state in - (default-db-or-filepath) - _alternative \ - ':default db:(global user clear)' \ - ':filepath:_files' - ;; - esac -} - -_cabal_copy () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--builddir=[the directory where Cabal puts generated build]:directory:_files -/' \ - '--destdir=[directory to copy files to]:directory:_files -/' -} - -_cabal_exec () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' -} - -_cabal_fetch () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--dependencies[resolve and fetch dependencies]' \ - '--no-dependencies[ignore dependencies]' \ - '--dry-run[do not install anything, only print what would be installed]' \ - '--solver=[select dependency solver to use]:solver:(topdown modular choose)]' \ - '--max-backjumps=[maximum number of backjumps allowed while solving dependencies]' \ - '--reorder-goals[try to reorder goals according to certain heuristics]' \ - '--shadow-installed-packages[if multiple package instances of the same version are installed, treat all but one as shadowed]' \ - '*:package:_cabal_list_packages' -} - -_cabal_freeze () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--dry-run[do not freeze anything, only print what would be frozen]' \ - '--solver=[select dependency solver to use]:solver:(topdown modular choose)]' \ - '--max-backjumps=[maximum number of backjumps allowed while solving dependencies]' \ - '--reorder-goals[try to reorder goals according to certain heuristics]' \ - '--shadow-installed-packages[if multiple package instances of the same version are installed, treat all but one as shadowed]' -} - -_cabal_get () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - {-d-,--destdir=}'[where to unpack the packages]:directory:_files -/' \ - {-s,--source-repository=}"[copy the package's source repository]" \ - '--pristine[unpack the original pristine tarball, rather than updating the .cabal file with the latest revision from the package archive.]' \ - '*:package:_cabal_list_packages' -} - -_cabal_haddock () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--builddir=[the directory where Cabal puts generated files]:directory:_files -/' \ - '--keep-temp-files[keep temporary files]' \ - '--hoogle[generate a hoogle database]' \ - '--html[generate HTML documentation]' \ - '--html-location=[location of HTML documentation]:url:' \ - '--executables[run haddock for Executables targets]' \ - '--tests[run haddock for Test Suite targets]' \ - '--benchmarks[run haddock for Benchmark targets]' \ - '--all[run haddock for all targets]' \ - '--internal[run haddock for internal modules]' \ - '--css=[path to the haddock stylesheet]:file:_files' \ - '--hyperlink-source[hyperlink the documentation to the source code]' \ - '--hscolour-css=[path to the HsColour stylesheet]:file:_files' \ - '--contents-location=[bake URL in as the location for the contents page]:url:' \ - '--with-ghc=[path to ghc]:file:_files' \ - '--with-haddock=[path to haddock]:file:_files' \ - '--PROG-option=[give an extra option to PROG (no need to quote options containing spaces)]:option:' \ - '--ghc-options=[give extra options to ghc]:option:' \ - '--haddock-options=[give extra options to haddock]:option:' \ -} - -_cabal_help () -{ - local -a cmds - cmds=(install update list info fetch freeze get check sdist upload report run init - configure build repl sandbox haddock exec copy clean hscolour register test bench help) - _arguments \ - {-h,--help}'[Show help]' \ - '*::command:( $cmds )' -} - -_cabal_hscolour () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--builddir=[the directory where Cabal puts generated files]:directory:_files -/' \ - '--executables[run hscolour for Executables targets]' \ - '--tests[run hscolour for Test Suite targets]' \ - '--benchmarks[run hscolour for Benchmarks targets]' \ - '--all[run hscolour for all targets]' \ - '--css=[path to stylesheet]:file:_files' -} - -_cabal_info () -{ - local context state state_descr line - typeset -A opt_args - - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--package-db=[use a given package database]:: :->default-db-or-filepath' \ - '*:package:_cabal_list_packages' - - case $state in - (default-db-or-filepath) - _alternative \ - ':default db:(global user clear)' \ - ':filepath:_files' - ;; - esac -} - -_cabal_install () -{ - local context state state_descr line - typeset -A opt_args - - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--builddir=[the directory where Cabal puts generated build files]:directory:_files -/' \ - {-g,--ghc}'[compile with GHC]' \ - '--nhc98[compile with NHC]' \ - '--jhc[compile with JHC]' \ - '--lhc[compile with LHC]' \ - '--hugs[compile with Hugs]' \ - '--uhc[compile with UHC]' \ - '--haskell-suite[compile with a haskell-suite compiler]' \ - {-w,--with-compiler=}'[give the path to a particular compiler]:file:_files' \ - '--with-hc-pkg=[give the path to the package tool]:file:_files' \ - '--prefix=[take this prefix in preparation of installation]:directory:_files -/' \ - '--bindir=[installation directory for executables]:directory:_files -/' \ - '--libdir=[installation directory for libraries]:directory:_files -/' \ - '--libsubdir=[subdirectory of libdir in which libs are installed]:directory:_files -/' \ - '--libexecdir=[installation directory for program executables]:directory:_files -/' \ - '--datadir=[installation directory for read-only data]:directory:_files -/' \ - '--datasubdir=[subdirectory of datadir in which data files are installed]:directory:_files -/' \ - '--docdir=[installation directory for documentation]:directory:_files -/' \ - '--htmldir=[installation directory for HTML]:directory:_files -/' \ - '--haddockdir=[installation directory for haddock interfaces]:directory:_files -/' \ - '--sysconfdir=[installation directory for configuration files]:directory:_files -/' \ - {-b,--scratchdir=}'[directory to receive the built package]:directory:_files -/' \ - '--program-prefix=[prefix to be applied to installed executables]' \ - '--program-suffix=[suffix to be applied to installed executables]' \ - '--enable-library-vanilla[enable Vanilla libraries]' \ - '--disable-library-vanilla[disable Vanilla libraries]' \ - {-p,--enable-library-profiling}'[enable Library profiling]' \ - '--disable-library-profiling[disable Library profiling]' \ - '--enable-shared[enable Shared library]' \ - '--disable-shared[disable Shared library]' \ - '--enable-executable-dynamic[enable Executable dynamic linking]' \ - '--disable-executable-dynamic[disable Executable dynamic linking]' \ - '--enable-executable-profiling[enable Executable profiling]' \ - '--disable-executable-profiling[disable Executable profiling]' \ - {-O-,--enable-optimization=}'[build with optimization]:level:(0 1 2)' \ - '--disable-optimization[build without optimization]' \ - '--enable-library-for-ghci[enable compile library for use with GHCi]' \ - '--disable-library-for-ghci[disable compile library for use with GHCi]' \ - '--enable-split-objs[enable split library into smaller objects]' \ - '--disable-split-objs[disable split library into smaller objects]' \ - '--enable-executable-stripping[enable strip executables upon installation]' \ - '--disable-executable-stripping[disable strip executables upon installation]' \ - '--configure-option=[extra option for configure]' \ - '--user[enable doing a per-user installation]' \ - '--global[disable doing a per-user installation]' \ - '--package-db=[use a given package database]:: :->default-db-or-filepath' \ - {-f,--flags=}'[force values for the given flags]:flags:' \ - '--extra-include-dirs=[a list of directories to search for header files]:directory:_files -/' \ - '--extra-lib-dirs=[a list of directories to search for external libraries]:directory:_files -/' \ - '--extra-prog-path=[a list of directories to search for required programs]:directory:_files -/' \ - '--enable-tests[enable dependency checking and compilation for test suites listed in the package description file]' \ - '--disable-tests[disable dependency checking and compilation for test suites listed in the package description file]' \ - '--enable-library-coverage[enable build library and test suites with, Haskell Program Coverage enabled. (GHC only)]' \ - '--disable-library-coverage[disable build library and test suites with, Haskell Program Coverage enabled. (GHC only)]' \ - '--enable-benchmarks[enable dependency checking and compilation, for benchmarks listed in the package]' \ - '--disable-benchmarks[disable dependency checking and compilation, for benchmarks listed in the package]' \ - $_cabal_programs \ - '--cabal-lib-version=[select which version of the Cabal lib to use]' \ - '--constraint=[a list of additional constraints on the dependencies]' \ - '--preference=[specify preferences on the version of a package]' \ - '--solver=[select dependency solver to use]:solver:(topdown modular choose)' \ - '--allow-newer=[ignore upper bounds in dependencies on some or all packages]' \ - '--enable-documentation[enable building of documentation]' \ - '--disable-documentation[disable building of documentation]' \ - '--doc-index-file=[a central index of haddock API documentation]:file:_files' \ - '--dry-run[do not install anything]' \ - '--max-backjumps=[maximum number of backjumps allowed while solving dependencies]' \ - '--reorder-goals[try to reorder goals according to certain heuristics]' \ - '--shadow-installed-packages[if multiple package instances of the same version are installed, treat all but one as shadowed]' \ - '--reinstall[always install]' \ - '--avoid-reinstalls[do not select versions that would destructively overwrite installed packages]' \ - '--force-reinstalls[reinstall packages even if they will most likely break other installed packages]' \ - '--upgrade-dependencies[pick the latest version for all dependencies, rather than trying to pick an installed version]' \ - {--only-dependencies,--dependencies-only}'[install only the dependencies necessary to build the given packages]' \ - '--root-cmd=[command used to gain root privileges]::' \ - '--symlink-bindir=[add symlinks into this directory]:directory:_files -/' \ - '--build-summary=[save build summaries to file]:file:_files' \ - '--build-log=[log all builds to file]:file:_files' \ - '--remote-build-reporting=[generate build reports to send to a remote]:level:(none anonymous detailed)' \ - '--one-shot[do not record the packages in the world file]' \ - '--run-tests[run package test suites during installation]' \ - {-j,--jobs=}'[run NUM jobs simultaneously]' \ - '--haddock-hoogle[generate a hoogle database]' \ - '--haddock-html[generate HTML documentation]' \ - '--haddock-html-location=[location of HTML documentation]:url:' \ - '--haddock-executables[run haddock for Executables targets]' \ - '--haddock-tests[run haddock for Test Suite targets]' \ - '--haddock-benchmarks[run haddock for Benchmarks targets]' \ - '--haddock-all[run haddock for all targets]' \ - '--haddock-internal[run haddock for internal modules]' \ - '--haddock-css=[path to the haddock stylesheet]:file:_files' \ - '--haddock-hyperlink-source[hyperlink the documentation to the source code]' \ - '--haddock-hscolour-css=[path to the HsColour stylesheet]:file:_files' \ - '--haddock-contents-location=[bake URL in as the location for the contents page]:url:' \ - '*:: :->package-or-cabal-file' - - case $state in - (default-db-or-filepath) - _alternative \ - ':default db:(global user clear)' \ - ':filepath:_files' - ;; - (package-or-cabal-file) - _alternative \ - ':package:_cabal_list_packages' \ - ':files:_files -g "*.cabal"' - ;; - esac -} - -_cabal_list () -{ - local context state state_descr line - typeset -A opt_args - - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--installed[only print installed packages]' \ - '--simple-output[print in a easy-to-parse format]' \ - '--package-db=[use a given package database]:: :->default-db-or-filepath' \ - '*:package:_cabal_list_packages' - - case $state in - (default-db-or-filepath) - _alternative \ - ':default db:(global user clear)' \ - ':filepath:_files' - ;; - esac -} - -_cabal_register () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--builddir=[the directory where Cabal puts generated files]:directory:_files -/' \ - "--user[register in user's local package database]" \ - "--global[register in the system-wide package database]" \ - '--inplace[register in build location]' \ - '--gen-script[generate a script to register later]' \ - '--gen-pkg-config=[generate package registration file]' -} - -_cabal_repl () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--builddir=[the directory where Cabal puts generated build files]:directory:_files -/' \ - $_cabal_programs -} - -_cabal_report () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - {-u,--username=}'[hackage username]' \ - {-p,--password=}'[hackage password]' -} - -_cabal_run () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--builddir=[the directory where Cabal puts generated build files]:directory:_files -/' \ - {-j,--jobs=}'[run NUM jobs simultaneously]' \ - $_cabal_programs \ - "--only[don't reinstall add-source dependencies (sandbox-only)]" -} - -_cabal_sandbox () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--sandbox=[Sandbox location]:sandbox:_files -/' - - if (( CURRENT == 2 )); then - local -a _cabal_sandbox_cmds - _cabal_sandbox_cmds=( - 'init:initialize the sandbox' - 'delete:delete the sandbox' - 'add-source:add sources path to sandbox' - 'hc-pkg:call sandbox related haskell compiler package database' - 'list-sources:list added sources paths' - ) - _describe -t sandbox-commands 'sandbox-command' _cabal_sandbox_cmds || compadd "$@" - else - case $WORDS[3] in - add-source) - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--snapshot[take a snapshot instead of creating a link]' \ - '--sandbox=[Sandbox location]:sandbox:_files -/' \ - '*:sources:_files -/' - ;; - *) - _message "unknown cabal sandbox command: $WORDS[3]" - ;; - esac - fi -} - -_cabal_sdist () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--builddir=[the directory where Cabal puts generated files]:directory:_files -/' \ - "--list-sources=[just write a list of the package's sources to a file]:directory:_files -/" \ - '--snapshot[produce a snapshot source distribution]' \ - '--output-directory=[generate a source distribution in the given directory]:directory:_files -/' \ - '--targz[produce a .tar.gz format archive]' \ - '--zip[produce a .zip format archive]' -} - -_cabal_test () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - '--builddir=[the directory where Cabal puts generated files]:directory:_files -/' \ - '--log=[log all test suite results to file]:file:_files' \ - '--machine-log=[produce a machine-readable log file]:file:_files' \ - '--show-details=[when to show results of individual test cases?]:filter:(always never failures)' \ - '--keep-tix-files[keep .tix files for HPC between test runs]' \ - '--test-options=[give extra options to test executables]' \ - '--test-option=[give an extra option to test executables]' \ - {-j,--jobs=}'[run NUM jobs simultaneously]' \ - $_cabal_programs \ - "--only[don't reinstall add-source dependencies (sandbox-only)]" -} - -_cabal_update () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' -} - -_cabal_upload () -{ - _arguments \ - {-h,--help}'[show help]' \ - {-v-,--verbose=}'[control verbosity]:level:(0 1 2 3)' \ - {-c,--check}'[do not upload, just do QA checks]' \ - {-u-,--username=}'[hackage username]' \ - {-p-,--password=}'[hackage password]' \ - '*:file:_files -g "*.tar.gz"' -} - -_cabal_list_packages () { - _cabal_get_available_packages - _cabal_get_available_files=(*.cabal) - compadd "$@" -a -- _cabal_available_packages _cabal_get_available_files -} - -_cabal_get_available_packages () -{ - if ( [[ ${+_cabal_available_packages} -eq 0 ]] || _cache_invalid CABAL_AVAILABLE_PACKAGES ) && - ! _retrieve_cache CABAL_AVAILABLE_PACKAGES; - then - _cabal_available_packages=( $(cabal list --simple-output | cut -d' ' -f1 | uniq) ) - _store_cache CABAL_AVAILABLE_PACKAGES _cabal_available_packages - fi -} - -_cabal "$@" diff --git a/.zprezto/modules/completion/external/src/_caffeinate b/.zprezto/modules/completion/external/src/_caffeinate new file mode 100644 index 0000000..5f1e6a7 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_caffeinate @@ -0,0 +1,50 @@ +#compdef caffeinate +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------- +# Description +# ----------- +# +# Completion script for the OSX 'caffeinate' tool (man 8 caffeinate). +# +# ------------------------------------------------------------------------- +# Authors +# ------- +# +# * Nicolas Despres (initial version) +# +# ------------------------------------------------------------------------- + +_arguments -s \ + '-d[prevent the display from sleeping]' \ + '-i[prevent the system from idle sleeping]' \ + '-m[prevent the disk from idle sleeping]' \ + '-s[prevent the system from sleeping but only when running on AC power]' \ + '-u[declare that user is active]' \ + '-t+[assertion timeout value]:delay in seconds' \ + '-w+[waits for process to exit]:pid:_pids' \ + '(-):command: _command_names -e' \ + '*::args: _normal' diff --git a/.zprezto/modules/completion/external/src/_cap b/.zprezto/modules/completion/external/src/_cap index b6def37..a9a8fe5 100644 --- a/.zprezto/modules/completion/external/src/_cap +++ b/.zprezto/modules/completion/external/src/_cap @@ -1,5 +1,30 @@ #compdef cap # ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_celery b/.zprezto/modules/completion/external/src/_celery deleted file mode 100644 index 6c2c541..0000000 --- a/.zprezto/modules/completion/external/src/_celery +++ /dev/null @@ -1,139 +0,0 @@ -#compdef celery -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for celery (https://github.com/celery/celery). -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Dong weiming (https://github.com/dongweiming) -# -# ------------------------------------------------------------------------------ - -_celery () { -local -a _1st_arguments ifargs dopts controlargs - -typeset -A opt_args - -_1st_arguments=('worker' 'events' 'beat' 'shell' 'multi' 'amqp' 'status' 'inspect' \ - 'control' 'purge' 'list' 'migrate' 'call' 'result' 'report') -ifargs=('--app=' '--broker=' '--loader=' '--config=' '--version') -dopts=('--detach' '--umask=' '--gid=' '--uid=' '--pidfile=' '--logfile=' '--loglevel=') -controlargs=('--timeout' '--destination') -_arguments \ - '(-A --app=)'{-A,--app}'[app instance to use (e.g. module.attr_name):APP]' \ - '(-b --broker=)'{-b,--broker}'[url to broker. default is "amqp://guest@localhost//":BROKER]' \ - '(--loader)--loader[name of custom loader class to use.:LOADER]' \ - '(--config)--config[Name of the configuration module:CONFIG]' \ - '(--workdir)--workdir[Optional directory to change to after detaching.:WORKING_DIRECTORY]' \ - '(-q --quiet)'{-q,--quiet}'[Don"t show as much output.]' \ - '(-C --no-color)'{-C,--no-color}'[Don"t display colors.]' \ - '(--version)--version[show program"s version number and exit]' \ - '(- : *)'{-h,--help}'[show this help message and exit]' \ - '*:: :->subcmds' && return 0 - -if (( CURRENT == 1 )); then - _describe -t commands "celery subcommand" _1st_arguments - return -fi - -case "$words[1]" in - worker) - _arguments \ - '(-C --concurrency=)'{-C,--concurrency=}'[Number of child processes processing the queue. The default is the number of CPUs.]' \ - '(--pool)--pool=:::(processes eventlet gevent threads solo)' \ - '(--purge --discard)'{--discard,--purge}'[Purges all waiting tasks before the daemon is started.]' \ - '(-f --logfile=)'{-f,--logfile=}'[Path to log file. If no logfile is specified, stderr is used.]' \ - '(--loglevel=)--loglevel=:::(critical error warning info debug)' \ - '(-N --hostname=)'{-N,--hostname=}'[Set custom hostname, e.g. "foo.example.com".]' \ - '(-B --beat)'{-B,--beat}'[Also run the celerybeat periodic task scheduler.]' \ - '(-s --schedule=)'{-s,--schedule=}'[Path to the schedule database if running with the -B option. Defaults to celerybeat-schedule.]' \ - '(-S --statedb=)'{-S,--statedb=}'[Path to the state database.Default: None]' \ - '(-E --events)'{-E,--events}'[Send events that can be captured by monitors like celeryev, celerymon, and others.]' \ - '(--time-limit=)--time-limit=[nables a hard time limit (in seconds int/float) for tasks]' \ - '(--soft-time-limit=)--soft-time-limit=[Enables a soft time limit (in seconds int/float) for tasks]' \ - '(--maxtasksperchild=)--maxtasksperchild=[Maximum number of tasks a pool worker can execute before it"s terminated and replaced by a new worker.]' \ - '(-Q --queues=)'{-Q,--queues=}'[List of queues to enable for this worker, separated by comma. By default all configured queues are enabled.]' \ - '(-I --include=)'{-I,--include=}'[Comma separated list of additional modules to import.]' \ - '(--pidfile=)--pidfile=[Optional file used to store the process pid.]' \ - '(--autoscale=)--autoscale=[Enable autoscaling by providing max_concurrency, min_concurrency.]' \ - '(--autoreload)--autoreload[Enable autoreloading.]' \ - '(--no-execv)--no-execv[Don"t do execv after multiprocessing child fork.]' - compadd -a ifargs - ;; - inspect) - _values -s \ - 'active[dump active tasks (being processed)]' \ - 'active_queues[dump queues being consumed from]' \ - 'ping[ping worker(s)]' \ - 'registered[dump of registered tasks]' \ - 'report[get bugreport info]' \ - 'reserved[dump reserved tasks (waiting to be processed)]' \ - 'revoked[dump of revoked task ids]' \ - 'scheduled[dump scheduled tasks (eta/countdown/retry)]' \ - 'stats[dump worker statistics]' - compadd -a controlargs ifargs - ;; - control) - _values -s \ - 'add_consumer[tell worker(s) to start consuming a queue]' \ - 'autoscale[change autoscale settings]' \ - 'cancel_consumer[tell worker(s) to stop consuming a queue]' \ - 'disable_events[tell worker(s) to disable events]' \ - 'enable_events[tell worker(s) to enable events]' \ - 'pool_grow[start more pool processes]' \ - 'pool_shrink[use less pool processes]' \ - 'rate_limit[tell worker(s) to modify the rate limit for a task type]' \ - 'time_limit[tell worker(s) to modify the time limit for a task type.]' - compadd -a controlargs ifargs - ;; - multi) - _values -s \ - '--nosplash[Don"t display program info.]' \ - '--verbose[Show more output.]' \ - '--no-color[Don"t display colors.]' \ - '--quiet[Don"t show as much output.]' \ - 'start' 'restart' 'stopwait' 'stop' 'show' \ - 'names' 'expand' 'get' 'kill' - compadd -a ifargs - ;; - amqp) - _values -s \ - 'queue.declare' 'queue.purge' 'exchange.delete' 'basic.publish' \ - 'exchange.declare' 'queue.delete' 'queue.bind' 'basic.get' - ;; - list) - _values -s, 'bindings' - ;; - shell) - _values -s \ - '--ipython[force iPython.]' \ - '--bpython[force bpython.]' \ - '--python[force default Python shell.]' \ - '--without-tasks[don"t add tasks to locals.]' \ - '--eventlet[use eventlet.]' \ - '--gevent[use gevent.]' - compadd -a ifargs - ;; - beat) - _arguments \ - '(-s --schedule=)'{-s,--schedule=}'[Path to the schedule database. Defaults to celerybeat-schedule.]' \ - '(-S --scheduler=)'{-S,--scheduler=}'[Scheduler class to use. Default is celery.beat.PersistentScheduler.]' \ - '(--max-interval)--max-interval[]' - compadd -a dopts fargs - ;; - events) - _arguments \ - '(-d --dump)'{-d,--dump}'[Dump events to stdout.]' \ - '(-c --camera=)'{-c,--camera=}'[Take snapshots of events using this camera.]' \ - '(-F --frequency=)'{-F,--frequency=}'[Camera: Shutter frequency. Default is every 1.0 seconds.]' \ - '(-r --maxrate=)'{-r,--maxrate=}'[Camera: Optional shutter rate limit (e.g. 10/m).]' - compadd -a dopts fargs - ;; - *) - ;; - esac -} diff --git a/.zprezto/modules/completion/external/src/_cf b/.zprezto/modules/completion/external/src/_cf new file mode 100644 index 0000000..2c899d1 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_cf @@ -0,0 +1,994 @@ +#compdef cf +# ------------------------------------------------------------------------------ +# +# Copyright 2015 Ferran Rodenas & Danny Rosen +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ +# +# Description +# ----------- +# +# Completion script for Cloud Foundry CLI (https://github.com/cloudfoundry/cli#downloads) +# +# ------------------------------------------------------------------------------ +# +# Authors +# ------- +# +# * Ferran Rodenas (https://github.com/frodenas) +# * Danny Rosen (https://github.com/dannyzen) +# +# ------------------------------------------------------------------------------ + +# ---------------------- +# ----- Helper functions +# ---------------------- + +# Output a selectable list of organizations +__cf_orgs() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf orgs | awk 'NR>3{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'ORG' cont_cmd +} + +# Output a selectable list of spaces +__cf_spaces() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf spaces | awk 'NR>3{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'SPACE' cont_cmd +} + +# Output a selectable list of applications +__cf_apps() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf apps | awk 'NR>4{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'APP' cont_cmd +} + +# Output a selectable list of stacks +__cf_stacks() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf stacks | awk 'NR>4{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'STACK' cont_cmd +} + +# Output a selectable list of services +__cf_marketplace_services() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf marketplace | awk 'NR>4{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'SERVICE' cont_cmd +} + +# Output a selectable list of services +__cf_services() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf services | awk 'NR>4{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'SERVICE' cont_cmd +} + +# Output a selectable list of domains +__cf_domains() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf domains | grep -v shared | awk 'NR>2{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'DOMAIN' cont_cmd +} + +# Output a selectable list of shared domains +__cf_shared_domains() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf domains | grep -v owned | awk 'NR>2{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'SHARED-DOMAIN' cont_cmd +} + +# Output a selectable list of hostnames +__cf_hostnames() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf routes | awk 'NR>3{print $2}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'ROUTE' cont_cmd +} + +# Output a selectable list of buildpacks +__cf_buildpacks() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf buildpacks | awk 'NR>3{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'BUILDPACK' cont_cmd +} + +# Output a selectable list of feature flags +__cf_feature_flags() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf feature-flags | awk 'NR>4{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'FEATURE-FLAG' cont_cmd +} + +# Output a selectable list of plugin repos +__cf_repo_plugins() { + declare -a cont_cmd + cont_cmd=($(CF_COLOR=false CF_TRACE=false cf list-plugin-repos | awk 'NR>3{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'REPO-PLUGIN' cont_cmd +} + +# Output a selectable list of plugins +__cf_plugins() { + declare -a cont_cmd + cont_cmd=($(cf plugins | awk 'NR>4{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'PLUGIN' cont_cmd +} + +# Output a selectable list of targets (requires cf-targets plugin) +__cf_targets() { + declare -a cont_cmd + cont_cmd=($(cf targets | awk '{print $1}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'TARGET' cont_cmd +} + + +# -------------------------- +# ----- end Helper functions +# -------------------------- + +# -------------- +# ----- Commands +# -------------- + +__login() { + _arguments \ + '-a=[API endpoint (e.g. https://api.example.com)]:api endpoint:' \ + '-u=[Username]:username:' \ + '-p=[Password]:password:' \ + '-o=[Organization]:organization name:__cf_orgs' \ + '-s=[Space]:space name:__cf_spaces' \ + '--sso[Use a one-time password to login]' \ + '--skip-ssl-validation[Skip SSL validation]' +} + +__logout() { + # no arguments +} + +__passwd() { + _arguments \ + '1:password:' +} + +__target() { + _arguments \ + '-o=[Organization]:organization name:__cf_orgs' \ + '-s=[Space]:space name:__cf_spaces' +} + +__api() { + _arguments \ + '1:API url:' \ + '--unset[Remove all api endpoint targeting]' \ + '--skip-ssl-validation[Skip SSL validation]' +} + +__auth() { + # no arguments +} + +__apps() { + # no arguments +} + +__app() { + _arguments \ + '1:application name:__cf_apps' \ + '--guid[Retrieve and display the given app guid. All other health and status output for the app is suppressed]' +} + +__push() { + _arguments \ + '1:application name:__cf_apps' \ + '-b=[Custom buildpack by name (e.g. my-buildpack) or GIT URL or GIT BRANCH URL]:buildpack name:__cf_buildpacks' \ + '-c=[Startup command, set to null to reset to default start command]:startup command:' \ + '-d=[Domain (e.g. example.com)]:domain (e.g. example.com):__cf_domains' \ + '-f=[Path to manifest]:file:_files:' \ + '-i=[Number of instances]:number of instances:' \ + '-k=[Disk limit (e.g. 256M, 1024M, 1G)]:disk limit (e.g. 256M, 1024M, 1G):' \ + '-m=[Memory limit (e.g. 256M, 1024M, 1G)]:memory limit (e.g. 256M, 1024M, 1G):' \ + '-n=[Hostname (e.g. my-subdomain)]:hostname (e.g. my-subdomain):' \ + '-p=[Path to app directory or to a zip file of the contents of the app directory]:file:_files' \ + '-s=[Stack to use (a stack is a pre-built file system, including an operating system, that can run apps)]:stack name:__cf_stacks:' \ + '-t=[Maximum time (in seconds) for CLI to wait for application start, other server side timeouts may apply]:maximum time (in seconds):' \ + '--no-hostname[Map the root domain to this app]' \ + '--no-manifest[Ignore manifest file]' \ + '--no-route[Do not map a route to this app and remove routes from previous pushes of this app]' \ + '--no-start[Do not start an app after pushing]' \ + '--random-route[Create a random route for this app]' +} + +__scale() { + _arguments \ + '1:application name:__cf_apps' \ + '-i=[Number of instances]:number of instances:' \ + '-k=[Disk limit (e.g. 256M, 1024M, 1G)]:disk limit (e.g. 256M, 1024M, 1G):' \ + '-m=[Memory limit (e.g. 256M, 1024M, 1G)]:memory limit (e.g. 256M, 1024M, 1G):' \ + '-f[Force restart of app without prompt]' +} + +__delete() { + _arguments \ + '1:application name:__cf_apps' \ + '--f[Force deletion without confirmation]' \ + '--r[Also delete any mapped routes]' +} + +__rename() { + _arguments \ + '1:application name:__cf_apps' \ + '2:application name:' +} + +__start() { + _arguments \ + '1:application name:__cf_apps' +} + +__stop() { + _arguments \ + '1:application name:__cf_apps' +} + +__restart() { + _arguments \ + '1:application name:__cf_apps' +} + +__restage() { + _arguments \ + '1:application name:__cf_apps' +} + +__restart-app-instance() { + _arguments \ + '1:application name:__cf_apps' \ + '2:application index:' +} + +__events() { + _arguments \ + '1:application name:__cf_apps' +} + +__files() { + _arguments \ + '1:application name:__cf_apps' \ + '2::path:' \ + '-i=[instance]' +} + +__logs() { + _arguments \ + '1:application name:__cf_apps' \ + '--recent[Dump recent logs instead of tailing]' +} + +__env() { + _arguments \ + '1:application name:__cf_apps' +} + +__set-env() { + _arguments \ + '1:application name:__cf_apps' \ + '2:env var name:' \ + '3:env var value:' +} + +__unset-env() { + _arguments \ + '1:application name:__cf_apps' \ + '2:env var name:' +} + +__stacks() { + # no arguments +} + +__stack() { + _arguments \ + '1:stack name:__cf_stacks' \ + '--guid[Retrieve and display the given stack guid. All other output for the stack is suppressed]' +} + +__copy-source() { + _arguments \ + '1:source application name:__cf_apps' \ + '2:target application name:' \ + '-o=[Org that contains the target application]:organization name:__cf_orgs' \ + '-s=[Space that contains the target application]:space name:__cf_spaces' \ + '--no-restart[Override restart of the application in target environment after copy-source completes]' +} + +__create-app-manifest() { + _arguments \ + '1:application name:__cf_apps' \ + '-p=[Specify a path for file creation. If path not specified, manifest file is created in current working directory]:path:_files' +} + +__marketplace() { + _arguments \ + '-s=[Show plan details for a particular service offering]' +} + +__services() { + # no arguments +} + +__service() { + _arguments \ + '1:service name:__cf_services' \ + '--guid[Retrieve and display the given service guid. All other output for the service is suppressed]' +} + +__create-service() { + _arguments \ + '1:service:__cf_marketplace_services' \ + '2:plan:' \ + '3:service name:' \ + '-c=[Valid JSON object containing service-specific configuration parameters, provided either in-line or in a file]' \ + '-t=[User provided tags]' +} + +__update-service() { + _arguments \ + '1:service name:__cf_services' \ + '-p=[Change service plan for a service instance]' \ + '-c=[Valid JSON object containing service-specific configuration parameters, provided either in-line or in a file]' \ + '-t=[User provided tags]' +} + +__rename-service() { + _arguments \ + '1:service name:__cf_services' \ + '2:service name:' +} + +__delete-service() { + _arguments \ + '1:service name:__cf_services' \ + '-f[Force deletion without confirmation]' +} + +__create-service-key() { + _arguments \ + '1:service name:__cf_services' \ + '2:service key:' \ + '-c=[Valid JSON object containing service-specific configuration parameters, provided either in-line or in a file]' +} + +__service-keys() { + _arguments \ + '1:service name:__cf_services' +} + +__service-key() { + _arguments \ + '1:service name:__cf_services' \ + '2:service key:' +} + +__delete-service-key() { + _arguments \ + '1:service name:__cf_services' \ + '2:service key:' \ + '-f[Force deletion without confirmation]' +} + +__bind-service() { + _arguments \ + '1:application name:__cf_apps' \ + '2:service name:__cf_services' \ + '-c=[Valid JSON object containing service-specific configuration parameters, provided either in-line or in a file]' +} + +__unbind-service() { + _arguments \ + '1:application name:__cf_apps' \ + '2:service name:__cf_services' +} + +__create-user-provided-service() { + _arguments \ + '1:service name:' \ + '-p=[Credentials]' \ + '-l=[Syslog Drain Url]' +} + +__update-user-provided-service() { + _arguments \ + '1:service name:__cf_services' \ + '-p=[Credentials]' \ + '-l=[Syslog Drain Url]' +} + +__orgs() { + # no arguments +} + +__org() { + _arguments \ + '1:organization name:__cf_orgs' \ + '--guid[Retrieve and display the given org guid. All other output for the org is suppressed]' +} + +__create-org() { + _arguments \ + '1:organization name:' \ + '-q=[Quota to assign to the newly created org (excluding this option results in assignment of default quota)]' +} + +__delete-org() { + _arguments \ + '1:organization name:__cf_orgs' \ + '-f[Force deletion without confirmation]' +} + +__spaces() { + # no arguments +} + +__space() { + _arguments \ + '1:space name:__cf_spaces' \ + '--guid[Retrieve and display the given space guid. All other output for the space is suppressed]' \ + '--security-group-rules[Retrive the rules for all the security groups associated with the space]' +} + +__create-space() { + _arguments \ + '1:space name:' \ + '-o=[Org that contains the target application]:organization name:__cf_orgs' \ + '-q=[Quota to assign to the newly created space (excluding this option results in assignment of default quota)]' +} + +__delete-space() { + _arguments \ + '1:space name:__cf_spaces' \ + '-f[Force deletion without confirmation]' +} + +__domains() { + # no arguments +} + +__create-domain() { + _arguments \ + '1:organization name:__cf_orgs' \ + '2:domain:' +} + +__delete-domain() { + _arguments \ + '1:domain:__cf_domains' \ + '-f[Force deletion without confirmation]' +} + +__create-shared-domain() { + _arguments \ + '1:domain:' +} + +__delete-shared-domain() { + _arguments \ + '1:domain:__cf_shared_domains' \ + '-f[Force deletion without confirmation]' +} + +__routes() { + _arguments \ + '--orglevel[List all the routes for all spaces of current organization]' +} + +__create-route() { + _arguments \ + '1:space name:__cf_spaces' \ + '2:domain:__cf_domains' \ + '-n=[Hostname]' +} + +__check-route() { + _arguments \ + '1:hostname:__cf_hostnames' \ + '2:domain:__cf_domains' +} + +__map-route() { + _arguments \ + '1:application name:__cf_apps' \ + '2:domain:__cf_domains' \ + '-n=[Hostname]:hostname:__cf_hostnames:' +} + +__unmap-route() { + _arguments \ + '1:application name:__cf_apps' \ + '2:domain:__cf_domains' \ + '-n=[Hostname]:hostname:__cf_hostnames:' +} + +__delete-route() { + _arguments \ + '1:domain:__cf_domains' \ + '-n=[Hostname]:hostname:__cf_hostnames:' \ + '-f[Force deletion without confirmation]' +} + +__delete-orphaned-routes() { + _arguments \ + '-f[Force deletion without confirmation]' +} + +__buildpacks() { + # no arguments +} + +__create-buildpack() { + _arguments \ + '1:buildpack name:' \ + '2:path:_files' \ + '3:position:' \ + '--enable[Enable the buildpack to be used for staging]' \ + '--disable[Disable the buildpack from being used for staging]' +} + +__update-buildpack() { + _arguments \ + '1:buildpack name:__cf_buildpacks' \ + '-p=[Path to directory or zip file]:file:_files' \ + '-i=[The order in which the buildpacks are checked during buildpack auto-detection]' \ + '--enable[Enable the buildpack to be used for staging]' \ + '--disable[Disable the buildpack from being used for staging]' \ + '--lock[Lock the buildpack to prevent updates]' \ + '--unlock[Unlock the buildpack to enable updates]' +} + +__rename-buildpack() { + _arguments \ + '1:buildpack name:__cf_buildpacks' \ + '2:new buildpack name:' +} + +__delete-buildpack() { + _arguments \ + '1:buildpack name:__cf_buildpacks' \ + '-f[Force deletion without confirmation]' +} + +__running-environment-variable-group() { + # no arguments +} + +__staging-environment-variable-group() { + # no arguments +} + +__set-staging-environment-variable-group() { + # no arguments +} + +__set-running-environment-variable-group() { + # no arguments +} + +__feature-flags() { + # no arguments +} + +__feature-flag() { + _arguments \ + '1:feature name:__cf_feature_flags' +} + +__enable-feature-flag() { + _arguments \ + '1:feature name:__cf_feature_flags' +} + +__disable-feature-flag() { + _arguments \ + '1:feature name:__cf_feature_flags' +} + +__curl() { + _arguments \ + '1:path:' \ + '-i[Include response headers in the output]' \ + '-v[Enable CF_TRACE output for all requests and responses]' \ + '-X=[HTTP method]:http method:(GET POST PUT DELETE)' \ + '-h=[Custom headers to include in the request, flag can be specified multiple times]' \ + '-d=[HTTP data to include in the request body]' \ + '--output[Write curl body to FILE instead of stdout]' +} + +__config() { + _arguments \ + '--async-timeout=[Timeout for async HTTP requests]' \ + '--trace=[Trace HTTP requests]:trace:(true false)' \ + '--color=[Enable or disable color]:color:(true false)' \ + '--locale=[Set default locale. If LOCALE is CLEAR, previous locale is deleted]' +} + +__oauth-token() { + # no arguments +} + +__add-plugin-repo() { + _arguments \ + '1:repo name:' \ + '2:url:' +} + +__remove-plugin-repo() { + _arguments \ + '1:repo name:__cf_repo_plugins' \ + '2:url:' +} + +__list-plugin-repos() { + # no arguments +} + +__repo-plugins() { + _arguments \ + '-r=[Repo Name]:repo name:__cf_repo_plugins' +} + +__plugins() { + _arguments \ + '-checksum[Compute and show the sha1 value of the plugin binary file]' +} + +__install-plugin() { + _arguments \ + '1:plugin URL or path:_files' \ + '-r=[repo name where the plugin binary is located]:repo name:__cf_repo_plugins' +} + +__uninstall-plugin() { + _arguments \ + '1:plugin name:__cf_plugins' +} + +__save-target() { + _arguments \ + '1:target-name:' \ + '-f[Force save even if current target is already saved under another name]' +} + +__set-target() { + _arguments \ + '1:target-name:__cf_targets' \ + '-f[Force target change even if current target is unsaved]' +} + +__delete-target() { + _arguments \ + '1:target-name:__cf_targets' +} + +# ------------------ +# ----- end Commands +# ------------------ + +# ------------------- +# ----- 1st Arguments +# ------------------- + +local -a _1st_arguments +_1st_arguments=( + "login":"Log user in" + "logout":"Log user out" + "passwd":"Change user password" + "target":"Set or view the targeted org or space" + "api":"Set or view target api url" + "auth":"Authenticate user non-interactively" + "apps":"List all apps in the target space" + "app":"Display health and status for app" + "push":"Push a new app or sync changes to an existing app" + "scale":"Change or view the instance count, disk space limit, and memory limit for an app" + "delete":"Delete an app" + "rename":"Rename an app" + "start":"Start an app" + "stop":"Stop an app" + "restart":"Restart an app" + "restage":"Restage an app" + "restart-app-instance":"Terminate the running application Instance at the given index and instantiate a new instance of the application with the same index" + "events":"Show recent app events" + "files":"Print out a list of files in a directory or the contents of a specific file" + "logs":"Tail or show recent logs for an app" + "env":"Show all env variables for an app" + "set-env":"Set an env variable for an app" + "unset-env":"Remove an env variable" + "stacks":"List all stacks" + "stack":"Show information for a stack" + "copy-source":"Make a copy of app source code from one application to another. Unless overridden, the copy-source command will restart the application" + "create-app-manifest":"Create an app manifest for an app that has been pushed successfully" + "marketplace":"List available offerings in the marketplace" + "services":"List all service instances in the target space" + "service":"Show service instance info" + "create-service":"Create a service instance" + "update-service":"Update a service instance" + "delete-service":"Delete a service instance" + "rename-service":"Rename a service instance" + "create-service-key":"Create key for a service instance" + "service-keys":"List keys for a service instance" + "service-key":"Show service key info" + "delete-service-key":"Delete a service key" + "bind-service":"Bind a service instance to an app" + "unbind-service":"Unbind a service instance from an app" + "create-user-provided-service":"Make a user-provided service instance available to cf apps" + "update-user-provided-service":"Update user-provided service instance name value pairs" + "orgs":"List all orgs" + "org":"Show org info" + "create-org":"Create an org" + "delete-org":"Delete an org" + "rename-org":"Rename an org" + "spaces":"List all spaces in an org" + "space":"Show space info" + "create-space":"Create a space" + "delete-space":"Delete a space" + "rename-space":"Rename a space" + "domains":"List domains in the target org" + "create-domain":"Create a domain in an org for later use" + "delete-domain":"Delete a domain" + "create-shared-domain":"Create a domain that can be used by all orgs (admin-only)" + "delete-shared-domain":"Delete a shared domain" + "routes":"List all routes in the current space or the current organization" + "create-route":"Create a url route in a space for later use" + "check-route":"Perform a simple check to determine whether a route currently exists or not" + "map-route":"Add a url route to an app" + "unmap-route":"Remove a url route from an app" + "delete-route":"Delete a route" + "delete-orphaned-routes":"Delete all orphaned routes (e.g.: those that are not mapped to an app)" + "buildpacks":"List all buildpacks" + "create-buildpack":"Create a buildpack" + "update-buildpack":"Update a buildpack" + "rename-buildpack":"Rename a buildpack" + "delete-buildpack":"Delete a buildpack" + "running-environment-variable-group":"Retrieve the contents of the running environment variable group" + "staging-environment-variable-group":"Retrieve the contents of the staging environment variable group" + "set-staging-environment-variable-group":"Pass parameters as JSON to create a staging environment variable group" + "set-running-environment-variable-group":"Pass parameters as JSON to create a running environment variable group" + "feature-flags":"Retrieve list of feature flags with status of each flag-able feature" + "feature-flag":"Retrieve an individual feature flag with status" + "enable-feature-flag":"Enable the use of a feature so that users have access to and can use the feature" + "disable-feature-flag":"Disable the use of a feature so that users have access to and can use the feature" + "curl":"Executes a raw request, content-type set to application/json by default" + "config":"write default values to the config" + "oauth-token":"Retrieve and display the OAuth token for the current session" + "add-plugin-repo":"Add a new plugin repository" + "remove-plugin-repo":"Remove a plugin repository" + "list-plugin-repos":"list all the added plugin repository" + "repo-plugins":"List all available plugins in all added repositories" + "plugins":"list all available plugin commands" + "install-plugin":"Install the plugin defined in command argument" + "uninstall-plugin":"Uninstall the plugin defined in command argument" + "targets":"List all saved targets (requires cf-targets plugin)" + "save-target":"Save the current target under a given name (requires cf-targets plugin)" + "set-target":"Restore a previously saved target (requires cf-targets plugin)" + "delete-target":"Delete a saved target (requires cf-targets plugin)" +) + +# ----------------------- +# ----- end 1st Arguments +# ----------------------- + +# ---------- +# ----- Main +# ---------- + +_arguments '*:: :->command' + +if (( CURRENT == 1 )); then + _describe -t commands "cf command" _1st_arguments + return +fi + +local -a _command_args +case "$words[1]" in + login) + __login ;; + logout) + __logout ;; + passwd) + __passwd ;; + target) + __target ;; + api) + __api ;; + auth) + __auth ;; + apps) + __apps ;; + app) + __app ;; + push) + __push ;; + scale) + __scale ;; + delete) + __delete ;; + rename) + __rename ;; + start) + __start ;; + stop) + __stop ;; + restart) + __restart ;; + restage) + __restage ;; + restart-app-instance) + __restart-app-instance ;; + events) + __events ;; + files) + __files ;; + logs) + __logs ;; + env) + __env ;; + set-env) + __set-env ;; + unset-env) + __unset-env ;; + stacks) + __stacks ;; + stack) + __stack ;; + copy-source) + __copy-source ;; + create-app-manifest) + __create-app-manifest ;; + marketplace) + __marketplace ;; + services) + __services ;; + service) + __service ;; + create-service) + __create-service ;; + update-service) + __update-service ;; + rename-service) + __rename-service ;; + delete-service) + __delete-service ;; + create-service-key) + __create-service-key ;; + service-keys) + __service-keys ;; + service-key) + __service-key ;; + delete-service-key) + __delete-service-key ;; + bind-service) + __bind-service ;; + unbind-service) + __unbind-service ;; + create-user-provided-service) + __create-user-provided-service ;; + update-user-provided-service) + __update-user-provided-service ;; + orgs) + __orgs ;; + org) + __org ;; + create-org) + __create-org ;; + delete-org) + __delete-org ;; + spaces) + __spaces ;; + space) + __space ;; + create-space) + __create-space ;; + delete-space) + __delete-space ;; + domains) + __domains ;; + create-domain) + __create-domain ;; + delete-domain) + __delete-domain ;; + create-shared-domain) + __create-shared-domain ;; + delete-shared-domain) + __delete-shared-domain ;; + routes) + __routes ;; + create-route) + __create-route ;; + check-route) + __check-route ;; + map-route) + __map-route ;; + unmap-route) + __unmap-route ;; + delete-route) + __delete-route ;; + delete-orphaned-routes) + __delete-orphaned-routes ;; + buildpacks) + __buildpacks ;; + create-buildpack) + __create-buildpack ;; + update-buildpack) + __update-buildpack ;; + rename-buildpack) + __rename-buildpack ;; + delete-buildpack) + __delete-buildpack ;; + running-environment-variable-group) + __running-environment-variable-group ;; + staging-environment-variable-group) + __staging-environment-variable-group ;; + set-staging-environment-variable-group) + __set-staging-environment-variable-group ;; + set-running-environment-variable-group) + __set-running-environment-variable-group ;; + feature-flags) + __feature-flags ;; + feature-flag) + __feature-flag ;; + enable-feature-flag) + __enable-feature-flag ;; + disable-feature-flag) + __disable-feature-flag ;; + curl) + __curl ;; + config) + __config ;; + oauth-token) + __oauth-token ;; + add-plugin-repo) + __add-plugin-repo ;; + remove-plugin-repo) + __remove-plugin-repo ;; + list-plugin-repos) + __list-plugin-repos ;; + repo-plugins) + __repo-plugins ;; + plugins) + __plugins ;; + install-plugin) + __install-plugin ;; + uninstall-plugin) + __uninstall-plugin ;; + save-target) + __save-target ;; + set-target) + __set-target ;; + delete-target) + __delete-target ;; +esac diff --git a/.zprezto/modules/completion/external/src/_chattr b/.zprezto/modules/completion/external/src/_chattr new file mode 100644 index 0000000..072bb14 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_chattr @@ -0,0 +1,77 @@ +#compdef chattr +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for chattr a tool to change file attributes on a Linux second extended file system. (http://e2fsprogs.sourceforge.net/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + + +_chattr() { + +_arguments -C \ + "-R[Recursively change attributes of directories and their contents.]" \ + "-V[Be verbose with chattr's output and print the program version.]" \ + "-f[Suppress most error messages.]" \ + "-v[Set the file's version/generation number.]:version:" \ + "(-A)+A[Disable atime updates]" \ + "(+A)-A[Enable atime updates]" \ + "(-a)+a[Enable append only - file cannot be overridden]" \ + "(+a)-a[Disable append only - file can be overridden]" \ + "(-c)+c[Enable automatic compression]" \ + "(+c)-c[Disable automatic compression]" \ + "(-D)+D[Enable synchronous directory updates]" \ + "(+D)-D[Disable synchronous directory updates]" \ + "(-d)+d[Forbid backing file up with dump program]" \ + "(+d)-d[Allow backing file up with dump program]" \ + "(-i)+i[Mark as immutable]" \ + "(+i)-i[Unmark as immutable]" \ + "(-j)+j[Enable ext3 journaling]" \ + "(+j)-j[Disable ext3 journaling]" \ + "(-s)+s[Enable secure deletion - zero all blocks on delete]" \ + "(+s)-s[Disable secure deletion - do not zero all blocks on delete]" \ + "(-S)+S[Enable synchronous updates]" \ + "(+S)-S[Disable synchronous updates]" \ + "(-T)+T[Set top of hierarchy - direct subdirectories are allocated independently]" \ + "(+T)-T[Unset top of hierarchy]" \ + "(-t)+t[Disable tail merging]" \ + "(+t)-t[Enable tail merging]" \ + "(-u)+u[Mark as undeletable - enable undeletion]" \ + "(+u)-u[Unmark as undeletable - disable undeletion]" \ + '*:files:_files' \ +} + +_chattr + diff --git a/.zprezto/modules/completion/external/src/_cheat b/.zprezto/modules/completion/external/src/_cheat new file mode 100644 index 0000000..349249c --- /dev/null +++ b/.zprezto/modules/completion/external/src/_cheat @@ -0,0 +1,73 @@ +#compdef cheat +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Cheat an interactive cheatsheets on the command-line. (https://github.com/chrisallenlane/cheat/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + +local cheats + +_cheat_load_cheats() { + cheats=("${(f)$(cheat -l | cut -d' ' -f1)}") +} + + +_cheat() { + + + _arguments -C -s -S -n \ + '(- 1 *)'{-d,--directories}'[List directories on CHEATPATH]: :->full' \ + '(- 1 *)'{-e,--edit}'[Edit cheatsheet]:cheat:->cheats' \ + '(- 1 *)'{-l,--list}'[List cheatsheets]: :->full' \ + '(- 1 *)'{-s,--search}'[Search cheatsheets for ]: :->full' \ + '(- 1 *)'{-v,--version}'[display version and copyright information]: :->full' \ + + case "$state" in + (full) + ;; + (cheats) + _cheat_load_cheats + _describe -t cheats 'cheats' cheats + ;; + (*) + _cheat_load_cheats + _describe -t cheats 'cheats' cheats + ;; + esac +} + +_cheat + diff --git a/.zprezto/modules/completion/external/src/_cmake b/.zprezto/modules/completion/external/src/_cmake index 544137b..240c7ea 100644 --- a/.zprezto/modules/completion/external/src/_cmake +++ b/.zprezto/modules/completion/external/src/_cmake @@ -1,5 +1,30 @@ #compdef cmake - +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------- # Description # ----------- # @@ -9,7 +34,8 @@ # Authors # ------- # -# * Scott M. Kroll +# * Scott M. Kroll (initial version) +# * Paul Seyfert (handling of --build) # # ------------------------------------------------------------------------- # Notes @@ -24,10 +50,133 @@ # # ------------------------------------------------------------------------- -_cmake() { - local context state line curcontext="$curcontext" cmake_args +local context state line curcontext="$curcontext" cmake_args - local cmake_help_actions;cmake_help_actions=( +local cmake_build_options;cmake_build_options=( + '-C[Pre-load a script to populate the cache]:script:_files' + '*-D-[Create a cmake cache entry]:property:_cmake_define_property' + '-U[Remove matching entries from CMake cache]:globbing expression' + '-G[Specify a makefile generator]:generator:_cmake_generators' + '-T[Specify toolset name if supported by generator]:toolset name' + '(-Wno-dev -Wdev)-Wno-dev[Suppress/Enable developer warnings]' + '(-Wno-dev -Wdev)-Wdev[Suppress/Enable developer warnings]' + '(-Wno-deprecated -Wdeprecated)-Wno-deprecated[Suppress/Enable deprecation warnings]' + '(-Wno-deprecated -Wdeprecated)-Wdeprecated[Suppress/Enable deprecation warnings]' + '(-Wno-error=dev -Werror=dev)-Wno-error=dev[Make developer warnings (not) errors]' + '(-Wno-error=dev -Werror=dev)-Werror=dev[Make developer warnings (not) errors]' + '(-Wno-error=deprecated -Werror=deprecated)-Werror=deprecated[Make deprecated macro and function warnings (not) errors]' + '(-Wno-error=deprecated -Werror=deprecated)-Wno-error=deprecated[Make deprecated macro and function warnings (not) errors]' + '--warn-uninitialized[Warn about uninitialized values.]' + '--warn-unused-vars[Warn about unused variables.]' + '--no-warn-unused-cli[Dont warn about command line options.]' + '-i[Run in wizard mode]' + '-L-[List cache variables]::_values "options" "[non-advanced cache variables]" "A[advanced cache variables]" "H[non-advanced cached variables with help]" "AH[advanced cache variables with help]"' + '--trace[Put cmake in trace mode]' + '--find-package[Run in pkg-config like mode.]' + ':cmake project:_files -/' +) + +# ------------------------ +# _cmake_generator_options +# ------------------------ +(( $+functions[_cmake_generator_options] )) || +_cmake_generator_options() { + if [ -f $1/Makefile ] + then + $_comps[make] + elif [ -f $1/build.ninja ] + then + $_comps[ninja] + fi +} + +# -------------- +# _cmake_targets +# -------------- +(( $+functions[_cmake_targets] )) || +_cmake_targets() { + local -a targets + if [ -f $1/Makefile ] + then + # `make help` doesn't work for Makefiles in general, but for cmake generated makefiles it does. + i=1 + for target in $(make help | \grep -e "\.\.\." | sed "s/\.\.\. //" | sed "s/ (the default.*//") ; do + targets[$i]=$target + (( i = $i + 1 )) + done + elif [ -f $1/build.ninja ] + then + # `ninja help` doesn't seem to be the list of targets we're interested in + i=1 + for target in $(ninja -C $1 -t targets all 2&>/dev/null | awk -F: '{print $1}') ; do + targets[$i]="$target" + (( i++ )) + done + fi + _describe 'build targets' targets +} + +_cmake_on_build() { + local build_extras;build_extras=( + '--[Native build tool options]' + '--target[specify build target]' + '--clean-first[build target clean first]' + '--config[For multi-configuration tools]' + '--use-stderr') + local -a undescribed_build_extras + i=1 + for be in $build_extras ; do + undescribed_build_extras[$i]=$(echo $be | sed "s/\[.*//") + (( i++ )) + done + inbuild=false + nativemode=false + for ((i = (($CURRENT - 1)); i > 1 ; i--)); do + if [[ $words[$i] == --build ]] ; then + inbuild=true + buildat=$i + (( difference = $CURRENT - $i )) + elif [[ $words[$i] == -- ]] ; then + nativemode=true + fi + done + # check if build mode has been left + outofbuild=false + for ((i = (($CURRENT - 1)); i > (($buildat + 1)); i--)); do + # don't check the word after --build (should be a directory) + if [[ ${undescribed_build_extras[(r)$words[$i]]} == $words[$i] ]] ; then continue ; fi + if [[ $words[(($i - 1))] == --target ]] ; then continue ; fi + if [[ $words[(($i - 1))] == --config ]] ; then continue ; fi + outofbuild=true + done + if [ "$nativemode" = true ] ; then + _cmake_generator_options $words[(($buildat + 1))] && return 0 + fi + if [ "$inbuild" = false ] ; then + _arguments -C -s \ + - build_opts \ + "$cmake_build_options[@]" \ + - build_cmds \ + "$cmake_suggest_build[@]" && return 0 + elif [ $difference -eq 1 ] ; then + # directly after --build comes the build directory + _alternative ':current directory:(.)' 'directory::_directories' && return 0 + elif [[ $words[(($CURRENT - 1))] == --target ]] ; then + # after --build --target, suggest targets + _cmake_targets $words[(($buildat + 1))] && return 0 + elif [[ $words[(($CURRENT - 1))] == --config ]] ; then + # after --build --config, no idea + return 0 + elif [ "$outofbuild" = true ] ; then + # after --build --, suggest other cmake_build_options (like -Wno-dev) + _arguments "$cmake_build_options[@]" && return 0 + else + # after --build , suggest other cmake_build_options (like -Wno-dev) or --build options (like --clean-first) + _arguments "$build_extras[@]" "$cmake_build_options[@]" && return 0 + fi +} + +local cmake_help_actions;cmake_help_actions=( '(- 1)--help-command[Print help for a single command and exit]:command-name:_cmake_command_names' '(- 1)--help-command-list[List available listfile commands and exit]' '(- 1)--help-commands[Print help for all commands and exit]' @@ -47,33 +196,9 @@ _cmake() { '(- 1)--help-html[Print full help in HTML format]' '(- 1)--help-man[Print full help as a UNIX man page and exit]' '(- 1)'{--version,-version}'[Print full help as a UNIX man page and exit]' - ) - - local cmake_build_options;cmake_build_options=( - '-C[Pre-load a script to populate the cache]:script:_files' - '*-D-[Create a cmake cache entry]:property:_cmake_define_property' - '-U[Remove matching entries from CMake cache]:globbing expression' - '-G[Specify a makefile generator]:generator:_cmake_generators' - '-T[Specify toolset name if supported by generator]:toolset name' - '(-Wno-dev -Wdev)-Wno-dev[Suppress developer warnings]' - '(-Wno-dev -Wdev)-Wdev[Enable developer warnings]' - '-i[Run in wizard mode]' - '-L-[List cache variables]::_values "options" "[non-advanced cache variables]" "A[advanced cache variables]" "H[non-advanced cached variables with help]" "AH[advanced cache variables with help]"' - '--trace[Put cmake in trace mode]' - ':cmake project:_files -/' - ) - - local cmake_command_actions;cmake_command_actions=( - '-E[CMake command mode]:*:command' - ) - - _arguments -C -s \ - - help \ - "$cmake_help_actions[@]" \ - - command \ - "$cmake_command_actions[@]" \ - - build_opts \ - "$cmake_build_options[@]" && return 0 +) +_cmake_help() { + _arguments -C -s - help "$cmake_help_actions[@]" } # ------------------- @@ -163,7 +288,7 @@ _cmake_define_lang_property_names() { "CMAKE_${cmake_lang}_COMPILER:${cmake_lang_desc} compiler" "CMAKE_${cmake_lang}_FLAGS:${cmake_lang_desc} compiler flags for all builds" "CMAKE_${cmake_lang}_FLAGS_DEBUG:${cmake_lang_desc} compiler flags for all Debug build" - "CMAKE_${cmake_lang}_FLAGS_RLEASE:${cmake_lang_desc} compiler flags for all Relase build" + "CMAKE_${cmake_lang}_FLAGS_RELEASE:${cmake_lang_desc} compiler flags for all Relase build" "CMAKE_${cmake_lang}_FLAGS_MINSIZREL:${cmake_lang_desc} compiler flags for all MinSizRel build" "CMAKE_${cmake_lang}_FLAGS_RELWITHDEBINFO:${cmake_lang_desc} compiler flags for all RelWithDebInfo build" ) @@ -177,10 +302,12 @@ _cmake_define_lang_property_names() { (( $+functions[_cmake_define_common_property_names] )) || _cmake_define_common_property_names() { local properties; properties=( + 'CMAKE_MODULE_PATH:Search path for cmake modules' 'CMAKE_BUILD_TYPE:Specifies the build type for make based generators' 'CMAKE_TOOLCHAIN_FILE:Absolute or relative path to a cmake script which sets up toolchain related variables' 'CMAKE_COLOR_MAKEFILE:Enables/disables color output when using the Makefile generator' 'CMAKE_INSTALL_PREFIX:Install directory used by install' + 'CMAKE_EXPORT_COMPILE_COMMANDS:Enable/disable output of compilation database during generation' ) _describe -t 'common-property-names' 'common property name' properties $@ @@ -198,6 +325,7 @@ _cmake_define_property_values() { (CMAKE_TOOLCHAIN_FILE) _wanted toolchain-files expl 'file' _cmake_toolchain_files && ret=0;; (CMAKE_COLOR_MAKEFILE) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; (CMAKE_INSTALL_PREFIX) _files -/ && ret=0;; + (CMAKE_EXPORT_COMPILE_COMMANDS) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; (CMAKE_*_COMPILER) _wanted compilers expl 'compiler' _cmake_compilers && ret=0;; (CMAKE_*_FLAGS(|_?*)) _message -e compiler-flags 'compiler flags' && ret=0;; (*) _files && ret=0;; @@ -269,6 +397,31 @@ _cmake_compilers() { _command_names -e } +local cmake_command_actions;cmake_command_actions=( + '-E[CMake command mode]:*:command' +) +_cmake_command() { + _arguments -C -s - command "$cmake_command_actions[@]" +} -_cmake "$@" +local cmake_suggest_build;cmake_suggest_build=( + '--build[build]' +) +if [ $CURRENT -eq 2 ] ; then + _arguments -C -s \ + - help \ + "$cmake_help_actions[@]" \ + - command \ + "$cmake_command_actions[@]" \ + - build_opts \ + "$cmake_build_options[@]" \ + - build_cmds \ + "$cmake_suggest_build[@]" && return 0 +elif [[ $words[2] = --help* ]] ; then + _cmake_help +elif [[ $words[2] != -E ]] ; then + _cmake_on_build +else + _cmake_command +fi diff --git a/.zprezto/modules/completion/external/src/_column b/.zprezto/modules/completion/external/src/_column new file mode 100644 index 0000000..1cb2245 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_column @@ -0,0 +1,60 @@ +#compdef column +# +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for column (from util-linux 2.27.1->) +# (https://git.kernel.org/cgit/utils/util-linux/util-linux.git/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Ole Jørgen Brønner +# +# ------------------------------------------------------------------------------ +# +# Note: column has upstream bash completions. +# +# Automatically generated with http://github.com/RobSis/zsh-completion-generator + +local arguments + +arguments=( + '(-c --columns)'{-c,--columns}'[width of output in number of characters]:width:' + '(-t --table)'{-t,--table}'[create a table]' + '(-s --separator)'{-s,--separator}'[possible table delimiters]:separator:' + '(-o --output-separator)'{-o,--output-separator}'[columns separator for table output; default is two spaces]:separator:' + '(-x --fillrows)'{-x,--fillrows}'[fill rows before columns]' + '(-h --help)'{-h,--help}'[display this help and exit]' + '(-V --version)'{-V,--version}'[output version information and exit]' + '*:filename:_files' +) + +_arguments -s $arguments diff --git a/.zprezto/modules/completion/external/src/_console b/.zprezto/modules/completion/external/src/_console index fc2a6f0..7e5b454 100644 --- a/.zprezto/modules/completion/external/src/_console +++ b/.zprezto/modules/completion/external/src/_console @@ -35,18 +35,29 @@ # ------- # # * loranger (https://github.com/loranger) +# * Yohan Tambè (https://github.com/Cronos87) # # ------------------------------------------------------------------------------ +_find_console () { + echo "php $(find . -maxdepth 2 -mindepth 1 -name 'console' -type f | head -n 1)" +} _console_get_command_list () { - php console --no-ansi | sed "1,/Available commands/d" | awk '/ [a-z]+/ { print $1 }' + IFS=" " + `_find_console` --no-ansi | \ + sed "1,/Available commands/d" | \ + awk '/ [a-z]+/ { print $0 }' | \ + sed -E 's/^[ ]+//g' | \ + sed -E 's/[:]+/\\:/g' | \ + sed -E 's/[ ]{2,}/\:/g' } _console () { - if [ -f console ]; then - compadd `_console_get_command_list` - fi + local -a commands + IFS=$'\n' + commands=(`_console_get_command_list`) + _describe 'commands' commands } compdef _console php console diff --git a/.zprezto/modules/completion/external/src/_cpanm b/.zprezto/modules/completion/external/src/_cpanm deleted file mode 100644 index 8597b1f..0000000 --- a/.zprezto/modules/completion/external/src/_cpanm +++ /dev/null @@ -1,105 +0,0 @@ -#compdef cpanm -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for cpanm (http://search.cpan.org/dist/App-cpanminus/lib/App/cpanminus.pm). -# -# Source: https://github.com/rshhh/cpanminus/blob/master/etc/_cpanm -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Ryushi (https://github.com/rshhh) -# -# ------------------------------------------------------------------------------ - - -local arguments curcontext="$curcontext" -typeset -A opt_args - - -arguments=( - -# Commands -# '(--install -i)'{--install,-i}'[Installs the modules]' - '(- :)--self-upgrade[Upgrades itself]' - '(- :)--info[Displays distribution info on CPAN]' - '(--installdeps)--installdeps[Only install dependencies]' - '(--look)--look[Download/unpack the distribution and then open the directory with your shell]' - '(--uninstall -U)'{--uninstall,-U}'[Uninstalls the modules]' - '(- :)'{--help,-h}'[Displays help information]' - '(- :)'{--version,-V}'[Displays software version]' - -# Options - {--force,-f}'[Force install]' - {--notest,-n}'[Do not run unit tests]' - '(--test-only)--test-only[Run the test only and do not install the module]' - {--sudo,-S}'[sudo to run install commands]' - '(-v --verbose --quiet -q)'{--verbose,-v}'[Turns on chatty output]' - '(-q --quiet --verbose -v)'{--quiet,-q}'[Turns off all output]' - {--local-lib,-l}'[Specify the install base to install modules]' - {--local-lib-contained,-L}'[Specify the install base to install all non-core modules]' - '(--self-contained)--self-contained[Assume no non-core modules are installed on the system]' - '--mirror[Specify the base URL for the mirror (e.g. http://cpan.cpantesters.org/)]:URLs:_urls' - '--mirror-only[Use the mirror\''s index file instead of the CPAN Meta DB]' - '--mirror-index[Specifies the file path for module search index]:FILES:_files' - '--prompt[Prompt when configure/build/test fails]' - '(--dev)--dev[Search for a newer developer release as well]' - '--reinstall[Reinstall the distribution even if you already have the latest version installed]' - '--interactive[Turn on interactive configure]' - '(--pp --pureperl)'{--pp,--pureperl}'[Prefer Pure perl build of modules]' - '(--with-recommends)--with-recommends[Installs dependencies declared as "recommends"]' - '(--with-suggests)--with-suggests[Installs dependencies declared as "suggests"]' - '(--with-feature)--with-feature[Specifies the feature to enable]' - '(--without-feature)--without-feature[Specifies the feature to disable]' - '(--with-all-features)--with-all-features[Enables all the optional features]' - '(--configure-timeout)--configure-timeout[Specify the timeout length to wait for configure]' - '(--build-timeout)--build-timeout[Specify the timeout length to wait for build]' - '(--test-timeout)--test-timeout[Specify the timeout length to wait for test]' - '(--configure-args)--configure-args[Pass arguments for configure commands]' - '(--build-args)--build-args[Pass arguments for build commands]' - '(--test-args)--test-args[Pass arguments for test commands]' - '(--install-args)--install-args[Pass arguments for install commands]' - - '--scandeps[Scan the dependencies of given modules and output the tree in a text format]' - '--format[Specify what format to display the scanned dependency tree]:scandeps format:(tree json yaml dists)' - - '--save-dists[Specify the optional directory path to copy downloaded tarballs]' - '(--uninst-shadows)--uninst-shadows[Uninstalls the shadow files of the distribution that you\''re installing]' - - '(--cascade-search)--cascade-search[Specifies whether to cascade search]' - '(--skip-installed)--skip-installed[Specifies modules which latest version are already installed]' - '(--skip-satisfied)--skip-satisfied[Specifies module and version for skipping installation]' - '(--verify)--verify[Verify the integrity of distribution files]' - '(--no-report-perl-version)--report-perl-version[Report locally installed perl version as part of User-Agent]' - '(--report-perl-version)--no-report-perl-version[Disable --report-perl-version]' - '--auto-cleanup[Number of days that cpanm\''s work directories expire in. Defaults to 7]' - '(--no-man-pages)--man-pages[Generates man pages for executables (man1) and libraries (man3)]' - '(--man-pages)--no-man-pages[Do not generate man pages]' - - - # Note: Normally with "--lwp", "--wget" and "--curl" options set to true (which is the default) cpanm tries LWP, - # Wget, cURL and HTTP::Tiny (in that order) and uses the first one available. - # (So that the exclusions are not enabled here for the completion) - '(--lwp)--lwp[Use LWP module to download stuff]' - '(--wget)--wget[Use GNU Wget (if available) to download stuff]' - '(--curl)--curl[Use cURL (if available) to download stuff]' - -# Other completions - '*:Local directory or archive:_files -/ -g "*.(tar.gz|tgz|tar.bz2|zip)(-.)"' - # '*::args: _normal' # this looks for default files (any files) -) -_arguments -s $arguments \ - && return 0 - -return 1 - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_dad b/.zprezto/modules/completion/external/src/_dad new file mode 100644 index 0000000..9ceee06 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_dad @@ -0,0 +1,68 @@ +#compdef dad +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for dad a command line manager of aria2 daemon. (https://github.com/baskerville/diana). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + +_dad() { + local -a commands + + commands=( + "start:Start aria2c daemon" + "stop:Stop aria2c daemon" + ) + + _arguments -C \ + '(- 1 *)'-h"[Show help and exit]" \ + "-d[Set download dir]:download_dir:->val" \ + "-s[Set secret token]:secret_token:->val" \ + "-u[Set aria2c username]:username:->val" \ + "-p[Set aria2c password]:password:->val" \ + '1:cmd:->cmds' \ + '*: : :->args' \ + + case "$state" in + (cmds) + _describe -t commands 'commands' commands + ;; + (*) + ;; + esac +} + +_dad + diff --git a/.zprezto/modules/completion/external/src/_debuild b/.zprezto/modules/completion/external/src/_debuild index e2c5b62..20c676e 100644 --- a/.zprezto/modules/completion/external/src/_debuild +++ b/.zprezto/modules/completion/external/src/_debuild @@ -1,30 +1,5 @@ #compdef debuild # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_dget b/.zprezto/modules/completion/external/src/_dget index 4c196c0..7460210 100644 --- a/.zprezto/modules/completion/external/src/_dget +++ b/.zprezto/modules/completion/external/src/_dget @@ -1,5 +1,30 @@ #compdef dget # ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ # Description # ----------- # @@ -9,7 +34,7 @@ # Authors # ------- # -# * Kris Shannon +# * Kris Shannon # # ------------------------------------------------------------------------------ @@ -18,18 +43,19 @@ _dget() { local -A opt_args _arguments -A "-*" \ - '(-h --help)'{-h,--help}'[Show help message]' \ - '(-V --version)'{-v,--version}'[Print license, copyright, and version information and exit]' \ - '(-q --quiet)'{-q,--quiet}'[Suppress wget/curl output]' \ - '(-d --download-only --build)'{-d,--download-only}'[Do not extract downloaded source]' \ - '(-x --extract)'{-x,--extract}'[Unpack downloaded source]' \ - '(-u --allow-unauthenticated)'{-u,--allow-unauthenticated}'[Make no attempt to verify source package signature]' \ - '(-d --download-only --build)--build[Build package with dpkg-buildpackage after download]' \ - '--path[Check this directory in addition to the apt archive]:DIR:_files -/' \ - '(--insecure)--insecure[Do not check SSL certificates when downloading]' \ - '(--no-cache)--no-cache[Disable server-side HTTP cache]' \ + '(--no-conf -h --help)'{-h,--help}'[Show help message]' \ + '(--no-conf -V --version)'{-v,--version}'[Print license, copyright, and version information and exit]' \ + '(--no-conf -b --backup)'{-b,--backup}'[Move files that would be overwritten to ./backup]' \ + '(--no-conf -q --quiet)'{-q,--quiet}'[Suppress wget/curl output]' \ + '(--no-conf -x --extract -d --download-only --build)'{-d,--download-only}'[Do not extract downloaded source]' \ + '(--no-conf -x --extract -d --download-only --build)'{-x,--extract}'[Unpack downloaded source]' \ + '(--no-conf -x --extract -d --download-only --build)--build[Build package with dpkg-buildpackage after download]' \ + '(--no-conf -u --allow-unauthenticated)'{-u,--allow-unauthenticated}'[Make no attempt to verify source package signature]' \ + '(--no-conf)--path[Check this directory in addition to the apt archive]:DIR:_files -/' \ + '(--no-conf --insecure)--insecure[Do not check SSL certificates when downloading]' \ + '(--no-conf --no-cache)--no-cache[Disable server-side HTTP cache]' \ "(--no-conf)--no-conf[Don't read devscripts config files]" \ - '1:dsc url:_urls' + '(-)*:debian package urls:_urls' } _dget "$@" diff --git a/.zprezto/modules/completion/external/src/_dhcpcd b/.zprezto/modules/completion/external/src/_dhcpcd index 5683424..82b821f 100644 --- a/.zprezto/modules/completion/external/src/_dhcpcd +++ b/.zprezto/modules/completion/external/src/_dhcpcd @@ -1,30 +1,5 @@ #compdef dhcpcd # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_diana b/.zprezto/modules/completion/external/src/_diana new file mode 100644 index 0000000..54bb029 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_diana @@ -0,0 +1,150 @@ +#compdef diana +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Diana a command line interface to the aria2 daemon. (https://github.com/baskerville/diana). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + +local GIDs PGIDs + +_diana_load_gids() { + GIDs=() + local downloads hashArr fileName + + downloads=$(diana list | cut -d' ' -f1) + + if [ ${#downloads} -eq "0" ]; then + return + fi + + hashArr=("${(f)$(echo "$downloads")}") + for ((i=1; i<=${#hashArr[@]}; i++)); do + fileName=$(diana files $hashArr[i] | grep "[X]" | rev | cut -d'/' -f1 | rev); + GIDs+=("$hashArr[i]:$fileName"); + done +} + +_diana_load_paused_gids() { + PGIDs=() + local downloads hashArr fileName + + downloads=$(diana paused | cut -d' ' -f1) + + if [ ${#downloads} -eq "0" ]; then + return + fi + + hashArr=("${(f)$(echo "$downloads")}") + for ((i=1; i<=${#hashArr[@]}; i++)); do + fileName=$(diana files $hashArr[i] | grep "[X]" | rev | cut -d'/' -f1 | rev); + PGIDs+=("$hashArr[i]:$fileName"); + done +} + +_diana_command_arguments() { + case $words[1] in + (remove) + _diana_load_gids + _describe -t output 'Downloads to delete' GIDs + ;; + (info) + _diana_load_gids + _describe -t output 'Downloads to get info' GIDs + ;; + (files) + _diana_load_gids + _describe -t output 'Get files for downloads' GIDs + ;; + (forcerm) + _diana_load_gids + _describe -t output 'Downloads to delete' GIDs + ;; + (pause) + _diana_load_gids + _describe -t output 'Downloads to pause' GIDs + ;; + (resume) + _diana_load_paused_gids + _describe -t output 'Downloads to resume' PGIDs + ;; + (preview) + _diana_load_gids + _describe -t output 'Downloads to preview' GIDs + ;; + esac + + +} + +_diana() { + local -a commands + + commands=( + "list:Output the list of active downloads." + "paused:Output the list of paused downloads." + "stopped:Output the list of stopped downloads." + "info:Output informations regarding the given GIDs." + "files:Output the files owned by the downloads corresponding to the given GIDs." + "errors:Output the list of errors." + "stats:Output download bandwidth statistics." + "add:Download the given items (local or remote URLs to torrents, etc.)." + "remove:Remove the downloads corresponding to the given GIDs." + "forcerm:Forcibly remove the downloads corresponding to the given GIDs." + "pause:Pause the downloads corresponding to the given GIDs." + "resume:Resume the downloads corresponding to the given GIDs." + "preview:Preview all the files from all the downloads corresponding to the given GIDs." + "sleep:Pause all the active downloads." + "wake:Resume all the paused downloads." + "purge:Clear the list of stopped downloads and errors." + "clean:Stop seeding completed downloads." + ) + +_arguments -C \ + '1:cmd:->cmds' \ + '*:: :->args' \ + +case "$state" in + (cmds) + _describe -t commands 'commands' commands + ;; + (*) + _diana_command_arguments + ;; +esac +} + +_diana + diff --git a/.zprezto/modules/completion/external/src/_ditz b/.zprezto/modules/completion/external/src/_ditz deleted file mode 100644 index 70cf552..0000000 --- a/.zprezto/modules/completion/external/src/_ditz +++ /dev/null @@ -1,53 +0,0 @@ -#compdef ditz -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for Ditz (http://ditz.rubyforge.org). -# -# Source: https://github.com/technolize/zsh-completion-funcs -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * technolize (https://github.com/technolize) -# -# ------------------------------------------------------------------------------ - - -local ME=ditz -local COMMANDS=--commands -local OPTIONS='' - -if (($CURRENT == 2)); then - # We're completing the first word after the tool: the command. - _wanted command expl "$ME command" \ - compadd -- $( "$ME" "$COMMANDS" ) -else - # Find the options/files/URL/etc. for the current command by using the tool itself. - case "${words[$CURRENT]}"; in - -*) - _wanted args expl "Arguments for $ME ${words[2]}" \ - compadd -- $( "$ME" "${words[2]}" "$OPTIONS" ; _files ) - ;; - ht*|ft*) - _arguments '*:URL:_urls' - ;; - /*|./*|\~*|../*) - _arguments '*:file:_files' - ;; - *) - _wanted args expl "Arguments for $ME ${words[2]}" \ - compadd -- $( "$ME" "${words[2]}" "$OPTIONS" ) - ;; - esac -fi - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_docker b/.zprezto/modules/completion/external/src/_docker deleted file mode 100644 index 9104f38..0000000 --- a/.zprezto/modules/completion/external/src/_docker +++ /dev/null @@ -1,483 +0,0 @@ -#compdef docker -# -# zsh completion for docker (http://docker.com) -# -# version: 0.3.0 -# github: https://github.com/felixr/docker-zsh-completion -# -# contributors: -# - Felix Riedel -# - Vincent Bernat -# -# license: -# -# Copyright (c) 2013, Felix Riedel -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -__docker_get_containers() { - local kind expl - declare -a running stopped lines args - - kind=$1 - shift - [[ $kind = (stopped|all) ]] && args=($args -a) - - lines=(${(f)"$(_call_program commands docker ps ${args})"}) - - # Parse header line to find columns - local i=1 j=1 k header=${lines[1]} - declare -A begin end - while (( $j < ${#header} - 1 )) { - i=$(( $j + ${${header[$j,-1]}[(i)[^ ]]} - 1)) - j=$(( $i + ${${header[$i,-1]}[(i) ]} - 1)) - k=$(( $j + ${${header[$j,-1]}[(i)[^ ]]} - 2)) - begin[${header[$i,$(($j-1))]}]=$i - end[${header[$i,$(($j-1))]}]=$k - } - lines=(${lines[2,-1]}) - - # Container ID - local line - local s - for line in $lines; do - s="${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}" - s="$s:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}" - s="$s, ${${${line[$begin[IMAGE],$end[IMAGE]]}/:/\\:}%% ##}" - if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then - stopped=($stopped $s) - else - running=($running $s) - fi - done - - # Names - local name - local -a names - for line in $lines; do - names=(${(ps:,:)${${line[${begin[NAMES]},-1]}%% *}}) - for name in $names; do - s="${name}:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}" - s="$s, ${${${line[$begin[IMAGE],$end[IMAGE]]}/:/\\:}%% ##}" - if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then - stopped=($stopped $s) - else - running=($running $s) - fi - done - done - - [[ $kind = (running|all) ]] && _describe -t containers-running "running containers" running - [[ $kind = (stopped|all) ]] && _describe -t containers-stopped "stopped containers" stopped -} - -__docker_stoppedcontainers() { - __docker_get_containers stopped "$@" -} - -__docker_runningcontainers() { - __docker_get_containers running "$@" -} - -__docker_containers () { - __docker_get_containers all "$@" -} - -__docker_images () { - local expl - declare -a images - images=(${${${${(f)"$(_call_program commands docker images)"}[2,-1]}/ ##/\\:}%% *}) - images=(${${images%\\:}#} ${${${(f)"$(_call_program commands docker images)"}[2,-1]}/(#b)([^ ]##) ##([^ ]##) ##([^ ]##)*/${match[3]}:${(r:15:: :::)match[2]} in ${match[1]}}) - _describe -t docker-images "images" images -} - -__docker_tags() { - local expl - declare -a tags - tags=(${${${${${(f)"$(_call_program commands docker images)"}#* }## #}%% *}[2,-1]}) - _describe -t docker-tags "tags" tags -} - -__docker_repositories_with_tags() { - if compset -P '*:'; then - __docker_tags - else - __docker_repositories -qS ":" - fi -} - -__docker_search() { - # declare -a dockersearch - local cache_policy - zstyle -s ":completion:${curcontext}:" cache-policy cache_policy - if [[ -z "$cache_policy" ]]; then - zstyle ":completion:${curcontext}:" cache-policy __docker_caching_policy - fi - - local searchterm cachename - searchterm="${words[$CURRENT]%/}" - cachename=_docker-search-$searchterm - - local expl - local -a result - if ( [[ ${(P)+cachename} -eq 0 ]] || _cache_invalid ${cachename#_} ) \ - && ! _retrieve_cache ${cachename#_}; then - _message "Searching for ${searchterm}..." - result=(${${${(f)"$(_call_program commands docker search ${searchterm})"}%% *}[2,-1]}) - _store_cache ${cachename#_} result - fi - _wanted dockersearch expl 'available images' compadd -a result -} - -__docker_caching_policy() -{ - oldp=( "$1"(Nmh+1) ) # 1 hour - (( $#oldp )) -} - - -__docker_repositories () { - local expl - declare -a repos - repos=(${${${(f)"$(_call_program commands docker images)"}%% *}[2,-1]}) - _describe -t docker-repos "repositories" repos "$@" -} - -__docker_commands () { - # local -a _docker_subcommands - local cache_policy - - zstyle -s ":completion:${curcontext}:" cache-policy cache_policy - if [[ -z "$cache_policy" ]]; then - zstyle ":completion:${curcontext}:" cache-policy __docker_caching_policy - fi - - if ( [[ ${+_docker_subcommands} -eq 0 ]] || _cache_invalid docker_subcommands) \ - && ! _retrieve_cache docker_subcommands; - then - local -a lines - lines=(${(f)"$(_call_program commands docker 2>&1)"}) - _docker_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:}) - _docker_subcommands=($_docker_subcommands 'help:Show help for a command') - _store_cache docker_subcommands _docker_subcommands - fi - _describe -t docker-commands "docker command" _docker_subcommands -} - -__docker_subcommand () { - local -a _command_args - case "$words[1]" in - (attach) - _arguments \ - '--no-stdin[Do not attach stdin]' \ - '--sig-proxy[Proxy all received signals to the process (non-TTY mode only)]' \ - ':containers:__docker_runningcontainers' - ;; - (build) - _arguments \ - '--force-rm[Always remove intermediate containers]' \ - '--no-cache[Do not use cache when building the image]' \ - {-q,--quiet}'[Suppress verbose build output]' \ - '--rm[Remove intermediate containers after a successful build]' \ - {-t,--tag=-}'[Repository, name and tag to be applied]:repository:__docker_repositories_with_tags' \ - ':path or URL:_directories' - ;; - (commit) - _arguments \ - {-a,--author=-}'[Author]:author: ' \ - {-m,--message=-}'[Commit message]:message: ' \ - {-p,--pause}'[Pause container during commit]' \ - '--run=-[Configuration automatically applied when the image is run]:configuration: ' \ - ':container:__docker_containers' \ - ':repository:__docker_repositories_with_tags' - ;; - (cp) - _arguments \ - ':container:->container' \ - ':hostpath:_files' - case $state in - (container) - if compset -P '*:'; then - _files - else - __docker_containers -qS ":" - fi - ;; - esac - ;; - (diff|export) - _arguments '*:containers:__docker_containers' - ;; - (events) - _arguments \ - '--since=-[Events created since this timestamp]:timestamp: ' \ - '--until=-[Events created until this timestamp]:timestamp: ' - ;; - (exec) - _arguments \ - {-d,--detach}'[Detached mode: leave the container running in the background]' \ - {-i,--interactive}'[Keep stdin open even if not attached]' \ - {-t,--tty}'[Allocate a pseudo-tty]' \ - ':containers:__docker_runningcontainers' - ;; - (history) - _arguments \ - '--no-trunc[Do not truncate output]' \ - {-q,--quiet}'[Only show numeric IDs]' \ - '*:images:__docker_images' - ;; - (images) - _arguments \ - {-a,--all}'[Show all images]' \ - '*'{-f,--filter=-}'[Filter values]:filter: ' \ - '--no-trunc[Do not truncate output]' \ - {-q,--quiet}'[Only show numeric IDs]' \ - '--tree[Output graph in tree format]' \ - '--viz[Output graph in graphviz format]' \ - ':repository:__docker_repositories' - ;; - (inspect) - _arguments \ - {-f,--format=-}'[Format the output using the given go template]:template: ' \ - '*:containers:__docker_containers' - ;; - (import) - _arguments \ - ':URL:(- http:// file://)' \ - ':repository:__docker_repositories_with_tags' - ;; - (info) - ;; - (import) - _arguments \ - ':URL:(- http:// file://)' \ - ':repository:__docker_repositories_with_tags' - ;; - (insert) - _arguments '1:containers:__docker_containers' \ - '2:URL:(http:// file://)' \ - '3:file:_files' - ;; - (kill) - _arguments \ - {-s,--signal=-}'[Signal to send]:signal:_signals' \ - '*:containers:__docker_runningcontainers' - ;; - (load) - _arguments \ - {-i,--input=-}'[Read from tar archive file]:tar:_files' - ;; - (login) - _arguments \ - {-e,--email=-}'[Email]:email: ' \ - {-p,--password=-}'[Password]:password: ' \ - {-u,--user=-}'[Username]:username: ' \ - ':server: ' - ;; - (logout) - _arguments \ - ':server: ' - ;; - (logs) - _arguments \ - {-f,--follow}'[Follow log output]' \ - {-t,--timestamps}'[Show timestamps]' \ - '*:containers:__docker_containers' - ;; - (port) - _arguments \ - '1:containers:__docker_runningcontainers' \ - '2:port:_ports' - ;; - (pause|unpause) - _arguments \ - '1:containers:__docker_runningcontainers' - ;; - (start) - _arguments \ - {-a,--attach}'[Attach container'"'"'s stdout/stderr and forward all signals]' \ - {-i,--interactive}'[Attach container'"'"'s stding]' \ - '*:containers:__docker_stoppedcontainers' - ;; - (rm) - _arguments \ - {-f,--force}'[Force removal]' \ - {-l,--link}'[Remove the specified link and not the underlying container]' \ - {-v,--volumes}'[Remove the volumes associated to the container]' \ - '*:containers:__docker_stoppedcontainers' - ;; - (rmi) - _arguments \ - {-f,--force}'[Force removal]' \ - '--no-prune[Do not delete untagged parents]' \ - '*:images:__docker_images' - ;; - (restart|stop) - _arguments \ - {-t,--time=-}'[Number of seconds to try to stop for before killing the container]:seconds to before killing:(1 5 10 30 60)' \ - '*:containers:__docker_runningcontainers' - ;; - (top) - _arguments \ - '1:containers:__docker_runningcontainers' \ - '(-)*:: :->ps-arguments' - case $state in - (ps-arguments) - _ps - ;; - esac - - ;; - (ps) - _arguments \ - {-a,--all}'[Show all containers]' \ - '--before=-[Show only container created before...]:containers:__docker_containers' \ - '*'{-f,--filter=-}'[Filter values]:filter: ' \ - {-l,--latest}'[Show only the latest created container]' \ - '-n[Show n last created containers, include non-running one]:n:(1 5 10 25 50)' \ - '--no-trunc[Do not truncate output]' \ - {-q,--quiet}'[Only show numeric IDs]' \ - {-s,--size}'[Display total file sizes]' \ - '--since=-[Show only containers created since...]:containers:__docker_containers' - ;; - (tag) - _arguments \ - {-f,--force}'[force]'\ - ':image:__docker_images'\ - ':repository:__docker_repositories_with_tags' - ;; - (create|run) - _arguments \ - {-a,--attach}'[Attach to stdin, stdout or stderr]' \ - '*--add-host=-[Add a custom host-to-IP mapping]:host\:ip mapping: ' \ - {-c,--cpu-shares=-}'[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)' \ - '*--cap-add=-[Add Linux capabilities]:capability: ' \ - '*--cap-drop=-[Drop Linux capabilities]:capability: ' \ - '--cidfile=-[Write the container ID to the file]:CID file:_files' \ - '--cpuset=-[CPUs in which to allow execution]:CPU set: ' \ - {-d,--detach}'[Detached mode: leave the container running in the background]' \ - '*--device=-[Add a host device to the container]:device:_files' \ - '*--dns=-[Set custom dns servers]:dns server: ' \ - '*--dns-search=-[Set custom DNS search domains]:dns domains: ' \ - '*'{-e,--environment=-}'[Set environment variables]:environment variable: ' \ - '--entrypoint=-[Overwrite the default entrypoint of the image]:entry point: ' \ - '*--env-file=-[Read environment variables from a file]:environment file:_files' \ - '*--expose=-[Expose a port from the container without publishing it]: ' \ - {-h,--hostname=-}'[Container host name]:hostname:_hosts' \ - {-i,--interactive}'[Keep stdin open even if not attached]' \ - '*--link=-[Add link to another container]:link:->link' \ - '*--lxc-conf=-[Add custom lxc options]:lxc options: ' \ - '-m[Memory limit (in bytes)]:limit: ' \ - '--name=-[Container name]:name: ' \ - '--net=-[Network mode]:network mode:(bridge none container: host)' \ - {-P,--publish-all}'[Publish all exposed ports]' \ - '*'{-p,--publish=-}'[Expose a container'"'"'s port to the host]:port:_ports' \ - '--privileged[Give extended privileges to this container]' \ - '--restart=-[Restart policy]:restart policy:(no on-failure always)' \ - '--rm[Remove intermediate containers when it exits]' \ - '*--security-opt=-[Security options]:security option: ' \ - '--sig-proxy[Proxy all received signals to the process (non-TTY mode only)]' \ - {-t,--tty}'[Allocate a pseudo-tty]' \ - {-u,--user=-}'[Username or UID]:user:_users' \ - '*-v[Bind mount a volume]:volume: '\ - '*--volumes-from=-[Mount volumes from the specified container]:volume: ' \ - {-w,--workdir=-}'[Working directory inside the container]:directory:_directories' \ - '(-):images:__docker_images' \ - '(-):command: _command_names -e' \ - '*::arguments: _normal' - - case $state in - (link) - if compset -P '*:'; then - _wanted alias expl 'Alias' compadd -E "" - else - __docker_runningcontainers -qS ":" - fi - ;; - esac - - ;; - (pull|search) - _arguments ':name:__docker_search' - ;; - (push) - _arguments ':images:__docker_images' - ;; - (save) - _arguments \ - {-o,--output=-}'[Write to file]:file:_files' \ - ':images:__docker_images' - ;; - (wait) - _arguments ':containers:__docker_runningcontainers' - ;; - (help) - _arguments ':subcommand:__docker_commands' - ;; - (*) - _message 'Unknown sub command' - esac - -} - -_docker () { - # Support for subservices, which allows for `compdef _docker docker-shell=_docker_containers`. - # Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`. - if [[ $service != docker ]]; then - _call_function - _$service - return - fi - - local curcontext="$curcontext" state line - typeset -A opt_args - - _arguments -C \ - '-H[tcp://host:port to bind/connect to]:socket: ' \ - '(-): :->command' \ - '(-)*:: :->option-or-argument' - - if (( CURRENT == 1 )); then - - fi - case $state in - (command) - __docker_commands - ;; - (option-or-argument) - curcontext=${curcontext%:*:*}:docker-$words[1]: - __docker_subcommand - ;; - esac -} - -_docker "$@" - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 4 -# indent-tabs-mode: nil -# sh-basic-offset: 4 -# End: -# vim: ft=zsh sw=4 ts=4 et diff --git a/.zprezto/modules/completion/external/src/_docker-compose b/.zprezto/modules/completion/external/src/_docker-compose deleted file mode 100644 index b333f4d..0000000 --- a/.zprezto/modules/completion/external/src/_docker-compose +++ /dev/null @@ -1,197 +0,0 @@ -#compdef docker-compose -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for Docker Compose (http://docs.docker.com/compose/). -# Adapted from boot2docker completion by hhatto (https://github.com/hhatto) -# and docker completion by @aeonazaan and @bobmaerten. -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * ilkka (https://github.com/ilkka) -# -# ------------------------------------------------------------------------------ - -# helper function for getting *.yml (compose) files -__yml_files_in_current_dir() { - _values 'YAML files' *.yml -} - -# helper function for completing services in current project -__services() { - declare -a services_cmd - services_cmd=($(sed -n -E 's/^([^[:space:]][^:]*):/\1/p' docker-compose.yml | tr \\n ' ')) - _describe 'services' services_cmd -} - -# subcommands -local -a _docker_compose_cmds - -_docker_compose_cmds=( - 'build:Build or rebuild services' \ - 'help:Get help on a command' \ - 'kill:Kill containers' \ - 'logs:View output from containers' \ - 'port:Print the public port for a port binding' \ - 'ps:List containers' \ - 'pull:Pulls service images' \ - 'rm:Remove stopped containers' \ - 'run:Run a one-off command' \ - 'scale:Set number of containers for a service' \ - 'start:Start services' \ - 'stop:Stop services' \ - 'restart:Restart services' \ - 'up:Create and start containers' -) - -# subcommand completion functions -__build() { - _arguments \ - '--no-cache[Do not use cache when building image]' - __services -} - -__help() { - _values 'Get help for subcommand' \ - 'build' \ - 'help' \ - 'kill' \ - 'logs' \ - 'port' \ - 'ps' \ - 'pull' \ - 'rm' \ - 'run' \ - 'scale' \ - 'start' \ - 'stop' \ - 'restart' \ - 'up' -} - -__kill() { - _arguments \ - '-s[Signal to send instead of SIGKILL]' - __services -} - -__logs() { - _arguments \ - '--no-color[Monochrome output]' - __services -} - -__port() { - _arguments \ - '--protocol:protocol:(tcp udp)' \ - '--index[Index of container]:index' - __services -} - -__ps() { - _arguments \ - '-q[Only display IDs]' - __services -} - -__pull() { - _arguments \ - '--allow-insecure-ssl[Allow insecure connections to the docker registry]' - __services -} - -__rm() { - _arguments \ - "--force[Don't ask for confirmation]" \ - '-v[Remove volumes]' - __services -} - -__run() { - _arguments \ - '--allow-insecure-ssl[Allow insecure connections to the docker registry]' \ - '-d[Detached mode: Run container in the background, print new container name.]' \ - '--entrypoint[Override the entrypoint of the image.]:command:()' \ - '-e[Set an environment variable.]:key=val:()' \ - "--no-deps[Don't start linked services.]" \ - '--rm[Remove container after run. Ignored in detached mode.]' \ - "--service-ports[Run command with the service's ports enabled and mapped to the host.]" \ - '-T[Disable pseudo-tty allocation.]' - __services -} - -__scale() { - __services -} - -__start() { - __services -} - -__stop() { - __services -} - -__restart() { - __services -} - -__up() { - _arguments \ - '--allow-insecure-ssl[Allow insecure connections to the docker registry]' \ - '-d[Detached mode: Run containers in the background, print new container names.]' \ - '--no-color[Produce monochrome output.]' \ - "--no-deps[Don't start linked services.]" \ - "--no-recreate[If containers already exist, don't recreate them.]" \ - "--no-build[Don't build an image, even if it's missing]" - __services -} - -# common args -_arguments \ - '--verbose[Show more output]' \ - '--version[Print version and exit]' \ - '--file[Specify an alternate compose file]:__yml_files_in_current_dir' \ - '--project-name[Specify an alternate project name]:args' \ - '*:: :->command' - -# start machines! -if (( CURRENT == 1 )); then - _describe -t commands 'docker-compose command' _docker_compose_cmds -fi - -local -a _command_args -case "$words[1]" in - build) - __build ;; - help) - __help ;; - kill) - __kill ;; - logs) - __logs ;; - port) - __port ;; - ps) - __ps ;; - pull) - __pull ;; - rm) - __rm ;; - run) - __run ;; - scale) - __scale ;; - start) - __start ;; - stop) - __stop ;; - restart) - __restart ;; - up) - __up ;; -esac - diff --git a/.zprezto/modules/completion/external/src/_docker-machine b/.zprezto/modules/completion/external/src/_docker-machine deleted file mode 100644 index cf1cfbe..0000000 --- a/.zprezto/modules/completion/external/src/_docker-machine +++ /dev/null @@ -1,294 +0,0 @@ -#compdef docker-machine -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for Docker Machine (http://docs.docker.com/machine/). -# Adapted from boot2docker completion by hhatto (https://github.com/hhatto) -# and docker completion by @aeonazaan and @bobmaerten. -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * ilkka (https://github.com/ilkka) -# -# ------------------------------------------------------------------------------ - -# helper function for completing available machines -__machines() { - declare -a machines_cmd - machines_cmd=($(docker-machine ls|tail +2|awk '{print $1":"$3"("$4")"}')) - _describe 'machines' machines_cmd -} - -# subcommands -local -a _docker_machine_cmds - -_docker_machine_cmds=( - 'active:Get or set the active machine' \ - 'create:Create a machine' \ - 'config:Print the connection config for machine' \ - 'inspect:Inspect information about a machine' \ - 'ip:Get the IP address of a machine' \ - 'kill:Kill a machine' \ - 'ls:List machines' \ - 'restart:Restart a machine' \ - 'rm:Remove a machine' \ - 'env:Display the commands to set up the environment for the Docker client' \ - 'ssh:Log into or run a command on a machine with SSH' \ - 'start:Start a machine' \ - 'stop:Stop a machine' \ - 'upgrade:Upgrade a machine to the latest version of Docker' \ - 'url:Get the URL of a machine' \ - 'help:Shows a list of commands or help for one command' -) - -# subcommand completion functions -__active() { - __machines -} - -__help() { - _values 'Get help for subcommand' \ - 'active' \ - 'create' \ - 'config' \ - 'inspect' \ - 'ip' \ - 'kill' \ - 'ls' \ - 'restart' \ - 'rm' \ - 'env' \ - 'ssh' \ - 'start' \ - 'stop' \ - 'upgrade' \ - 'url' \ - 'help' -} - -__create() { - _arguments \ - '--amazonec2-access-key:AWS Access Key:()' \ - '--amazonec2-ami:AWS machine image:()' \ - '--amazonec2-instance-type:AWS instance type:()' \ - '--amazonec2-region:AWS region:()' \ - '--amazonec2-root-size:AWS root disk size (in GB):()' \ - '--amazonec2-secret-key:AWS Secret Key:()' \ - '--amazonec2-security-group:AWS VPC security group:()' \ - '--amazonec2-session-token:AWS Session Token:()' \ - '--amazonec2-subnet-id:AWS VPC subnet id:()' \ - '--amazonec2-vpc-id:AWS VPC id:()' \ - '--amazonec2-zone:AWS zone for instance (i.e. a,b,c,d,e):()' \ - '--azure-docker-port:Azure Docker port:()' \ - '--azure-image:Azure image name. Default is Ubuntu 14.04 LTS x64:()' \ - '--azure-location:Azure location:()' \ - '--azure-password:Azure user password:()' \ - '--azure-publish-settings-file:Azure publish settings file:()' \ - '--azure-size:Azure size:()' \ - '--azure-ssh-port:Azure SSH port:()' \ - '--azure-subscription-cert:Azure subscription cert:()' \ - '--azure-subscription-id:Azure subscription ID:()' \ - '--azure-username:Azure username:()' \ - '--digitalocean-access-token:Digital Ocean access token:()' \ - '--digitalocean-image:Digital Ocean Image:()' \ - '--digitalocean-region:Digital Ocean region:()' \ - '--digitalocean-size:Digital Ocean size:()' \ - '--google-disk-size:GCE Instance Disk Size (in GB):()' \ - '--google-machine-type:GCE Machine Type:()' \ - '--google-project:GCE Project:()' \ - '--google-scopes:GCE Scopes (comma-separated if multiple scopes):()' \ - '--google-username:GCE User Name:()' \ - '--google-zone:GCE Zone:()' \ - '--openstack-auth-url:OpenStack authentication URL:()' \ - '--openstack-endpoint-type:OpenStack endpoint type (adminURL, internalURL or publicURL):()' \ - '--openstack-flavor-id:OpenStack flavor id to use for the instance:()' \ - '--openstack-flavor-name:OpenStack flavor name to use for the instance:()' \ - '--openstack-floatingip-pool:OpenStack floating IP pool to get an IP from to assign to the instance:()' \ - '--openstack-image-id:OpenStack image id to use for the instance:()' \ - '--openstack-image-name:OpenStack image name to use for the instance:()' \ - '--openstack-net-id:OpenStack image name to use for the instance:()' \ - '--openstack-net-name:OpenStack network name the machine will be connected on:()' \ - '--openstack-password:OpenStack password:()' \ - '--openstack-region:OpenStack region name:()' \ - '--openstack-sec-groups:OpenStack comma separated security groups for the machine:()' \ - '--openstack-ssh-port:OpenStack SSH port:()' \ - '--openstack-ssh-user:OpenStack SSH user:()' \ - '--openstack-tenant-id:OpenStack tenant id:()' \ - '--openstack-tenant-name:OpenStack tenant name:()' \ - '--openstack-username:OpenStack username:()' \ - '--rackspace-api-key:Rackspace API key:()' \ - '--rackspace-docker-install:Set if docker have to be installed on the machine:()' \ - '--rackspace-endpoint-type:Rackspace endpoint type (adminURL, internalURL or the default publicURL):()' \ - '--rackspace-flavor-id:Rackspace flavor ID. Default: General Purpose 1GB:()' \ - '--rackspace-image-id:Rackspace image ID. Default: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM):()' \ - '--rackspace-region:Rackspace region name:()' \ - '--rackspace-ssh-port:SSH port for the newly booted machine. Set to 22 by default:()' \ - '--rackspace-ssh-user:SSH user for the newly booted machine. Set to root by default:()' \ - '--rackspace-username:Rackspace account username:()' \ - '--softlayer-api-endpoint:softlayer api endpoint to use:()' \ - '--softlayer-api-key:softlayer user API key:()' \ - "--softlayer-cpu:number of CPUs for the machine:()" \ - '--softlayer-disk-size:Disk size for machine, a value of 0 uses the default size on softlayer:()' \ - '--softlayer-domain:domain name for machine:()' \ - '--softlayer-hostname:hostname for the machine:()' \ - '--softlayer-hourly-billing:set hourly billing for machine - on by default:()' \ - '--softlayer-image:OS image for machine:()' \ - '--softlayer-local-disk:use machine local disk instead of softlayer SAN:()' \ - '--softlayer-memory:Memory in MB for machine:()' \ - '--softlayer-private-net-only:Use only private networking:()' \ - '--softlayer-region:softlayer region for machine:()' \ - '--softlayer-user:softlayer user account name:()' \ - '--url:URL of host when no driver is selected:()' \ - '--virtualbox-boot2docker-url:The URL of the boot2docker image. Defaults to the latest available version:()' \ - '--virtualbox-disk-size:Size of disk for host in MB:()' \ - '--virtualbox-memory:Size of memory for host in MB:()' \ - '--vmwarefusion-boot2docker-url:Fusion URL for boot2docker image:()' \ - '--vmwarefusion-disk-size:Fusion size of disk for host VM (in MB):()' \ - '--vmwarefusion-memory-size:Fusion size of memory for host VM (in MB):()' \ - '--vmwarevcloudair-catalog:vCloud Air Catalog (default is Public Catalog):()' \ - '--vmwarevcloudair-catalogitem:vCloud Air Catalog Item (default is Ubuntu Precise):()' \ - '--vmwarevcloudair-computeid:vCloud Air Compute ID (if using Dedicated Cloud):()' \ - '--vmwarevcloudair-cpu-count:vCloud Air VM Cpu Count (default 1):()' \ - '--vmwarevcloudair-docker-port:vCloud Air Docker port:()' \ - '--vmwarevcloudair-edgegateway:vCloud Air Org Edge Gateway (Default is ):()' \ - '--vmwarevcloudair-memory-size:vCloud Air VM Memory Size in MB (default 2048):()' \ - '--vmwarevcloudair-orgvdcnetwork:vCloud Air Org VDC Network (Default is -default-routed):()' \ - '--vmwarevcloudair-password:vCloud Air password:()' \ - '--vmwarevcloudair-provision:vCloud Air Install Docker binaries (default is true):()' \ - '--vmwarevcloudair-publicip:vCloud Air Org Public IP to use:()' \ - '--vmwarevcloudair-ssh-port:vCloud Air SSH port:()' \ - '--vmwarevcloudair-username:vCloud Air username:()' \ - '--vmwarevcloudair-vdcid:vCloud Air VDC ID:()' \ - '--vmwarevsphere-boot2docker-url:vSphere URL for boot2docker image:()' \ - '--vmwarevsphere-compute-ip:vSphere compute host IP where the docker VM will be instantiated:()' \ - '--vmwarevsphere-cpu-count:vSphere CPU number for docker VM:()' \ - '--vmwarevsphere-datacenter:vSphere datacenter for docker VM:()' \ - '--vmwarevsphere-datastore:vSphere datastore for docker VM:()' \ - '--vmwarevsphere-disk-size:vSphere size of disk for docker VM (in MB):()' \ - '--vmwarevsphere-memory-size:vSphere size of memory for docker VM (in MB):()' \ - '--vmwarevsphere-network:vSphere network where the docker VM will be attached:()' \ - '--vmwarevsphere-password:vSphere password:()' \ - '--vmwarevsphere-pool:vSphere resource pool for docker VM:()' \ - '--vmwarevsphere-username:vSphere username:()' \ - '--vmwarevsphere-vcenter:vSphere IP/hostname for vCenter:()' \ - '--driver:Driver to create machine with.:(amazonec2 azure digitalocean google none openstack rackspace softlayer virtualbox vmwarefusion vmwarevcloudair vmwarevsphere)' \ - '--swarm:Configure Machine with Swarm:()' \ - '--swarm-master:Configure Machine to be a Swarm master:()' \ - '--swarm-discovery:Discovery service to use with Swarm:()' \ - '--swarm-host:ip/socket to listen on for Swarm master:()' \ - '--swarm-addr:addr to advertise for Swarm (default: detect and use the machine IP):()' -} - -__config() { - _arguments \ - '--swarm[Display the Swarm config instead of the Docker daemon]' - __machines -} - -__inspect() { - __machines -} - -__ip() { - __machines -} - -__env() { - _arguments \ - '--unset[Unset variables instead of setting them]' \ - '--swarm[Display the Swarm config instead of the Docker daemon]' - __machines -} - -__kill() { - __machines -} - -__ls() { - _arguments \ - '--quiet[Enable quiet mode]' -} - -__restart() { - __machines -} - -__start() { - __machines -} - -__stop() { - __machines -} - -__rm() { - __machines -} - -__ssh() { - __machines -} - -__upgrade() { - __machines -} - -__url() { - __machines -} - -# common args -_arguments \ - '--debug[Enable debug mode]' \ - '--storage-path[Configures storage path]:_files' \ - '--tls-ca-cert[CA to verify remotes against]:_files' \ - '--tls-ca-key[Private key to generate certificates]:_files' \ - '--tls-client-cert[Client cert to use for TLS]:_files' \ - '--tls-client-key[Private key used in client TLS auth]:_files' \ - '--help[show help]' \ - '--version[print the version]' \ - '*:: :->command' - -# start machines! -if (( CURRENT == 1 )); then - _describe -t commands 'docker-machine command' _docker_machine_cmds -fi - -local -a _command_args -case "$words[1]" in - active) - __active ;; - create) - __create ;; - config) - __config ;; - inspect) - __inspect ;; - ip) - __ip ;; - kill) - __kill ;; - ls) - __ls ;; - restart) - __restart ;; - rm) - __rm ;; - env) - __env ;; - ssh) - __ssh ;; - start) - __start ;; - stop) - __stop ;; - upgrade) - __upgrade ;; - url) - __url ;; - help) - __help ;; -esac diff --git a/.zprezto/modules/completion/external/src/_docpad b/.zprezto/modules/completion/external/src/_docpad index 874db44..21ff533 100644 --- a/.zprezto/modules/completion/external/src/_docpad +++ b/.zprezto/modules/completion/external/src/_docpad @@ -1,5 +1,30 @@ #compdef docpad # ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ # Description # ----------- # @@ -30,13 +55,13 @@ _1st_arguments=( ) _arguments -C \ - '(-h,--help)'{-h,--help}'[output usage information]'\ - '(-V,--version)'{-V,--version}'[output the version number]'\ - '(-o,--out)'{-o,--out}'[where to output the rendered directory or files]:path:_files'\ - '(-c,--config)'{-c,--config}'[a custom configuration file to load in]:path:_files'\ - '(-e,--env)'{-e,--env}'[the environment name to use for this instance, multiple names can be separated with a comma]'\ - '(-d,--debug)'{-d,--debug}'+[the level of debug messages you would like to display, if specified defaults to 7, otherwise 6]:number'\ - '(-f,--force)'{-f,--force}'[force a re-install of all modules]'\ + '(-h --help)'{-h,--help}'[output usage information]'\ + '(-V --version)'{-V,--version}'[output the version number]'\ + '(-o --out)'{-o,--out}'[where to output the rendered directory or files]:path:_files'\ + '(-c --config)'{-c,--config}'[a custom configuration file to load in]:path:_files'\ + '(-e --env)'{-e,--env}'[the environment name to use for this instance, multiple names can be separated with a comma]'\ + '(-d --debug)'{-d,--debug}'+[the level of debug messages you would like to display, if specified defaults to 7, otherwise 6]:number'\ + '(-f --force)'{-f,--force}'[force a re-install of all modules]'\ '1: :->cmds'\ '*: :_files'&& ret=0 diff --git a/.zprezto/modules/completion/external/src/_drush b/.zprezto/modules/completion/external/src/_drush index 6a05c6f..8f281db 100644 --- a/.zprezto/modules/completion/external/src/_drush +++ b/.zprezto/modules/completion/external/src/_drush @@ -1,5 +1,30 @@ #compdef drush # ------------------------------------------------------------------------------ +# Copyright (c) 2014 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_dzen2 b/.zprezto/modules/completion/external/src/_dzen2 deleted file mode 100644 index b0e49d2..0000000 --- a/.zprezto/modules/completion/external/src/_dzen2 +++ /dev/null @@ -1,44 +0,0 @@ -#compdef dzen2 - -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for dzen2 0.8.5 ( https://github.com/robm/dzen ) -# Last updated: 31.03.2013 -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Valodim ( https://github.com/Valodim ) -# -# ------------------------------------------------------------------------------ -# Notes -# ----- -# -# the _x_color completer has rather outdated paths, a zstyle like this helps -# get the x colors right (the list is rather long, then) -# -# zstyle ":completion:*:colors" path '/etc/X11/rgb.txt' -# -# ------------------------------------------------------------------------------ - -_arguments \ - '-fg[Set foreground color]:foreground color:_x_color' \ - '-bg[Set background color]:background color:_x_color' \ - '-fn[Set font]:font:_x_font' \ - '-ta[Set alignment of title window content]:alignment:( l c r )' \ - '-tw[Set title window width]:width (pixels)' \ - '-sa[Set alignment of slave window]:alignment:( l c r )' \ - '-l[Number of lines to display in slave window]:lines' \ - '-e[Set up events and actions]:event string' \ - '-m[Start up in menu mode]' \ - '-u[Update contents of title and slave window simultaneously]' \ - '-p[Persist EOF]:timeout (seconds)' \ - '-x[Set x position on the screen]:x position (pixels)' \ - '-y[Set y position on the screen]:y position (pixels)' \ - '-h[Set line height]:line height (pixels)' \ - '-w[Set window width]:width (pixels)' \ - '-xs[Set the Xinerama screen number where dzen should appear]:screen number' \ - '-v[Display version information]' && return 0 diff --git a/.zprezto/modules/completion/external/src/_emulator b/.zprezto/modules/completion/external/src/_emulator index ae86717..0ca397a 100644 --- a/.zprezto/modules/completion/external/src/_emulator +++ b/.zprezto/modules/completion/external/src/_emulator @@ -1,30 +1,5 @@ #compdef emulator # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_envdir b/.zprezto/modules/completion/external/src/_envdir new file mode 100644 index 0000000..6437993 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_envdir @@ -0,0 +1,49 @@ +#compdef envdir +# ------------------------------------------------------------------------------ +# Copyright (c) 2016, Github zsh-users (https://github.com/zsh-users) +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for envdir (https://github.com/jezdez/envdir). +# It completes its few options and then a directory and command. +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Daniel Hahler +# +# ------------------------------------------------------------------------------ + +args=( + '(-h --help)'{-h+,--help}'[show this help message and exit]' + '(-)'--version'[display version information and exit]' + '(-)1:directory: _path_files -/' + '(-)2:command: _command_names -e' + '*::arguments: _precommand' +) +_arguments -S $args diff --git a/.zprezto/modules/completion/external/src/_fab b/.zprezto/modules/completion/external/src/_fab index 59b08f1..21b3a28 100644 --- a/.zprezto/modules/completion/external/src/_fab +++ b/.zprezto/modules/completion/external/src/_fab @@ -1,5 +1,30 @@ #compdef fab # ------------------------------------------------------------------------------ +# Copyright (c) 2015 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ # Description # ----------- # @@ -57,6 +82,7 @@ _arguments -w -S -C \ "(-f+ --fabfile=)"{-f+,--fabfile=}"[Python module file to import]: :_files -g *.py" \ '(-c+ --config=-)'{-c+,--config=-}'[specify location of config file to use]: :_files' \ '(-s+ --shell=-)'{-s+,--shell=-}'[specify a new shell, defaults to ''/bin/bash -l -c'']: :' \ + '(--ssh-config-path=)--ssh-config-path=[ssh config path]: :_files' \ '(--hide=-)--hide=-[comma-separated list of output levels to hide]: :->levels' \ '(--show=-)--show=-[comma-separated list of output levels to show]: :->levels' \ '*::: :->subcmds' && return 0 diff --git a/.zprezto/modules/completion/external/src/_ffind b/.zprezto/modules/completion/external/src/_ffind new file mode 100644 index 0000000..c9a05a0 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_ffind @@ -0,0 +1,61 @@ +#compdef ffind +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for ffind (https://github.com/jaimebuelta/ffind). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Sergei Eremenko (https://github.com/SmartFinn) +# +# ------------------------------------------------------------------------------ + +_arguments -C \ + '(-h --help)'{-h,--help}'[show help message and exit]' \ + '--version[show version number and exit]' \ + '-p[match whole path, not only name of files]' \ + '--nocolor[do not display color]' \ + '--nosymlinks[do not follow symlinks]' \ + '--hidden[do not ignore hidden directories]' \ + '-c[force case sensitive]' \ + '--delete[delete files found]' \ + '--exec[execute the given command with the file found]:command:_command_names' \ + '--module[execute the given module with the file found]:module_name args:' \ + '--command[execute the given python program with the file found]:program:_files' \ + '--ignore-vcs[ignore version control system files and directories]' \ + '-f[experimental fuzzy search]' \ + '--return-results[for testing purposes only]' \ + '1:directory to search:_path_files -/' \ + '*:filepattern:' + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_fleetctl b/.zprezto/modules/completion/external/src/_fleetctl new file mode 100644 index 0000000..a754e3c --- /dev/null +++ b/.zprezto/modules/completion/external/src/_fleetctl @@ -0,0 +1,123 @@ +#compdef fleetctl +# ------------------------------------------------------------------------------ +# Copyright (c) 2009-2015 Robby Russell and contributors (see +# https://github.com/robbyrussell/oh-my-zsh/contributors) +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for fleetctl (https://github.com/coreos/fleet). +# +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Remi Paulmier (https://github.com/shtouff) +# +# ------------------------------------------------------------------------------ + +# fleetctl zsh completion + +local -a _1st_arguments +_1st_arguments=( + 'cat:Output the contents of a submitted unit' + 'destroy:Destroy one or more units in the cluster' + 'fd-forward:Proxy stdin and stdout to a unix domain socket' + 'help:Show a list of commands or help for one command' + 'journal:Print the journal of a unit in the cluster to stdout' + 'list-machines:Enumerate the current hosts in the cluster' + 'list-unit-files:List the units that exist in the cluster.' + 'list-units:List the current state of units in the cluster' + 'load:Schedule one or more units in the cluster, first submitting them if necessary.' + 'ssh:Open interactive shell on a machine in the cluster' + 'start:Instruct systemd to start one or more units in the cluster, first submitting and loading if necessary.' + 'status:Output the status of one or more units in the cluster' + 'stop:Instruct systemd to stop one or more units in the cluster.' + 'submit:Upload one or more units to the cluster without starting them' + 'unload:Unschedule one or more units in the cluster.' + 'version:Print the version and exit' +) + +__task_list () +{ + local expl + declare -a tasks + + tasks=(cat destroy fd-forward help journal list-machines list-unit-files \ + list-units load ssh start status stop submit unload version) + + _wanted tasks expl 'help' compadd $tasks +} + +__unit_list () +{ + _wanted application expl 'command' compadd $(command fleetctl list-units | \ + tail -n +2 | awk '{print $1}') +} + +local expl + +local curcontext="$curcontext" state line +local -A opt_args + +_arguments -C \ + ':command:->command' \ + '*::options:->options' + +case $state in + (command) + _describe -t commands "gem subcommand" _1st_arguments + return + ;; + + (options) + case $line[1] in + (help) + _arguments ':feature:__task_list' + ;; + + (destroy|journal|start|status|stop|unload|cat) + _arguments '*:feature:__unit_list' + ;; + + (load|submit) + _arguments '*:file:_files -g *.service' + ;; + + (ssh) + _arguments '*:host:_hosts' + ;; + + (*) + _arguments '*:file:_files' + ;; + esac + ;; +esac + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_force b/.zprezto/modules/completion/external/src/_force new file mode 100644 index 0000000..327d96a --- /dev/null +++ b/.zprezto/modules/completion/external/src/_force @@ -0,0 +1,221 @@ +#compdef force +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for force CLI 0.22.39 (https://github.com/heroku/force). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Peter Limbach +# +# ------------------------------------------------------------------------------ + +local -a _1st_arguments +_1st_arguments=( + 'apiversion:Display/Set current API version' + 'login:force login [-i=] [<-u=username> <-p=password>]' + 'logout:Log out from force.com' + 'logins:List force.com logins used' + 'active:Show or set the active force.com account' + 'whoami:Show information about the active account' + 'describe:Describe the object or list of available objects' + 'sobject:Manage standard & custom objects' + 'bigobject:Manage big objects' + 'field:Manage sobject fields' + 'record:Create, modify, or view records' + 'bulk:Load csv file use Bulk API' + 'fetch:Export specified artifact(s) to a local directory' + 'import:Import metadata from a local directory' + 'export:Export metadata to a local directory' + 'query:Execute a SOQL statement' + 'apex:Execute anonymous Apex code' + 'trace:Manage trace flags' + 'log:Fetch debug logs' + 'eventlogfile:List and fetch event log file' + 'oauth:Manage ConnectedApp credentials' + 'test:Run apex tests' + 'security:Displays the OLS and FLS for a give SObject' + 'version:Display current version' + 'update:Update to the latest version' + 'push:Deploy artifact from a local directory' + 'aura:force aura push -f ' + 'password:See password status or reset password' + 'notify:Should notifications be used' + 'limits:Display current limits' + 'help:Show this help' + 'datapipe:Manage DataPipes' +) + +local -a _field_arguments + + +_apex_types=( + 'string' 'textarea' 'longtextarea' 'richtextarea' + 'boolean' 'double' 'number' 'autonumber' 'picklist' + 'lookup' 'masterdetail' 'geolocation' +) + +_field_arguments=( + 'list' 'create' 'delete' 'type' +) + +_sobject_arguments=( + 'list' 'create' 'delete' +) + +_bulk_arguments=( + 'insert:upload a .csv file to insert records' + 'update:upload a .csv file to update records' + 'query:run a SOQL statement to generate a .csv file on the server' + 'retrieve:retrieve a query generated .csv file from the server' + 'job:get information about a job based on job Id' + 'batch:get detailed information about a batch within a job based on job Id and batch Id' + 'batches:get a list of batches associated with a job based on job Id' +) + +__sobject_list() { + _wanted application expl 'sobjects' compadd $(force sobject list) +} + +__log_list() { + _wanted application expl 'logfiles' compadd $(force log | grep -o -e '07\w*') +} + +__login_user_list() { + # remove active user string, remove colors & print the username + _wanted application expl 'usernames' compadd $(force logins | sed 's/(active)//' | sed 's,$(printf "\033"")\\[[0-9;]*[a-zA-Z],,g' | awk '{print $1}') +} + +__login_instance_list() { + _wanted application expl 'instances' compadd $(force logins | awk '{print $3}' | sed 's/https:\/\///') +} + +__sobject_command () { + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + ':command:->command' \ + '*::options:->options' + + case $state in + (command) + _describe -t commands "sobject commands" _sobject_arguments + return + ;; + + (options) + case $line[1] in + (delete) + _arguments ':feature:__sobject_list' + ;; + esac + ;; + esac +} + +__field_command () { + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + ':command:->command' \ + '*::options:->options' + + case $state in + (command) + _describe -t commands "field commands" _field_arguments + return + ;; + + (options) + case $line[1] in + (list) + _arguments ':feature:__sobject_list' + ;; + (type) + _describe -t commands "apex types" _apex_types + return + ;; + esac + ;; + esac +} + +local expl +local -a active logins + +local curcontext="$curcontext" state line +local -A opt_args + +_arguments -C \ + ':command:->command' \ + '*::options:->options' + +case $state in + (command) + _describe -t commands "force commands" _1st_arguments + return + ;; + + (options) + case $line[1] in + (help) + _describe -t commands "command help" _1st_arguments + return + ;; + + (login) + _arguments \ + '-u[salesforce user]:userame:__login_user_list' \ + '-i[salesforce instance]:instance:__login_instance_list' \ + '-p[salesforce password]' + ;; + (bulk) + _arguments \ + '-c[bulk command]:_bulk_arguments' + ;; + + (log) + _arguments ':feature:__log_list' + ;; + + (field) + __field_command + ;; + + (sobject) + __sobject_command + ;; + + esac + ;; +esac \ No newline at end of file diff --git a/.zprezto/modules/completion/external/src/_gas b/.zprezto/modules/completion/external/src/_gas index 18da7e4..c173507 100644 --- a/.zprezto/modules/completion/external/src/_gas +++ b/.zprezto/modules/completion/external/src/_gas @@ -1,5 +1,26 @@ #compdef gas # ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# +# 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. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_geany b/.zprezto/modules/completion/external/src/_geany index b55bd5c..79278b8 100644 --- a/.zprezto/modules/completion/external/src/_geany +++ b/.zprezto/modules/completion/external/src/_geany @@ -1,30 +1,5 @@ #compdef geany # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_gem b/.zprezto/modules/completion/external/src/_gem deleted file mode 100644 index 9c816f1..0000000 --- a/.zprezto/modules/completion/external/src/_gem +++ /dev/null @@ -1,499 +0,0 @@ -#compdef gem gem1.9 macgem -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for gem (http://rubygems.org). -# -# Source: https://gist.github.com/164465 -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Alex Vollmer (https://github.com/alexvollmer) -# * Tim Pope (https://github.com/tpope) -# -# ------------------------------------------------------------------------------ - - -gem_general_flags=("(-h --help)"{-h,--help}"[Get help on this command]" - "(-V --verbose)"{-V,--verbose}"[Set the verbose level of output]" - "(-q --quiet)"{-q,--quiet}"[Silence commands]" - "--config-file[Use this config file instead of default]:file:_files" - "--backtrace[Show stack backtrace on errors]" - "--debug[Turn on Ruby debugging]" - $nul_arg -) - -__all_gems() { - _gem_names=($(${service} list | awk '{print $1}')) - compadd "$@" -k _gem_names -} - -__all_gems_all() { - _gem_names=($(gem list | awk '{print $1}') "--all") - compadd "$@" -k _gem_names -} - -__gem_help_arguments() { - _args=("commands" - "examples" - "build" - "cert" - "check" - "cleanup" - "contents" - "dependency" - "environment" - "fetch" - "generate_index" - "help" - "install" - "list" - "lock" - "mirror" - "outdated" - "owner" - "pristine" - "push" - "query" - "rdoc" - "search" - "server" - "sources" - "specification" - "stale" - "tumble" - "uninstall" - "unpack" - "update" - "which") - compadd "$@" -k _args -} - -__gem_trust_policies() { - _args=("NoSecurity" - "LowSecurity" - "MediumSecurity" - "HighSecurity") - compadd "$@" -k _args -} - -_gem_build() { - _arguments \ - *:file:_files -f \ - $gem_general_flags && ret=0 -} - -_gem_cert() { - _arguments \ - "(-a --add)"{-a,--add}"[Add a trusted certificate.]":file:_files \ - "(-l --list)"{-l,--list}"[List trusted certificates.]" \ - "(-r --remove)"{-r,--remove}"[Remove trusted certificates containing STRING.]" \ - "(-b --build)"{-b,--build}"[Build private key and self-signed certificate for EMAIL_ADDR.]" \ - "(-C --certificate)"{-C,--certificate}"[Certificate for --sign command.]":file:_files \ - "(-K --private-key)"{-K,--private-key}"[Private key for --sign command.]":file:_files \ - "(-s --sign)"{-s,--sign}"[Sign a certificate with my key and certificate.]":file:_files \ - $gem_general_flags && ret=0 -} - -_gem_check() { - _arguments \ - "--verify[Verify gem file against its internal checksum]":file:_files \ - "(-a --alien)"{-a,--alien}"[Report 'unmanaged' or rogue files in the gem repository]" \ - "(-v --verbose)"{-v,--verbose}"[Spew more words]" \ - "(-t --test)"{-t,--test}"[Run unit tests for gem]" \ - "(-v --version)"{-v,--version}"[Specify version of gem to run tests for]" \ - $gem_general_flags && ret=0 -} - -_gem_cleanup() { - _arguments \ - "*:gemname:__all_gems" \ - "(-d --dryrun)"{-d,--dryrun}"[]" \ - $gem_general_flags && ret=0 -} - -_gem_contents() { - _arguments \ - "*:gemname:__all_gems" \ - "(-v --version)"{-v,--version}"[Specify version of gem to contents]" \ - "--all[Contents for all gems]" \ - "(-s --spec-dir)"{-s,--spec-dir}"[Search for gems under specific paths]" \ - "(-l --no-lib-only)"{-l,--no-lib-only}"[Only return files in the Gem's lib_dirs]" \ - "--no-prefix[Don't include installed path prefix]" \ - $gem_general_flags && ret=0 -} - -_gem_dependency() { - _arguments \ - ":gemname:__all_gems" \ - "(-l --local)"{-l,--local}"[Restrict operations to the LOCAL domain]" \ - "(-r --remote)"{-r,--remote}"[Restrict operations to the REMOTE domain]" \ - "(-b --both)"{-b,--both}"[Allow LOCAL and REMOTE operations]" \ - "(-B --bulk-threshold)"{-B,--bulk-threshold}"[Threshold for switching to bulk synchronization (default 1000)]" \ - "--source[Use URL as the remote source for gems]" \ - "(-p --[no-]http-proxy)"{-p,--[no-]http-proxy}"[Use HTTP proxy for remote operations]" \ - "(-u --no-update-sources)"{-u,--no-update-sources}"[Update local source cache]" \ - "(-v --version)"{-v,--version}"[Specify version of gem to dependency]" \ - "--platform[Specify the platform of gem to dependency]" \ - "(-R --no-reverse-dependencies)"{-R,--no-reverse-dependencies}"[Include reverse dependencies in the output]" \ - "(-p --pipe)"{-p,--pipe}"[Pipe Format (name --version ver)]" \ - $gem_general_flags && ret=0 -} - -_gem_environment() { - typeset -g _environment_arg= - _environment_arg='::environment:((packageversion\:"display the package version" - gemdir\:"display the path where gems are installed" - gempath\:"display path used to search for gems" - version\:"display the gem format version" - remotesources\:"display the remote gem servers"))' - _arguments \ - $_environment_arg \ - $gem_general_flags && ret=0 -} - -_gem_fetch() { - _arguments \ - "*:gemname:__all_gems" \ - "(-B --bulk-threshold)"{-B,--bulk-threshold}"[Threshold for switching to bulk synchronization (default 1000)]" \ - "(-p --[no-]http-proxy)"{-p,--[no-]http-proxy}"[Use HTTP proxy for remote operations]" \ - "--source[Use URL as the remote source for gems]" \ - "(-v --version)"{-v,--version}"[Specify version of gem to fetch]" \ - "--platform[Specify the platform of gem to fetch]" \ - $gem_general_flags && ret=0 -} - -_gem_generate_index() { - _arguments \ - "(-d --directory=DIRNAME)"{-d,--directory=-}"[repository base dir containing gems subdir]":directory:_directories \ - "--no-legacy[Generate indexes for RubyGems older than 1.2.0]" \ - "--no-modern[Generate indexes for RubyGems newer than 1.2.0]" \ - "--update[Update modern indexes with gems added since the last update]" \ - "--rss-gems-host=-[Host name where gems are served from, used for GUID and enclosure values]" \ - "--rss-host=-[Host name for more gems information, used for RSS feed link]" \ - "--rss-title=-[Set title for RSS feed]" \ - $gem_general_flags && ret=0 -} - -_gem_help() { - _arguments \ - ":argument:__gem_help_arguments" \ - $gem_general_flags && ret=0 -} - -_gem_install() { - _arguments \ - "*:gemname:__all_gems" \ - "(-i --install-dir)"{-i,--install-dir}"[Gem repository directory to get installed gems]":directory:_directories \ - "(-n --bindir)"{-n,--bindir}"[Directory where binary files are located]":directory:_directories \ - "(-d --no-rdoc)"{-d,--no-rdoc}"[Generate RDoc documentation for the gem on install]" \ - "--no-ri[Generate RI documentation for the gem on install]" \ - "(-E --no-env-shebang)"{-E,--no-env-shebang}"[Rewrite the shebang line on installed scripts to use /usr/bin/env]" \ - "(-f --no-force)"{-f,--no-force}"[Force gem to install, bypassing dependency checks]" \ - "(-t --no-test)"{-t,--no-test}"[Run unit tests prior to installation]" \ - "(-w --no-wrappers)"{-w,--no-wrappers}"[Use bin wrappers for executables Not available on dosish platforms]" \ - "(-P --trust-policy)"{-P,--trust-policy}"[Specify gem trust policy]:trust policy:__gem_trust_policies" \ - "--ignore-dependencies[Do not install any required dependent gems]" \ - "(-y --include-dependencies)"{-y,--include-dependencies}"[Unconditionally install the required dependent gems]" \ - "--no-format-executable[Make installed executable names match ruby. If ruby is ruby18, foo_exec will be foo_exec18]" \ - "--no-user-install[Install in user's home directory instead of GEM_HOME. Defaults to using home only if GEM_HOME is not writable.]" \ - "--development[Install any additional development dependencies]" \ - "--prerelease[Install prerelease versions of a gem if available. Defaults to skipping prereleases.]" \ - "(-l --local)"{-l,--local}"[Restrict operations to the LOCAL domain]" \ - "(-r --remote)"{-r,--remote}"[Restrict operations to the REMOTE domain]" \ - "(-b --both)"{-b,--both}"[Allow LOCAL and REMOTE operations]" \ - "(-B --bulk-threshold)"{-B,--bulk-threshold}"[Threshold for switching to bulk synchronization (default 1000)]" \ - "--source[Use URL as the remote source for gems]" \ - "(-p --[no-]http-proxy)"{-p,--[no-]http-proxy}"[Use HTTP proxy for remote operations]" \ - "(-u --no-update-sources)"{-u,--no-update-sources}"[Update local source cache]" \ - "--platform[Specify the platform of gem to install]" \ - "(-v --version)"{-v,--version}"[Specify version of gem to install]" \ - $gem_general_flags && ret=0 -} - -_gem_list() { - _arguments \ - ":gem name: " \ - "(-i --no-installed)"{-i,--no-installed}"[Check for installed gem]" \ - "(-v --version)"{-v,--version}"[Specify version of gem to list]" \ - "(-d --no-details)"{-d,--no-details}"[Display detailed information of gem(s)]" \ - "--no-versions[Display only gem names]" \ - "(-a --all)"{-a,--all}"[Display all gem versions]" \ - "--prerelease[Display prerelease versions]" \ - "(-l --local)"{-l,--local}"[Restrict operations to the LOCAL domain]" \ - "(-r --remote)"{-r,--remote}"[Restrict operations to the REMOTE domain]" \ - "(-b --both)"{-b,--both}"[Allow LOCAL and REMOTE operations]" \ - "(-B --bulk-threshold)"{-B,--bulk-threshold}"[Threshold for switching to bulk synchronization (default 1000)]" \ - "--source[Use URL as the remote source for gems]" \ - "(-p --[no-]http-proxy)"{-p,--[no-]http-proxy}"[Use HTTP proxy for remote operations]" \ - "(-u --no-update-sources)"{-u,--no-update-sources}"[Update local source cache]" \ - $gem_general_flags && ret=0 -} - -_gem_lock() { - _arguments \ - ":gemname:__all_gems" \ - "(-s --no-strict)"{-s,--no-strict}"[fail if unable to satisfy a dependency]" \ - $gem_general_flags && ret=0 -} - -_gem_mirror() { - _arguments \ - $gem_general_flags && ret=0 -} - -_gem_open() { - _arguments \ - "*:gemname:__all_gems" \ - "(-v --version)"{-v,--version}"[Specify version of gem to open]" -} - -_gem_outdated() { - _arguments \ - "(-l --local)"{-l,--local}"[Restrict operations to the LOCAL domain]" \ - "(-r --remote)"{-r,--remote}"[Restrict operations to the REMOTE domain]" \ - "(-b --both)"{-b,--both}"[Allow LOCAL and REMOTE operations]" \ - "(-B --bulk-threshold)"{-B,--bulk-threshold}"[Threshold for switching to bulk synchronization (default 1000)]" \ - "--source[Use URL as the remote source for gems]" \ - "(-p --[no-]http-proxy)"{-p,--[no-]http-proxy}"[Use HTTP proxy for remote operations]" \ - "(-u --no-update-sources)"{-u,--no-update-sources}"[Update local source cache]" \ - "--platform[Specify the platform of gem to outdated]" \ - $gem_general_flags && ret=0 -} - -_gem_owner() { - _arguments \ - "(-a --add)"{-a,--add}"[Add an owner]" \ - "(-r --remove)"{-r,--remove}"[Remove an owner]" \ - $gem_general_flags && ret=0 -} - -_gem_pristine() { - _arguments \ - ":gem name:__all_gems_all" \ - "--all[Restore all installed gems to pristine condition]" \ - "(-v --version)"{-v,--version}"[Specify version of gem to restore to pristine condition]" \ - $gem_general_flags && ret=0 -} - -_gem_push() { - _arguments \ - *:file:_files -f \ - "(-p --http-proxy)"{-p,--http-proxy}"[Use HTTP proxy for remote operations]" \ - $gem_general_flags && ret=0 -} - -_gem_query() { - _arguments \ - "(-i --no-installed)"{-i,--no-installed}"[Check for installed gem]" \ - "(-v --version)"{-v,--version}"[Specify version of gem to query]" \ - "(-n --name-matches)"{-n,--name-matches}"[Name of gem(s) to query on matches the provided REGEXP]" \ - "(-d --no-details)"{-d,--no-details}"[Display detailed information of gem(s)]" \ - "--no-versions[Display only gem names]" \ - "(-a --all)"{-a,--all}"[Display all gem versions]" \ - "--prerelease[Display prerelease versions]" \ - "(-l --local)"{-l,--local}"[Restrict operations to the LOCAL domain]" \ - "(-r --remote)"{-r,--remote}"[Restrict operations to the REMOTE domain]" \ - "(-b --both)"{-b,--both}"[Allow LOCAL and REMOTE operations]" \ - "(-B --bulk-threshold)"{-B,--bulk-threshold}"[Threshold for switching to bulk synchronization (default 1000)]" \ - "--source[Use URL as the remote source for gems]" \ - "(-p --[no-]http-proxy)"{-p,--[no-]http-proxy}"[Use HTTP proxy for remote operations]" \ - "(-u --no-update-sources)"{-u,--no-update-sources}"[Update local source cache]" \ - $gem_general_flags && ret=0 -} - -_gem_rdoc() { - _arguments \ - ":gem name:__all_gems_all" \ - "--all[Generate RDoc/RI documentation for all installed gems]" \ - "--no-rdoc[Include RDoc generated documents]" \ - "--no-ri[Include RI generated documents]" \ - "(-v --version)"{-v,--version}"[Specify version of gem to rdoc]" \ - $gem_general_flags && ret=0 -} - -_gem_search() { - _arguments \ - ":gem name::" \ - "(-i --no-installed)"{-i,--no-installed}"[Check for installed gem]" \ - "(-v --version)"{-v,--version}"[Specify version of gem to search]" \ - "(-d --no-details)"{-d,--no-details}"[Display detailed information of gem(s)]" \ - "--no-versions[Display only gem names]" \ - "(-a --all)"{-a,--all}"[Display all gem versions]" \ - "--prerelease[Display prerelease versions]" \ - "(-l --local)"{-l,--local}"[Restrict operations to the LOCAL domain]" \ - "(-r --remote)"{-r,--remote}"[Restrict operations to the REMOTE domain]" \ - "(-b --both)"{-b,--both}"[Allow LOCAL and REMOTE operations]" \ - "(-B --bulk-threshold)"{-B,--bulk-threshold}"[Threshold for switching to bulk synchronization (default 1000)]" \ - "--source[Use URL as the remote source for gems]" \ - "(-p --[no-]http-proxy)"{-p,--[no-]http-proxy}"[Use HTTP proxy for remote operations]" \ - "(-u --no-update-sources)"{-u,--no-update-sources}"[Update local source cache]" \ - $gem_general_flags && ret=0 -} - -_gem_server() { - _arguments \ - "(-p --port=PORT)"{-p,--port=-}"[port to listen on]" \ - "(-d --dir=GEMDIR)"{-d,--dir=-}"[directory from which to serve gems]":directory:_directories \ - "--no-daemon[run as a daemon]" \ - $gem_general_flags && ret=0 -} - -_gem_sources() { - _arguments \ - "(-a --add)"{-a,--add}"[Add source]" \ - "(-l --list)"{-l,--list}"[List sources]" \ - "(-r --remove)"{-r,--remove}"[Remove source]" \ - "(-c --clear-all)"{-c,--clear-all}"[Remove all sources (clear the cache)]" \ - "(-u --update)"{-u,--update}"[Update source cache]" \ - "(-p --[no-]http-proxy)"{-p,--[no-]http-proxy}"[Use HTTP proxy for remote operations]" \ - $gem_general_flags && ret=0 -} - -_gem_specification() { - _arguments \ - ":gemname:__all_gems" \ - "(-l --local)"{-l,--local}"[Restrict operations to the LOCAL domain]" \ - "(-r --remote)"{-r,--remote}"[Restrict operations to the REMOTE domain]" \ - "(-b --both)"{-b,--both}"[Allow LOCAL and REMOTE operations]" \ - "(-B --bulk-threshold)"{-B,--bulk-threshold}"[Threshold for switching to bulk synchronization (default 1000)]" \ - "--source[Use URL as the remote source for gems]" \ - "(-p --[no-]http-proxy)"{-p,--[no-]http-proxy}"[Use HTTP proxy for remote operations]" \ - "(-u --no-update-sources)"{-u,--no-update-sources}"[Update local source cache]" \ - "(-v --version)"{-v,--version}"[Specify version of gem to examine]" \ - "--platform[Specify the platform of gem to specification]" \ - "--all[Output specifications for all versions of the gem]" \ - "--ruby[Output ruby format]" \ - "--yaml[Output RUBY format]" \ - "--marshal[Output Marshal format]" \ - $gem_general_flags && ret=0 -} - -_gem_stale() { - _arguments \ - $gem_general_flags && ret=0 -} - -_gem_tumble() { - _arguments \ - $gem_general_flags && ret=0 -} - -_gem_uninstall() { - _arguments \ - "*:gemname:__all_gems" \ - "(-a --no-all)"{-a,--no-all}"[Uninstall all matching versions]" \ - "(-I --no-ignore-dependencies)"{-I,--no-ignore-dependencies}"[Ignore dependency requirements while uninstalling]" \ - "(-x --no-executables)"{-x,--no-executables}"[Uninstall applicable executables without confirmation]" \ - "(-i --install-dir)"{-i,--install-dir}"[Directory to uninstall gem from]":directory:_directories \ - "(-n --bindir)"{-n,--bindir}"[Directory to remove binaries from]":directory:_directories \ - "--no-user-install[Uninstall from user's home directory in addition to GEM_HOME.]" \ - "(-v --version)"{-v,--version}"[Specify version of gem to uninstall]" \ - "--platform[Specify the platform of gem to uninstall]" \ - $gem_general_flags && ret=0 -} - -_gem_unpack() { - _arguments \ - ":gemname:__all_gems" \ - "--target=-[target directory for unpacking]":directory:_directories \ - "(-v --version)"{-v,--version}"[Specify version of gem to unpack]" \ - $gem_general_flags && ret=0 -} - -_gem_update() { - _arguments \ - "*:gemname:__all_gems" \ - "(-i --install-dir)"{-i,--install-dir}"[Gem repository directory to get installed gems]":directory:_directories \ - "(-n --bindir)"{-n,--bindir}"[Directory where binary files are located]":directory:_directories \ - "(-d --no-rdoc)"{-d,--no-rdoc}"[Generate RDoc documentation for the gem on install]" \ - "--no-ri[Generate RI documentation for the gem on install]" \ - "(-E --no-env-shebang)"{-E,--no-env-shebang}"[Rewrite the shebang line on installed scripts to use /usr/bin/env]" \ - "(-f --no-force)"{-f,--no-force}"[Force gem to install, bypassing dependency checks]" \ - "(-t --no-test)"{-t,--no-test}"[Run unit tests prior to installation]" \ - "(-w --no-wrappers)"{-w,--no-wrappers}"[Use bin wrappers for executables Not available on dosish platforms]" \ - "(-P --trust-policy)"{-P,--trust-policy}"[Specify gem trust policy]:trust policy:__gem_trust_policies" \ - "--ignore-dependencies[Do not install any required dependent gems]" \ - "(-y --include-dependencies)"{-y,--include-dependencies}"[Unconditionally install the required dependent gems]" \ - "--no-format-executable[Make installed executable names match ruby. If ruby is ruby18, foo_exec will be foo_exec18]" \ - "--no-user-install[Install in user's home directory instead of GEM_HOME. Defaults to using home only if GEM_HOME is not writable.]" \ - "--development[Install any additional development dependencies]" \ - "--prerelease[Install prerelease versions of a gem if available. Defaults to skipping prereleases.]" \ - "(-l --local)"{-l,--local}"[Restrict operations to the LOCAL domain]" \ - "(-r --remote)"{-r,--remote}"[Restrict operations to the REMOTE domain]" \ - "(-b --both)"{-b,--both}"[Allow LOCAL and REMOTE operations]" \ - "(-B --bulk-threshold)"{-B,--bulk-threshold}"[Threshold for switching to bulk synchronization (default 1000)]" \ - "--source[Use URL as the remote source for gems]" \ - "(-p --[no-]http-proxy)"{-p,--[no-]http-proxy}"[Use HTTP proxy for remote operations]" \ - "(-u --no-update-sources)"{-u,--no-update-sources}"[Update local source cache]" \ - "--system[Update the RubyGems system software]" \ - "--platform[Specify the platform of gem to update]" \ - $gem_general_flags && ret=0 -} - -_gem_which() { - _arguments \ - *:file:_files -f \ - "(-a --no-all)"{-a,--no-all}"[show all matching files]" \ - "(-g --no-gems-first)"{-g,--no-gems-first}"[search gems before non-gems]" \ - $gem_general_flags && ret=0 -} - -_gem_migrate() { - _arguments \ - "*:gemname:__all_gems" \ - $gem_general_flags && ret=0 -} - -if (( CURRENT > 2 )); then - (( CURRENT-- )) - shift words - _call_function 1 _gem_${words[1]} -else - _values "gem command" \ - "build[Build a gem from a gemspec]" \ - "cert[Manage RubyGems certificates and signing settings]" \ - "check[Check installed gems]" \ - "cleanup[Clean up old versions of installed gems in the local repository]" \ - "contents[Display the contents of the installed gems]" \ - "dependency[Show the dependencies of an installed gem]" \ - "environment[Display information about the RubyGems environment]" \ - "fetch[Download a gem and place it in the current directory]" \ - "generate_index[Generates the index files for a gem server directory]" \ - "help[Provide help on the 'gem' command]" \ - "install[Install a gem into the local repository]" \ - "list[Display gems whose name starts with STRING]" \ - "lock[Generate a lockdown list of gems]" \ - "migrate[Migrate a gem you own from Rubyforge to Gemcutter]" \ - "mirror[Mirror a gem repository]" \ - "open[Open a gem in your editor]" \ - "outdated[Display all gems that need updates]" \ - "owner[Manage gem owners on Gemcutter]" \ - "pristine[Restores installed gems to pristine condition from files located in the gem cache]" \ - "push[Push a gem up to Gemcutter]" \ - "query[Query gem information in local or remote repositories]" \ - "rdoc[Generates RDoc for pre-installed gems]" \ - "search[Display all gems whose name contains STRING]" \ - "server[Documentation and gem repository HTTP server]" \ - "sources[Manage the sources and cache file RubyGems uses to search for gems]" \ - "specification[Display gem specification (in yaml)]" \ - "stale[List gems along with access times]" \ - "tumble[Enable or disable Gemcutter as your primary gem source]" \ - "uninstall[Uninstall gems from the local repository]" \ - "unpack[Unpack an installed gem to the current directory]" \ - "update[Update the named gems (or all installed gems) in the local repository]" \ - "which[Find the location of a library file you can require]" -fi - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et - - diff --git a/.zprezto/modules/completion/external/src/_gist b/.zprezto/modules/completion/external/src/_gist index 826c1b7..77544a6 100644 --- a/.zprezto/modules/completion/external/src/_gist +++ b/.zprezto/modules/completion/external/src/_gist @@ -1,6 +1,6 @@ #compdef gist # ------------------------------------------------------------------------------ -# Copyright (c) 2015 Github zsh-users - http://github.com/zsh-users +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,7 @@ # ------- # # * Akira Maeda +# * Patrick Ziegler # # ------------------------------------------------------------------------------ # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- @@ -61,6 +62,58 @@ _arguments -C \ '(-P --paste)'{-P,--paste}'[Paste from the clipboard to gist]' \ '(-h --help)'{-h,--help}'[print options help]' \ '(-v --version)'{-v,--version}'[print version]' \ + '(-r --read)'{-r,--read}'[Read a gist and print out the contents]:user gists:user_gists' \ '*: :_files' && ret=0 +_user_gists_cache_policy() { + # rebuild if cache is more than a day old + local -a oldp + oldp=( "$1"(mh+1) ) + (( $#oldp )) +} + +user_gists() { + local update_policy ret=1 + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _user_gists_cache_policy + fi + + # stores the gists of the logged in user in the format ID[Description] + _list=() + _cached_gists="user_gists" + + # retrieve/Write gists from/to cache + if _cache_invalid $_cached_gists || ! _retrieve_cache $_cached_gists; then + _gists=$(gist -l) + + if [ $? -eq 0 ]; then + _store_cache $_cached_gists _gists + else + # some error occurred, the user is probably not logged in + # set _gists to an empty string so that no completion is attempted + _gists="" + fi + else + _retrieve_cache $_cached_gists + fi + + if [ -n "$_gists" ]; then + echo "$_gists" | while read -r line; do + # Splitting the gist -l output + url="$(echo "$line" | cut -d " " -f 1 | cut -d "/" -f 4)" + # gists w/o descriptions can have only one column in the output, those + # have their description set to an empty string + description="$(echo "$line" | awk '{if(NF > 1){$1=""; print $0}}')" + + _list+=( "${url}[${description}]" ) + done + + _values "gists" $_list + ret=0 + fi + + return ret +} + return ret diff --git a/.zprezto/modules/completion/external/src/_git-flow b/.zprezto/modules/completion/external/src/_git-flow index 1f4e866..d7c7b73 100644 --- a/.zprezto/modules/completion/external/src/_git-flow +++ b/.zprezto/modules/completion/external/src/_git-flow @@ -1,5 +1,25 @@ #compdef git-flow # ------------------------------------------------------------------------------ +# Copyright (c) 2010-2015 Justin Hileman +# +# 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. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_git-journal b/.zprezto/modules/completion/external/src/_git-journal new file mode 100644 index 0000000..0f2dfbe --- /dev/null +++ b/.zprezto/modules/completion/external/src/_git-journal @@ -0,0 +1,225 @@ +#compdef git-journal +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for git-journal: +# https://github.com/saschagrunert/git-journal +# +# Authors +# ------- +# +# * Sascha Grunert +# * Nico Wagner +# ------------------------------------------------------------------------------ + +_git-journal() { + typeset -A opt_args + local ret=1 + + local context curcontext="$curcontext" state line + _arguments -s -S -C \ +"-p+[Sets a custom working path.]" \ +"--path+[Sets a custom working path.]" \ +"-n+[The number of tags until the parser stops when a single revision is given.]" \ +"--tags-count+[The number of tags until the parser stops when a single revision is given.]" \ +"-e+[A pattern to exclude git tags from the processing.]" \ +"-t+[Use a custom output template.]" \ +"--template+[Use a custom output template.]" \ +"-o+[The output file for the changelog.]" \ +"--output+[The output file for the changelog.]" \ +"-a[Do not stop parsing at the first tag when a single revision is given. Overwrites '-n/--tags-count'.]" \ +"--all[Do not stop parsing at the first tag when a single revision is given. Overwrites '-n/--tags-count'.]" \ +"-g[Generate a fresh output template from a commit range.]" \ +"--generate[Generate a fresh output template from a commit range.]" \ +"-s[Print only the shortlog (summary) form.]" \ +"--short[Print only the shortlog (summary) form.]" \ +"-u[Skip entries without any relation to a git TAG.]" \ +"--skip-unreleased[Skip entries without any relation to a git TAG.]" \ +"-h[Prints help information]" \ +"--help[Prints help information]" \ +"-V[Prints version information]" \ +"--version[Prints version information]" \ +"1:: :_git-journal_commands" \ +"*:: :->git-journal" \ +&& ret=0 + case $state in + (git-journal) + curcontext="${curcontext%:*:*}:git-journal-command-$words[1]:" + case $line[1] in + (p) +_arguments -s -S -C \ +"-h[Prints help information]" \ +"--help[Prints help information]" \ +"-V[Prints version information]" \ +"--version[Prints version information]" \ +"1:: :_git-journal_prepare_commands" \ +&& ret=0 +;; +(prepare) +_arguments -s -S -C \ +"-h[Prints help information]" \ +"--help[Prints help information]" \ +"-V[Prints version information]" \ +"--version[Prints version information]" \ +"1:: :_git-journal_prepare_commands" \ +&& ret=0 +;; +(s) +_arguments -s -S -C \ +"-h[Prints help information]" \ +"--help[Prints help information]" \ +"-V[Prints version information]" \ +"--version[Prints version information]" \ +&& ret=0 +;; +(setup) +_arguments -s -S -C \ +"-h[Prints help information]" \ +"--help[Prints help information]" \ +"-V[Prints version information]" \ +"--version[Prints version information]" \ +&& ret=0 +;; +(v) +_arguments -s -S -C \ +"-h[Prints help information]" \ +"--help[Prints help information]" \ +"-V[Prints version information]" \ +"--version[Prints version information]" \ +"1:: :_git-journal_verify_commands" \ +&& ret=0 +;; +(verify) +_arguments -s -S -C \ +"-h[Prints help information]" \ +"--help[Prints help information]" \ +"-V[Prints version information]" \ +"--version[Prints version information]" \ +"1:: :_git-journal_verify_commands" \ +&& ret=0 +;; +(help) +_arguments -s -S -C \ +"-h[Prints help information]" \ +"--help[Prints help information]" \ +"-V[Prints version information]" \ +"--version[Prints version information]" \ +&& ret=0 +;; + esac + ;; +esac +} + +(( $+functions[_git-journal_commands] )) || +_git-journal_commands() { + local commands; commands=( + "prepare:Prepare a commit message before the user can edit it." \ +"p:Prepare a commit message before the user can edit it." \ +"setup:Creates all necessary git hooks and an initial configuration file. Shell completions for bash and fish will be available inside the current working directory." \ +"s:Creates all necessary git hooks and an initial configuration file. Shell completions for bash and fish will be available inside the current working directory." \ +"verify:Verify the specified commit message." \ +"v:Verify the specified commit message." \ +"help:Prints this message or the help of the given subcommand(s)" \ +"REVISION_RANGE:Specifies the revision range to be processed. If a single revision is specified, the output will stop at the first following git TAG." \ + ) + _describe -t commands 'git-journal commands' commands "$@" +} +(( $+functions[_git-journal_help_commands] )) || +_git-journal_help_commands() { + local commands; commands=( + + ) + _describe -t commands 'git-journal help commands' commands "$@" +} +(( $+functions[_git-journal_p_commands] )) || +_git-journal_p_commands() { + local commands; commands=( + "MESSAGE:The path to the commit message which should be prepared." \ +"TYPE:The type of the commit. For example "message"." \ + ) + _describe -t commands 'git-journal p commands' commands "$@" +} +(( $+functions[_p_commands] )) || +_p_commands() { + local commands; commands=( + "MESSAGE:The path to the commit message which should be prepared." \ +"TYPE:The type of the commit. For example "message"." \ + ) + _describe -t commands 'p commands' commands "$@" +} +(( $+functions[_git-journal_prepare_commands] )) || +_git-journal_prepare_commands() { + local commands; commands=( + "MESSAGE:The path to the commit message which should be prepared." \ +"TYPE:The type of the commit. For example "message"." \ + ) + _describe -t commands 'git-journal prepare commands' commands "$@" +} +(( $+functions[_git-journal_s_commands] )) || +_git-journal_s_commands() { + local commands; commands=( + + ) + _describe -t commands 'git-journal s commands' commands "$@" +} +(( $+functions[_s_commands] )) || +_s_commands() { + local commands; commands=( + + ) + _describe -t commands 's commands' commands "$@" +} +(( $+functions[_git-journal_setup_commands] )) || +_git-journal_setup_commands() { + local commands; commands=( + + ) + _describe -t commands 'git-journal setup commands' commands "$@" +} +(( $+functions[_git-journal_v_commands] )) || +_git-journal_v_commands() { + local commands; commands=( + "MESSAGE:The path to the commit message which should be prepared." \ + ) + _describe -t commands 'git-journal v commands' commands "$@" +} +(( $+functions[_v_commands] )) || +_v_commands() { + local commands; commands=( + "MESSAGE:The path to the commit message which should be prepared." \ + ) + _describe -t commands 'v commands' commands "$@" +} +(( $+functions[_git-journal_verify_commands] )) || +_git-journal_verify_commands() { + local commands; commands=( + "MESSAGE:The path to the commit message which should be prepared." \ + ) + _describe -t commands 'git-journal verify commands' commands "$@" +} + +_git-journal "$@" \ No newline at end of file diff --git a/.zprezto/modules/completion/external/src/_git-pulls b/.zprezto/modules/completion/external/src/_git-pulls index 88fb8a8..8dfc117 100644 --- a/.zprezto/modules/completion/external/src/_git-pulls +++ b/.zprezto/modules/completion/external/src/_git-pulls @@ -1,30 +1,5 @@ #compdef git-pulls # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_github b/.zprezto/modules/completion/external/src/_github deleted file mode 100644 index 3e98356..0000000 --- a/.zprezto/modules/completion/external/src/_github +++ /dev/null @@ -1,272 +0,0 @@ -#compdef github gh -# ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for Github gem 0.6.2 (https://github.com/defunkt/github-gem). -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Julien Nicoulaud (https://github.com/nicoulaj) -# -# ------------------------------------------------------------------------------ - - -_github() { - typeset -A opt_args - local context state line curcontext="$curcontext" - - local ret=1 - - _arguments -C \ - '1:cmd:->cmds' \ - '*::arg:->args' \ - && ret=0 - - case "$state" in - (cmds) - local commands; commands=( - 'admin:open this repo'\''s Admin panel a web browser' - 'browse:open this repo in a web browser' - 'clone:clone a repo' - 'config:automatically set configuration info, or pass args to specify' - 'create:create a new, empty GitHub repository' - 'create-from-local:create a new GitHub repository from the current local repository' - 'fetch:fetch from a remote to a local branch' - 'fetch_all:fetch all refs from a user' - 'fork:forks a GitHub repository' - 'home:open this repo'\''s master branch in a web browser' - 'ignore:ignore a SHA' - 'info:info about this project' - 'issues:project issues tools' - 'network:project network tools' - 'open:open the given user/project in a web browser' - 'pull:pull from a remote' - 'pull-request:generate the text for a pull request' - 'search:search GitHub for the given repository name' - 'track:track another user'\''s repository' - ) - _describe -t commands 'command' commands && ret=0 - ;; - (args) - curcontext="${curcontext%:*:*}:github-cmd-$words[1]:" - case $words[1] in - (admin|fetch|fetch_all|home|info) - _message 'no more arguments' && ret=0 - ;; - (browse) - _arguments \ - '1: :_github_users' \ - '2: :_github_branches' \ - && ret=0 - ;; - (clone) - _arguments \ - '1: :_github_users' \ - '2: :_github_repos' \ - '3: :_files -/' \ - '--search[search for user or repo and clone selected repository]:user or repo' \ - '--ssh[clone using the git@github.com style url]' \ - && ret=0 - ;; - (config) - _arguments \ - '1: :_github_users' \ - '2: :_github_repos' \ - && ret=0 - ;; - (create) - _arguments \ - '1:repo name' \ - '--markdown[create README.markdown]' \ - '--mdown[create README.mdown]' \ - '--private[create private repository]' \ - '--rdoc[create README.rdoc]' \ - '--rst[create README.rst]' \ - '--textile[create README.textile]' \ - && ret=0 - ;; - (create-from-local) - _arguments \ - '--private[create private repository]' \ - && ret=0 - ;; - (fork) - _arguments \ - '1: :_github_user_slash_repos' \ - && ret=0 - ;; - (ignore) - _arguments \ - '1: :_github_network_commits' \ - && ret=0 - ;; - (issues) - _arguments -C \ - '1:issue-status:->issue-statuses' \ - '2:: :_github_users' \ - '--after[only show issues updated after a certain date]:date' \ - '--label[only show issues with a certain label]:label' \ - && ret=0 - case "$state" in - (issue-statuses) - local statuses; statuses=( - 'open:show open issues' - 'closed:show closed issues' - ) - _describe -t statuses 'status' statuses && ret=0 - ;; - esac - ;; - (network) - _arguments -C \ - '1:network-subcommand:->network-subcommands' \ - '*::network-arg:->network-args' \ - '(--after)--before[only show commits before a certain date]:date' \ - '(--before)--after[only show commits after a certain date]:date' \ - '--applies[filter commits to patches that apply cleanly]' \ - '--author[filter commits on a email address of author]:author' \ - '--cache[use the network data even if it'\''s expired]' \ - '--common[show common branch point]' \ - '--limit[only look through the first X heads - useful for really large projects]:number' \ - '--noapply[filter commits to patches that do not apply cleanly]' \ - '--nocache[do not use the cached network data]' \ - '--project[filter commits on a certain project]:project' \ - '--shas[only show shas]' \ - '--sort[how to sort : date, branch, author]:sort type:((date\:sort\ by\ date\ \(default\) branch\:sort\ by\ branch author\:sort\ by\ author))' \ - '--thisbranch[look at branches that match the current one]' \ - && ret=0 - case "$state" in - (network-subcommands) - local subcommands; subcommands=( - 'web:open network in a web browser' - 'list:list network members' - 'fetch:fetch network members commits' - 'commits:list network members commits' - ) - _describe -t subcommands 'subcommand' subcommands && ret=0 - ;; - (network-args) - case $words[1] in - (web) - _arguments \ - '1: :_github_users' \ - && ret=0 - ;; - esac - ;; - esac - ;; - (open) - _arguments \ - '1: :_github_user_slash_repos' \ - && ret=0 - ;; - (pull) - _arguments \ - '1: :_github_users' \ - '2: :_github_branches' \ - '--merge[automatically merge remote'\''s changes into your master]' \ - && ret=0 - ;; - (pull-request) - _arguments \ - '1: :_github_users' \ - '2: :_github_branches' \ - && ret=0 - ;; - (search) - _arguments \ - '1:query' \ - && ret=0 - ;; - (track) - _arguments \ - '1:: :((remote))' \ - '*: :_github_user_slash_repos' \ - {--private,--ssh}'[use git@github.com: instead of git://github.com/]' \ - && ret=0 - ;; - esac - ;; - esac - - return ret -} - -(( $+functions[_github_users] )) || -_github_users() { - _alternative \ - 'users:user:_users' \ - 'github-network-users:github network user:_github_network_users' -} - -(( $+functions[_github_network_users] )) || -_github_network_users() { - local users; users=(${(f)"$(_call_program users $service network list 2>/dev/null)"}) - _describe -t github-network-users 'github network user' users "$@" -} - -(( $+functions[_github_repos] )) || -_github_repos() { - _message -e repos 'repo' -} - -(( $+functions[_github_branches] )) || -_github_branches() { - _message -e branches 'branch' -} - -(( $+functions[_github_user_slash_repos] )) || -_github_user_slash_repos() { - local ret=1 - if compset -P '*/'; then - _wanted repos expl 'repo' _github_repos && ret=0 - else - _wanted users expl 'user' _github_users -qS/ && ret=0 - fi - return ret -} - -(( $+functions[_github_network_commits] )) || -_github_network_commits() { - local commits; commits=(${${(f)"$(_call_program commits $service network commits 2>/dev/null)"}%%[[:blank:]]*}) - _describe -t commits 'commit' commits "$@" -} - -_github "$@" - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_go b/.zprezto/modules/completion/external/src/_go new file mode 100644 index 0000000..0a9b6a0 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_go @@ -0,0 +1,554 @@ +#compdef go +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# Copyright (c) 2013-2015 Robby Russell and contributors (see +# https://github.com/robbyrussell/oh-my-zsh/contributors) +# Copyright (c) 2010-2014 Go authors +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for go 1.5 (http://golang.org). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Mikkel Oscar Lyderik +# * oh-my-zsh authors: +# https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/golang/golang.plugin.zsh +# * Go authors +# +# ------------------------------------------------------------------------------ + +typeset -A opt_args + +_go() { + local -a commands build_flags + commands=( + 'build:compile packages and dependencies' + 'clean:remove object files' + 'doc:show documentation for package or symbol' + 'env:print Go environment information' + 'fix:run go tool fix on packages' + 'fmt:run gofmt on package sources' + 'generate:generate Go files by processing source' + 'get:download and install packages and dependencies' + 'install:compile and install packages and dependencies' + 'list:list packages' + 'run:compile and run Go program' + 'test:test packages' + 'tool:run specified go tool' + 'version:print Go version' + 'vet:run go tool vet on packages' + 'help:get more information about a command' + ) + + _arguments \ + "1: :{_describe 'command' commands}" \ + '*:: :->args' + + case $state in + args) + build_flags=( + '-a[force rebuilding of packages that are already up-to-date]' + '-n[print the commands but do not run them]' + '-p[number of builds that can be run in parallel]:number' + '-race[enable data race detection]' + '-v[print the names of packages as they are compiled]' + '-work[print temporary work directory and keep it]' + '-x[print the commands]' + '-asmflags[arguments for each go tool asm invocation]:flags' + '-buildmode[build mode to use]:mode' + '-compiler[name of compiler to use]:name' + '-gccgoflags[arguments for gccgo]:args' + '-gcflags[arguments for each go tool compile invocation]:args' + '-installsuffix[suffix to add to package directory]:suffix' + '-ldflags[arguments to pass on each go tool link invocation.]:flags' + '-linkshared[link against shared libraries]' + '-pkgdir[install and load all packages from dir]:dir' + '-tags[list of build tags to consider satisfied]:tags' + '-toolexec[program to use to invoke toolchain programs]:args' + ) + + __go_packages() { + local gopaths + declare -a gopaths + gopaths=("${(s/:/)$(go env GOPATH)}") + gopaths+=("$(go env GOROOT)") + for p in $gopaths; do + _path_files -W "$p/src" -/ + done + } + + case $words[1] in + build) + _arguments \ + '-o[force build to write to named output file]:file:_files' \ + '-i[installs the packages that are dependencies of the target]' \ + ${build_flags[@]} \ + '*:importpaths:__go_packages' + ;; + + clean) + _arguments \ + '-i[remove corresponding installed archive or binary]' \ + '-r[apply clean recursively on all dependencies]' \ + ${build_flags[@]} \ + '*:importpaths:__go_packages' + ;; + + doc) + _arguments \ + '-c[respect case when matching symbols]' \ + '-cmd[treat a command (package main) like a regular package]' \ + '-u[show docs for unexported and exported symbols and methods]' + ;; + + fix) + _arguments '*:importpaths:__go_packages' + ;; + + fmt) + _arguments \ + '-n[prints commands that would be executed]' \ + '-x[prints commands as they are executed]' \ + '*:importpaths:__go_packages' + ;; + + generate) + _arguments \ + '-run=[specifies a regular expression to select directives]:regex' \ + '-x[print the commands]' \ + '-n[print the commands but do not run them]' \ + '-v[print the names of packages as they are compiled]' \ + "*:args:{ _alternative ':importpaths:__go_packages' _files }" + ;; + + get) + _arguments \ + '-d[instructs get to stop after downloading the packages]' \ + '-f[force get -u not to verify that each package has been checked from vcs]' \ + '-fix[run the fix tool on the downloaded packages]' \ + '-insecure[permit fetching/resolving custom domains]' \ + '-t[also download the packages required to build tests]' \ + '-u[use the network to update the named packages]' \ + ${build_flags[@]} \ + '*:importpaths:__go_packages' + ;; + + install) + _arguments ${build_flags[@]} \ + '*:importpaths:__go_packages' + ;; + + list) + _arguments \ + '-e[changes the handling of erroneous packages]' \ + '-f[specifies an alternate format for the list]:format' \ + '-json[causes package data to be printed in JSON format]' \ + ${build_flags[@]} \ + '*:importpaths:__go_packages' + ;; + + run) + _arguments \ + ${build_flags[@]} \ + '-exec[invoke the binary using xprog]:xporg' \ + '*:file:_files -g "*.go(-.)"' + ;; + + test) + _arguments \ + "-c[compile but don't run test]" \ + '-i[install dependencies of the test]' \ + '-bench[run benchmarks matching the regular expression]:regexp' \ + '-benchmem[print memory allocation statistics for benchmarks]' \ + '-benchtime[run benchmarks for t rime]:t' \ + '-blockprofile[write a goroutine blocking profile to the specified file]:block' \ + '-blockprofilerate[control goroutine blocking profiles]:n' \ + '-count[run each test and benchmark n times]:n' \ + '-cover[enable coverage analysis]' \ + '-covermode[set the mode for coverage analysis]:mode:(set count atomic)' \ + '-coverpkg[apply coverage analysis in each test of listed packages]:list' \ + '-coverprofile[write a coverage profile to file]:cover' \ + '-cpu[specify a list of GOMAXPROCS values]:cpus' \ + '-cpuprofile[write a CPU profile to the specified file]:profile' \ + '-memprofile[write a memory profile to file]:mem' \ + '-memprofilerate[enable more precise memory profiles]:n' \ + '-outputdir[place output files from profiling in output dir]:dir' \ + '-parallel[allow parallel execution of test functions]:n' \ + '-run[run tests and examples matching the regular expression]:regexp' \ + '-short[tell long-running tests to shorten their run time]' \ + '-timeout[timeout long running tests]:t' \ + '-trace[write an execution trace to the specified file]:trace' \ + '-v[verbose output]' \ + ${build_flags[@]} \ + '-exec[run test binary using xprog]:xprog' \ + '-o[compile test binary to named file]:file:_files' \ + '*:importpaths:__go_packages' + ;; + + tool) + local -a tools + tools=($(go tool)) + + _arguments \ + '-n[print command that would be executed]' \ + "1: :{_describe 'tool' tools}" \ + '*:: :->args' + + case $state in + args) + case $words[1] in + addr2line) + _files + ;; + + asm) + _arguments \ + '-D[predefined symbol with optional simple value]:value' \ + '-I[include directory]:value' \ + '-S[print assembly and machine code]' \ + '-debug[dump instructions as they are parsed]' \ + '-dynlink[support references to Go symbols]' \ + '-o[output file]:string' \ + '-shared[generate code that can be linked into a shared lib]' \ + '-trimpath[remove prefix from recorded source file paths]:string' + ;; + + callgraph) + local -a algos graphs + algos=( + 'static:static calls only' + 'cha:Class Hierarchy Analysis' + 'rta:Rapid Type Analysis' + 'pta:inclusion-based Points-To Analysis' + ) + graphs=( + 'digraph:output in digraph format' + 'graphviz:output in AT&T GraphViz (.dot) format' + ) + + _arguments \ + '-algo=[call-graph construction algorithm]:algos:{ _describe "algos" algos }' \ + "-test[include the package's tests in the analysis]" \ + '-format=[format in which each call graph edge is displayed]:graphs:{ _describe "graphs" graphs }' + ;; + + cgo) + _arguments \ + '-debug-define[print relevant #defines]' \ + '-debug-gcc[print gcc invocations]' \ + '-dynimport[if non-empty, print dynamic import data]:string' \ + '-dynlinker[record dynamic linker information]' \ + '-dynout[write -dynimport output to file]:file' \ + '-dynpackage[set Go package for -dynimport output]:string' \ + '-exportheader[where to write export header]:string' \ + '-gccgo[generate files for use with gccgo]' \ + '-gccgopkgpath[-fgo-pkgpath option used with gccgo]:string' \ + '-gccgoprefix[-fgo-prefix option used with gccgo]:string' \ + '-godefs[write Go definitions for C file to stdout]' \ + '-import_runtime_cgo[import runtime/cgo in generated code]' \ + '-import_syscall[import syscall in generated code]' \ + '-importpath[import path of package being built]:path' \ + '-objdir[object directory]:dir' + ;; + + compile) + _arguments \ + '-%[debug non-static initializers]' \ + '-+[compiling runtime]' \ + "-A[for bootstrapping, allow 'any' type]" \ + '-B[disable bounds checking]' \ + '-D[set relative path for local imports]:path' \ + '-E[debug symbol export]' \ + '-I[add directory to import search path]:directory' \ + '-K[debug missing line numbers]' \ + '-L[use full (long) path in error messages]' \ + '-M[debug move generation]' \ + '-N[disable optimizations]' \ + '-P[debug peephole optimizer]' \ + '-R[debug register optimizer]' \ + '-S[print assembly listing]' \ + '-V[print compiler version]' \ + '-W[debug parse tree after type checking]' \ + '-asmhdr[write assembly header to file]:file' \ + '-buildid[record id as the build id in the export metadata]:id' \ + '-complete[compiling complete package (no C or assembly)]' \ + '-cpuprofile[write cpu profile to file]:file' \ + '-d[print debug information about items in list]:list' \ + '-dynlink[support references to Go symbols]' \ + '-e[no limit on number of errors reported]' \ + '-f[debug stack frames]' \ + '-g[debug code generation]' \ + '-h[halt on error]' \ + '-i[debug line number stack]' \ + '-importmap[add definition of the form source=actual to import map]:definition' \ + '-installsuffix[set pkg directory suffix]:suffix' \ + '-j[debug runtime-initialized variables]' \ + '-l[disable inlining]' \ + '-largemodel[generate code that assumes a large memory model]' \ + '-live[debug liveness analysis]' \ + '-m[print optimization decisions]' \ + '-memprofile[write memory profile to file]:file' \ + '-memprofilerate[set runtime.MemProfileRate to rate]:rate' \ + '-nolocalimports[reject local (relative) imports]' \ + '-o[write output to file]:file' \ + '-p[set expected package import path]:path' \ + '-pack[write package file instead of object file]' \ + '-r[debug generated wrappers]' \ + '-race[enable race detector]' \ + '-s[warn about composite literals that can be simplified]' \ + '-shared[generate code that can be linked into a shared library]' \ + '-trimpath[remove prefix from recorded source file paths]:prefix' \ + '-u[reject unsafe code]' \ + '-v[increase debug verbosity]' \ + '-w[debug type checking]' \ + '-wb[enable write barrier (default 1)]' \ + '-x[debug lexer]' \ + '-y[debug declarations in canned imports (with -d)]' \ + '*:file:_files -g "*.go(-.)"' + ;; + + cover) + if (( CURRENT == 2 )); then + _arguments \ + '-func=[output coverage profile information for each function]:string' \ + '-html=[generate HTML representation of coverage profile]:file:_files' \ + '-mode=[coverage mode]:mode:(set count atomic)' + return + fi + + _arguments \ + '-o[file for output]:file' \ + '-var=[name of coverage variable to generate]:var' \ + '*:file:_files -g "*.go(-.)"' + ;; + + doc) + _arguments \ + '-c[respect case when matching symbols]' \ + '-cmd[treat a command (package main) like a regular package]' \ + '-u[show docs for unexported and exported symbols and methods]' \ + ;; + + fix) + _arguments \ + '-diff[display diffs instead of rewriting files]' \ + '-force[force fixes to run even if the code looks updated]:string' \ + '-r[restrict the rewrites]:string' \ + '*:files:_files' + ;; + + link) + _arguments \ + '-B[add an ELF NT_GNU_BUILD_ID note when using ELF]:note' \ + '-C[check Go calls to C code]' \ + '-D[set data segment address (default -1)]:address' \ + '-E[set entry symbol name]:entry' \ + '-H[set header type]:type' \ + '-I[use linker as ELF dynamic linker]:linker' \ + '-L[add specified directory to library path]:directory' \ + '-R[set address rounding quantum (default -1)]:quantum' \ + '-T[set text segment address (default -1)]:address' \ + '-V[print version and exit]' \ + '-W[disassemble input]' \ + '-X[add string value definition]:definition' \ + '-a[disassemble output]' \ + '-buildid[record id as Go toolchain build id]:id' \ + '-buildmode[set build mode]:mode' \ + '-c[dump call graph]' \ + '-cpuprofile[write cpu profile to file]:file' \ + '-d[disable dynamic executable]' \ + '-extld[use linker when linking in external mode]:linker' \ + '-extldflags[pass flags to external linker]:flags' \ + '-f[ignore version mismatch]' \ + '-g[disable go package data checks]' \ + '-h[halt on error]' \ + '-installsuffix[set package directory suffix]:suffix' \ + '-k[set field tracking symbol]:symbol' \ + '-linkmode[set link mode]:mode:(internal external auto)' \ + '-linkshared[link against installed Go shared libraries]' \ + '-memprofile[write memory profile to file]:file' \ + '-memprofilerate[set runtime.MemProfileRate to rate]:rate' \ + '-n[dump symbol table]' \ + '-o[write output to file]:file' \ + '-r[set the ELF dynamic linker search path to dir1:dir2:...]:path' \ + '-race[enable race detector]' \ + '-s[disable symbol table]' \ + '-shared[generate shared object (implies -linkmode external)]' \ + '-tmpdir[use directory for temporary files]:directory' \ + '-u[reject unsafe packages]' \ + '-v[print link trace]' \ + '-w[disable DWARF generation]' \ + '*:files:_files' + ;; + + objdump) + _arguments \ + '-s[only dump symbols matching this regexp]:regexp' \ + '*:files:_files' + ;; + + pack) + _arguments '1:ops:(c p r t x)' '::verbose:(v)' ':files:_files' + ;; + + pprof) + _arguments \ + '-callgrind[outputs a graph in callgrind format]' \ + '-disasm=[output annotated assembly]:p' \ + '-dot[outputs a graph in DOT format]' \ + '-eog[visualize graph through eog]' \ + '-evince[visualize graph through evince]' \ + '-gif[outputs a graph image in GIF format]' \ + '-gv[visualize graph through gv]' \ + '-list=[output annotated source for functions matching regexp]:p' \ + '-pdf[outputs a graph in PDF format]' \ + '-peek=[output callers/callees of functions matching regexp]:p' \ + '-png[outputs a graph image in PNG format]' \ + '-proto[outputs the profile in compressed protobuf format]' \ + '-ps[outputs a graph in PS format]' \ + '-raw[outputs a text representation of the raw profile]' \ + '-svg[outputs a graph in SVG format]' \ + '-tags[outputs all tags in the profile]' \ + '-text[outputs top entries in text form]' \ + '-top[outputs top entries in text form]' \ + '-tree[outputs a text rendering of call graph]' \ + '-web[visualize graph through web browser]' \ + '-weblist=[output annotated source in HTML]:p' \ + '-output=[generate output on file f (stdout by default)]:f' \ + '-functions[report at function level (default)]' \ + '-files[report at source file level]' \ + '-lines[report at source line level]' \ + '-addresses[report at address level]' \ + '-base[show delta from this profile]:profile' \ + '-drop_negative[ignore negative differences]' \ + '-cum[sort by cumulative data]' \ + '-seconds=[length of time for dynamic profiles]:n' \ + '-nodecount=[max number of nodes to show]:n' \ + '-nodefraction=[hide nodes below *total]:f' \ + '-edgefraction=[hide edges below *total]:f' \ + '-sample_index[index of sample value to display]' \ + '-mean[average sample value over first value]' \ + '-inuse_space[display in-use memory size]' \ + '-inuse_objects[display in-use object counts]' \ + '-alloc_space[display allocated memory size]' \ + '-alloc_objects[display allocated object counts]' \ + '-total_delay[display total delay at each region]' \ + '-contentions[display number of delays at each region]' \ + '-mean_delay[display mean delay at each region]' \ + '-runtime[show runtime call frames in memory profiles]' \ + '-focus=[restricts to paths going through a node matching regexp]:r' \ + '-ignore=[skips paths going through any nodes matching regexp]:r' \ + '-tagfocus=[restrict to samples tagged with key:value matching regexp]:r' \ + '-tagignore=[discard samples tagged with key:value matching regexp]' \ + '-call_tree[generate a context-sensitive call tree]' \ + '-unit=[convert all samples to unit u for display]:u' \ + '-divide_by=[scale all samples by dividing them by f]:f' \ + '-buildid=[override build id for main binary in profile]:id' \ + '-tools=[search path for object-level tools]:path' \ + '-help[help message]' \ + '*:files:_files' + ;; + + trace) + _arguments \ + '-http=[HTTP service address]:addr' \ + '*:files:_files' + ;; + + vet) + _arguments \ + '-all[check everything]' \ + '-asmdecl[check assembly against Go declarations]' \ + '-assign[check for useless assignments]' \ + '-atomic[check for common mistaken usages of the sync/atomic]' \ + '-bool[check for mistakes involving boolean operators]' \ + '-buildtags[check that +build tags are valid]' \ + '-composites[check that composite literals used field-keyed elements]' \ + '-compositewhitelist[use composite white list]' \ + '-copylocks[check that locks are not passed by value]' \ + '-methods[check that canonically named methods are canonically defined]' \ + '-nilfunc[check for comparisons between functions and nil]' \ + '-printf[check printf-like invocations]' \ + '-printfuncs[print function names to check]:string' \ + '-rangeloops[check that range loop variables are used correctly]' \ + '-shadow[check for shadowed variables]' \ + '-shadowstrict[whether to be strict about shadowing]' \ + '-shift[check for useless shifts]' \ + '-structtags[check that struct field tags have canonical format]' \ + '-tags[list of build tags to apply when parsing]:list' \ + '-test[for testing only: sets -all and -shadow]' \ + '-unreachable[check for unreachable code]' \ + '-unsafeptr[check for misuse of unsafe.Pointer]' \ + '-unusedfuncs[list of functions whose results must be used]:string' \ + '-unusedresult[check for unused result of calls to functions in -unusedfuncs]' \ + '-unusedstringmethods[list of methods whose results must be used]:string' \ + '-v[verbose]' \ + '*:files:_files' + ;; + + yacc) + _arguments \ + '-o[output]:output' \ + '-v[parsetable]:parsetable' \ + '*:files:_files' + ;; + esac + ;; + esac + ;; + + vet) + _arguments \ + '-n[print commands that would be executed]' \ + '-x[prints commands as they are executed]' \ + ${build_flags[@]} \ + '*:importpaths:__go_packages' + ;; + help) + local -a topics + topics=( + 'c:calling between Go and C' + 'buildmode:description of build modes' + 'filetype:file types' + 'gopath:GOPATH environment variable' + 'environment:environment variables' + 'importpath:import path syntax' + 'packages:description of package lists' + 'testflag:description of testing flags' + 'testfunc:description of testing functions' + ) + + _arguments "1: :{_describe 'command' commands -- topics}" + ;; + esac + ;; + esac +} + +_go diff --git a/.zprezto/modules/completion/external/src/_google b/.zprezto/modules/completion/external/src/_google index ca1987f..8cd6a1b 100644 --- a/.zprezto/modules/completion/external/src/_google +++ b/.zprezto/modules/completion/external/src/_google @@ -1,5 +1,30 @@ #compdef google # ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_gradle b/.zprezto/modules/completion/external/src/_gradle deleted file mode 100644 index 9587e4b..0000000 --- a/.zprezto/modules/completion/external/src/_gradle +++ /dev/null @@ -1,135 +0,0 @@ -#compdef gradle gradlew -# ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for Gradle 1.0-milestone-5 (http://www.gradle.org). -# -# Status: incomplete (see TODO/FIXME tags) -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Julien Nicoulaud -# -# ------------------------------------------------------------------------------ - - -_gradle() { - typeset -A opt_args - local context state line - - local curcontext="$curcontext" - - _arguments \ - '(- 1 *)'{-?,-h,--help}'[show help message]' \ - '(-a --no-rebuild)'{-a,--no-rebuild}'[do not rebuild project dependencies]' \ - '(-b --build-file)'{-b,--build-file}'[specify the build file]:build file:_gradle_scripts' \ - '(-C --cache)'{-C,--cache}'[specify how compiled build scripts should be cached]:cache strategy:((rebuild\:rebuild\ the\ cache on\:use\ the\ cache\ \(default\)))' \ - '(-c --settings-file)'{-c,--settings-file}'[specify the settings file]:settings file:_gradle_scripts' \ - '*'{-D-,--system-prop}'[set system property of the JVM]:property:_gradle_properties' \ - '(-d --debug -q --quiet -i --info)'{-d,--debug}'[log in debug mode (includes normal stacktrace)]' \ - '(--foreground --no-daemon --stop)--daemon[use the Gradle daemon to run the build, starts the daemon if not running]' \ - '(-e --embedded)'{-e,--embedded}'[specify an embedded build script]:embedded build script' \ - '(--daemon --no-daemon --stop)--foreground[start the Gradle daemon in the foreground]' \ - '(-g --gradle-user-home)'{-g,--gradle-user-home}'[specify the gradle user home directory]: :_files -/' \ - '--gui[launch a GUI application]' \ - '(-I --init-script)'{-I,--init-script}'[specify an initialization script]:init script:_gradle_scripts' \ - '(-i --info -q --quiet -d --debug)'{-i,--info}'[set log level to info]' \ - '(-m --dry-run)'{-m,--dry-run}'[run the builds with all task actions disabled]' \ - '(-n --dependencies)'{-n,--dependencies}'[show list of all project dependencies]' \ - '--no-color[do not use color in the console output]' \ - '(--daemon --foreground --stop)--no-daemon[do not use the Gradle daemon to run the build]' \ - '--no-opt[ignore any task optimization]' \ - '*'{-P-,--project-prop}'[set project property for the build script]:property:_gradle_properties' \ - '(-p --project-dir)'{-p,--project-dir}'[specify the start directory for Gradle]: :_files -/' \ - '--profile[profile build execution time and generate a report in the /reports/profile directory]' \ - '(-q --quiet -d --debug -i --info)'{-q,--quiet}'[log errors only]' \ - '(-r --properties)'{-r,--properties}'[show list of all available project properties]' \ - '(-S --full-stacktrace)'{-S,--full-stacktrace}'[print out the full (very verbose) stacktrace for any exceptions]' \ - '(-s --stacktrace)'{-s,--stacktrace}'[print out the stacktrace also for user exceptions]' \ - '(--daemon --foreground)--stop[stop the Gradle daemon if it is running]' \ - '(-t --tasks)'{-t,--tasks}'[show list of available tasks]' \ - '(-u --no-search-upward)'{-u,--no-search-upward}'[don'\''t search in parent folders for a settings.gradle file]' \ - '(-v --version)'{-v,--version}'[print version info]' \ - '(-x --exclude-task)*'{-x,--exclude-task}'[specify a task to be excluded from execution]:task:_gradle_tasks' \ - '*: :_gradle_tasks' -} - -(( $+functions[_gradle_tasks] )) || -_gradle_tasks() { - local alternatives task_group task_group_name task_group_tasks - local project="${PREFIX%:*}" - alternatives=("project:project:_gradle_projects -qS:") - for task_group in ${(M)${(ps:\n\n:)"$($service --daemon --quiet --no-color ${project}:tasks 2>/dev/null)"}:#*[[:space:]]\-[[:space:]]*}; do - task_group_name="${${${task_group%%---*}%[[:space:]]tasks[[:space:]]*}:l}" - task_group_tasks=(${(q)${(f)${task_group##*---}}/[[:space:]]\-[[:space:]]/:}) - alternatives+=("${task_group_name//[[:space:]]/-}-task:${task_group_name} task:((${task_group_tasks[@]}))") - done - _alternative "${alternatives[@]}" -} - -(( $+functions[_gradle_projects] )) || -_gradle_projects() { - local project="${PREFIX%:*}" - local projects; projects=(${${${(M)${(f)"$($service --daemon --quiet --no-color ${project}:projects 2>/dev/null)"}:#*--- Project\ \':*}#*\'}%\'*}) - _multi_parts $@ : projects -} - -(( $+functions[_gradle_scripts] )) || -_gradle_scripts() { - _files -g '*.gradle*' -} - -(( $+functions[_gradle_properties] )) || -_gradle_properties() { - local ret=1 - if compset -P '*='; then - _message -e property-values 'property value' && ret=0 - else - _wanted property-names expl 'property name' _gradle_property_names -qS= && ret=0 - fi - return ret -} - -(( $+functions[_gradle_property_names] )) || -_gradle_property_names() { - local property_names; property_names=(${${(M)${(f)"$($service --daemon --quiet --no-color :properties 2>/dev/null)"}:#*:*}%%:*}) - _describe -t property_names 'property name' property_names "$@" -} - -_gradle "$@" - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_gtk-launch b/.zprezto/modules/completion/external/src/_gtk-launch new file mode 100644 index 0000000..a2bede4 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_gtk-launch @@ -0,0 +1,87 @@ +#compdef gtk-launch +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for gtk-launch on gtk+-3.14.8 (http://www.gtk.org/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * ncaq (version 3.14.8) +# +# ------------------------------------------------------------------------------ + +_gtk-launch() { + _arguments \ + {-h,--help}'[Show help options]' \ + --help-all'[Show all help options]' \ + --help-gtk'[Show GTK+ Options]' \ + --display='[X display to use]' \ + '1: :_applications' +} + +_applications() { + local -a applications + + for file in /usr/share/applications/*.desktop; do + applications+=`_format_entry $file` + done + + _values -w \ + 'applications' \ + $applications +} + +_format_entry() { + echo "`_remove_path_extension $1`[`_get_description $1`]" +} + +_remove_path_extension() { + # echo arg + # remove path string + # remove extension string + echo $1 | \ + sed 's/.*\///' | \ + sed 's/\.desktop//' +} + +_get_description() { + # grep --no-messages option is handling of not UTF-8 text + grep --no-messages '^Comment=\|^Exec=' $1 | \ + tr '\n' ' ' +} + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_heroku b/.zprezto/modules/completion/external/src/_heroku deleted file mode 100644 index dcc0b54..0000000 --- a/.zprezto/modules/completion/external/src/_heroku +++ /dev/null @@ -1,209 +0,0 @@ -#compdef heroku -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for the Heroku client gem (https://github.com/heroku/heroku) -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Ali B. (http://awhitebox.com) -# -# ------------------------------------------------------------------------------ - -local -a _1st_arguments -_1st_arguments=( - "account\:confirm_billing":"Confirm that your account can be billed at the end of the month" - "addons":"list installed addons" - "addons\:list":"list all available addons" - "addons\:add":"install an addon" - "addons\:upgrade":"upgrade an existing addon" - "addons\:downgrade":"downgrade an existing addon" - "addons\:remove":"uninstall an addon" - "addons\:open":"open an addon's dashboard in your browser" - "apps":"list your apps" - "apps\:info":"show detailed app information" - "apps\:create":"create a new app" - "apps\:rename":"rename the app" - "apps\:open":"open the app in a web browser" - "apps\:destroy":"permanently destroy an app" - "auth\:login":"log in with your heroku credentials" - "auth\:logout":"clear local authentication credentials" - "config":"display a config vars for an app" - "config\:get":"display a config value for an app" - "config\:set":"set one or more config vars" - "config\:unset":"unset one or more config vars" - "db\:push":"push local data up to your app" - "db\:pull":"pull heroku data down into your local database" - "domains":"list custom domains for an app" - "domains\:add":"add a custom domain to an app" - "domains\:remove":"remove a custom domain from an app" - "domains\:clear":"remove all custom domains from an app" - "help":"list available commands or display help for a specific command" - "keys":"display keys for the current user" - "keys\:add":"add a key for the current user" - "keys\:remove":"remove a key from the current user" - "keys\:clear":"remove all authentication keys from the current user" - "logs":"display recent log output" - "logs\:cron":"DEPRECATED: display cron logs from legacy logging" - "logs\:drains":"manage syslog drains" - "maintenance\:on":"put the app into maintenance mode" - "maintenance\:off":"take the app out of maintenance mode" - "open":"open app in a web browser" - "pg\:info":"display database information" - "pg\:ingress":"allow direct connections to the database from this IP for one minute" - "pg\:promote":"sets DATABASE as your DATABASE_URL" - "pg\:psql":"open a psql shell to the database" - "pg\:reset":"delete all data in DATABASE" - "pg\:unfollow":"stop a replica from following and make it a read/write database" - "pg\:wait":"monitor database creation, exit when complete" - "pgbackups":"list captured backups" - "pgbackups\:url":"get a temporary URL for a backup" - "pgbackups\:capture":"capture a backup from a database id" - "pgbackups\:restore":"restore a backup to a database" - "pgbackups\:destroy":"destroys a backup" - "plugins":"list installed plugins" - "plugins\:install":"install a plugin" - "plugins\:uninstall":"uninstall a plugin" - "plugins\:update":"updates all plugins or a single plugin by name" - "ps\:dynos":"scale to QTY web processes" - "ps\:workers":"scale to QTY background processes" - "ps":"list processes for an app" - "ps\:restart":"restart an app process" - "ps\:scale":"scale processes by the given amount" - "releases":"list releases" - "releases\:info":"view detailed information for a release" - "rollback":"roll back to an older release" - "run":"run an attached process" - "run\:rake":"remotely execute a rake command" - "run\:console":"open a remote console session" - "sharing":"list collaborators on an app" - "sharing\:add":"add a collaborator to an app" - "sharing\:remove":"remove a collaborator from an app" - "sharing\:transfer":"transfer an app to a new owner" - "ssl":"list certificates for an app" - "ssl\:add":"add an ssl certificate to an app" - "ssl\:remove":"remove an ssl certificate from an app" - "ssl\:clear":"remove all ssl certificates from an app" - "stack":"show the list of available stacks" - "stack\:migrate":"prepare migration of this app to a new stack" - "version":"show heroku client version" -) - -_arguments '*:: :->command' - -if (( CURRENT == 1 )); then - _describe -t commands "heroku command" _1st_arguments - return -fi - -local -a _command_args -case "$words[1]" in - apps:info) - _command_args=( - '(-r|--raw)'{-r,--raw}'[output info as raw key/value pairs]' \ - ) - ;; - apps:create) - _command_args=( - '(-a|--addons)'{-a,--addons}'[a list of addons to install]' \ - '(-r|--remote)'{-r,--remote}'[the git remote to create, default "heroku"]' \ - '(-s|--stack)'{-s,--stack}'[the stack on which to create the app]' \ - ) - ;; - config) - _command_args=( - '(-s|--shell)'{-s,--shell}'[output config vars in shell format]' \ - ) - ;; - db:push) - _command_args=( - '(-c|--chunksize)'{-c,--chunksize}'[specify the number of rows to send in each batch]' \ - '(-d|--debug)'{-d,--debug}'[enable debugging output]' \ - '(-e|--exclude)'{-e,--exclude}'[exclude the specified tables from the push]' \ - '(-f|--filter)'{-f,--filter}'[only push certain tables]' \ - '(-r|--resume)'{-r,--resume}'[resume transfer described by a .dat file]' \ - '(-t|--tables)'{-t,--tables}'[only push the specified tables]' \ - ) - ;; - db:pull) - _command_args=( - '(-c|--chunksize)'{-c,--chunksize}'[specify the number of rows to send in each batch]' \ - '(-d|--debug)'{-d,--debug}'[enable debugging output]' \ - '(-e|--exclude)'{-e,--exclude}'[exclude the specified tables from the pull]' \ - '(-f|--filter)'{-f,--filter}'[only pull certain tables]' \ - '(-r|--resume)'{-r,--resume}'[resume transfer described by a .dat file]' \ - '(-t|--tables)'{-t,--tables}'[only pull the specified tables]' \ - ) - ;; - keys) - _command_args=( - '(-l|--long)'{-l,--long}'[display extended information for each key]' \ - ) - ;; - logs) - _command_args=( - '(-n|--num)'{-n,--num}'[the number of lines to display]' \ - '(-p|--ps)'{-p,--ps}'[only display logs from the given process]' \ - '(-s|--source)'{-s,--source}'[only display logs from the given source]' \ - '(-t|--tail)'{-t,--tail}'[continually stream logs]' \ - ) - ;; - pgbackups:capture) - _command_args=( - '(-e|--expire)'{-e,--expire}'[if no slots are available to capture, delete the oldest backup to make room]' \ - ) - ;; - stack) - _command_args=( - '(-a|--all)'{-a,--all}'[include deprecated stacks]' \ - ) - ;; - esac - -_arguments \ - $_command_args \ - '(-a|--app)'{-a,--app}'[the app name]' \ - '(-r|--remote)'{-r,--remote}'[the git remote name]:remote:->remotes' \ - && return 0 - -__heroku_git_remotes () { - local expl gitdir remotes - - gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null) - __heroku_git_command_successful || return - - remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]}) - __heroku_git_command_successful || return - - # TODO: Should combine the two instead of either or. - if (( $#remotes > 0 )); then - _wanted remotes expl remote compadd $* - $remotes - else - _wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*" - fi -} - -__heroku_git_command_successful () { - if (( ${#pipestatus:#0} > 0 )); then - _message 'not a git repository' - return 1 - fi - return 0 -} - -case $state in - (remotes) - __heroku_git_remotes && return 0 - ;; -esac - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_hledger b/.zprezto/modules/completion/external/src/_hledger deleted file mode 100644 index 156bf92..0000000 --- a/.zprezto/modules/completion/external/src/_hledger +++ /dev/null @@ -1,177 +0,0 @@ -#compdef hledger - -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for hleder 0.23.2 ( http://hledger.org/ ) -# Last updated: 16.11.2014 -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Valodim ( https://github.com/Valodim ) -# -# ------------------------------------------------------------------------------ -# Notes -# ----- -# -# account completion depends on availability of a ~/.hledger.journal file -# -# ------------------------------------------------------------------------------ - - -local curcontext="$curcontext" curstate state line expl grp cmd ret=1 -typeset -a args -typeset -A opt_args - -args=( - '(- *)'{-h,--help}'[print help information]' - '(-f --file)'{-f,--file}'=[use a different input file]:input file:_files' - '--rules-file=[CSV conversion rules file]:rules file:_files' - '--alias=[display accounts named OLD as NEW]:alias specification' - '(-b --begin)'{-b,--begin}'=[include postings/txns on or after this date]:date' - '(-e --end)'{-e,--end}'=[include postings/txns before this date]:date' - '(-D --daily)'{-D,--daily}'[multiperiod/multicolumn report by day]' - '(-W --weekly)'{-W,--weekly}'[multiperiod/multicolumn report by week]' - '(-M --monthly)'{-M,--monthly}'[multiperiod/multicolumn report by month]' - '(-Q --quarterly)'{-Q,--quarterly}'[multiperiod/multicolumn report by quarter]' - '(-Y --yearly)'{-Y,--yearly}'[multiperiod/multicolumn report by year]' - '(-p --period)'{-p,--period}'=[set start date, end date, and/or reporting interval all at once]' - '(-C --cleared)'{-C,--cleared}'[include only cleared postings/txns]' - '(-U --uncleared)'{-U,--uncleared}'[include only uncleared postings/txns]' - '(-R --real)'{-R,--real}'[include only non-virtual postings]' - '(--depth)--depth=[hide accounts/postings deeper than N]:depth' - '(-E --empty)'{-E,--empty}'[show empty/zero things which are normally omitted]' - '(-B --cost)'{-B,--cost}'[show amounts in their cost price'\''s commodity]' -) - -_arguments -C "$args[@]" -A "-*" \ - '(- *)--version[print version information]' \ - '--debug[show debug output]' \ - '1: :->cmds' \ - '*:: :->args' && ret=0 - -while (( $#state )); do - curstate=$state - shift state - case $curstate in - cmds) - typeset -a cmds - cmds=( - 'print:show transaction entries' - 'accounts:show account names' - 'balance:show accounts and balances (bal)' - 'register:show postings and running total (reg)' - 'incomestatement:show an income statement (is)' - 'balancesheet:show a balance sheet (bs)' - 'cashflow:show a cashflow statement (cf)' - 'activity:show an ascii barchart of posting counts per interval' - 'stats:show some journal statistics' - ) - _describe 'subcommands' cmds && ret=0 - ;; - args) - : $words - local cmd=$words[1] - (( $+cmd )) || return 1 - # curcontext="${curcontext%:*:*}:$service-$cmd:" - case $cmd in - accounts) - args+=( - '(--tree)--tree[show accounts as a tree (default in simple reports)]' - '(--flat)--flat[show accounts as a list (default in multicolumn)]' - '(--drop)--drop=[flat mode, omit N leading account name parts]:drop n' - ) - ;; - activity) - ;; - bal|balance) - args+=( - '(--tree)--tree[show accounts as a tree (default in simple reports)]' - '(--flat)--flat[show accounts as a list (default in multicolumn)]' - '(--drop)--drop=[in flat mode, omit N leading account name parts]:drop n' - '(--format)--format=[in tree mode, use this custom line format]:custom line format' - '(--no-elide)--no-elide[tree mode, do not squash boring parent accounts]' - '(--no-total)--no-total[do not show the final total]' - '(--cumulative)--cumulative[multicolumn mode, show accumulated ending balances]' - '(-H --historical)'{-H,--historical}'[multicolumn mode, show historical ending balances]' - ) - ;; - cashflow|cf|balancesheet|bs|incomestatement|is) - args+=( - '(--flat)--flat[show accounts as a list (default in multicolumn)]' - '(--drop)--drop=[in flat mode, omit N leading account name parts]:drop n' - ) - ;; - print) - ;; - register|reg) - args+=( - '(-H --historical)'{-H,--historical}'[include prior postings in the running total]' - '(-A --average)'{-A,--average}'[show a running average instead of the running total]' - '(-r --related)'{-r,--related}'[show postings'\'' siblings instead]' - '(-w --width)'{-w,--width}'=[set output width to 120, or N]:width (default 80)' - ) - ;; - stats) - ;; - # fallback to _default - *) _arguments -C -A "-*" "$args[@]" \ - '*: :_default' && ret=0 - continue - esac - _arguments -C -A "-*" "$args[@]" \ - '*:query patterns:->query' && ret=0 - ;; - query) - - local -a accs keywords - keywords=( - 'code\::match by transaction code' - 'desc\::match transaction descriptions' - 'tag\::match by tag name' - 'depth\::match at or above depth' - 'status\::match cleared/uncleared transactions' - 'real\::match real/virtual transactions' - 'empty\::match if amount is/is not zero' - 'amt\::match transaction amount' - ) - if compset -P 'amt:'; then - _message 'match amount (<, <=, >, >=, add sign for non-absolute match)' && ret=0 - continue - fi - if compset -P '(#b)(code|desc|tag|depth|status|real|empty):'; then - _message "'$match[1]' parameter" && ret=0 - continue - fi - - accs=( ${(f)"$(_call_program hledger hledger accounts $PREFIX 2>/dev/null)"} ) - if (( $? )); then - _message "error fetching accounts from hledger" - fi - - # decided against partial matching here. these lines can - # be uncommented to complete subaccounts hierarchically - # (add -S '' -q to the compadd below, too) - # if compset -P '(#b)(*):'; then - # accs=( ${(M)accs:#$match[1]:*} ) - # accs=( ${accs#$IPREFIX} ) - # fi - # accs=( ${accs%%:*} ) - - _wanted accounts expl "accounts" compadd -a accs && ret=0 - _describe "matcher keywords" keywords -S '' && ret=0 - - # not is special, it doesn't need the -S '' - keywords=( - 'not:negate expression' - ) - _describe "matcher keywords" keywords && ret=0 - - ;; - esac -done - -return ret diff --git a/.zprezto/modules/completion/external/src/_homestead b/.zprezto/modules/completion/external/src/_homestead new file mode 100644 index 0000000..9dc1c41 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_homestead @@ -0,0 +1,53 @@ +#compdef homestead +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for homestead (http://laravel.com/docs/homestead). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * loranger (https://github.com/loranger) +# +# ------------------------------------------------------------------------------ + + +_homestead_get_command_list () { + homestead --no-ansi | sed "1,/Available commands/d" | awk '/ [a-z]+/ { print $1 }' +} + +_homestead () { + if [ -f homestead ]; then + compadd `_homestead_get_command_list` + fi +} + +compdef _homestead php homestead +compdef _homestead homestead diff --git a/.zprezto/modules/completion/external/src/_httpie b/.zprezto/modules/completion/external/src/_httpie index ea4a2ed..4d702ef 100644 --- a/.zprezto/modules/completion/external/src/_httpie +++ b/.zprezto/modules/completion/external/src/_httpie @@ -36,6 +36,7 @@ # # * Akira Maeda # * Valodim +# * Claus Klingberg # # ------------------------------------------------------------------------------ # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- @@ -72,16 +73,18 @@ _httpie_params () { compset -P '(#b)([^:@=]#)' local name=$match[1] - if compset -P ':'; then - _message "$name header content" + if compset -P '='; then + _message "$name data field value" elif compset -P '@'; then _files + elif compset -P ':=@'; then + _files elif compset -P ':='; then _message "$name raw json data" elif compset -P '=='; then _message "$name url parameter value" - elif compset -P '='; then - _message "$name data field value" + elif compset -P ':'; then + _message "$name header content" else typeset -a ops ops=( @@ -90,6 +93,7 @@ _httpie_params () { '==:request parameter' '@:data file field' '\:=:raw json field' + '\:=@:raw json field file path' ) _describe -t httpparams "parameter types" ops -Q -S '' fi diff --git a/.zprezto/modules/completion/external/src/_ibus b/.zprezto/modules/completion/external/src/_ibus new file mode 100644 index 0000000..69c114c --- /dev/null +++ b/.zprezto/modules/completion/external/src/_ibus @@ -0,0 +1,84 @@ +#compdef ibus +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for ibus (https://github.com/ibus/ibus). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Tomo Kazahaya +# +# ------------------------------------------------------------------------------ + +# The completion of "ibus emoji --lang=" depends on _language_codes from +# https://github.com/zsh-users/zsh-completions. + +local context state state_descr line +typeset -A opt_args +local curcontext=$curcontext + +_arguments -C \ + ":command:(($(ibus help|sed -ne 's/^ \(\S\+\) \+\(.*\)/"\1\\:\2"/p')))" \ + '*:: :->args' \ + && return + +case $state in + args) + case $line[1] in + engine) + _arguments \ + ":engine:(($(ibus list-engine|sed -ne 's/:/\\\\:/g' -e 's/^ \(\S\+\) - \(.*\)$/"\1:\2"/p')))" \ + && return + ;; + read-cache) + _arguments \ + '--system[show the content of the system registry cache]' \ + '--file=[custom registry cache to show]:registry cache:_files' \ + && return + ;; + write-cache) + _arguments \ + '--system[save the system registry cache]' \ + '--file=[custom registry cache to save]:registry cache:_files' \ + && return + ;; + emoji) + _arguments \ + '--font=[emoji font]:emoji font: ' \ + '--lang=[language of emoji annotations]:language:_language_codes ISO-639-1' \ + '--partial-match[match annotations with a partial string]' \ + && return + ;; + esac + ;; +esac + +return 1 diff --git a/.zprezto/modules/completion/external/src/_id3 b/.zprezto/modules/completion/external/src/_id3 deleted file mode 100644 index df4f1de..0000000 --- a/.zprezto/modules/completion/external/src/_id3 +++ /dev/null @@ -1,70 +0,0 @@ -#compdef id3 - -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for id3, based on v0.15 -# -# Last updated: 03.04.2013 -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Valodim ( https://github.com/Valodim ) -# -# ------------------------------------------------------------------------------ - -_id3_genre () { - - setopt localoptions extendedglob - - local -A _id3_genres - # got them cached? - if _cache_invalid id3-genres || ! _retrieve_cache id3-genres ; then - - # generate from id3 -L otherwise - local tmp - for line in ${${${(f)"$(_call_program id3genre id3 -L)"}## #}}; do - tmp=( ${(s,: ,)line} ) - _id3_genres[${tmp[1]}]=$tmp[2] - # alternate display string, which I decided against in the end - # to preserve reasonable alphabetic sorting - # "${(l:3:: :)${tmp[1]}}: ${tmp[2]}" - done - - # store if we got any - (( $#_id3_genres > 0 )) && _store_cache id3-genres _id3_genres - fi - - # bail if we don't - (( $#_id3_genres > 0 )) || { _message "could not fetch genres"; return } - - _wanted id3genres expl 'Genres' \ - compadd -d _id3_genres -k _id3_genres && return 0 - -} - -# only show files if at least one argument or something has been provided -local showfiles='' -(( CURRENT <= 2 )) && showfiles='!' - -_arguments \ - - tagging \ - '-t[modify title tag]:title' \ - '-T[modify track tag]:track' \ - '-a[modify artist tag]:artist' \ - '-A[modify album tag]:album' \ - '-y[modify year tag]:year' \ - '-c[modify comment tag]:comment' \ - '-g[modify genre tag]:genre:_id3_genre' \ - '(-)-l[lists tags]' \ - '-R[use rfc822-style format for output]' \ - '(-)-d[delete id3 tag]' \ - $showfiles'*:mp3 file:_files -g \*.mp3' \ - - meta \ - '(- *)-L[list all genres]' \ - '(- *)-h[display help info]' \ - '(- *)-v[print version info]' && return 0 - diff --git a/.zprezto/modules/completion/external/src/_id3v2 b/.zprezto/modules/completion/external/src/_id3v2 deleted file mode 100644 index edae6e7..0000000 --- a/.zprezto/modules/completion/external/src/_id3v2 +++ /dev/null @@ -1,116 +0,0 @@ -#compdef id3v2 - -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for id3v2, based on v0.1.12 -# -# Last updated: 05.04.2013 -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Valodim ( https://github.com/Valodim ) -# -# ------------------------------------------------------------------------------ - -_id3v2_genre () { - - setopt localoptions extendedglob - - local -A _id3v2_genres - # got them cached? - if _cache_invalid id3v2-genres || ! _retrieve_cache id3v2-genres ; then - - # generate from id3 -L otherwise - local tmp - for line in ${${${(f)"$(_call_program id3v2genres id3v2 -L)"}## #}}; do - tmp=( ${(s,: ,)line} ) - _id3v2_genres[${tmp[1]}]=$tmp[2] - # alternate display string, which I decided against in the end - # to preserve reasonable alphabetic sorting - # "${(l:3:: :)${tmp[1]}}: ${tmp[2]}" - done - - # store if we got any - (( $#_id3v2_genres > 0 )) && _store_cache id3v2-genres _id3v2_genres - fi - - # bail if we don't - (( $#_id3v2_genres > 0 )) || { _message "could not fetch genres"; return } - - _wanted id3v2genres expl 'Genres' \ - compadd -d _id3v2_genres -k _id3v2_genres && return 0 - -} - -# this function assumes _id3v2_frames is defined! -_id3v2_frame () { - - (( $#_id3v2_frames > 0 )) || { _message "could not fetch genres"; return } - local -a framenames - framenames=( ${_id3v2_frames#--} ) - _describe -t framenames 'id3v2 frames' framenames - -} - -_id3v2 () { - - setopt localoptions extendedglob - - # previous word was a frame name? this is an argument, then. - if [[ $words[$CURRENT-1] == --[A-Z](#c4) ]]; then - _message 'frame value' - return 0 - fi - - # load frame names - local -a _id3v2_frames - if _cache_invalid id3v2-frames || ! _retrieve_cache id3v2-frames ; then - _id3v2_frames=( ${${${(f)"$(_call_program id3v2frames id3v2 -f)"}## #}/ /:} ) - (( $#_id3v2_frames > 0 )) && _store_cache id3v2-frames _id3v2_frames - fi - - local ret=1 - - # if we already have a -- prefix, show all those frames - if [[ -prefix -- ]] && (( $#_id3v2_frames > 0 )); then - _describe -t frames 'id3v2 frames' _id3v2_frames && ret=0 - fi - - local showfiles='' - (( CURRENT <= 2 )) && showfiles='!' - - # regular arguments either way - _arguments \ - - tagging \ - '(-s --delete-v1 -d --delete-v2)'{-s,--delete-v1}'[deletes id3v1 tags]' \ - '(-s --delete-v1 -d --delete-v2)'{-d,--delete-v2}'[deletes id3v2 tags]' \ - '(-C --convert)'{-C,--convert}'[converts id3v1 tag to id3v2]' \ - '(-1 --id3v1-only -2 --id3v2-only)'{-1,--id3v1-only}'[write only id3v1 tag]' \ - '(-1 --id3v1-only -2 --id3v2-only)'{-2,--id3v2-only}'[write only id3v2 tag]' \ - '(-r --remove-frame)'{-r,--remove-frame}'[removes specified id3v2 frame]:frame id:_id3v2_frame' \ - '(-a --artist)'{-a,--artist}'[set artist]:artist' \ - '(-A --album)'{-A,--album}'[set album title]:album' \ - '(-t --song)'{-t,--song}'[set song title]:song title' \ - '(-c --comment)'{-c,--comment}'[set comment field]' \ - '(-g --genre)'{-g,--genre}'[set the genre number]:genre:_id3v2_genre' \ - '(-y --year)'{-y,--year}'[set the year]:year' \ - '(-T --track)'{-T,--track}'[set the track number/(optional) total tracks]:track number (current/total)' \ - '(-R --list-rfc822)'{-R,--list-rfc822}'[lists using an rfc822-style format for output]' \ - '(-)'{-D,--delete-all}'[deletes both id3v1 and id3v2 tags]' \ - '(-)'{-l,--list}'[lists the tag(s) on the file(s)]' \ - $showfiles'*:mp3 file:_files -g "*.mp3"' \ - - meta \ - '(- *)'{-f,--list-frames}'[display all possible frames for id3v2]' \ - '(- *)'{-L,--list-genres}'[lists all id3v1 genres]' \ - '(- *)'{-h,--help}'[display help and exit]' \ - '(- *)'{-v,--version}'[display version information and exit]' && ret=0 - - return ret - -} - -_id3v2 "$@" diff --git a/.zprezto/modules/completion/external/src/_iw b/.zprezto/modules/completion/external/src/_iw deleted file mode 100644 index 6217a33..0000000 --- a/.zprezto/modules/completion/external/src/_iw +++ /dev/null @@ -1,247 +0,0 @@ -#compdef iw - -# Some parameters to hold patterns that will be used later. -local xp='[[:xdigit:]][[:xdigit:]]' -local -a bssid devices flags fouraddr fouronoff frequency high_throughput ifacename ifacetype ifacetypes -local -a matchany matchnum key lladdr lladdrs meshid meshidval ssid value -# matches any word -matchany=(/$'[^\0]##\0'/) -# matches any number -matchnum=(/$'[[:digit:]]##\0'/) -# matches any BSSID -bssid=($matchany ':bssid:BSSID:') -# matches any devices -devices=( /$'[[:alpha:]]##[[:digit:]]##(\.[[:digit:]]##)#\0'/ ':interfaces:network_interface:_net_interfaces' ) -# matches the word 'flags' followed by a list of some of the following words: none fcsfail control otherbss cook -flags=(/$'flags\0'/ ':flags:flags:(flags)' $matchany ':flags:flags:(none fcsfail control otherbss cook)' \#) -# matches the word '4addr' followed by either 'on' or 'off' -fouronoff=(/$'(on|off)\0'/ ':4addr:4addr:(on off)') -fouraddr=( /$'4addr\0'/ ':4addr:4addr:(4addr)' $fouronoff ) -# matches any number (description is 'frequency') -frequency=($matchnum ':freq:frequency:') -# matches one of HT20 HT40+ or HT40- -high_throughput=(/$'HT[0-9]##(+|-)#\0'/ ':HT:high throughput:(HT20 HT40+ HT40-)') -# matches any name (description is 'name') -ifacename=($matchany ':name:name:') -# matches the word 'type' followed by one of: managed ibss monitor mesh wds -ifacetypes=(/$'(managed|ibss|monitor|mesh|wds)\0'/ ':type:type:(managed ibss monitor mesh wds)') -ifacetype=(/$'type\0'/ ':type:type:(type)' $ifacetypes) -# matches any word (description is 'key') -key=($matchany ':key:key:') -# matches a MAC address (i.e. a sequence of six 2-digit numbers separated by spaces), $xp is defined earlier. -lladdr=(/"${xp}:${xp}:${xp}:${xp}:${xp}:${xp}"$'\0'/ ':lladdress:link layer (MAC) address:') -# as above but with a different description -lladdrs=(/"${xp}:${xp}:${xp}:${xp}:${xp}:${xp}"$'\0'/ ':lladdress:link layer (MAC) addresses (use - to match any octet):' \#) -# matches the word 'mesh_id' followed by a number -meshidval=($matchnum ':meshid:mesh ID:') -meshid=(/$'mesh_id\0'/ ':meshid:meshid:(mesh_id)' $meshidval) -# matches any word (description 'SSID') -ssid=($matchany ':ssid:SSID:') -# matches any word (description 'value') -value=($matchany ':val:value:') -# matches any number (description 'value') -numvalue=($matchnum ':val:value:') - -# Use the _regex_words function to create a variable containing command words to go after "iw reg" -local -a reg_cmds -_regex_words regulatory-commands "reg command" \ - 'g*et:print out the kernels current regulatory domain information'\ - 's*et:notify the kernel about the current regulatory domain' -reg_cmds=("$reply[@]") - -# Options for to go after "iw event" -local -a event_opts -_regex_words event-options "event option" \ - '-t:print timestamp' \ - '-r:print relative timestamp' \ - '-f:print full frame for auth/assoc etc' -event_opts=("$reply[@]") - -# Commands to go after "iw phy wowlan enable" -local -a phy_wowlan_enable_cmds -_regex_words phy-wowlan-enable-commands "phy WoWLAN enable commands" \ - '4*way-handshake:enable WoWLAN with 4way handshake trigger' \ - 'a*ny:enable WoWLAN with any trigger' \ - 'd*isconnect:enable WoWLAN with disconnect trigger' \ - 'e*ap-identity-request:enable WoWLAN with EAP identity request trigger' \ - 'g*tk-rekey-failure:enable WoWLAN with gtk rekey failure trigger' \ - 'm*agic-packet:enable WoWLAN with magic packet trigger' \ - 'p*atterns:MAC address triggers:$lladdrs' \ - 'r*fkill-release:enable WoWLAN with rfkill release trigger' -phy_wowlan_enable_cmds=("$reply[@]") - -# Commands to go after "iw phy wowlan" -local -a phy_wowlan_cmds -_regex_words phy-wowlan-commands "phy WoWLAN commands" \ - 's*how:show WoWLAN status' \ - 'd*isable:disable WoWLAN' \ - 'e*nable:enable WoWLAN:$phy_wowlan_enable_cmds' -phy_wowlan_cmds=("$reply[@]") - -# Some parameters to hold patterns that will be used for "iw phy set" commands -# (not perfect, but mostly OK). -local -a phy_set_antenna phy_set_channel phy_set_coverage phy_set_frag phy_set_freq phy_set_distance -local -a phy_set_name phy_set_netns phy_set_rts phy_set_txpower phy_txpower_opt -phy_set_antenna=($matchany ':antenna:bitmap:') -phy_set_channel=($matchnum ':channel:channel (1-14):' $high_throughput) -phy_set_coverage=($matchnum ':coverage:coverage class (0-255):') -phy_set_distance=($matchnum ':distance:valid values\: 0 - 114750:') -phy_set_frag=(/$'([0-9]##|off)\0'/ ':channel:channel (1-14):(1 2 3 4 5 6 7 8 9 10 11 12 13 14 off)') -phy_set_freq=($frequency $high_throughput) -phy_set_name=($matchany ':name:device name:') -phy_set_netns=($matchany ':netns:network namespace:') -phy_set_rts=($matchnum ':rts:rts threshold:') -phy_txpower_opt=($matchany ':txpower:tx power in mBm:') -_regex_words phy-set-txpower "set txpower" \ - 'a*uto:auto:' \ - 'f*ixed:fixed:$phy_txpower_opt' \ - 'l*imit:limit:$phy_txpower_opt' -phy_set_txpower=("$reply[@]") - -# Commands to go after "iw phy set" -local -a phy_set_cmds -_regex_words phy-set-commands "phy set commands" \ - 'a*ntenna:set a bitmap of allowed antennas to use for TX and RX:$phy_set_antenna' \ - 'ch*annel:set channel:$phy_set_channel' \ - 'co*verage:set coverage class (1 for every 3 usec of air propagation time):$phy_set_coverage' \ - 'd*istance:set appropriate coverage class for given link distance in meters:$phy_set_distance' \ - 'fra*g:set fragmentation threshold:$phy_set_frag' \ - 'fre*q:set frequency/channel the hardware is using, including HT configuration:$phy_set_freq' \ - 'na*me:rename this wireless device:$phy_set_name' \ - 'ne*tns:set network namespace:$phy_set_netns' \ - 'r*ts:set rts threshold:$phy_set_rts' \ - 't*xpower:specify transmit power level and setting type:$phy_set_txpower' -phy_set_cmds=("$reply[@]") - -# Commands to go after "iw phy interface" -local -a phy_interface_cmds -# This needs work (should not offer meshid, fouraddr of flags more than once, and need to accomodate multiple flag options) -phy_interface_cmds=(\( /$'add\0'/ ':add:add a new virtual interface with the given configuration:(add)' $ifacename $ifacetype \ - \( $meshid \| $fouraddr \| $flags \) \# \)) - -# Commands to go after "iw phy " -local -a phy_cmds -_regex_words phy-commands "phy command" \ - 's*et:set/configure interface properties:$phy_set_cmds' \ - 'inf*o:show capabilities for the specified wireless device' \ - 'int*erface:add a new virtual interface with the given configuration:$phy_interface_cmds' \ - 'w*owlan:WoWLAN commands:$phy_wowlan_cmds' -phy_cmds=("$reply[@]") - -# Parameters to hold patterns for dev commands -local -a dev_cmds_connect dev_cmds_cqm dev_cmds_get dev_cmds_ibss dev_cmds_interface dev_cmds_mesh dev_cmds_scan_options -local -a dev_cmds_mpath dev_cmds_offchannel dev_cmds_roc dev_cmds_scan dev_cmds_set dev_cmds_station dev_cmds_survey -dev_cmds_connect=($ssid $frequency $bssid $key) -dev_cmds_cqm=(/$'rssi\0'/ ':rssi:rssi:(rssi)' $matchnum ':thresh:threshold:' $matchnum ':hysteresis:hysteresis:') -dev_cmds_get=(/$'(mesh_param|power_save)\0'/ ':get:parameter:(mesh_param power_save)' $value) -# TODO: THIS NEEDS WORK! THE FINAL OPTIONS FOR JOIN NEED WORK -# dev ibss join [fixed-freq] [] [beacon-interval ] [basic-rates ] [mcast-rate ] [key d:0:abcde] -dev_cmds_ibss=(\( /$'leave\0'/ ':cmd:command:((leave:"Leave the IBSS cell"))' \| \( /$'join\0'/ ':cmd:command:((join\:"Join an IBSS cell"))' $ssid $frequency \( /$'fixed-freq\0'/ ':opt:option:((fixed-freq\:"fixed frequency (no args)"))' \| $bssid \| /$'beacon-interval\0'/ ':opt:option:((beacon-interval\:"beacon interval (takes single arg)"))' $numvalue \| /$'basic-rates\0'/ ':opt:option:((basic-rates\:"basic rates (comma separated list of rates)"))' $numvalue \| /$'mcast-rate\0'/ ':opt:option:((mcast-rate\:"multicast rate (takes single arg)"))' $numvalue \| $key \) \# \) \)) -dev_cmds_interface=(/$'add\0'/ ':add:add:(add)' $ifacename $ifacetype \( $meshid \| $fouraddr \| $flags \) \# ) -dev_cmds_mesh=(\( /$'leave\0'/ ':leave:leave a mesh:(leave)' \| /$'join\0'/ ':join:join a mesh:(join)' \ - $matchnum ':meshid:mesh ID:' $matchany ':parameter:mesh parameters [=]*:' \# \)) -dev_cmds_mpath=(\( /$'(del|get)\0'/ ':mpath:mesh path command:((del\:"remove the mesh path to the given node" \ -get\:"get information on mesh path to the given node"))' $lladdr \| /$'(new|set)\0'/ ':mpath:mesh path \ -command:((new\:"create a new mesh path (instead of relying on automatic discovery)" set\:"set an existing mesh \ -paths next hop"))' $lladdr /$'next_hop\0'/ ':nexthop:next hop:(next_hop)' $lladdr \| /$'dump\0'/ ':mpath:mesh path \ -command:((dump\:"list known mesh paths"))' \)) -dev_cmds_offchannel=($frequency $matchnum ':duration:duration:') -dev_cmds_roc=(/$'start\0'/ ':start:start:(start)' $frequency $matchnum ':time:time:') -dev_cmds_scan_options=(/$'freq\0'/ ':freq:freq:(freq)' $frequency $frequency \# /$'ies\0'/ ':ies:ies:(ies)' $lladdr \( /$'ssid\0'/ ':ssid:ssid:(ssid)' $ssid \# \| /$'passive\0'/ ':opt:passive:(passive)' \)) -dev_cmds_scan=(\( $dev_cmds_scan_options \| $matchany -'! [[ $match[1] =~ "dump|trigger" ]]' ':opt:option:((-u\:"include unknown data in results" \:""))' $dev_cmds_scan_options \| /$'dump\0'/ ':cmd:command:((dump\:"dump the current scan results"))' $matchany ':opt:option:((-u\:"include unknown data in results" \:""))' \| /$'trigger\0'/ ':cmd:command:((trigger\:"trigger a scan on the given frequencies with probing for the given SSIDs (or wildcard if not given) unless passive scanning is requested"))' $dev_cmds_scan_options \)) -local -a dev_cmds_set_bitrates dev_cmds_set_freq dev_cmds_set_mesh_param -local -a dev_cmds_set_monitor dev_cmds_set_peer dev_cmds_set_power_save -local -a dev_cmds_set_type dev_cmds_set_txpower -# dev set bitrates [legacy-<2.4|5> *] -dev_cmds_set_bitrates=(/$'legacy-*\0'/ ':opt:legacy:(legacy-2.4 legacy-2.5)' $matchnum ':rate:legacy rate in Mbps:') -# dev set freq [HT20|HT40+|HT40-] -dev_cmds_set_freq=($frequency $high_throughput) -# dev set mesh_param = [=]* -dev_cmds_set_mesh_param=( $matchany ':val:param=value:' \# ) -# dev set monitor * -dev_cmds_set_monitor=( $matchany ':flag:flag:((none\:"no special flags" fcsfail\:"show frames with FCS errors"\ - control\:"show control frames" otherbss\:"show frames from other BSSes" cook\:"use cooked mode"))' \# ) -# dev set peer -dev_cmds_set_peer=($lladdr) -# dev set power_save -dev_cmds_set_power_save=(/$'(on|off)\0'/ ':opt:power save mode:(on off)') - -_regex_words setcmds "dev set commands" \ - '4*addr:set interface 4addr (WDS) mode:$fouronoff'\ - 'b*itrates:set/clear specified rate masks:$dev_cmds_set_bitrates'\ - 'c*hannel:set channel:$phy_set_channel'\ - 'f*req:set frequency:$dev_cmds_set_freq'\ - 'mesh_param:set mesh parameters:$dev_cmds_set_mesh_param'\ - 'meshid:set mesh id:$meshidval'\ - 'mo*nitor:set monitor flags:$dev_cmds_set_monitor'\ - 'pe*er:set interface WDS peer MAC address:$dev_cmds_set_peer'\ - 'po*wer_save:set power save on/off:$dev_cmds_set_power_save'\ - 'tx*power:set transmission power:$phy_set_txpower'\ - 'ty*pe:set type:$ifacetypes' -dev_cmds_set=("$reply[@]") - -local -a dev_cmds_station_plink dev_cmds_station_vlan -dev_cmds_station_plink=(/$'(open|block)\0'/ ':opt::(open block)') -dev_cmds_station_vlan=($matchnum ':val:ifindex:') - -local -a dev_cmds_station_set -_regex_words stationsetcmds "dev station set commands"\ - 'plink_action:set peer link action:$dev_cmds_station_plink'\ - 'vlan:set AP VLAN:$dev_cmds_station_vlan' -dev_cmds_station_set=(\( $lladdr \) "$reply[@]") - -_regex_words stationcmds "dev station commands" \ - 'del:remove the given station entry (use with caution!):$lladdr'\ - 'dump:list all stations known, e.g. the AP on managed interfaces:'\ - 'get:get information for a specific station:$lladdr'\ - 'set:set AP VLAN or mesh peer link action:$dev_cmds_station_set' -dev_cmds_station=("$reply[@]") - -dev_cmds_survey=(/$'dump\0'/ ':dump:list all gathered channel survey data:(dump)') - -local -a dev_cmds -_regex_words dev-commands "dev commands" \ - 'co*nnect:join a network:$dev_cmds_connect' \ - 'cq*m:set connection quality monitor RSSI threshold:$dev_cmds_cqm' \ - 'de*l:remove this virtual interface' \ - 'di*sconnect:disconnect from the current network' \ - 'g*et:retrieve mesh parameter / power save state:$dev_cmds_get' \ - 'ib*ss:join/leave IBSS cell:$dev_cmds_ibss' \ - 'inf*o:show information for this interface' \ - 'int*erface:add an interface:$dev_cmds_interface' \ - 'l*ink:print information about the current link, if any' \ - 'me*sh:join/leave a mesh:$dev_cmds_mesh' \ - 'mp*ath:mesh path commands:$dev_cmds_mpath' \ - 'o*ffchannel:leave operating channel and go to the given channel for a while:$dev_cmds_offchannel' \ - 'r*oc:roc:$dev_cmds_roc' \ - 'sc*an:scan:$dev_cmds_scan' \ - 'se*t:set interface parameter:$dev_cmds_set' \ - 'st*ation:station commands:$dev_cmds_station' \ - 'su*rvey:list all gathered channel survey data:$dev_cmds_survey' -dev_cmds=( $devices "$reply[@]") - -# Arguments to _regex_arguments, built up in array $args. -local -a args reply -# Command word. Don't care what that is. -args=( $matchany ) - -local -a phydevs -phy_devs=( \( $(iw list|grep '^[[:alnum:]]\+'|cut -f 2 -d ' ') \) ) -phy_cmds=( \( $matchany ":test:test:$phy_devs[*]" \) "$phy_cmds[@]" ) - -_regex_words commands "iw command" \ - 'd*ev:commands to control/list the software devices:$dev_cmds' \ - 'e*vent:monitor events from the kernel:$event_opts' \ - 'h*elp:print usage for each command' \ - 'l*ist:list all wireless devices and their capabilities' \ - 'p*hy:commands to control the physical device:$phy_cmds' \ - 'r*eg:get/set regulatory domain:$reg_cmds' -args+=("$reply[@]") - -_regex_arguments _iw "${args[@]}" - -_iw "$@" - -# Local Variables: -# mode:shell-script -# End: diff --git a/.zprezto/modules/completion/external/src/_jekyll b/.zprezto/modules/completion/external/src/_jekyll deleted file mode 100644 index ca119e6..0000000 --- a/.zprezto/modules/completion/external/src/_jekyll +++ /dev/null @@ -1,145 +0,0 @@ -#compdef jekyll -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for jekyll(http://jekyllrb.com) -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * farseer90718 (https://github.com/farseer90718) -# -# ------------------------------------------------------------------------------ - -local ret=1 state - -local -a common_ops -common_ops=( - {-v,--version}"[Display version information]" - {-h,--help}"[Display help documentation]" - {-p,--plugins}"[Plugins directory (defautls to ./_plugins)]: :_directories" - {-s,--source}"[Source directory (defaults to ./)]: :_directories" - {-d,--destination}"[Destination directory (defautls to ./_site)]: :_directories" - "--layouts=[Layouts directory (defaults to ./_layouts)]: :_directories" - "--safe=[Safe mode (defaults to false)]" -) - -typeset -A opt_args -_arguments \ - ':subcommand:->subcommand' \ - $common_ops \ - '*::options:->options' && ret=0 - -case $state in - subcommand) - local -a subcommands - subcommands=( - "build:Build your site" - "docs:Launch local server with docs for jekyll" - "doctor:Search site and print specific deprecation warnings" - "help:Display global or [command] help documentation" - "import:Import your old blog to Jekyll" - "new:Creates a new Jekyll site scaffold in PATH" - "serve:Serve your site locally" - ) - - _describe -t subcommands 'jekyll subcommand' subcommands && ret=0 - ;; - - options) - local -a args - args=( - $common_ops - ) - - local -a config - config=( - "--config[Custom configuration file]: :_files" - ) - local -a help - help=( - {-h,--help}"[Display help information]" - ) - local -a build - build=( - {-w,--watch}"[Watch for changes and rebuild]" - "--limit_posts[Limits the number of posts to parse and publish]" - "--future[Publishes posts with a future date]" - "--lsi[Use LSI for improved related posts]" - "--drafts[Render posts in the _drafts folder]" - ) - - case $words[1] in - help) - args=() - compadd "$@" build docs doctor help import new serve - ;; - - build) - args+=( - $build - $config - ) - ;; - - docs) - args=( - {-p,--port}"[Port to listen on]: :_ports" - {-u,--host}"[Host to bind to]: :_hosts" - $help - ) - ;; - - doctor) - args+=( - $config - ) - ;; - - import) - args=( - "--source[Source file or URL to migrate from]:url" - "--file[File to migrate from]: :_files" - "--dbname[Database name to migrate from]:database" - "--user[Username to use when migrating]:user" - "--pass[Password to use when migrating]:password" - "--host[Host address to use when migrating]:url" - $help - ) - ;; - - new) - args=( - ": :_directories" - "--force[Force creation even if PATH already exists]" - "--blank[Creates scaffolding but with empty files]" - $help - ) - ;; - - serve) - args+=( - $build - $config - {-P,--port}"[Port to listen on]: :_posts" - {-H,--host}"[Host to bind to]: :_hosts" - {-b,--baseurl}"[Base URL]:url" - ) - - esac - - _arguments $args && ret=0 - ;; -esac - -return ret - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_jmeter b/.zprezto/modules/completion/external/src/_jmeter index 762747b..c26db82 100644 --- a/.zprezto/modules/completion/external/src/_jmeter +++ b/.zprezto/modules/completion/external/src/_jmeter @@ -1,30 +1,5 @@ #compdef jmeter # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_jmeter-plugins b/.zprezto/modules/completion/external/src/_jmeter-plugins index 8c466ac..3253896 100644 --- a/.zprezto/modules/completion/external/src/_jmeter-plugins +++ b/.zprezto/modules/completion/external/src/_jmeter-plugins @@ -1,30 +1,5 @@ #compdef jmeter-plugins # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_jonas b/.zprezto/modules/completion/external/src/_jonas index 6aeb879..1965917 100644 --- a/.zprezto/modules/completion/external/src/_jonas +++ b/.zprezto/modules/completion/external/src/_jonas @@ -1,30 +1,5 @@ #compdef jonas # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_jrnl b/.zprezto/modules/completion/external/src/_jrnl new file mode 100644 index 0000000..c0c03e6 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_jrnl @@ -0,0 +1,65 @@ +#compdef jrnl +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for jrnl a simple journal application for your command line. (https://maebert.github.io/jrnl/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + + +_jrnl() { + + _arguments -C \ + '(- 1 *)'-h"[Show help and exit]" \ + '(- 1 *)'-v"[Prints version information and exits]" \ + '(- 1 *)'-ls"[Displays accessible journals]" \ + '(- 1 *)'-d"[Execute in debug mode]" \ + '(- 1 *)'--tags"[Returns a list of all tags and number of occurences]" \ + "--short[Show only titles or line containing the search]" \ + "-from[View entries after this date]:date:" \ + "-until[View entries before this date]:date:" \ + "-to[View entries before this date]:date:" \ + "-on[View entries on this date]:date:" \ + "-and[Filter by tags using AND (default: OR)]" \ + "-starred[Show only starred entries]" \ + "-n[Shows the last n entries matching the filter. And '-3' have the same effect.]":number: \ + "--export[Export your journal. TYPE can be json, markdown text.]:format:(json markdown text)" \ + "-o[Optionally specifies output file when using --export If OUTPUT is a directory, exports each entry in individual file instead.]:output file:" \ + "--encrypt[Encrypts your existing journal with a new pass]" \ + "--decrypt[Decrypts your journal and stores it in plain text]" \ +} + +_jrnl + diff --git a/.zprezto/modules/completion/external/src/_kak b/.zprezto/modules/completion/external/src/_kak new file mode 100644 index 0000000..9fd2540 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_kak @@ -0,0 +1,69 @@ +#compdef kak +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for kak (https://github.com/mawww/kakoune) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Frank LENORMAND +# +# ------------------------------------------------------------------------------ +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------ + +_kak_sessions() { + session_ids=($(_call_program session_ids kak -l)) + _values "${session_ids[@]}" +} + +_kak() { + _arguments \ + '-n[do not source rc files on startup]' \ + '-l[list existing sessions]:session_id:_kak_sessions' \ + '-clear[clear dead sessions]' \ + '-ro[readonly mode]' \ + '(-help --help)'{-help,--help}'[display a help message and quit]' \ + '-d[run as a headless session (requires -s)]' \ + '-q[in filter mode, be quiet about errors applying keys]' \ + '-c[connect to given session]:session_id:_kak_sessions' \ + '-e[execute argument on client initialisation]:keys' \ + '-E[execute argument on server initialisation]:keys' \ + '-s[set session name]:session_id' \ + '-p[just send stdin as commands to the given session]:session_id:_kak_sessions' \ + '-f[act as a filter, executing given keys on given files]:keys' \ + '-i[backup the files on which a filter is applied using the given suffix]:suffix' \ + '-ui[set the type of user interface to use (ncurses, dummy, or json)]:ui_type:(ncurses dummy json)' \ + '*::files:_files' +} + +_kak "$@" diff --git a/.zprezto/modules/completion/external/src/_knife b/.zprezto/modules/completion/external/src/_knife index be55e56..53aa9ac 100644 --- a/.zprezto/modules/completion/external/src/_knife +++ b/.zprezto/modules/completion/external/src/_knife @@ -1,5 +1,26 @@ #compdef knife # ------------------------------------------------------------------------------ +# Copyright (c) 2009-2015 Robby Russell and contributors (see +# https://github.com/robbyrussell/oh-my-zsh/contributors) +# +# 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. +# ------------------------------------------------------------------------------ # Description # ----------- # @@ -44,7 +65,7 @@ _knife() { case $state in knifecmd) - compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" environment user exec index node recipe role search ssh status windows $cloudproviders + compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" diff environment user exec index node recipe role search ssh status windows $cloudproviders ;; knifesubcmd) case $words[2] in @@ -60,6 +81,9 @@ _knife() { cookbook) compadd -Q "$@" test list create download delete "metadata from" show "bulk delete" metadata upload ;; + diff) + _arguments '*:file or directory:_files -g "*.(rb|json)"' + ;; environment) compadd -Q "$@" create delete edit "from file" list show ;; @@ -195,7 +219,7 @@ _chef_users_remote() { # The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server _chef_cookbooks_local() { - (for i in $( grep cookbook_path $HOME/.chef/knife.rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/' ); do ls $i; done) + (for i in $( grep cookbook_path $HOME/.chef/knife.rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/' | cut -d '"' -f2 ); do ls $i; done) } # This function extracts the available cookbook versions on the chef server diff --git a/.zprezto/modules/completion/external/src/_language_codes b/.zprezto/modules/completion/external/src/_language_codes index 19322ac..ef9d25a 100644 --- a/.zprezto/modules/completion/external/src/_language_codes +++ b/.zprezto/modules/completion/external/src/_language_codes @@ -1,30 +1,5 @@ #autoload # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_lein b/.zprezto/modules/completion/external/src/_lein deleted file mode 100644 index c1b988f..0000000 --- a/.zprezto/modules/completion/external/src/_lein +++ /dev/null @@ -1,62 +0,0 @@ -#compdef lein -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for Leiningen (https://github.com/technomancy/leiningen) -# -# Source: https://github.com/technolize/zsh-completion-funcs -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * technolize (https://github.com/technolize) -# -# ------------------------------------------------------------------------------ - -local ret=1 state -_arguments ':subcommand:->subcommand' && ret=0 - -case $state in - subcommand) - subcommands=( - "check:Check syntax and warn on reflection." - "classpath:Print the classpath of the current project." - "clean:Remove all files from project's target-path." - "compile:Compile Clojure source into .class files." - "deploy:Build and deploy jar to remote repository." - "deps:Download all dependencies." - "do:Higher-order task to perform other tasks in succession." - "help:Display a list of tasks or help for a given task." - "install:Install the current project to the local repository." - "jack-in:Jack in to a Clojure SLIME session from Emacs." - "jar:Package up all the project's files into a jar file." - "javac:Compile Java source files." - "new:Generate project scaffolding based on a template." - "pom:Write a pom.xml file to disk for Maven interoperability." - "pprint:Pretty-print a representation of the project map." - "repl:Start a repl session either with the current project or standalone." - "retest:Run only the test namespaces which failed last time around." - "run:Run a -main function with optional command-line arguments." - "search:Search remote maven repositories for matching jars." - "show-profiles:List all available profiles or display one if given an argument." - "test:Run the project's tests." - "trampoline:Run a task without nesting the project's JVM inside Leiningen's." - "uberjar:Package up the project files and dependencies into a jar file." - "upgrade:Upgrade Leiningen to specified version or latest stable." - "version:Print version for Leiningen and the current JVM." - "with-profile:Apply the given task with the profile(s) specified." - ) - _describe -t subcommands 'leiningen subcommands' subcommands && ret=0 -esac - -return ret - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_logger b/.zprezto/modules/completion/external/src/_logger deleted file mode 100644 index 2b25938..0000000 --- a/.zprezto/modules/completion/external/src/_logger +++ /dev/null @@ -1,61 +0,0 @@ -#compdef logger -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for logger (from bsdutils). -# -# Last updated: 26.02.2013 -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Valodim ( https://github.com/Valodim ) -# -# ------------------------------------------------------------------------------ - - -_logger_priority() { - local expl - - if compset -P '*.'; then - # hidden aliases.. not quite sure how this is supposed to work :\ - # compadd -n panic warning error - - # just this one tag - _wanted priority expl "Priority" \ - compadd -- debug info notice warn err crit alert emerg - return 0 - fi - - _wanted facility expl "Facility" \ - compadd -S '.' -- kern user mail daemon auth syslog lpr news \ - uucp cron security ftp ntp logaudit logalert clock \ - local0 local1 local2 local3 local4 local5 local6 local7 - return 0 - -} - -_logger() { - - local curcontext="$curcontext" state line - typeset -A opt_args - - _arguments -C -S -s \ - {-d,--udp}'[use UDP (TCP is default)]' \ - {-i,--id}'[log the process ID too]' \ - {-f,--file}'[log the contents of this file]:Logfile:_files' \ - '(-)'{-h,--help}'[display this help text and exit]' \ - {-n,--server}'[write to this remote syslog server]:Server:_hosts' \ - {-P,--port}'[use this UDP port]:UDP Port' \ - {-p,--priority}'[mark given message with this priority]:Priority:_logger_priority' \ - {-s,--stderr}'[output message to standard error as well]' \ - {-t,--tag}'[mark every line with this tag]:Tag' \ - {-u,--socket}'[write to this Unix socket]:Socket:_files -W *(=)' \ - '(-)'{-V,--version}'[output version information and exit]' \ - '*:Message:' && return 0 - -} - -_logger "$@" diff --git a/.zprezto/modules/completion/external/src/_lsattr b/.zprezto/modules/completion/external/src/_lsattr new file mode 100644 index 0000000..3d936fe --- /dev/null +++ b/.zprezto/modules/completion/external/src/_lsattr @@ -0,0 +1,54 @@ +#compdef lsattr +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for lsattr a tool which lists file attributes on a Linux second extended file system. (http://e2fsprogs.sourceforge.net/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + + +_lsattr() { + +_arguments -C \ + "(-d)-R[Recursively list attributes of directories and their contents.]" \ + "-V[Display the program version.]" \ + "(-d)-a[List all files in directories, including files that start with '.']" \ + "(-a -R)-d[List directories like other files, rather than listing their contents.]" \ + "-v[List the file\'s version/generation number.]" \ + '*:files:_files' \ +} + +_lsattr + diff --git a/.zprezto/modules/completion/external/src/_lsblk b/.zprezto/modules/completion/external/src/_lsblk new file mode 100644 index 0000000..4040338 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_lsblk @@ -0,0 +1,97 @@ +#compdef lsblk +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for lsblk (from util-linux 2.27.1->) +# (https://git.kernel.org/cgit/utils/util-linux/util-linux.git/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Ole Jørgen Brønner +# +# ------------------------------------------------------------------------------ +# +# Note: lsblk has upstream bash completions, which has served as a guide +# Note: Credit to https://github.com/RobSis/zsh-completion-generator which was +# used to generate an initial skeleton + +local arguments + +local lsblk_cols_all=( + NAME KNAME MAJ:MIN FSTYPE MOUNTPOINT + LABEL UUID PARTTYPE PARTLABEL PARTUUID PARTFLAGS + RA RO RM + MODEL SIZE STATE OWNER GROUP MODE + ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC + ROTA SCHED RQ-SIZE TYPE DISC-ALN + DISC-GRAN DISC-MAX DISC-ZERO WSAME WWN + RAND PKNAME HCTL TRAN REV VENDOR) + +_lsblk_columns() { + compadd $@ $lsblk_cols_all +} + +_lsblk_major_number() { + # /sys/dev/block/ contains MAJOR:MINOR symlinks. eg. 7:0 + local device_paths=(/sys/dev/block/*(N)) + local major_numbers=(${${device_paths##*/}%%:*}) + # major_numbers might have duplicates but compadd handles that + compadd $@ $major_numbers +} + +arguments=( + '(-a --all)'{-a,--all}'[print all devices]' + '(-b --bytes)'{-b,--bytes}'[print size in bytes rather than in human readable format]' + '(-d --nodeps)'{-d,--nodeps}'[dont print slaves or holders]' + '(-D --discard)'{-D,--discard}'[print discard capabilities]' + '(-e --exclude)'{-e,--exclude}'[exclude devices by major number]:major number:_sequence _lsblk_major_number' + '(-f --fs)'{-f,--fs}'[output info about filesystems]' + '(-i --ascii)'{-i,--ascii}'[use ascii characters only]' + '(-I --include)'{-I,--include}'=[show only devices with specified major numbers]:major number:_sequence _lsblk_major_number' + '(-J --json)'{-J,--json}'[use JSON output format]' + '(-l --list)'{-l,--list}'[use list format output]' + '(-m --perms)'{-m,--perms}'[output info about permissions]' + '(-n --noheadings)'{-n,--noheadings}'[dont print headings]' + '(-o --output)'{-o,--output}'=[specify output columns]:output column:_sequence _lsblk_columns' + '(-O --output-all)'{-O,--output-all}'[output all columns]' + '(-p --paths)'{-p,--paths}'[print complete device path]' + '(-P --pairs)'{-P,--pairs}'[use key="value" output format]' + '(-r --raw)'{-r,--raw}'[use raw output format]' + '(-s --inverse)'{-s,--inverse}'[inverse dependencies]' + '(-S --scsi)'{-S,--scsi}'[output info about SCSI devices]' + '(-t --topology)'{-t,--topology}'[output info about topology]' + '(-x --sort)'{-x,--sort}'=[sort output by specified column]:sort column:_lsblk_columns' + '(-h --help)'{-h,--help}'[display this help and exit]' + '(-V --version)'{-V,--version}'[output version information and exit]' + '*:device:_path_files -g "*(N-%) *(N-/)"' +) + +_arguments -s $arguments diff --git a/.zprezto/modules/completion/external/src/_lunar b/.zprezto/modules/completion/external/src/_lunar deleted file mode 100644 index 19b4832..0000000 --- a/.zprezto/modules/completion/external/src/_lunar +++ /dev/null @@ -1,314 +0,0 @@ -#compdef lunar lin lrm lvu -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for Lunar (http://www.lunar-linux.org) -# -# Source: https://github.com/Valodim/lunar-zsh-completion -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Valodim (https://github.com/Valodim) -# -# ------------------------------------------------------------------------------ - - -# completion for lunar itself (different name, see below) -_lunar_comp() { - local suf ret=1 curcontext="$curcontext" - local -a vals state line expl - - # regular arguments, this will probably just hand down to the * command below - _arguments -C \ - '(- :)-d[Enables debug messages]' \ - '(- :)-h[Display help text]' \ - '(- :)-v[Increases the level of message output]' \ - '*::command:->command' && return 0 - - # complete the first word, ie. subcommand - if (( CURRENT == 1 )); then - local -a lunar_commands - # all lunar subcommands - lunar_commands=( - 'prune:Removes old sources and install/compile logs' - 'renew:Checks ver. against moonbase & recompiles if necessary' - 'update:Fetches latest moonbase and then does a "renew"' - 'rebuild:Recompiles all installed modules' - 'optimize:Shortcut to the optimization menu' - 'fix:Check and fix all modules and internal state of lunar' - 'nofix:Check but do not fix modules and internal state' - 'fixdepends:Check and fix the dependency database of lunar' - 'set:Check internal variable(s) and assign their values' - 'unset:Unsets an internal variable' - 'resurrect:Force modulename(s) to be unpacked from /var/cache' - 'install:Install a checklist of modules' - 'remove:Remove a checklist of modules' - 'hold:Place a hold on a checklist of modules' - 'unhold:Remove a hold on a checklist of modules' - 'exile:Remove a module a/o prevent it from being resurrected' - 'unexile:Allows a module to be compiled|resurrected again') - - # just show the commands with description - _describe -t commands 'lunar command' lunar_commands && ret=0 - return ret - else - - # at this point, we have to decide what to complete for specific subcommands - - # make a list of subcommands with no further arguments for later - local -a lunar_no_args - lunar_no_args=( prune renew update rebuild optimize fix nofix fixdepends ) - - # update the current context - curcontext="${curcontext%:*:*}:lunar-$words[1]:" - # if there is a specific function of the form _lunar-subcommand - if (( $+functions[_lunar-$words[1]] )); then - # call that for completion - _call_function ret _lunar-$words[1] - elif [[ -n "${lunar_no_args[(r)${words[1]}]}" ]]; then - # all commands from the array above take no further arguments - _message "lunar ${words[1]} requires no arguments" - else - # by default, complete modules - _lunar_modules - fi - return ret - fi -} - -# specific completion for lunar set -_lunar-set() { - # second argument: all lunar variables - if (( CURRENT == 2 )); then - local vars - vars=( ${(f)"$(cat /var/lib/lunar/unset.sh | cut -d' ' -f2)"} ) - _describe -t modules 'lunar variable' vars && return 0 - # third argument: some value - elif (( CURRENT == 3 )); then - _message "value" - # no further argument - else - _message "no further arguments" - fi -} - -_lunar-unset() { - local vars - vars=( ${(f)"$(cat /var/lib/lunar/unset.sh | cut -d' ' -f2)"} ) - _describe -t modules 'lunar variable' vars && return 0 -} - -_lunar-unhold() { - local vals - vals=( ${(f)"$(lvu held | sort | uniq)"} ) - _describe -t modules 'held modules' vals && return 0 -} - -_lunar-unexile() { - local vals - vals=( ${(f)"$(lvu exiled | sort | uniq)"} ) - _describe -t modules 'exiled modules' vals && return 0 -} - -_lrm() { - _arguments \ - '(-d --debug)'{-d,--debug}'[Enables debug messages]' \ - '(-D --downgrade)'{-D,--downgrade}'[downgrades a module]:module:_lunar_modules:version' \ - '(-h --help)'{-h,--help}'[Displays this help text]' \ - '(-k --keepconfig)'{-k,--keepconfig}'[remove module(s) but keep dependencies and config]' \ - '(-n --nosustain)'{-n,--nosustain}'[removes module(s) even if they are sustained]' \ - '(-u --upgrade)'{-u,--upgrade}'[remove the module but do not run scripts etc.]' \ - '(-v --verbose)'{-v,--verbose}'[Increases the level of message output]' \ - '(-p --purge)'{-p,--purge}'[Delete all modules that depend on the module(s) being removed as well]' \ - '*:module:_lunar_installed_modules' && return 0 -} - -_lin() { - _arguments \ - '(-c --compile)'{-c,--compile}'[Ignore /var/cache/lunar and compiles]' \ - '(-d --debug)'{-d,--debug}'[Enables debug messages]' \ - '--deps[Configure modules and determine dependencies]' \ - '(-f --from)'{-f,--from}'[Specify an alternate for /var/spool/lunar]:directory:_files -/' \ - '(-h --help)'{-h,--help}'[Displays help text]' \ - '--opts[Add custom configure options to the module]:configure option string' \ - '(-p --probe)'{-p,--probe}'[Only lin if not already installed]' \ - '(-r --reconfigure)'{-r,--reconfigure}'[Select new dependencies for modules]' \ - '(-R --resurrect)'{-R,--resurrect}'[Force to be unpacked from /var/cache/lunar]' \ - '(-s --silent)'{-s,--silent}'[Decreases the level of message output]' \ - '(-v --verbose)'{-v,--verbose}'[Increases the level of message output]' \ - '(-w --want)'{-w,--want}'[Try to install a different version]:wanted version' \ - '*:module:_lunar_modules' && return 0 -} - -# completion for lvu, very similar to the lunar one above (therefore uncommented) -_lvu() { - local suf ret=1 curcontext="$curcontext" - local -a vals state line expl - - _arguments -C \ - '(- :)-d[Enables debug messages]' \ - '(- :)-h[Display help text]' \ - '(- :)-v[Increases the level of message output]' \ - '*::command:->command' && return 0 - - if (( CURRENT == 1 )); then - local -a lvu_commands - lvu_commands=( - 'what:display a module''s description' - 'short:display a module''s short description' - 'where:display a module''s section' - 'cd:change directory to module and execs a new shell' - 'alien:discover untracked files' - 'from:discover what installed a given file' - 'leafs:display installed modules that have no explicit dependencies on them' - 'orphans:display installed modules that are missing dependencies' - 'conflicts:display conflicting files' - 'held:display held modules' - 'exiled:display exiled modules' - 'expired:display a list of modules which need an update' - 'info:display terse summary information about module' - 'search:searches all modules long descriptions for phrase.' - 'service:displays modules that provide that service' - 'website:display a module''s website' - 'install:display an install log' - 'size:find and show installed size of a module or ALL (slow)' - 'installed:display installed modules/version of module' - 'compile:display a compile log' - 'compiler:display the compiler version used' - 'links:display a list of modules that this module links to' - 'sources:display source files for a module' - 'urls:display all URLs for a module' - 'maintainer:display maintainer for a module' - 'version:display version of module in moonbase' - 'new:attempt to create a new module from scratch' - 'edit:copy a module to zlocal for editing' - 'diff:view changes on edited module' - 'submit:attempt to submit a module to the lunar ML' - 'unedit:delete zlocal copy of a module' - 'sum:display checksums' - 'md5sum:display md5sums' - 'export:make snapshot of box''s configuration.' - 'import:restores an exported snapshot.' - 'section:display moonbase sections' - 'moonbase:display text listing of the moonbase' - 'html:display html listing of the moonbase' - 'updatelog:display summary log of previous lunar update' - 'activity:display main log file' - 'newer:display available modules newer than Aug 01, 2003' - 'older:display modules installed before Jan 01, 2003' - 'voyeur:peak into module compilation' - 'pam:display installed modules that are Linux-PAM aware' - 'depends:displays installed modules that explicitly or recursively depend on this module.' - 'tree:displays a tree of the module''s dependencies' - 'stree:same as ''tree'' but highly abbreviated' - 'eert:same as ''tree'' but reverse and installed deps only' - 'leert:full reverse dependency tree') - - _describe -t commands 'lvu command' lvu_commands && ret=0 - - return ret - elif (( CURRENT == 2 )); then - local -a lvu_no_args - lvu_no_args=( alien leafs orphans conflicts held exiled expired export moonbase html updatelog pam ) - - curcontext="${curcontext%:*:*}:lvu-$words[1]:" - if (( $+functions[_lvu-$words[1]] )); then - _call_function ret _lvu-$words[1] - elif [[ -n "${lvu_no_args[(r)${words[1]}]}" ]]; then - _message "lvu ${words[1]} requires no arguments" - else - _lunar_modules - fi - return ret - else - _message "No further arguments" - fi - -} - -_lvu-service() { - _alternative \ - 'service:service name:_lvu-service-service' \ - 'port:port number:_guard "[0-9]#" "port number"' -} - -_lvu-service-service() { - local vals - vals=( ${(f)"$(cat /etc/services | grep -E -o '^(\w+)' | sort | uniq)"} ) - _describe -t modules 'service' vals && return 0 -} - -_lvu-diff() { - local vals - vals=( /var/lib/lunar/moonbase/zlocal/*(/:t) ) - _describe -t modules 'moonbase module from zlocal' vals && return 0 -} - -_lvu-unedit() { - local vals - vals=( /var/lib/lunar/moonbase/zlocal/*(/:t) ) - _describe -t modules 'moonbase module from zlocal' vals && return 0 -} - -_lvu-newer() { - _message "date string" -} - -_lvu-older() { - _message "date string" -} - -_lvu-import() { - _files -} - -_lvu-from() { - _files -} - -_lvu-new() { - _message "module name" -} - -_lvu-search() { - _message "search string" -} - -# specific completion for moonbase modules -_lunar_modules() { - local vals - vals=( /var/lib/lunar/moonbase/*/*(/:t) ) - _describe -t modules 'moonbase module' vals && return 0 -} - -# specific completion for moonbase modules -_lunar_installed_modules() { - local vals - vals=( ${(f)"$(lvu installed | cut -d':' -f1)"} ) - _describe -t modules 'moonbase installed module' vals && return 0 -} - -# hub function called for completion -_lunar() { - # decide which completion to use - case "$service" in - lin) _lin "$@";; - lrm) _lrm "$@";; - lvu) _lvu "$@";; - lunar) _lunar_comp "$@";; - *) _message "unknown command $service";; - esac -} - -_lunar "$@" - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_lunchy b/.zprezto/modules/completion/external/src/_lunchy index 652c186..38cbda9 100644 --- a/.zprezto/modules/completion/external/src/_lunchy +++ b/.zprezto/modules/completion/external/src/_lunchy @@ -1,5 +1,30 @@ #compdef lunchy # ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_manage.py b/.zprezto/modules/completion/external/src/_manage.py deleted file mode 100644 index 7b6ccda..0000000 --- a/.zprezto/modules/completion/external/src/_manage.py +++ /dev/null @@ -1,270 +0,0 @@ -#compdef manage.py django-admin.py -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for Django's manage.py (https://www.djangoproject.com). -# -# Source: https://github.com/technolize/zsh-completion-funcs -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * technolize (https://github.com/technolize) -# -# ------------------------------------------------------------------------------ - - -_managepy-cleanup(){} -_managepy-compilemessages(){} - -_managepy-createcachetable(){ - _arguments -s : \ - $nul_args && ret=0 -} - -_managepy-dbshell(){ - _arguments -s : \ - $nul_args && ret=0 -} - -_managepy-diffsettings(){ - _arguments -s : \ - $nul_args && ret=0 -} - -_managepy-dumpdata(){ - _arguments -s : \ - '--format=-[specifies the output serialization format for fixtures.]:format:(json yaml xml)' \ - '--indent=-[specifies the indent level to use when pretty-printing output.]:' \ - $nul_args \ - '*::appname:_applist' && ret=0 -} - -_managepy-flush(){ - _arguments -s : \ - '--verbosity=-[verbosity level; 0=minimal output, 1=normal output, 2=all output.]:Verbosity:((0\:minimal 1\:normal 2\:all))' \ - '--noinput[tells Django to NOT prompt the user for input of any kind.]' \ - $nul_args && ret=0 -} - -_managepy-help(){ - _arguments -s : \ - '*:command:_managepy_cmds' \ - $nul_args && ret=0 -} - -_managepy_cmds(){ - local line - local -a cmd - _call_program help-command ./manage.py help \ - |& sed -n '/^ /s/[(), ]/ /gp' \ - | while read -A line; do cmd=($line $cmd) done - _describe -t managepy-command 'manage.py command' cmd -} - -_managepy-inspectdb(){ - _arguments -s : \ - $nul_args && ret=0 -} - -_managepy-loaddata(){ - _arguments -s : \ - '--verbosity=-[verbosity level; 0=minimal output, 1=normal output, 2=all output.]:Verbosity:((0\:minimal 1\:normal 2\:all))' \ - '*::file:_files' \ - $nul_args && ret=0 -} - -_managepy-makemessages(){} - -_managepy-reset(){ - _arguments -s : \ - '--noinput[tells Django to NOT prompt the user for input of any kind.]' \ - '*::appname:_applist' \ - $nul_args && ret=0 -} - -_managepy-runfcgi(){ - local state - - local fcgi_opts - fcgi_opts=( - 'protocol[fcgi, scgi, ajp, ... (default fcgi)]:protocol:(fcgi scgi ajp)' - 'host[hostname to listen on..]:' - 'port[port to listen on.]:' - 'socket[UNIX socket to listen on.]::file:_files' - 'method[prefork or threaded (default prefork)]:method:(prefork threaded)' - 'maxrequests[number of requests a child handles before it is killed and a new child is forked (0 = no limit).]:' - 'maxspare[max number of spare processes / threads.]:' - 'minspare[min number of spare processes / threads.]:' - 'maxchildren[hard limit number of processes / threads.]:' - 'daemonize[whether to detach from terminal.]:boolean:(False True)' - 'pidfile[write the spawned process-id to this file.]:file:_files' - 'workdir[change to this directory when daemonizing.]:directory:_files' - 'outlog[write stdout to this file.]:file:_files' - 'errlog[write stderr to this file.]:file:_files' - ) - - _arguments -s : \ - $nul_args \ - '*: :_values "FCGI Setting" $fcgi_opts' && ret=0 -} - -_managepy-runserver(){ - _arguments -s : \ - '--noreload[tells Django to NOT use the auto-reloader.]' \ - '--adminmedia[specifies the directory from which to serve admin media.]:directory:_files' \ - $nul_args && ret=0 -} - -_managepy-shell(){ - _arguments -s : \ - '--plain[tells Django to use plain Python, not IPython.]' \ - $nul_args && ret=0 -} - -_managepy-sql(){} -_managepy-sqlall(){} -_managepy-sqlclear(){} -_managepy-sqlcustom(){} -_managepy-sqlflush(){} -_managepy-sqlindexes(){} -_managepy-sqlinitialdata(){} -_managepy-sqlreset(){} -_managepy-sqlsequencereset(){} -_managepy-startapp(){} - -_managepy-startproject(){ - _arguments -s : \ - "(-v --verbosity)"{-v,--verbosity}"[Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output.]:Verbosity:((0\:minimal 1\:normal 2\:verbose 4\:very\ verbose))" \ - '--template[The path or URL to load the template from.]:file:_files' \ - "(-e --extension)"{-e,--extension}"[The file extension(s) to render (default: "py"). Separate multiple extensions with commas, or use -e multiple times.]" \ - "(-n --name)"{-n,--name}"[The file name(s) to render. Separate multiple extensions with commas, or use -n multiple times. --version show program\'s version number and exit]:file:_files" \ - $nul_args \ - '*::args:_gnu_generic' -} - -_managepy-syncdb() { - _arguments -s : \ - '--verbosity=-[verbosity level; 0=minimal output, 1=normal output, 2=all output.]:Verbosity:((0\:minimal 1\:normal 2\:all))' \ - '--noinput[tells Django to NOT prompt the user for input of any kind.]' \ - $nul_args && ret=0 -} - -_managepy-test() { - _arguments -s : \ - '--verbosity=-[verbosity level; 0=minimal output, 1=normal output, 2=all output.]:Verbosity:((0\:minimal 1\:normal 2\:all))' \ - '--noinput[tells Django to NOT prompt the user for input of any kind.]' \ - '*::appname:_applist' \ - $nul_args && ret=0 -} - -_managepy-testserver() { - _arguments -s : \ - '--verbosity=-[verbosity level; 0=minimal output, 1=normal output, 2=all output.]:Verbosity:((0\:minimal 1\:normal 2\:all))' \ - '--addrport=-[port number or ipaddr:port to run the server on.]' \ - '*::fixture:_files' \ - $nul_args && ret=0 -} - -_managepy-validate() { - _arguments -s : \ - $nul_args && ret=0 -} - -_managepy-changepassword(){} -_managepy-createsuperuser(){} -_managepy-collectstatic(){} -_managepy-findstatic(){} - -_managepy-commands() { - local -a commands - - commands=( - 'cleanup:Can be run as a cronjob or directly to clean out old data from the database (only expired sessions at the moment).' - 'compilemessages:Compiles .po files to .mo files for use with builtin gettext support.' - 'createcachetable:creates the table needed to use the SQL cache backend.' - 'dbshell:runs the command-line client for the current DATABASE_ENGINE.' - "diffsettings:displays differences between the current settings.py and Django's default settings." - 'dumpdata:Output the contents of the database as a fixture of the given format.' - 'flush:Executes ``sqlflush`` on the current database.' - 'help:manage.py help.' - 'inspectdb:Introspects the database tables in the given database and outputs a Django model module.' - 'loaddata:Installs the named fixture(s) in the database.' - 'makemessages:Runs over the entire source tree of the current directory and pulls out all strings marked for translation.' - 'reset:Executes ``sqlreset`` for the given app(s) in the current database.' - 'runfcgi:Run this project as a fastcgi (or some other protocol supported by flup) application,' - 'runserver:Starts a lightweight Web server for development.' - 'shell:Runs a Python interactive interpreter.' - 'sql:Prints the CREATE TABLE SQL statements for the given app name(s).' - 'sqlall:Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s).' - 'sqlclear:Prints the DROP TABLE SQL statements for the given app name(s).' - 'sqlcustom:Prints the custom table modifying SQL statements for the given app name(s).' - 'sqlflush:Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed.' - 'sqlindexes:Prints the CREATE INDEX SQL statements for the given model module name(s).' - "sqlinitialdata:RENAMED: see 'sqlcustom'" - 'sqlreset:Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s).' - 'sqlsequencereset:Prints the SQL statements for resetting sequences for the given app name(s).' - "startapp:Creates a Django app directory structure for the given app name in this project's directory." - "startproject:Creates a Django project directory structure for the given project name in the current directory or the given destination." - "syncdb:Create the database tables for all apps in INSTALLED_APPS whose tables haven't already been created." - 'test:Runs the test suite for the specified applications, or the entire site if no apps are specified.' - 'testserver:Runs a development server with data from the given fixture(s).' - 'validate:Validates all installed models.' - ) - if [[ $words[1] =~ "manage.py$" ]]; then - commands=($commands - "changepassword:Change a user's password for django.contrib.auth." - 'createsuperuser:Used to create a superuser.' - 'collectstatic:Collect static files in a single location.' - 'findstatic:Finds the absolute paths for the given static file(s).' - ) - fi - - _describe -t commands 'manage.py command' commands && ret=0 -} - -_applist() { - local line - local -a apps - _call_program help-command "python -c \"import os.path as op, re, settings, sys;\\ - bn=op.basename(op.abspath(op.curdir));[sys\\ - .stdout.write(str(re.sub(r'^%s\.(.*?)$' % - bn, r'\1', i)) + '\n') for i in settings.\\ - INSTALLED_APPS if re.match(r'^%s' % bn, i)]\"" \ - | while read -A line; do apps=($line $apps) done - _values 'Application' $apps && ret=0 -} - -_manage.py() { - local -a nul_args - nul_args=( - '--settings=-[the Python path to a settings module.]:file:_files' - '--pythonpath=-[a directory to add to the Python path.]::directory:_directories' - '--traceback[print traceback on exception.]' - "--version[show program's version number and exit.]" - {-h,--help}'[show this help message and exit.]' - ) - - local curcontext=$curcontext ret=1 - - if ((CURRENT == 2)); then - _managepy-commands - else - shift words - (( CURRENT -- )) - curcontext="${curcontext%:*:*}:managepy-$words[1]:" - _call_function ret _managepy-$words[1] - fi -} - -_manage.py "$@" - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_middleman b/.zprezto/modules/completion/external/src/_middleman index 6c18551..cbcebf2 100644 --- a/.zprezto/modules/completion/external/src/_middleman +++ b/.zprezto/modules/completion/external/src/_middleman @@ -1,5 +1,25 @@ #compdef middleman # ------------------------------------------------------------------------------ +# Copyright (c) 2013 Jozef Izso, 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. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_mina b/.zprezto/modules/completion/external/src/_mina index 2a8d935..01b06f2 100644 --- a/.zprezto/modules/completion/external/src/_mina +++ b/.zprezto/modules/completion/external/src/_mina @@ -1,5 +1,30 @@ #compdef mina # ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_mix b/.zprezto/modules/completion/external/src/_mix new file mode 100644 index 0000000..bb4233f --- /dev/null +++ b/.zprezto/modules/completion/external/src/_mix @@ -0,0 +1,235 @@ +#compdef mix +#autoload + +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Elixir Mix +# +# Last updated: 18.04.2017 +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Han Ngo (https://github.com/tieubao) +# * Teja Sophista (https://github.com/tejanium) +# +# ------------------------------------------------------------------------------ + +local -a _1st_arguments +_1st_arguments=( + 'app.start:Starts all registered apps' + 'app.tree:Prints the application tree' + 'archive:Lists installed archives' + 'archive.build:Archives this project into a .ez file' + 'archive.install:Installs an archive locally' + 'archive.uninstall:Uninstalls archives' + 'clean:Deletes generated application files' + 'cmd:Executes the given command' + 'compile:Compiles source files' + 'deps:Lists dependencies and their status' + "deps.clean:Deletes the given dependencies' files" + 'deps.compile:Compiles dependencies' + 'deps.get:Gets all out of date dependencies' + 'deps.tree:Prints the dependency tree' + 'deps.unlock:Unlocks the given dependencies' + 'deps.update:Updates the given dependencies' + 'do:Executes the tasks separated by comma' + 'ecto:Prints Ecto help information' + 'ecto.create:Creates the repository storage' + 'ecto.drop:Drops the repository storage' + 'ecto.dump:Dumps the repository database structure' + 'ecto.gen.migration:Generates a new migration for the repo' + 'ecto.gen.repo:Generates a new repository' + 'ecto.load:Loads previously dumped database structure' + 'ecto.migrate:Runs the repository migrations' + 'ecto.migrations:Displays the repository migration status' + 'ecto.rollback:Rolls back the repository migrations' + 'escript:Lists installed escripts' + 'escript.build:Builds an escript for the project' + 'escript.install:Installs an escript locally' + 'escript.uninstall:Uninstalls escripts' + 'gettext.extract:Extracts translations from source code' + 'gettext.merge:Merge template files into translation files' + 'help:Prints help information for tasks' + 'hex:Prints Hex help information' + 'hex.build:Builds a new package version locally' + 'hex.config:Reads, updates or deletes Hex config' + 'hex.docs:Fetch or open documentation of a package' + 'hex.info:Prints Hex information' + 'hex.key:Manages Hex API key' + 'hex.outdated:Shows outdated Hex deps for the current project' + 'hex.owner:Manages Hex package ownership' + 'hex.public_keys:Manages Hex public keys' + 'hex.publish:Publishes a new package version' + 'hex.retire:Retires a package version' + 'hex.search:Searches for package names' + 'hex.user:Registers or manages Hex user' + 'loadconfig:Loads and persists the given configuration' + 'local:Lists local tasks' + 'local.hex:Installs Hex locally' + 'local.phoenix:Updates Phoenix locally' + 'local.phx:Updates the Phoenix project generator locally' + 'local.public_keys:Manages public keys' + 'local.rebar:Installs Rebar locally' + 'new:Creates a new Elixir project' + 'phoenix.gen.html:Generates controller, model and views for an HTML based resource' + 'phoenix.server:Starts applications and their servers' + 'phx.digest:Digests and compresses static files' + 'phx.digest.clean:Removes old versions of static assets.' + 'phx.gen.channel:Generates a Phoenix channel' + 'phx.gen.context:Generates a context with functions around an Ecto schema' + 'phx.gen.html:Generates controller, views, and context for an HTML resource' + 'phx.gen.json:Generates controller, views, and context for a JSON resource' + 'phx.gen.presence:Generates a Presence tracker' + 'phx.gen.schema:Generates an Ecto schema and migration file' + 'phx.gen.secret:Generates a secret' + 'phx.new:Creates a new Phoenix application' + 'phx.new.ecto:Creates a new Ecto project within an umbrella project' + 'phx.new.web:Creates a new Phoenix web project within an umbrella project' + 'phx.routes:Prints all routes' + 'phx.server:Starts applications and their servers' + 'profile.fprof:Profiles the given file or expression with fprof' + 'run:Runs the given file or expression' + "test:Runs a project's tests" + 'xref:Performs cross reference checks' + '--help:Describe available tasks' + '--version:Prints the Elixir version information' +) + +__task_list () +{ + local expl + declare -a tasks + + tasks=( + 'app.start' + 'app.tree' + 'archive' + 'archive.build' + 'archive.install' + 'archive.uninstall' + 'clean' + 'cmd' + 'compile' + 'deps' + 'deps.clean' + 'deps.compile' + 'deps.get' + 'deps.tree' + 'deps.unlock' + 'deps.update' + 'do' + 'ecto' + 'ecto.create' + 'ecto.drop' + 'ecto.dump' + 'ecto.gen.migration' + 'ecto.gen.repo' + 'ecto.load' + 'ecto.migrate' + 'ecto.migrations' + 'ecto.rollback' + 'escript' + 'escript.build' + 'escript.install' + 'escript.uninstall' + 'gettext.extract' + 'gettext.merge' + 'help' + 'hex' + 'hex.build' + 'hex.config' + 'hex.docs' + 'hex.info' + 'hex.key' + 'hex.outdated' + 'hex.owner' + 'hex.public_keys' + 'hex.publish' + 'hex.retire' + 'hex.search' + 'hex.user' + 'loadconfig' + 'local' + 'local.hex' + 'local.public_keys' + 'local.rebar' + 'new' + 'phoenix.gen.html' + 'phoenix.server' + 'phx.digest' + 'phx.digest.clean' + 'phx.gen.channel' + 'phx.gen.context' + 'phx.gen.html' + 'phx.gen.json' + 'phx.gen.presence' + 'phx.gen.schema' + 'phx.gen.secret' + 'phx.routes' + 'phx.server' + 'profile.fprof' + 'run' + 'test' + 'xref' + ) + + _wanted tasks expl 'help' compadd $tasks +} + +local expl + +local curcontext="$curcontext" state line +typeset -A opt_args + +_arguments -C \ + ':command:->command' \ + '*::options:->options' + +case $state in + (command) + _describe -t commands "mix subcommand" _1st_arguments + return + ;; + + (options) + case $line[1] in + (help) + _arguments ':feature:__task_list' + return + ;; + (test) + _arguments ':PATH:_files' + return + ;; + esac + ;; +esac diff --git a/.zprezto/modules/completion/external/src/_mosh b/.zprezto/modules/completion/external/src/_mosh deleted file mode 100644 index f0c8a9d..0000000 --- a/.zprezto/modules/completion/external/src/_mosh +++ /dev/null @@ -1,35 +0,0 @@ -#compdef mosh -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for mosh (http://mosh.mit.edu). -# -# Source: https://gist.github.com/2242920 -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Ben O'Hara (https://github.com/benohara) -# -# ------------------------------------------------------------------------------ - -_arguments \ - '--client=:client helper:_command_names -e' \ - '--server=:server helper:_files' \ - '--ssh=:ssh command to run:_files' \ - '(-a -n)--predict=:when:(adaptive always never)' \ - '(--predict -n)-a[predict always]' \ - '(--predict -a)-n[predict never]' \ - {-p,--port=}':port:_ports' \ - ':remote:_hosts' \ - ':remote command:_command_names -e' - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_multirust b/.zprezto/modules/completion/external/src/_multirust new file mode 100644 index 0000000..00deb67 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_multirust @@ -0,0 +1,163 @@ +#compdef multirust +# ------------------------------------------------------------------------------ +# Copyright (C) 2016 by Hideo Hattori +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for multirust (https://github.com/brson/multirust). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Hideo Hattori (https://github.com/hhatto) +# +# ------------------------------------------------------------------------------ + +_multirust() { + typeset -A opt_args + local context state line + + _arguments -s -S \ + "--verbose[run verbosely]" \ + "--version[print version info]" \ + "*::multirust commands:_multirust_command" +} + +(( $+functions[_multirust_command] )) || +_multirust_command() { + local cmd ret=1 + + (( $+multirust_cmds )) || _multirust_cmds=( + "default:Set the default toolchain" \ + "override:Set the toolchain override for the current directory tree" \ + "update:Install or update a given toolchain" \ + "show-override:Show information about the current override" \ + "show-default:Show information about the current default" \ + "list-overrides:List all overrides" \ + "list-toolchains:List all installed toolchains" \ + "remove-override:Remove an override, for current directory unless specified" \ + "remove-toolchain:Uninstall a toolchain" \ + "run:Run a command in an environment configured for a toolchain" \ + "delete-data:Delete all user metadata, including installed toolchains" \ + "upgrade-data:Upgrade the ~/.multirust directory from previous versions" \ + "doc:Open the documentation for the currently active toolchain" \ + "which:Report location of the currently active Rust tool." \ + "help:Show help for this command or subcommands" \ + ) + + if (( CURRENT == 1 )); then + _describe -t commands 'multirust subcommand' _multirust_cmds || compadd "$@" - ${(s.:.)${(j.:.)_multirust_syns}} + else + local curcontext="$curcontext" + + cmd="${${_multirust_cmds[(r)$words[1]:*]%%:*}:-${(k)_multirust_syns[(r)(*:|)$words[1](:*|)]}}" + if (( $#cmd )); then + curcontext="${curcontext%:*:*}:multirust-${cmd}:" + _call_function ret _multirust_$cmd || _message 'no more arguments' + else + _message "unknown multirust command: $words[1]" + fi + return ret + fi +} + +(( $+functions[_multirust_default] )) || +_multirust_default() { + _arguments -s \ + "--copy-local[install by copying a local toolchain]:PATH:_gnu_generic::" \ + "--link-local[install by linking a local toolchain]:PATH:_gnu_generic::" \ + "--installer[allows arbitrary builds of rust to be installed from a custom-built installer]:PATH:_gnu_generic::" \ + "*::multirust commands:_multirust" +} + +(( $+functions[_multirust_override] )) || +_multirust_override() { + _multirust_default +} + +(( $+functions[_multirust_update] )) || +_multirust_update() { + _multirust_default +} + +__overrides() { + declare -a overrides + overrides=($(multirust list-overrides|awk -F";" '{print $1":"$2}')) + _describe 'override' overrides +} + +__toolchains() { + declare -a toolchains + toolchains=($(multirust list-toolchains)) + _describe "toolchain" toolchains +} + +__subcommands() { + declare -a cmds + cmds=($(multirust|grep "# "|awk '{print $2}')) + _describe "command" cmds +} + +(( $+functions[_multirust_remove-override] )) || +_multirust_remove-override() { + __overrides +} + +(( $+functions[_multirust_remove-toolchain] )) || +_multirust_remove-toolchain() { + __toolchains +} + +(( $+functions[_multirust_run] )) || +_multirust_run() { + __toolchains +} + +(( $+functions[_multirust_delete-data] )) || +_multirust_delete-data() { + _arguments -s \ + "-y[Disable prompt]" \ + "*::multirust commands:_multirust" +} + +(( $+functions[_multirust_doc] )) || +_multirust_doc() { + _arguments -s \ + "--all[open the documentation overview page, which gives access to all the installed documentation]:" \ + "*::multirust commands:_multirust" +} + +(( $+functions[_multirust_help] )) || +_multirust_help() { + __subcommands +} + +_multirust "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_mvn b/.zprezto/modules/completion/external/src/_mvn index 2dc385b..6f4b31c 100644 --- a/.zprezto/modules/completion/external/src/_mvn +++ b/.zprezto/modules/completion/external/src/_mvn @@ -1,30 +1,5 @@ #compdef mvn mvnDebug # ------------------------------------------------------------------------------ -# Copyright (c) 2010-2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # @@ -430,6 +405,7 @@ _mvn_common_property_names() { 'skipTests:skip tests execution' 'maven.test.skip:skip tests compilation and execution' 'gpg.passphrase:gpg passphrase' + 'tycho.mode:enable maven mode for Tycho projects to disable p2 resolution' ) _describe -t 'common-property-names' 'common property name' properties $@ } @@ -473,6 +449,7 @@ _mvn_property_values() { ((#i)*(createChecksum|generatePom|maven.test.skip)*) _wanted booleans expl 'boolean' _mvn_booleans && ret=0;; ((#i)*user*) _wanted users expl 'user' _users && ret=0;; # TODO Use _alternative and add repository usernames from settings + projects ((#i)*plugin*) _wanted plugin expl 'plugin' _mvn_plugins && ret=0;; + ((#i)*tycho.mode*) _wanted tychomodes expl 'tychomode' _mvn_tycho_modes && ret=0;; (*) _default && ret=0;; esac return ret @@ -546,6 +523,14 @@ _mvn_booleans() { } +(( $+functions[_mvn_tycho_modes] )) || +_mvn_tycho_modes() { + local tychomodes; tychomodes=( + 'maven:maven mode, Tycho will not do any p2 dependency resolution' + ) + _describe -t tychomodes 'boolean' tychomodes +} + # ------------------------------------------------------------------------------ # Helper functions # ------------------------------------------------------------------------------ diff --git a/.zprezto/modules/completion/external/src/_nl b/.zprezto/modules/completion/external/src/_nl deleted file mode 100644 index 53db404..0000000 --- a/.zprezto/modules/completion/external/src/_nl +++ /dev/null @@ -1,56 +0,0 @@ -#compdef nl -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for GNU nl (coreutils 8.13). -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * github.com/RobSis -# -# ------------------------------------------------------------------------------ - -local arguments style_values format_values ret=1 - -style_values=( - "a:number all lines" - "t:number only nonempty lines" - "n:number no lines" - "pBRE:number only lines that contain a match for the basic regular expression, BRE" -) - -format_values=( - "ln:left justified, no leading zeros" - "rn:right justified, no leading zeros" - "rz:right justified, leading zeros" -) - -_arguments -C -s -S \ - {-b+,--body-numbering=}'[use STYLE for given number of lines]:style:->style' \ - {-d+,--section-delimiter=}'[use CC for separating logical pages]' \ - {-f+,--footer-numbering=}'[use STYLE for numbering footer lines]:style:->style' \ - {-h+,--header-numbering=}'[use STYLE for numbering header lines]:style:->style' \ - {-i+,--line-increment=}'[line number increment at each line]' \ - {-l+,--join-blank-lines=}'[group of NUMBER empty lines counted as one]' \ - {-n+,--number-format=}'[insert line numbers according to FORMAT]:format:->format' \ - {-p,--no-renumber}'[do not reset line numbers at logical pages]' \ - {-s+,--number-separator=}'[add STRING after (possible) line number]' \ - {-v+,--starting-line-number=}'[first line number on each logical page]' \ - {-w+,--number-width=}'[use NUMBER columns for line numbers]' \ - --help'[display help and exit]' \ - --version'[output version information and exit]' \ - '*:filename:_files' && ret=0 - -case "$state" in - (style) - _describe -t style style style_values && ret=0 - ;; - (format) - _describe -t format format format_values && ret=0 - ;; -esac - -return $ret diff --git a/.zprezto/modules/completion/external/src/_nvm b/.zprezto/modules/completion/external/src/_nvm index 2f6acc5..05b4cf1 100644 --- a/.zprezto/modules/completion/external/src/_nvm +++ b/.zprezto/modules/completion/external/src/_nvm @@ -1,5 +1,30 @@ #compdef nvm # ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_openssl b/.zprezto/modules/completion/external/src/_openssl new file mode 100644 index 0000000..1d5ec38 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_openssl @@ -0,0 +1,1685 @@ +#compdef openssl +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ + +# openssl command [ command_opts ] [ command_args ] + +_openssl() { + local openssl_commands cmd cmds + if [[ "$CURRENT" -lt 2 ]]; then + # I do not think this can happen... + return + elif [[ "$CURRENT" -eq 2 ]]; then + # first parameter, the command + openssl_commands=(${(z)${${(f)"$(openssl help 2>&1)"}:#([A-Z]|openssl:Error:)*}}) + _describe 'openssl commands' openssl_commands + else + # $CURRENT -gt 2 + cmd="${words[2]}" + # Note: we could use ${(k)functions} to get a list of all functions and + # filter those that start with _openssl_ + # but that would mean defining a new function *somewhere* might mess with + # the completion... + cmds=(asn1parse ca ciphers cms crl crl2pkcs7 dgst dh dhparam dsa dsaparam \ + ec ecparam enc engine errstr gendh gendsa genpkey genrsa nseq ocsp \ + passwd pkcs12 pkcs7 pkcs8 pkey pkeyparam pkeyutl prime rand req rsa \ + rsautl s_client s_server s_time sess_id smime speed spkac srp ts \ + verify version x509) + # check if $cmd is in $cmds, the list of supported commands + if [[ "${cmds[(r)$cmd]}" == "${cmd}" ]]; then + # we should be able to complete $cmd + # run _openssl_$cmd with the remaining words from the command line + shift words + (( CURRENT-- )) + _openssl_${cmd} + elif [[ ${${=${"$(openssl help 2>&1)"/*Cipher commands[^)]#)/}}[(re)$cmd]} == "$cmd" ]]; then + # $cmd is a cipher command, which is practically an alias to enc + shift words + (( CURRENT-- )) + _openssl_enc + elif [[ ${${=${${"$(openssl help 2>&1)"%%Cipher commands*}/*Message Digest commands[^)]#)/}}[(re)$cmd]} == "$cmd" ]]; then + # $cmd is a message digest command, which is practically an alias to dgst + shift words + (( CURRENT-- )) + _openssl_dgst + fi + fi +} + + +_openssl_asn1parse() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format - one of DER PEM]:format:(DER PEM)' \ + '-in[input file]:file:_files' \ + '-out[output file (output format is always DER]:file:_files' \ + "-noout[don't produce any output]" \ + '-offset[offset into file]:number: ' \ + '-length[length of section in file]:number: ' \ + '-i[indent entries]' \ + '-dump[dump unknown data in hex form]' \ + '-dlimit[dump the first arg bytes of unknown data in hex form]:number: ' \ + '-oid[file of extra oid definitions]:file:_files' \ + "-strparse[a series of these can be used to 'dig' into multiple ASN1 blob wrappings]:offset:" \ + '-genstr[string to generate ASN1 structure from]:str:' \ + '-genconf[file to generate ASN1 structure from]:file:_files' +} + + +_openssl_ca() { + # written for openssl 1.0.1k + _arguments -C \ + '-verbose[talk alot while doing things]' \ + '-config[a config file]:file:_files' \ + '-name[the particular CA definition to use]:section: ' \ + '-gencrl[generate a new CRL]' \ + '-crldays[days is when the next CRL is due]:days: ' \ + '-crlhours[hours is when the next CRL is due]:hours: ' \ + '-startdate[certificate validity notBefore]:date: ' \ + '-enddate[certificate validity notAfter (overrides -days)]:date: ' \ + '-days[number of days to certify the certificate for]:days: ' \ + '-md[md to use, one of md2, md5, sha or sha1]:alg:(md2 md5 sha sha1)' \ + "-policy[the CA 'policy' to support]:policy: " \ + '-keyfile[private key file]:file:_files' \ + '-keyform[private key file format (PEM or ENGINE)]:format:(PEM ENGINE)' \ + '-key[key to decode the private key if it is encrypted]:password: ' \ + '-cert[the CA certificate]:file:_files' \ + '-selfsign[sign a certificate with the key associated with it]' \ + '-in[the input PEM encoded certificate request(s)]:file:_files' \ + '-out[where to put the output file(s)]:file:_files' \ + '-outdir[where to put output certificates]:dir:_files -/' \ + '-infiles[the last argument, requests to process]:*:files:_files' \ + '-spkac[file contains DN and signed public key and challenge]:file:_files' \ + '-ss_cert[file contains a self signed cert to sign]:file:_files' \ + "-preserveDN[don't re-order the DN]" \ + "-noemailDN[don't add the EMAIL field into certificate' subject]" \ + "-batch[don't ask questions]" \ + '-msie_hack[msie modifications to handle all those universal strings]' \ + '-revoke[revoke a certificate (given in file)]:file:_files' \ + "-subj[use arg instead of request's subject]:subject: " \ + '-utf8[input characters are UTF8 (default ASCII)]' \ + '-multivalue-rdn[enable support for multivalued RDNs]' \ + '-extensions[extension section (override value in config file)]:section: ' \ + '-extfile[configuration file with X509v3 extentions to add]:file:_files' \ + '-crlexts[CRL extension section (override value in config file)]:section: ' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-status[shows certificate status given the serial number]:serial: ' \ + '-updatedb[updates db for expired certificates]' +} + + +_openssl_ciphers() { + # written for openssl 1.0.1k + _arguments -C \ + '-v[verbose mode, a textual listing of the SSL/TLS ciphers in OpenSSL]' \ + '-V[even more verbose]' \ + '-ssl2[SSL2 mode]' \ + '-ssl3[SSL3 mode]' \ + '-tls1[TLS1 mode]' \ + ':cipher suite:_list_ciphers' +} + + +_openssl_cms() { + # written for openssl 1.0.1k + _arguments -C \ + '-encrypt[encrypt message]' \ + '-decrypt[decrypt encrypted message]' \ + '-sign[sign message]' \ + '-verify[verify signed message]' \ + '-cmsout[output CMS structure]' \ + '-des3[encrypt with triple DES]' \ + '-des[encrypt with DES]' \ + '-seed[encrypt with SEED]' \ + '-rc2-40[encrypt with RC2-40 (default)]' \ + '-rc2-64[encrypt with RC2-64]' \ + '-rc2-128[encrypt with RC2-128]' \ + '-aes128[encrypt PEM output with cbc aes]' \ + '-aes192[encrypt PEM output with cbc aes]' \ + '-aes256[encrypt PEM output with cbc aes]' \ + '-camellia128[encrypt PEM output with cbc camellia]' \ + '-camellia192[encrypt PEM output with cbc camellia]' \ + '-camellia256[encrypt PEM output with cbc camellia]' \ + "-nointern[don't search certificates in message for signer]" \ + "-nosigs[don't verify message signature]" \ + "-noverify[don't verify signers certificate]" \ + "-nocerts[don't include signers certificate when signing]" \ + '-nodetach[use opaque signing]' \ + "-noattr[don't include any signed attributes]" \ + "-binary[don't translate message to text]" \ + '-certfile[other certificates file]:file:_files' \ + '-certsout[certificate output file]:file:_files' \ + '-signer[signer certificate file]:file:_files' \ + '-recip[recipient certificate file for decryption]:file:_files' \ + '-keyid[use subject key identifier]' \ + '-in[input file]:file:_files' \ + '-inform[input format SMIME (default), PEM or DER]:format:(SMIME PEM DER)' \ + '-inkey[input private key (if not signer or recipient)]:file:_files' \ + '-keyform[input private key format (PEM or ENGINE)]:format:(PEM ENGINE)' \ + '-out[output file]:file:_files' \ + '-outform[output format SMIME (default), PEM or DER]:format:(SMIME PEM DER)' \ + '-content[supply or override content for detached signature]:file:_files' \ + '-to[to address mail head]:address: ' \ + '-from[from address mail head]:address: ' \ + '-subject[subject mail head]:subject: ' \ + '-text[include or delete text MIME headers]' \ + '-CApath[trusted certificates directory]:dir:_files -/' \ + '-CAfile[trusted certificates file]:file:_files' \ + "-crl_check[check revocation status of signer's certificate using CRLs]" \ + "-crl_check_all[check revocation status of signer's certificate chain using CRLs]" \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-passin[input file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-rand[files to use for random number input]:file:_rand_files' \ + '*:certificate:_files' +} + + +_openssl_crl() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format - default PEM (DER or PEM)]:format:(PEM DER)' \ + '-outform[output format - default PEM]:format:(PEM DER)' \ + '-text[print out a text format version]' \ + '-in[input file - default stdin]:file:_files' \ + '-out[output file - default stdout]:file:_files' \ + '-hash[print hash value]' \ + '-hash_old[print old-style (MD5) hash value]' \ + '-fingerprint[print the crl fingerprint]' \ + '-issuer[print issuer DN]' \ + '-lastupdate[print lastUpdate field]' \ + '-nextupdate[print nextUpdate field]' \ + '-crlnumber[print CRL number]' \ + '-noout[no CRL output]' \ + '-CAfile[verify CRL using certificates in the specified file]:file:_files' \ + '-CApath[verify CRL using certificates in the specified directory]:dir:_files -/' \ + '*-nameopt[various certificate name options]:options:_nameopts' +} + + +_openssl_crl2pkcs7() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format - DER or PEM]:format:(PEM DER)' \ + '-outform[output format - DER or PEM]:format:(PEM DER)' \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-certfile[certificates file of chain to a trusted CA (can be used more than once)]:file:_files' \ + "-nocrl[no crl to load, just certs from '-certfile']" +} + + +_openssl_dgst() { + # written for openssl 1.0.1k + local digests + digests=(-dss1 -md4 -md5 -mdc2 -ripemd160 -sha -sha1 -sha224 -sha256 -sha384 -sha512 -whirlpool) + # -hmac is listed twice because it's documented twice by openssl + _arguments -C -A '-*' \ + '(-r -hex -binary)-c[to output the digest with separating colons]' \ + '(-c -hex -binary)-r[to output the digest in coreutils format]' \ + '-d[to output debug info]' \ + '(-c -r -binary)-hex[output as hex dump]' \ + '(-c -r -hex)-binary[output in binary form]' \ + '-hmac[set the HMAC key to arg]:key: ' \ + '-non-fips-allow[allow use of non FIPS digest]' \ + '-sign[sign digest using private key in the specified file]:file:_files' \ + '-verify[verify a signature using public key in the specified file]:file:_files' \ + '-prverify[verify a signature using private key in the specified file]:file:_files' \ + '-keyform[key file format (PEM or ENGINE)]:format:(PEM ENGINE)' \ + '-out[output to filename rather than stdout]:file:_files' \ + '-signature[signature to verify]:file:_files' \ + '-sigopt[signature parameter]:nm\:v: ' \ + '-hmac[create hashed MAC with key]:key: ' \ + '-mac[create MAC (not neccessarily HMAC)]:algorithm: ' \ + '-macopt[MAC algorithm parameters or key]:nm\:v: ' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + "($digests)-dss1[use the dss1 message digest algorithm]" \ + "($digests)-md4[to use the md4 message digest algorithm]" \ + "($digests)-md5[to use the md5 message digest algorithm]" \ + "($digests)-mdc2[to use the mdc2 message digest algorithm]" \ + "($digests)-ripemd160[to use the ripemd160 message digest algorithm]" \ + "($digests)-sha[to use the sha message digest algorithm]" \ + "($digests)-sha1[to use the sha1 message digest algorithm]" \ + "($digests)-sha224[to use the sha224 message digest algorithm]" \ + "($digests)-sha256[to use the sha256 message digest algorithm]" \ + "($digests)-sha384[to use the sha384 message digest algorithm]" \ + "($digests)-sha512[to use the sha512 message digest algorithm]" \ + "($digests)-whirlpool[to use the whirlpool message digest algorithm]" \ + '*:file:_files' +} + + +_openssl_dh() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-check[check the DH parameters]' \ + '-text[print a text form of the DH parameters]' \ + '-C[output C code]' \ + '-noout[no output]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' +} + + +_openssl_dhparam() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-dsaparam[read or generate DSA parameters, convert to DH]' \ + '-check[check the DH parameters]' \ + '-text[print a text form of the DH parameters]' \ + '-C[output C code]' \ + '-2[generate parameters using 2 as the generator value]' \ + '-5[generate parameters using 5 as the generator value]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-rand[files to use for random number input]:file:_rand_files' \ + '-noout[no output]' \ + ':numbits: ' +} + + +_openssl_dsa() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file]:file:_files' \ + '-passin[input file pass phrase source]:file:_files' \ + '-out[output file]:file:_files' \ + '-passout[output file pass phrase source]:file:_files' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-des[encrypt PEM output with cbc des]' \ + '-des3[encrypt PEM output with ede cbc des using 168 bit key]' \ + '-idea[encrypt PEM output with cbc idea]' \ + '-aes128[encrypt PEM output with cbc aes]' \ + '-aes192[encrypt PEM output with cbc aes]' \ + '-aes256[encrypt PEM output with cbc aes]' \ + '-camellia128[encrypt PEM output with cbc camellia]' \ + '-camellia192[encrypt PEM output with cbc camellia]' \ + '-camellia256[encrypt PEM output with cbc camellia]' \ + '-seed[encrypt PEM output with cbc seed]' \ + '-text[print the key in text]' \ + "-noout[don't print key out]" \ + '-modulus[print the DSA public value]' +} + + +_openssl_dsaparam() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-text[print as text]' \ + '-C[output C code]' \ + '-noout[no output]' \ + '-genkey[generate a DSA key]' \ + '-rand[files to use for random number input]:file:_rand_files' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + ':numbits: ' +} + + +_openssl_ec() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file]:file:_files' \ + '-passin[input file pass phrase source]:file:_files' \ + '-out[output file]:file:_files' \ + '-passout[output file pass phrase source]:file:_files' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + "-des[encrypt PEM output, instead of 'des' every other cipher supported by OpenSSL can be used]" \ + '-text[print the key]' \ + "-noout[don't print key out]" \ + '-param_out[print the elliptic curve parameters]' \ + '-conv_form[specifies the point conversion form]:form:(compressed uncompressed hybrid)' \ + '-param_enc[specifies the way the ec parameters are encoded in the asn1 der encoding]:encoding:(named_curve explicit)' +} + + +_openssl_ecparam() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file - default stdin]:file:_files' \ + '-out[output file - default stdout]:file:_files' \ + '-noout[do not print the ec parameter]' \ + '-text[print the ec parameters in text form]' \ + '-check[validate the ec parameters]' \ + "-C[print a 'C' function creating the parameters]" \ + "-name[use the ec parameters with 'short name' name]:name: " \ + "-list_curves[prints a list of all currently available curve 'short names']" \ + '-conv_form[specifies the point conversion form]:form:(compressed uncompressed hybrid)' \ + '-param_enc[specifies the way the ec parameters are encoded in the asn1 der encoding]:encoding:(named_curve explicit)' \ + "-no_seed[if 'explicit' parameters are chosen do not use the seed]" \ + '-genkey[generate ec key]' \ + '-rand[files to use for random number input]:file:_rand_files' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' +} + + +_openssl_enc() { + # written for openssl 1.0.1k + local ciphers + ciphers=(-aes-128-cbc -aes-128-cbc-hmac-sha1 -aes-128-cfb -aes-128-cfb1 \ + -aes-128-cfb8 -aes-128-ctr -aes-128-ecb -aes-128-gcm -aes-128-ofb \ + -aes-128-xts -aes-192-cbc -aes-192-cfb -aes-192-cfb1 -aes-192-cfb8 \ + -aes-192-ctr -aes-192-ecb -aes-192-gcm -aes-192-ofb -aes-256-cbc \ + -aes-256-cbc-hmac-sha1 -aes-256-cfb -aes-256-cfb1 -aes-256-cfb8 \ + -aes-256-ctr -aes-256-ecb -aes-256-gcm -aes-256-ofb -aes-256-xts \ + -aes128 -aes192 -aes256 -bf -bf-cbc -bf-cfb -bf-ecb -bf-ofb \ + -blowfish -camellia-128-cbc -camellia-128-cfb -camellia-128-cfb1 \ + -camellia-128-cfb8 -camellia-128-ecb -camellia-128-ofb \ + -camellia-192-cbc -camellia-192-cfb -camellia-192-cfb1 \ + -camellia-192-cfb8 -camellia-192-ecb -camellia-192-ofb \ + -camellia-256-cbc -camellia-256-cfb -camellia-256-cfb1 \ + -camellia-256-cfb8 -camellia-256-ecb -camellia-256-ofb \ + -camellia128 -camellia192 -camellia256 -cast -cast-cbc -cast5-cbc \ + -cast5-cfb -cast5-ecb -cast5-ofb -des -des-cbc -des-cfb -des-cfb1 \ + -des-cfb8 -des-ecb -des-ede -des-ede-cbc -des-ede-cfb -des-ede-ofb \ + -des-ede3 -des-ede3-cbc -des-ede3-cfb -des-ede3-cfb1 \ + -des-ede3-cfb8 -des-ede3-ofb -des-ofb -des3 -desx -desx-cbc \ + -id-aes128-GCM -id-aes192-GCM -id-aes256-GCM -idea -idea-cbc \ + -idea-cfb -idea-ecb -idea-ofb -rc2 -rc2-40-cbc -rc2-64-cbc \ + -rc2-cbc -rc2-cfb -rc2-ecb -rc2-ofb -rc4 -rc4-40 -rc4-hmac-md5 \ + -rc5 -rc5-cbc -rc5-cfb -rc5-ecb -rc5-ofb -seed -seed-cbc -seed-cfb \ + -seed-ecb -seed-ofb) + _arguments -C \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-pass[pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-e[encrypt]' \ + '-d[decrypt]' \ + '(-a -base64)'{-a,-base64}'[base64 encode/decode, depending on encryption flag]' \ + '-k[the password to derive the key from]:password: ' \ + '-kfile[read the password to derive the key from the first line of the file]:file:_files' \ + '-md[the md to use to create a key from a passphrase]:alg:(md2 md5 sha sha1)' \ + '-S[the actual salt to use]:salt: ' \ + '-K[the actual key to use]:key: ' \ + '-iv[the actual IV to use]:IV: ' \ + '-p[print out the key and IV used]' \ + '-P[print out the key and IV used the exit]' \ + '-bufsize[set the buffer size for I/O]:size: ' \ + '-nopad[disable standard block padding]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + "(${ciphers})-aes-128-cbc[cipher types]" \ + "(${ciphers})-aes-128-cbc-hmac-sha1[cipher types]" \ + "(${ciphers})-aes-128-cfb[cipher types]" \ + "(${ciphers})-aes-128-cfb1[cipher types]" \ + "(${ciphers})-aes-128-cfb8[cipher types]" \ + "(${ciphers})-aes-128-ctr[cipher types]" \ + "(${ciphers})-aes-128-ecb[cipher types]" \ + "(${ciphers})-aes-128-gcm[cipher types]" \ + "(${ciphers})-aes-128-ofb[cipher types]" \ + "(${ciphers})-aes-128-xts[cipher types]" \ + "(${ciphers})-aes-192-cbc[cipher types]" \ + "(${ciphers})-aes-192-cfb[cipher types]" \ + "(${ciphers})-aes-192-cfb1[cipher types]" \ + "(${ciphers})-aes-192-cfb8[cipher types]" \ + "(${ciphers})-aes-192-ctr[cipher types]" \ + "(${ciphers})-aes-192-ecb[cipher types]" \ + "(${ciphers})-aes-192-gcm[cipher types]" \ + "(${ciphers})-aes-192-ofb[cipher types]" \ + "(${ciphers})-aes-256-cbc[cipher types]" \ + "(${ciphers})-aes-256-cbc-hmac-sha1[cipher types]" \ + "(${ciphers})-aes-256-cfb[cipher types]" \ + "(${ciphers})-aes-256-cfb1[cipher types]" \ + "(${ciphers})-aes-256-cfb8[cipher types]" \ + "(${ciphers})-aes-256-ctr[cipher types]" \ + "(${ciphers})-aes-256-ecb[cipher types]" \ + "(${ciphers})-aes-256-gcm[cipher types]" \ + "(${ciphers})-aes-256-ofb[cipher types]" \ + "(${ciphers})-aes-256-xts[cipher types]" \ + "(${ciphers})-aes128[cipher types]" \ + "(${ciphers})-aes192[cipher types]" \ + "(${ciphers})-aes256[cipher types]" \ + "(${ciphers})-bf[cipher types]" \ + "(${ciphers})-bf-cbc[cipher types]" \ + "(${ciphers})-bf-cfb[cipher types]" \ + "(${ciphers})-bf-ecb[cipher types]" \ + "(${ciphers})-bf-ofb[cipher types]" \ + "(${ciphers})-blowfish[cipher types]" \ + "(${ciphers})-camellia-128-cbc[cipher types]" \ + "(${ciphers})-camellia-128-cfb[cipher types]" \ + "(${ciphers})-camellia-128-cfb1[cipher types]" \ + "(${ciphers})-camellia-128-cfb8[cipher types]" \ + "(${ciphers})-camellia-128-ecb[cipher types]" \ + "(${ciphers})-camellia-128-ofb[cipher types]" \ + "(${ciphers})-camellia-192-cbc[cipher types]" \ + "(${ciphers})-camellia-192-cfb[cipher types]" \ + "(${ciphers})-camellia-192-cfb1[cipher types]" \ + "(${ciphers})-camellia-192-cfb8[cipher types]" \ + "(${ciphers})-camellia-192-ecb[cipher types]" \ + "(${ciphers})-camellia-192-ofb[cipher types]" \ + "(${ciphers})-camellia-256-cbc[cipher types]" \ + "(${ciphers})-camellia-256-cfb[cipher types]" \ + "(${ciphers})-camellia-256-cfb1[cipher types]" \ + "(${ciphers})-camellia-256-cfb8[cipher types]" \ + "(${ciphers})-camellia-256-ecb[cipher types]" \ + "(${ciphers})-camellia-256-ofb[cipher types]" \ + "(${ciphers})-camellia128[cipher types]" \ + "(${ciphers})-camellia192[cipher types]" \ + "(${ciphers})-camellia256[cipher types]" \ + "(${ciphers})-cast[cipher types]" \ + "(${ciphers})-cast-cbc[cipher types]" \ + "(${ciphers})-cast5-cbc[cipher types]" \ + "(${ciphers})-cast5-cfb[cipher types]" \ + "(${ciphers})-cast5-ecb[cipher types]" \ + "(${ciphers})-cast5-ofb[cipher types]" \ + "(${ciphers})-des[cipher types]" \ + "(${ciphers})-des-cbc[cipher types]" \ + "(${ciphers})-des-cfb[cipher types]" \ + "(${ciphers})-des-cfb1[cipher types]" \ + "(${ciphers})-des-cfb8[cipher types]" \ + "(${ciphers})-des-ecb[cipher types]" \ + "(${ciphers})-des-ede[cipher types]" \ + "(${ciphers})-des-ede-cbc[cipher types]" \ + "(${ciphers})-des-ede-cfb[cipher types]" \ + "(${ciphers})-des-ede-ofb[cipher types]" \ + "(${ciphers})-des-ede3[cipher types]" \ + "(${ciphers})-des-ede3-cbc[cipher types]" \ + "(${ciphers})-des-ede3-cfb[cipher types]" \ + "(${ciphers})-des-ede3-cfb1[cipher types]" \ + "(${ciphers})-des-ede3-cfb8[cipher types]" \ + "(${ciphers})-des-ede3-ofb[cipher types]" \ + "(${ciphers})-des-ofb[cipher types]" \ + "(${ciphers})-des3[cipher types]" \ + "(${ciphers})-desx[cipher types]" \ + "(${ciphers})-desx-cbc[cipher types]" \ + "(${ciphers})-id-aes128-GCM[cipher types]" \ + "(${ciphers})-id-aes192-GCM[cipher types]" \ + "(${ciphers})-id-aes256-GCM[cipher types]" \ + "(${ciphers})-idea[cipher types]" \ + "(${ciphers})-idea-cbc[cipher types]" \ + "(${ciphers})-idea-cfb[cipher types]" \ + "(${ciphers})-idea-ecb[cipher types]" \ + "(${ciphers})-idea-ofb[cipher types]" \ + "(${ciphers})-rc2[cipher types]" \ + "(${ciphers})-rc2-40-cbc[cipher types]" \ + "(${ciphers})-rc2-64-cbc[cipher types]" \ + "(${ciphers})-rc2-cbc[cipher types]" \ + "(${ciphers})-rc2-cfb[cipher types]" \ + "(${ciphers})-rc2-ecb[cipher types]" \ + "(${ciphers})-rc2-ofb[cipher types]" \ + "(${ciphers})-rc4[cipher types]" \ + "(${ciphers})-rc4-40[cipher types]" \ + "(${ciphers})-rc4-hmac-md5[cipher types]" \ + "(${ciphers})-rc5[cipher types]" \ + "(${ciphers})-rc5-cbc[cipher types]" \ + "(${ciphers})-rc5-cfb[cipher types]" \ + "(${ciphers})-rc5-ecb[cipher types]" \ + "(${ciphers})-rc5-ofb[cipher types]" \ + "(${ciphers})-seed[cipher types]" \ + "(${ciphers})-seed-cbc[cipher types]" \ + "(${ciphers})-seed-cfb[cipher types]" \ + "(${ciphers})-seed-ecb[cipher types]" \ + "(${ciphers})-seed-ofb[cipher types]" +} + + +_openssl_engine() { + # written for openssl 1.0.1k + _arguments -C \ + '(-vv -vvv -vvvv)-v[verbose mode, for each engine, list its "control commands"]' \ + "(-v -vvv -vvvv)-vv[like -v, but additionally display each command's description]" \ + '(-v -vv -vvvv)-vvv[like -vv, but also add the input flags for each command]' \ + '(-v -vv -vvv)-vvvv[like -vvv, but also show internal input flags]' \ + '-c[for each engine, also list the capabilities]' \ + '(-tt)-t[for each engine, check that they are really available]' \ + '(-t)-tt[display error trace for unavailable engines]' \ + "-pre[runs command 'cmd' against the ENGINE before any attempts to load it (if -t is used)]:cmd: " \ + "-post[runs command 'cmd' against the ENGINE after loading it (only used if -t is also provided)]:cmd: " \ + '*:engine:_engines' + # TODO: can cmd (for -pre and -post) be completed? +} + + +_openssl_errstr() { + # written for openssl 1.0.1k + # written for openssl 1.0.2a + _arguments -C \ + '-stats' \ + ':errno: ' +} + + +_openssl_gendh() { + # written for openssl 1.0.1k + _arguments -C \ + "-out[output the key to 'file']:file:_files" \ + '-2[use 2 as the generator value]' \ + '-5[use 5 as the generator value]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-rand[files to use for random number input]:file:_rand_files' \ + ':numbits: ' +} + + +_openssl_gendsa() { + # written for openssl 1.0.1k + _arguments -C \ + "-out[output the key to 'file']:file:_files" \ + '-des[encrypt the generated key with DES in cbc mode]' \ + '-des3[encrypt the generated key with DES in ede cbc mode (168 bit key)]' \ + '-idea[encrypt the generated key with IDEA in cbc mode]' \ + '-seed[encrypt PEM output with cbc seed]' \ + '-aes128[encrypt PEM output with cbc aes]' \ + '-aes192[encrypt PEM output with cbc aes]' \ + '-aes256[encrypt PEM output with cbc aes]' \ + '-camellia128[encrypt PEM output with cbc camellia]' \ + '-camellia192[encrypt PEM output with cbc camellia]' \ + '-camellia256[encrypt PEM output with cbc camellia]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-rand[files to use for random number input]:file:_rand_files' \ + ':dsaparam-file:_files' +} + + +_openssl_genpkey() { + # written for openssl 1.0.1k + local ciphers cipher_opts + ciphers=( ${$(openssl list-cipher-algorithms | cut -d' ' -f1)} ) + cipher_opts=() + for alg in ${ciphers}; do + cipher_opts=(${cipher_opts} "(${${(l:32:: ::-:)ciphers[@]}// / })-${alg}[use this cipher to encrypt the key]") + done + _arguments -C \ + '-out[output file]:file:_files' \ + '-outform[output format]:format:(PEM DER)' \ + '-pass[output file pass phrase source]:pass phrase source:_pass_phrase_source' \ + $cipher_opts \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '(-algorithm)-paramfile[parameters file]:file:_files' \ + '(-paramfile)-algorithm[the public key algorithm]:algorithm:(EC RSA DSA DH)' \ + '-pkeyopt[public key options]:option\:value: ' \ + '-genparam[generate parameters, not key]' \ + '-text[print the in text]' + # NB: options order may be important! See the manual page. + # TODO: complete pkeyopts + # However: "The precise set of options supported depends on the public key + # algorithm used and its implementation." +} + + +_openssl_genrsa() { + # written for openssl 1.0.1k + _arguments -C \ + '-des[encrypt the generated key with DES in cbc mode]' \ + '-des3[encrypt the generated key with DES in ede cbc mode (168 bit key)]' \ + '-idea[encrypt the generated key with IDEA in cbc mode]' \ + '-seed[encrypt PEM output with cbc seed]' \ + '-aes128[encrypt PEM output with cbc aes]' \ + '-aes192[encrypt PEM output with cbc aes]' \ + '-aes256[encrypt PEM output with cbc aes]' \ + '-camellia128[encrypt PEM output with cbc camellia]' \ + '-camellia192[encrypt PEM output with cbc camellia]' \ + '-camellia256[encrypt PEM output with cbc camellia]' \ + '-out[output the key to file]:file:_files' \ + '-passout[output file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-f4[use F4 (0x10001) for the E value]' \ + '-3[use 3 for the E value]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-rand[files to use for random number input]:file:_rand_files' \ + ':numbits: ' +} + + +_openssl_nseq() { + # written for openssl 1.0.1k + _arguments -C \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-toseq[output NS Sequence file]' +} + + +_openssl_ocsp() { + # written for openssl 1.0.1k + _arguments -C \ + '-out[output filename]:file:_files' \ + '-issuer[issuer certificate]:file:_files' \ + '-cert[certificate to check]:file:_files' \ + '-serial[serial number to check]:serial: ' \ + '-signer[certificate to sign OCSP request with]:file:_files' \ + '-signkey[private key to sign OCSP request with]:file:_files' \ + '-sign_other[additional certificates to include in signed request]:file:_files' \ + "-no_certs[don't include any certificates in signed request]" \ + '-req_text[print text form of request]' \ + '-resp_text[print text form of response]' \ + '-text[print text form of request and response]' \ + '-reqout[write DER encoded OCSP request to "file"]:file:_files' \ + '-respout[write DER encoded OCSP reponse to "file"]:file:_files' \ + '-reqin[read DER encoded OCSP request from "file"]:file:_files' \ + '-respin[read DER encoded OCSP reponse from "file"]:file:_files' \ + '-nonce[add OCSP nonce to request]' \ + "-no_nonce[don't add OCSP nonce to request]" \ + '-url[OCSP responder URL]:URL: ' \ + '-host[send OCSP request to given host on given port]:host\:port: ' \ + '-path[path to use in OCSP request]' \ + '-CApath[trusted certificates directory]:directory:_files -/' \ + '-CAfile[trusted certificates file]:file:_files' \ + '-VAfile[validator certificates file]:file:_files' \ + '-validity_period[maximum validity discrepancy in seconds]:seconds: ' \ + '-status_age[maximum status age in seconds]:seconds: ' \ + "-noverify[don't verify response at all]" \ + '-verify_other[additional certificates to search for signer]:file:_files' \ + "-trust_other[don't verify additional certificates]" \ + "-no_intern[don't search certificates contained in response for signer]" \ + "-no_signature_verify[don't check signature on response]" \ + "-no_cert_verify[don't check signing certificate]" \ + "-no_chain[don't chain verify response]" \ + "-no_cert_checks[don't do additional checks on signing certificate]" \ + '-port[port to run responder on]:port: ' \ + '-index[certificate status index file]:file:_files' \ + '-CA[CA certificate]:file:_files' \ + '-rsigner[responder certificate to sign responses with]:file:_files' \ + '-rkey[responder key to sign responses with]:file:_files' \ + '-rother[other certificates to include in response]:file:_files' \ + "-resp_no_certs[don't include any certificates in response]" \ + '-nmin[number of minutes before next update]:minutes: ' \ + '-ndays[number of days before next update]:days: ' \ + '-resp_key_id[identify reponse by signing certificate key ID]' \ + '-nrequest[number of requests to accept (default unlimited)]:limit: ' \ + '-dss1[use specified digest in the request]' \ + '-md4[use specified digest in the request]' \ + '-md5[use specified digest in the request]' \ + '-mdc2[use specified digest in the request]' \ + '-ripemd160[use specified digest in the request]' \ + '-ripemd[use specified digest in the request]' \ + '-rmd160[use specified digest in the request]' \ + '-sha1[use specified digest in the request]' \ + '-sha224[use specified digest in the request]' \ + '-sha256[use specified digest in the request]' \ + '-sha384[use specified digest in the request]' \ + '-sha512[use specified digest in the request]' \ + '-sha[use specified digest in the request]' \ + '-ssl2-md5[use specified digest in the request]' \ + '-ssl3-md5[use specified digest in the request]' \ + '-ssl3-sha1[use specified digest in the request]' \ + '-whirlpool[use specified digest in the request]' \ + '-timeout[timeout connection to OCSP responder after n seconds]:seconds: ' +} + + +_openssl_passwd() { + # written for openssl 1.0.1k + _arguments -C \ + '-crypt[standard Unix password algorithm (default)]' \ + '-1[MD5-based password algorithm]' \ + '-apr1[MD5-based password algorithm, Apache variant]' \ + '-salt[use provided salt]:salt: ' \ + '-in[read passwords from file]:file:_files' \ + '-stdin[read passwords from stdin]' \ + '-noverify[never verify when reading password from terminal]' \ + '-quiet[no warnings]' \ + '-table[format output as table]' \ + '-reverse[switch table columns]' \ + '*:password:' +} + + +_openssl_pkcs12() { + # written for openssl 1.0.2d + local algorithms + algorithms=(aes-128-cbc aes-128-ecb aes-192-cbc aes-192-ecb aes-256-cbc \ + aes-256-ecb bf-cbc bf-cfb bf-ecb bf-ofb camellia-128-cbc \ + camellia-128-ecb camellia-192-cbc camellia-192-ecb \ + camellia-256-cbc camellia-256-ecb cast-cbc cast5-cbc cast5-cfb \ + cast5-ecb cast5-ofb des-cbc des-cfb des-ecb des-ede des-ede-cbc \ + des-ede-cfb des-ede-ofb des-ede3 des-ede3-cbc des-ede3-cfb \ + des-ede3-ofb des-ofb idea-cbc idea-cfb idea-ecb idea-ofb \ + rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 \ + rc4-40 rc5-cbc rc5-cfb rc5-ecb rc5-ofb seed-cbc seed-cfb \ + seed-ecb seed-ofb PBE-MD2-DES PBE-MD5-DES PBE-SHA1-RC2-64 \ + PBE-MD2-RC2-64 PBE-MD5-RC2-64 PBE-SHA1-DES PBE-SHA1-RC4-128 \ + PBE-SHA1-RC4-40 PBE-SHA1-3DES PBE-SHA1-2DES PBE-SHA1-RC2-128 \ + PBE-SHA1-RC2-40) + _arguments -C \ + '-export[output PKCS12 file]' \ + '-chain[add certificate chain]' \ + '-inkey[private key if not infile]:file:_files' \ + '-certfile[add all certs in the specified file]:file:_files' \ + "-CApath[PEM format directory of CA's]:file:_files" \ + "-CAfile[PEM format file of CA's]:file:_files" \ + '-name[use specified friendly name]:name: ' \ + '*-caname[use specified CA friendly name]:name: ' \ + '-in[input filename]:file:_files' \ + '-out[output filename]:file:_files' \ + "-noout[don't output anything, just verify]" \ + "-nomacver[don't verify MAC]" \ + "-nocerts[don't output certificates]" \ + '-clcerts[only output client certificates]' \ + '-cacerts[only output CA certificates]' \ + "-nokeys[don't output private keys]" \ + '-info[give info about PKCS#12 structure]' \ + '-des[encrypt private keys with DES]' \ + '-des3[encrypt private keys with triple DES (default)]' \ + '-idea[encrypt private keys with idea]' \ + '-seed[encrypt private keys with seed]' \ + '-aes128[encrypt PEM output with cbc aes]' \ + '-aes192[encrypt PEM output with cbc aes]' \ + '-aes256[encrypt PEM output with cbc aes]' \ + '-camellia128[encrypt PEM output with cbc camellia]' \ + '-camellia192[encrypt PEM output with cbc camellia]' \ + '-camellia256[encrypt PEM output with cbc camellia]' \ + "-nodes[don't encrypt private keys]" \ + "-noiter[don't use encryption iteration]" \ + "-nomaciter[don't use MAC iteration]" \ + '-maciter[use MAC iteration]' \ + "-nomac[don't generate MAC]" \ + '-twopass[separate MAC, encryption passwords]' \ + '-descert[encrypt PKCS#12 certificates with triple DES (default RC2-40)]' \ + "-certpbe[specify certificate PBE algorithm (default RC2-40)]:alg:(${algorithms})" \ + '-keypbe[specify private key PBE algorithm (default 3DES)]:alg:(${algorithms})' \ + '-macalg[digest algorithm used in MAC (default SHA1)]:alg:_list_message_digest_algorithms' \ + '-keyex[set MS key exchange type]' \ + '-keysig[set MS key signature type]' \ + '-password[set import/export password source]:pass phrase source:_pass_phrase_source' \ + '-passin[input file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-passout[output file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-rand[files to use for random number input]:file:_rand_files' \ + '-CSP[Microsoft CSP name]:name: ' \ + '-LMK[add local machine keyset attribute to private key]' +} + + +_openssl_pkcs7() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-print_certs[print any certs or crl in the input]' \ + '-text[print full details of certificates]' \ + "-noout[don't output encoded data]" \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' +} + + +_openssl_pkcs8() { + # written for openssl 1.0.2d + _arguments -C \ + '-in[input file]:file:_files' \ + '-inform[input format]:format:(PEM DER)' \ + '-passin[input file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-outform[output format]:format:(PEM DER)' \ + '-out[output file]:file:_files' \ + '-passout[output file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-topk8[output PKCS8 file]' \ + '-nooct[use (nonstandard) no octet format]' \ + '-embed[use (nonstandard) embedded DSA parameters format]' \ + '-nsdb[use (nonstandard) DSA Netscape DB format]' \ + '-noiter[use 1 as iteration count]' \ + '-nocrypt[use or expect unencrypted private key]' \ + '-v2[use PKCS#5 v2.0 and given cipher]:alg:(aes-128-cbc aes-128-ecb aes-192-cbc aes-192-ecb aes-256-cbc aes-256-ecb bf bf-cbc bf-cfb bf-ecb bf-ofb camellia-128-cbc camellia-128-ecb camellia-192-cbc camellia-192-ecb camellia-256-cbc camellia-256-ecb cast cast-cbc cast5-cbc cast5-cfb cast5-ecb cast5-ofb des des-cbc des-cfb des-ecb des-ede des-ede-cbc des-ede-cfb des-ede-ofb des-ede3 des-ede3-cbc des-ede3-cfb des-ede3-ofb des-ofb des3 desx idea idea-cbc idea-cfb idea-ecb idea-ofb rc2 rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 rc4-40 rc5 rc5-cbc rc5-cfb rc5-ecb rc5-ofb seed seed-cbc seed-cfb seed-ecb seed-ofb)' \ + '-v2prf[set the PRF algorithm to use with PKCS#5 v2.0]:alg:(hmacWithMD5 hmacWithRMD160 hmacWithSHA1 hmacWithSHA224 hmacWithSHA256 hmacWithSHA384 hmacWithSHA512)' \ + '-v1[use PKCS#5 v1.5 and given cipher]:obj:(PBE-MD2-DES PBE-MD5-DES PBE-SHA1-RC2-64 PBE-MD2-RC2-64 PBE-MD5-RC2-64 PBE-SHA1-DES PBE-SHA1-RC4-128 PBE-SHA1-RC4-40 PBE-SHA1-3DES PBE-SHA1-2DES PBE-SHA1-RC2-128 PBE-SHA1-RC2-40)' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' +} + + +_openssl_pkey() { + # written for openssl 1.0.1k + _arguments -C \ + '-in[input file]:file:_files' \ + '-inform[input format]:format:(PEM DER)' \ + '-passin[input file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-outform[output format]:format:(PEM DER)' \ + '-out[output file]:file:_files' \ + '-passout[output file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' +} + + +_openssl_pkeyparam() { + # written for openssl 1.0.1k + _arguments -C \ + '-in[the input filename to read parameters from]:file:_files' \ + '-out[the output filename to write parameters]:file:_files' \ + '-text[prints out the parameters in plain text in addition to the encoded version]' \ + '-noout[do not output the encoded version of the parameters]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' +} + + +_openssl_pkeyutl() { + # written for openssl 1.0.1k + _arguments -C \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-sigfile[signature file (verify operation only)]:file:_files' \ + '-inkey[input key]:file:_files' \ + '-keyform[private key format]:format:(PEM DER)' \ + '-pubin[input is a public key]' \ + '-certin[input is a certificate carrying a public key]' \ + '-pkeyopt[public key options]:option\:value:_pkeyopts' \ + '-sign[sign with private key]' \ + '-verify[verify with public key]' \ + '-verifyrecover[verify with public key, recover original data]' \ + '-encrypt[encrypt with public key]' \ + '-decrypt[decrypt with private key]' \ + '-derive[derive shared secret]' \ + '-hexdump[hex dump output]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-passin[pass phrase source]:pass phrase source:_pass_phrase_source' +} + + +_openssl_prime() { + # written for openssl 1.0.1k + _arguments -C \ + '-hex[hex]' \ + '-checks[number of checks]:checks: ' \ + ':number:' +} + + +_openssl_rand() { + # written for openssl 1.0.1k + _arguments -C \ + '-out[write to file]:file:_files' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-rand[files to use for random number input]:file:_rand_files' \ + '-base64[base64 encode output]' \ + '-hex[hex encode output]' \ + ':num:' +} + + +_openssl_req() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-text[text form of request]' \ + '-pubkey[output public key]' \ + '-noout[do not output REQ]' \ + '-verify[verify signature on REQ]' \ + '-modulus[RSA modulus]' \ + "-nodes[don't encrypt the output key]" \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + "-subject[output the request's subject]" \ + '-passin[private key pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-key[use the private key contained in the specified file]:file:_files' \ + '-keyform[key file format]:format:(PEM DER)' \ + '-keyout[file to send the key to]:file:_files' \ + '-rand[files to use for random number input]:file:_rand_files' \ + "-newkey rsa\:-[generate a new RSA key of the specified number of bits in size]:bits: " \ + "-newkey dsa\:[generate a new DSA key, parameters taken from CA in the specified file]:file:_files" \ + "-newkey ec\:[generate a new EC key, parameters taken from CA in the specified file]:file:_files" \ + '-md2[digest to sign with]' \ + '-md4[digest to sign with]' \ + '-md5[digest to sign with]' \ + '-mdc2[digest to sign with]' \ + '-sha1[digest to sign with]' \ + '-config[request template file]:file:_files' \ + '-subj[set or modify request subject]:subject: ' \ + '-multivalue-rdn[enable support for multivalued RDNs]' \ + '-new[new request]' \ + '-batch[do not ask anything during request generation]' \ + '-x509[output a x509 structure instead of a certificate request]' \ + '-days[number of days a certificate generated by -x509 is valid for]:days: ' \ + '-set_serial[serial number to use for a certificate generated by -x509]:serial: ' \ + '-newhdr[output "NEW" in the header lines]' \ + "-asn1-kludge[output the 'request' in a format that is wrong but some CA's have been reported as requiring]" \ + '-extensions[specify certificate extension section (override value in config file)]:section: ' \ + '-reqexts[specify request extension section (override value in config file)]:section: ' \ + '-utf8[input characters are UTF8 (default ASCII)]' \ + '*-nameopt[various certificate name options]:options:_nameopts' \ + '*-reqopt[- various request text options]:options:_certopts' + # TODO: complete -extensions and -reqexts +} + + +_openssl_rsa() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER NET)' \ + '-outform[output format]:format:(PEM DER NET)' \ + '-in[input file]:file:_files' \ + '-sgckey[use IIS SGC key format]' \ + '-passin[input file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-out[output file]:file:_files' \ + '-passout[output file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-des[encrypt PEM output with cbc des]' \ + '-des3[encrypt PEM output with ede cbc des using 168 bit key]' \ + '-idea[encrypt PEM output with cbc idea]' \ + '-seed[encrypt PEM output with cbc seed]' \ + '-aes128[encrypt PEM output with cbc aes]' \ + '-aes192[encrypt PEM output with cbc aes]' \ + '-aes256[encrypt PEM output with cbc aes]' \ + '-camellia128[encrypt PEM output with cbc camellia]' \ + '-camellia192[encrypt PEM output with cbc camellia]' \ + '-camellia256[encrypt PEM output with cbc camellia]' \ + '-text[print the key in text]' \ + "-noout[don't print key out]" \ + '-modulus[print the RSA key modulus]' \ + '-check[verify key consistency]' \ + '-pubin[expect a public key in input file]' \ + '-pubout[output a public key]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' +} + + +_openssl_rsautl() { + # written for openssl 1.0.1k + _arguments -C \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-inkey[input key]:file:_files' \ + '-keyform[private key format]:format:(PEM DER)' \ + '-pubin[input is an RSA public]' \ + '-certin[input is a certificate carrying an RSA public key]' \ + '-ssl[use SSL v2 padding]' \ + '-raw[use no padding]' \ + '-pkcs[use PKCS#1 v1.5 padding (default)]' \ + '-oaep[use PKCS#1 OAEP]' \ + '-sign[sign with private key]' \ + '-verify[verify with public key]' \ + '-encrypt[encrypt with public key]' \ + '-decrypt[decrypt with private key]' \ + '-hexdump[hex dump output]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-passin[pass phrase source]:pass phrase source:_pass_phrase_source' +} + + +_openssl_s_client() { + # written for openssl 1.0.1k + _arguments -C \ + '(-6)-4[use IPv4 only]' \ + '(-4)-6[use IPv6 only]' \ + '(-connect)-host[use -connect instead]:host: ' \ + '(-connect)-port[use -connect instead]:port: ' \ + '(-host -port)-connect[who to connect to (default is localhost:4433)]:host\:port: ' \ + '-verify[turn on peer certificate verification]:depth: ' \ + '-verify_return_error[return verification errors]' \ + '-cert[certificate file to use, PEM format assumed]:file:_files' \ + '-certform[certificate format (PEM or DER) PEM default]:format:(PEM DER)' \ + '-key[private key file to use, in cert file if not specified but cert file is]:file:_files' \ + '-keyform[key format (PEM or DER) PEM default]:format:(PEM DER)' \ + '-pass[private key file pass phrase source]:pass phrase source:_pass_phrase_source' \ + "-CApath[PEM format directory of CA's]:directory:_files -/" \ + "-CAfile[PEM format file of CA's]:file:_files" \ + '-reconnect[drop and re-make the connection with the same Session-ID]' \ + '-pause[sleep(1) after each read(2) and write(2) system call]' \ + '-prexit[print session information even on connection failure]' \ + '-showcerts[show all certificates in the chain]' \ + '-debug[extra output]' \ + '-msg[show protocol messages]' \ + '-nbio_test[more ssl protocol testing]' \ + "-state[print the 'ssl' states]" \ + '-nbio[run with non-blocking IO]' \ + '-crlf[convert LF from terminal into CRLF]' \ + '-quiet[no s_client output]' \ + '(-no_ign_eof)-ign_eof[ignore input eof (default when -quiet)]' \ + "(-ign_eof)-no_ign_eof[don't ignore input eof]" \ + '-psk_identity[PSK identity]:identity: ' \ + '-psk[PSK in hex (without 0x)]:key: ' \ + "-srpuser[SRP authentification for 'user']:user: " \ + "-srppass[password for 'user']:password: " \ + '-srp_lateuser[SRP username into second ClientHello message]' \ + '-srp_moregroups[tolerate other than the known g N values]' \ + '-srp_strength[minimal length in bits for N (default 1024)]:int: ' \ + '(-no_ssl2 -ssl3 -tls1 -tls1_1 -tls1_2 -dtls1)-ssl2[just use SSLv2]' \ + '(-no_ssl3 -ssl2 -tls1 -tls1_1 -tls1_2 -dtls1)-ssl3[just use SSLv3]' \ + '(-no_tls1_2 -ssl2 -ssl3 -tls1 -tls1_1 -dtls1)-tls1_2[just use TLSv1.2]' \ + '(-no_tls1_1 -ssl2 -ssl3 -tls1 -tls1_1 -dtls1)-tls1_1[just use TLSv1.1]' \ + '(-no_tls1 -ssl2 -ssl3 -tls1 -tls1_1 -dtls1)-tls1[just use TLSv1.0]' \ + '(-no_dtls1 -ssl2 -ssl3 -tls1 -tls1_1 -tls1_2)-dtls1[just use DTLSv1]' \ + '-fallback_scsv[send TLS_FALLBACK_SCSV]' \ + '-mtu[set the link layer MTU]' \ + '(-tls1_2)-no_tls1_2[turn off TLSv1.2]' \ + '(-tls1_1)-no_tls1_1[turn off TLSv1.1]' \ + '(-tls1)-no_tls1[turn off TLSv1.0]' \ + '(-ssl3)-no_ssl3[turn off SSLv3]' \ + '(-ssl2)-no_ssl2[turn off SSLv2]' \ + '-bugs[switch on all SSL implementation bug workarounds]' \ + "-serverpref[use server's cipher preferences (only SSLv2)]" \ + '-cipher[preferred cipher to use]:cipher suite:_list_ciphers' \ + "-starttls[use the STARTTLS command before starting TLS for those protocols that support it]:protocol:(smtp pop3 imap ftp xmpp)" \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-rand[files to use for random number input]:file:_rand_files' \ + '-sess_out[file to write SSL session to]:file:_files' \ + '-sess_in[file to read SSL session from]:file:_files' \ + '-servername[set TLS extension servername in ClientHello]:host: ' \ + '-tlsextdebug[hex dump of all TLS extensions received]' \ + '-status[request certificate status from server]' \ + '-no_ticket[disable use of RFC4507bis session tickets]' \ + '-nextprotoneg[enable NPN extension, considering named protocols supported (comma-separated list)]:protocols: ' \ + '-legacy_renegotiation[enable use of legacy renegotiation (dangerous)]' \ + '-use_srtp[offer SRTP key management with a colon-separated profile list]:profiles: ' \ + '-keymatexport[export keying material using label]:label: ' \ + '-keymatexportlen[export len bytes of keying material (default 20)]:len: ' +} + + +_openssl_s_server() { + # written for openssl 1.0.1k + _arguments -C \ + '-accept[port to accept on (default is 4433)]:port: ' \ + '-context[set session ID context]:id: ' \ + '-verify[turn on peer certificate verification]:depth: ' \ + '-Verify[turn on peer certificate verification, must have a cert]:depth: ' \ + '-verify_return_error[return verification errors]' \ + '-cert[certificate file to use (default is server.pem)]:file:_files' \ + '-crl_check[check the peer certificate has not been revoked by its CA]' \ + '-crl_check_all[check the peer certificate has not been revoked by its CA or any other CRL in the CA chain]' \ + '-certform[certificate format]:format:(PEM DER)' \ + '-key[Private Key file to use, in cert file if not specified (default is server.pem)]:file:_files' \ + '-keyform[key format]:format:(PEM DER ENGINE)' \ + '-pass[private key file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-dcert[second certificate file to use (usually for DSA)]:file:_files' \ + '-dcertform[second certificate format]:format:(PEM DER)' \ + '-dkey[second private key file to use (usually for DSA)]:file:_files' \ + '-dkeyform[second key format]:format:(PEM DER ENGINE)' \ + '-dpass[second private key file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-dhparam[DH parameter file to use, in cert file if not specified or a default set of parameters is used]:file:_files' \ + '-named_curve[elliptic curve name to use for ephemeral ECDH keys. (default is nistp256)]:named curve:_list_curves' \ + '-nbio[run with non-blocking IO]' \ + '-nbio_test[test with the non-blocking test bio]' \ + '-crlf[convert LF from terminal into CRLF]' \ + '-debug[print more output]' \ + '-msg[show protocol messages]' \ + '-state[print the SSL states]' \ + "-CApath[PEM format directory of CA's]:file:_files -/" \ + "-CAfile[PEM format file of CA's]:file:_files" \ + "-nocert[don't use any certificates (Anon-DH)]" \ + '-cipher[preferred cipher to use]:cipher suite:_list_ciphers' \ + "-serverpref[use server's cipher preferences]" \ + '-quiet[no server output]' \ + '-no_tmp_rsa[do not generate a tmp RSA key]' \ + '-psk_hint[PSK identity hint to use]:hint: ' \ + '-psk[PSK in hex (without 0x)]:PSK: ' \ + '-srpvfile[the verifier file for SRP]:file:_files' \ + '-srpuserseed[a seed string for a default user salt]:seed: ' \ + '-ssl2[just talk SSLv2]' \ + '-ssl3[just talk SSLv3]' \ + '-tls1_2[just talk TLSv1.2]' \ + '-tls1_1[just talk TLSv1.1]' \ + '-tls1[just talk TLSv1]' \ + '-dtls1[just talk DTLSv1]' \ + '-timeout[enable timeouts]' \ + '-mtu[set link layer MTU]' \ + '-chain[read a certificate chain]' \ + '-no_ssl2[just disable SSLv2]' \ + '-no_ssl3[just disable SSLv3]' \ + '-no_tls1[just disable TLSv1]' \ + '-no_tls1_1[just disable TLSv1.1]' \ + '-no_tls1_2[just disable TLSv1.2]' \ + '-no_dhe[disable ephemeral DH]' \ + '-no_ecdhe[disable ephemeral ECDH]' \ + '-bugs[turn on SSL bug compatibility]' \ + '-hack[workaround for early Netscape code]' \ + "-www[respond to a 'GET /' with a status page]" \ + "-WWW[respond to a 'GET / HTTP/1.0' with file ./]" \ + "-HTTP[respond to a 'GET / HTTP/1.0' with file ./ with the assumption it contains a complete HTTP response]" \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-id_prefix[generate SSL/TLS session IDs prefixed by arg]:prefix: ' \ + '-rand[files to use for random number input]:file:_rand_files' \ + '-servername[servername for HostName TLS extension]:hostname: ' \ + '-servername_fatal[on mismatch send fatal alert (default warning alert)]' \ + '-cert2[certificate file to use for servername (default is server2.pem)]:file:_files' \ + '-key2[Private Key file to use for servername, in cert file if not specified (default is server2.pem)]:file:_files' \ + '-tlsextdebug[hex dump of all TLS extensions received]' \ + '-no_ticket[disable use of RFC4507bis session tickets]' \ + '-legacy_renegotiation[enable use of legacy renegotiation (dangerous)]' \ + '-nextprotoneg[set the advertised protocols for the NPN extension (comma-separated list)]:protocol:(http/1.0 http/1.1)' \ + '-use_srtp[offer SRTP key management with a colon-separated profile list]:profiles: ' \ + '-4[use IPv4 only]' \ + '-6[use IPv6 only]' \ + '-keymatexport[export keying material using label]:label: ' \ + '-keymatexportlen[export len bytes of keying material (default 20)]:length: ' \ + '-status[respond to certificate status requests]' \ + '-status_verbose[enable status request verbose printout]' \ + '-status_timeout[status request responder timeout]:seconds: ' \ + '-status_url[status request fallback URL]:URL: ' + # TODO: srtp profiles +} + + +_openssl_s_time() { + # written for openssl 1.0.1k + _arguments -C \ + '-connect[host:port to connect to (default is localhost:4433)]:host\:port: ' \ + '-nbio[run with non-blocking IO]' \ + '-ssl2[just use SSLv2]' \ + '-ssl3[just use SSLv3]' \ + '-bugs[turn on SSL bug compatibility]' \ + '-new[just time new connections]' \ + '-reuse[just time connection reuse]' \ + "-www[retrieve the specified page from the site]:page: " \ + '-time[max number of seconds to collect data, default 30]:seconds: ' \ + '-verify[turn on peer certificate verification]:depth: ' \ + '-cert[certificate file to use, PEM format assumed]:file:_files' \ + '-key[RSA file to use, PEM format assumed, key is in cert file]:file:_files' \ + "-CApath[PEM format directory of CA's]:file:_files -/" \ + "-CAfile[PEM format file of CA's]:file:_files" \ + '-cipher[preferred cipher to use]:cipher suite:_list_ciphers' +} + + +_openssl_sess_id() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format]:format:(PEM DER)' \ + '-outform[output format]:format:(PEM DER)' \ + '-in[input file (default stdin)]:file:_files' \ + '-out[output file (default stdout)]:file:_files' \ + '-text[print ssl session id details]' \ + '-cert[output certificate ]' \ + '-noout[no CRL output]' \ + '-context[set the session ID context]:id: ' +} + + +_openssl_smime() { + # written for openssl 1.0.1k + _arguments -C \ + '-encrypt[encrypt message]' \ + '-decrypt[decrypt encrypted message]' \ + '-sign[sign message]' \ + '-verify[verify signed message]' \ + '-pk7out[output PKCS#7 structure]' \ + '-des3[encrypt with triple DES]' \ + '-des[encrypt with DES]' \ + '-seed[encrypt with SEED]' \ + '-rc2-40[encrypt with RC2-40 (default)]' \ + '-rc2-64[encrypt with RC2-64]' \ + '-rc2-128[encrypt with RC2-128]' \ + '-aes128[encrypt PEM output with cbc aes]' \ + '-aes192[encrypt PEM output with cbc aes]' \ + '-aes256[encrypt PEM output with cbc aes]' \ + '-camellia128[encrypt PEM output with cbc camellia]' \ + '-camellia192[encrypt PEM output with cbc camellia]' \ + '-camellia256[encrypt PEM output with cbc camellia]' \ + "-nointern[don't search certificates in message for signer]" \ + "-nosigs[don't verify message signature]" \ + "-noverify[don't verify signers certificate]" \ + "-nocerts[don't include signers certificate when signing]" \ + '-nodetach[use opaque signing]' \ + "-noattr[don't include any signed attributes]" \ + "-binary[don't translate message to text]" \ + '-certfile[other certificates file]:file:_files' \ + '-signer[signer certificate file]:file:_files' \ + '-recip[recipient certificate file for decryption]:file:_files' \ + '-in[input file]:file:_files' \ + '-inform[input format]:format:(SMIME PEM DER)' \ + '-inkey[input private key (if not signer or recipient)]:file:_files' \ + '-keyform[input private key format]:format:(PEM ENGINE)' \ + '-out[output file]:file:_files' \ + '-outform[output format]:format:(SMIME PEM DER)' \ + '-content[supply or override content for detached signature]:file:_files' \ + '-to[to address]:address: ' \ + '-from[from address]:address: ' \ + '-subject[subject]:subject: ' \ + '-text[include or delete text MIME headers]' \ + '-CApath[trusted certificates directory]:directory:_files -/' \ + '-CAfile[trusted certificates file]:file:_files' \ + "-crl_check[check revocation status of signer's certificate using CRLs]" \ + "-crl_check_all[check revocation status of signer's certificate chain using CRLs]" \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-passin[input file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-rand[files to use for random number input]:file:_rand_files' \ + ':certificate:_files' +} + + +_openssl_speed() { + # written for openssl 1.0.1k + local algorithms + algorithms=(mdc2 md4 md5 hmac sha1 sha256 sha512 whirlpoolrmd160 idea-cbc \ + seed-cbc rc2-cbc rc5-cbc bf-cbc des-cbc des-ede3 aes-128-cbc \ + aes-192-cbc aes-256-cbc aes-128-ige aes-192-ige aes-256-ige \ + camellia-128-cbc camellia-192-cbc camellia-256-cbc rc4 rsa512 \ + rsa1024 rsa2048 rsa4096 dsa512 dsa1024 dsa2048 ecdsap160 \ + ecdsap192 ecdsap224 ecdsap256 ecdsap384 ecdsap521 ecdsak163 \ + ecdsak233 ecdsak283 ecdsak409 ecdsak571 ecdsab163 ecdsab233 \ + ecdsab283 ecdsab409 ecdsab571 ecdsa ecdhp160 ecdhp192 ecdhp224 \ + ecdhp256 ecdhp384 ecdhp521 ecdhk163 ecdhk233 ecdhk283 ecdhk409 \ + ecdhk571 ecdhb163 ecdhb233 ecdhb283 ecdhb409 ecdhb571 ecdh idea \ + seed rc2 des aes camellia rsa blowfish) + _arguments -C \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-evp[use the specified EVP]:EVP: ' \ + '-decrypt[time decryption instead of encryption (only EVP)]' \ + '-mr[produce machine readable output]' \ + '-multi[run n benchmarks in parallel]:benchmarks: ' \ + "*:algorithm:(${algorithms})" +} + + +_openssl_spkac() { + # written for openssl 1.0.1k + _arguments -C \ + '-in[input file]:file:_files' \ + '-out[output file]:file:_files' \ + '-key[create SPKAC using private key]:file:_files' \ + '-passin[input file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-challenge[challenge string]:string: ' \ + '-spkac[alternative SPKAC name]:spkacname: ' \ + '-spksect[alternative section name]:section: ' \ + "-noout[don't print SPKAC]" \ + '-pubkey[output public key]' \ + '-verify[verify SPKAC signature]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' +} + + +_openssl_srp() { + # written for openssl 1.0.1k + _arguments -C \ + '-verbose[talk alot while doing things]' \ + '-config[a config file]:file:_files' \ + '-name[the particular srp definition to use]:definition: ' \ + '-srpvfile[the srp verifier file name]:file:_files' \ + '(-modify -delete -list)-add[add an user and srp verifier]' \ + '(-add -delete -list)-modify[modify the srp verifier of an existing user]' \ + '(-add -modify -list)-delete[delete user from verifier file]' \ + '(-add -modify -delete)-list[list user]' \ + '-gn[g and N values to be used for new verifier]:g and N: ' \ + '-userinfo[additional info to be set for user]:userinfo: ' \ + '-passin[input file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-passout[output file pass phrase source]:pass phrase source:_pass_phrase_source' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '-rand[files to use for random number input]:file:_rand_files' \ + ':user:' +} + + +_openssl_ts() { + # written for openssl 1.0.1k + # written for openssl 1.0.2e + local action digests + digests=(-dss1 -md4 -md5 -mdc2 -ripemd160 -sha -sha1 -sha224 -sha256 \ + -sha384 -sha512 -whirlpool) + if [[ "${CURRENT}" -eq 2 ]]; then + # first parameter to ts + _values 'openssl time stamp action' '-query[time stamp request generation]' '-reply[time stamp response generation]' '-verify[time stamp response verification]' + else + action="${words[2]}" + case "${action}" in + -query) + _arguments -C \ + '-rand[files to use for random number input]:file:_rand_files' \ + '-config[config file to use]:file:_files' \ + '(-digest)-data[data file for which the time stamp request needs to be created]:file:_files' \ + '(-data)-digest[digest of the data file]:bytes: ' \ + "($digests)-dss1[use the dss1 message digest algorithm]" \ + "($digests)-md4[to use the md4 message digest algorithm]" \ + "($digests)-md5[to use the md5 message digest algorithm]" \ + "($digests)-mdc2[to use the mdc2 message digest algorithm]" \ + "($digests)-ripemd160[to use the ripemd160 message digest algorithm]" \ + "($digests)-sha[to use the sha message digest algorithm]" \ + "($digests)-sha1[to use the sha1 message digest algorithm]" \ + "($digests)-sha224[to use the sha224 message digest algorithm]" \ + "($digests)-sha256[to use the sha256 message digest algorithm]" \ + "($digests)-sha384[to use the sha384 message digest algorithm]" \ + "($digests)-sha512[to use the sha512 message digest algorithm]" \ + "($digests)-whirlpool[to use the whirlpool message digest algorithm]" \ + '-policy[policy to use for creating the time stamp token]:policy ID: ' \ + '-no_nonce[do not include a nonce in the request]' \ + '-cert[request a signing certificate in the response]' \ + '-in[use the previously created time stamp request]:file:_files' \ + '-out[name of the output file to which the request will be written]:file:_files' \ + '-text[output in human-readable format instead of DER]' + ;; + -reply) + _arguments -C \ + '-config[config file to use]:file:_files' \ + '-section[config file section for response generation]:section: ' \ + '-queryfile[file containing a DER encoded time stamp request]:file:_files' \ + '-passin[private key password source]:pass phrase source:_pass_phrase_source' \ + '-signer[signer certificate of the TSA in PEM format]:file:_files' \ + '-inkey[signer private key in PEM format]:file:_files' \ + '-chain[signer certificate chain in PEM format]:file:_files' \ + '-policy[default policy to use for response]:policy ID: ' \ + '-in[use the previously created time stamp response in DER format]:file:_files' \ + '-token_in[the paramter to -in is a time stamp token in DER format]' \ + '-out[name of the output file to which the response will be written]:file:_files' \ + '-token_out[output a time stamp token instead of a time stamp response]' \ + '-text[output in human-readable format instead of DER]' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' + ;; + -verify) + _arguments -C \ + '(-digest -queryfile)-data[verify response against the specified file]:file:_files' \ + '(-data -queryfile)-digest[verify the response against the specified message digest]:digest bytes: ' \ + '(-data -digest)-queryfile[the original time stamp request in DER format]:file:_files' \ + '-in[time stamp response that needs to be verified in DER format]:file:_files' \ + '-token_in[the paramter to -in is a time stamp token in DER format]' \ + '-CApath[directory containing the trused CA certificates of the client]:directory:_files -/' \ + '-CAFile[file containing a set of trusted self-signed CA certificates in PEM format]:file:_files' \ + '-untrusted[set of additional untrusted certificates in PEM format which may be needed when building the certificate chain]:file:_files' + ;; + esac + fi +} + + +_openssl_verify() { + # written for openssl 1.0.1k + _arguments -C \ + '-CApath[a directory of trusted certificates]:directory:_files -/' \ + '-CAfile[file A file of trusted certificates]:file:_files' \ + '-purpose[the intended use for the certificate]:purpose:(sslclient sslserver nssslserver smimesign smimeencrypt crlsign any ocsphelper timestampsign)' \ + '*-policy[enable policy processing and add arg to the user-initial-policy-set]:object name or OID: ' \ + '-ignore_critical[ignore critical extensions]' \ + '-attime[perform validation checks using the given time]:timestamp: ' \ + '-check_ss_sig[verify the signature on the self-signed root CA]' \ + "-crlfile[file containing one or more CRL's (in PEM format) to load]:file:_files" \ + '-crl_check[check end entity certificate in CRL]' \ + '-crl_check_all[check all certificates in CRL]' \ + '-policy_check[enables certificate policy processing]' \ + '-explicit_policy[set policy variable require-explicit-policy]' \ + '-inhibit_any[set policy variable inhibit-any-policy]' \ + '-inhibit_map[set policy variable inhibit-policy-mapping]' \ + '-x509_strict[strict X.509-compliance]' \ + '-extended_crl[enable extended CRL features]' \ + '-use_deltas[enable support for delta CRLs]' \ + '-policy_print[print out diagnostics related to policy processing]' \ + '-untrusted[a file of untrusted certificates]:file:_files' \ + '(-*)-help[print out a usage message]' \ + '-issuer_checks[print out diagnostics relating to searches for the issuer certificate of the current certificate]' \ + '-verbose[print extra information about the operations being performed]' \ + '*:certificate:_files' + # TODO: - may be used to separate certificates from options + # TODO: Do not hardcode purposes +} + + +_openssl_version() { + # written for openssl 1.0.1k + _arguments -C \ + '-a[all information, this is the same as setting all the other flags]' \ + '-v[the current OpenSSL version]' \ + '-b[the date the current version of OpenSSL was built]' \ + '-o[option information: various options set when the library was built]' \ + '-f[compilation flags]' \ + '-p[platform setting]' \ + '-d[OPENSSLDIR setting]' +} + + +_openssl_x509() { + # written for openssl 1.0.1k + _arguments -C \ + '-inform[input format - default PEM (one of DER, NET or PEM)]:format:(DER NET PEM)' \ + '-outform[output format - default PEM (one of DER, NET or PEM)]:arg:(DER NET PEM)' \ + '-keyform[private key format - default PEM]:arg:(DER PEM)' \ + '-CAform[CA format - default PEM]:arg:(DER PEM)' \ + '-CAkeyform[CA key format - default PEM]:arg:(DER PEM)' \ + '-in[input file - default stdin]:file:_files' \ + '-out[output file - default stdout]:file:_files' \ + '-passin[private key password source]:pass phrase source:_pass_phrase_source' \ + '-serial[print serial number value]' \ + '-subject_hash[print subject hash value]' \ + '-subject_hash_old[print old-style (MD5) subject hash value]' \ + '-issuer_hash[print issuer hash value]' \ + '-issuer_hash_old[print old-style (MD5) issuer hash value]' \ + '-hash[synonym for -subject_hash]' \ + '-subject[print subject DN]' \ + '-issuer[print issuer DN]' \ + '-email[print email address(es)]' \ + '-startdate[notBefore field]' \ + '-enddate[notAfter field]' \ + '-purpose[print out certificate purposes]' \ + '-dates[both Before and After dates]' \ + '-modulus[print the RSA key modulus]' \ + '-pubkey[output the public key]' \ + '-fingerprint[print the certificate fingerprint]' \ + '-alias[output certificate alias]' \ + '-noout[no certificate output]' \ + '-ocspid[print OCSP hash values for the subject name and public key]' \ + '-ocsp_uri[print OCSP Responder URL(s)]' \ + '-trustout[output a "trusted" certificate]' \ + '-clrtrust[clear all trusted purposes]' \ + '-clrreject[clear all rejected purposes]' \ + '-addtrust[trust certificate for a given purpose]:purpose:(clientAuth serverAuth emailProtection)' \ + '-addreject[reject certificate for a given purpose]:purpose:(clientAuth serverAuth emailProtection)' \ + '-setalias[set certificate alias]:alias: ' \ + '-days[how long till expiry of a signed certificate (default 30 days)]:days: ' \ + '-checkend[check whether the cert expires in the specified time]:seconds: ' \ + '-signkey[self sign cert with arg]:file:_files' \ + '-x509toreq[output a certification request object]' \ + '-req[input is a certificate request, sign and output]' \ + '-CA[set the CA certificate, must be PEM format]:file:_files' \ + '-CAkey[set the CA key, must be PEM format]:file:_files' \ + '-CAcreateserial[create serial number file if it does not exist]' \ + '-CAserial[serial file]:file:_files' \ + '-set_serial[serial number to use]' \ + '-text[print the certificate in text form]' \ + '-C[print out C code forms]' \ + '(-md5 -sha1 -mdc2)-md2[digest to use]' \ + '(-md2 -sha1 -mdc2)-md5[digest to use]' \ + '(-md2 -md5 -mdc2)-sha1[digest to use]' \ + '(-md2 -md5 -sha1)-mdc2[digest to use]' \ + '-extfile[configuration file with X509V3 extensions to add]' \ + '-extensions[section from config file with X509V3 extensions to add]' \ + '-clrext[delete extensions before signing and input certificate]' \ + '*-nameopt[various certificate name options]:options:_nameopts' \ + '-engine[use the specified engine, possibly a hardware device]:engine:_engines' \ + '*-certopt[various certificate text options]:options:_certopts' +} + + +_pass_phrase_source() { + # pass:password + # env:var + # file:pathname + # fd:number + # stdin + _values -S : 'pass phrase source' \ + 'pass[obtain the password from the command line]:password: ' \ + 'env[obtain the password from the environment variable var]:var:_parameters -g "*export*"' \ + 'file[obtain the password from a file]:file:_files' \ + 'fd[read the password from the file descriptor number]:number: ' \ + 'stdin[read the password from standard input]' +} + + +_rand_files() { + # FIXME: this does not allow using multiple files separated by : + # the following would probably work, but how to generate $files? + #_values -s : -S ' ' 'random source file or directory' ${files} + _files +} + + +_engines() { + # openssl engines + local engines + engines=(${${${(@f)"$(_call_program engines openssl engine)"}%)*}#\(}) + _values 'engines' ${engines} +} + + +_list_ciphers() { + # openssl ciphers + local ciphers + # add cipher suites + ciphers=(${(@s/:/)"$(_call_program ciphers openssl ciphers)"}) + # add static cipher strings + ciphers=(${ciphers} \ + 'DEFAULT[the default cipher list]' \ + 'COMPLEMENTOFDEFAULT[the ciphers included in ALL but not enabled by default]' \ + 'ALL[all cipher suites except the eNULL ciphers]' \ + 'COMPLEMENTOFALL[the cipher suites not enabled by ALL]' \ + 'HIGH["high" encryption cipher suites]' \ + 'MEDIUM["medium" encryption cipher suites]' \ + 'LOW["low" encryption cipher suites]' \ + {EXP,EXPORT}'[export encryption algorithms]' \ + 'EXPORT40[40 bit export encryption algorithms]' \ + 'EXPORT56[56 bit export encryption algorithms]' \ + {eNULL,NULL}'[ciphers offering no encryption]' \ + 'aNULL[ciphers offering no authentication]' \ + {kRSA,RSA}'[cipher suites rusing RSA key exchange]' \ + 'kDHr[cipher suites using DH key agreement signed by CAs with RSA keys]' \ + 'kDHd[cipher suites using DH key agreement signed by CAs with DSS keys]' \ + 'kDH[cipher suites using DH key agreement]' \ + {kDHE,kEDH}'[cipher suites using ephemeral DH key agreement, including anonymous cipher suites]' \ + {DHE,EDH}'[cipher suites using authenticated ephemeral DH key agreement]' \ + 'ADH[anonymous DH cipher suites, not including anonymous ECDH ciphers]' \ + 'DH[cipher suites using DH, including anonymous DH, ephemeral DH and fixed DH]' \ + 'kECDHr[cipher suites using fixed ECDH key agreement signed by CAs with RSA keys]' \ + 'kECDHe[cipher suites using fixed ECDH key agreement signed by CAs with ECDSA keys]' \ + 'kECDH[cipher suites using fixed ECDH key agreement]' \ + {kECDHE,kEECDH}'[cipher suites using ephemeral ECDH key agreement, including anonymous cipher suites]' \ + {ECDHE,kEECDH}'[cipher suites using authenticated ephemeral ECDH key agreement]' \ + 'AECDH[anonymous Elliptic Curve Diffie Hellman cipher suites]' \ + 'ECDH[cipher suites using ECDH key exchange, including anonymous, ephemeral and fixed ECDH]' \ + 'aRSA[cipher suites using RSA authentication]' \ + {aDSS,DSS}'[cipher suites using DSS authentication]' \ + 'aDH[cipher suites effectively using DH authentication]' \ + 'aECDH[cipher suites effectively using ECDH authentication]' \ + {aECDSA,ECDSA}'[cipher suites using ECDSA authentication]' \ + 'TLSv1.2[TLSv1.2 cipher suites]' \ + 'TLSv1[TLSv1.0 cipher suites]' \ + 'SSLv3[SSLv3.0 cipher suites]' \ + 'SSLv2[SSLv2.0 cipher suites]' \ + 'AES128[cipher suites using 128 bit AES]' \ + 'AES256[cipher suites using 256 bit AES]' \ + 'AES[cipher suites using AES]' \ + 'AESGCM[AES in Galois Counter Mode (GCM)]' \ + 'CAMELLIA128[cipher suites using 128 bit CAMELLIA]' \ + 'CAMELLIA256[cipher suites using 256 bit CAMELLIA]' \ + 'CAMELLIA[cipher suites using CAMELLIA]' \ + '3DES[cipher suites using triple DES]' \ + 'DES[cipher suites using DES (not triple DES)]' \ + 'RC4[cipher suites using RC4]' \ + 'RC2[cipher suites using RC2]' \ + 'IDEA[cipher suites using IDEA]' \ + 'SEED[cipher suites using SEED]' \ + 'MD5[cipher suites using MD5]' \ + {SHA1,SHA}'[cipher suites using SHA1]' \ + 'SHA256[cipher suites using SHA256]' \ + 'SHA384[cipher suites using SHA284]' \ + 'aGOST[cipher suites using GOST R 34.10 for authenticaction]' \ + 'aGOST01[cipher suites using GOST R 34.10-2001 authentication]' \ + 'aGOST94[cipher suites using GOST R 34.10-94 authentication]' \ + 'kGOST[cipher suites, using VKO 34.10 key exchange]' \ + 'GOST94[cipher suites, using HMAC based on GOST R 34.11-94]' \ + 'GOST89MAC[cipher suites using GOST 28147-89 MAC instead of HMAC]' \ + 'PSK[cipher suites using pre-shared keys (PSK)]' \ + 'SUITEB128[suite B mode operation using 128 or 192 bit level of security]' \ + 'SUITEB128ONLY[suite B mode operation using 128 bit level of security]' \ + 'SUITEB192[suite B mode operation using 192 bit level of security]' \ + ) + # FIXME: support !, + and - before each cipher suite + _values -s : 'cipher suite' ${ciphers} +} + + +_list_curves() { + # openssl ecparam -list_curves + local curves not_curves + curves="$(_call_program list_curves openssl ecparam -list_curves)" + # identify lines that do not contain curve names but only descriptions + not_curves=(${${(f)curves[@]}:#*:*}) + # remove non-curve lines, trailing descriptions and leading spaces + curves=(${${${${(f)curves[@]}:|not_curves}%:*}##* }) + _values 'named curves' ${curves} +} + + +_list_message_digest_algorithms() { + # openssl list-message-digest-algorithms + local algorithms + algorithms=(${${(@f)"$(_call_program message_digest_algorithms openssl list-message-digest-algorithms)"}%% *}) + _values 'message digest algorithms' ${algorithms} +} + + +_nameopts() { + _values -s ',' -w 'nameopts' \ + '(-compat compat)'{-compat,compat}'[use the old format. This is equivalent to specifying no name options at all]' \ + '(-RFC2253 RFC2253)'{-RFC2253,RFC2253}'[displays names compatible with RFC2253 equivalent to esc_2253, esc_ctrl, esc_msb, utf8, dump_nostr, dump_unknown, dump_der, sep_comma_plus, dn_rev and sname]' \ + '(-oneline oneline)'{-oneline,oneline}'[a oneline format which is more readable than RFC2253. Equivalent to esc_2253, esc_ctrl, esc_msb, utf8, dump_nostr, dump_der, use_quote, sep_comma_plus_space, space_eq and sname options]' \ + '(-multiline multiline)'{-multiline,multiline}'[a multiline format. Equivalent to esc_ctrl, esc_msb, sep_multiline, space_eq, lname and align]' \ + '(-esc_2253 esc_2253)'{-esc_2253,esc_2253}'[escape the "special" characters required by RFC2253 in a field]' \ + '(-esc_ctrl esc_ctrl)'{-esc_ctrl,esc_ctrl}'[escape control characters]' \ + '(-esc_msb esc_msb)'{-esc_msb,esc_msb}'[escape characters with the MSB set]' \ + '(-use_quote use_quote)'{-use_quote,use_quote}'[escapes some characters by surrounding the whole string with " characters]' \ + '(-utf8 utf8)'{-utf8,utf8}'[convert all strings to UTF8 format first]' \ + '(-ignore_type ignore_type)'{-ignore_type,ignore_type}'[this option does not attempt to interpret multibyte characters in any way]' \ + '(-show_type show_type)'{-show_type,show_type}'[show the type of the ASN1 character string]' \ + '(-dump_der dump_der)'{-dump_der,dump_der}'[use DER encoding when hexdumping fields]' \ + '(-dump_nostr dump_nostr)'{-dump_nostr,dump_nostr}'[dump non character string types]' \ + '(-dump_all dump_all)'{-dump_all,dump_all}'[dump all fields]' \ + '(-dump_unknown dump_unknown)'{-dump_unknown,dump_unknown}'[dump any field whose OID is not recognised by OpenSSL]' \ + '(-sep_comma_plus sep_comma_plus)'{-sep_comma_plus,sep_comma_plus}'[these options determine the field separators]' \ + '(-sep_comma_plus_space sep_comma_plus_space)'{-sep_comma_plus_space,sep_comma_plus_space}'[these options determine the field separators]' \ + '(-sep_semi_plus_space sep_semi_plus_space)'{-sep_semi_plus_space,sep_semi_plus_space}'[these options determine the field separators]' \ + '(-sep_multiline sep_multiline)'{-sep_multiline,sep_multiline}'[these options determine the field separators]' \ + '(-dn_rev dn_rev)'{-dn_rev,dn_rev}'[reverse the fields of the DN]' \ + '(-nofname nofname)'{-nofname,nofname}'[do not display field names]' \ + '(-sname sname)'{-sname,sname}'[display field names in short form]' \ + '(-lname lname)'{-lname,lname}'[display field names in long form]' \ + '(-oid oid)'{-oid,oid}'[display field names in numerical form]' \ + '(-align align)'{-align,align}'[align field values for a more readable output. Only usable with sep_multiline]' \ + '(-space_eq space_eq)'{-space_eq,space_eq}'[places spaces around the = character which follows the field name]' +} + + +_certopts() { + _values -s ',' -w 'certopts' \ + 'compatible[use the old format. This is equivalent to specifying no output options at all]' \ + "no_header[don't print header information: that is the lines saying \"Certificate\" and \"Data\"]" \ + "no_version[don't print out the version number]" \ + "no_serial[don't print out the serial number]" \ + "no_signame[don't print out the signature algorithm used]" \ + "no_validity[don't print the validity, that is the notBefore and notAfter fields]" \ + "no_subject[don't print out the subject name]" \ + "no_issuer[don't print out the issuer name]" \ + "no_pubkey[don't print out the public key]" \ + "no_sigdump[don't give a hexadecimal dump of the certificate signature]" \ + "no_aux[don't print out certificate trust information]" \ + "no_extensions[don't print out any X509V3 extensions]" \ + 'ext_default[retain default extension behaviour: attempt to print out unsupported certificate extensions]' \ + 'ext_error[print an error message for unsupported certificate extensions]' \ + 'ext_parse[ASN1 parse unsupported extensions]' \ + 'ext_dump[hex dump unsupported extensions]' \ + '(no_issuer no_pubkey no_header no_version no_sigdump no_signame)ca_default[the value used by the ca utility, equivalent to no_issuer, no_pubkey, no_header, no_version, no_sigdump and no_signame]' +} + + +_openssl "$@" + +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_pactree b/.zprezto/modules/completion/external/src/_pactree deleted file mode 100644 index 06bd404..0000000 --- a/.zprezto/modules/completion/external/src/_pactree +++ /dev/null @@ -1,26 +0,0 @@ -#compdef pactree -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for pactree 4.0 -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Limao Luo -# -# ------------------------------------------------------------------------------ - -typeset -A opt_args - -_pactree() { - local -a cmd packages packages_long - packages_long=(/var/lib/pacman/local/*(/)) - packages=( ${${packages_long#/var/lib/pacman/local/}%-*-*} ) - compadd "$@" -a packages -} - -# run the main dispatcher -_pactree "$@" diff --git a/.zprezto/modules/completion/external/src/_paste b/.zprezto/modules/completion/external/src/_paste new file mode 100644 index 0000000..fd7d035 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_paste @@ -0,0 +1,58 @@ +#compdef paste +# +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for paste (from util-linux 2.27.1->) +# (https://git.kernel.org/cgit/utils/util-linux/util-linux.git/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Ole Jørgen Brønner +# +# ------------------------------------------------------------------------------ +# +# Note: paste has upstream bash completion +# Note: Credit to https://github.com/RobSis/zsh-completion-generator which was +# used to generate most of the script. + +local arguments + +arguments=( + '*'{-d,--delimiters}'[reuse characters from LIST instead of TABs]:delimiters' + '(-s --serial)'{-s,--serial}'[paste one file at a time instead of in parallel]' + '(-z --zero-terminated)'{-z,--zero-terminated}'[line delimiter is NUL, not newline]' + '--help[display this help and exit]' + '--version[output version information and exit]' + '*:filename:_files' +) + +_arguments -s $arguments diff --git a/.zprezto/modules/completion/external/src/_patool b/.zprezto/modules/completion/external/src/_patool new file mode 100644 index 0000000..d132a6c --- /dev/null +++ b/.zprezto/modules/completion/external/src/_patool @@ -0,0 +1,95 @@ +#compdef patool +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# +# 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. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for patool (https://github.com/wummel/patool). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Sergei Eremenko (https://github.com/SmartFinn) +# +# ------------------------------------------------------------------------------ + +local state line ret=1 + +_arguments -C \ + '(-h --help)'{-h,--help}'[show help message and exit]' \ + '(--non-interactive)'--non-interactive'[do not query for user input]' \ + '(-v --verbose)'{-v,--verbose}'[verbose operation]' \ + '1:cmd:->cmds' \ + '*:arg:->args' && ret=0 + +case $state in + (cmds) + local -a cmds + + cmds=( + 'create:create an archive from given files' + 'diff:show differences between two archives' + 'extract:extract files from given archives' + 'formats:show all supported archive formats' + 'list:list files in archives' + 'repack:repackage archive to a different format' + 'recompress:recompress an archive to smaller size' + 'search:search in archive contents for given pattern' + 'test:test the given archives' + ) + + _describe -t commands 'patool commands' cmds && ret=0 + ;; + (args) + case $line[1] in + (extract) + _arguments \ + '--outdir[extract to the given output directory]:select directory:_files -/' \ + '*:files:_files' && ret=0 + ;; + (formats) + _message 'no more arguments' && ret=0 + ;; + (search) + _arguments \ + '2:search pattern:' \ + '*:files:_files' && ret=0 + ;; + (*) + _arguments \ + '*:files:_files' && ret=0 + ;; + esac + ;; +esac + +return $ret + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_pear b/.zprezto/modules/completion/external/src/_pear deleted file mode 100644 index 86f368f..0000000 --- a/.zprezto/modules/completion/external/src/_pear +++ /dev/null @@ -1,89 +0,0 @@ -#compdef pear -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for Pear (http://pear.php.net). -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * aki77 (https://github.com/aki77) -# -# ------------------------------------------------------------------------------ - - -_pear () { - local curcontext="$curcontext" state line expl ret=1 - - _arguments \ - '1: :->subcmds' \ - '*:: :->args' && ret=0 - - case $state in - subcmds) - _pear_commands - ;; - args) - local cmd args - - cmd=$words[1] - args=() - - case $cmd in - channel-alias|channel-delete|channel-info|channel-update) - args+=( - ':channel:_pear_discovered_channels' - ) - ;; - uninstall|upgrade|run-scripts) - args+=( - ':package:_pear_installed_packages' - ) - ;; - esac - - _arguments "$args[@]" && ret=0 - return - ;; - esac - return ret -} - -_pear_commands () { - local commands - - commands=( - ${${(f)${"$(_call_program commands $service 2>&1)"#*Commands:}%Usage:*}/[[:blank:]]*[[:blank:]][[:blank:]]/:} - ) - _describe -t commands 'Pear commands' commands -} - -_pear_installed_packages () { - local packages - - packages=( - ${${(f)"$(pear list)"#*STATE}%%[[:blank:]]*} - ) - _wanted package expl 'package' compadd -a packages -} - -_pear_discovered_channels () { - local channels - - channels=( - ${${${(f)"$(_call_program commands pear list-channels)"#*SUMMARY}%__uri*}%%[[:blank:]]*} - ) - _wanted channel expl 'channel' compadd -a channels -} - -_pear "$@" - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_perf b/.zprezto/modules/completion/external/src/_perf index bf5898d..74035d2 100644 --- a/.zprezto/modules/completion/external/src/_perf +++ b/.zprezto/modules/completion/external/src/_perf @@ -1,30 +1,5 @@ #compdef perf # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_periscope b/.zprezto/modules/completion/external/src/_periscope index 1d950b4..588c4ef 100644 --- a/.zprezto/modules/completion/external/src/_periscope +++ b/.zprezto/modules/completion/external/src/_periscope @@ -1,30 +1,5 @@ #compdef periscope # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_pgsql_utils b/.zprezto/modules/completion/external/src/_pgsql_utils index 64cd527..8bd16fb 100644 --- a/.zprezto/modules/completion/external/src/_pgsql_utils +++ b/.zprezto/modules/completion/external/src/_pgsql_utils @@ -1,5 +1,30 @@ #compdef psql pg_dump pg_dumpall pg_restore createdb dropdb vacuumdb createuser dropuser initdb # ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users, Dominic Mitchell, Johann 'Myrkraverk' Oskarsson, Daniel Serodio, J Smith +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ # Description # ----------- # @@ -121,11 +146,21 @@ _pgsql_databases () { local _pgsql_user _pgsql_port _pgsql_host _pgsql_params _pgsql_get_identity + local _pgsql_services _pgsql_service_files + _pgsql_service_files=( + ~/.pg_service.conf + $(pg_config --sysconfdir)/pg_service.conf + ) + _pgsql_services=$( grep -h '^\[.*\]' $_pgsql_service_files 2>/dev/null \ + | sed -e 's/^\[/service=/' -e 's/\].*$//' ) + local _pgsql_db_sql _pgsql_db_sql="select d.datname from pg_catalog.pg_database d \ where d.datname <> 'template0'" - compadd "$@" - $( psql $_pgsql_params[@] -Atq -c $_pgsql_db_sql template1 2>/dev/null ) + compadd "$@" - \ + ${(f)_pgsql_services} \ + $( psql $_pgsql_params[@] -Atq -c $_pgsql_db_sql template1 2>/dev/null ) } _pgsql_encodings () { @@ -154,8 +189,11 @@ _psql () { {-A,--no-align}'[unaligned output mode]' \ {-c+,--command=}':execute SQL command:' \ {-d+,--dbname=}':database to connect to:_pgsql_databases' \ + {-b,--echo-errors}'[echo failed commands]' \ {-e,--echo-queries}'[display queries submitted]' \ {-E,--echo-hidden}'[display hidden queries]' \ + {-L,--log-file=}'[send session log to file]' \ + {-n,--no-readline}'[disable enhanced command line editing (readline)]' \ {-f+,--file=}':SQL file to read:_files' \ {-F+,--field-separator=}':field separator char:' \ {-H,--html}'[HTML output]' \ @@ -171,6 +209,8 @@ _psql () { -u'[prompt for username/password]' \ {-v+,--set=,--variable=}':set SQL variable:' \ {-x,--expanded}'[one column per line]' \ + {-z,--field-separator-zero}'[set field separator for unaligned output to zero byte]' \ + {-0,--record-separator-zero}'[set record separator for unaligned output to zero byte]' \ {-X,--no-psqlrc}'[dont read ~/.psqlrc]' \ ':PostgreSQL database:_pgsql_databases' \ ':PostgreSQL user:_pgsql_users' @@ -191,6 +231,7 @@ _pg_dump () { {-D,--{attribute,column}-inserts}'[use INSERT (cols) not COPY]' \ {-f+,--file=}':output file:_files' \ {-F+,--format=}':output format:_values "format" "p[plain text]" "t[tar]" "c[custom]"' \ + {-j,--jobs=}'[use this many parallel jobs to dump]' \ {-i,--ignore-version}'[ignore version mismatch]' \ {-n+,--schema=}':schema to dump:_pgsql_schemas' \ {-N+,--exclude-schema=}':schema to NOT dump:_pgsql_schemas' \ @@ -208,13 +249,23 @@ _pg_dump () { {-Z+,--compress=}':compression level:_values "level" 9 8 7 6 5 4 3 2 1 0' \ ':PostgreSQL database:_pgsql_databases' \ --section=':dump named section:_values "section" pre-data data post-data' \ + --binary-upgrade'[for use by upgrade utilities only]' \ + --column-inserts'[dump data as INSERT commands with column names]' \ --disable-dollar-quoting'[disable dollar quoting, use SQL standard quoting]' \ --disable-triggers'[disable triggers during data-only restore]' \ + --enable-row-security'[enable row security (dump only content user has access to)]' \ + --exclude-table-data='[do NOT dump data for the named table(s)]' \ + --if-exists'[use IF EXISTS when dropping objects]' \ + --inserts'[dump data as INSERT commands, rather than COPY]' \ + --lock-wait-timeout='[fail after waiting TIMEOUT for a table lock]' \ --no-security-labels'[do not dump security label assignments]' \ + --no-synchronized-snapshots'[do not use synchronized snapshots in parallel jobs]' \ --no-tablespaces'[do not dump tablespace assignments]' \ --no-unlogged-table-data'[do not dump unlogged table data]' \ --quote-all-identifiers'[quote all identifiers, even if not key words]' \ --serializable-deferrable'[wait until the dump can run without anomalies]' \ + --snapshot='[use given snapshot for the dump]' \ + --strict-names'[require table and/or schema include patterns to match at least one entity each]' \ --use-set-session-authorization'[use SET SESSION AUTHORIZATION commands instead of ALTER OWNER]' } @@ -341,6 +392,7 @@ _createuser () { {-d,--createdb}'[role can create new databases]' \ {-D,--no-createdb}'[role cannot create databases]' \ {-E,--encrypted}'[encrypt stored password]' \ + {-g,--role=}'[new role will be a member of this role]' \ {-i,--inherit}'[role inherits privileges of roles it is a member of (default)]' \ {-I,--no-inherit}'[role does not inherit privileges]' \ {-l,--login}'[role can login (default)]' \ @@ -350,7 +402,10 @@ _createuser () { {-r,--createrole}'[role can create new roles]' \ {-R,--no-createrole}'[role cannot create roles]' \ {-s,--superuser}'[role will be superuser]' \ - {-S,--no-superuser}'[role will not be superuser]' + {-S,--no-superuser}'[role will not be superuser]' \ + {--interactive}'[prompt for missing role name and attributes rather than using defaults]' \ + {--replication}'[role can initiate replication]' \ + {--no-replication}'[role cannot initiate replication]' \ } _dropuser () { @@ -361,7 +416,7 @@ _dropuser () { "$_pgsql_common_opts[@]" \ {-e,--echo}'[display SQL queries]' \ {-q,--quiet}'[non verbose mode]' \ - {-i,--interactive}'[confirm before drop]' \ + {-i,--interactive}'[prompt before deleting anything, and prompt for role name if not specified]' \ ':PostgreSQL user:_pgsql_users' } @@ -371,6 +426,8 @@ _initdb () { _arguments -C -s \ {--auth=,-A+}':default authentication method for local connections:_values "auth methods" $_pgsql_auth_methods[@]' \ + --auth-host=':default authentication method for local TCP/IP connections:_values "auth methods" $_pgsql_auth_methods[@]' \ + --auth-local=':default authentication method for local-socket connections:_values "auth methods" $_pgsql_auth_methods[@]' \ {-D+,--pgdata=}':location for this database cluster:_files' \ {-E+,--encoding=}':set default encoding for new databases:' \ --locale=':set default locale for new databases:' \ @@ -388,8 +445,11 @@ _initdb () { {-X+,--xlogdir=}':location for the transaction log directory:_files' \ {-d,--debug}'[generate lots of debugging output]' \ -L+':where to find the input files:_files' \ + {-k,--data-checksums}':use data page checksums:' \ {-n,--noclean}'[do not clean up after errors]' \ + {-N,--nosync}':do not wait for changes to be written safely to disk:' \ {-s,--show}'[show internal settings]' \ + {-S,--sync-only}'[only sync data directory]' \ ':location for this database cluster:_files' } @@ -402,6 +462,7 @@ _pgsql_utils () { {-p+,--port=}':database port number:_pgsql_ports' {-U+,--username=}':connect as user:_pgsql_users' {-W,--password}'[prompt for password]' + --role='[do SET ROLE before restore]' ) _pgsql_auth_methods=( diff --git a/.zprezto/modules/completion/external/src/_pixz b/.zprezto/modules/completion/external/src/_pixz new file mode 100644 index 0000000..f15c3ca --- /dev/null +++ b/.zprezto/modules/completion/external/src/_pixz @@ -0,0 +1,100 @@ +#compdef pixz +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for pixz a parallel, indexing version of xz. (https://github.com/vasi/pixz). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + +local -a files index +files=() +index=() + +_pixz_compressed_files() { + files=("${(f)$(ls -l | grep '.tpxz$\|.xz$' | rev | cut -d' ' -f1 | rev)}") +} + +_pixz_load_file_index() { + index=("${(f)$(pixz -l $1)}") +} + +_pixz() { + + _arguments -C \ + '(- 1 *)'-h"[Show help and exit]" \ + '(- 1 *)'-l"[List tarball contents very fast]:file:->xzfiles" \ + '(- 1 *)'-x"[Extract one file very fast]:filepath:->filepath" \ + '(- 1 *)'-d"[Decompress]:file:->xzfiles" \ + "-i[Input]:file:->files" \ + "-o[Output]:output:->outputxz" \ + "-p[Use a maximum of NUM CPU-intensive threads]:cpu:->cpus" \ + "-t[Don't assume input is in tar format]" \ + "-k[Keep original input (do not remove it)]" \ + "-e[Use "extreme" compression, which is much slower]" \ + "-f[Set the size of each compression block, relative to the LZMA dictionary size (default is 2.0)]:num" \ + "-q[Set the number of blocks to allocate for the compression queue (default is 1.3 * cores + 2)]:num" \ + '1:inputfile:->files' \ + '2:outputfile' \ + '*: : :->args' \ + + case "$state" in + (cmds) + _describe -t commands 'commands' commands + ;; + (xzfiles) + _pixz_compressed_files + _describe -t files 'files' files + ;; + (files) + _files + ;; + (cpus) + local num_cpus cores + num_cpus=$(nproc) + cores=() + for i in {1..$num_cpus}; do + cores+=($i) + done + _describe -t cores 'cores' cores + ;; + (filepath) + ;; + (*) + ;; + esac +} + +_pixz + diff --git a/.zprezto/modules/completion/external/src/_play b/.zprezto/modules/completion/external/src/_play index 3960d8a..fb2cf59 100644 --- a/.zprezto/modules/completion/external/src/_play +++ b/.zprezto/modules/completion/external/src/_play @@ -1,30 +1,5 @@ #compdef play # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_port b/.zprezto/modules/completion/external/src/_port index 8e3fc5b..29a08fa 100644 --- a/.zprezto/modules/completion/external/src/_port +++ b/.zprezto/modules/completion/external/src/_port @@ -12,6 +12,34 @@ # * Matt Cable # * Sorin Ionescu # * Aljaž Srebrnič +# ----------------------------------------------------------------------------- +# License +# ------- +# +# Copyright (c) 2016, Matt Cable, Sorin Ionescu, Aljaž Srebrnič +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # ------------------------------------------------------------------------------ @@ -221,6 +249,13 @@ _port_select() { fi } +stat -f%m . > /dev/null 2>&1 +if [ "$?" = 0 ]; then + stat_cmd=(stat -f%Z) +else + stat_cmd=(stat --format=%Z) +fi + _port_caching_policy() { local reg_time comp_time check_file case "${1##*/}" in @@ -231,8 +266,8 @@ _port_caching_policy() { check_file=${$(port dir MacPorts)%/*/*}/PortIndex ;; esac - reg_time=$(stat -c '%Z' $check_file) - comp_time=$(stat -c '%Z' $1) + reg_time=$($stat_cmd $check_file) + comp_time=$($stat_cmd $1) return $(( reg_time < comp_time )) } diff --git a/.zprezto/modules/completion/external/src/_primus b/.zprezto/modules/completion/external/src/_primus deleted file mode 100644 index 6530db2..0000000 --- a/.zprezto/modules/completion/external/src/_primus +++ /dev/null @@ -1,43 +0,0 @@ -# compdef primus -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for primus (https://github.com/amonakov/primus). -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Christophe-Marie Duquesne -# -# ------------------------------------------------------------------------------ - - -local curcontext="$curcontext" state line -typeset -A opt_args - -args=( - '--version[output version information]' - '(-h --help)'{-h,--help}'[show help]' - '(-c --vgl-compress)'{-c,--vgl-compress}'[image transport method]:method:(proxy jpeg rgb xb yuv)' - '--failsafe[run a program even if the nvidia card is unavailable]' - '--no-failsafe[do not run a program if the nvidia card is unavailable]' - '--vgl-options[options to be passed to vglrun (example: +tr)]' - '(-q --quiet --silent)'{-q,--quiet,--silent}'[suppress all logging messages]' - '(-v --verbose)'{-v,--verbose}'[increase the verbosity level of log messages]' - '--debug[set the verbosity level to the maximum]' - '(-d --display)'{-d,--display}'[the X display number to use]' - '(-C --config)'{-C,--config}'[retrieve settings for Bumblebee from FILE]:file:_files' - '(-l --ldpath)'{-l,--ldpath}'[PATH the libraries like libGL.so are searched in]:file:_files -/' - '(-s --socket)'{-s,--socket}'[use FILE for communication with the daemon]:file:_files' -) - -_arguments $args -# -c, --vgl-compress METHOD image compression or transport to use with -# VirtualGL. Valid values for METHOD are proxy, -# jpeg, rgb, xv and yuv. Changing this setting -# may affect performance, CPU usage and image -# quality -# -d, --display DISPLAY the X display number to use - diff --git a/.zprezto/modules/completion/external/src/_ps b/.zprezto/modules/completion/external/src/_ps deleted file mode 100644 index a0755d4..0000000 --- a/.zprezto/modules/completion/external/src/_ps +++ /dev/null @@ -1,102 +0,0 @@ -#compdef ps - -# This works with procps version 3.2.8 - -local context state state_descr line -typeset -A opt_args -local filterexcl="(-A -a -C -d -e -g -G --group --Group -p --pid --ppid -s --sid -t --tty -u -U --user --User)" - -_arguments -s -w \ - "$filterexcl-A[all processes]"\ - "$filterexcl-a[all w/ tty except session leaders]"\ - "--cumulative[include some dead child process data (as a sum with the parent)]"\ - "(-f -F --format -l -o -O)--context[display security context format (for SE Linux)]"\ - "-c[show different scheduler information]"\ - "$filterexcl-C[by command name]:processes:->pname"\ - "(--columns)--cols[set screen width]:width:( )"\ - "(--cols)--columns[set screen width]:width:( )"\ - "--deselect[negate selection]"\ - "$filterexcl-d[all except session leaders]"\ - "$filterexcl-e[all processes]"\ - "--forest[ASCII art process tree]"\ - "(--context -F --format -o -O)-f[full format listing]"\ - "(--context -f --format -o -O)-F[extra full format]"\ - "(--context -f -F -j -l -o -O)--format[user-defined format]:output format:->format"\ - "$filterexcl-g[by session OR by effective group name]:groups:_groups"\ - "$filterexcl-G[by real group ID (supports names)]:groups:->rgid"\ - "$filterexcl--group[by session OR by effective group name]:groups:_groups"\ - "$filterexcl--Group[by real group ID (supports names)]:groups:->rgid"\ - "-H[show process hierarchy]"\ - "(--no-heading)--heading[repeat header lines, one per page of output]"\ - "-j[jobs format]"\ - "-l[long format. the -y option is often useful with this]"\ - "-L[show threads, possibly with LWP and NLWP columns]"\ - "-m[show threads after processes]"\ - "-M[add a column of security data]"\ - "-N[negate selection]"\ - "(--heading --header)--no-heading[omit header lines]"\ - "(--context -f -F --format -j -l)-o[user-defined format]:output format:->format"\ - "(--context -f -F --format -j -l)-O[preloaded -o (user-defined with some)]:output format:->format"\ - "$filterexcl-p[by process ID]:process IDs:->pid"\ - "$filterexcl--pid[by process ID]:process IDs:->pid"\ - "$filterexcl--ppid[select by parent process ID]:process IDs:->ppid"\ - "--rows[set screen height.]:height:( )"\ - "$filterexcl-s[by session IDs]:sessions:->sid"\ - "$filterexcl--sid[by session IDs]:sessions:->sid"\ - "--sort[specify sorting order]:sort specs:->sortspec"\ - "$filterexcl-t[by tty]:ttys:->tty"\ - "-T[show threads, possibly with SPID column]"\ - "$filterexcl--tty[by tty]:ttys:->tty"\ - "$filterexcl-u[by effective user ID (supports names)]:users:_users"\ - "$filterexcl-U[by real user ID (supports names)]:users:_users"\ - "$filterexcl--user[by effective user ID (supports names)]:users:_users"\ - "$filterexcl--User[by real user ID (supports names)]:users:_users"\ - "(--version)-V[print the procps version]"\ - "(-V)--version[print the procps version]"\ - "-w[wide output]"\ - "-y[use with -l, do not show flags, show rss in place of addr]"\ - "1:BSD-style options (complete - to see unix & gnu-style options):((T\:'all processes on this terminal' a\:'all w/ tty, including other users' r\:'only running processes' x\:'processes w/o controlling ttys' t\:'list by tty' j\:'BSD jobs control format' l\:'BSD long format' s\:'signal format' v\:'virtual memory format' u\:'user-oriented format' X\:'register format' L\:'list format codes' S\:'sum info of children into parents' c\:'true command name' n\:'numeric WCHAN & UID' H\:'show threads as if they were processes' U\:'by effective user ID' p\:'by process ID'))"\ - - debug "--info[print debugging info]" - -case "$state" in - pid) - _values -s , 'process id' "${(uonzf)$(ps -A o pid=)}" - ;; - rgid) - _values -s , 'process group id' "${(uonzf)$(ps -A o rgid=)}" - ;; - pname) - local ispat="pattern matching " - if (( ${+opt_args[-x]} )) - then - ispat="" - fi - if (( ${+opt_args[-f]} )) - then - _wanted pname expl $ispat'process command line' compadd ${(u)${(f)"$(ps -A o cmd=)"}} - else - _wanted pname expl $ispat'process name' compadd ${(u)${(f)"$(ps -A co cmd=)"}} - fi - ;; - sid) - _values -s , 'session id' "${(uonzf)$(ps -A o sid=)}" - ;; - tty) - local -a ttys - ttys=( /dev/tty*(N) /dev/pts/*(N) ) - _values -s , 'terminal device' ${ttys#/dev/} - ;; - ppid) - _values -s , 'parent process id' "${(uonzf)$(ps -A o ppid=)}" - ;; - sortspec) - _values -s , 'format specifier (prefix with - for decreasing order)' "${(uozf)$(ps L|cut -f 1 -d" ")}" - ;; - format) - _values -s , 'format specifier' "${(uozf)$(ps L|cut -f 1 -d" ")}" - ;; -esac - -# Local Variables: -# mode:shell-script -# End: diff --git a/.zprezto/modules/completion/external/src/_rails b/.zprezto/modules/completion/external/src/_rails index 4b66108..6dc85d4 100644 --- a/.zprezto/modules/completion/external/src/_rails +++ b/.zprezto/modules/completion/external/src/_rails @@ -1,5 +1,30 @@ #compdef rails # ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ # Description # ----------- # @@ -54,6 +79,7 @@ __rails_commands() { profiler'[Get profile information from a piece of code]' plugin'[Install a plugin]' {runner,r}'[Run a piece of code in the application environment]' + {test,t}'[Run tests]' ) else commands=( @@ -375,8 +401,8 @@ _rails_generate_scaffold_controller() { _arguments \ $model_generators_options \ - '(-e,--template-engine)'{-e,--template-engine=}'[Template engine to be invoked]:template engine' \ - '(-t,--test-framework)'{-t,--test-framework=}'[Test framework to be invoked]:test framework' \ + '(-e --template-engine)'{-e,--template-engine=}'[Template engine to be invoked]:template engine' \ + '(-t --test-framework)'{-t,--test-framework=}'[Test framework to be invoked]:test framework' \ --helper'[Indicates when to generate helper]: :__rails_boolean' \ ': :_guard "^-*" "name"' } @@ -445,16 +471,16 @@ _rails_new() { _arguments -C \ $rails_options \ $runtime_options \ - '(-r,--ruby)'{-r,--ruby=}'[Path to the Ruby binary of your choice]:path' \ - '(-b,--builder)'{-b,--builder=}'[Path to a application builder (can be a filesystem path or URL)]: :->path_or_url' \ - '(-m,--template)'{-m,--template=}'[Path to an application template (can be a filesystem path or URL)]: :->path_or_url' \ + '(-r --ruby)'{-r,--ruby=}'[Path to the Ruby binary of your choice]:path' \ + '(-b --builder)'{-b,--builder=}'[Path to a application builder (can be a filesystem path or URL)]: :->path_or_url' \ + '(-m --template)'{-m,--template=}'[Path to an application template (can be a filesystem path or URL)]: :->path_or_url' \ --skip-gemfile"[Don't create a Gemfile]" \ --skip-bundle"[Don't run bundle install]" \ - '(-G,--skip-git)'{-G,--skip-git}'[Skip Git ignores and keeps]' \ - '(-O,--skip-active-record)'{-O,--skip-active-record}'[Skip Active Record files]' \ - '(-S,--skip-sprockets)'{-S,--skip-sprockets}'[Skip Sprockets files]' \ - '(-d,--database)'{-d,--database=}'[Preconfigure for selected database]:database:(mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc)' \ - '(-j,--javascript)'{-j,--javascript=}'[Preconfigure for selected JavaScript library]:javascript' \ + '(-G --skip-git)'{-G,--skip-git}'[Skip Git ignores and keeps]' \ + '(-O --skip-active-record)'{-O,--skip-active-record}'[Skip Active Record files]' \ + '(-S --skip-sprockets)'{-S,--skip-sprockets}'[Skip Sprockets files]' \ + '(-d --database)'{-d,--database=}'[Preconfigure for selected database]:database:(mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc)' \ + '(-j --javascript)'{-j,--javascript=}'[Preconfigure for selected JavaScript library]:javascript' \ '(-J --skip-javascript)'{-J,--skip-javascript}'[Skip JavaScript files]' \ --dev'[Setup the application with Gemfile pointing to your Rails checkout]' \ --edge'[Setup the application with Gemfile pointing to Rails repository]' \ @@ -569,6 +595,24 @@ _rails_r() { _rails_runner } +_rails_test() { + local context state line curcontext="$curcontext" + + _arguments -C \ + ': :->path' + + case "$state" in + path) + _alternative \ + 'files:filename:_files -g "*.rb"' + ;; + esac +} + +_rails_t() { + _rails_test +} + _rails "$@" # Local Variables: diff --git a/.zprezto/modules/completion/external/src/_ralio b/.zprezto/modules/completion/external/src/_ralio index 7c35552..cedbb02 100644 --- a/.zprezto/modules/completion/external/src/_ralio +++ b/.zprezto/modules/completion/external/src/_ralio @@ -1,12 +1,43 @@ #compdef ralio - -# ZSH completion for ralio +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. # -# https://github.com/oesmith/ralio +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. # -# Author +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- # -# Peter Yates +# Completion script for ralio (https://github.com/oesmith/ralio), a +# Rally client +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Peter Yates +# +# ------------------------------------------------------------------------------ _ralio () { diff --git a/.zprezto/modules/completion/external/src/_rclone b/.zprezto/modules/completion/external/src/_rclone new file mode 100644 index 0000000..15d3fc0 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_rclone @@ -0,0 +1,119 @@ +#compdef rclone + +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for rclone (http://rclone.org/). +# +# ------------------------------------------------------------------------------ +# Author(s) +# ------- +# +# * Rajat Roy +# +# ------------------------------------------------------------------------------ + +_rclone() { + local state + + _arguments \ + '1: :->subcommand' \ + '--bwlimit' \ + '--checkers' \ + '(-c --checksum)'{-c,--checksum}'[check the file hash and size to determine if files are equal]' \ + '--config' \ + '--contimeout' \ + '--dedupe-mode' \ + '(-n --dry-run)'{-n,--dry-run}'[Do a trial run with no permanent changes]' \ + '--ignore-existing' \ + '--ignore-size' \ + '(-I --ignore-times)'{-I,--ignore-times}'[unconditionally upload all files regardless of the state of files on the destination]' \ + '--log-file' \ + '--low-level-retries' \ + '--max-depth' \ + '--modify-window' \ + '--no-gzip-encoding' \ + '--no-update-modtime' \ + '(-q --quiet)'{-q,--quiet}'[as little output as possible]' \ + '--retries' \ + '--size-only' \ + '--stats' \ + '--delete-' \ + '--timeout' \ + '--transfers' \ + '(-u --update)'{-u,--update}'[skip any files which exist on the destination and have a modified time that is newer than the source file]' \ + '(-v --verbose)'{-v,--verbose}'[tells you about every file it considers and transfers]' \ + '--delete-excluded' \ + '--filter' \ + '--filter-from' \ + '-exclude' \ + '--exclude-from' \ + '--include' \ + '--include-from' \ + '--files-from' \ + '--min-size' \ + '--max-size' \ + '--min-age' \ + '--max-age' \ + '--dump-filters' \ + '*:files:_files' + + case $state in + subcommand) + _arguments '1: :( + config + copy + sync + move + delete + purge + mkdir + rmdir + check + ls + lsd + lsl + md5sum + sha1sum + size + version + cleanup + dedupe + authorize + cat + genautocomplete + gendocs + listremotes + mount + --help)' + ;; + esac +} + +_rclone "$@" diff --git a/.zprezto/modules/completion/external/src/_redis-cli b/.zprezto/modules/completion/external/src/_redis-cli index 1e1aa36..d11c06f 100644 --- a/.zprezto/modules/completion/external/src/_redis-cli +++ b/.zprezto/modules/completion/external/src/_redis-cli @@ -1,5 +1,26 @@ #compdef redis-cli rec # ------------------------------------------------------------------------------ +# Copyright (c) 2009-2015 Robby Russell and contributors (see +# https://github.com/robbyrussell/oh-my-zsh/contributors) +# +# 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. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_rkt b/.zprezto/modules/completion/external/src/_rkt new file mode 100644 index 0000000..d4ce021 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_rkt @@ -0,0 +1,369 @@ +#compdef rkt +# ------------------------------------------------------------------------------ +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for rkt (https://coreos.com/rkt/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Massimiliano Torromeo +# +# ------------------------------------------------------------------------------ + +typeset -A opt_args +autoload -U regexp-replace + +_rkt() { + _arguments \ + '--debug[print out more debug information to stderr]' \ + '--dir=[rkt data directory]:data directory:_files -/' \ + '--insecure-options=[comma-separated list of security features to disable]:option:{_values -s , none image tls ondisk http all}' \ + '--local-config=[local configuration directory]:configuration directory:_files -/' \ + '--system-config=[system configuration directory]:configuration directory:_files -/' \ + '--trust-keys-from-https[automatically trust gpg keys fetched from https]' \ + '--user-config=[user configuration directory]:configuration directory:_files -/' \ + '--help' \ + '1: :_rkt_cmds' \ + '*:: :->rkt_cmd_args' + + case $state in + rkt_cmd_args) + case $words[1] in + help) + _arguments \ + '1: :_rkt_cmds' \ + '*:: :->rkt_help_args' \ + ;; + + api-service) + _arguments \ + '--listen=[address to listen for client API requests]:address' \ + ;; + + cat-manifest) + _arguments \ + '--pretty-print[apply indent to format the output]' \ + '--uuid-file=[read pod UUID from file instead of argument]:uuid file:_files' \ + '1:POD:_rkt_pods' \ + ;; + + config) + _arguments \ + '--pretty-print[apply indent to format the output]' \ + ;; + + enter) + _arguments \ + '--app=:appname' \ + '1:POD:_rkt_pods' \ + ;; + + export) + _arguments \ + '--app=:appname' \ + '--overwrite[overwrite output ACI]' \ + '1:POD:_rkt_pods' \ + '2:OUTPUT_ACI_FILE:_files' \ + ;; + + fetch) + _arguments \ + '--full[print the full image hash after fetching]' \ + '--no-store[fetch images ignoring the local store]' \ + '--signature=[local signature file to use in validating the preceding image]:signature:_files' \ + '--store-only[use only available images in the store]' \ + ;; + + gc) + _arguments \ + '--grace-period=[duration to wait before discarding inactive pods from garbage]:duration' \ + '--expire-prepared=[duration to wait before expiring prepared pods]:duration' \ + '--mark-only[move to the garbage directories without actually deleting]' \ + ;; + + image) + _arguments \ + '1: :_rkt_image_cmds' \ + '*:: :->rkt_image_args' + ;; + + list) + _arguments \ + '--full[use long output format]' \ + '--no-legend[suppress a legend with the list]' \ + ;; + + metadata-service) + _arguments \ + '--listen-port=[listen port]:port' \ + ;; + + prepare) + # TODO: autocomplete stage1 images + _arguments \ + '--caps-remove=[capability to remove]:capability' \ + '--caps-retain=[capability to retain]:capability' \ + '--cpu=[cpu limit for the preceding image]:cpu limit' \ + '--cpu-shares=[assign the specified CPU time share weight]:weight' \ + "--environment=[set the app's environment variables]:variable key=value" \ + '--exec=[override the exec command for the preceding image]:command' \ + '--group=[group override for the preceding image]:group' \ + '--inherit-env[inherit all environment variables not set by apps]' \ + '--memory=[memory limit for the preceding image]:memory' \ + '--mount=[mount point binding a volume to a path within an app]:mount point' \ + '--name=[set the name of the app]:name' \ + '--no-overlay[disable overlay filesystem]' \ + '--oom-score-adj=[oom-score-adj isolator override]:oom-score-adj' \ + '--pod-manifest=[the path to the pod manifest]:manifest:_files' \ + '--port=[ports to expose on the host]:NAME\:HOSTPORT' \ + '--private-users[run within user namespaces]' \ + '--quiet[suppress superfluous output on stdout, print only the UUID on success]' \ + '--readonly-rootfs=[mount rootfs read-only]:fs' \ + '--set-env=[an environment variable to set for apps]:NAME=VALUE' \ + '--set-env-file=[the path to an environment variables file]:file:_files' \ + '--signature=[local signature file to use in validating the preceding image]:signature:_files' \ + '--stage1-from-dir=[a filename of an image in stage1 images directory to use as stage1]:image' \ + '--stage1-hash=[a hash of an image to use as stage1]:image hash' \ + '--stage1-name=[a name of an image to use as stage1]:image name' \ + '--stage1-path=[a path to an image to use as stage1]:image path:_files' \ + '--stage1-url=[a URL to an image to use as stage1]:image url' \ + '--supplementary-gids=[supplementary group IDs override for the preceding image]:group IDs' \ + '--user=[user override for the preceding image]:user' \ + "--user-annotation=[set the app's annotations]:annotation key=value" \ + "--user-label=[set the app's labels]:label key=value" \ + '--volume=[volumes to make available in the pod]:volume' \ + '--working-dir=[override the working directory of the preceding image]:working directory:_files -/' \ + '1:IMAGE:_rkt_images' \ + ;; + + rm) + _arguments \ + '--uuid-file=[read pod UUID from file instead of argument]:uuid file:_files' \ + '1:POD:_rkt_pods' \ + ;; + + run) + _arguments \ + '--caps-remove=[capability to remove]:capability' \ + '--caps-retain=[capability to retain]:capability' \ + '--cpu=[cpu limit for the preceding image]:cpu limit' \ + '--cpu-shares=[assign the specified CPU time share weight]:weight' \ + '--dns=[name servers to write in /etc/resolv.conf]:name servers' \ + '--dns-domain=[DNS domain to write in]:domain' \ + '--dns-opt=[DNS options to write in /etc/resolv.conf]:dns options' \ + '--dns-search=[DNS search domains to write in /etc/resolv.conf]:search domains' \ + "--environment=[set the app's environment variables]:variable key=value" \ + '--exec=[override the exec command for the preceding image]:command' \ + '--group=[group override for the preceding image]:group' \ + "--hostname=[pod's hostname]:hostname" \ + "--hosts-entry=[entries to add to the pod-wide /etc/hosts. Pass 'host' to use the host's /etc/hosts]:hosts entry" \ + '--inherit-env[inherit all environment variables not set by apps]' \ + '--interactive[run pod interactively]' \ + '--mds-register[register pod with metadata service]' \ + '--memory=[memory limit for the preceding image]:memory limit' \ + '--mount=[mount point binding a volume to a path within an app]:mount point' \ + '--name=[set the name of the app]:name' \ + "--net=[configure the pod's networking]:networks" \ + '--no-overlay[disable overlay filesystem]' \ + '--pod-manifest=[the path to the pod manifest]:manifest:_files' \ + '--port=[ports to expose on the host]:NAME\:HOSTPORT' \ + '--private-users[run within user namespaces]' \ + '--set-env=[an environment variable to set for apps]:NAME=VALUE' \ + '--set-env-file=[the path to an environment variables file]:file:_files' \ + '--signature=[local signature file to use in validating the preceding image]:signature:_files' \ + '--stage1-from-dir=[a filename of an image in stage1 images directory to use as stage1]:image' \ + '--stage1-hash=[a hash of an image to use as stage1]:image hash' \ + '--stage1-name=[a name of an image to use as stage1]:image name' \ + '--stage1-path=[a path to an image to use as stage1]:image path:_files' \ + '--stage1-url=[a URL to an image to use as stage1]:image url' \ + '--supplementary-gids=[supplementary group IDs override for the preceding image]:group IDs' \ + '--user=[user override for the preceding image]:user' \ + "--user-annotation=[set the app's annotations]:annotation key=value" \ + "--user-label=[set the app's labels]:label key=value" \ + '--uuid-file-save=[write out pod UUID to specified file]:uuid file:_files' \ + '--volume=[volumes to make available in the pod]:volume' \ + '--working-dir=[override the working directory of the preceding image]:working directory:_files -/' \ + '1:IMAGE:_rkt_images' \ + ;; + + run-prepared) + _arguments \ + '--dns=[name servers to write in /etc/resolv.conf]:name servers' \ + '--dns-domain=[DNS domain to write in]:domain' \ + '--dns-opt=[DNS options to write in /etc/resolv.conf]:dns options' \ + '--dns-search=[DNS search domains to write in /etc/resolv.conf]:search domains' \ + "--hostname=[pod's hostname]:hostname" \ + "--hosts-entry=[entries to add to the pod-wide /etc/hosts. Pass 'host' to use the host's /etc/hosts]:hosts entry" \ + '--interactive[run pod interactively]' \ + '--mds-register[register pod with metadata service]' \ + "--net=[configure the pod's networking]:networks" \ + '1:POD:_rkt_pods' \ + ;; + + status) + _arguments \ + '--format=[choose the output format]:format:(json json-pretty)' \ + '--wait[toggles waiting for the pod to exit]' \ + '--wait-ready[toggles waiting until the pod is ready]' \ + '1:POD:_rkt_pods' \ + ;; + + stop) + _arguments \ + '--force[forced stopping]' \ + '--uuid-file=[read pod UUID from file instead of argument]:uuid file:_files' \ + '1:POD:_rkt_pods' \ + ;; + + trust) + _arguments \ + '--insecure-allow-http[allow HTTP use for key discovery and/or retrieval]' \ + '--prefix=[prefix to limit trust to]:prefix' \ + '--root[add root key from filesystem without a prefix]' \ + '--skip-fingerprint-review[accept key without fingerprint confirmation]' \ + ;; + esac + ;; + esac + + case $state in + rkt_help_args) + case $words[1] in + image) + _arguments \ + '1: :_rkt_image_cmds' + ;; + esac + ;; + + rkt_image_args) + case $words[1] in + cat-manifest) + _arguments \ + '--pretty-print[apply indent to format the output]' \ + '1:IMAGE:_rkt_images' \ + ;; + + export) + _arguments \ + '--overwrite[overwrite output ACI]' \ + '1:IMAGE:_rkt_images' \ + '2:OUTPUT_ACI_FILE:_files' \ + ;; + + extract|render) + _arguments \ + '--overwrite[overwrite output ACI]' \ + '--rootfs-only[extract rootfs only]' \ + '1:IMAGE:_rkt_images' \ + '2:OUTPUT_DIR:_files -/' \ + ;; + + gc) + _arguments \ + '--grace-period=[duration to wait before discarding inactive pods from garbage]:duration' \ + ;; + + list) + _arguments \ + '--fields=[comma-separated list of fields to display]:fields:{_values -s , id name importtime lastused size latest}' \ + '--full[use long output format]' \ + '--no-legend[suppress a legend with the list]' \ + ;; + + rm) + _arguments \ + '*:IMAGE:_rkt_images' \ + ;; + esac + ;; + esac +} + +_rkt_cmds() { + local -a commands + commands=( + 'api-service:Run API service' + 'cat-manifest:Inspect and print the pod manifest' + 'config:Print configuration for each stage in JSON format' + 'enter:Enter the namespaces of an app within a rkt pod' + 'export:Export an app from an exited pod to an ACI file' + 'fetch:Fetch image(s) and store them in the local store' + 'gc:Garbage collect rkt pods no longer in use' + 'image:Operate on image(s) in the local store' + 'list:List pods' + 'metadata-service:Run metadata service' + 'prepare:Prepare to run image(s) in a pod in rkt' + 'rm:Remove all files and resources associated with an exited pod' + 'run:Run image(s) in a pod in rkt' + 'run-prepared:Run a prepared application pod in rkt' + 'status:Check the status of a rkt pod' + 'stop:Stop a pod' + 'trust:Trust a key for image verification' + 'version:Print the version and exit' + 'help:Help about any command' + ) + _describe 'command' commands +} + +_rkt_image_cmds() { + local -a commands + commands=( + 'cat-manifest:Inspect and print the image manifest' + 'export:Export a stored image to an ACI file' + 'extract:Extract a stored image to a directory' + 'gc:Garbage collect local store' + 'list:List images in the local store' + 'render:Render a stored image to a directory with all its dependencies' + 'rm:Remove image(s) with the given ID(s) or name(s) from the local store' + ) + _describe 'command' commands +} + +_rkt_images() { + local -a images + images=($(rkt image list --fields id,name --no-legend | sed 's/\t/\n/;s/:/\\:/g' | sort | uniq)) + _describe 'IMAGE' images +} + +_rkt_pods() { + local -a pods + IFS=$'\n' + pods=($(rkt list --full --no-legend | sed 's/:/\\:/g;s/\t/:/;s/\t/ /g')) + _describe 'POD' pods +} + +_rkt "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_rslsync b/.zprezto/modules/completion/external/src/_rslsync new file mode 100644 index 0000000..d1cd5bc --- /dev/null +++ b/.zprezto/modules/completion/external/src/_rslsync @@ -0,0 +1,61 @@ +#compdef rslsync +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for resilio sync (https://getsync.com/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Fabian Klötzl (https://github.com/kloetzl) +# +# ------------------------------------------------------------------------------ + +_rslsync(){ + integer ret=1 + local -a args + args+=( + '(-)--help[Print help]' + '(--help)--config[Use a configuration file]:file:_files' + '(--help)--dump-sample-config[Print a sample configuration file]' + '(--help)--generate-secret[Generate a read/write key]::version:(2)' + '(--help)--get-ro-secret[Get the read-only key associated to a read/write key]:key:' + '(--help)--identity[Creates user identity]:name:' + '(--help)--license[Apply owner license]:file:_files' + '(--help)--log[Set log file]:file:_files' + '(--help)--nodaemon[Do not daemonize]' + '(--help)--storage[Storage path for identity and license]:path:_files -/' + '(--help)--webui.listen[Set the webui listening interface]:ip\:port:' + ) + _arguments $args[@] && ret=0 + return ret +} + +_rslsync diff --git a/.zprezto/modules/completion/external/src/_rspec b/.zprezto/modules/completion/external/src/_rspec index 394fe4b..2ffb196 100644 --- a/.zprezto/modules/completion/external/src/_rspec +++ b/.zprezto/modules/completion/external/src/_rspec @@ -1,5 +1,30 @@ #compdef rspec # ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_rsvm b/.zprezto/modules/completion/external/src/_rsvm new file mode 100644 index 0000000..d6de50c --- /dev/null +++ b/.zprezto/modules/completion/external/src/_rsvm @@ -0,0 +1,88 @@ +#compdef rsvm +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for rsvm (https://github.com/sdepold/rsvm). +# Adapted from Docker Machine completion by hhatto (https://github.com/ilkka) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * michaelmior (https://github.com/michaelmior) +# +# ------------------------------------------------------------------------------ + +# helper function for completing available rusts +__rusts() { + declare -a rusts_cmd + rusts_cmd=($(ls "$HOME/.rsvm/versions")) + _describe 'rusts' rusts_cmd +} + +# subcommands +local -a _rsvm_cmds + +_rsvm_cmds=( + 'help:Show a help message' \ + 'install:Download and install a version' \ + 'uninstall:Uninstall a version' \ + 'use:Activate a version for now and the future' \ + 'ls:List all installed versions of rust' \ + 'ls-remote:List remote versions available for install' \ + 'ls-channel:Print a channel version available for install' \ +) + +# subcommand completion functions +__uninstall() { + __rusts +} + +__use() { + __rusts +} + +# common args +_arguments \ + '--help[show help]' \ + '--version[print the version]' \ + '*:: :->command' + +# start rusts! +if (( CURRENT == 1 )); then + _describe -t commands 'rsvm command' _rsvm_cmds +fi + +local -a _command_args +case "$words[1]" in + uninstall) + __uninstall ;; + use) + __use ;; +esac diff --git a/.zprezto/modules/completion/external/src/_rvm b/.zprezto/modules/completion/external/src/_rvm index 2a600e7..390e0f5 100644 --- a/.zprezto/modules/completion/external/src/_rvm +++ b/.zprezto/modules/completion/external/src/_rvm @@ -1,11 +1,26 @@ #compdef rvm # ------------------------------------------------------------------------------ +# Copyright (c) 2009-2011 Wayne E. Seguin +# Copyright (c) 2011-2015 Michal Papis +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ------------------------------------------------------------------------------ # Description # ----------- # # Completion script for rvm (https://rvm.beginrescueend.com/). # -# Source: https://github.com/wayneeseguin/rvm/blob/master/scripts/zsh/Completion/_rvm +# Source: https://github.com/rvm/rvm/blob/master/scripts/extras/completion.zsh/_rvm # # ------------------------------------------------------------------------------ # Authors diff --git a/.zprezto/modules/completion/external/src/_scl b/.zprezto/modules/completion/external/src/_scl new file mode 100644 index 0000000..831d528 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_scl @@ -0,0 +1,81 @@ +#compdef scl +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Software Collections (https://www.softwarecollections.org). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Julien Nicoulaud +# +# ------------------------------------------------------------------------------ + +_scl() { + local context curcontext="$curcontext" state line + typeset -A opt_args + + local ret=1 + + _arguments -C \ + '1: :_scl_cmds' \ + "(- : *)"{-h,--help}'[display help information]' \ + "(- : *)"{-l,--list}'[list installed Software Collections or packages that belong to them]:installed collection:_scl_installed_collections' \ + '*::arg:->args' \ + && ret=0 + + case $state in + (args) + curcontext="${curcontext%:*:*}:scl-cmd-$words[1]:" + case $line[1] in + (register) + _arguments '1:Software Collection path:_files -/' && ret=0 + ;; + (deregister) + _arguments -C \ + '1:: :_scl_installed_collections' \ + '--force[force suppression of the collection]' \ + && ret=0 + ;; + (enable) + _arguments -C \ + '1:: :_scl_installed_collections' \ + '2:command: _command_names -e' \ + && ret=0 + ;; + *) + _call_function ret _scl_cmd_$words[1] && ret=0 + (( ret )) && _message 'no more arguments' + ;; + esac + ;; + esac +} + +(( $+functions[_scl_cmds] )) || +_scl_cmds() { + local commands; commands=( + 'register:register a Software Collection' + 'deregister:deregister a Software Collection' + 'enable:enable a Software Collection' + ) + _describe -t commands 'scl command' commands "$@" +} + +(( $+functions[_scl_installed_collections] )) || +_scl_installed_collections() { + local installed_collections; installed_collections=($(_call_program installed_collections $service --list)) + _describe -t collections 'Software Collection' installed_collections "$@" +} + +_scl "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_scrub b/.zprezto/modules/completion/external/src/_scrub new file mode 100644 index 0000000..2c473e3 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_scrub @@ -0,0 +1,66 @@ +#compdef scrub +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for scrub an utility which iteratively writes patterns on files or disk devices to make retrieving the data more difficult. (http://linux.die.net/man/1/scrub). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + + +_scrub() { + +local patterns +patterns="nnsa dod bsi gutmann schneier pfitzner7 pfitzner33 usarmy fillzero fillff random random2 old fastold" + +_arguments -C \ + "(- 1 *)"{-v,--version}"[Print scrub version and exit.]" \ + {-r,--remove}"[Remove the file after scrubbing.]" \ + {-p,--pattern}"[Select the patterns to write.]:pattern:($patterns)" \ + {-b,--blocksize}"[Perform read and write calls using the specified blocksize (in bytes).]:block size:" \ + {-f,--force}"[Scrub even if target contains signature indicating it has already been scrubbed.]" \ + {-S,--no-signature}"[Do not write scrub signature.]" \ + {-X,--freespace}"[Create specified directory and fill it with files until write returns ENOSPC (file sys‐tem full), then scrub the files as usual.]:directory name:" \ + {-D,--dirent}"[After scrubbing the file, scrub its name in the directory entry, then rename it to the new name.]:new name:" \ + {-s,--device-size}"[Override the device size (in bytes).]:size:" \ + {-L,--no-link}"[If file is a symbolic link, do not scrub the link target.]" \ + {-R,--no-hwrand}"[Don't use a hardware random number generator even if one is available.]" \ + {-t,--no-threads}"[Don't generate random data in parallel with I/O.]" \ + {-n,--dry-run}"[Do everything but write to targets.]" \ + {-h,--help}"[Print a summary of command line options on stderr.]" \ + '*:files:_files' \ +} + +_scrub + diff --git a/.zprezto/modules/completion/external/src/_setcap b/.zprezto/modules/completion/external/src/_setcap new file mode 100644 index 0000000..6f34a0e --- /dev/null +++ b/.zprezto/modules/completion/external/src/_setcap @@ -0,0 +1,108 @@ +#compdef setcap +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# ------------------------------------------------------------------------------ +# Description +# ------------------------------------------------------------------------------ +# Completion script for libcap's setcap: +# - https://people.redhat.com/sgrubb/libcap-ng/ +# +# ZSH provides the `zsh/cap` module that does not work on most modern systems, +# in lieu of this I have written this zsh-completion modules. +# +# Written by +# - Zephyr Pellerin (https://github.com/zv) +# ------------------------------------------------------------------------------ + +local curcontext=$curcontext state line expl ret=1 +local -a args privs operators + +args=( '*:file:->files' + '1:capability:->capability' + '-v[verify]' '-q[quiet]' ) + +_arguments -C -s "$args[@]" && ret=0 + +operators=("e:effective" "i:inheritable" "p:permitted") + +case "$state" in + capability) + if compset -P '*?[=+-]'; then + _describe -t operators "operator" operators && ret=0 + else + _values -s , capability \ + 'cap_audit_control[Enable and disable kernel auditing]' \ + 'cap_audit_read[Allow reading the audit log]' \ + 'cap_audit_write[Write records to kernel auditing log.]' \ + 'cap_block_suspend[Employ features that can block system suspend]' \ + 'cap_chown[Make arbitrary changes to file UIDs and GIDs]' \ + 'cap_dac_override[Bypass file read, write, and execute permission checks.]' \ + 'cap_dac_read_search[Bypass file read permission checks]' \ + 'cap_fowner[Bypass filesystem UID checks, set extended attrs.]' \ + "cap_fsetid[Don't clear set-user-ID and set-group-ID permission bits when a file is modified]" \ + 'cap_ipc_lock[Lock memory]' \ + 'cap_ipc_owner[Bypass checks on SySV IPC object operations.]' \ + 'cap_kill[Bypass permission checks for sending signals]' \ + 'cap_lease[Establish leases on arbitrary files]' \ + 'cap_linux_immutable[Set immutability or append only]' \ + 'cap_mac_admin[Override Mandatory Access Control]' \ + 'cap_mac_override[Allow MAC configuration or state changes.]' \ + 'cap_mknod[Create special files using mknod(2)]' \ + 'cap_net_admin[Perform various network-related operations]' \ + 'cap_net_bind_service[Bind a socket to a privileged ports.]' \ + 'cap_net_broadcast[Make socket broadcasts and listen to multicast.]' \ + 'cap_net_raw[Use raw sockets.]' \ + 'cap_setgid[Manipulate process GIDs.]' \ + 'cap_setfcap[Set file capabilities.]' \ + "cap_setpcap[Grant or remove any capability in the caller's permitted capability set to or from any other process.]" \ + 'cap_setuid[Manipulate or forge process UIDs]' \ + 'cap_sys_admin[Perform numerous administrative tasks.]' \ + 'cap_sys_boot[Reboot]' \ + 'cap_sys_chroot[Use chroot]' \ + 'cap_sys_module[Load kernel module.]' \ + 'cap_sys_nice[Nice or renice processes.]' \ + 'cap_sys_pacct[Use acct(2).]' \ + 'cap_sys_ptrace[Inspect processes with ptrace or use process_vm_writev.]' \ + 'cap_sys_rawio[Numerous device IO functions, including performing raw IO and access x86 MSRs]' \ + 'cap_sys_resource[Set numerous resource limits]' \ + 'cap_sys_time[Set system clock]' \ + 'cap_sys_tty_config[Use vhangup(2)]' \ + 'cap_syslog[Perform privileged syslog(2) operations.]' \ + 'cap_wake_alarm[Trigger something that will wake up the system]' && ret=0 + fi ;; + files) _files && ret=0 ;; +esac + +return ret + +# Local variables: +# mode: shell-script +# sh-basic-offset: 2 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: sw=2 ts=2 et filetype=sh diff --git a/.zprezto/modules/completion/external/src/_setup.py b/.zprezto/modules/completion/external/src/_setup.py index 8b7402e..c7d88d3 100644 --- a/.zprezto/modules/completion/external/src/_setup.py +++ b/.zprezto/modules/completion/external/src/_setup.py @@ -1,5 +1,25 @@ #compdef setup.py # ------------------------------------------------------------------------------ +# Copyright (C) 2015 by Hideo Hattori +# +# 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. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_showoff b/.zprezto/modules/completion/external/src/_showoff index 8a0104f..f470141 100644 --- a/.zprezto/modules/completion/external/src/_showoff +++ b/.zprezto/modules/completion/external/src/_showoff @@ -1,5 +1,30 @@ #compdef showoff # ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_socat b/.zprezto/modules/completion/external/src/_socat deleted file mode 100644 index 4b15e2a..0000000 --- a/.zprezto/modules/completion/external/src/_socat +++ /dev/null @@ -1,233 +0,0 @@ -#compdef socat -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for socat ( http://www.dest-unreach.org/socat/ ). -# -# Source: https://github.com/Valodim/zsh-socat-completion -# Last updated: 23.02.2013, commit 3c564c9 -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Valodim ( https://github.com/Valodim ) -# -# ------------------------------------------------------------------------------ - - -if (( ! $+_socat_params || ! $+_socat_groups )); then - - # we cache socat parameters, groups, option groups, option types parsed - # straight from socat, since these are platform specific - typeset -gHA _socat_params _socat_groups _socat_opt_groups _socat_opt_types - - if _cache_invalid socat-params || _cache_invalid socat-groups \ - || ! _retrieve_cache socat-params || ! _retrieve_cache socat-groups ; then - () { - setopt localoptions rematchpcre - local line - - # anyone know a better way to do "get rest starting from matching line" than awk? - _call_program socat-params socat -h | awk '/address-head:/,0 { print }' | while read -r line; do - - # parse line, format: proxy::: groups=A,B,C - [[ $line =~ '([^:]+)((?::<[^:]+>)*)\s+groups=(.+)' ]] || continue - - # canonicalize and note down parameters - _socat_params[$match[1]]=${${${match[2]#:}//(\<|\>)/}//:/,} - - # store groups for this parameter - _socat_groups[$match[1]]=${match[3]} - - done - - _store_cache socat-params _socat_params - _store_cache socat-groups _socat_groups - - } - fi - - if _cache_invalid socat-opt-groups || _cache_invalid socat-opt-types \ - || ! _retrieve_cache socat-opt-groups || ! _retrieve_cache socat-opt-types ; then - () { - setopt localoptions rematchpcre - local line - - _call_program socat-opts socat -hh | awk '/opt:/,0 { print }' | while read -r line; do - # parse format: wronly groups=OPEN phase=OPEN type=BOOL - [[ $line =~ ' *(\w+)\s+groups=(\w+)\s.+type=(\w+)' ]] || continue - _socat_opt_groups[$match[1]]=$match[2] - _socat_opt_types[$match[1]]=${(L)match[3]} - done - } - - _store_cache socat-opt-groups _socat_opt_groups - _store_cache socat-opt-types _socat_opt_types - fi -fi - -if (( ! $+_socat_param_handler )); then - typeset -gHA _socat_param_handler - # bunch of manually extracted parameter handlers. names work as both - _socat_param_handler=( - create _files - gopen _files - open _files - pipe '_files -g *(p)' - unix-connect '_files -g *(=)' - unix-listen '_files -g *(=)' - unix-sendto '_files -g *(=)' - unix-recvfrom '_files -g *(=)' - unix-client '_files -g *(=)' - host '_hosts -S : -r :,\ \\t\\n\\-' - ) -fi - -if (( ! $+_socat_opt_handler )); then - typeset -gHA _socat_opt_handler - # bunch of manually extracted handlers - _socat_opt_handler=( - history _files - lockfile _files - waitlock _files - allow-table _files - deny-table _files - link _files - cert _files - key _files - dhparams _files - cafile _files - egdfile _files - capath '_files -/' - tcpwrap-etc '_files -/' - capath '_files -/' - chroot-early '_files -/' - path _directories - group _groups - group-early _groups - group-late _groups - setgid _groups - setgid-early _groups - user _users - user-early _users - user-late _users - setuid _users - setuid-early _users - su _users - su-d _users - ) -fi - -_socat_address_head() { - setopt localoptions extendedglob - - # do we have a socket type yet? - if ! compset -P 1 '(#b)(*)(:|,)'; then - # all which have pameters (ie, non-empty values) - compadd -M 'M:{[:upper:]}={[:lower:]}' -S : -r ":, \t\n\-" -k '_socat_params[(R)?*]' - # others (ie, empty value) - compadd -M 'M:{[:upper:]}={[:lower:]}' -S , -q -k '_socat_params[(R)]' - return 0 - fi - - local expl ret=1 - - # any parameters? - local socket_type="${(L)match[1]}" lastop="$match[2]" - - local -a params_left - params_left=( "${(@s:,:)_socat_params[$socket_type]}" ) - - if [[ $lastop == ':' ]]; then - - # chunk away the parameters - while compset -P 1 '[^:]#:'; do - (( $#params_left > 0 )) && shift params_left - done - - if compset -P '*,'; then - lastop=',' - elif (( $#params_left == 0 )); then - _message -e parameters "No more parameters for $socket_type" && return 0 - else - # do we have a handler? this works either by typename or socket type - if (( $+_socat_param_handler[$socket_type] )); then - _wanted param expl "parameter $params_left[1]" "${(@z)_socat_param_handler[$socket_type]}" && return 0 - elif (( $+_socat_param_handler[${params_left[1]}] )); then - _wanted param expl "parameter $params_left[1]" "${(@z)_socat_param_handler[$params_left[1]]}" && return 0 - else - _message -e parameters "$params_left[1]" && return 0 - fi - fi - - # shift to make warning msg below accurate - (( $#params_left > 0 )) && shift params_left - - fi - - # got any params left? At least leave a note.. - (( $#params_left > 0 )) && _message -e parameters "Unfilled parameters: $params_left" - - if [[ $lastop == ',' ]]; then - # chip away all old opts - compset -P '*,' - # is it one with a type? - if compset -P '(#b)(*)\='; then - if (( $+_socat_opt_types[$match[1]] )); then - # do we have a handler? - if (( $+_socat_opt_handler[$match[1]] )); then - _wanted optparam expl "option parameter <$_socat_opt_types[$match[1]]>" "${(@z)_socat_opt_handler[$match[1]]}" && return 0 - else - _message -e optparam "opt param for $match[1]: $_socat_opt_types[$match[1]]" && return 0 - fi - else - _message -e optparam "opt param for $match[1]: unknown" && return 0 - fi - fi - - # add completions for all groups, then - _tags "${(s:,:)_socat_groups[$socket_type]}" - while _tags; do - for g in ${(s:,:)_socat_groups[$socket_type]}; do - _requested $g expl "${(L)g}" \ - compadd -M 'M:{[:upper:]}={[:lower:]}' -S = -r '=, \t\n\-' -k "_socat_opt_groups[(R)$g]" && ret=0 - done - (( ret )) || break - done - fi - - return ret -} - -# complete common options -_arguments \ - -V'[print version and feature information to stdout, and exit]' \ - -h'[print a help text describing command line options and addresses, and exit]' \ - -hh'[like -h, plus a list of all common address option names]' \ - -hhh'[like -hh, plus a list of all available address option names]' \ - \*-d'[increase verbosity (use up to 4 times; 2 are recommended)]' \ - -D'[analyze file descriptors before loop]' \ - -ly'[log to syslog, using facility (default is daemon)]:log facility:( auth authpriv cron daemon kern lpr mail mark news security syslog user uucp local0 local1 local2 local3 local4 local5 local6 local7 )' \ - -lf'[log to file]:log file:_files' \ - -ls'[log to stderr (default if no other log)]' \ - -lm'[mixed log mode (stderr during initialization, then syslog)]:log facility:( auth authpriv cron daemon kern lpr mail mark news security syslog user uucp local0 local1 local2 local3 local4 local5 local6 local7 )' \ - -lp'[set the program name used for logging]:log program name' \ - -lu'[use microseconds for logging timestamps]' \ - -lh'[add hostname to log messages]' \ - '(-x)'-v'[verbose data traffic, text]' \ - '(-v)'-x'[verbose data traffic, hexadecimal]' \ - -b'[set data buffer size (8192)]:buffer size (bytes)' \ - -s'[sloppy (continue on error)]' \ - -t'[wait seconds before closing second channel]:timeout (seconds)' \ - -T'[total inactivity timeout in seconds]:timeout (seconds)' \ - '(-U)'-u'[unidirectional mode (left to right)]' \ - '(-u)'-U'[unidirectional mode (right to left)]' \ - -g'[do not check option groups]' \ - '(-W)'-L'[try to obtain lock, or fail]:lockfile:_files' \ - '(-L)'-W'[try to obtain lock, or wait]:lockfile:_files' \ - '(-6)'-4'[prefer IPv4 if version is not explicitly specified]' \ - '(-4)'-6'[prefer IPv6 if version is not explicitly specified]' \ - '*:socket:_socat_address_head' && return 0 - diff --git a/.zprezto/modules/completion/external/src/_srm b/.zprezto/modules/completion/external/src/_srm index 49e6579..08d2a32 100644 --- a/.zprezto/modules/completion/external/src/_srm +++ b/.zprezto/modules/completion/external/src/_srm @@ -1,5 +1,26 @@ #compdef srm # ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# +# 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. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_ssh-copy-id b/.zprezto/modules/completion/external/src/_ssh-copy-id index 98daeba..77bd01c 100644 --- a/.zprezto/modules/completion/external/src/_ssh-copy-id +++ b/.zprezto/modules/completion/external/src/_ssh-copy-id @@ -1,30 +1,5 @@ #compdef ssh-copy-id # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_watch b/.zprezto/modules/completion/external/src/_subl similarity index 62% rename from .zprezto/modules/completion/external/src/_watch rename to .zprezto/modules/completion/external/src/_subl index 63bcddb..2f21385 100644 --- a/.zprezto/modules/completion/external/src/_watch +++ b/.zprezto/modules/completion/external/src/_subl @@ -1,6 +1,6 @@ -#compdef watch +#compdef subl # ------------------------------------------------------------------------------ -# Copyright (c) 2014 Github zsh-users - http://github.com/zsh-users +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -28,28 +28,33 @@ # Description # ----------- # -# Completion script for watch (https://gitorious.org/procps/procps). +# Completion script for Sublime Text (https://www.sublimetext.com/). # # ------------------------------------------------------------------------------ # Authors # ------- # -# * Nicolas Iooss (https://github.com/fishilico) +# * Fabian Klötzl (https://github.com/kloetzl) # # ------------------------------------------------------------------------------ -_arguments \ - '(-b --beep)'{-b,--beep}'[beep if command has a non-zero exit]' \ - '(-c --color)'{-c,--color}'[interpret ANSI color sequences]' \ - '(-d --differences)'{-d,--differences}'[highlight changes between updates]' \ - '(-d --differences)--differences=permanent[highlight changes since the first iteration]' \ - '(-e --errexit)'{-e,--errexit}'[exit if command has a non-zero exit]' \ - '(-g --chgexit)'{-g,--chgexit}'[exit when output from command changes]' \ - '(-n --interval)'{-n,--interval}'[seconds to wait between updates]:interval:' \ - '(-p --precise)'{-p,--precise}'[attempt run command in precise intervals]' \ - '(-t --no-title)'{-t,--no-title}'[turn off showing the header]' \ - '(-x --exec)'{-x,--exec}'[pass command to exec instead of "sh -c"]' \ - '(-h --help)'{-h,--help}'[display help information]' \ - '(-v --version)'{-v,--version}'[output version information]' \ - '(-):command: _command_names -e' \ - '*::arguments: _normal' + +_subl() { + integer ret=1 + local I="-h --help -v --version" + local -a args + args+=( + "(- *)"{-h,--help}'[Show help and exit]' + "(- *)"{-v,--version}'[Show version and exit]' + "($I)--project[Load the given project]:project:" + "($I)--command[Run the given command]:command:" + "($I -n --new-window)"{-n,--new-window}'[Open a new window]' + "($I -a --add)"{-a,--add}'[Add folders to the current window]' + "($I -w --wait)"{-w,--wait}'[Wait for the files to be closed before returning]' + "($I -b --background)"{-b,--background}'[Do not activate the application]' + ) + _arguments $args[@] '*:file:_files' && ret=0 + return ret +} + +_subl diff --git a/.zprezto/modules/completion/external/src/_subliminal b/.zprezto/modules/completion/external/src/_subliminal index 73f097a..9534de8 100644 --- a/.zprezto/modules/completion/external/src/_subliminal +++ b/.zprezto/modules/completion/external/src/_subliminal @@ -1,30 +1,5 @@ #compdef subliminal # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_supervisorctl b/.zprezto/modules/completion/external/src/_supervisorctl new file mode 100644 index 0000000..b48ce13 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_supervisorctl @@ -0,0 +1,174 @@ +#compdef supervisorctl +# ------------------------------------------------------------------------------ +# Copyright (c) 2015 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for supervisorctl from Supervisord (http://supervisord.org) +# +# Sources: +# https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/supervisor +# https://github.com/zsh-users/zsh-completions/blob/master/src/_brew +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Matt Black (https://github.com/mafrosis) +# * dongweiming (https://github.com/dongweiming) +# +# ------------------------------------------------------------------------------ + + +_supervisorctl_list_procs() { + procs=(${(f)"$(_call_program supervisor_procs supervisorctl avail | awk '{print $1}')"}) +} +_supervisorctl_list_groups() { + groups=(${(f)"$(_call_program supervisor_procs supervisorctl avail | awk '$1 ~ /:/ { print substr($1,1,index($1,":")) }' | uniq)"}) +} + +_supervisorctl_list_procs_stopped() { + procs=(${(f)"$(_call_program supervisor_procs supervisorctl status | awk '/STOPPED/ {print $1}')"}) +} +_supervisorctl_list_groups_stopped() { + groups=(${(f)"$(_call_program supervisor_procs supervisorctl status | awk '$1$2 ~ /:(.*)STOPPED/ { print substr($1,1,index($1,":")) }' | uniq)"}) +} + +_supervisorctl_list_procs_running() { + procs=(${(f)"$(_call_program supervisor_procs supervisorctl status | awk '/RUNNING/ {print $1}')"}) +} +_supervisorctl_list_groups_running() { + groups=(${(f)"$(_call_program supervisor_procs supervisorctl status | awk '$1$2 ~ /:(.*)RUNNING/ { print substr($1,1,index($1,":")) }' | uniq)"}) +} + +local -a _1st_arguments +_1st_arguments=( + 'add:Activates any updates in config for process/group' + 'avail:Display all configured processes' + 'clear:Clear single/multiple/all process log files' + 'exit:Exit the supervisor shell' + 'fg:Connect to a process in foreground mode' + 'maintail:tail of supervisor main log file' + 'open:Connect to a remote supervisord process. (for UNIX domain socket, use unix:///socket/path)' + 'pid:Get the PID of process/supervisord' + 'quit:Exit the supervisor shell' + 'reload:Restart the remote supervisord' + 'remove:Removes process/group from active config' + "reread:Reload the daemon's configuration files" + 'restart:Restart process, group or all' + 'shutdown:Shut the remote supervisord down' + 'start:Start process, group or all' + 'status:Get process/group status info' + 'stop:Stop process, group or all' + 'tail:tail of process stdout' + 'update:Reload config and add/remove as necessary' + 'version:Show the version of the remote supervisord process' + 'help:Show help' +) + +local expl +local -a procs + +_arguments \ + {--configuration,-c}='[configuration file path (default /etc/supervisor.conf)]:filename:_files' \ + {--help,-h}'[print usage message and exit]:' \ + {--interactive,-i}'[start an interactive shell after executing commands]' \ + {--serverurl,-s}='[URL on which supervisord server is listening (default "http://localhost:9001")]' \ + {--username,-u}='[username to use for authentication with server]:username:_users' \ + {--password,-p}='[password to use for authentication with server]:password:' \ + {--history-file,-r}'[keep a readline history (if readline is available)]:filename:_files' \ + '*:: :->subcmds' && return 0 + +if (( CURRENT == 1 )); then + _describe -t commands 'supervisorctl subcommand' _1st_arguments + return +fi + +case "$words[1]" in + help) + tasks=(add avail clear exit fg maintail open pid quit reload remove \ + reread restart shutdown start status stop tail update version) + + _wanted tasks expl 'help' compadd $tasks ;; + + add|fg|remove) + # commands that only operate on processes + _supervisorctl_list_procs + _wanted procs expl 'process' compadd -a procs ;; + + clear|pid) + # commands that operate on processes and "all" + _supervisorctl_list_procs + procs+=('all') + _wanted procs expl 'process' compadd -a procs ;; + + status|update) + # commands that operate on processes, groups & "all" + _supervisorctl_list_procs + procs+=('all') + _wanted procs expl 'process' compadd -a procs + + _supervisorctl_list_groups + _wanted groups expl 'group' compadd -a groups ;; + + stop) + # commands that operate on RUNNING processes, groups & "all" + _supervisorctl_list_procs_running + procs+=('all') + _wanted procs expl 'process' compadd -a procs + + _supervisorctl_list_groups_running + _wanted groups expl 'group' compadd -a groups ;; + + restart|start) + # commands that operate on STOPPED processes, groups & "all" + _supervisorctl_list_procs_stopped + procs+=('all') + _wanted procs expl 'process' compadd -a procs + + _supervisorctl_list_groups_stopped + _wanted groups expl 'group' compadd -a groups ;; + + tail|maintail) + _arguments \ + '-f[Continuous tail of named process stdout]' \ + '-[last N *bytes* of process stdout]:number' \ + '1: :->forms' && return 0 + + if [[ $state == forms ]]; then + _supervisorctl_list_procs + _wanted procs expl 'processes' compadd -a procs + fi ;; +esac + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_symfony b/.zprezto/modules/completion/external/src/_symfony deleted file mode 100644 index ff23aad..0000000 --- a/.zprezto/modules/completion/external/src/_symfony +++ /dev/null @@ -1,456 +0,0 @@ -#compdef symfony -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for Symfony (http://www.symfony-project.org). -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * aki77 (https://github.com/aki77) -# -# ------------------------------------------------------------------------------ - - -_symfony () { - local curcontext="$curcontext" state line expl ret=1 cache_version - - cache_version=$(_get_sf_cache_var version) - (( ${(P)+cache_version} == 0 )) && { - eval $cache_version=${${${(z)$($service -V)}[3]}%.*} - } - - if [ ${(P)cache_version} = "1.0" ] ; then - _symfony10 - return - fi - - _arguments -C \ - '(-T --tasks)'{-T,--tasks}'[list of the symfony tasks]' \ - '(-V --version)'{-V,--version}'[version]' \ - '1: :->tasks' \ - '*:: :->args' && ret=0 - - case $state in - tasks) - _sf_tasks - ;; - args) - local task args - - task=$words[1] - args=( - ${${${${${(M)${${${(z)${${"$($service help $task)"#*Usage:}#[[:cntrl:]]}%%[[:cntrl:]]*}//\[/}//\]/}:#--*}%%\"*}/=/"=-"}/(#b)--(app|application)=-/--$match[1]=-:application:_sf_apps}//(#b)--(env|environment)=-/--$match[1]=-:environment:_sf_environments} - ) - - case $task in - help) - args+=( - ':task:_sf_tasks' - ) - ;; - - app:routes) - args+=( - ':application:_sf_apps' - ':"route name":' - ) - ;; - - configure:author) - _message 'project author' - ;; - - configure:database) - _message 'database dsn' - ;; - - generate:app) - _message 'new application name' - ;; - - generate:module) - args+=( - ':application:_sf_apps' - ':"new module name":' - ) - ;; - - generate:project) - _message 'new project name' - ;; - - generate:task) - _message 'new task name' - ;; - - i18n:extract) - args+=( - ':application:_sf_apps' - ':"target culture":' - ) - ;; - - i18n:find) - args+=( - ':application:_sf_apps' - ) - ;; - - log:rotate) - args+=( - ':application:_sf_apps' - ':environment:_sf_environments' - ) - ;; - - plugin:add-channel) - _message 'channel name' - ;; - - plugin:install) - _message 'plugin name' - ;; - - plugin:publish-assets) - args+=( - ':plugin:_sf_plugins' - ) - ;; - - plugin:uninstall) - _message 'plugin name' - ;; - - plugin:upgrade) - _message 'plugin name' - ;; - - project:deploy) - _message 'server name' - ;; - - project:disable|project:enable) - args+=( - ':environment:_sf_environments' - '*:application:_sf_apps' - ) - ;; - - project:optimize) - args+=( - ':application:_sf_apps' - ':environment:_sf_environments' - ) - ;; - - propel:data-dump|doctrine:data-dump) - _message 'target filename' - ;; - - propel:data-load|doctrine:data-load) - args+=( - '*:file:_files' - ) - ;; - - propel:generate-admin) - args+=( - ':application:_sf_apps' - ':model:_sf_models' - ) - ;; - - propel:generate-module|propel:init-admin) - args+=( - ':application:_sf_apps' - ':module:_sf_modules_candidate' - ':model:_sf_models' - ) - ;; - - propel:generate-module-for-route|doctrine:generate-module-for-route) - args+=( - ':application:_sf_apps' - ':"route name":' - ) - ;; - - doctrine:create-model-tables|doctrine:delete-model-files) - args+=( - '*:model:_sf_doctrine_models' - ) - ;; - - doctrine:generate-admin) - args+=( - ':application:_sf_apps' - '*:model:_sf_doctrine_models' - ) - ;; - - doctrine:generate-module) - args+=( - ':application:_sf_apps' - ':module:_sf_doctrine_modules_candidate' - ':model:_sf_doctrine_models' - ) - ;; - - test:coverage) - args+=( - '*:file:_files' - ) - ;; - - test:functional) - args+=( - ':application:_sf_apps' - '*:test:_sf_functionaltests' - ) - ;; - - test:unit) - args+=( - '*:test:_sf_unittests' - ) - ;; - - esac - - _arguments "$args[@]" && ret=0 - return - ;; - esac - return ret -} - -_symfony10 () { - local curcontext="$curcontext" state line expl ret=1 - - _arguments -C \ - '(-T --tasks)'{-T,--tasks}'[list of the symfony tasks]' \ - '(-V --version)'{-V,--version}'[version]' \ - '1: :->tasks' \ - '*:: :->args' && ret=0 - - case $state in - tasks) - _sf10_tasks - ;; - args) - local task args - - task=$words[1] - args=() - - case $task in - init-project) - _message 'new project name' - ;; - - init-app) - _message 'application name' - ;; - - init-module) - args+=( - ':application:_sf_apps' - ) - ;; - - init-batch) - args+=( - ':skeleton name:compadd default rotate' - ':"script name":' - ':application:_sf_apps' - ) - ;; - - init-controller) - args+=( - ':application:_sf_apps' - ':environment:_sf_environments' - ':"script name":' - ':"debug?":compadd true false' - ) - ;; - - log-rotate) - args+=( - ':application:_sf_apps' - ':environment:_sf_environments' - ) - ;; - - propel-load-data|propel-build-all-load) - args+=( - ':application:_sf_apps' - ':environment:_sf_environments' - ':fixtures:_sf_fixtures' - ) - ;; - - clear-cache|cc) - args+=( - ':application:_sf_apps' - ':what:compadd template config' - ) - ;; - - sync) - args+=( - ':environment:_sf_environments' - ':"real run?":compadd go' - ) - ;; - - propel-init-crud|propel*-init-admin|propel-generate-crud) - args+=( - ':application:_sf_apps' - ':module:_sf_modules_candidate' - ':model:_sf_models' - ) - ;; - - doctrine-init-admin|doctrine-generate-crud) - args+=( - ':application:_sf_apps' - ':module:_sf_doctrine_modules_candidate' - ':model:_sf_doctrine_models' - ) - ;; - - test-unit) - args+=( - ':test:_sf_unittests' - ) - ;; - - test-functional) - args+=( - ':application:_sf_apps' - ':test:_sf_functionaltests' - ) - ;; - - esac - - _arguments "$args[@]" && ret=0 - return - ;; - esac - return ret -} - -_sf_tasks () { - local tmp ns line cache_task - - cache_task=$(_get_sf_cache_var task) - (( ${(P)+cache_task} == 0 )) && { - tmp=( - ${${${(f)${"$($service -T)"##*Available tasks:}}##[[:blank:]][[:blank:]]}%%[[:blank:]]*} - ) - eval "$cache_task=()" - ns='' - - for line in $tmp; do - if [ $line[1] = ":" ] ; then - eval "$cache_task+=( ${ns}${line#:} )" - else - ns="${line}:" - fi - done - } - - _wanted symfony-task expl 'Symfony task' compadd -a $cache_task -} - -_sf10_tasks () { - local sf_tasks - - sf_tasks=( - ${${${(f)${"$($service -T)"#available pake tasks:}%%task aliases:*}#[[:blank:]][[:blank:]]}/[[:blank:]]*>[[:blank:]]/:} - ) - - _describe -t symfony-tasks 'Symfony task' sf_tasks -} - -_sf_apps () { - _wanted application expl 'application' compadd \ - ${$(echo apps/*):t} -} - -_sf_environments () { - local app - - app=$([ -f apps/"$words[2]"/config/settings.yml ] && echo $words[2] || echo frontend) - if [ -r apps/$app/config/settings.yml ] ; then - _wanted environment expl 'environment' compadd \ - ${${${(M)${(@f)"$( +# * Jindřich Pilař (https://github.com/JindrichPilar) # # ------------------------------------------------------------------------------ -_arguments -A "-*" \ - '(-h --help)'{-h,--help}'[Show help message]' \ - '(-i --interactive)'{-i,--interactive}'[Drop to bpython shell after running file instead of exiting]' \ - '(-q --quiet)'{-q,--quiet}"[Don't flush the output to stdout]" \ - '(-V --version)'{-V,--version}'[Print version and exit]' \ - '--config[Use CONFIG instead of default config file]:Config file:_files' \ - '*: :_files' + +_trash-empty() { + + _arguments -C \ + '--version[Show programs version number and exit]' \ + {-h,--help}'[Show help message and exit]' \ + '*: :' \ + +} + +_trash-empty # Local Variables: # mode: Shell-Script diff --git a/.zprezto/modules/completion/external/src/_trash-list b/.zprezto/modules/completion/external/src/_trash-list new file mode 100644 index 0000000..0f821c0 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_trash-list @@ -0,0 +1,59 @@ +#compdef trash-list +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for trash-list a tool from trash management package trash-cli (http://code.google.com/p/trash-cli). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + + +_trash-list() { + + _arguments -C \ + '--version[Show programs version number and exit]' \ + {-h,--help}'[Show help message and exit]' \ + '*: :' \ + +} + +_trash-list + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_trash-put b/.zprezto/modules/completion/external/src/_trash-put new file mode 100644 index 0000000..e9bf06d --- /dev/null +++ b/.zprezto/modules/completion/external/src/_trash-put @@ -0,0 +1,64 @@ +#compdef trash-put trash +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for trash-put a tool from trash management package trash-cli (http://code.google.com/p/trash-cli). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + + +_trash-put() { + + _arguments -C \ + '--version[Show programs version number and exit]' \ + {-h,--help}'[Show help message and exit]' \ + {-d,--directory}'[Remove empty directories - ignored (for GNU rm compabilty)]' \ + {-f,--force}'[Ignore nonexistent arguments and never prompt - ignored (for GNU rm compabilty)]' \ + {-i,--interactive}'[Prompt before every removal - ignored (for GNU rm compabilty)]' \ + {-r,-R,--recursive}'[Remove directories and their content recursively - ignored (for GNU rm compabilty)]' \ + {-v,--verbose}'[Explain what is being done]' \ + '*: :_files' \ + +} + +_trash-put + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_trash-restore b/.zprezto/modules/completion/external/src/_trash-restore new file mode 100644 index 0000000..35e313a --- /dev/null +++ b/.zprezto/modules/completion/external/src/_trash-restore @@ -0,0 +1,58 @@ +#compdef trash-restore +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for trash-restore a tool from trash management package trash-cli (http://code.google.com/p/trash-cli). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + + +_trash-restore() { + + _arguments -C \ + '--version[Show programs version number and exit]' \ + '*: :' \ + +} + +_trash-restore + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_udisksctl b/.zprezto/modules/completion/external/src/_udisksctl new file mode 100644 index 0000000..267c4af --- /dev/null +++ b/.zprezto/modules/completion/external/src/_udisksctl @@ -0,0 +1,163 @@ +#compdef udisksctl +# +# ------------------------------------------------------------------------------ +# The MIT License +# +# Copyright 2014 Damir Jelić +# +# 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. +# +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for udisksctl +# (https://cgit.freedesktop.org/udisks/tree/tools) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Damir Jelić [1] +# * Ole Jørgen Brønner (minor additions) +# +# [1] https://lists.freedesktop.org/archives/devkit-devel/2014-February/001554.html +# +# ------------------------------------------------------------------------------ +# Notes +# ----- +# +# udisksctl actually provide built-in support for completion: It accepts an +# special command 'complete' that returns completeions. That is what drives the +# upstream bash completion. In the future one might condsider rewriting using +# that. (but not sure how straight forward it would be to provide descriptions?) +# + +_paths() { + local -a _path_list + + for _path in $(_call_program paths "udisksctl complete \"udisksctl $words\" $CURSOR"); do + _path_list+=$_path + done + + _describe 'paths' _path_list +} + +_filesystems() { + _fs_types=( + 'adfs' 'affs' 'autofs' 'cifs' 'coda' 'coherent' 'cramfs' 'debugfs' 'devpts' + 'efs' 'ext' 'ext2' 'ext3' 'ext4' 'hfs' 'hfsplus' 'hpfs' 'iso9660' 'jfs' 'minix' + 'msdos' 'ncpfs' 'nfs' 'nfs4' 'ntfs' 'proc' 'qnx4' 'ramfs' 'reiserfs' 'romfs' + 'squashfs' 'smbfs' 'sysv' 'tmpfs' 'ubifs' 'udf' 'ufs' 'umsdos' 'usbfs' 'vfat' + 'xenix' 'xfs' 'xiafs' + ) + + _describe 'file system types' _fs_types +} + +_udisksctl() { + typeset -A opt_args + local curcontext="$curcontext" state line + + _arguments -C \ + '1:udisksctl commands:->cmds' \ + '*:: :->cmd_args' \ + + case $state in + cmds) + local commands; commands=( + 'help: Show help' + 'info: Show info about an object' + 'dump: Show info about all object' + 'status: Shows high-level status' + 'monitor: Monitor changes to objects' + 'mount: Mount a filesystem' + 'unmount: Unmount a filesystem' + 'unlock: Unlock an encrypted device' + 'lock: Lock an encrypted device' + 'loop-setup: Set-up a loop device' + 'loop-delete: Delete a loop device' + 'power-off: Safely power off a drive' + 'smart-simulate: Set SMART data for a drive' + ) + _describe -t commands 'udisksctl commands' commands + ;; + + cmd_args) + case $words[1] in + info) + _arguments \ + {-p,--object-path}'[Object to get information about]:object path:_paths' \ + {-b,--block-device}'[Block device to get information about]:block device:_paths' \ + {-d,--drive}'[Drive to get information about]:drives:_paths' \ + ;; + mount) + _arguments \ + {-p,--object-path}'[Object to mount]:object path:_paths' \ + {-b,--block-device}'[Block device to mount]:block device:_paths' \ + {-t,--filesystem-type}'[Filesystem type to use]:fs type:_filesystems' \ + {-o,--options}'[Mount options]' \ + '(--no-user-interaction)--no-user-interaction[Do not authenticate the user if needed]' \ + ;; + unmount) + _arguments \ + {-p,--object-path}'[Object to unmount]:object path:_paths' \ + {-b,--block-device}'[Block device to unmount]:block device:_paths' \ + {-f,--force}'[Force/lazy unmount]' \ + '(--no-user-interaction)--no-user-interaction[Do not authenticate the user if needed]' \ + ;; + unlock|lock) + _arguments \ + {-p,--object-path}'[Object to lock/unlock]:object path:_paths' \ + {-b,--block-device}'[Block device to lock/unlock]:block device:_paths' \ + '(--no-user-interaction)--no-user-interaction[Do not authenticate the user if needed]' \ + ;; + loop-setup) + _arguments \ + {-f,--file}'[File to set-up a loop device for]:files:_files' \ + {-r,--read-only}'[Setup read-only device]' \ + {-o,--offset}'[Start at bytes into file]:offset in bytes:' \ + {-s,--size}'[Limit size to bytes]:limit in bytes:' \ + '(--no-user-interaction)--no-user-interaction[Do not authenticate the user if needed]' \ + ;; + loop-delete) + _arguments \ + {-p,--object-path}'[Object for loop device to delete]:object path:_paths' \ + {-b,--block-device}'[Loop device to delete]:block device:_paths' \ + '(--no-user-interaction)--no-user-interaction[Do not authenticate the user if needed]' \ + ;; + power-off) + _arguments \ + {-p,--object-path}'[Object path for ATA device]:object path:_paths' \ + {-b,--block-device}'[Device file for ATA devic]:block device:_paths' \ + '(--no-user-interaction)--no-user-interaction[Do not authenticate the user if needed]' \ + ;; + smart-simulate) + _arguments \ + {-f,--file}'[File with libatasmart blob]:files:_files' \ + {-p,--object-path}'[Object to get information about]:object path:_paths' \ + {-b,--block-device}'[Block device to get information about]:block device:_paths' \ + '(--no-user-interaction)--no-user-interaction[Do not authenticate the user if needed]' \ + ;; + esac + ;; + esac +} + +_udisksctl "$@" diff --git a/.zprezto/modules/completion/external/src/_ufw b/.zprezto/modules/completion/external/src/_ufw new file mode 100644 index 0000000..b4cf0f1 --- /dev/null +++ b/.zprezto/modules/completion/external/src/_ufw @@ -0,0 +1,143 @@ +#compdef ufw +# ------------------------------------------------------------------------------ +# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for The Uncomplicated Firewall (ufw). (https://launchpad.net/ufw). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jindřich Pilař (https://github.com/JindrichPilar) +# +# ------------------------------------------------------------------------------ + + +_ufw_logging() { + + local main additional second + second=$words[2] + + if [ ! -z $second ]; then + return + fi + + params=( + "on" + "off" + ) + + additional=( + "low" + "medium" + "high" + "full" + ) + + _describe -t params 'On/Off' params + _describe -t additional 'Level' additional +} + + +_ufw_delete() { + local rules complrules second + + second=$words[2] + + if [ ! -z $second ]; then + return + fi + + complrules=() + rules=("${(f)$(ufw status | tr -s ' ' | tail -n +5 | tr -s '\n')}") + + for ((i=1; i<=${#rules[@]}; i++)); do + complrules+=("$i:$rules[i]"); + done + + _describe -t complrules 'Rules' complrules +} + +_ufw() { + local -a commands + + commands=( + "enable:Enables the firewall" + "disable:Disables the firewall" + "default:Set default policy" + "logging:Set logging to LEVEL" + "allow:Add allow rule" + "deny:Add deny rule" + "reject:Add reject rule" + "limit:Add limit rule" + "delete:Delete RULE" + "insert:Insert RULE at NUM" + "route:Add route RULE" + "reload:Reload firewall" + "reset:Reset firewall" + "status:Show firewall status" + "show:Show firewall report" + "version:Display version information" + ) + + + + _arguments -C -s -S -n \ + '(- 1 *)'--version"[Show program\'s version number and exit]: :->full" \ + '(- 1 *)'{-h,--help}'[Show help message and exit]: :->full' \ + '(- 1 *)'--dry-run"[Don\'t modify anything, just show the changes]: :->cmds" \ + '1:cmd:->cmds' \ + '*:: :->args' \ + + case "$state" in + (cmds) + _describe -t commands 'commands' commands + ;; + (args) + local cmd + cmd=$words[1] + case "$cmd" in + (logging) + _ufw_logging + ;; + (delete) + _ufw_delete + ;; + (*) + return + ;; + esac + ;; + (*) + ;; + esac +} + +_ufw + diff --git a/.zprezto/modules/completion/external/src/_vagrant b/.zprezto/modules/completion/external/src/_vagrant index c6ea59e..79d56fb 100644 --- a/.zprezto/modules/completion/external/src/_vagrant +++ b/.zprezto/modules/completion/external/src/_vagrant @@ -1,5 +1,26 @@ #compdef vagrant # ------------------------------------------------------------------------------ +# Copyright (c) 2009-2015 Robby Russell and contributors (see +# https://github.com/robbyrussell/oh-my-zsh/contributors) +# +# 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. +# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_veewee b/.zprezto/modules/completion/external/src/_veewee deleted file mode 100644 index 3de9adb..0000000 --- a/.zprezto/modules/completion/external/src/_veewee +++ /dev/null @@ -1,164 +0,0 @@ -#compdef veewee -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for veewee 0.3.7 (https://github.com/jedi4ever/veewee) -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Marius Bergmann (https://github.com/mbrgm) -# -# ------------------------------------------------------------------------------ - -typeset curcontext state line cmds ret - -curcontext="$curcontext" -ret=1 - -_arguments -C \ - '--debug' \ - '--workdir=[Change the working directory (the folder containing the definitions folder).]:directory:_files -/' \ - '1: :->cmds' \ - '2: :->providers' \ - '*: :->args' && ret=0 - - -local -a provider_cmds; provider_cmds=( - 'build:Build box' - 'copy:Copy a file to the VM' - 'define:Define a new basebox starting from a template' - 'destroy:Destroys the virtualmachine that was built' - 'halt:Activates a shutdown the virtualmachine' - 'help:Describe subcommands or one specific subcommand' - 'list:Lists all defined boxes' - 'ostypes:List the available Operating System types' - 'sendkeys:Sends the key sequence (comma separated) to the box. E.g for testing the :boot_cmd_sequence' - 'ssh:SSH to box' - 'templates:List the currently available templates' - 'undefine:Removes the definition of a basebox' - 'up:Starts a Box' - 'validate:Validates a box against vmfusion compliancy rules' - 'winrm:Execute command via winrm' -) - -case $state in - cmds) - local -a cmds; cmds=( - 'fusion:Subcommand for Vmware fusion' - 'help:Describe available commands or one specific command' - 'kvm:Subcommand for KVM' - 'parallels:Subcommand for Parallels' - 'vbox:Subcommand for VirtualBox' - 'version:Prints the Veewee version information' - ) - - _describe -t commands 'veewee command' cmds && ret=0 - ;; - - providers) - case $line[1] in - (help) - local -a cmds; cmds=( - 'fusion' - 'help' - 'kvm' - 'parallels' - 'vbox' - 'version' - ) - - _values -S , 'commands' $cmds && ret=0 - ;; - - (fusion) - provider_cmds+='add_share:Adds a share to the guest' - provider_cmds+='export:Exports the basebox to the vagrant format' - - _describe -t commands 'veewee fusion command' provider_cmds && ret=0 - ;; - - (kvm) - provider_cmds+='export:Exports the basebox to the vagrant format' - - _describe -t commands 'veewee kvm command' provider_cmds && ret=0 - ;; - - (parallels) - _describe -t commands 'veewee parallels command' provider_cmds && ret=0 - ;; - - (vbox) - - provider_cmds+='export:Exports the basebox to the vagrant format' - provider_cmds+='screenshot:Takes a screenshot of the box' - - _describe -t commands 'veewee vbox command' provider_cmds && ret=0 - ;; - esac; - ;; - args) - case $line[2] in - (add_share|build|copy|destroy|export|halt|screenshot|sendkeys|ssh|undefine|up|validate|winrm) - if [ ${#line[@]} -eq 3 ]; then - boxes=( ${(f)"$(ls -1 ./definitions)"} ) - _values -S , 'boxes' $boxes && ret=0 - fi - ;; - (define) - if [ ${#line[@]} -eq 4 ]; then - templates=( ${(f)"$(_call_program templates veewee $line[1] templates | awk '/^veewee.+define/{sub(/^.+>[:\47] [:\47]/, "");sub(/[:\47].+$/, "");print}')"} ) - _values -S , 'templates' $templates && ret=0 - fi - ;; - (help) - local -a cmds; cmds=( - 'build' - 'copy' - 'define' - 'destroy' - 'halt' - 'help' - 'list' - 'ostypes' - 'sendkeys' - 'ssh' - 'templates' - 'undefine' - 'up' - 'validate' - 'winrm' - ) - if [ $line[1] = "fusion" ]; then - cmds+='add_share' - cmds+='export' - elif [ $line[1] = "kvm" ]; then - cmds+='export' - elif [ $line[1] = "vbox" ]; then - cmds+='export' - cmds+='screenshot' - fi - _values -S , 'commands' $cmds && ret=0 - ;; - esac; - case $line[2] in - (add_share) - if [ ${#line[@]} -eq 5 ]; then - _arguments "*::filename:_files" - fi - ;; - (copy) - if [ ${#line[@]} -eq 4 ]; then - _arguments "*::filename:_files" - fi - ;; - (screenshot) - if [ ${#line[@]} -eq 4 ]; then - _arguments "*::filename:_files" - fi - ;; - esac; - ;; -esac; diff --git a/.zprezto/modules/completion/external/src/_virtualbox b/.zprezto/modules/completion/external/src/_virtualbox index de0e35a..49869cf 100644 --- a/.zprezto/modules/completion/external/src/_virtualbox +++ b/.zprezto/modules/completion/external/src/_virtualbox @@ -1,27 +1,5 @@ #compdef VBoxManage=vboxmanage VBoxHeadless=vboxheadless # ------------------------------------------------------------------------------ -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_vpnc b/.zprezto/modules/completion/external/src/_vpnc index b5235e4..622b1d3 100644 --- a/.zprezto/modules/completion/external/src/_vpnc +++ b/.zprezto/modules/completion/external/src/_vpnc @@ -1,30 +1,5 @@ #compdef vpnc vpnc-connect vpnc-disconnect # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ # Description # ----------- # diff --git a/.zprezto/modules/completion/external/src/_xinput b/.zprezto/modules/completion/external/src/_xinput index ae2b375..dd99c36 100644 --- a/.zprezto/modules/completion/external/src/_xinput +++ b/.zprezto/modules/completion/external/src/_xinput @@ -93,8 +93,11 @@ _xinput(){ --set-prop ) - local context state line expl + local context state line local -A opt_args + # Used with "-O expl" for unsorted. + local -a expl + expl=(-Vx) _arguments '*:: :->subcmds' && return 0 @@ -103,92 +106,101 @@ _xinput(){ return fi - _xinput_devices_id=($(xinput list --id-only)) - for i in $(xinput list --id-only) - do - _xinput_devices_name[$i]="$(xinput list --name-only $i)" - done - _xinput_devices=( $_xinput_devices_id $_xinput_devices_name ) + typeset -a xinput_devices_id xinput_devices xinput_devices_name + local i name + for i in ${(on)$(xinput list --id-only)}; do + # Removing prefixes, e.g. from "∼ 7" (floating slave). + i=${i##[^[:digit:]]#} + [[ -n "$i" ]] || continue + xinput_devices_id+=($i) + name="$(xinput list --name-only $i)" + xinput_devices_name+=($name) + xinput_devices+=($i\:$name) + done + xinput_devices+=($xinput_devices_name) # xinput arguments handler case "$words[1]" in --get-feedbacks|--set-ptr-feedback|--get-button-map|--query-state|--list-props|--watch-props|get-feedbacks|set-ptr-feedback|get-button-map|query-state|list-props|watch-props|--enable|enable|--map-to-output|map-to-output|--disable|disable) - _arguments \ - ':list option:($_xinput_devices)' + _arguments -O expl \ + ':list option:(($xinput_devices))' ;; --list|list) - _arguments \ - ':list option:($_xinput_devices --short --long --name-only --id-only)' \ - ':list option:(--short --long --name-only --id-only)' + _arguments -O expl \ + '--short' \ + '--long' \ + '--name-only' \ + '--id-only' \ + ':list option:(($xinput_devices))' \ ;; --set-integer-feedback|set-integer-feedback) - _arguments \ - ':list option:($_xinput_devices)' \ + _arguments -O expl \ + ':list option:(($xinput_devices))' \ ':list option:( feedback )' \ - ':list option:( $_xinput_devices_id )' + ':list option:( $xinput_devices_id )' ;; --set-button-map|set-button-map) - _arguments \ - ':list option:($_xinput_devices)' #map button 1 [map button 2 [...]] + _arguments -O expl \ + ':list option:(($xinput_devices))' #map button 1 [map button 2 [...]] ;; --set-pointer|set-pointer) - _arguments \ - ':list option:($_xinput_devices)' # [x index y index] + _arguments -O expl \ + ':list option:(($xinput_devices))' # [x index y index] ;; --set-mode|set-mode) - _arguments \ - ':list option:($_xinput_devices)' \ + _arguments -O expl \ + ':list option:(($xinput_devices))' \ ':list option:(ABSOLUTE RELATIVE)' ;; --test|test) - _arguments \ - ':list option:(-proximity $_xinput_devices )' \ - ':list option:($_xinput_devices)' + _arguments -O expl \ + ':list option:(-proximity ($xinput_devices ))' \ + ':list option:(($xinput_devices))' ;; --reattach|reattach) - _arguments \ - ':list option:($_xinput_devices)' \ + _arguments -O expl \ + ':list option:(($xinput_devices))' \ ':list option:(master slave)' ;; --float|float) - _arguments \ - ':list option:($_xinput_devices_id)' + _arguments -O expl \ + ':list option:(($xinput_devices))' ;; --test-xi2|test-xi2) - _arguments \ - ':list option:($_xinput_devices --root)' \ - ':list option:($_xinput_devices)' + _arguments -O expl \ + ':list option:(($xinput_devices --root))' \ + ':list option:(($xinput_devices))' ;; --delete-prop|delete-prop) - _arguments \ - ':list option:($_xinput_devices)' #property + _arguments -O expl \ + ':list option:(($xinput_devices))' #property ;; --create-master|create-master) - _arguments \ - ':list option:($_xinput_devices_id)' # [sendCore (dflt:1)] [enable (dflt:1)] + _arguments -O expl \ + ':list option:(($xinput_devices))' # [sendCore (dflt:1)] [enable (dflt:1)] ;; --remove-master|remove-master) - _arguments \ - ':list option:($_xinput_devices_id)' # [Floating|AttachToMaster (dflt:Floating)] [returnPointer] [returnKeyboard] + _arguments -O expl \ + ':list option:($xinput_devices_id)' # [Floating|AttachToMaster (dflt:Floating)] [returnPointer] [returnKeyboard] ;; # --set-cp|set-cp); window device;; --set-prop|set-prop) - _arguments \ - ':list option:($_xinput_devices)' \ + _arguments -O expl \ + ':list option:(($xinput_devices))' \ ':list option:(--type={atom,float,int} --format={8,16,32})' \ ':list option:(--type={atom,float,int} --format={8,16,32})' # property val [val ...] ;; --set-int-prop|set-int-prop) - _arguments \ - ':list option:($_xinput_devices)' # property format (8, 16, 32) val [val ...] + _arguments -O expl \ + ':list option:(($xinput_devices))' # property format (8, 16, 32) val [val ...] ;; --set-float-prop|set-float-prop) - _arguments \ - ':list option:($_xinput_devices)' # property val [val ...] + _arguments -O expl \ + ':list option:(($xinput_devices))' # property val [val ...] ;; --set-atom-prop|set-atom-prop) - _arguments \ - ':list option:($_xinput_devices)' # property val [val ...] + _arguments -O expl \ + ':list option:(($xinput_devices))' # property val [val ...] ;; esac } diff --git a/.zprezto/modules/completion/external/src/_xsel b/.zprezto/modules/completion/external/src/_xsel new file mode 100644 index 0000000..3ba249b --- /dev/null +++ b/.zprezto/modules/completion/external/src/_xsel @@ -0,0 +1,63 @@ +#compdef xsel +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for xsel (http://www.vergenet.net/~conrad/software/xsel/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Tomo Kazahaya (https://github.com/tomonacci) +# +# ------------------------------------------------------------------------------ + +local input='(-a --append -f --follow -i --input)' +local operation='(-c --clear -d --delete -k --keep -x --exchange)' +local selection='(-p --primary -s --secondary -b --clipboard)' + +_arguments -s \ + $input{-a,--append}'[append standard input to the selection]' \ + $input{-f,--follow}'[append to selection as standard input grows]' \ + $input{-i,--input}'[read standard input into the selection]' \ + {-o,--output}'[write the selection to standard output]' \ + $operation{-c,--clear}'[clear the selection]' \ + $operation{-d,--delete}'[request that the current selection be deleted]' \ + $selection{-p,--primary}'[operate on the PRIMARY selection (default)]' \ + $selection{-s,--secondary}'[operate on the SECONDARY selection]' \ + $selection{-b,--clipboard}'[operate on the CLIPBOARD selection]' \ + $operation{-k,--keep}'[do not modify the selections, but make the PRIMARY and SECONDARY selections persist even after the programs they were selected in exit]' \ + $operation{-x,--exchange}'[exchange the PRIMARY and SECONDARY selections]' \ + '--display[specify the server to use; see X(1)]:X display:_x_display' \ + {-t,--selectionTimeout}'[specify the timeout in milliseconds within which the selection must be retrieved]:number' \ + {-l,--logfile}'[specify the file to log errors to when detached (default $HOME/.xsel.log)]:log file:_files' \ + {-n,--nodetach}'[do not detach from the controlling terminal]' \ + {-h,--help}'[display usage information and exit]' \ + {-v,--verbose}'[print informative messages; additional instances of -v raise the debugging level]' \ + '--version[output version information and exit]' diff --git a/.zprezto/modules/completion/external/src/_yaourt b/.zprezto/modules/completion/external/src/_yaourt index e9db0da..920b16f 100644 --- a/.zprezto/modules/completion/external/src/_yaourt +++ b/.zprezto/modules/completion/external/src/_yaourt @@ -1,8 +1,17 @@ #compdef yaourt yaourt.static=yaourt - -# Completion file for yaourt, based on pacman's - -# copy this file to /usr/share/zsh/site-functions/_pacman +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for yaourt (https://archlinux.fr/yaourt-en) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * zsh-users mailing list +# +# ------------------------------------------------------------------------------ # handles --help subcommand _yaourt_action_help() { @@ -31,7 +40,7 @@ _yaourt_action_query() { _arguments -s : \ "$_yaourt_opts_common[@]" \ "$_yaourt_opts_query_modifiers[@]" \ - '*:package file:_files -g "*.pkg.tar.*"' + '*:package file:_files -g "*.pkg.tar*"' ;; query_group) _arguments -s : \ @@ -239,7 +248,7 @@ _yaourt() { _yaourt_opts_pkgfile=( '-d[Skip dependency checks]' '-f[Overwrite conflicting files]' - '*:package file:_files -g "*.pkg.tar.*(.)"' + '*:package file:_files -g "*.pkg.tar*(.)"' ) # options for passing to _arguments: subactions for --query command @@ -323,11 +332,11 @@ _yaourt() { "$_yaourt_opts_query_modifiers[@]" \ '*:package file:_files' ;; - -Q*p*) # file *.pkg.tar.* + -Q*p*) # file *.pkg.tar* _arguments -s : \ "$_yaourt_opts_common[@]" \ "$_yaourt_opts_query_modifiers[@]" \ - '*:package file:_files -g "*.pkg.tar.*"' + '*:package file:_files -g "*.pkg.tar*"' ;; -Q*) _yaourt_action_query ;; -R*) _yaourt_action_remove ;; diff --git a/.zprezto/modules/completion/external/src/_yarn b/.zprezto/modules/completion/external/src/_yarn new file mode 100644 index 0000000..a41262d --- /dev/null +++ b/.zprezto/modules/completion/external/src/_yarn @@ -0,0 +1,345 @@ +#compdef yarn +# ------------------------------------------------------------------------------ +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for yarn (https://yarnpkg.com/) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Massimiliano Torromeo +# +# ------------------------------------------------------------------------------ + +_commands=( + 'access' + 'cache' + "check:Verify package dependencies agains yarn's lock file" + 'clean:Cleans and removes unnecessary files from package dependencies' + 'config:Manages the yarn configuration files' + 'generate-lock-entry:Generates a lock file entry' + 'global:Install packages globally on your operating system' + 'help:Show information about a command' + 'import' + 'info:Show information about a package' + 'init:Interactively creates or updates a package.json file' + 'install:Install all the dependencies listed within package.json' + 'licenses:List licenses for installed packages' + 'link:Symlink a package folder during development' + 'list:List installed packages' + 'login:Store registry username and email' + 'logout:Clear registry username and email' + 'outdated:Checks for outdated package dependencies' + 'owner:Manage package owners' + 'pack:Creates a compressed gzip archive of package dependencies' + 'publish:Publishes a package to the npm registry' + 'run:Runs a defined package script' + 'tag:Add, remove, or list tags on a package' + 'team:Maintain team memberships' + 'unlink:Unlink a previously created symlink for a package' + 'version:Updates the package version' + 'versions' + 'why:Show information about why a package is installed' +) + +_global_commands=( + 'add:Installs a package and any packages that it depends on' + 'bin:Displays the location of the yarn bin folder' + 'remove:Remove installed package from dependencies updating package.json' + 'upgrade:Upgrades packages to their latest version based on the specified range' + 'upgrade-interactive' +) + +_yarn_commands_scripts() { + local -a scripts + scripts=($(yarn run --json 2>/dev/null | sed -E '/Commands available|possibleCommands/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g' | tr , '\n')) + _describe 'command or script' _commands -- _global_commands -- scripts +} + +_yarn_scripts() { + local -a scripts + scripts=($(yarn run --json 2>/dev/null | sed -E '/Commands available|possibleCommands/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g' | tr , '\n')) + _describe 'script' scripts +} + +_yarn_global_commands() { + local -a cmds + cmds=('ls:List installed packages') + _describe 'command' _global_commands +} + +_yarn_commands() { + _describe 'command' _commands -- _global_commands +} + +_yarn() { + local context state state_descr line + typeset -A opt_args + + _arguments \ + '(-h --help)'{-h,--help}'[output usage information]' \ + '(-V --version)'{-V,--version}'[output the version number]' \ + '--verbose[output verbose messages on internal operations]' \ + '--offline[trigger an error if any required dependencies are not available in local cache]' \ + '--prefer-offline[use network only if dependencies are not available in local cache]' \ + '--strict-semver' \ + '--json' \ + "--ignore-scripts[don't run lifecycle scripts]" \ + '--har[save HAR output of network traffic]' \ + '--ignore-platform[ignore platform checks]' \ + '--ignore-engines[ignore engines check]' \ + '--ignore-optional[ignore optional dependencies]' \ + '--force[install and build packages even if they were built before, overwrite lockfile]' \ + '--skip-integrity-check[run install without checking if node_modules is installed]' \ + '--check-files[install will verify file tree of packages for consistency]' \ + "--no-bin-links[don't generate bin links when setting up packages]" \ + '--flat[only allow one version of a package]' \ + '(--prod --production)'{--prod,--production} \ + "--no-lockfile[don't read or generate a lockfile]" \ + "--pure-lockfile[don't generate a lockfile]" \ + "--frozen-lockfile[don't generate a lockfile and fail if an update is needed]" \ + '--link-duplicates[create hardlinks to the repeated modules in node_modules]' \ + '--global-folder=[modules folder]:folder:_files -/' \ + '--modules-folder=[rather than installing modules into the node_modules folder relative to the cwd, output them here]:folder:_files -/' \ + '--cache-folder=[specify a custom folder to store the yarn cache]:folder:_files -/' \ + '--mutex=[use a mutex to ensure only one yarn instance is executing]:type[\:specifier]' \ + '--no-emoji[disable emoji in output]' \ + '(-s --silent)'{-s,--silent}'[skip Yarn console logs, other types of logs (script output) will be printed]' \ + '--proxy=:host:_hosts' \ + '--https-proxy=:host:_hosts' \ + '--no-progress[disable progress bar]' \ + '--network-concurrency=[maximum number of concurrent network requests]:number' \ + '--network-timeout=[TCP timeout for network requests]:milliseconds' \ + '--non-interactive[do not show interactive prompts]' \ + '1: :_yarn_commands_scripts' \ + '*:: :->command_args' + + + case $state in + command_args) + case $words[1] in + help) + _arguments \ + '1: :_yarn_commands' \ + ;; + + access) + _arguments \ + '1: :(public restricted grant revoke ls-packages ls-collaborators edit)' + ;; + + add) + _arguments \ + '(-D --dev)'{-D,--dev}'[install packages in devDependencies]' \ + '(-P --peer)'{-P,--peer}'[install packages in peerDependencies]' \ + '(-O --optional)'{-O,--optional}'[install packages in optionalDependencies]' \ + '(-E --exact)'{-E,--exact}'[install packages as exact versions]' \ + '(-T --tilde)'{-T,--tilde}'[install the most recent release of the packages that have the same minor version]' \ + '*:package-name:' + ;; + + cache) + _arguments \ + '1: :(ls dir clean)' + ;; + + check) + _arguments \ + '--integrity' \ + '--verify-tree' + ;; + + config) + _arguments \ + '1: :(set get delete list)' \ + '*:: :->config_args' + ;; + + global) + _arguments \ + '--prefix=[bin prefix to use to install binaries]' \ + '1: :_yarn_global_commands' \ + '*:: :->command_args' + ;; + + info) + _arguments \ + '1:package:' \ + '2:field' + ;; + + init) + _arguments \ + '(-y --yes)'{-y,--yes}'[install packages in devDependencies]' + ;; + + licenses) + _arguments \ + '1: :(ls generate-disclaimer)' \ + ;; + + link|unlink|outdated) + _arguments \ + '1:package' \ + ;; + + list) + _arguments \ + '--depth[Limit the depth of the shown dependencies]:depth' + ;; + + owner) + _arguments \ + '1: :(ls add rm)' \ + '*:: :->owner_args' + ;; + + pack) + _arguments \ + '(-f --filename)'{-f,--filename}':filename:_files' + ;; + + publish) + _arguments \ + '--new-version:version:' \ + '--message:message:' \ + '--no-git-tag-version' \ + '--access:access:' \ + '--tag:tag:' \ + '1: :_files' + ;; + + remove|upgrade) + _arguments \ + '*:package:' + ;; + + run) + _arguments \ + '1: :_yarn_scripts' + ;; + + tag) + _arguments \ + '1: :(ls add rm)' \ + '*:: :->tag_args' + ;; + + team) + _arguments \ + '1: :(create destroy add rm ls)' \ + '*:: :->team_args' + ;; + + version) + _arguments \ + '--new-version:version:' \ + '--message:message:' \ + '--no-git-tag-version' + ;; + + why) + _arguments \ + '1:query:_files' + ;; + esac + ;; + esac + + case $state in + config_args) + case $words[1] in + get|delete) + _arguments \ + '1:key:' + ;; + + set) + _arguments \ + '(-g --global)'{-g,--global} \ + '1:key:' \ + '2:value:' + ;; + esac + ;; + + owner_args) + case $words[1] in + ls) + _arguments \ + '1:package:' + ;; + + add|rm) + _arguments \ + '1:user:' \ + '2:package:' + ;; + esac + ;; + + tag_args) + case $words[1] in + ls) + _arguments \ + '1:package' + ;; + + add|rm) + _arguments \ + '1:package:' \ + '2:tag:' + ;; + esac + ;; + + team_args) + case $words[1] in + create|destroy|ls) + _arguments \ + '1:scope\:team:' + ;; + + add|rm) + _arguments \ + '1:scope\:team:' \ + '2:user:' + ;; + esac + ;; + esac +} + +_yarn "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_zcash-cli b/.zprezto/modules/completion/external/src/_zcash-cli new file mode 100644 index 0000000..6dfbe2d --- /dev/null +++ b/.zprezto/modules/completion/external/src/_zcash-cli @@ -0,0 +1,184 @@ +#compdef zcash-cli +# ------------------------------------------------------------------------------ +# Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for zcash-cli (https://z.cash). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Jordy van Wolferen (https://github.com/jvwdev) +# +# ------------------------------------------------------------------------------ + +_zcash-cli() { + local context state line curcontext="$curcontext" + + _arguments -C \ + -?'[This help message]' \ + -conf='[Specify configuration file (default: zcash.conf)]:PATH:_files' \ + -datadir='[Specify data directory]:PATH:_directories' \ + -testnet'[Use the test network]' \ + -regtest'[Enter regression test mode, which uses a special chain in which blocks can be solved instantly. This is intended for regression testing tools and app development.]' \ + -rpcconnect='[Send commands to node running on (default: 127.0.0.1)]:RPCCONNECT:_hosts' \ + -rpcport='[Connect to JSON-RPC on (default: 8232 or testnet: 18232)]: :_guard "[[\:digit\:]]#" "PORT"' \ + -rpcwait'[Wait for RPC server to start]' \ + -rpcuser='[Username for JSON-RPC connections]:RPCUSER:()' \ + -rpcpassword='[Password for JSON-RPC connections]:RPCPASSWORD:()' \ + -rpcclienttimeout='[Timeout in seconds during HTTP requests, or 0 for no timeout. (default: 900)]: :_guard "[[\:digit\:]]#" "RPCCLIENTTIMEOUT"' \ + ':subcommand:->subcommand' && ret=0 + + case $state in + subcommand) + subcommands=( + 'getbestblockhash' + 'getblock' + 'getblockchaininfo' + 'getblockcount' + 'getblockhash' + 'getblockheader' + 'getchaintips' + 'getdifficulty' + 'getmempoolinfo' + 'getrawmempool' + 'gettxout' + 'gettxoutproof' + 'gettxoutsetinfo' + 'verifychain' + 'verifytxoutproof' + 'getinfo' + 'help' + 'stop' + 'generate' + 'getgenerate' + 'setgenerate' + 'getblocksubsidy' + 'getblocktemplate' + 'getlocalsolps' + 'getmininginfo' + 'getnetworkhashps' + 'getnetworksolps' + 'prioritisetransaction' + 'submitblock' + 'addnode' + 'clearbanned' + 'disconnectnode' + 'getaddednodeinfo' + 'getconnectioncount' + 'getnettotals' + 'getnetworkinfo' + 'getpeerinfo' + 'listbanned' + 'ping' + 'setban' + 'createrawtransaction' + 'decoderawtransaction' + 'decodescript' + 'fundrawtransaction' + 'getrawtransaction' + 'sendrawtransaction' + 'signrawtransaction' + 'createmultisig' + 'estimatefee' + 'estimatepriority' + 'validateaddress' + 'verifymessage' + 'z_validateaddress' + 'addmultisigaddress' + 'backupwallet' + 'dumpprivkey' + 'dumpwallet' + 'encryptwallet' + 'getaccount' + 'getaccountaddress' + 'getaddressesbyaccount' + 'getbalance' + 'getnewaddress' + 'getrawchangeaddress' + 'getreceivedbyaccount' + 'getreceivedbyaddress' + 'gettransaction' + 'getunconfirmedbalance' + 'getwalletinfo' + 'importaddress' + 'importprivkey' + 'importwallet' + 'keypoolrefill' + 'listaccounts' + 'listaddressgroupings' + 'listlockunspent' + 'listreceivedbyaccount' + 'listreceivedbyaddress' + 'listsinceblock' + 'listtransactions' + 'listunspent' + 'lockunspent' + 'move' + 'sendfrom' + 'sendmany' + 'sendtoaddress' + 'setaccount' + 'settxfee' + 'signmessage' + 'z_exportkey' + 'z_exportwallet' + 'z_getbalance' + 'z_getnewaddress' + 'z_getoperationresult' + 'z_getoperationstatus' + 'z_gettotalbalance' + 'z_importkey' + 'z_importwallet' + 'z_listaddresses' + 'z_listoperationids' + 'z_listreceivedbyaddress' + 'z_sendmany' + 'zcbenchmark' + 'zcrawjoinsplit' + 'zcrawkeygen' + 'zcrawreceive' + 'zcsamplejoinsplit' + ) + + _describe -t subcommands 'zcash-cli subcommands' subcommands && ret=0 + esac + + return ret +} + +_zcash-cli "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/.zprezto/modules/completion/external/src/_zfs b/.zprezto/modules/completion/external/src/_zfs deleted file mode 100644 index d742c12..0000000 --- a/.zprezto/modules/completion/external/src/_zfs +++ /dev/null @@ -1,597 +0,0 @@ -#compdef zfs -# ------------------------------------------------------------------------------ -# Copyright (c) 2014 Github zsh-users - http://github.com/zsh-users -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the zsh-users nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# Completion script for zfs -# -# Source: https://github.com/zsh-users/zsh/blob/master/Completion/Unix/Command/_zfs -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Rick van Hattem (https://github.com/wolph) -# -# ------------------------------------------------------------------------------ -# Synced with the S11U1 man page - -_zfs() { - local context state line expl - typeset -A opt_args - local -a subcmds rw_properties rw_propnames ro_properties create_properties - local -a share_nfs_ro_properties share_nfs_rw_properties - local -a share_smb_ro_properties share_nfs_rw_properties - local -a share_ro_properties share_rw_properties - local -a difffields delegatable_perms - - subcmds=( - "create" "destroy" "clone" "promote" "rename" "snapshot" - "rollback" "list" "set" "get" "inherit" "mount" "unmount" - "share" "unshare" "send" "receive" "allow" "unallow" - "upgrade" "userspace" "groupspace" "hold" "holds" "release" - "diff" "key" "help" - ) - - share_nfs_ro_properties=( - "share.nfs.all" - ) - - share_nfs_rw_properties=( - "share.nfs:value:(on off)" - "share.nfs.aclok:value:(on off)" - "share.nfs.acflfab:value:(on off)" - "share.nfs.anon:uid:" - "share.nfs.charset.euc-cn:access-list:" - "share.nfs.charset.euc-jpms:access-list:" - "share.nfs.charset.euc-kr:access-list:" - "share.nfs.charset.euc-tw:access-list:" - "share.nfs.charset.iso8859-1:access-list:" - "share.nfs.charset.iso8859-2:access-list:" - "share.nfs.charset.iso8859-5:access-list:" - "share.nfs.charset.iso8859-6:access-list:" - "share.nfs.charset.iso8859-7:access-list:" - "share.nfs.charset.iso8859-8:access-list:" - "share.nfs.charset.iso8859-9:access-list:" - "share.nfs.charset.iso8859-13:access-list:" - "share.nfs.charset.iso8859-15:access-list:" - "share.nfs.charset.koi8-r:access-list:" - "share.nfs.index:file:_files" - "share.nfs.log:nfslog.conf tag:" - "share.nfs.nosub:value:(on off)" - "share.nfs.nosuid:value:(on off)" - "share.nfs.public:value:(on off)" - "share.nfs.sec:security-mode-list:" - "share.nfs.sec.default.none:access-list:" - "share.nfs.sec.default.ro:access-list:" - "share.nfs.sec.default.root:access-list:" - "share.nfs.sec.default.root_mapping:uid:" - "share.nfs.sec.default.rw:access-list:" - "share.nfs.sec.default.window:seconds" - "share.nfs.sec.dh.none:access-list:" - "share.nfs.sec.dh.ro:access-list:" - "share.nfs.sec.dh.root:access-list:" - "share.nfs.sec.dh.root_mapping:uid:" - "share.nfs.sec.dh.rw:access-list:" - "share.nfs.sec.dh.window:seconds" - "share.nfs.sec.krb5.none:access-list:" - "share.nfs.sec.krb5.ro:access-list:" - "share.nfs.sec.krb5.root:access-list:" - "share.nfs.sec.krb5.root_mapping:uid:" - "share.nfs.sec.krb5.rw:access-list:" - "share.nfs.sec.krb5.window:seconds" - "share.nfs.sec.krb5i.none:access-list:" - "share.nfs.sec.krb5i.ro:access-list:" - "share.nfs.sec.krb5i.root:access-list:" - "share.nfs.sec.krb5i.root_mapping:uid:" - "share.nfs.sec.krb5i.rw:access-list:" - "share.nfs.sec.krb5i.window:seconds" - "share.nfs.sec.krb5p.none:access-list:" - "share.nfs.sec.krb5p.ro:access-list:" - "share.nfs.sec.krb5p.root:access-list:" - "share.nfs.sec.krb5p.root_mapping:uid:" - "share.nfs.sec.krb5p.rw:access-list:" - "share.nfs.sec.krb5p.window:seconds" - "share.nfs.sec.none.none:access-list:" - "share.nfs.sec.none.ro:access-list:" - "share.nfs.sec.none.root:access-list:" - "share.nfs.sec.none.root_mapping:uid:" - "share.nfs.sec.none.rw:access-list:" - "share.nfs.sec.none.window:seconds" - "share.nfs.sec.sys.none:access-list:" - "share.nfs.sec.sys.ro:access-list:" - "share.nfs.sec.sys.root:access-list:" - "share.nfs.sec.sys.root_mapping:uid:" - "share.nfs.sec.sys.rw:access-list:" - "share.nfs.sec.sys.window:seconds" - ) - - share_smb_ro_properties=( - "share.smb.all" - ) - - share_smb_rw_properties=( - "share.smb:value:(on off)" - "share.smb.ad-container" - "share.smb.abe" - "share.smb.csc:value:(disabled manual auto vdo)" - "share.smb.catia:value:(on off)" - "share.smb.dfsroot:value:(on off)" - "share.smb.guestok:value:(on off)" - "share.smb.ro:access-list:" - "share.smb.rw:access-list:" - "share.smb.none:access-list:" - ) - - share_ro_properties=( - "share.all" - "share.fs" - "share.name" - "share.point" - "share.protocols" - "share.state" - $share_nfs_ro_properties - $share_smb_ro_properties - ) - - share_rw_properties=( - "share.desc:description:" - "share.noauto:value:(on off)" - "share.path:path:" - $share_nfs_rw_properties - $share_smb_rw_properties - ) - - # TODO: userused@ and groupused@ could have more extensive handling - ro_properties=( - "name" "type" "creation" "used" "available" "referenced" - "compressratio" "mounted" "origin" "usedbychildren" - "usedbydataset" "usedbyrefreservation" "usedbysnapshots" - "defer_destroy" "userused@" "userrefs" "groupused@" - "keychangedate" "keystatus" "rekeydate" - $share_ro_properties - ) - - # TODO: Be cleverer about what values can be set. Is there any way to - # set the sorting for *size properties to false by default? - rw_properties=( - "aclinherit:value:(discard noallow restricted passthrough passthrough-x)" - "aclmode:value:(discard mask passthrough)" - "atime:value:(on off)" - "canmount:value:(on off noauto)" - "checksum:value:(on off fletcher2 fletcher4 sha256 sha256+mac)" - "compression:value:(on off lzjb gzip gzip-{1..9} zle)" - "copies:value:(1 2 3)" - "dedup:value:(on off verify sha256 sha256,verify)" - "devices:value:(on off)" - "encryption:value:(off on aes128-ccm aes-192-ccm aes-256-ccm aes-128-gcm aes-192-gcm aes-256-gcm)" - "exec:value:(on off)" - "groupquota@:value:" # TODO: complete group=size|none - "keysource:value:_zfs_keysource_props" - "logbias:value:(latency throughput)" - "mlslabel:value:(none)" # TODO: list sensitivity labels - "mountpoint:path, 'legacy', or 'none':{if [[ -prefix /* ]]; then _path_files -/; else _wanted mountpoints expl 'mountpoint (type \"/\" to start completing paths)' compadd legacy none; fi}" - "multilevel:value:(on off)" - "nbmand:value:(on off)" - "primarycache:value:(all none metadata)" - "quota:number or 'none':{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ $PREFIX == quota= ]]; then _wanted none expl 'number or none' compadd none; else _wanted none expl 'quota' compadd none; fi}" - "readonly:value:(on off)" - "recordsize:value:(512 1K 2K 4K 8K 16K 32K 64K 128K 256K 512K 1M)" - "refquota:number or 'none':{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ $PREFIX == refquota= ]]; then _wanted none expl 'number or none' compadd none; else _wanted none expl 'refquota' compadd none; fi}" - "refreservation:number or 'none':{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ $PREFIX == refreservation= ]]; then _wanted none expl 'number or none' compadd none; else _wanted none expl 'refreservation' compadd none; fi}" - "reservation:value:{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ $PREFIX == reservation= ]]; then _wanted none expl 'number or none' compadd none; else _wanted none expl 'reservation' compadd none; fi}" - "rstchown:value:(on off)" - "secondarycache:value:(all none metadata)" - "setuid:value:(on off)" - "shadow:value:" # TODO: complete URI|none - "share:share properties:" - "snapdir:value:(hidden visible)" - "sync:value:(standard always disabled)" - "userquota@:value:" # TODO: complete user=size|none - "version:value:(1 2 3 4 current)" - "volsize:value:" # - "vscan:value:(on off)" - "xattr:value:(on off)" - "zoned:value:(on off)" - $share_rw_properties - ) - - create_properties=( - $rw_properties - "casesensitivity:value:(sensitive insensitive mixed)" - "normalization:value:(none formC formD formKC formKD)" - "utf8only:value:(on off)" - "volblocksize:value:(512 1K 2K 4K 8K 16K 32K 64K 128K 256K 512K 1M)" - ) - - delegatable_perms=( - "allow" "clone" "create" "destroy" "diff" "hold" "key" - "keychange" "mount" "promote" "receive" "release" "rename" - "rollback" "send" "share" "snapshot" - "groupused" "userused" "userprop" - ${create_properties%%:*} - ) - - rw_propnames=( ${rw_properties%%:*} ) - - difffields=( - object parent size links linkschange name oldname user group - ctime mtime atime crtime - ) - - if [[ $service == "zfs" ]]; then - _arguments -C -A "-*" \ - '-\?[Help]' \ - '*::command:->subcmd' && return 0 - - if (( CURRENT == 1 )); then - _wanted commands expl "zfs subcommand" compadd -a subcmds - return - fi - service="$words[1]" - curcontext="${curcontext%:*}=$service:" - fi - - case $service in - ("create") - _arguments -A "-*" \ - '-p[Create parent datasets]' \ - '-u[Filesystem is not mounted]' \ - '-o[Set initial properties]:property:_values -s , "property" $create_properties' \ - - set1 \ - ':filesystem:_zfs_dataset -t fs -e "parent dataset"' \ - - set2 \ - '-s[Create sparse volume]' \ - '-b[Set volblocksize]:blocksize:' \ - '-V[Set size]:size:' \ - ':volume:_zfs_dataset -t fs -e "parent dataset"' - ;; - - ("destroy") - _arguments -A "-*" \ - '-r[Recursively destroy all children]' \ - '-R[Recursively destroy all dependents]' \ - '-n[Do a dry run (No-op)]' \ - '-p[Display numbers exactly]' \ - '-v[Verbose]' \ - - set1 \ - '-d[delete or mark deferred]' \ - ':snapshot:_zfs_dataset -t snap' \ - - set2 \ - '-f[Force unmounts]' \ - ':filesystem/volume/snapshot:_zfs_dataset -t fs -t vol' - ;; - - ("snapshot") - _arguments -A "-*" \ - '-r[Recursively snapshot all descendant datasets]' \ - '-o[Set property]:property:_values -s , "property" $create_properties' \ - ':filesystem/volume:_zfs_dataset -t fs -t vol -S@' - ;; - - ("rollback") - _arguments -A "-*" \ - '-r[Recursively destroy more recent snapshots]' \ - '-R[Recursively destroy more recent snapshots and clones]' \ - '-f[Force unmounts]' \ - ':snapshot:_zfs_dataset -t snap' - ;; - - ("clone") - # XXX needs to bail if there are no snapshots - _arguments -A "-*" \ - '-p[Create parent datasets]' \ - '-K[Create encryption key]' \ - '-o[Set property]:property:_values -s , "property" $create_properties' \ - ':snapshot:_zfs_dataset -t snap' \ - ':filesystem/volume:_zfs_dataset -t fs -e "parent dataset"' - ;; - - ("promote") - _arguments \ - ':filesystem:_zfs_dataset -t clone' \ - ;; - - ("rename") - _arguments -A "-*" \ - '(-r)-p[Create parent datasets]' \ - '(-p)-r[Recursively rename snapshots of all descendent datasets]' \ - '-u[Do not remount file systems]' \ - '-f[Force unmounts]' \ - ':dataset:_zfs_dataset -r1' \ - ':dataset:_zfs_dataset -r2' - ;; - - ("list") - _arguments -A "-*" \ - '-r[Recursively display children]' \ - '-H[Scripting mode]' \ - '-d[Depth]:value:' \ - '-o[Properties to list]:property:_values -s , "property" $ro_properties $rw_propnames' \ - '*-s[Sort key (ascending)]:property:_values "property" $ro_properties $rw_propnames' \ - '*-S[Sort key (descending)]:property:_values "property" $ro_properties $rw_propnames' \ - '-t[Dataset types to list]:dataset type:_values -s , "dataset type" all filesystem snapshot volume' \ - '*:filesystem/volume/snapshot/path:_zfs_dataset -p' - ;; - - ("set") - _arguments \ - '-r[Recursively apply value]' \ - ':property:_values -s , "property" $rw_properties' \ - '*:filesystem/volume:_zfs_dataset -t fs -t vol' - ;; - - ("get") - _arguments -A "-*" \ - "-r[Recursively display children's properties]" \ - '-d[Depth]:value:' \ - '-H[Scripting mode]' \ - '-p[Display numbers exactly]' \ - '-s[Specify sources]:source:_values -s , "source" local default inherited temporary none' \ - '-o[Specify fields]:field:_values -s , "field" name property value source' \ - ':property:_values -s , "property" $ro_properties $rw_propnames all' \ - '*:filesystem/volume/snapshot:_zfs_dataset' - ;; - - ("inherit") - _arguments -A "-*" \ - '-r[Recursively inherit property for all children]' \ - '-S[Revert to received property value]' \ - ':property:_values -s , "property" $ro_properties $rw_properties' \ - '*:filesystem/volume:_zfs_dataset -t fs -t vol' - ;; - - ("userspace"|"groupspace") - _arguments -A "-*" \ - '-n[Print numeric ID]' \ - '-H[Tab-delimited output with no headers]' \ - '-p[Parseable mode]' \ - '-o[Properties to list]:property:_values -s , "property" type name used quota' \ - '*-s[Sort key (ascending)]:property:_values "property" type name used quota' \ - '*-S[Sort key (descending)]:property:_values "property" type name used quota' \ - '-t[Types to list]:type:_values -s , "type" all posixuser smbuser posixgroup smbgroup' \ - '-i[Translate SID to POSIX ID]' \ - '*:filesystem/volume/snapshot:_zfs_dataset' - ;; - - ("mount") - _arguments -A "-*" \ - '-o[Mount options]:mount options:_values -s , "option" {,no}{devices,exec,setuid} ro rw' \ - '-O[Overlay mount]' \ - '-v[Report mount progress]' \ - - set1 \ - ':filesystem:_zfs_dataset -t fs' \ - - set2 \ - '-a[Mount all available ZFS filesystems]' - ;; - - ("unmount") - _arguments -A "-*" \ - - set1 \ - '-f[Force unmount]' \ - ':filesystem:_zfs_dataset -t fs -t mtpt' \ - - set2 \ - '-a[Unmount all ZFS filesystems]' - ;; - - ("share") - _arguments -A "-*" \ - - set1 \ - '-a[Share all available ZFS filesystems]' \ - - set2 \ - '-r[Share filesystems recursively]' \ - ':filesystem:_zfs_dataset -t fs' \ - - set3 \ - '*-o[Create a share with these properties]:property:_values -w "share properties" $share_rw_properties' \ - '-u[Create a share without sharing it]' \ - ':filesystem:_zfs_dataset -t fs' \ - - set4 \ - ':filesystem:_zfs_dataset -t fs -t mtpt -t share' - ;; - - ("unshare") - _arguments -A "-*" \ - - set1 \ - '-a[Unshare all shared ZFS filesystems]' \ - - set2 \ - '-r[Unshare filesystems recursively]' \ - ':filesystem:_zfs_dataset -t fs' \ - - set3 \ - ':filesystem:_zfs_dataset -t fs -t mtpt -t share' - ;; - - ("send") - _arguments -A "-*" \ - '-b' \ - '-i[Generate an incremental stream]:snapshot:_zfs_dataset -t snap' \ - '-D[Perform dedup processing]' \ - '-p[Send properties]' \ - '-n[Do a dry run (No-op)]' \ - '-P[Display numbers exactly]' \ - '-v[Verbose]' \ - - set1 \ - '-I[Generate an incremental stream with intermediary snapshots]:snapshot:_zfs_dataset -t snap' \ - '-R[Generate a replication stream package]' \ - ':snapshot:_zfs_dataset -t snap' \ - - set2 \ - '-c[Create a self-contained stream]' \ - '-r[Generate a recursive stream package]' \ - ':snapshot:_zfs_dataset -t snap' - ;; - - ("receive") - _arguments -A "-*" \ - '-v[Verbose]' \ - '-n[Do not receive the stream]' \ - '-F[Force a rollback if necessary]' \ - '-u[Filesystem is not mounted]' \ - '-o[Include property change in the stream]::' \ - '-x[Exclude property change from the stream]:property:' \ - - set1 \ - ':filesystem/volume/snapshot:_zfs_dataset' \ - - set2 \ - '(-e)-d[Set path prefix from stream, excluding only pool name]' \ - '(-d)-e[Set path prefix from stream, using last path element]' \ - '-:filesystem:_zfs_dataset -t fs' - ;; - - ("allow") - _arguments -A "-*" \ - - set1 \ - ':filesystem/volume:_zfs_dataset -t fs -t vol' \ - - set2 \ - '(-g)-u[User]:user:_users' \ - '(-u)-g[Group]:group:_groups' \ - '-l[Allow for named dataset]' \ - '-d[Allow for descendent datasets]' \ - ':permissions or sets:_values -s , "permission or set" $delegatable_perms' \ - ':filesystem/volume:_zfs_dataset -t fs -t vol' \ - - set3 \ - '-e[Everyone]' \ - '-l[Allow for named dataset]' \ - '-d[Allow for descendent datasets]' \ - ':permissions or sets:_values -s , "permission or set" $delegatable_perms' \ - ':filesystem/volume:_zfs_dataset -t fs -t vol' \ - - set4 \ - '-c[Create-time permissions]' \ - ':permissions or sets:_values -s , "permission or set" $delegatable_perms' \ - ':filesystem/volume:_zfs_dataset -t fs -t vol' \ - - set5 \ - '-s[Define or modify permission sets]' \ - ':setname:' \ - ':permissions or sets:_values -s , "permission or set" $delegatable_perms' \ - ':filesystem/volume:_zfs_dataset -t fs -t vol' - ;; - - ("unallow") - _arguments -A "-*" \ - '-r[Recursive removal]' \ - - set1 \ - '-s[Remove permissions from or delete a permission set]:permission set:' \ - ':permissions or sets:_values -s , "permission or set" $delegatable_perms' \ - ':filesystem/volume:_zfs_dataset -t fs -t vol' \ - - set2 \ - '(-g)-u[User]:user:_users' \ - '(-u)-g[Group]:group:_groups' \ - '-l[Allow for named dataset]' \ - '-d[Allow for descendent datasets]' \ - ':permissions or sets:_values -s , "permission or set" $delegatable_perms' \ - ':filesystem/volume:_zfs_dataset -t fs -t vol' \ - - set3 \ - '-e[Everyone]' \ - '-l[Allow for named dataset]' \ - '-d[Allow for descendent datasets]' \ - ':permissions or sets:_values -s , "permission or set" $delegatable_perms' \ - ':filesystem/volume:_zfs_dataset -t fs -t vol' \ - - set4 \ - '-c[Create-time permissions]' \ - ':permissions or sets:_values -s , "permission or set" $delegatable_perms' \ - ':filesystem/volume:_zfs_dataset -t fs -t vol' - ;; - - ("upgrade") - _arguments -A "-*" \ - - set1 \ - '-v[Verbose]' \ - - set2 \ - '-a[Upgrade all filesystems on all pools]' \ - '-r[Upgrade descendent filesystems, too]' \ - '-V[Upgrade to specified version]:version:(1 2)' \ - - set3 \ - '-r[Upgrade descendent filesystems, too]' \ - '-V[Upgrade to specified version]:version:(1 2)' \ - ':filesystem:_zfs_dataset -t fs' - ;; - - ("hold") - _arguments -A "-*" \ - '-r[Apply hold recursively]' \ - ':tag:' \ - ':snapshot:_zfs_dataset -t snap' - ;; - - ("holds") - _arguments -A "-*" \ - '-r[List holds recursively]' \ - ':snapshot:_zfs_dataset -t snap' - ;; - - ("release") - _arguments -A "-*" \ - '-r[Release holds recursively]' \ - ':tag:' \ - ':snapshot:_zfs_dataset -t snap' - ;; - - ("diff") - _arguments -A "-*" \ - '-F[Add column for filetype character]' \ - '-H[Parseable output]' \ - '-e[Only show new and changed files]' \ - '*-o[Show fields]:field:_values "field" $difffields' \ - '-t[Add column for ctime]' \ - - set1 \ - ':snapshot:_zfs_dataset -t snap' \ - ':snapshot or filesystem:_zfs_dataset -t snap -t fs' \ - - set2 \ - '-E[Show difference from empty]' \ - ':snapshot or filesystem:_zfs_dataset -t snap -t fs' - ;; - - ("key") - _arguments -A "-*" \ - - set1 \ - '-a[Apply to all datasets in all pools]' \ - '(-u -K -f)-l[Load the encryption key]' \ - '(-l -K)-u[Unload the encryption key]' \ - '(-l -u -f)-K[Create a new data encryption key]' \ - '(-l -K)-f[Unmount the dataset before unloading the encryption key]' \ - '-r[Apply recursively]' \ - ':filesystem or volume:_zfs_dataset -t fs -t vol' \ - - set2 \ - '-c[Change the encryption key]' \ - '-o[Change a property]:property:_zfs_keysource_props' \ - ':filesystem or volume:_zfs_dataset -t fs -t vol' - ;; - - ("help") - _arguments -A "-*" \ - - set1 \ - ':command:($subcmds $delegatable_perms $ro_properties ${rw_properties%%:*} properties)' \ - - set2 \ - '-l[Display property information]' \ - ': :(properties)' - ;; - - (*) - _message "unknown zfs subcommand: $service" - ;; - esac -} - -_zfs "$@" diff --git a/.zprezto/modules/completion/external/zsh-completions.plugin.zsh b/.zprezto/modules/completion/external/zsh-completions.plugin.zsh index f8be8e7..b56f55d 100644 --- a/.zprezto/modules/completion/external/zsh-completions.plugin.zsh +++ b/.zprezto/modules/completion/external/zsh-completions.plugin.zsh @@ -1 +1 @@ -fpath+="`dirname $0`/src" +fpath+="${0:h}/src" diff --git a/.zprezto/modules/completion/init.zsh b/.zprezto/modules/completion/init.zsh index 023a90e..48202f3 100644 --- a/.zprezto/modules/completion/init.zsh +++ b/.zprezto/modules/completion/init.zsh @@ -14,9 +14,6 @@ fi # Add zsh-completions to $fpath. fpath=("${0:h}/external/src" $fpath) -# Load and initialize the completion system ignoring insecure directories. -autoload -Uz compinit && compinit -i - # # Options # @@ -27,9 +24,22 @@ setopt PATH_DIRS # Perform path search even on command names with slas setopt AUTO_MENU # Show completion menu on a successive tab press. setopt AUTO_LIST # Automatically list choices on ambiguous completion. setopt AUTO_PARAM_SLASH # If completed parameter is a directory, add a trailing slash. +setopt EXTENDED_GLOB # Needed for file modification glob modifiers with compinit unsetopt MENU_COMPLETE # Do not autoselect the first completion entry. unsetopt FLOW_CONTROL # Disable start/stop characters in shell editor. +# Load and initialize the completion system ignoring insecure directories with a +# cache time of 20 hours, so it should almost always regenerate the first time a +# shell is opened each day. +autoload -Uz compinit +_comp_files=(${ZDOTDIR:-$HOME}/.zcompdump(Nm-20)) +if (( $#_comp_files )); then + compinit -i -C +else + compinit -i +fi +unset _comp_files + # # Styles # @@ -66,8 +76,9 @@ zstyle ':completion:*' completer _complete _match _approximate zstyle ':completion:*:match:*' original only zstyle ':completion:*:approximate:*' max-errors 1 numeric -# Increase the number of errors based on the length of the typed word. -zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)' +# Increase the number of errors based on the length of the typed word. But make +# sure to cap (at 7) the max-errors to avoid hanging. +zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3>7?7:($#PREFIX+$#SUFFIX)/3))numeric)' # Don't complete unavailable commands. zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec))' @@ -91,11 +102,14 @@ zstyle ':completion:*:history-words' menu yes # Environmental Variables zstyle ':completion::*:(-command-|export):*' fake-parameters ${${${_comps[(I)-value-*]#*,}%%,*}:#-*-} -# Populate hostname completion. +# Populate hostname completion. But allow ignoring custom entries from static +# */etc/hosts* which might be uninteresting. +zstyle -a ':prezto:module:completion:*:hosts' etc-host-ignores '_etc_host_ignores' + zstyle -e ':completion:*:hosts' hosts 'reply=( - ${=${=${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) 2>/dev/null)"}%%[#| ]*}//\]:[0-9]*/ }//,/ }//\[/ } - ${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2>/dev/null))"}%%\#*} - ${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}} + ${=${=${=${${(f)"$(cat {/etc/ssh/ssh_,~/.ssh/}known_hosts(|2)(N) 2> /dev/null)"}%%[#| ]*}//\]:[0-9]*/ }//,/ }//\[/ } + ${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2> /dev/null))"}%%(\#${_etc_host_ignores:+|${(j:|:)~_etc_host_ignores}})*} + ${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2> /dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}} )' # Don't complete uninteresting users... @@ -139,9 +153,8 @@ if [[ -s "$HOME/.mutt/aliases" ]]; then fi # SSH/SCP/RSYNC -zstyle ':completion:*:(scp|rsync):*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *' +zstyle ':completion:*:(ssh|scp|rsync):*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *' zstyle ':completion:*:(scp|rsync):*' group-order users files all-files hosts-domain hosts-host hosts-ipaddr -zstyle ':completion:*:ssh:*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *' zstyle ':completion:*:ssh:*' group-order users hosts-domain hosts-host users hosts-ipaddr zstyle ':completion:*:(ssh|scp|rsync):*:hosts-host' ignored-patterns '*(.|:)*' loopback ip6-loopback localhost ip6-localhost broadcasthost zstyle ':completion:*:(ssh|scp|rsync):*:hosts-domain' ignored-patterns '<->.<->.<->.<->' '^[-[:alnum:]]##(.[-[:alnum:]]##)##' '*@*' diff --git a/.zprezto/modules/directory/init.zsh b/.zprezto/modules/directory/init.zsh index 47191df..8abc1e2 100644 --- a/.zprezto/modules/directory/init.zsh +++ b/.zprezto/modules/directory/init.zsh @@ -16,7 +16,6 @@ setopt PUSHD_IGNORE_DUPS # Do not store duplicates in the stack. setopt PUSHD_SILENT # Do not print the directory stack after pushd or popd. setopt PUSHD_TO_HOME # Push to home directory when no argument is given. setopt CDABLE_VARS # Change directory to a path stored in a variable. -setopt AUTO_NAME_DIRS # Auto add variable-stored paths to ~ list. setopt MULTIOS # Write to multiple descriptors. setopt EXTENDED_GLOB # Use extended globbing syntax. unsetopt CLOBBER # Do not overwrite existing files with > and >>. diff --git a/.zprezto/modules/docker/README.md b/.zprezto/modules/docker/README.md new file mode 100644 index 0000000..335f77a --- /dev/null +++ b/.zprezto/modules/docker/README.md @@ -0,0 +1,190 @@ +# ZSH Docker Aliases + +Defines [Docker][1] aliases and functions. + +## Aliases + +### Docker + +- `dk` is short for `docker` +- `dka` Attach to a running container +- `dkb` Build an image from a Dockerfile +- `dkd` Inspect changes on a container's filesystem +- `dkdf` Show docker filesystem usage +- `dke` Run a command in a running container +- `dkE` Run an interactive command in a running container +- `dkh` Show the history of an image +- `dki` List images +- `dkin` Return low-level information on a container, image or task +- `dkk` Kill a running container +- `dkl` Fetch the logs of a container +- `dkli` Log in to a Docker registry +- `dklo` Log out from a Docker registry +- `dkls` is alias for `dkps` +- `dkp` Pause all processes within one or more containers +- `dkP` Unpause all processes within one or more containers +- `dkpl` Pull an image or a repository from a registry +- `dkph` Push an image or a repository to a registry +- `dkps` List containers +- `dkpsa` List all containers (default lists just running) +- `dkr` Run a command in a new container +- `dkR` Run an interactive command in a new container and automatically remove the container when it exits +- `dkRe` like `dkR` and set entry point to `/bin/bash` +- `dkrm` Remove one or more containers +- `dkrmi` Remove one or more images +- `dkrmC` Clean up exited containers +- `dkrmI` Clean up dangling images +- `dkrmV` Clean up unused volumes ( Docker >= 1.9 ) +- `dkrn` Rename a container +- `dks` Start one or more stopped containers +- `dkS` Restart a container +- `dkss` Display a live stream of container(s) resource usage statistics +- `dksv` Save one or more images to a tar archive (streamed to STDOUT by default) +- `dkt` Tag an image into a repository +- `dktop` Display the running processes of a container +- `dkup` Update configuration of one or more containers +- `dkV` Manage Docker volumes +- `dkv` Show the Docker version information +- `dkw` Block until a container stops, then print its exit code +- `dkx` Stop a running container + +#### container (C) + +- `dkC` Manage containers +- `dkCa` Attach to a running container +- `dkCcp` Copy files/folders between a container and the local filesystem +- `dkCd` Inspect changes on a container's filesystem +- `dkCe` Run a command in a running container +- `dkCin` Display detailed information on one or more containers +- `dkCk` Kill one or more running containers +- `dkCl` Fetch the logs of a container +- `dkCls` List containers +- `dkCp` Pause all processes within one or more containers +- `dkCpr` Remove all stopped containers +- `dkCrn` Rename a container +- `dkCS` Restart one or more containers +- `dkCrm` Remove one or more containers +- `dkCr` Run a command in a new container +- `dkCR` Run an interactive command in a new container and automatically remove the container when it exits +- `dkCRe` like `dkCR` and set entry point to `/bin/bash` +- `dkCs` Start one or more stopped containers +- `dkCss` Display a live stream of container(s) resource usage statistics +- `dkCx` Stop one or more running containers +- `dkCtop` Display the running processes of a container +- `dkCP` Unpause all processes within one or more containers +- `dkCup` Update configuration of one or more containers +- `dkCw` Block until one or more containers stop, then print their exit codes + +#### image (I) + +- `dkI` Manage images +- `dkIb` Build an image from a Dockerfile +- `dkIh` Show the history of an image +- `dkIim` Import the contents from a tarball to create a filesystem image +- `dkIin` Display detailed information on one or more images +- `dkIls` List images +- `dkIpr` Remove unused images +- `dkIpl` Pull an image or a repository from a registry +- `dkIph` Push an image or a repository to a registry +- `dkIrm` Remove one or more images +- `dkIsv` Save one or more images to a tar archive (streamed to STDOUT by default) +- `dkIt` Tag an image into a repository + +#### volume (V) + +- `dkV` Manage volumes +- `dkVin` Display detailed information on one or more volumes +- `dkVls` List volumes +- `dkVpr` Remove all unused volumes +- `dkVrm` Remove one or more volumes + +#### network (N) + +- `dkN` Manage networks +- `dkNs` Connect a container to a network +- `dkNx` Disconnects a container from a network +- `dkNin` Displays detailed information on a network +- `dkNls` Lists all the networks created by the user +- `dkNpr` Remove all unused networks +- `dkNrm` Deletes one or more networks + +#### system (Y) + +- `dkY` Manage Docker +- `dkYdf` Show docker filesystem usage +- `dkYpr` Remove unused data + +#### stack (K) + +- `dkK` Manage Docker stacks +- `dkKls` List stacks +- `dkKps` List the tasks in the stack +- `dkKrm` Remove the stack + +#### swarm (W) + +- `dkW` Manage Docker Swarm + +### Docker Machine + +- `dkm` is short for `docker-machine` +- `dkma` Get or set the active machine +- `dkmcp` Copy files between machines +- `dkmd` Set up the default machine ; alowing you to use `dkme` without arguments +- `dkme` Set up the environment for the Docker client (eg: `dkme staging` to toggle to staging) +- `dkmin` Inspect information about a machine +- `dkmip` Get the IP address of a machine +- `dkmk` Kill a machine +- `dkmls` List machines +- `dkmpr` Re-provision existing machines +- `dkmps` is alias for `dkmls` +- `dkmrg` Regenerate TLS Certificates for a machine +- `dkmrm` Remove a machine +- `dkms` Start a machine +- `dkmsh` Log into or run a command on a machine with SSH +- `dkmst` Get the status of a machine +- `dkmS` Restart a machine +- `dkmu` Get the URL of a machine +- `dkmup` Upgrade a machine to the latest version of Docker +- `dkmV` Show the Docker Machine version or a machine docker version +- `dkmx` Stop a machine + +### Docker Compose + +- `dkc` is short for `docker-compose` +- `dkcb` Build or rebuild services +- `dkcB` Build or rebuild services and do not use cache when building the image +- `dkcd` Stop and remove containers, networks, images, and volumes +- `dkce` Execute a command in a running container +- `dkck` Kill containers +- `dkcl` View output from containers +- `dkcls` is alias for `dkcps` +- `dkcp` Pause services +- `dkcP` Unpause services +- `dkcpl` Pull service images +- `dkcph` Push service images +- `dkcps` List containers +- `dkcr` Run a one-off command +- `dkcR` Run a one-off command and remove container after run. +- `dkcrm` Remove stopped containers +- `dkcs` Start services +- `dkcsc` Set number of containers for a service +- `dkcS` Restart services +- `dkcu` Create and start containers +- `dkcU` Create and start containers in detached mode: + Run containers in the background, print new container names +- `dkcV` Show the Docker-Compose version information +- `dkcx` Stop services + +## Support + +If you're having problems, use the [Prezto issue tracker][2]. + +## Acknowledgements + +This module is a copy of [akarzim/zsh-docker-aliases][3] by [François Vantomme][4] (MIT License). + +[1]: https://www.docker.com/ +[2]: https://github.com/zsh-users/prezto/issues +[3]: https://github.com/akarzim/zsh-docker-aliases +[4]: https://github.com/akarzim diff --git a/.zprezto/modules/docker/alias.zsh b/.zprezto/modules/docker/alias.zsh new file mode 100644 index 0000000..cdd9f7c --- /dev/null +++ b/.zprezto/modules/docker/alias.zsh @@ -0,0 +1,177 @@ +# +# Defines Docker aliases. +# +# Author: +# François Vantomme +# + +# +# Aliases +# + +# Docker +alias dk='docker' +alias dka='docker attach' +alias dkb='docker build' +alias dkd='docker diff' +alias dkdf='docker system df' +alias dke='docker exec' +alias dkE='docker exec -it' +alias dkh='docker history' +alias dki='docker images' +alias dkin='docker inspect' +alias dkim='docker import' +alias dkk='docker kill' +alias dkl='docker logs' +alias dkli='docker login' +alias dklo='docker logout' +alias dkls='docker ps' +alias dkp='docker pause' +alias dkP='docker unpause' +alias dkpl='docker pull' +alias dkph='docker push' +alias dkps='docker ps' +alias dkpsa='docker ps -a' +alias dkr='docker run' +alias dkR='docker run -it --rm' +alias dkRe='docker run -it --rm --entrypoint /bin/bash' +alias dkRM='docker system prune' +alias dkrm='docker rm' +alias dkrmi='docker rmi' +alias dkrn='docker rename' +alias dks='docker start' +alias dkS='docker restart' +alias dkss='docker stats' +alias dksv='docker save' +alias dkt='docker tag' +alias dktop='docker top' +alias dkup='docker update' +alias dkV='docker volume' +alias dkv='docker version' +alias dkw='docker wait' +alias dkx='docker stop' + +## Container (C) +alias dkC='docker container' +alias dkCa='docker container attach' +alias dkCcp='docker container cp' +alias dkCd='docker container diff' +alias dkCe='docker container exec' +alias dkCin='docker container inspect' +alias dkCk='docker container kill' +alias dkCl='docker container logs' +alias dkCls='docker container ls' +alias dkCp='docker container pause' +alias dkCpr='docker container prune' +alias dkCrn='docker container rename' +alias dkCS='docker container restart' +alias dkCrm='docker container rm' +alias dkCr='docker container run' +alias dkCR='docker container run -it --rm' +alias dkCRe='docker container run -it --rm --entrypoint /bin/bash' +alias dkCs='docker container start' +alias dkCss='docker container stats' +alias dkCx='docker container stop' +alias dkCtop='docker container top' +alias dkCP='docker container unpause' +alias dkCup='docker container update' +alias dkCw='docker container wait' + +## Image (I) +alias dkI='docker image' +alias dkIb='docker image build' +alias dkIh='docker image history' +alias dkIim='docker image import' +alias dkIin='docker image inspect' +alias dkIls='docker image ls' +alias dkIpr='docker image prune' +alias dkIpl='docker image pull' +alias dkIph='docker image push' +alias dkIrm='docker image rm' +alias dkIsv='docker image save' +alias dkIt='docker image tag' + +## Volume (V) +alias dkV='docker volume' +alias dkVin='docker volume inspect' +alias dkVls='docker volume ls' +alias dkVpr='docker volume prune' +alias dkVrm='docker volume rm' + +## Network (N) +alias dkN='docker network' +alias dkNs='docker network connect' +alias dkNx='docker network disconnect' +alias dkNin='docker network inspect' +alias dkNls='docker network ls' +alias dkNpr='docker network prune' +alias dkNrm='docker network rm' + +## System (Y) +alias dkY='docker system' +alias dkYdf='docker system df' +alias dkYpr='docker system prune' + +## Stack (K) +alias dkK='docker stack' +alias dkKls='docker stack ls' +alias dkKps='docker stack ps' +alias dkKrm='docker stack rm' + +## Swarm (W) +alias dkW='docker swarm' + +## CleanUp (rm) +# Clean up exited containers (docker < 1.13) +alias dkrmC='docker rm $(docker ps -qaf status=exited)' +# Clean up dangling images (docker < 1.13) +alias dkrmI='docker rmi $(docker images -qf dangling=true)' +# Clean up dangling volumes (docker < 1.13) +alias dkrmV='docker volume rm $(docker volume ls -qf dangling=true)' + + +# Docker Machine (m) +alias dkm='docker-machine' +alias dkma='docker-machine active' +alias dkmcp='docker-machine scp' +alias dkmin='docker-machine inspect' +alias dkmip='docker-machine ip' +alias dkmk='docker-machine kill' +alias dkmls='docker-machine ls' +alias dkmpr='docker-machine provision' +alias dkmps='docker-machine ps' +alias dkmrg='docker-machine regenerate-certs' +alias dkmrm='docker-machine rm' +alias dkms='docker-machine start' +alias dkmsh='docker-machine ssh' +alias dkmst='docker-machine status' +alias dkmS='docker-machine restart' +alias dkmu='docker-machine url' +alias dkmup='docker-machine upgrade' +alias dkmv='docker-machine version' +alias dkmx='docker-machine stop' + +# Docker Compose (c) +alias dkc='docker-compose' +alias dkcb='docker-compose build' +alias dkcB='docker-compose build --no-cache' +alias dkcd='docker-compose down' +alias dkce='docker-compose exec' +alias dkck='docker-compose kill' +alias dkcl='docker-compose logs' +alias dkcls='docker-compose ps' +alias dkcp='docker-compose pause' +alias dkcP='docker-compose unpause' +alias dkcpl='docker-compose pull' +alias dkcph='docker-compose push' +alias dkcps='docker-compose ps' +alias dkcr='docker-compose run' +alias dkcR='docker-compose run --rm' +alias dkcrm='docker-compose rm' +alias dkcs='docker-compose start' +alias dkcsc='docker-compose scale' +alias dkcS='docker-compose restart' +alias dkcu='docker-compose up' +alias dkcU='docker-compose up -d' +alias dkcv='docker-compose version' +alias dkcx='docker-compose stop' diff --git a/.zprezto/modules/docker/init.zsh b/.zprezto/modules/docker/init.zsh new file mode 100644 index 0000000..8ad6bfd --- /dev/null +++ b/.zprezto/modules/docker/init.zsh @@ -0,0 +1,57 @@ +# +# Defines Docker aliases. +# +# Author: +# François Vantomme +# + +# Return if requirements are not found. +if (( ! $+commands[docker] )); then + return 1 +fi + +# +# Functions +# + +# Set Docker Machine environment +function dkme { + if (( ! $+commands[docker-machine] )); then + return 1 + fi + + eval $(docker-machine env $1) +} + +# Set Docker Machine default machine +function dkmd { + if (( ! $+commands[docker-machine] )); then + return 1 + fi + + pushd ~/.docker/machine/machines + + if [[ ! -d $1 ]]; then + echo "Docker machine '$1' does not exists. Abort." + popd + return 1 + fi + + if [[ -L default ]]; then + eval $(rm -f default) + elif [[ -d default ]]; then + echo "A default machine already exists. Abort." + popd + return 1 + elif [[ -e default ]]; then + echo "A file named 'default' already exists. Abort." + popd + return 1 + fi + + eval $(ln -s $1 default) + popd +} + +# Source module files. +source "${0:h}/alias.zsh" diff --git a/.zprezto/modules/dpkg/functions/deb-clone b/.zprezto/modules/dpkg/functions/deb-clone index a284c96..a767bd3 100644 --- a/.zprezto/modules/dpkg/functions/deb-clone +++ b/.zprezto/modules/dpkg/functions/deb-clone @@ -6,6 +6,8 @@ # Sorin Ionescu # +# function deb-clone { + local clone_script="${0}.sh" local package_list=$( perl \ @@ -23,3 +25,5 @@ rm "$clone_script" print '#!/bin/sh\n' > "$clone_script" print "aptitude install ${package_list}\n" >> "$clone_script" chmod +x "$clone_script" + +# } diff --git a/.zprezto/modules/dpkg/functions/deb-history b/.zprezto/modules/dpkg/functions/deb-history index 3737679..a1369de 100644 --- a/.zprezto/modules/dpkg/functions/deb-history +++ b/.zprezto/modules/dpkg/functions/deb-history @@ -7,6 +7,8 @@ # Sorin Ionescu # +# function deb-history { + case "$1" in (install) zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*) @@ -34,3 +36,5 @@ Commands: EOF ;; esac + +# } diff --git a/.zprezto/modules/dpkg/functions/deb-kbuild b/.zprezto/modules/dpkg/functions/deb-kbuild index bdf7801..a84a9b6 100644 --- a/.zprezto/modules/dpkg/functions/deb-kbuild +++ b/.zprezto/modules/dpkg/functions/deb-kbuild @@ -6,9 +6,13 @@ # Sorin Ionescu # +# function deb-kbuild { + make-kpkg clean MAKEFLAGS='' time fakeroot make-kpkg \ --append-to-version '-custom' \ --revision "$(date +"%Y%m%d")" \ kernel_image \ kernel_headers + +# } diff --git a/.zprezto/modules/dpkg/init.zsh b/.zprezto/modules/dpkg/init.zsh index e1f479b..69d524f 100644 --- a/.zprezto/modules/dpkg/init.zsh +++ b/.zprezto/modules/dpkg/init.zsh @@ -54,4 +54,4 @@ fi alias deb-build='time dpkg-buildpackage -rfakeroot -us -uc' # Removes all kernel images and headers, except for the ones in use. -alias deb-kclean='sudo aptitude remove -P "?and(~i~nlinux-(ima|hea) ?not(~n`uname -r`))"' +alias deb-kclean='sudo aptitude remove -P "?and(~i~nlinux-(ima|hea) ?not(~n$(uname -r)))"' diff --git a/.zprezto/modules/editor/README.md b/.zprezto/modules/editor/README.md index da0185f..c27e864 100644 --- a/.zprezto/modules/editor/README.md +++ b/.zprezto/modules/editor/README.md @@ -11,14 +11,27 @@ Settings To enable key bindings, add the following to *zpreztorc*, and replace 'bindings' with 'emacs' or 'vi'. - zstyle ':prezto:module:editor' key-bindings 'bindings' +```sh +zstyle ':prezto:module:editor' key-bindings 'bindings' +``` ### Dot Expansion To enable the auto conversion of .... to ../.., add the following to *zpreztorc*. - zstyle ':prezto:module:editor' dot-expansion 'yes' +```sh +zstyle ':prezto:module:editor' dot-expansion 'yes' +``` + +### PS Context + +To enable the prompt context to be set, add the following to your +*zpreztorc*. + +```sh +zstyle ':prezto:module:editor' ps-context 'yes' +``` Theming ------- @@ -26,31 +39,56 @@ Theming To indicate when the editor is in the primary keymap (emacs or viins), add the following to your `theme_prompt_setup` function. - zstyle ':prezto:module:editor:info:keymap:primary' format '>>>' +```sh +zstyle ':prezto:module:editor:info:keymap:primary' format '>>>' +``` To indicate when the editor is in the primary keymap (emacs or viins) insert mode, add the following to your `theme_prompt_setup` function. - zstyle ':prezto:module:editor:info:keymap:primary:insert' format 'I' +```sh +zstyle ':prezto:module:editor:info:keymap:primary:insert' format 'I' +``` To indicate when the editor is in the primary keymap (emacs or viins) overwrite mode, add the following to your `theme_prompt_setup` function. - zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format 'O' +```sh +zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format 'O' +``` To indicate when the editor is in the alternate keymap (vicmd), add the following to your `theme_prompt_setup` function. - zstyle ':prezto:module:editor:info:keymap:alternate' format '<<<' +```sh +zstyle ':prezto:module:editor:info:keymap:alternate' format '<<<' +``` To indicate when the editor is completing, add the following to your `theme_prompt_setup` function. - zstyle ':prezto:module:editor:info:completing' format '...' +```sh +zstyle ':prezto:module:editor:info:completing' format '...' +``` Then add `$editor_info[context]`, where context is *keymap*, *insert*, or *overwrite*, to `$PROMPT` or `$RPROMPT`. +Convenience Functions +--------------------- + +### bindkey-all + +Provides a function `bindkey-all` which can be useful for checking how all of the +keys are bound. Normal `bindkey` command will only list the keys bound for one +keymap, which is not as useful if you want to grep through the output. The +keymap's names go to stderr so when you grep through bindkey-all's output you +will still see the headings and can tell which keymap each binding goes to. + +It will also pass through arguments so you can use bindkey-all to set bindings +for all keymaps at once. If provided arguments it will *not* print out the +names of each of the keymaps, and just run the command for each keymap. + Authors ------- diff --git a/.zprezto/modules/editor/init.zsh b/.zprezto/modules/editor/init.zsh index 9aa64d6..085947e 100644 --- a/.zprezto/modules/editor/init.zsh +++ b/.zprezto/modules/editor/init.zsh @@ -14,8 +14,7 @@ fi # Options # -# Beep on error in line editor. -setopt BEEP +setopt BEEP # Beep on error in line editor. # # Variables @@ -28,9 +27,11 @@ WORDCHARS='*?_-.[]~&;!#$%^(){}<>' zmodload zsh/terminfo typeset -gA key_info key_info=( - 'Control' '\C-' - 'ControlLeft' '\e[1;5D \e[5D \e\e[D \eOd' - 'ControlRight' '\e[1;5C \e[5C \e\e[C \eOc' + 'Control' '\C-' + 'ControlLeft' '\e[1;5D \e[5D \e\e[D \eOd' + 'ControlRight' '\e[1;5C \e[5C \e\e[C \eOc' + 'ControlPageUp' '\e[5;5~' + 'ControlPageDown' '\e[6;5~' 'Escape' '\e' 'Meta' '\M-' 'Backspace' "^?" @@ -78,7 +79,15 @@ zle -N edit-command-line # # Functions # - +# Runs bindkey but for all of the keymaps. Running it with no arguments will +# print out the mappings for all of the keymaps. +function bindkey-all { + local keymap='' + for keymap in $(bindkey -l); do + [[ "$#" -eq 0 ]] && printf "#### %s\n" "${keymap}" 1>&2 + bindkey -M "${keymap}" "$@" + done +} # Exposes information about the Zsh Line Editor via the $editor_info associative # array. function editor-info { @@ -103,12 +112,27 @@ function editor-info { fi unset REPLY - - zle reset-prompt - zle -R + zle zle-reset-prompt } zle -N editor-info +# Reset the prompt based on the current context and +# the ps-context option. +function zle-reset-prompt { + if zstyle -t ':prezto:module:editor' ps-context; then + # If we aren't within one of the specified contexts, then we want to reset + # the prompt with the appropriate editor_info[keymap] if there is one. + if [[ $CONTEXT != (select|cont) ]]; then + zle reset-prompt + zle -R + fi + else + zle reset-prompt + zle -R + fi +} +zle -N zle-reset-prompt + # Updates editor information when the keymap changes. function zle-keymap-select { zle editor-info @@ -186,6 +210,14 @@ zle -N expand-dot-to-parent-directory-path function expand-or-complete-with-indicator { local indicator zstyle -s ':prezto:module:editor:info:completing' format 'indicator' + + # This is included to work around a bug in zsh which shows up when interacting + # with multi-line prompts. + if [[ -z "$indicator" ]]; then + zle expand-or-complete + return + fi + print -Pn "$indicator" zle expand-or-complete zle redisplay @@ -201,6 +233,35 @@ function prepend-sudo { } zle -N prepend-sudo +# Expand aliases +function glob-alias { + zle _expand_alias + zle expand-word + zle magic-space +} +zle -N glob-alias + +# Toggle the comment character at the start of the line. This is meant to work +# around a buggy implementation of pound-insert in zsh. +# +# This is currently only used for the emacs keys because vi-pound-insert has +# been reported to work properly. +function pound-toggle { + if [[ "$BUFFER" = '#'* ]]; then + # Because of an oddity in how zsh handles the cursor when the buffer size + # changes, we need to make this check before we modify the buffer and let + # zsh handle moving the cursor back if it's past the end of the line. + if [[ $CURSOR != $#BUFFER ]]; then + (( CURSOR -= 1 )) + fi + BUFFER="${BUFFER:1}" + else + BUFFER="#$BUFFER" + (( CURSOR += 1 )) + fi +} +zle -N pound-toggle + # Reset to default key bindings. bindkey -d @@ -236,12 +297,18 @@ if (( $+widgets[history-incremental-pattern-search-backward] )); then history-incremental-pattern-search-forward fi +# Toggle comment at the start of the line. Note that we use pound-toggle which +# is similar to pount insert, but meant to work around some issues that were +# being seen in iTerm. +bindkey -M emacs "$key_info[Escape];" pound-toggle + + # # Vi Key Bindings # -# Edit command in an external editor. -bindkey -M vicmd "v" edit-command-line +# Edit command in an external editor emacs style (v is used for visual mode) +bindkey -M vicmd "$key_info[Control]X$key_info[Control]E" edit-command-line # Undo/Redo bindkey -M vicmd "u" undo @@ -255,14 +322,61 @@ else bindkey -M vicmd "/" history-incremental-search-forward fi +# Toggle comment at the start of the line. +bindkey -M vicmd "#" vi-pound-insert + # # Emacs and Vi Key Bindings # -for keymap in 'emacs' 'viins'; do +# Unbound keys in vicmd and viins mode will cause really odd things to happen +# such as the casing of all the characters you have typed changing or other +# undefined things. In emacs mode they just insert a tilde, but bind these keys +# in the main keymap to a noop op so if there is no keybind in the users mode +# it will fall back and do nothing. +function _prezto-zle-noop { ; } +zle -N _prezto-zle-noop +local -a unbound_keys +unbound_keys=( + "${key_info[F1]}" + "${key_info[F2]}" + "${key_info[F3]}" + "${key_info[F4]}" + "${key_info[F5]}" + "${key_info[F6]}" + "${key_info[F7]}" + "${key_info[F8]}" + "${key_info[F9]}" + "${key_info[F10]}" + "${key_info[F11]}" + "${key_info[F12]}" + "${key_info[PageUp]}" + "${key_info[PageDown]}" + "${key_info[ControlPageUp]}" + "${key_info[ControlPageDown]}" +) +for keymap in $unbound_keys; do + bindkey -M viins "${keymap}" _prezto-zle-noop + bindkey -M vicmd "${keymap}" _prezto-zle-noop +done + +# Keybinds for all keymaps +for keymap in 'emacs' 'viins' 'vicmd'; do bindkey -M "$keymap" "$key_info[Home]" beginning-of-line bindkey -M "$keymap" "$key_info[End]" end-of-line +done +# Keybinds for all vi keymaps +for keymap in viins vicmd; do + # Ctrl + Left and Ctrl + Right bindings to forward/backward word + for key in "${(s: :)key_info[ControlLeft]}" + bindkey -M "$keymap" "$key" vi-backward-word + for key in "${(s: :)key_info[ControlRight]}" + bindkey -M "$keymap" "$key" vi-forward-word +done + +# Keybinds for emacs and vi insert mode +for keymap in 'emacs' 'viins'; do bindkey -M "$keymap" "$key_info[Insert]" overwrite-mode bindkey -M "$keymap" "$key_info[Delete]" delete-char bindkey -M "$keymap" "$key_info[Backspace]" backward-delete-char @@ -305,8 +419,14 @@ for keymap in 'emacs' 'viins'; do # Insert 'sudo ' at the beginning of the line. bindkey -M "$keymap" "$key_info[Control]X$key_info[Control]S" prepend-sudo + + # control-space expands all aliases, including global + bindkey -M "$keymap" "$key_info[Control] " glob-alias done +# Delete key deletes character in vimcmd cmd mode instead of weird default functionality +bindkey -M vicmd "$key_info[Delete]" delete-char + # Do not expand .... to ../.. during incremental search. if zstyle -t ':prezto:module:editor' dot-expansion; then bindkey -M isearch . self-insert 2> /dev/null @@ -326,4 +446,4 @@ else print "prezto: editor: invalid key bindings: $key_bindings" >&2 fi -unset key{,map,bindings} +unset key{,map,_bindings} diff --git a/.zprezto/modules/environment/README.md b/.zprezto/modules/environment/README.md index b86cbc5..b0d579b 100644 --- a/.zprezto/modules/environment/README.md +++ b/.zprezto/modules/environment/README.md @@ -13,13 +13,14 @@ Contributors This module **MUST NOT** rely on any command not built in Zsh. -Non-interactive environment variables should be defined in *zshenv*. +Non-interactive environment variables should be defined in [`zshenv`][1]. Authors ------- -*The authors of this module should be contacted via the [issue tracker][1].* +*The authors of this module should be contacted via the [issue tracker][2].* - [Sorin Ionescu](https://github.com/sorin-ionescu) -[1]: https://github.com/sorin-ionescu/prezto/issues +[1]: https://github.com/sorin-ionescu/prezto/blob/master/runcoms/zshenv +[2]: https://github.com/sorin-ionescu/prezto/issues diff --git a/.zprezto/modules/environment/init.zsh b/.zprezto/modules/environment/init.zsh index 76655a6..4f3bbfe 100644 --- a/.zprezto/modules/environment/init.zsh +++ b/.zprezto/modules/environment/init.zsh @@ -9,18 +9,34 @@ # Smart URLs # -autoload -Uz url-quote-magic -zle -N self-insert url-quote-magic +# This logic comes from an old version of zim. Essentially, bracketed-paste was +# added as a requirement of url-quote-magic in 5.1, but in 5.1.1 bracketed +# paste had a regression. Additionally, 5.2 added bracketed-paste-url-magic +# which is generally better than url-quote-magic so we load that when possible. +autoload -Uz is-at-least +if [[ ${ZSH_VERSION} != 5.1.1 ]]; then + if is-at-least 5.2; then + autoload -Uz bracketed-paste-url-magic + zle -N bracketed-paste bracketed-paste-url-magic + else + if is-at-least 5.1; then + autoload -Uz bracketed-paste-magic + zle -N bracketed-paste bracketed-paste-magic + fi + fi + autoload -Uz url-quote-magic + zle -N self-insert url-quote-magic +fi # # General # -setopt BRACE_CCL # Allow brace character class list expansion. -setopt COMBINING_CHARS # Combine zero-length punctuation characters (accents) - # with the base character. -setopt RC_QUOTES # Allow 'Henry''s Garage' instead of 'Henry'\''s Garage'. -unsetopt MAIL_WARNING # Don't print a warning message if a mail file has been accessed. +setopt COMBINING_CHARS # Combine zero-length punctuation characters (accents) + # with the base character. +setopt INTERACTIVE_COMMENTS # Enable comments in interactive shell. +setopt RC_QUOTES # Allow 'Henry''s Garage' instead of 'Henry'\''s Garage'. +unsetopt MAIL_WARNING # Don't print a warning message if a mail file has been accessed. # # Jobs diff --git a/.zprezto/modules/fasd/README.md b/.zprezto/modules/fasd/README.md index 7d22626..cb3fc20 100644 --- a/.zprezto/modules/fasd/README.md +++ b/.zprezto/modules/fasd/README.md @@ -12,6 +12,12 @@ module. The Prezto Fasd configuration differs from the default. The default aliases have been disabled. +Installation +------------ + +`fasd` is bundled with prezto as a git submodule. Alternatively, you can manually install `fasd`. +If a manual install is found, it will be used instead of the bundled version. + Aliases ------- diff --git a/.zprezto/modules/fasd/external/.git_backup b/.zprezto/modules/fasd/external/.git_backup new file mode 100644 index 0000000..930375b --- /dev/null +++ b/.zprezto/modules/fasd/external/.git_backup @@ -0,0 +1 @@ +gitdir: ../../../.git/modules/modules/fasd/external diff --git a/.zprezto/modules/fasd/external/INSTALL.md b/.zprezto/modules/fasd/external/INSTALL.md new file mode 100644 index 0000000..e253399 --- /dev/null +++ b/.zprezto/modules/fasd/external/INSTALL.md @@ -0,0 +1,72 @@ +Fasd is a self-contained posix shell script that can be either sourced or +executed. A Makefile is provided to install `fasd` and `fasd.1` to desired +places. + + +System-wide install: + + make install + +Install to $HOME: + + PREFIX=$HOME make install + +Or alternatively you can just copy `fasd` to anywhere you like. + +To get fasd working in a shell, some initialization code must be run. Put the +line below in your shell rc. + + eval "$(fasd --init auto)" + +This will setup a command hook that executes on every command and advanced tab +completion for zsh and bash. + +If you want more control over what gets into your shell environment, you can +pass customized set of arguments to `fasd --init`. + + zsh-hook # define _fasd_preexec and add it to zsh preexec array + zsh-ccomp # zsh command mode completion definitions + zsh-ccomp-install # setup command mode completion for zsh + zsh-wcomp # zsh word mode completion definitions + zsh-wcomp-install # setup word mode completion for zsh + bash-hook # add hook code to bash $PROMPT_COMMAND + bash-ccomp # bash command mode completion definitions + bash-ccomp-install # setup command mode completion for bash + posix-alias # define alias that applies to all posix shells + posix-hook # setup $PS1 hook for shells that's posix compatible + tcsh-alias # define aliases for tcsh + tcsh-hook # setup tcsh precmd alias + +Example for a minimal zsh setup (no tab completion): + + eval "$(fasd --init posix-alias zsh-hook)" + +Note that this method will slightly increase your shell start-up time, since +calling binaries has overhead. You can cache fasd init code if you want minimal +overhead. Example code for bash (to be put into .bashrc): + + fasd_cache="$HOME/.fasd-init-bash" + if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then + fasd --init posix-alias bash-hook bash-ccomp bash-ccomp-install >| "$fasd_cache" + fi + source "$fasd_cache" + unset fasd_cache + +Optionally, if you can also source `fasd` if you want `fasd` to be a shell +function instead of an executable. + +You can tweak initialization code. For instance, if you want to use "c" +instead of "z" to do directory jumping. You run the code below: + + # function to execute built-in cd + fasd_cd() { + if [ $# -le 1 ]; then + fasd "$@" + else + local _fasd_ret="$(fasd -e echo "$@")" + [ -z "$_fasd_ret" ] && return + [ -d "$_fasd_ret" ] && cd "$_fasd_ret" || echo "$_fasd_ret" + fi + } + alias c='fasd_cd -d' # `-d' option present for bash completion + diff --git a/.zprezto/modules/fasd/external/LICENSE b/.zprezto/modules/fasd/external/LICENSE new file mode 100644 index 0000000..81af5a7 --- /dev/null +++ b/.zprezto/modules/fasd/external/LICENSE @@ -0,0 +1,20 @@ +Copyright (C) 2011, 2012 by Wei Dai. All rights reserved. + +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/.zprezto/modules/fasd/external/Makefile b/.zprezto/modules/fasd/external/Makefile new file mode 100644 index 0000000..138d7c2 --- /dev/null +++ b/.zprezto/modules/fasd/external/Makefile @@ -0,0 +1,27 @@ +PREFIX?= /usr/local +BINDIR?= ${PREFIX}/bin +MANDIR?= ${PREFIX}/share/man +INSTALL?= install +INSTALLDIR= ${INSTALL} -d +INSTALLBIN= ${INSTALL} -m 755 +INSTALLMAN= ${INSTALL} -m 644 + +all: fasd.1 + +uninstall: + rm -f ${DESTDIR}${BINDIR}/fasd + rm -f ${DESTDIR}${MANDIR}/man1/fasd.1 + +install: + ${INSTALLDIR} ${DESTDIR}${BINDIR} + ${INSTALLBIN} fasd ${DESTDIR}${BINDIR} + ${INSTALLDIR} ${DESTDIR}${MANDIR}/man1 + ${INSTALLMAN} fasd.1 ${DESTDIR}${MANDIR}/man1 + +man: fasd.1 + +fasd.1: fasd.1.md + pandoc -s -w man fasd.1.md -o fasd.1 + +.PHONY: all install uninstall man + diff --git a/.zprezto/modules/fasd/external/README.md b/.zprezto/modules/fasd/external/README.md new file mode 100644 index 0000000..475e23e --- /dev/null +++ b/.zprezto/modules/fasd/external/README.md @@ -0,0 +1,378 @@ +# Fasd + +Fasd (pronounced similar to "fast") is a command-line productivity booster. +Fasd offers quick access to files and directories for POSIX shells. It is +inspired by tools like [autojump](https://github.com/joelthelion/autojump), +[z](http://github.com/rupa/z) and [v](https://github.com/rupa/v). Fasd keeps +track of files and directories you have accessed, so that you can quickly +reference them in the command line. + +The name fasd comes from the default suggested aliases `f`(files), +`a`(files/directories), `s`(show/search/select), `d`(directories). + +Fasd ranks files and directories by "frecency," that is, by both "frequency" and +"recency." The term "frecency" was first coined by Mozilla and used in Firefox +([link](https://developer.mozilla.org/en/The_Places_frecency_algorithm)). + +# Introduction + +If you use your shell to navigate and launch applications, fasd can help you do +it more efficiently. With fasd, you can open files regardless of which +directory you are in. Just with a few key strings, fasd can find a "frecent" +file or directory and open it with command you specify. Below are some +hypothetical situations, where you can type in the command on the left and fasd +will "expand" your command into the right side. Pretty magic, huh? + +``` + v def conf => vim /some/awkward/path/to/type/default.conf + j abc => cd /hell/of/a/awkward/path/to/get/to/abcdef + m movie => mplayer /whatever/whatever/whatever/awesome_movie.mp4 + o eng paper => xdg-open /you/dont/remember/where/english_paper.pdf + vim `f rc lo` => vim /etc/rc.local + vim `f rc conf` => vim /etc/rc.conf +``` + +Fasd comes with some useful aliases by default: + +```sh +alias a='fasd -a' # any +alias s='fasd -si' # show / search / select +alias d='fasd -d' # directory +alias f='fasd -f' # file +alias sd='fasd -sid' # interactive directory selection +alias sf='fasd -sif' # interactive file selection +alias z='fasd_cd -d' # cd, same functionality as j in autojump +alias zz='fasd_cd -d -i' # cd with interactive selection +``` + +Fasd will smartly detect when to display a list of files or just the best +match. For instance, when you call fasd in a subshell with some search +parameters, fasd will only return the best match. This enables you to do: + +```sh +mv update.html `d www` +cp `f mov` . +``` + +# Install + +Fasd is available in various package managers. Please check +[the wiki page](https://github.com/clvv/fasd/wiki/Installing-via-Package-Managers) +for an up-to-date list. + +You can also manually obtain a copy of fasd. + +Download fasd 1.0.1 from GitHub: +[zip](https://github.com/clvv/fasd/zipball/1.0.1), +[tar.gz](https://github.com/clvv/fasd/tarball/1.0.1). + +Fasd is a self-contained POSIX shell script that can be either sourced or +executed. A Makefile is provided to install `fasd` and `fasd.1` to desired +places. + +System-wide install: + + make install + +Install to $HOME: + + PREFIX=$HOME make install + +Or alternatively you can just copy `fasd` to anywhere you like (preferably +under some directory in `$PATH`). + +To get fasd working in a shell, some initialization code must be run. Put the +line below in your shell rc. + +```sh +eval "$(fasd --init auto)" +``` + +This will setup a command hook that executes on every command and advanced tab +completion for zsh and bash. + +If you want more control over what gets into your shell environment, you can +pass customized set of arguments to `fasd --init`. + +``` +zsh-hook # define _fasd_preexec and add it to zsh preexec array +zsh-ccomp # zsh command mode completion definitions +zsh-ccomp-install # setup command mode completion for zsh +zsh-wcomp # zsh word mode completion definitions +zsh-wcomp-install # setup word mode completion for zsh +bash-hook # add hook code to bash $PROMPT_COMMAND +bash-ccomp # bash command mode completion definitions +bash-ccomp-install # setup command mode completion for bash +posix-alias # define aliases that applies to all posix shells +posix-hook # setup $PS1 hook for shells that's posix compatible +tcsh-alias # define aliases for tcsh +tcsh-hook # setup tcsh precmd alias +``` + +Example for a minimal zsh setup (no tab completion): + +```sh +eval "$(fasd --init posix-alias zsh-hook)" +``` + +Note that this method will slightly increase your shell start-up time, since +calling binaries has overhead. You can cache fasd init code if you want minimal +overhead. Example code for bash (to be put into .bashrc): + +```sh +fasd_cache="$HOME/.fasd-init-bash" +if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then + fasd --init posix-alias bash-hook bash-ccomp bash-ccomp-install >| "$fasd_cache" +fi +source "$fasd_cache" +unset fasd_cache +``` + +Optionally, if you can also source `fasd` if you want `fasd` to be a shell +function instead of an executable. + +You can tweak initialization code. For instance, if you want to use "c" +instead of "z" to do directory jumping, you can use the alias below: + +```sh +alias c='fasd_cd -d' +# `-d` option present for bash completion +# function fasd_cd is defined in posix-alias +``` + +After you first installed fasd, open some files (with any program) or `cd` +around in your shell. Then try some examples below. + +# Examples + +```sh +f foo # list frecent files matching foo +a foo bar # list frecent files and directories matching foo and bar +f js$ # list frecent files that ends in js +f -e vim foo # run vim on the most frecent file matching foo +mplayer `f bar` # run mplayer on the most frecent file matching bar +z foo # cd into the most frecent directory matching foo +open `sf pdf` # interactively select a file matching pdf and launch `open` +``` + +You should add your own aliases to fully utilize the power of fasd. Here are +some examples to get you started: + +```sh +alias v='f -e vim' # quick opening files with vim +alias m='f -e mplayer' # quick opening files with mplayer +alias o='a -e xdg-open' # quick opening files with xdg-open +``` + +If you're using bash, you have to call `_fasd_bash_hook_cmd_complete` to make +completion work. For instance: + + _fasd_bash_hook_cmd_complete v m j o + +You could select an entry in the list of matching files. + +# Matching + +Fasd has three matching modes: default, case-insensitive, and fuzzy. + +For a given set of queries (the set of command-line arguments passed to fasd), +a path is a match if and only if: + +1. Queries match the path *in order*. +2. The last query matches the *last segment* of the path. + +If no match is found, fasd will try the same process ignoring case. If still no +match is found, fasd will allow extra characters to be placed between query +characters for fuzzy matching. + +Tips: + +* If you want your last query not to match the last segment of the path, append + `/` as the last query. +* If you want your last query to match the end of the filename, append `$` to + the last query. + +# How It Works + +When you run fasd init code or source `fasd`, fasd adds a hook which will be +executed whenever you execute a command. The hook will scan your commands' +arguments and determine if any of them refer to existing files or directories. +If yes, fasd will add them to the database. + +# Compatibility + +Fasd's basic functionalities are POSIX compliant, meaning that you should be +able to use fasd in all POSIX compliant shells. Your shell need to support +command substitution in `$PS1` in order for fasd to automatically track your +commands and files. This feature is not specified by the POSIX standard, but +it's nonetheless present in many POSIX compliant shells. In shells without +prompt command or prompt command substitution (csh for instance), you can add +entries manually with `fasd -A`. You are very welcomed to contribute shell +initialization code for not yet supported shells. + +Fasd has been tested on the following shells: bash, zsh, mksh, pdksh, dash, +busybox ash, FreeBSD 9 /bin/sh and OpenBSD /bin/sh. + +# Synopsis + + fasd [options] [query ...] + [f|a|s|d|z] [options] [query ...] + options: + -s list paths with scores + -l list paths without scores + -i interactive mode + -e set command to execute on the result file + -b only use backend + -B add additional backend + -a match files and directories + -d match directories only + -f match files only + -r match by rank only + -t match by recent access only + -R reverse listing order + -h show a brief help message + -[0-9] select the nth entry + + fasd [-A|-D] [paths ...] + -A add paths + -D delete paths + +# Tab Completion + +Fasd offers two completion modes, command mode completion and word mode +completion. Command mode completion works in bash and zsh. Word mode +completion only works in zsh. + +Command mode completion is just like completion for any other commands. It is +triggered when you hit tab on a `fasd` command or its aliases. Under this mode +your queries can be separated by a space. Tip: if you find that the completion +result overwrites your queries, type an extra space before you hit tab. + +Word mode completion can be triggered on *any* command. Word completion is +triggered by any command line argument that starts with `,` (all), `f,` +(files), or `d,` (directories), or that ends with `,,` (all), `,,f` (files), or +`,,d` (directories). Examples: + + $ vim ,rc,lo + $ vim /etc/rc.local + + $ mv index.html d,www + $ mv index.html /var/www/ + +There are also three zle widgets: `fasd-complete`, `fasd-complete-f`, +`fasd-complete-d`. You can bind them to keybindings you like: + +```sh +bindkey '^X^A' fasd-complete # C-x C-a to do fasd-complete (files and directories) +bindkey '^X^F' fasd-complete-f # C-x C-f to do fasd-complete-f (only files) +bindkey '^X^D' fasd-complete-d # C-x C-d to do fasd-complete-d (only directories) +``` + +# Backends + +Fasd can take advantage of different sources of recent / frequent files. Most +desktop environments (such as OS X and Gtk) and some editors (such as Vim) keep +a list of accessed files. Fasd can use them as additional backends if the data +can be converted into fasd's native format. Below is a list of available +backends. + +``` +`spotlight` +OSX spotlight, provides entries that are changed today or opened within the +past month + +`recently-used` +GTK's recently-used file (Usually available on Linux) + +`current` +Provides everything in $PWD (whereever you are executing `fasd`) + +`viminfo` +Vim's editing history, useful if you want to define an alias just for editing +things in vim +``` + +You can define your own backend by declaring a function by that name in your +`.fasdrc`. You can set default backend with `_FASD_BACKENDS` variable in our +`.fasdrc`. + +Fasd can mimic [v](http://github.com/rupa/v)'s behavior by this alias: + +```sh +alias v='f -t -e vim -b viminfo' +``` + +# Tweaks + +Some shell variables that you can set before sourcing `fasd`. You can set them +in `$HOME/.fasdrc` + +``` +$_FASD_DATA +Path to the fasd data file, default "$HOME/.fasd". + +$_FASD_BLACKLIST +List of blacklisted strings. Commands matching them will not be processed. +Default is "--help". + +$_FASD_SHIFT +List of all commands that needs to be shifted, defaults to "sudo busybox". + +$_FASD_IGNORE +List of all commands that will be ignored, defaults to "fasd ls echo". + +$_FASD_TRACK_PWD +Fasd defaults to track your "$PWD". Set this to 0 to disable this behavior. + +$_FASD_AWK +Which awk to use. Fasd can detect and use a compatible awk. + +$_FASD_SINK +File to log all STDERR to, defaults to "/dev/null". + +$_FASD_MAX +Max total score / weight, defaults to 2000. + +$_FASD_SHELL +Which shell to execute. Some shells will run faster than others. fasd +runs faster with dash and ksh variants. + +$_FASD_BACKENDS +Default backends. + +$_FASD_RO +If set to any non-empty string, fasd will not add or delete entries from +database. You can set and export this variable from command line. + +$_FASD_FUZZY +Level of "fuzziness" when doing fuzzy matching. More precisely, the number of +characters that can be skipped to generate a match. Set to empty or 0 to +disable fuzzy matching. Default value is 2. + +$_FASD_VIMINFO +Path to .viminfo file for viminfo backend, defaults to "$HOME/.viminfo" + +$_FASD_RECENTLY_USED_XBEL +Path to XDG recently-used.xbel file for recently-used backend, defaults to +"$HOME/.local/share/recently-used.xbel" + +``` + +# Debugging + +If fasd does not work as expected, please file a bug report describing the +unexpected behavior along with your OS version, shell version, awk version, sed +version, and a log file. + +You can set `_FASD_SINK` in your `.fasdrc` to obtain a log. + +```sh +_FASD_SINK="$HOME/.fasd.log" +``` + +# COPYING + +Fasd is originally written based on code from [z](https://github.com/rupa/z) by +rupa deadwyler under the WTFPL license. Most if not all of the code has been +rewritten. Fasd is licensed under the "MIT/X11" license. + diff --git a/.zprezto/modules/fasd/external/fasd b/.zprezto/modules/fasd/external/fasd new file mode 100755 index 0000000..4275b7e --- /dev/null +++ b/.zprezto/modules/fasd/external/fasd @@ -0,0 +1,636 @@ +#!/usr/bin/env sh + +# Fasd (this file) can be sourced or executed by any POSIX compatible shell. + +# Fasd is originally written based on code from z (https://github.com/rupa/z) +# by rupa deadwyler under the WTFPL license. Most if not all of the code has +# been rewritten. + +# Copyright (C) 2011, 2012 by Wei Dai. All rights reserved. +# +# 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. + +fasd() { + + # make zsh do word splitting inside this function + [ "$ZSH_VERSION" ] && emulate sh && setopt localoptions + + case $1 in + --init) shift + while [ "$1" ]; do + case $1 in + env) + { # source rc files if present + [ -s "/etc/fasdrc" ] && . "/etc/fasdrc" + [ -s "$HOME/.fasdrc" ] && . "$HOME/.fasdrc" + + # set default options + [ -z "$_FASD_DATA" ] && _FASD_DATA="$HOME/.fasd" + [ -z "$_FASD_BLACKLIST" ] && _FASD_BLACKLIST="--help" + [ -z "$_FASD_SHIFT" ] && _FASD_SHIFT="sudo busybox" + [ -z "$_FASD_IGNORE" ] && _FASD_IGNORE="fasd ls echo" + [ -z "$_FASD_SINK" ] && _FASD_SINK=/dev/null + [ -z "$_FASD_TRACK_PWD" ] && _FASD_TRACK_PWD=1 + [ -z "$_FASD_MAX" ] && _FASD_MAX=2000 + [ -z "$_FASD_BACKENDS" ] && _FASD_BACKENDS=native + [ -z "$_FASD_FUZZY" ] && _FASD_FUZZY=2 + [ -z "$_FASD_VIMINFO" ] && _FASD_VIMINFO="$HOME/.viminfo" + [ -z "$_FASD_RECENTLY_USED_XBEL" ] && \ + _FASD_RECENTLY_USED_XBEL="$HOME/.local/share/recently-used.xbel" + + if [ -z "$_FASD_AWK" ]; then + # awk preferences + local awk; for awk in mawk gawk original-awk nawk awk; do + $awk "" && _FASD_AWK=$awk && break + done + fi + } >> "${_FASD_SINK:-/dev/null}" 2>&1 + ;; + + auto) cat <> "$_FASD_SINK" 2>&1 + +EOS + ;; + + posix-alias) cat <& /dev/null || fasd -d'; +EOS + ;; + + zsh-hook) cat <> "$_FASD_SINK" 2>&1 +} +autoload -Uz add-zsh-hook +add-zsh-hook preexec _fasd_preexec + +EOS + ;; + + bash-hook) cat <> "$_FASD_SINK" 2>&1 +} + +# add bash hook +case \$PROMPT_COMMAND in + *_fasd_prompt_func*) ;; + *) PROMPT_COMMAND="_fasd_prompt_func;\$PROMPT_COMMAND";; +esac + +EOS + ;; + + posix-hook) cat <> "$_FASD_SINK" 2>&1 +} +case \$PS1 in + *_fasd_ps1_func*) ;; + *) export PS1="\\\$(_fasd_ps1_func)\$PS1";; +esac + +EOS + ;; + + tcsh-hook) cat <& /dev/null'; +EOS + + ;; + + zsh-ccomp) cat <> "$_FASD_SINK" | \\ + sort -nr | sed 's/^[^ ]*[ ]*//' | while read -r line; do + compadd -U -V fasd "\$line" + done + compstate[insert]=menu # no expand + } + _fasd_zsh_word_complete_f() { _fasd_zsh_word_complete f ; } + _fasd_zsh_word_complete_d() { _fasd_zsh_word_complete d ; } + _fasd_zsh_word_complete_trigger() { + local _fasd_cur="\${words[CURRENT]}" + eval \$(fasd --word-complete-trigger _fasd_zsh_word_complete \$_fasd_cur) + } + # define zle widgets + zle -C fasd-complete complete-word _generic + zstyle ':completion:fasd-complete:*' completer _fasd_zsh_word_complete + zstyle ':completion:fasd-complete:*' menu-select + + zle -C fasd-complete-f complete-word _generic + zstyle ':completion:fasd-complete-f:*' completer _fasd_zsh_word_complete_f + zstyle ':completion:fasd-complete-f:*' menu-select + + zle -C fasd-complete-d complete-word _generic + zstyle ':completion:fasd-complete-d:*' completer _fasd_zsh_word_complete_d + zstyle ':completion:fasd-complete-d:*' menu-select +} + +EOS + ;; + + zsh-ccomp-install) cat <> "$_FASD_SINK" | sed -n "\\\$s/^.*'\\\\(.*\\\\)'/\\\\1/p") + \${COMP_LINE#* }" | while read -r line; do + quote_readline "\$line" 2>/dev/null || \\ + printf %q "\$line" 2>/dev/null && \\ + printf \\\\n + done) + local IFS=\$'\\n'; COMPREPLY=( \$RESULT ) +} +_fasd_bash_hook_cmd_complete() { + for cmd in \$*; do + complete -F _fasd_bash_cmd_complete \$cmd + done +} + +EOS + ;; + + bash-ccomp-install) cat <$`{}]\{1,\}/\1 /g' + ;; + + --proc) shift # process commands + # stop if we don't own $_FASD_DATA or $_FASD_RO is set + [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return + + # blacklists + local each; for each in $_FASD_BLACKLIST; do + case " $* " in *\ $each\ *) return;; esac + done + + # shifts + while true; do + case " $_FASD_SHIFT " in + *\ $1\ *) shift;; + *) break;; + esac + done + + # ignores + case " $_FASD_IGNORE " in + *\ $1\ *) return;; + esac + + shift; fasd --add "$@" # add all arguments except command + ;; + + --add|-A) shift # add entries + # stop if we don't own $_FASD_DATA or $_FASD_RO is set + [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return + + # find all valid path arguments, convert them to simplest absolute form + local paths="$(while [ "$1" ]; do + [ -e "$1" ] && printf %s\\n "$1"; shift + done | sed '/^[^/]/s@^@'"$PWD"'/@ + s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0 + s@[^/][^/]*//*\.\./@/@;t 0 + s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@;s@^$@/@' 2>> "$_FASD_SINK" \ + | tr '\n' '|')" + + # add current pwd if the option is set + [ "$_FASD_TRACK_PWD" = "1" -a "$PWD" != "$HOME" ] && paths="$paths|$PWD" + + [ -z "${paths##\|}" ] && return # stop if we have nothing to add + + # maintain the file + local tempfile + tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return + $_FASD_AWK -v list="$paths" -v now="$(date +%s)" -v max="$_FASD_MAX" -F"|" ' + BEGIN { + split(list, files, "|") + for(i in files) { + path = files[i] + if(path == "") continue + paths[path] = path # array for checking + rank[path] = 1 + time[path] = now + } + } + $2 >= 1 { + if($1 in paths) { + rank[$1] = $2 + 1 / $2 + time[$1] = now + } else { + rank[$1] = $2 + time[$1] = $3 + } + count += $2 + } + END { + if(count > max) + for(i in rank) print i "|" 0.9*rank[i] "|" time[i] # aging + else + for(i in rank) print i "|" rank[i] "|" time[i] + }' "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile" + if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then + env rm -f "$tempfile" + else + env mv -f "$tempfile" "$_FASD_DATA" + fi + ;; + + --delete|-D) shift # delete entries + # stop if we don't own $_FASD_DATA or $_FASD_RO is set + [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return + + # turn valid arguments into entry-deleting sed commands + local sed_cmd="$(while [ "$1" ]; do printf %s\\n "$1"; shift; done | \ + sed '/^[^/]/s@^@'"$PWD"'/@;s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0 + s@[^/][^/]*//*\.\./@/@;t 0 + s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@ + s@^$@/@;s@\([.[\/*^$]\)@\\\1@g;s@^\(.*\)$@/^\1|/d@' 2>> "$_FASD_SINK")" + + # maintain the file + local tempfile + tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return + + sed "$sed_cmd" "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile" + + if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then + env rm -f "$tempfile" + else + env mv -f "$tempfile" "$_FASD_DATA" + fi + ;; + + --query) shift # query the db, --query [$typ ["$fnd" [$mode]]] + [ -f "$_FASD_DATA" ] || return # no db yet + [ "$1" ] && local typ="$1" + [ "$2" ] && local fnd="$2" + [ "$3" ] && local mode="$3" + + # cat all backends + local each _fasd_data; for each in $_FASD_BACKENDS; do + _fasd_data="$_fasd_data +$(fasd --backend $each)" + done + [ "$_fasd_data" ] || _fasd_data="$(cat "$_FASD_DATA")" + + # set mode specific code for calculating the prior + case $mode in + rank) local prior='times[i]';; + recent) local prior='sqrt(100000/(1+t-la[i]))';; + *) local prior='times[i] * frecent(la[i])';; + esac + + if [ "$fnd" ]; then # dafault matching + local bre="$(printf %s\\n "$fnd" | sed 's/\([*\.\\\[]\)/\\\1/g + s@ @[^|]*@g;s/\$$/|/')" + bre='^[^|]*'"$bre"'[^|/]*|' + local _ret="$(printf %s\\n "$_fasd_data" | grep "$bre")" + [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + if [ "$_ret" ]; then + _fasd_data="$_ret" + else # no case mathcing + _ret="$(printf %s\\n "$_fasd_data" | grep -i "$bre")" + [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + if [ "$_ret" ]; then + _fasd_data="$_ret" + elif [ "${_FASD_FUZZY:-0}" -gt 0 ]; then # fuzzy matching + local fuzzy_bre="$(printf %s\\n "$fnd" | \ + sed 's/\([*\.\\\[]\)/\\\1/g;s/\$$/|/ + s@\(\\\{0,1\}[^ ]\)@\1[^|/]\\{0,'"$_FASD_FUZZY"'\\}@g + s@ @[^|]*@g')" + fuzzy_bre='^[^|]*'"$fuzzy_bre"'[^|/]*|' + _ret="$(printf %s\\n "$_fasd_data" | grep -i "$fuzzy_bre")" + [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + [ "$_ret" ] && _fasd_data="$_ret" || _fasd_data= + fi + fi + else # no query arugments + _fasd_data="$(printf %s\\n "$_fasd_data" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + fi + + # query the database + [ "$_fasd_data" ] && printf %s\\n "$_fasd_data" | \ + $_FASD_AWK -v t="$(date +%s)" -F"|" ' + function frecent(time) { + dx = t-time + if( dx < 3600 ) return 6 + if( dx < 86400 ) return 4 + if( dx < 604800 ) return 2 + return 1 + } + { + if(!paths[$1]) { + times[$1] = $2 + la[$1] = $3 + paths[$1] = 1 + } else { + times[$1] += $2 + if($3 > la[$1]) la[$1] = $3 + } + } + END { + for(i in paths) printf "%-10s %s\n", '"$prior"', i + }' - 2>> "$_FASD_SINK" + ;; + + --backend) + case $2 in + native) cat "$_FASD_DATA";; + viminfo) + < "$_FASD_VIMINFO" sed -n '/^>/{s@~@'"$HOME"'@ + s/^..// + p + }' | $_FASD_AWK -v t="$(date +%s)" '{ + t -= 60 + print $0 "|1|" t + }' + ;; + recently-used) + local nl="$(printf '\\\nX')"; nl="${nl%X}" # slash newline for sed + tr -d '\n' < "$_FASD_RECENTLY_USED_XBEL" | \ + sed 's@file:/@'"$nl"'@g;s@count="@'"$nl"'@g' | sed '1d;s/".*$//' | \ + tr '\n' '|' | sed 's@|/@'"$nl"'@g' | $_FASD_AWK -F'|' '{ + sum = 0 + for( i=2; i<=NF; i++ ) sum += $i + print $1 "|" sum + }' + ;; + current) + for path in *; do + printf "$PWD/%s|1\\n" "$path" + done + ;; + spotlight) + mdfind '(kMDItemFSContentChangeDate >= $time.today) || + kMDItemLastUsedDate >= $time.this_month' \ + | sed '/Library\//d + /\.app$/d + s/$/|2/' + ;; + *) eval "$2";; + esac + ;; + + *) # parsing logic and processing + local fnd= last= _FASD_BACKENDS="$_FASD_BACKENDS" _fasd_data= comp= exec= + while [ "$1" ]; do case $1 in + --complete) [ "$2" = "--" ] && shift; set -- $2; local lst=1 r=r comp=1;; + --query|--add|--delete|-A|-D) fasd "$@"; return $?;; + --version) [ -z "$comp" ] && echo "1.0.1" && return;; + --) while [ "$2" ]; do shift; fnd="$fnd $1"; last="$1"; done;; + -*) local o="${1#-}"; while [ "$o" ]; do case $o in + s*) local show=1;; + l*) local lst=1;; + i*) [ -z "$comp" ] && local interactive=1 show=1;; + r*) local mode=rank;; + t*) local mode=recent;; + e*) o="${o#?}"; if [ "$o" ]; then # there are characters after "-e" + local exec="$o" # anything after "-e" + else # use the next argument + local exec="${2:?"-e: Argument needed "}" + shift + fi; break;; + b*) o="${o#?}"; if [ "$o" ]; then + _FASD_BACKENDS="$o" + else + _FASD_BACKENDS="${2:?"-b: Argument needed"}" + shift + fi; break;; + B*) o="${o#?}"; if [ "$o" ]; then + _FASD_BACKENDS="$_FASD_BACKENDS $o" + else + _FASD_BACKENDS="$_FASD_BACKENDS ${2:?"-B: Argument needed"}" + shift + fi; break;; + a*) local typ=e;; + d*) local typ=d;; + f*) local typ=f;; + R*) local r=r;; + [0-9]*) local _fasd_i="$o"; break;; + h*) [ -z "$comp" ] && echo "fasd [options] [query ...] +[f|a|s|d|z] [options] [query ...] + options: + -s list paths with scores + -l list paths without scores + -i interactive mode + -e set command to execute on the result file + -b only use backend + -B add additional backend + -a match files and directories + -d match directories only + -f match files only + -r match by rank only + -t match by recent access only + -R reverse listing order + -h show a brief help message + -[0-9] select the nth entry + +fasd [-A|-D] [paths ...] + -A add paths + -D delete paths" >&2 && return;; + esac; o="${o#?}"; done;; + *) fnd="$fnd $1"; last="$1";; + esac; shift; done + + # guess whether the last query is selected from tab completion + case $last in + /?*) if [ -z "$show$lst" -a -${typ:-e} "$last" -a "$exec" ]; then + $exec "$last" + return + fi;; + esac + + local R; [ -z "$r" ] && R=r || R= # let $R be the opposite of $r + fnd="${fnd# }" + + local res + res="$(fasd --query 2>> "$_FASD_SINK")" # query the database + [ $? -gt 0 ] && return + if [ 0 -lt ${_fasd_i:-0} ] 2>> "$_FASD_SINK"; then + res="$(printf %s\\n "$res" | sort -n${R} | \ + sed -n "$_fasd_i"'s/^[^ ]*[ ]*//p')" + elif [ "$interactive" ] || [ "$exec" -a -z "$fnd$lst$show" -a -t 1 ]; then + if [ "$(printf %s "$res" | sed -n '$=')" -gt 1 ]; then + res="$(printf %s\\n "$res" | sort -n${R})" + printf %s\\n "$res" | sed = | sed 'N;s/\n/ /' | sort -nr >&2 + printf "> " >&2 + local i; read i; [ 0 -lt "${i:-0}" ] 2>> "$_FASD_SINK" || return 1 + fi + res="$(printf %s\\n "$res" | sed -n "${i:-1}"'s/^[^ ]*[ ]*//p')" + elif [ "$lst" ]; then + [ "$res" ] && printf %s\\n "$res" | sort -n${r} | sed 's/^[^ ]*[ ]*//' + return + elif [ "$show" ]; then + [ "$res" ] && printf %s\\n "$res" | sort -n${r} + return + elif [ "$fnd" ] && [ "$exec" -o ! -t 1 ]; then # exec or subshell + res="$(printf %s\\n "$res" | sort -n | sed -n '$s/^[^ ]*[ ]*//p')" + else # no args, show + [ "$res" ] && printf %s\\n "$res" | sort -n${r} + return + fi + if [ "$res" ]; then + fasd --add "$res" + [ -z "$exec" ] && exec='printf %s\n' + $exec "$res" + fi + ;; + esac +} + +fasd --init env + +case $- in + *i*) ;; # assume being sourced, do nothing + *) # assume being executed as an executable + if [ -x "$_FASD_SHELL" -a -z "$_FASD_SET" ]; then + _FASD_SET=1 exec $_FASD_SHELL "$0" "$@" + else + fasd "$@" + fi;; +esac + diff --git a/.zprezto/modules/fasd/external/fasd.1 b/.zprezto/modules/fasd/external/fasd.1 new file mode 100644 index 0000000..02b8c18 --- /dev/null +++ b/.zprezto/modules/fasd/external/fasd.1 @@ -0,0 +1,313 @@ +.TH "FASD" "1" "Jul 16, 2012" "fasd user manual" "" +.SH NAME +.PP +fasd \- quick access to files and directories +.SH SYNOPSIS +.PP +fasd [options] [query ...] +.PP +[f|a|s|d|z] [options] [query ...] +.PP +fasd [\-A|\-D] [paths ...] +.SH OPTIONS +.IP +.nf +\f[C] +\-s\ \ \ \ \ \ \ \ \ list\ paths\ with\ ranks +\-l\ \ \ \ \ \ \ \ \ list\ paths\ without\ ranks +\-i\ \ \ \ \ \ \ \ \ interactive\ mode +\-e\ \ \ \ set\ command\ to\ execute\ on\ the\ result\ file +\-b\ \ \ only\ use\ \ backend +\-B\ \ \ add\ additional\ backend\ +\-a\ \ \ \ \ \ \ \ \ match\ files\ and\ directories +\-d\ \ \ \ \ \ \ \ \ match\ directories\ only +\-f\ \ \ \ \ \ \ \ \ match\ files\ only +\-r\ \ \ \ \ \ \ \ \ match\ by\ rank\ only +\-t\ \ \ \ \ \ \ \ \ match\ by\ recent\ access\ only +\-R\ \ \ \ \ \ \ \ \ reverse\ listing\ order +\-h\ \ \ \ \ \ \ \ \ show\ a\ brief\ help\ message +\-[0\-9]\ \ \ \ \ select\ the\ nth\ entry +\f[] +.fi +.SH DESCRIPTION +.PP +Fasd keeps track of files and directories you access in your shell and +gives you quick access to them. +You can use fasd to reference files or directories by just a few key +identifying characters. +You can use fasd to boost your command line productivity by defining +your own aliases to launch programs on files or directories. +Fasd, by default, provides some basic aliases, including a shell +function "z" that resembles the functionality of "z" and "autojump." +.PP +The name "fasd" comes from the default suggested aliases +\f[C]f\f[](files), \f[C]a\f[](files/directories), +\f[C]s\f[](show/search/select), \f[C]d\f[](directories). +.PP +Fasd ranks files and directories by "frecency," that is, by both +"frequency" and "recency." The term "frecency" was first coined by +Mozilla and used in Firefox. +.SH EXAMPLES +.IP +.nf +\f[C] +z\ bundle +f\ \-e\ vim\ nginx\ conf +f\ \-i\ rc$ +vi\ `f\ nginx\ conf` +cp\ update.html\ `d\ www` +open\ `sf\ pdf` +\f[] +.fi +.SH SHELL INITIALIZATION +.PP +To get fasd working in a shell, some initialization code must be run. +Put lines below in your POSIX compatible shell rc. +.IP +.nf +\f[C] +eval\ "$(fasd\ \-\-init\ auto)" +\f[] +.fi +.PP +This will setup a command hook that executes on every command and +advanced tab completion for zsh and bash. +.PP +If you want more control over what gets into your shell environment, you +can pass customized set of arguments to \f[C]fasd\ \-\-init\f[]. +.IP +.nf +\f[C] +zsh\-hook\ \ \ \ \ \ \ \ \ \ \ \ \ #\ define\ _fasd_preexec\ and\ add\ it\ to\ zsh\ preexec\ array +zsh\-ccomp\ \ \ \ \ \ \ \ \ \ \ \ #\ zsh\ command\ mode\ completion\ definitions +zsh\-ccomp\-install\ \ \ \ #\ setup\ command\ mode\ completion\ for\ zsh +zsh\-wcomp\ \ \ \ \ \ \ \ \ \ \ \ #\ zsh\ word\ mode\ completion\ definitions +zsh\-wcomp\-install\ \ \ \ #\ setup\ word\ mode\ completion\ for\ zsh +bash\-hook\ \ \ \ \ \ \ \ \ \ \ \ #\ add\ hook\ code\ to\ bash\ $PROMPT_COMMAND +bash\-ccomp\ \ \ \ \ \ \ \ \ \ \ #\ bash\ command\ mode\ completion\ definitions +bash\-ccomp\-install\ \ \ #\ setup\ command\ mode\ completion\ for\ bash +posix\-alias\ \ \ \ \ \ \ \ \ \ #\ define\ aliases\ that\ applies\ to\ all\ posix\ shells +posix\-hook\ \ \ \ \ \ \ \ \ \ \ #\ setup\ $PS1\ hook\ for\ shells\ that\[aq]s\ posix\ compatible +tcsh\-alias\ \ \ \ \ \ \ \ \ \ \ #\ define\ aliases\ for\ tcsh +tcsh\-hook\ \ \ \ \ \ \ \ \ \ \ \ #\ setup\ tcsh\ precmd\ alias +\f[] +.fi +.PP +Example for a minimal zsh setup (no tab completion): +.IP +.nf +\f[C] +eval\ "$(fasd\ \-\-init\ posix\-alias\ zsh\-hook)" +\f[] +.fi +.PP +Note that this method will slightly increase your shell start\-up time, +since calling binaries has overhead. +You can cache fasd init code if you want minimal overhead. +Example code for bash (to be put into .bashrc): +.IP +.nf +\f[C] +fasd_cache="$HOME/.fasd\-init\-bash" +if\ [\ "$(command\ \-v\ fasd)"\ \-nt\ "$fasd_cache"\ \-o\ !\ \-s\ "$fasd_cache"\ ];\ then +\ \ fasd\ \-\-init\ posix\-alias\ bash\-hook\ bash\-ccomp\ bash\-ccomp\-install\ >|\ "$fasd_cache" +fi +source\ "$fasd_cache" +unset\ fasd_cache +\f[] +.fi +.PP +Optionally, if you can also source \f[C]fasd\f[] if you want +\f[C]fasd\f[] to be a shell function instead of an executable. +.PP +You can tweak initialization code. +For instance, if you want to use "c" instead of "z" to do directory +jumping, you can use the alias below: +.IP +.nf +\f[C] +alias\ c=\[aq]fasd_cd\ \-d\[aq] +#\ `\-d\[aq]\ option\ present\ for\ bash\ completion +#\ function\ fasd_cd\ is\ defined\ in\ posix\-alias +\f[] +.fi +.SH MATCHING +.PP +Fasd has three matching modes: default, case\-insensitive, and fuzzy. +.PP +For a given set of queries (the set of command\-line arguments passed to +fasd), a path is a match if and only if: +.IP "1." 3 +Queries match the path in order. +.IP "2." 3 +The last query matches the last segment of the path. +.PP +If no match is found, fasd will try the same process ignoring case. +If still no match is found, fasd will allow extra characters to be +placed between query characters for fuzzy matching. +.PP +Tips: +.IP \[bu] 2 +If you want your last query not to match the last segment of the path, +append `/\[aq] as the last query. +.IP \[bu] 2 +If you want your last query to match the end of the filename, append +`$\[aq] to the last query. +.SH COMPATIBILITY +.PP +Fasd\[aq]s basic functionalities are POSIX compliant, meaning that you +should be able to use fasd in all POSIX compliant shells. +Your shell need to support command substitution in $PS1 in order for +fasd to automatically track your commands and files. +This feature is not specified by the POSIX standard, but it\[aq]s +nonetheless present in many POSIX compliant shells. +In shells without prompt command or prompt command substitution (tcsh +for instance), you can add entries manually with "fasd \-A". +You are very welcomed to contribute shell initialization code for not +yet supported shells. +.SH TAB COMPLETION +.PP +Fasd offers two completion modes, command mode completion and word mode +completion. +Command mode completion works in bash and zsh. +Word mode completion only works in zsh. +.PP +Command mode completion is just like completion for any other commands. +It is triggered when you hit tab on a fasd command or its aliases. +Under this mode your queries can be separated by a space. +Tip: if you find that the completion result overwrites your queries, +type an extra space before you hit tab. +.PP +Word mode completion can be triggered on \f[I]any\f[] command. +Word completion is triggered by any command line argument that starts +with "," (all), "f," (files), or "d," (directories), or that ends with +",," (all), ",,f" (files), or ",,d" (directories). +Examples: +.IP +.nf +\f[C] +$\ vim\ ,rc,lo +$\ vim\ /etc/rc.local + +$\ mv\ index.html\ d,www +$\ mv\ index.html\ /var/www/ +\f[] +.fi +.PP +There are also three zle widgets: "fasd\-complete", "fasd\-complete\-f", +"fasd\-complete\-d". +You can bind them to keybindings you like: +.IP +.nf +\f[C] +bindkey\ \[aq]^X^A\[aq]\ fasd\-complete\ \ \ \ #\ C\-x\ C\-a\ to\ do\ fasd\-complete\ (files\ and\ directories) +bindkey\ \[aq]^X^F\[aq]\ fasd\-complete\-f\ \ #\ C\-x\ C\-f\ to\ do\ fasd\-complete\-f\ (only\ files) +bindkey\ \[aq]^X^D\[aq]\ fasd\-complete\-d\ \ #\ C\-x\ C\-d\ to\ do\ fasd\-complete\-d\ (only\ directories) +\f[] +.fi +.SH BACKENDS +.PP +Fasd can take advantage of different sources of recent / frequent files. +Most desktop environments (such as OS X and Gtk) and some editors (such +as Vim) keep a list of accessed files. +Fasd can use them as additional backends if the data can be converted +into fasd\[aq]s native format. +Below is a list of available backends. +.IP \[bu] 2 +spotlight: OSX spotlight, provides entries that are changed today or +opened within the past month +.IP \[bu] 2 +recently\-used: GTK\[aq]s recently\-used file (Usually available on +Linux) +.IP \[bu] 2 +current: Provides everything in $PWD (whereever you are executing +\f[C]fasd\f[]) +.IP \[bu] 2 +viminfo: Vim\[aq]s editing history, useful if you want to define an +alias just for editing things in vim +.PP +You can define your own backend by declaring a function by that name in +your \f[C]\&.fasdrc\f[]. +You can set default backend with \f[C]_FASD_BACKENDS\f[] variable in our +\f[C]\&.fasdrc\f[]. +.SH TWEAKS +.PP +Upon every execution, fasd will source "/etc/fasdrc" and "$HOME/.fasdrc" +if they are present. +Below are some variables you can set: +.IP +.nf +\f[C] +$_FASD_DATA +Path\ to\ the\ fasd\ data\ file,\ default\ "$HOME/.fasd". + +$_FASD_BLACKLIST +List\ of\ blacklisted\ strings.\ Commands\ matching\ them\ will\ not\ be\ processed. +Default\ is\ "\-\-help". + +$_FASD_SHIFT +List\ of\ all\ commands\ that\ needs\ to\ be\ shifted,\ defaults\ to\ "sudo\ busybox". + +$_FASD_IGNORE +List\ of\ all\ commands\ that\ will\ be\ ignored,\ defaults\ to\ "fasd\ ls\ echo". + +$_FASD_TRACK_PWD +Fasd\ defaults\ to\ track\ your\ "$PWD".\ Set\ this\ to\ 0\ to\ disable\ this\ behavior. + +$_FASD_AWK +Which\ awk\ to\ use.\ fasd\ can\ detect\ and\ use\ a\ compatible\ awk. + +$_FASD_SINK +File\ to\ log\ all\ STDERR\ to,\ defaults\ to\ "/dev/null". + +$_FASD_MAX +Max\ total\ score\ /\ weight,\ defaults\ to\ 2000. + +$_FASD_SHELL +Which\ shell\ to\ execute.\ Some\ shells\ will\ run\ faster\ than\ others.\ fasd +runs\ faster\ with\ dash\ and\ ksh\ variants. + +$_FASD_BACKENDS +Default\ backends. + +$_FASD_RO +If\ set\ to\ any\ non\-empty\ string,\ fasd\ will\ not\ add\ or\ delete\ entries\ from +database.\ You\ can\ set\ and\ export\ this\ variable\ from\ command\ line. + +$_FASD_FUZZY +Level\ of\ "fuzziness"\ when\ doing\ fuzzy\ matching.\ More\ precisely,\ the\ number\ of +characters\ that\ can\ be\ skipped\ to\ generate\ a\ match.\ Set\ to\ empty\ or\ 0\ to +disable\ fuzzy\ matching.\ Default\ value\ is\ 2. + +$_FASD_VIMINFO +Path\ to\ .viminfo\ file\ for\ viminfo\ backend,\ defaults\ to\ "$HOME/.viminfo" + +$_FASD_RECENTLY_USED_XBEL +Path\ to\ XDG\ recently\-used.xbel\ file\ for\ recently\-used\ backend,\ defaults\ to +"$HOME/.local/share/recently\-used.xbel" +\f[] +.fi +.SH DEBUGGING +.PP +Fasd is hosted on GitHub: https://github.com/clvv/fasd +.PP +If fasd does not work as expected, please file a bug report on GitHub +describing the unexpected behavior along with your OS version, shell +version, awk version, sed version, and a log file. +.PP +You can set \f[C]_FASD_SINK\f[] in your \f[C]\&.fasdrc\f[] to obtain a +log. +.IP +.nf +\f[C] +_FASD_SINK="$HOME/.fasd.log" +\f[] +.fi +.SH COPYING +.PP +Fasd is originally written based on code from z +(https://github.com/rupa/z) by rupa deadwyler under the WTFPL license. +Most if not all of the code has been rewritten. +Fasd is licensed under the "MIT/X11" license. +.SH AUTHORS +Wei Dai . diff --git a/.zprezto/modules/fasd/external/fasd.1.md b/.zprezto/modules/fasd/external/fasd.1.md new file mode 100644 index 0000000..3deacfe --- /dev/null +++ b/.zprezto/modules/fasd/external/fasd.1.md @@ -0,0 +1,263 @@ +% FASD(1) fasd user manual +% Wei Dai +% Jul 16, 2012 + +# NAME + +fasd - quick access to files and directories + +# SYNOPSIS + +fasd [options] [query ...] + +[f|a|s|d|z] [options] [query ...] + +fasd [-A|-D] [paths ...] + +# OPTIONS + + -s list paths with ranks + -l list paths without ranks + -i interactive mode + -e set command to execute on the result file + -b only use backend + -B add additional backend + -a match files and directories + -d match directories only + -f match files only + -r match by rank only + -t match by recent access only + -R reverse listing order + -h show a brief help message + -[0-9] select the nth entry + +# DESCRIPTION + +Fasd keeps track of files and directories you access in your shell and gives you +quick access to them. You can use fasd to reference files or directories by just +a few key identifying characters. You can use fasd to boost your command line +productivity by defining your own aliases to launch programs on files or +directories. Fasd, by default, provides some basic aliases, including a shell +function "z" that resembles the functionality of "z" and "autojump." + +The name "fasd" comes from the default suggested aliases `f`(files), +`a`(files/directories), `s`(show/search/select), `d`(directories). + +Fasd ranks files and directories by "frecency," that is, by both "frequency" +and "recency." The term "frecency" was first coined by Mozilla and used in +Firefox. + +# EXAMPLES + + z bundle + f -e vim nginx conf + f -i rc$ + vi `f nginx conf` + cp update.html `d www` + open `sf pdf` + +# SHELL INITIALIZATION + +To get fasd working in a shell, some initialization code must be run. Put +lines below in your POSIX compatible shell rc. + + eval "$(fasd --init auto)" + +This will setup a command hook that executes on every command and advanced tab +completion for zsh and bash. + +If you want more control over what gets into your shell environment, you can +pass customized set of arguments to `fasd --init`. + + zsh-hook # define _fasd_preexec and add it to zsh preexec array + zsh-ccomp # zsh command mode completion definitions + zsh-ccomp-install # setup command mode completion for zsh + zsh-wcomp # zsh word mode completion definitions + zsh-wcomp-install # setup word mode completion for zsh + bash-hook # add hook code to bash $PROMPT_COMMAND + bash-ccomp # bash command mode completion definitions + bash-ccomp-install # setup command mode completion for bash + posix-alias # define aliases that applies to all posix shells + posix-hook # setup $PS1 hook for shells that's posix compatible + tcsh-alias # define aliases for tcsh + tcsh-hook # setup tcsh precmd alias + +Example for a minimal zsh setup (no tab completion): + + eval "$(fasd --init posix-alias zsh-hook)" + +Note that this method will slightly increase your shell start-up time, since +calling binaries has overhead. You can cache fasd init code if you want +minimal overhead. Example code for bash (to be put into .bashrc): + + fasd_cache="$HOME/.fasd-init-bash" + if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then + fasd --init posix-alias bash-hook bash-ccomp bash-ccomp-install >| "$fasd_cache" + fi + source "$fasd_cache" + unset fasd_cache + +Optionally, if you can also source `fasd` if you want `fasd` to be a shell +function instead of an executable. + +You can tweak initialization code. For instance, if you want to use "c" +instead of "z" to do directory jumping, you can use the alias below: + + alias c='fasd_cd -d' + # `-d' option present for bash completion + # function fasd_cd is defined in posix-alias + +# MATCHING + +Fasd has three matching modes: default, case-insensitive, and fuzzy. + +For a given set of queries (the set of command-line arguments passed to fasd), +a path is a match if and only if: + +1. Queries match the path in order. +2. The last query matches the last segment of the path. + +If no match is found, fasd will try the same process ignoring case. If still no +match is found, fasd will allow extra characters to be placed between query +characters for fuzzy matching. + +Tips: + +* If you want your last query not to match the last segment of the path, append + `/' as the last query. +* If you want your last query to match the end of the filename, append `$' to + the last query. + +# COMPATIBILITY + +Fasd's basic functionalities are POSIX compliant, meaning that you should be +able to use fasd in all POSIX compliant shells. Your shell need to support +command substitution in $PS1 in order for fasd to automatically track your +commands and files. This feature is not specified by the POSIX standard, but +it's nonetheless present in many POSIX compliant shells. In shells without +prompt command or prompt command substitution (tcsh for instance), you can add +entries manually with "fasd -A". You are very welcomed to contribute shell +initialization code for not yet supported shells. + +# TAB COMPLETION + +Fasd offers two completion modes, command mode completion and word mode +completion. Command mode completion works in bash and zsh. Word mode +completion only works in zsh. + +Command mode completion is just like completion for any other commands. It is +triggered when you hit tab on a fasd command or its aliases. Under this mode +your queries can be separated by a space. Tip: if you find that the completion +result overwrites your queries, type an extra space before you hit tab. + +Word mode completion can be triggered on *any* command. Word completion is +triggered by any command line argument that starts with "," (all), "f," +(files), or "d," (directories), or that ends with ",," (all), ",,f" (files), +or ",,d" (directories). Examples: + + $ vim ,rc,lo + $ vim /etc/rc.local + + $ mv index.html d,www + $ mv index.html /var/www/ + +There are also three zle widgets: "fasd-complete", "fasd-complete-f", +"fasd-complete-d". You can bind them to keybindings you like: + + bindkey '^X^A' fasd-complete # C-x C-a to do fasd-complete (files and directories) + bindkey '^X^F' fasd-complete-f # C-x C-f to do fasd-complete-f (only files) + bindkey '^X^D' fasd-complete-d # C-x C-d to do fasd-complete-d (only directories) + +# BACKENDS + +Fasd can take advantage of different sources of recent / frequent files. Most +desktop environments (such as OS X and Gtk) and some editors (such as Vim) keep +a list of accessed files. Fasd can use them as additional backends if the data +can be converted into fasd's native format. Below is a list of available +backends. + +* spotlight: OSX spotlight, provides entries that are changed today or opened + within the past month + +* recently-used: GTK's recently-used file (Usually available on Linux) + +* current: Provides everything in $PWD (whereever you are executing `fasd`) + +* viminfo: Vim's editing history, useful if you want to define an alias just + for editing things in vim + +You can define your own backend by declaring a function by that name in your +`.fasdrc`. You can set default backend with `_FASD_BACKENDS` variable in our +`.fasdrc`. + +# TWEAKS + +Upon every execution, fasd will source "/etc/fasdrc" and "$HOME/.fasdrc" if +they are present. Below are some variables you can set: + + $_FASD_DATA + Path to the fasd data file, default "$HOME/.fasd". + + $_FASD_BLACKLIST + List of blacklisted strings. Commands matching them will not be processed. + Default is "--help". + + $_FASD_SHIFT + List of all commands that needs to be shifted, defaults to "sudo busybox". + + $_FASD_IGNORE + List of all commands that will be ignored, defaults to "fasd ls echo". + + $_FASD_TRACK_PWD + Fasd defaults to track your "$PWD". Set this to 0 to disable this behavior. + + $_FASD_AWK + Which awk to use. fasd can detect and use a compatible awk. + + $_FASD_SINK + File to log all STDERR to, defaults to "/dev/null". + + $_FASD_MAX + Max total score / weight, defaults to 2000. + + $_FASD_SHELL + Which shell to execute. Some shells will run faster than others. fasd + runs faster with dash and ksh variants. + + $_FASD_BACKENDS + Default backends. + + $_FASD_RO + If set to any non-empty string, fasd will not add or delete entries from + database. You can set and export this variable from command line. + + $_FASD_FUZZY + Level of "fuzziness" when doing fuzzy matching. More precisely, the number of + characters that can be skipped to generate a match. Set to empty or 0 to + disable fuzzy matching. Default value is 2. + + $_FASD_VIMINFO + Path to .viminfo file for viminfo backend, defaults to "$HOME/.viminfo" + + $_FASD_RECENTLY_USED_XBEL + Path to XDG recently-used.xbel file for recently-used backend, defaults to + "$HOME/.local/share/recently-used.xbel" + +# DEBUGGING + +Fasd is hosted on GitHub: https://github.com/clvv/fasd + +If fasd does not work as expected, please file a bug report on GitHub describing +the unexpected behavior along with your OS version, shell version, awk version, +sed version, and a log file. + +You can set `_FASD_SINK` in your `.fasdrc` to obtain a log. + + _FASD_SINK="$HOME/.fasd.log" + +# COPYING + +Fasd is originally written based on code from z (https://github.com/rupa/z) by +rupa deadwyler under the WTFPL license. Most if not all of the code has been +rewritten. Fasd is licensed under the "MIT/X11" license. + diff --git a/.zprezto/modules/fasd/init.zsh b/.zprezto/modules/fasd/init.zsh index fc21425..37babd8 100644 --- a/.zprezto/modules/fasd/init.zsh +++ b/.zprezto/modules/fasd/init.zsh @@ -9,17 +9,20 @@ # Load dependencies. pmodload 'editor' -# Return if requirements are not found. +# If the command doesn't exist externally, we need to fall back to the bundled +# submodule. if (( ! $+commands[fasd] )); then - return 1 + source "${0:h}/external/fasd" || return 1 fi # # Initialization # -cache_file="${0:h}/cache.zsh" -if [[ "${commands[fasd]}" -nt "$cache_file" || ! -s "$cache_file" ]]; then +cache_file="${TMPDIR:-/tmp}/prezto-fasd-cache.$UID.zsh" +if [[ "${commands[fasd]}" -nt "$cache_file" \ + || "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" \ + || ! -s "$cache_file" ]]; then # Set the base init arguments. init_args=(zsh-hook) diff --git a/.zprezto/modules/git/README.md b/.zprezto/modules/git/README.md index c2d0449..a497826 100644 --- a/.zprezto/modules/git/README.md +++ b/.zprezto/modules/git/README.md @@ -15,20 +15,30 @@ The format of the [git-log][8] output is configurable via the following style, where context is *brief*, *oneline*, and *medium*, which will be passed to the `--pretty=format:` switch. - zstyle ':prezto:module:git:log:context' format '' +```sh +zstyle ':prezto:module:git:log:context' format '' +``` ### Status Retrieving the status of a repository with submodules can take a long time. Submodules may be ignored when they are *dirty*, *untracked*, *all*, or *none*. - zstyle ':prezto:module:git:status:ignore' submodules 'all' +```sh +zstyle ':prezto:module:git:status:ignore' submodules 'all' +``` This setting affects all aliases and functions that call `git-status`. Aliases ------- +Aliases are enabled by default. You can disable them with: + +```sh +zstyle ':prezto:module:git:alias' skip 'yes' +``` + ### Git - `g` is short for `git`. @@ -37,15 +47,17 @@ Aliases - `gb` lists, creates, renames, and deletes branches. - `gbc` creates a new branch. - - `gbl` lists branches and their commits. - - `gbL` lists local and remote branches and their commits. + - `gbl` lists branches and their commits. (also `gbv`) + - `gbL` lists all local and remote branches and their commits. + - `gbr` renames a branch. (also `gbm`) + - `gbR` renames a branch even if the new branch name already exists. (also + `gbM`) - `gbs` lists branches and their commits with ancestry graphs. - `gbS` lists local and remote branches and their commits with ancestry graphs. - - `gbx` deletes a branch. - - `gbX` deletes a branch irrespective of its merged status. - - `gbm` renames a branch. - - `gbM` renames a branch even if the new branch name already exists. + - `gbV` lists branches with more verbose information about their commits. + - `gbx` deletes a branch. (also `gbd`) + - `gbX` deletes a branch irrespective of its merged status. (also `gbD`) ### Commit @@ -53,11 +65,16 @@ Aliases - `gc` records changes to the repository. - `gca` stages all modified and deleted files. - `gcm` records changes to the repository with the given message. + - `gcS` records changes to the repository. (Signed) + - `gcSa` stages all modified and deleted files. (Signed) + - `gcSm` records changes to the repository with the given message. (Signed) - `gco` checks out a branch or paths to work tree. + - `gcam` stages all modified and deleted files, and records changes to the repository with the given message. - `gco` checks out a branch or paths to work tree. - `gcO` checks out hunks from the index or the tree interactively. - - `gcf` amends the tip of the current branch using the same log message as - *HEAD*. + - `gcf` amends the tip of the current branch using the same log message as *HEAD*. + - `gcSf` amends the tip of the current branch using the same log message as *HEAD*. (Signed) - `gcF` amends the tip of the current branch. + - `gcSF` amends the tip of the current branch. (Signed) - `gcp` applies changes introduced by existing commits. - `gcP` applies changes introduced by existing commits without committing. - `gcr` reverts existing commits by reverting patches and recording new @@ -65,6 +82,8 @@ Aliases - `gcR` removes the *HEAD* commit. - `gcs` displays various types of objects. - `gcl` lists lost commits. + - `gcy` displays commits yet to be applied to upstream in the short format. + - `gcY` displays commits yet to be applied to upstream. ### Conflict @@ -89,10 +108,86 @@ Aliases ### Fetch - `gf` downloads objects and references from another repository. + - `gfa` downloads objects and references from all remote repositories. - `gfc` clones a repository into a new directory. + - `gfcr` clones a repository into a new directory including all submodules. - `gfm` fetches from and merges with another repository or local branch. - `gfr` fetches from and rebases on another repository or local branch. +### Flow + + - `gFi` is short for `git flow init` + +#### Feature + + - `gFf` is short for `git flow feature` + - `gFfl` is short for `git flow feature list` + - `gFfs` is short for `git flow feature start` + - `gFff` is short for `git flow feature finish` + - `gFfp` is short for `git flow feature publish` + - `gFft` is short for `git flow feature track` + - `gFfd` is short for `git flow feature diff` + - `gFfr` is short for `git flow feature rebase` + - `gFfc` is short for `git flow feature checkout` + - `gFfm` is short for `git flow feature pull` + - `gFfx` is short for `git flow feature delete` + +#### Bugfix + + - `gFb` is short for `git flow bugfix` + - `gFbl` is short for `git flow bugfix list` + - `gFbs` is short for `git flow bugfix start` + - `gFbf` is short for `git flow bugfix finish` + - `gFbp` is short for `git flow bugfix publish` + - `gFbt` is short for `git flow bugfix track` + - `gFbd` is short for `git flow bugfix diff` + - `gFbr` is short for `git flow bugfix rebase` + - `gFbc` is short for `git flow bugfix checkout` + - `gFbm` is short for `git flow bugfix pull` + - `gFbx` is short for `git flow bugfix delete` + +#### Release + + - `gFl` is short for `git flow release` + - `gFll` is short for `git flow release list` + - `gFls` is short for `git flow release start` + - `gFlf` is short for `git flow release finish` + - `gFlp` is short for `git flow release publish` + - `gFlt` is short for `git flow release track` + - `gFld` is short for `git flow release diff` + - `gFlr` is short for `git flow release rebase` + - `gFlc` is short for `git flow release checkout` + - `gFlm` is short for `git flow release pull` + - `gFlx` is short for `git flow release delete` + +#### Hotfix + + - `gFh` is short for `git flow hotfix` + - `gFhl` is short for `git flow hotfix list` + - `gFhs` is short for `git flow hotfix start` + - `gFhf` is short for `git flow hotfix finish` + - `gFhp` is short for `git flow hotfix publish` + - `gFht` is short for `git flow hotfix track` + - `gFhd` is short for `git flow hotfix diff` + - `gFhr` is short for `git flow hotfix rebase` + - `gFhc` is short for `git flow hotfix checkout` + - `gFhm` is short for `git flow hotfix pull` + - `gFhx` is short for `git flow hotfix delete` + +#### Support + + - `gFs` is short for `git flow support` + - `gFsl` is short for `git flow support list` + - `gFss` is short for `git flow support start` + - `gFsf` is short for `git flow support finish` + - `gFsp` is short for `git flow support publish` + - `gFst` is short for `git flow support track` + - `gFsd` is short for `git flow support diff` + - `gFsr` is short for `git flow support rebase` + - `gFsc` is short for `git flow support checkout` + - `gFsm` is short for `git flow support pull` + - `gFsx` is short for `git flow support delete` + ### Grep - `gg` displays lines matching a pattern. @@ -109,6 +204,8 @@ Aliases - `giu` adds file contents to the index (updates only known files). - `gid` displays changes between the index and a named commit (diff). - `giD` displays changes between the index and a named commit (word diff). + - `gii` temporarily ignore differences in a given file. + - `giI` unignore differences in a given file. - `gir` resets the current HEAD to the specified state. - `giR` resets the current index interactively. - `gix` removes files/directories from the index (recursively). @@ -136,7 +233,8 @@ Aliases ### Push - `gp` updates remote refs along with associated objects. - - `gpf` forcefully updates remote refs along with associated objects. + - `gpf` forcefully updates remote refs along with associated objects using the safer `--force-with-lease` option. + - `gpF` forcefully updates remote refs along with associated objects using the riskier `--force` option. - `gpa` updates remote branches along with associated objects. - `gpA` updates remote branches and tags along with associated objects. - `gpt` updates remote tags along with associated objects. @@ -193,6 +291,11 @@ Aliases - `gSu` fetches and merges the latest changes for all submodule. - `gSx` removes a submodule. +### Tag + + - `gt` lists tags or creates tag. + - `gtl` lists tags matching pattern. + ### Working directory - `gws` displays working-tree status in the short format. @@ -212,8 +315,10 @@ Aliases The following aliases may shadow system commands: + - `gb` shadows the [GB][9]. + - `gm` shadows the [Graphics Magick image processor][11]. - `gpt` shadows the [GUID partition table maintenance utility][4]. - - `gs` shadows the [Ghostscript][5]. + - `gs` shadows the [Ghostscript interpreter and previewer][5]. If you frequently use the above commands, you may wish to remove said aliases from this module or to disable them at the bottom of the zshrc with `unalias`. @@ -228,7 +333,7 @@ Functions - `git-commit-lost` lists lost commits. - `git-dir` displays the path to the Git directory. - `git-hub-browse` opens the [GitHub][3] repository in the default browser. - - `git-hub-shorten-url` shortens GitHub URLs. + - `git-hub-shorten-url` shortens [GitHub URLs][10]. - `git-info` exposes repository information via the `$git_info` associative array. - `git-root` displays the path to the working tree root. @@ -245,7 +350,9 @@ To display information about the current repository in a prompt, define the following styles in the `prompt_name_setup` function, where the syntax for setting a style is as follows. - zstyle ':prezto:module:git:info:context:subcontext' format 'string' +```sh +zstyle ':prezto:module:git:info:context:subcontext' format 'string' +``` ### Main Contexts @@ -272,7 +379,9 @@ setting a style is as follows. The following contexts must be enabled with the following zstyle: - zstyle ':prezto:module:git:info' verbose 'yes' +```sh +zstyle ':prezto:module:git:info' verbose 'yes' +``` ### Verbose Contexts @@ -299,18 +408,24 @@ The following contexts must be enabled with the following zstyle: | rebase | value | Rebasing | rebase-interactive | value | Rebasing interactively | rebase-merge | value | Rebasing merge +| revert | value | Reverting +| revert-sequence | value | Reverting sequence First, format the repository state attributes. For example, to format the branch and remote names, define the following styles. - zstyle ':prezto:module:git:info:branch' format 'branch:%b' - zstyle ':prezto:module:git:info:remote' format 'remote:%R' +```sh +zstyle ':prezto:module:git:info:branch' format 'branch:%b' +zstyle ':prezto:module:git:info:remote' format 'remote:%R' +``` Second, format how the above attributes are displayed in prompts. - zstyle ':prezto:module:git:info:keys' format \ - 'prompt' ' git(%b)' \ - 'rprompt' '[%R]' +```sh +zstyle ':prezto:module:git:info:keys' format \ + 'prompt' ' git(%b)' \ + 'rprompt' '[%R]' +``` Last, add `$git_info[prompt]` to `$PROMPT` and `$git_info[rprompt]` to `$RPROMPT` respectively and call `git-info` in the `prompt_name_preexec` hook @@ -328,7 +443,10 @@ Authors [2]: https://github.com/defunkt/hub [3]: https://www.github.com [4]: http://www.manpagez.com/man/8/gpt/ -[5]: http://linux.die.net/man/1/gs +[5]: http://www.manpagez.com/man/1/gs/ [6]: https://github.com/sorin-ionescu/prezto/issues [7]: https://github.com/sorin-ionescu/prezto/issues/219 [8]: http://www.kernel.org/pub/software/scm/git/docs/git-log.html +[9]: https://getgb.io/ +[10]: https://github.com/blog/985-git-io-github-url-shortener +[11]: http://www.manpagez.com/man/1/gm/ diff --git a/.zprezto/modules/git/alias.zsh b/.zprezto/modules/git/alias.zsh index ffa854d..dde5b35 100644 --- a/.zprezto/modules/git/alias.zsh +++ b/.zprezto/modules/git/alias.zsh @@ -26,156 +26,245 @@ zstyle -s ':prezto:module:git:status:ignore' submodules '_git_status_ignore_subm # Aliases # -# Git -alias g='git' +if ! zstyle -t ':prezto:module:git:alias' skip 'yes'; then + # Git + alias g='git' -# Branch (b) -alias gb='git branch' -alias gbc='git checkout -b' -alias gbl='git branch -v' -alias gbL='git branch -av' -alias gbx='git branch -d' -alias gbX='git branch -D' -alias gbm='git branch -m' -alias gbM='git branch -M' -alias gbs='git show-branch' -alias gbS='git show-branch -a' + # Branch (b) + alias gb='git branch' + alias gba='git branch --all --verbose' + alias gbc='git checkout -b' + alias gbd='git branch --delete' + alias gbD='git branch --delete --force' + alias gbl='git branch --verbose' + alias gbL='git branch --all --verbose' + alias gbm='git branch --move' + alias gbM='git branch --move --force' + alias gbr='git branch --move' + alias gbR='git branch --move --force' + alias gbs='git show-branch' + alias gbS='git show-branch --all' + alias gbv='git branch --verbose' + alias gbV='git branch --verbose --verbose' + alias gbx='git branch --delete' + alias gbX='git branch --delete --force' -# Commit (c) -alias gc='git commit --verbose' -alias gca='git commit --verbose --all' -alias gcm='git commit --message' -alias gco='git checkout' -alias gcO='git checkout --patch' -alias gcf='git commit --amend --reuse-message HEAD' -alias gcF='git commit --verbose --amend' -alias gcp='git cherry-pick --ff' -alias gcP='git cherry-pick --no-commit' -alias gcr='git revert' -alias gcR='git reset "HEAD^"' -alias gcs='git show' -alias gcl='git-commit-lost' + # Commit (c) + alias gc='git commit --verbose' + alias gca='git commit --verbose --all' + alias gcm='git commit --message' + alias gcS='git commit -S --verbose' + alias gcSa='git commit -S --verbose --all' + alias gcSm='git commit -S --message' + alias gcam='git commit --all --message' + alias gco='git checkout' + alias gcO='git checkout --patch' + alias gcf='git commit --amend --reuse-message HEAD' + alias gcSf='git commit -S --amend --reuse-message HEAD' + alias gcF='git commit --verbose --amend' + alias gcSF='git commit -S --verbose --amend' + alias gcp='git cherry-pick --ff' + alias gcP='git cherry-pick --no-commit' + alias gcr='git revert' + alias gcR='git reset "HEAD^"' + alias gcs='git show' + alias gcl='git-commit-lost' + alias gcy='git cherry -v --abbrev' + alias gcY='git cherry -v' -# Conflict (C) -alias gCl='git status | sed -n "s/^.*both [a-z]*ed: *//p"' -alias gCa='git add $(gCl)' -alias gCe='git mergetool $(gCl)' -alias gCo='git checkout --ours --' -alias gCO='gCo $(gCl)' -alias gCt='git checkout --theirs --' -alias gCT='gCt $(gCl)' + # Conflict (C) + alias gCl='git --no-pager diff --name-only --diff-filter=U' + alias gCa='git add $(gCl)' + alias gCe='git mergetool $(gCl)' + alias gCo='git checkout --ours --' + alias gCO='gCo $(gCl)' + alias gCt='git checkout --theirs --' + alias gCT='gCt $(gCl)' -# Data (d) -alias gd='git ls-files' -alias gdc='git ls-files --cached' -alias gdx='git ls-files --deleted' -alias gdm='git ls-files --modified' -alias gdu='git ls-files --other --exclude-standard' -alias gdk='git ls-files --killed' -alias gdi='git status --porcelain --short --ignored | sed -n "s/^!! //p"' + # Data (d) + alias gd='git ls-files' + alias gdc='git ls-files --cached' + alias gdx='git ls-files --deleted' + alias gdm='git ls-files --modified' + alias gdu='git ls-files --other --exclude-standard' + alias gdk='git ls-files --killed' + alias gdi='git status --porcelain --short --ignored | sed -n "s/^!! //p"' -# Fetch (f) -alias gf='git fetch' -alias gfc='git clone' -alias gfm='git pull' -alias gfr='git pull --rebase' + # Fetch (f) + alias gf='git fetch' + alias gfa='git fetch --all' + alias gfc='git clone' + alias gfcr='git clone --recurse-submodules' + alias gfm='git pull' + alias gfr='git pull --rebase' -# Grep (g) -alias gg='git grep' -alias ggi='git grep --ignore-case' -alias ggl='git grep --files-with-matches' -alias ggL='git grep --files-without-matches' -alias ggv='git grep --invert-match' -alias ggw='git grep --word-regexp' + # Flow (F) + alias gFi='git flow init' + alias gFf='git flow feature' + alias gFb='git flow bugfix' + alias gFl='git flow release' + alias gFh='git flow hotfix' + alias gFs='git flow support' -# Index (i) -alias gia='git add' -alias giA='git add --patch' -alias giu='git add --update' -alias gid='git diff --no-ext-diff --cached' -alias giD='git diff --no-ext-diff --cached --word-diff' -alias gir='git reset' -alias giR='git reset --patch' -alias gix='git rm -r --cached' -alias giX='git rm -rf --cached' + alias gFfl='git flow feature list' + alias gFfs='git flow feature start' + alias gFff='git flow feature finish' + alias gFfp='git flow feature publish' + alias gFft='git flow feature track' + alias gFfd='git flow feature diff' + alias gFfr='git flow feature rebase' + alias gFfc='git flow feature checkout' + alias gFfm='git flow feature pull' + alias gFfx='git flow feature delete' -# Log (l) -alias gl='git log --topo-order --pretty=format:"${_git_log_medium_format}"' -alias gls='git log --topo-order --stat --pretty=format:"${_git_log_medium_format}"' -alias gld='git log --topo-order --stat --patch --full-diff --pretty=format:"${_git_log_medium_format}"' -alias glo='git log --topo-order --pretty=format:"${_git_log_oneline_format}"' -alias glg='git log --topo-order --all --graph --pretty=format:"${_git_log_oneline_format}"' -alias glb='git log --topo-order --pretty=format:"${_git_log_brief_format}"' -alias glc='git shortlog --summary --numbered' + alias gFbl='git flow bugfix list' + alias gFbs='git flow bugfix start' + alias gFbf='git flow bugfix finish' + alias gFbp='git flow bugfix publish' + alias gFbt='git flow bugfix track' + alias gFbd='git flow bugfix diff' + alias gFbr='git flow bugfix rebase' + alias gFbc='git flow bugfix checkout' + alias gFbm='git flow bugfix pull' + alias gFbx='git flow bugfix delete' -# Merge (m) -alias gm='git merge' -alias gmC='git merge --no-commit' -alias gmF='git merge --no-ff' -alias gma='git merge --abort' -alias gmt='git mergetool' + alias gFll='git flow release list' + alias gFls='git flow release start' + alias gFlf='git flow release finish' + alias gFlp='git flow release publish' + alias gFlt='git flow release track' + alias gFld='git flow release diff' + alias gFlr='git flow release rebase' + alias gFlc='git flow release checkout' + alias gFlm='git flow release pull' + alias gFlx='git flow release delete' -# Push (p) -alias gp='git push' -alias gpf='git push --force' -alias gpa='git push --all' -alias gpA='git push --all && git push --tags' -alias gpt='git push --tags' -alias gpc='git push --set-upstream origin "$(git-branch-current 2> /dev/null)"' -alias gpp='git pull origin "$(git-branch-current 2> /dev/null)" && git push origin "$(git-branch-current 2> /dev/null)"' + alias gFhl='git flow hotfix list' + alias gFhs='git flow hotfix start' + alias gFhf='git flow hotfix finish' + alias gFhp='git flow hotfix publish' + alias gFht='git flow hotfix track' + alias gFhd='git flow hotfix diff' + alias gFhr='git flow hotfix rebase' + alias gFhc='git flow hotfix checkout' + alias gFhm='git flow hotfix pull' + alias gFhx='git flow hotfix delete' -# Rebase (r) -alias gr='git rebase' -alias gra='git rebase --abort' -alias grc='git rebase --continue' -alias gri='git rebase --interactive' -alias grs='git rebase --skip' + alias gFsl='git flow support list' + alias gFss='git flow support start' + alias gFsf='git flow support finish' + alias gFsp='git flow support publish' + alias gFst='git flow support track' + alias gFsd='git flow support diff' + alias gFsr='git flow support rebase' + alias gFsc='git flow support checkout' + alias gFsm='git flow support pull' + alias gFsx='git flow support delete' -# Remote (R) -alias gR='git remote' -alias gRl='git remote --verbose' -alias gRa='git remote add' -alias gRx='git remote rm' -alias gRm='git remote rename' -alias gRu='git remote update' -alias gRp='git remote prune' -alias gRs='git remote show' -alias gRb='git-hub-browse' + # Grep (g) + alias gg='git grep' + alias ggi='git grep --ignore-case' + alias ggl='git grep --files-with-matches' + alias ggL='git grep --files-without-matches' + alias ggv='git grep --invert-match' + alias ggw='git grep --word-regexp' -# Stash (s) -alias gs='git stash' -alias gsa='git stash apply' -alias gsx='git stash drop' -alias gsX='git-stash-clear-interactive' -alias gsl='git stash list' -alias gsL='git-stash-dropped' -alias gsd='git stash show --patch --stat' -alias gsp='git stash pop' -alias gsr='git-stash-recover' -alias gss='git stash save --include-untracked' -alias gsS='git stash save --patch --no-keep-index' -alias gsw='git stash save --include-untracked --keep-index' + # Index (i) + alias gia='git add' + alias giA='git add --patch' + alias giu='git add --update' + alias gid='git diff --no-ext-diff --cached' + alias giD='git diff --no-ext-diff --cached --word-diff' + alias gii='git update-index --assume-unchanged' + alias giI='git update-index --no-assume-unchanged' + alias gir='git reset' + alias giR='git reset --patch' + alias gix='git rm -r --cached' + alias giX='git rm -rf --cached' -# Submodule (S) -alias gS='git submodule' -alias gSa='git submodule add' -alias gSf='git submodule foreach' -alias gSi='git submodule init' -alias gSI='git submodule update --init --recursive' -alias gSl='git submodule status' -alias gSm='git-submodule-move' -alias gSs='git submodule sync' -alias gSu='git submodule foreach git pull origin master' -alias gSx='git-submodule-remove' + # Log (l) + alias gl='git log --topo-order --pretty=format:"${_git_log_medium_format}"' + alias gls='git log --topo-order --stat --pretty=format:"${_git_log_medium_format}"' + alias gld='git log --topo-order --stat --patch --full-diff --pretty=format:"${_git_log_medium_format}"' + alias glo='git log --topo-order --pretty=format:"${_git_log_oneline_format}"' + alias glg='git log --topo-order --all --graph --pretty=format:"${_git_log_oneline_format}"' + alias glb='git log --topo-order --pretty=format:"${_git_log_brief_format}"' + alias glc='git shortlog --summary --numbered' -# Working Copy (w) -alias gws='git status --ignore-submodules=${_git_status_ignore_submodules} --short' -alias gwS='git status --ignore-submodules=${_git_status_ignore_submodules}' -alias gwd='git diff --no-ext-diff' -alias gwD='git diff --no-ext-diff --word-diff' -alias gwr='git reset --soft' -alias gwR='git reset --hard' -alias gwc='git clean -n' -alias gwC='git clean -f' -alias gwx='git rm -r' -alias gwX='git rm -rf' + # Merge (m) + alias gm='git merge' + alias gmC='git merge --no-commit' + alias gmF='git merge --no-ff' + alias gma='git merge --abort' + alias gmt='git mergetool' + + # Push (p) + alias gp='git push' + alias gpf='git push --force-with-lease' + alias gpF='git push --force' + alias gpa='git push --all' + alias gpA='git push --all && git push --tags' + alias gpt='git push --tags' + alias gpc='git push --set-upstream origin "$(git-branch-current 2> /dev/null)"' + alias gpp='git pull origin "$(git-branch-current 2> /dev/null)" && git push origin "$(git-branch-current 2> /dev/null)"' + + # Rebase (r) + alias gr='git rebase' + alias gra='git rebase --abort' + alias grc='git rebase --continue' + alias gri='git rebase --interactive' + alias grs='git rebase --skip' + + # Remote (R) + alias gR='git remote' + alias gRl='git remote --verbose' + alias gRa='git remote add' + alias gRx='git remote rm' + alias gRm='git remote rename' + alias gRu='git remote update' + alias gRp='git remote prune' + alias gRs='git remote show' + alias gRb='git-hub-browse' + + # Stash (s) + alias gs='git stash' + alias gsa='git stash apply' + alias gsx='git stash drop' + alias gsX='git-stash-clear-interactive' + alias gsl='git stash list' + alias gsL='git-stash-dropped' + alias gsd='git stash show --patch --stat' + alias gsp='git stash pop' + alias gsr='git-stash-recover' + alias gss='git stash save --include-untracked' + alias gsS='git stash save --patch --no-keep-index' + alias gsw='git stash save --include-untracked --keep-index' + + # Submodule (S) + alias gS='git submodule' + alias gSa='git submodule add' + alias gSf='git submodule foreach' + alias gSi='git submodule init' + alias gSI='git submodule update --init --recursive' + alias gSl='git submodule status' + alias gSm='git-submodule-move' + alias gSs='git submodule sync' + alias gSu='git submodule foreach git pull origin master' + alias gSx='git-submodule-remove' + + # Tag (t) + alias gt='git tag' + alias gtl='git tag -l' + + # Working Copy (w) + alias gws='git status --ignore-submodules=${_git_status_ignore_submodules} --short' + alias gwS='git status --ignore-submodules=${_git_status_ignore_submodules}' + alias gwd='git diff --no-ext-diff' + alias gwD='git diff --no-ext-diff --word-diff' + alias gwr='git reset --soft' + alias gwR='git reset --hard' + alias gwc='git clean -n' + alias gwC='git clean -f' + alias gwx='git rm -r' + alias gwX='git rm -rf' +fi diff --git a/.zprezto/modules/git/functions/_git-hub-browse b/.zprezto/modules/git/functions/_git-hub-browse index 54d223f..075314b 100644 --- a/.zprezto/modules/git/functions/_git-hub-browse +++ b/.zprezto/modules/git/functions/_git-hub-browse @@ -8,7 +8,7 @@ # Sorin Ionescu # -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then return 1 fi @@ -21,7 +21,7 @@ _arguments -C -s -S \ case "$state" in (remote) - remotes=($(git config --get-regexp 'remote.*.url' | cut -d. -f2)) + remotes=($(command git config --get-regexp 'remote.*.url' | cut -d. -f2)) _describe -t branch 'remotes' remotes && ret=0 ;; @@ -29,7 +29,7 @@ case "$state" in remote="$words[(($CURRENT - 1))]" branches_or_tags=($( - git ls-remote --heads --tags "$remote" 2>/dev/null | cut -f2 + command git ls-remote --heads --tags "$remote" 2> /dev/null | cut -f2 )) branches=(HEAD ${${(M)branches_or_tags[@]##refs/heads/?##}##refs/heads/}) @@ -39,7 +39,7 @@ case "$state" in _describe -t tag 'tags' tags && ret=0 ;; (file) - files=(${(0)"$(_call_program files git ls-files -z --exclude-standard 2>/dev/null)"}) + files=(${(0)"$(_call_program files command git ls-files -z --exclude-standard 2> /dev/null)"}) _wanted file expl 'file' _multi_parts - / files && ret=0 ;; esac diff --git a/.zprezto/modules/git/functions/_git-hub-shorten-url b/.zprezto/modules/git/functions/_git-hub-shorten-url index dcc7bb3..7e65ded 100644 --- a/.zprezto/modules/git/functions/_git-hub-shorten-url +++ b/.zprezto/modules/git/functions/_git-hub-shorten-url @@ -8,4 +8,9 @@ # Sorin Ionescu # -_arguments '1:url:' && return 0 +local service="$service" + +zstyle ":completion:*:${service}:*:prefixes" ignored-patterns '^http(|s)://' +zstyle ":completion:*:${service}:*:hosts" ignored-patterns '^*github.com' + +_arguments '1::GitHub URL:_urls' '2::code:' && return 0 diff --git a/.zprezto/modules/git/functions/_git-info b/.zprezto/modules/git/functions/_git-info index 1e21bfe..ef6d970 100644 --- a/.zprezto/modules/git/functions/_git-info +++ b/.zprezto/modules/git/functions/_git-info @@ -8,7 +8,7 @@ # Sorin Ionescu # -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then return 1 fi diff --git a/.zprezto/modules/git/functions/_git-submodule-move b/.zprezto/modules/git/functions/_git-submodule-move index 44eddb5..5f2122c 100644 --- a/.zprezto/modules/git/functions/_git-submodule-move +++ b/.zprezto/modules/git/functions/_git-submodule-move @@ -8,7 +8,7 @@ # Sorin Ionescu # -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then return 1 fi @@ -25,7 +25,7 @@ case "$state" in while IFS=$'\n' read submodule; do submodules+=("$submodule") done < <( - git config --file "$(git-root)/.gitmodules" --list \ + command git config --file "$(git-root)/.gitmodules" --list \ | grep '.path=' \ | cut -d= -f2- ) diff --git a/.zprezto/modules/git/functions/_git-submodule-remove b/.zprezto/modules/git/functions/_git-submodule-remove index 87bd7cb..819dfd8 100644 --- a/.zprezto/modules/git/functions/_git-submodule-remove +++ b/.zprezto/modules/git/functions/_git-submodule-remove @@ -8,7 +8,7 @@ # Sorin Ionescu # -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then return 1 fi @@ -18,7 +18,7 @@ local submodule while IFS=$'\n' read submodule; do submodules+=("$submodule") done < <( - git config --file "$(git-root)/.gitmodules" --list \ + command git config --file "$(git-root)/.gitmodules" --list \ | grep '.path=' \ | cut -d= -f2- ) diff --git a/.zprezto/modules/git/functions/git-branch-current b/.zprezto/modules/git/functions/git-branch-current index 944ffe2..3cf2e19 100644 --- a/.zprezto/modules/git/functions/git-branch-current +++ b/.zprezto/modules/git/functions/git-branch-current @@ -5,12 +5,14 @@ # Sorin Ionescu # -if ! git rev-parse 2> /dev/null; then +# function git-branch-current { + +if ! command git rev-parse 2> /dev/null; then print "$0: not a repository: $PWD" >&2 return 1 fi -local ref="$(git symbolic-ref HEAD 2> /dev/null)" +local ref="$(command git symbolic-ref HEAD 2> /dev/null)" if [[ -n "$ref" ]]; then print "${ref#refs/heads/}" @@ -18,3 +20,5 @@ if [[ -n "$ref" ]]; then else return 1 fi + +# } diff --git a/.zprezto/modules/git/functions/git-commit-lost b/.zprezto/modules/git/functions/git-commit-lost index 75ab571..1f086d3 100644 --- a/.zprezto/modules/git/functions/git-commit-lost +++ b/.zprezto/modules/git/functions/git-commit-lost @@ -5,16 +5,20 @@ # Sorin Ionescu # -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +# function git-commit-lost { + +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 fi -git fsck 2> /dev/null \ +command git fsck 2> /dev/null \ | grep "^dangling commit" \ | awk '{print $3}' \ - | git log \ + | command git log \ --date-order \ --no-walk \ --stdin \ --pretty=format:${_git_log_oneline_format} + +# } diff --git a/.zprezto/modules/git/functions/git-dir b/.zprezto/modules/git/functions/git-dir index 7e16ca8..aacaaa8 100644 --- a/.zprezto/modules/git/functions/git-dir +++ b/.zprezto/modules/git/functions/git-dir @@ -5,7 +5,9 @@ # Sorin Ionescu # -local git_dir="${$(git rev-parse --git-dir):A}" +# function git-dir { + +local git_dir="${$(command git rev-parse --git-dir):A}" if [[ -n "$git_dir" ]]; then print "$git_dir" @@ -14,3 +16,5 @@ else print "$0: not a repository: $PWD" >&2 return 1 fi + +# } diff --git a/.zprezto/modules/git/functions/git-hub-browse b/.zprezto/modules/git/functions/git-hub-browse index 549a544..cb3fc60 100644 --- a/.zprezto/modules/git/functions/git-hub-browse +++ b/.zprezto/modules/git/functions/git-hub-browse @@ -5,7 +5,9 @@ # Sorin Ionescu # -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +# function git-hub-browse { + +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 fi @@ -13,7 +15,7 @@ fi local remotes remote references reference file url remote="${1:-origin}" -remotes=($(git config --get-regexp 'remote.*.url' | cut -d. -f2)) +remotes=($(command git config --get-regexp 'remote.*.url' | cut -d. -f2)) if (( $remotes[(i)$remote] == $#remotes + 1 )); then print "$0: remote not found: $remote" >&2 @@ -21,14 +23,14 @@ if (( $remotes[(i)$remote] == $#remotes + 1 )); then fi url=$( - git config --get "remote.${remote}.url" \ + command git config --get "remote.${remote}.url" \ | sed -En "s/(git|https?)(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\4\/\5/p" ) reference="${${2:-$(git-branch-current)}:-HEAD}" references=( HEAD - ${$(git ls-remote --heads --tags "$remote" | awk '{print $2}')##refs/(heads|tags)/} + ${$(command git ls-remote --heads --tags "$remote" | awk '{print $2}')##refs/(heads|tags)/} ) if (( $references[(i)$reference] == $#references + 1 )); then @@ -37,7 +39,7 @@ if (( $references[(i)$reference] == $#references + 1 )); then fi if [[ "$reference" == 'HEAD' ]]; then - reference="$(git rev-parse HEAD 2>/dev/null)" + reference="$(command git rev-parse HEAD 2> /dev/null)" fi file="$3" @@ -56,3 +58,5 @@ else print "$0: not a Git repository or remote not set" >&2 return 1 fi + +# } diff --git a/.zprezto/modules/git/functions/git-hub-shorten-url b/.zprezto/modules/git/functions/git-hub-shorten-url index 77e4b0b..470c093 100644 --- a/.zprezto/modules/git/functions/git-hub-shorten-url +++ b/.zprezto/modules/git/functions/git-hub-shorten-url @@ -5,18 +5,24 @@ # Sorin Ionescu # -local url="$1" +# function git-hub-shorten-url { + +local url="$1" code="$2" if [[ "$url" == '-' ]]; then read url <&0 fi -if [[ -z "$url" ]]; then - print "usage: $0 [ url | - ]" >&2 +if [[ -z "$url" || ! "$url" =~ ^https?:\/\/.*github.com\/ ]]; then + print "usage: $0 [ url | - ] [code] ; url must be a github.com URL" >&2 + return 1 fi if (( $+commands[curl] )); then - curl -s -i 'http://git.io' -F "url=$url" | grep 'Location:' | sed 's/Location: //' + curl -s -i 'https://git.io' -F "url=$url" ${(s: :)code:+ -F "code=$code"} | sed -n 's/^Location: //p' else print "$0: command not found: curl" >&2 + return 1 fi + +# } diff --git a/.zprezto/modules/git/functions/git-info b/.zprezto/modules/git/functions/git-info index 8aaa4c3..a173c20 100644 --- a/.zprezto/modules/git/functions/git-info +++ b/.zprezto/modules/git/functions/git-info @@ -5,7 +5,7 @@ # Sorin Ionescu # -# Gets the Git special action (am, bisect, cherry, merge, rebase). +# Gets the Git special action (am, bisect, cherry, merge, rebase, revert). # Borrowed from vcs_info and edited. function _git-action { local action_dir @@ -18,6 +18,8 @@ function _git-action { local rebase_formatted local rebase_interactive_formatted local rebase_merge_formatted + local revert_formatted + local revert_sequence_formatted for action_dir in \ "${git_dir}/rebase-apply" \ @@ -80,6 +82,18 @@ function _git-action { return 0 fi + if [[ -f "${git_dir}/REVERT_HEAD" ]]; then + if [[ -d "${git_dir}/sequencer" ]] ; then + zstyle -s ':prezto:module:git:info:action:revert-sequence' format 'revert_sequence_formatted' || revert_sequence_formatted='revert-sequence' + print "$revert_sequence_formatted" + else + zstyle -s ':prezto:module:git:info:action:revert' format 'revert_formatted' || revert_formatted='revert' + print "$revert_formatted" + fi + + return 0 + fi + if [[ -f "${git_dir}/BISECT_LOG" ]]; then zstyle -s ':prezto:module:git:info:action:bisect' format 'bisect_formatted' || bisect_formatted='bisect' print "$bisect_formatted" @@ -164,15 +178,15 @@ function git-info { typeset -gA git_info # Return if not inside a Git repository work tree. - if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then + if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then return 1 fi if (( $# > 0 )); then if [[ "$1" == [Oo][Nn] ]]; then - git config --bool prompt.showinfo true + command git config --bool prompt.showinfo true elif [[ "$1" == [Oo][Ff][Ff] ]]; then - git config --bool prompt.showinfo false + command git config --bool prompt.showinfo false else print "usage: $0 [ on | off ]" >&2 fi @@ -180,7 +194,7 @@ function git-info { fi # Return if git-info is disabled. - if ! is-true "${$(git config --bool prompt.showinfo):-true}"; then + if ! is-true "${$(command git config --bool prompt.showinfo):-true}"; then return 1 fi @@ -190,7 +204,7 @@ function git-info { # Format commit. zstyle -s ':prezto:module:git:info:commit' format 'commit_format' if [[ -n "$commit_format" ]]; then - commit="$(git rev-parse HEAD 2> /dev/null)" + commit="$(command git rev-parse HEAD 2> /dev/null)" if [[ -n "$commit" ]]; then zformat -f commit_formatted "$commit_format" "c:$commit" fi @@ -199,7 +213,7 @@ function git-info { # Format stashed. zstyle -s ':prezto:module:git:info:stashed' format 'stashed_format' if [[ -n "$stashed_format" && -f "$(git-dir)/refs/stash" ]]; then - stashed="$(git stash list 2> /dev/null | wc -l | awk '{print $1}')" + stashed="$(command git stash list 2> /dev/null | wc -l | awk '{print $1}')" if [[ -n "$stashed" ]]; then zformat -f stashed_formatted "$stashed_format" "S:$stashed" fi @@ -215,7 +229,7 @@ function git-info { fi # Get the branch. - branch="${$(git symbolic-ref HEAD 2> /dev/null)#refs/heads/}" + branch="${$(command git symbolic-ref HEAD 2> /dev/null)#refs/heads/}" # Format branch. zstyle -s ':prezto:module:git:info:branch' format 'branch_format' @@ -226,7 +240,7 @@ function git-info { # Format position. zstyle -s ':prezto:module:git:info:position' format 'position_format' if [[ -z "$branch" && -n "$position_format" ]]; then - position="$(git describe --contains --all HEAD 2> /dev/null)" + position="$(command git describe --contains --all HEAD 2> /dev/null)" if [[ -n "$position" ]]; then zformat -f position_formatted "$position_format" "p:$position" fi @@ -236,7 +250,7 @@ function git-info { zstyle -s ':prezto:module:git:info:remote' format 'remote_format' if [[ -n "$branch" && -n "$remote_format" ]]; then # Gets the remote name. - remote_cmd='git rev-parse --symbolic-full-name --verify HEAD@{upstream}' + remote_cmd='command git rev-parse --symbolic-full-name --verify HEAD@{upstream}' remote="${$(${(z)remote_cmd} 2> /dev/null)##refs/remotes/}" if [[ -n "$remote" ]]; then zformat -f remote_formatted "$remote_format" "R:$remote" @@ -247,7 +261,7 @@ function git-info { zstyle -s ':prezto:module:git:info:behind' format 'behind_format' if [[ -n "$branch" && ( -n "$ahead_format" || -n "$behind_format" ) ]]; then # Gets the commit difference counts between local and remote. - ahead_and_behind_cmd='git rev-list --count --left-right HEAD...@{upstream}' + ahead_and_behind_cmd='command git rev-list --count --left-right HEAD...@{upstream}' # Get ahead and behind counts. ahead_and_behind="$(${(z)ahead_and_behind_cmd} 2> /dev/null)" @@ -276,7 +290,7 @@ function git-info { if [[ -n "$indexed_format" ]]; then (( indexed+=$( - git diff-index \ + command git diff-index \ --no-ext-diff \ --name-only \ --cached \ @@ -296,7 +310,7 @@ function git-info { if [[ -n "$unindexed_format" ]]; then (( unindexed+=$( - git diff-files \ + command git diff-files \ --no-ext-diff \ --name-only \ --ignore-submodules=${ignore_submodules:-none} \ @@ -314,7 +328,7 @@ function git-info { if [[ -n "$untracked_format" ]]; then (( untracked+=$( - git ls-files \ + command git ls-files \ --other \ --exclude-standard \ 2> /dev/null \ @@ -329,7 +343,7 @@ function git-info { (( dirty = indexed + unindexed + untracked )) else # Use porcelain status for easy parsing. - status_cmd="git status --porcelain --ignore-submodules=${ignore_submodules:-none}" + status_cmd="command git status --porcelain --ignore-submodules=${ignore_submodules:-none}" # Get current status. while IFS=$'\n' read line; do diff --git a/.zprezto/modules/git/functions/git-root b/.zprezto/modules/git/functions/git-root index 712e4fe..643f346 100644 --- a/.zprezto/modules/git/functions/git-root +++ b/.zprezto/modules/git/functions/git-root @@ -5,7 +5,9 @@ # Sorin Ionescu # -local root="$(git rev-parse --show-toplevel 2> /dev/null)" +# function git-root { + +local root="$(command git rev-parse --show-toplevel 2> /dev/null)" if [[ -n "$root" ]]; then print "$root" @@ -14,3 +16,5 @@ else print "$0: not a repository work tree: $PWD" >&2 return 1 fi + +# } diff --git a/.zprezto/modules/git/functions/git-stash-clear-interactive b/.zprezto/modules/git/functions/git-stash-clear-interactive index e45165c..cc665a1 100644 --- a/.zprezto/modules/git/functions/git-stash-clear-interactive +++ b/.zprezto/modules/git/functions/git-stash-clear-interactive @@ -5,7 +5,9 @@ # Sorin Ionescu # -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +# function git-stash-clear-interactive { + +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 fi @@ -13,10 +15,12 @@ fi local stashed if [[ -f "$(git-dir)/refs/stash" ]]; then - stashed="$(git stash list 2> /dev/null | wc -l | awk '{print $1}')" + stashed="$(command git stash list 2> /dev/null | wc -l | awk '{print $1}')" if (( $stashed > 0 )); then if read -q "?Clear $stashed stashed state(s) [y/N]? "; then - git stash clear + command git stash clear fi fi fi + +# } diff --git a/.zprezto/modules/git/functions/git-stash-dropped b/.zprezto/modules/git/functions/git-stash-dropped index 5158070..d9e759e 100644 --- a/.zprezto/modules/git/functions/git-stash-dropped +++ b/.zprezto/modules/git/functions/git-stash-dropped @@ -5,18 +5,22 @@ # Sorin Ionescu # -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +# function git-stash-dropped { + +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 fi -git fsck --unreachable 2> /dev/null \ +command git fsck --unreachable 2> /dev/null \ | grep 'commit' \ | awk '{print $3}' \ - | git log \ + | command git log \ --pretty=format:${_git_log_oneline_format} \ --extended-regexp \ --grep="${1:-(WIP )?[Oo]n [^:]+:}" \ --merges \ --no-walk \ --stdin + +# } diff --git a/.zprezto/modules/git/functions/git-stash-recover b/.zprezto/modules/git/functions/git-stash-recover index 6add26f..6cb5416 100644 --- a/.zprezto/modules/git/functions/git-stash-recover +++ b/.zprezto/modules/git/functions/git-stash-recover @@ -5,7 +5,9 @@ # Sorin Ionescu # -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +# function git-stash-recover { + +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 fi @@ -13,6 +15,8 @@ fi local commit for commit in "$@"; do - git update-ref \ - -m "$(git log -1 --pretty="format:%s" "$commit")" refs/stash "$commit" + command git update-ref \ + -m "$(command git log -1 --pretty="format:%s" "$commit")" refs/stash "$commit" done + +# } diff --git a/.zprezto/modules/git/functions/git-submodule-move b/.zprezto/modules/git/functions/git-submodule-move index 34c5e44..746f46e 100644 --- a/.zprezto/modules/git/functions/git-submodule-move +++ b/.zprezto/modules/git/functions/git-submodule-move @@ -5,7 +5,9 @@ # Sorin Ionescu # -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +# function git-submodule-move { + +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 elif [[ "$PWD" != "$(git-root)" ]]; then @@ -17,7 +19,7 @@ local src="$1" local dst="$2" local url -url="$(git config --file "$(git-root)/.gitmodules" --get "submodule.${src}.url")" +url="$(command git config --file "$(git-root)/.gitmodules" --get "submodule.${src}.url")" if [[ -z "$url" ]]; then print "$0: submodule not found: $src" >&2 @@ -27,6 +29,8 @@ fi mkdir -p "${dst:h}" git-submodule-remove "$src" -git submodule add "$url" "$dst" +command git submodule add "$url" "$dst" return 0 + +# } diff --git a/.zprezto/modules/git/functions/git-submodule-remove b/.zprezto/modules/git/functions/git-submodule-remove index 852b9cd..c8c11aa 100644 --- a/.zprezto/modules/git/functions/git-submodule-remove +++ b/.zprezto/modules/git/functions/git-submodule-remove @@ -5,23 +5,27 @@ # Sorin Ionescu # -if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then +# function git-submodule-remove { + +if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 elif [[ "$PWD" != "$(git-root)" ]]; then print "$0: must be run from the root of the work tree" >&2 return 1 -elif ! git config --file .gitmodules --get "submodule.${1}.path" &>/dev/null; then +elif ! command git config --file .gitmodules --get "submodule.${1}.path" &> /dev/null; then print "$0: submodule not found: $1" >&2 return 1 fi -git config --file "$(git-dir)/config" --remove-section "submodule.${1}" &>/dev/null -git config --file "$(git-root)/.gitmodules" --remove-section "submodule.${1}" &>/dev/null -git add .gitmodules +command git config --file "$(git-dir)/config" --remove-section "submodule.${1}" &> /dev/null +command git config --file "$(git-root)/.gitmodules" --remove-section "submodule.${1}" &> /dev/null +command git add .gitmodules -git rm --cached -rf "${1}" +command git rm --cached -rf "${1}" rm -rf "${1}" rm -rf "$(git-dir)/modules/${1}" return 0 + +# } diff --git a/.zprezto/modules/gnu-utility/README.md b/.zprezto/modules/gnu-utility/README.md index 34bc663..7e62a17 100644 --- a/.zprezto/modules/gnu-utility/README.md +++ b/.zprezto/modules/gnu-utility/README.md @@ -20,7 +20,9 @@ Settings To use a different prefix, add the following to *zpreztorc*, and replace 'g' with the desired prefix: - zstyle ':prezto:module:gnu-utility' prefix 'g' +```sh +zstyle ':prezto:module:gnu-utility' prefix 'g' +``` Authors ------- diff --git a/.zprezto/modules/gnu-utility/init.zsh b/.zprezto/modules/gnu-utility/init.zsh index 6556032..4675a3c 100644 --- a/.zprezto/modules/gnu-utility/init.zsh +++ b/.zprezto/modules/gnu-utility/init.zsh @@ -15,16 +15,16 @@ fi _gnu_utility_cmds=( # Coreutils - '[' 'base64' 'basename' 'cat' 'chcon' 'chgrp' 'chmod' 'chown' + '[' 'b2sum' 'base32' 'base64' 'basename' 'cat' 'chcon' 'chgrp' 'chmod' 'chown' 'chroot' 'cksum' 'comm' 'cp' 'csplit' 'cut' 'date' 'dd' 'df' 'dir' 'dircolors' 'dirname' 'du' 'echo' 'env' 'expand' 'expr' 'factor' 'false' 'fmt' 'fold' 'groups' 'head' 'hostid' 'id' - 'install' 'join' 'kill' 'link' 'ln' 'logname' 'ls' 'md5sum' - 'mkdir' 'mkfifo' 'mknod' 'mktemp' 'mv' 'nice' 'nl' 'nohup' 'nproc' - 'od' 'paste' 'pathchk' 'pinee' 'pr' 'printenv' 'printf' 'ptx' + 'install' 'join' 'kill' 'link' 'ln' 'logname' 'ls' 'md5sum' 'mkdir' + 'mkfifo' 'mknod' 'mktemp' 'mv' 'nice' 'nl' 'nohup' 'nproc' + 'numfmt' 'od' 'paste' 'pathchk' 'pinky' 'pr' 'printenv' 'printf' 'ptx' 'pwd' 'readlink' 'realpath' 'rm' 'rmdir' 'runcon' 'seq' 'sha1sum' 'sha224sum' 'sha256sum' 'sha384sum' 'sha512sum' 'shred' 'shuf' - 'sleep' 'sort' 'split' 'stat' 'stty' 'sum' 'sync' 'tac' 'tail' + 'sleep' 'sort' 'split' 'stat' 'stdbuf' 'stty' 'sum' 'sync' 'tac' 'tail' 'tee' 'test' 'timeout' 'touch' 'tr' 'true' 'truncate' 'tsort' 'tty' 'uname' 'unexpand' 'uniq' 'unlink' 'uptime' 'users' 'vdir' 'wc' 'who' 'whoami' 'yes' @@ -42,13 +42,13 @@ _gnu_utility_cmds=( 'libtool' 'libtoolize' # Miscellaneous - 'getopt' 'grep' 'indent' 'sed' 'tar' 'time' 'units' 'which' + 'getopt' 'grep' 'indent' 'make' 'sed' 'tar' 'time' 'units' 'which' ) # Wrap GNU utilities in functions. for _gnu_utility_cmd in "${_gnu_utility_cmds[@]}"; do _gnu_utility_pcmd="${_gnu_utility_p}${_gnu_utility_cmd}" - if (( ${+commands[${_gnu_utility_pcmd}]} )); then + if (( ${+commands[${_gnu_utility_pcmd}]} && ! ${+builtins[${_gnu_utility_cmd}]} )); then eval " function ${_gnu_utility_cmd} { '${commands[${_gnu_utility_pcmd}]}' \"\$@\" diff --git a/.zprezto/modules/gpg/README.md b/.zprezto/modules/gpg/README.md index 80e91d0..be3c1a9 100644 --- a/.zprezto/modules/gpg/README.md +++ b/.zprezto/modules/gpg/README.md @@ -9,7 +9,9 @@ To enable OpenSSH Agent protocol emulation, and make `gpg-agent` a drop-in replacement for `ssh-agent`, add the following line to *~/.gnupg/gpg-agent.conf*: - enable-ssh-support +```conf +enable-ssh-support +``` When OpenSSH Agent protocol emulation is enabled, this module will load the SSH module for additional processing. diff --git a/.zprezto/modules/gpg/init.zsh b/.zprezto/modules/gpg/init.zsh index b969c7a..7976fd7 100644 --- a/.zprezto/modules/gpg/init.zsh +++ b/.zprezto/modules/gpg/init.zsh @@ -12,13 +12,13 @@ fi # Set the default paths to gpg-agent files. _gpg_agent_conf="${GNUPGHOME:-$HOME/.gnupg}/gpg-agent.conf" -_gpg_agent_env="${TMPDIR:-/tmp}/gpg-agent.env" +_gpg_agent_env="${TMPDIR:-/tmp}/gpg-agent.env.$UID" + +# Load environment variables from previous run +source "$_gpg_agent_env" 2> /dev/null # Start gpg-agent if not started. if [[ -z "$GPG_AGENT_INFO" && ! -S "${GNUPGHOME:-$HOME/.gnupg}/S.gpg-agent" ]]; then - # Export environment variables. - source "$_gpg_agent_env" 2> /dev/null - # Start gpg-agent if not started. if ! ps -U "$LOGNAME" -o pid,ucomm | grep -q -- "${${${(s.:.)GPG_AGENT_INFO}[2]}:--1} gpg-agent"; then eval "$(gpg-agent --daemon | tee "$_gpg_agent_env")" @@ -29,7 +29,7 @@ fi export GPG_TTY="$(tty)" # Integrate with the SSH module. -if grep 'enable-ssh-support' "$_gpg_agent_conf" &> /dev/null; then +if grep '^enable-ssh-support' "$_gpg_agent_conf" &> /dev/null; then # Load required functions. autoload -Uz add-zsh-hook diff --git a/.zprezto/modules/helper/init.zsh b/.zprezto/modules/helper/init.zsh index 9d79218..328bed4 100644 --- a/.zprezto/modules/helper/init.zsh +++ b/.zprezto/modules/helper/init.zsh @@ -12,7 +12,7 @@ function is-autoloadable { # Checks if a name is a command, function, or alias. function is-callable { - (( $+commands[$1] )) || (( $+functions[$1] )) || (( $+aliases[$1] )) + (( $+commands[$1] || $+functions[$1] || $+aliases[$1] || $+builtins[$1] )) } # Checks a boolean variable for "true". diff --git a/.zprezto/modules/history-substring-search/README.md b/.zprezto/modules/history-substring-search/README.md index 79714fa..050a5c2 100644 --- a/.zprezto/modules/history-substring-search/README.md +++ b/.zprezto/modules/history-substring-search/README.md @@ -6,8 +6,8 @@ the [Fish shell][2]'s history search feature, where the user can type in any part of a previously entered command and press up and down to cycle through matching commands. -If this module is used in conjuncture with the *syntax-highlighting* module, it -must be loaded **after** it. +If this module is used in conjunction with the *syntax-highlighting* module, +this module must be loaded **after** the *syntax-highlighting* module. Contributors ------------ @@ -24,7 +24,9 @@ Settings To enable case-sensitivity for this module only, add the following line to *zpreztorc*: - zstyle ':prezto:module:history-substring-search' case-sensitive 'yes' +```sh +zstyle ':prezto:module:history-substring-search' case-sensitive 'yes' +``` ### Highlighting @@ -34,19 +36,27 @@ positive results. To enable highlighting for this module only, add the following line to *zpreztorc*: - zstyle ':prezto:module:history-substring-search' color 'yes' +```sh +zstyle ':prezto:module:history-substring-search' color 'yes' +``` To set the query found color, add the following line to *zpreztorc*: - zstyle ':prezto:module:history-substring-search:color' found '' +```sh +zstyle ':prezto:module:history-substring-search:color' found '' +``` To set the query not found color, add the following line to *zpreztorc*: - zstyle ':prezto:module:history-substring-search:color' not-found '' +```sh +zstyle ':prezto:module:history-substring-search:color' not-found '' +``` To set the search globbing flags, add the following line to *zpreztorc*: - zstyle ':prezto:module:history-substring-search' globbing-flags '' +```sh +zstyle ':prezto:module:history-substring-search' globbing-flags '' +``` Authors ------- diff --git a/.zprezto/modules/history-substring-search/external/.git_backup b/.zprezto/modules/history-substring-search/external/.git_backup new file mode 100644 index 0000000..453d98d --- /dev/null +++ b/.zprezto/modules/history-substring-search/external/.git_backup @@ -0,0 +1 @@ +gitdir: ../../../.git/modules/modules/history-substring-search/external diff --git a/.zprezto/modules/history-substring-search/external/.gitignore_backup b/.zprezto/modules/history-substring-search/external/.gitignore_backup new file mode 100644 index 0000000..75f3b76 --- /dev/null +++ b/.zprezto/modules/history-substring-search/external/.gitignore_backup @@ -0,0 +1,2 @@ +# zsh word code files (zcompile) +*.zwc diff --git a/.zprezto/modules/history-substring-search/external/README.md b/.zprezto/modules/history-substring-search/external/README.md index 042714c..e9642ba 100644 --- a/.zprezto/modules/history-substring-search/external/README.md +++ b/.zprezto/modules/history-substring-search/external/README.md @@ -1,10 +1,8 @@ -zsh-history-substring-search -============================================================================== +# zsh-history-substring-search This is a clean-room implementation of the [Fish shell][1]'s history search -feature, where you can type in any part of any previously entered command -and press the UP and DOWN arrow keys to cycle through the matching commands. -You can also use K and J in VI mode or ^P and ^N in EMACS mode for the same. +feature, where you can type in any part of any command from history and then +press chosen keys, such as the UP and DOWN arrows, to cycle through matches. [1]: http://fishshell.com [2]: http://www.zsh.org/mla/users/2009/msg00818.html @@ -13,13 +11,13 @@ You can also use K and J in VI mode or ^P and ^N in EMACS mode for the same. [5]: https://github.com/zsh-users/zsh-history-substring-search [6]: https://github.com/zsh-users/zsh-syntax-highlighting ------------------------------------------------------------------------------- + Requirements ------------------------------------------------------------------------------ * [ZSH](http://zsh.sourceforge.net) 4.3 or newer ------------------------------------------------------------------------------- + Usage ------------------------------------------------------------------------------ @@ -33,95 +31,112 @@ Usage % source zsh-syntax-highlighting.zsh % source zsh-history-substring-search.zsh -2. Bind keyboard shortcuts to this script's functions: +2. Bind keyboard shortcuts to this script's functions. - # bind UP and DOWN arrow keys - zmodload zsh/terminfo - bindkey "$terminfo[kcuu1]" history-substring-search-up - bindkey "$terminfo[kcud1]" history-substring-search-down + Users typically bind their UP and DOWN arrow keys to this script, thus: + * Run `cat -v` in your favorite terminal emulator to observe key codes. + * Press the UP arrow key and observe what is printed in your terminal. + * Press the DOWN arrow key and observe what is printed in your terminal. + * Press the Control and C keys simultaneously to terminate the `cat -v`. + * Use your observations from the previous steps to create key bindings. + For example, if you observed `^[[A` for UP and `^[[B` for DOWN, then: - # bind UP and DOWN arrow keys (compatibility fallback - # for Ubuntu 12.04, Fedora 21, and MacOSX 10.9 users) - bindkey '^[[A' history-substring-search-up - bindkey '^[[B' history-substring-search-down + bindkey '^[[A' history-substring-search-up + bindkey '^[[B' history-substring-search-down + + You might also want to bind the Control-P/N keys for use in EMACS mode: - # bind P and N for EMACS mode bindkey -M emacs '^P' history-substring-search-up bindkey -M emacs '^N' history-substring-search-down - # bind k and j for VI mode + You might also want to bind the `k` and `j` keys for use in VI mode: + bindkey -M vicmd 'k' history-substring-search-up bindkey -M vicmd 'j' history-substring-search-down 3. Type any part of any previous command and then: - * Press the UP arrow key to select the nearest command that (1) contains - your query and (2) is older than the current command in the command - history. + * Press the `history-substring-search-up` key, which was configured in + step 2 above, to select the nearest command that (1) contains your query + and (2) is also older than the current command in your command history. - * Press the DOWN arrow key to select the nearest command that (1) - contains your query and (2) is newer than the current command in the - command history. + * Press the `history-substring-search-down` key, which was configured in + step 2 above, to select the nearest command that (1) contains your query + and (2) is also newer than the current command in your command history. - * Press ^U (the Control and U keys simultaneously) to abort the search. + * Press `^U` the Control and U keys simultaneously to abort the search. 4. If a matching command spans more than one line of text, press the LEFT arrow key to move the cursor away from the end of the command, and then: - * Press the UP arrow key to move the cursor to the line above. When the - cursor reaches the first line of the command, pressing the UP arrow - key again will cause this script to perform another search. + * Press the `history-substring-search-up` key, which was configured in + step 2 above, to move the cursor to the line above the cursored line. + When the cursor reaches the first line of the command, pressing the + `history-substring-search-up` key again will cause this script to + perform another search. + + * Press the `history-substring-search-down` key, which was configured in + step 2 above, to move the cursor to the line below the cursored line. + When the cursor reaches the last line of the command, pressing the + `history-substring-search-down` key, which was configured in step 2 + above, again will cause this script to perform another search. - * Press the DOWN arrow key to move the cursor to the line below. When - the cursor reaches the last line of the command, pressing the DOWN - arrow key again will cause this script to perform another search. ------------------------------------------------------------------------------- Configuration ------------------------------------------------------------------------------ This script defines the following global variables. You may override their default values only after having loaded this script into your ZSH session. -* HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND is a global variable that defines +* `HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND` is a global variable that defines how the query should be highlighted inside a matching command. Its default value causes this script to highlight using bold, white text on a magenta background. See the "Character Highlighting" section in the zshzle(1) man page to learn about the kinds of values you may assign to this variable. -* HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND is a global variable that +* `HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND` is a global variable that defines how the query should be highlighted when no commands in the history match it. Its default value causes this script to highlight using bold, white text on a red background. See the "Character Highlighting" section in the zshzle(1) man page to learn about the kinds of values you may assign to this variable. -* HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS is a global variable that defines +* `HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS` is a global variable that defines how the command history will be searched for your query. Its default value causes this script to perform a case-insensitive search. See the "Globbing Flags" section in the zshexpn(1) man page to learn about the kinds of values you may assign to this variable. -To always receive _unique_ search results, use `setopt HIST_IGNORE_ALL_DUPS`. -Alternatively, use `setopt HIST_FIND_NO_DUPS` which makes this plugin skip -duplicate _adjacent_ search results as you cycle through them---however, this -does not guarantee that search results are unique: if your search results were -"Dog", "Dog", "HotDog", "Dog", then cycling them gives "Dog", "HotDog", "Dog". -Notice that the "Dog" search result appeared twice as you cycled through them! -If you wish to avoid this limitation, then use `setopt HIST_IGNORE_ALL_DUPS`. +* `HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE` is a global variable that defines + whether all search results returned are _unique_. If set to a non-empty + value, then only unique search results are presented. This behaviour is off + by default. An alternative way to ensure that search results are unique is + to use `setopt HIST_IGNORE_ALL_DUPS`. If this configuration variable is off + and `setopt HIST_IGNORE_ALL_DUPS` is unset, then `setopt HIST_FIND_NO_DUPS` + is still respected and it makes this script skip duplicate _adjacent_ search + results as you cycle through them, but this does not guarantee that search + results are unique: if your search results were "Dog", "Dog", "HotDog", + "Dog", then cycling them gives "Dog", "HotDog", "Dog". Notice that the "Dog" + search result appeared twice as you cycled through them. If you wish to + receive globally unique search results only once, then use this + configuration variable, or use `setopt HIST_IGNORE_ALL_DUPS`. + ------------------------------------------------------------------------------- History ------------------------------------------------------------------------------ -This script was originally written by [Peter Stephenson][2], who published it -to the ZSH users mailing list (thereby making it public domain) in September -2009. It was later revised by Guido van Steen and released under the BSD -license (see below) as part of [the fizsh project][3] in January 2011. +* September 2009: [Peter Stephenson][2] originally wrote this script and it + published to the zsh-users mailing list. -It was later extracted from fizsh release 1.0.1, refactored heavily, and -repackaged as both an [oh-my-zsh plugin][4] and as an independently loadable -[ZSH script][5] by Suraj N. Kurapati in 2011. +* January 2011: Guido van Steen (@guidovansteen) revised this script and + released it under the 3-clause BSD license as part of [fizsh][3], the + Friendly Interactive ZSHell. -It was [further developed][4] by Guido van Steen, Suraj N. Kurapati, Sorin -Ionescu, and Vincent Guerci in 2011. +* January 2011: Suraj N. Kurapati (@sunaku) extracted this script from + [fizsh][3] 1.0.1, refactored it heavily, and finally repackaged it as an + [oh-my-zsh plugin][4] and as an independently loadable [ZSH script][5]. + +* July 2011: Guido van Steen, Suraj N. Kurapati, and Sorin Ionescu + (@sorin-ionescu) [further developed it][4] with Vincent Guerci (@vguerci). + +* March 2016: Geza Lore (@gezalore) greatly refactored it in pull request #55. diff --git a/.zprezto/modules/history-substring-search/external/zsh-history-substring-search.plugin.zsh b/.zprezto/modules/history-substring-search/external/zsh-history-substring-search.plugin.zsh deleted file mode 100644 index b393f66..0000000 --- a/.zprezto/modules/history-substring-search/external/zsh-history-substring-search.plugin.zsh +++ /dev/null @@ -1,12 +0,0 @@ -# This file integrates the zsh-history-substring-search script into oh-my-zsh. - -source "${0:r:r}.zsh" - -if test "$CASE_SENSITIVE" = true; then - unset HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS -fi - -if test "$DISABLE_COLOR" = true; then - unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND -fi diff --git a/.zprezto/modules/history-substring-search/external/zsh-history-substring-search.zsh b/.zprezto/modules/history-substring-search/external/zsh-history-substring-search.zsh index ad316ac..34c3df5 100644 --- a/.zprezto/modules/history-substring-search/external/zsh-history-substring-search.zsh +++ b/.zprezto/modules/history-substring-search/external/zsh-history-substring-search.zsh @@ -6,6 +6,7 @@ # Copyright (c) 2011 Suraj N. Kurapati # Copyright (c) 2011 Sorin Ionescu # Copyright (c) 2011 Vincent Guerci +# Copyright (c) 2016 Geza Lore # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -37,13 +38,35 @@ # ############################################################################## +#----------------------------------------------------------------------------- +# declare global variables +#----------------------------------------------------------------------------- + +typeset -g BUFFER MATCH MBEGIN MEND CURSOR +typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND +typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND +typeset -g HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS +typeset -g HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE +typeset -g _history_substring_search_refresh_display +typeset -g _history_substring_search_query_highlight +typeset -g _history_substring_search_result +typeset -g _history_substring_search_query +typeset -g -A _history_substring_search_raw_matches +typeset -g _history_substring_search_raw_match_index +typeset -g -A _history_substring_search_matches +typeset -g -A _history_substring_search_unique_filter +typeset -g _history_substring_search_match_index + #----------------------------------------------------------------------------- # configuration variables #----------------------------------------------------------------------------- -HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold' -HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold' -HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' +typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold' +typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold' +typeset -g HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' +typeset -g HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE='' +typeset -g _history_substring_search_{refresh_display,query_highlight,result,query,match_index,raw_match_index} +typeset -ga _history_substring_search{,_raw}_matches #----------------------------------------------------------------------------- # the main ZLE widgets @@ -180,13 +203,32 @@ _history-substring-search-begin() { _history_substring_search_query_highlight= # - # Continue using the previous $_history_substring_search_result by default, - # unless the current query was cleared or a new/different query was entered. + # If the buffer is the same as the previously displayed history substring + # search result, then just keep stepping through the match list. Otherwise + # start a new search. # - if [[ -z $BUFFER || $BUFFER != $_history_substring_search_result ]]; then + if [[ -n $BUFFER && $BUFFER == ${_history_substring_search_result:-} ]]; then + return; + fi + + # + # Clear the previous result. + # + _history_substring_search_result='' + + if [[ -z $BUFFER ]]; then # - # For the purpose of highlighting we will also keep - # a version without doubly-escaped meta characters. + # If the buffer is empty, we will just act like up-history/down-history + # in ZSH, so we do not need to actually search the history. This should + # speed things up a little. + # + _history_substring_search_query= + _history_substring_search_raw_matches=() + + else + # + # For the purpose of highlighting we keep a copy of the original + # query string. # _history_substring_search_query=$BUFFER @@ -195,47 +237,59 @@ _history-substring-search-begin() { # we put an extra "\\" before meta characters such as "\(" and "\)", # so that they become "\\\(" and "\\\)". # - _history_substring_search_query_escaped=${BUFFER//(#m)[\][()|\\*?#<>~^]/\\$MATCH} + local escaped_query=${BUFFER//(#m)[\][()|\\*?#<>~^]/\\$MATCH} # # Find all occurrences of the search query in the history file. # # (k) returns the "keys" (history index numbers) instead of the values - # (Oa) reverses the order, because (R) returns results reversed. + # (R) returns values in reverse older, so the index of the youngest + # matching history entry is at the head of the list. # - _history_substring_search_matches=(${(kOa)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)*${_history_substring_search_query_escaped}*]}) + _history_substring_search_raw_matches=(${(k)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)*${escaped_query}*]}) + fi - # - # Define the range of values that $_history_substring_search_match_index - # can take: [0, $_history_substring_search_matches_count_plus]. - # - _history_substring_search_matches_count=$#_history_substring_search_matches - _history_substring_search_matches_count_plus=$(( _history_substring_search_matches_count + 1 )) - _history_substring_search_matches_count_sans=$(( _history_substring_search_matches_count - 1 )) + # + # In order to stay as responsive as possible, we will process the raw + # matches lazily (when the user requests the next match) to choose items + # that need to be displayed to the user. + # _history_substring_search_raw_match_index holds the index of the last + # unprocessed entry in _history_substring_search_raw_matches. Any items + # that need to be displayed will be added to + # _history_substring_search_matches. + # + # We use an associative array (_history_substring_search_unique_filter) as + # a 'set' data structure to ensure uniqueness of the results if desired. + # If an entry (key) is in the set (non-empty value), then we have already + # added that entry to _history_substring_search_matches. + # + _history_substring_search_raw_match_index=0 + _history_substring_search_matches=() + unset _history_substring_search_unique_filter + typeset -A -g _history_substring_search_unique_filter - # - # If $_history_substring_search_match_index is equal to - # $_history_substring_search_matches_count_plus, this indicates that we - # are beyond the beginning of $_history_substring_search_matches. - # - # If $_history_substring_search_match_index is equal to 0, this indicates - # that we are beyond the end of $_history_substring_search_matches. - # - # If we have initially pressed "up" we have to initialize - # $_history_substring_search_match_index to - # $_history_substring_search_matches_count_plus so that it will be - # decreased to $_history_substring_search_matches_count. - # - # If we have initially pressed "down" we have to initialize - # $_history_substring_search_match_index to - # $_history_substring_search_matches_count so that it will be increased to - # $_history_substring_search_matches_count_plus. - # - if [[ $WIDGET == history-substring-search-down ]]; then - _history_substring_search_match_index=$_history_substring_search_matches_count - else - _history_substring_search_match_index=$_history_substring_search_matches_count_plus - fi + # + # If $_history_substring_search_match_index is equal to + # $#_history_substring_search_matches + 1, this indicates that we + # are beyond the end of $_history_substring_search_matches and that we + # have also processed all entries in + # _history_substring_search_raw_matches. + # + # If $#_history_substring_search_match_index is equal to 0, this indicates + # that we are beyond the beginning of $_history_substring_search_matches. + # + # If we have initially pressed "up" we have to initialize + # $_history_substring_search_match_index to 0 so that it will be + # incremented to 1. + # + # If we have initially pressed "down" we have to initialize + # $_history_substring_search_match_index to 1 so that it will be + # decremented to 0. + # + if [[ $WIDGET == history-substring-search-down ]]; then + _history_substring_search_match_index=1 + else + _history_substring_search_match_index=0 fi } @@ -244,7 +298,7 @@ _history-substring-search-end() { _history_substring_search_result=$BUFFER - # the search was succesful so display the result properly by clearing away + # the search was successful so display the result properly by clearing away # existing highlights and moving the cursor to the end of the result buffer if [[ $_history_substring_search_refresh_display -eq 1 ]]; then region_highlight=() @@ -259,7 +313,7 @@ _history-substring-search-end() { # # The following expression yields a variable $MBEGIN, which # indicates the begin position + 1 of the first occurrence - # of _history_substring_search_query_escaped in $BUFFER. + # of _history_substring_search_query in $BUFFER. # : ${(S)BUFFER##(#m$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)($_history_substring_search_query##)} local begin=$(( MBEGIN - 1 )) @@ -378,12 +432,143 @@ _history-substring-search-down-history() { return 1 } +_history_substring_search_process_raw_matches() { + # + # Process more outstanding raw matches and append any matches that need to + # be displayed to the user to _history_substring_search_matches. + # Return whether there were any more results appended. + # + + # + # While we have more raw matches. Process them to see if there are any more + # matches that need to be displayed to the user. + # + while [[ $_history_substring_search_raw_match_index -lt $#_history_substring_search_raw_matches ]]; do + # + # Move on to the next raw entry and get its history index. + # + (( _history_substring_search_raw_match_index++ )) + local index=${_history_substring_search_raw_matches[$_history_substring_search_raw_match_index]} + + # + # If HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE is set to a non-empty value, + # then ensure that only unique matches are presented to the user. + # When HIST_IGNORE_ALL_DUPS is set, ZSH already ensures a unique history, + # so in this case we do not need to do anything. + # + if [[ ! -o HIST_IGNORE_ALL_DUPS && -n $HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ]]; then + # + # Get the actual history entry at the new index, and check if we have + # already added it to _history_substring_search_matches. + # + local entry=${history[$index]} + + if [[ -z ${_history_substring_search_unique_filter[$entry]} ]]; then + # + # This is a new unique entry. Add it to the filter and append the + # index to _history_substring_search_matches. + # + _history_substring_search_unique_filter[$entry]=1 + _history_substring_search_matches+=($index) + + # + # Indicate that we did find a match. + # + return 0 + fi + + else + # + # Just append the new history index to the processed matches. + # + _history_substring_search_matches+=($index) + + # + # Indicate that we did find a match. + # + return 0 + fi + + done + + # + # We are beyond the end of the list of raw matches. Indicate that no + # more matches are available. + # + return 1 +} + +_history-substring-search-has-next() { + # + # Predicate function that returns whether any more older matches are + # available. + # + + if [[ $_history_substring_search_match_index -lt $#_history_substring_search_matches ]]; then + # + # We did not reach the end of the processed list, so we do have further + # matches. + # + return 0 + + else + # + # We are at the end of the processed list. Try to process further + # unprocessed matches. _history_substring_search_process_raw_matches + # returns whether any more matches were available, so just return + # that result. + # + _history_substring_search_process_raw_matches + return $? + fi +} + +_history-substring-search-has-prev() { + # + # Predicate function that returns whether any more younger matches are + # available. + # + + if [[ $_history_substring_search_match_index -gt 1 ]]; then + # + # We did not reach the beginning of the processed list, so we do have + # further matches. + # + return 0 + + else + # + # We are at the beginning of the processed list. We do not have any more + # matches. + # + return 1 + fi +} + +_history-substring-search-found() { + # + # A match is available. The index of the match is held in + # $_history_substring_search_match_index + # + # 1. Make $BUFFER equal to the matching history entry. + # + # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND + # to highlight the current buffer. + # + BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]] + _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND +} + _history-substring-search-not-found() { # - # Nothing matched the search query, so put it back into the $BUFFER while - # highlighting it accordingly so the user can revise it and search again. + # No more matches are available. + # + # 1. Make $BUFFER equal to $_history_substring_search_query so the user can + # revise it and search again. + # + # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND + # to highlight the current buffer. # - _history_substring_search_old_buffer=$BUFFER BUFFER=$_history_substring_search_query _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND } @@ -392,91 +577,84 @@ _history-substring-search-up-search() { _history_substring_search_refresh_display=1 # - # Highlight matches during history-substring-up-search: + # Select history entry during history-substring-down-search: # - # The following constants have been initialized in + # The following variables have been initialized in # _history-substring-search-up/down-search(): # - # $_history_substring_search_matches is the current list of matches - # $_history_substring_search_matches_count is the current number of matches - # $_history_substring_search_matches_count_plus is the current number of matches + 1 - # $_history_substring_search_matches_count_sans is the current number of matches - 1 + # $_history_substring_search_matches is the current list of matches that + # need to be displayed to the user. # $_history_substring_search_match_index is the index of the current match + # that is being displayed to the user. # # The range of values that $_history_substring_search_match_index can take - # is: [0, $_history_substring_search_matches_count_plus]. A value of 0 - # indicates that we are beyond the end of + # is: [0, $#_history_substring_search_matches + 1]. A value of 0 + # indicates that we are beyond the beginning of # $_history_substring_search_matches. A value of - # $_history_substring_search_matches_count_plus indicates that we are beyond - # the beginning of $_history_substring_search_matches. + # $#_history_substring_search_matches + 1 indicates that we are beyond + # the end of $_history_substring_search_matches and that we have also + # processed all entries in _history_substring_search_raw_matches. + # + # If $_history_substring_search_match_index equals + # $#_history_substring_search_matches and + # $_history_substring_search_raw_match_index is not greater than + # $#_history_substring_search_raw_matches, then we need to further process + # $_history_substring_search_raw_matches to see if there are any more + # entries that need to be displayed to the user. # # In _history-substring-search-up-search() the initial value of - # $_history_substring_search_match_index is - # $_history_substring_search_matches_count_plus. This value is set in - # _history-substring-search-begin(). _history-substring-search-up-search() - # will initially decrease it to $_history_substring_search_matches_count. + # $_history_substring_search_match_index is 0. This value is set in + # _history-substring-search-begin(). _history-substring-search-up-search() + # will initially increment it to 1. # - if [[ $_history_substring_search_match_index -ge 2 ]]; then - # - # Highlight the next match: - # - # 1. Decrease the value of $_history_substring_search_match_index. - # - # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index-- )) - BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]] - _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - elif [[ $_history_substring_search_match_index -eq 1 ]]; then + if [[ $_history_substring_search_match_index -gt $#_history_substring_search_matches ]]; then # - # We will move beyond the end of $_history_substring_search_matches: + # We are beyond the end of $_history_substring_search_matches. This + # can only happen if we have also exhausted the unprocessed matches in + # _history_substring_search_raw_matches. # - # 1. Decrease the value of $_history_substring_search_match_index. - # - # 2. Save the current buffer in $_history_substring_search_old_buffer, - # so that it can be retrieved by - # _history-substring-search-down-search() later. - # - # 3. Make $BUFFER equal to $_history_substring_search_query. - # - # 4. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index-- )) - _history-substring-search-not-found - - elif [[ $_history_substring_search_match_index -eq $_history_substring_search_matches_count_plus ]]; then - # - # We were beyond the beginning of $_history_substring_search_matches but - # UP makes us move back to $_history_substring_search_matches: - # - # 1. Decrease the value of $_history_substring_search_match_index. - # - # 2. Restore $BUFFER from $_history_substring_search_old_buffer. - # - # 3. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index-- )) - BUFFER=$_history_substring_search_old_buffer - _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - - else - # - # We are at the beginning of history and there are no further matches. + # 1. Update display to indicate search not found. # _history-substring-search-not-found return fi + if _history-substring-search-has-next; then + # + # We do have older matches. + # + # 1. Move index to point to the next match. + # 2. Update display to indicate search found. + # + (( _history_substring_search_match_index++ )) + _history-substring-search-found + + else + # + # We do not have older matches. + # + # 1. Move the index beyond the end of + # _history_substring_search_matches. + # 2. Update display to indicate search not found. + # + (( _history_substring_search_match_index++ )) + _history-substring-search-not-found + fi + # # When HIST_FIND_NO_DUPS is set, meaning that only unique command lines from # history should be matched, make sure the new and old results are different. - # But when HIST_IGNORE_ALL_DUPS is set, ZSH already ensures a unique history. # - if [[ ! -o HIST_IGNORE_ALL_DUPS && -o HIST_FIND_NO_DUPS && $BUFFER == $_history_substring_search_result ]]; then + # However, if the HIST_IGNORE_ALL_DUPS shell option, or + # HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE is set, then we already have a + # unique history, so in this case we do not need to do anything. + # + if [[ -o HIST_IGNORE_ALL_DUPS || -n $HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ]]; then + return + fi + + if [[ -o HIST_FIND_NO_DUPS && $BUFFER == $_history_substring_search_result ]]; then # # Repeat the current search so that a different (unique) match is found. # @@ -488,92 +666,75 @@ _history-substring-search-down-search() { _history_substring_search_refresh_display=1 # - # Highlight matches during history-substring-up-search: + # Select history entry during history-substring-down-search: # - # The following constants have been initialized in + # The following variables have been initialized in # _history-substring-search-up/down-search(): # - # $_history_substring_search_matches is the current list of matches - # $_history_substring_search_matches_count is the current number of matches - # $_history_substring_search_matches_count_plus is the current number of matches + 1 - # $_history_substring_search_matches_count_sans is the current number of matches - 1 + # $_history_substring_search_matches is the current list of matches that + # need to be displayed to the user. # $_history_substring_search_match_index is the index of the current match + # that is being displayed to the user. # # The range of values that $_history_substring_search_match_index can take - # is: [0, $_history_substring_search_matches_count_plus]. A value of 0 - # indicates that we are beyond the end of + # is: [0, $#_history_substring_search_matches + 1]. A value of 0 + # indicates that we are beyond the beginning of # $_history_substring_search_matches. A value of - # $_history_substring_search_matches_count_plus indicates that we are beyond - # the beginning of $_history_substring_search_matches. + # $#_history_substring_search_matches + 1 indicates that we are beyond + # the end of $_history_substring_search_matches and that we have also + # processed all entries in _history_substring_search_raw_matches. # # In _history-substring-search-down-search() the initial value of - # $_history_substring_search_match_index is - # $_history_substring_search_matches_count. This value is set in - # _history-substring-search-begin(). - # _history-substring-search-down-search() will initially increase it to - # $_history_substring_search_matches_count_plus. + # $_history_substring_search_match_index is 1. This value is set in + # _history-substring-search-begin(). _history-substring-search-down-search() + # will initially decrement it to 0. # - if [[ $_history_substring_search_match_index -le $_history_substring_search_matches_count_sans ]]; then - # - # Highlight the next match: - # - # 1. Increase $_history_substring_search_match_index by 1. - # - # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index++ )) - BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]] - _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - elif [[ $_history_substring_search_match_index -eq $_history_substring_search_matches_count ]]; then + if [[ $_history_substring_search_match_index -lt 1 ]]; then # - # We will move beyond the beginning of $_history_substring_search_matches: + # We are beyond the beginning of $_history_substring_search_matches. # - # 1. Increase $_history_substring_search_match_index by 1. - # - # 2. Save the current buffer in $_history_substring_search_old_buffer, so - # that it can be retrieved by _history-substring-search-up-search() - # later. - # - # 3. Make $BUFFER equal to $_history_substring_search_query. - # - # 4. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index++ )) - _history-substring-search-not-found - - elif [[ $_history_substring_search_match_index -eq 0 ]]; then - # - # We were beyond the end of $_history_substring_search_matches but DOWN - # makes us move back to the $_history_substring_search_matches: - # - # 1. Increase $_history_substring_search_match_index by 1. - # - # 2. Restore $BUFFER from $_history_substring_search_old_buffer. - # - # 3. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index++ )) - BUFFER=$_history_substring_search_old_buffer - _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - - else - # - # We are at the end of history and there are no further matches. + # 1. Update display to indicate search not found. # _history-substring-search-not-found return fi + if _history-substring-search-has-prev; then + # + # We do have younger matches. + # + # 1. Move index to point to the previous match. + # 2. Update display to indicate search found. + # + (( _history_substring_search_match_index-- )) + _history-substring-search-found + + else + # + # We do not have younger matches. + # + # 1. Move the index beyond the beginning of + # _history_substring_search_matches. + # 2. Update display to indicate search not found. + # + (( _history_substring_search_match_index-- )) + _history-substring-search-not-found + fi + # # When HIST_FIND_NO_DUPS is set, meaning that only unique command lines from # history should be matched, make sure the new and old results are different. - # But when HIST_IGNORE_ALL_DUPS is set, ZSH already ensures a unique history. # - if [[ ! -o HIST_IGNORE_ALL_DUPS && -o HIST_FIND_NO_DUPS && $BUFFER == $_history_substring_search_result ]]; then + # However, if the HIST_IGNORE_ALL_DUPS shell option, or + # HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE is set, then we already have a + # unique history, so in this case we do not need to do anything. + # + if [[ -o HIST_IGNORE_ALL_DUPS || -n $HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ]]; then + return + fi + + if [[ -o HIST_FIND_NO_DUPS && $BUFFER == $_history_substring_search_result ]]; then # # Repeat the current search so that a different (unique) match is found. # diff --git a/.zprezto/modules/history-substring-search/init.zsh b/.zprezto/modules/history-substring-search/init.zsh index 67990a3..d3ee3a1 100644 --- a/.zprezto/modules/history-substring-search/init.zsh +++ b/.zprezto/modules/history-substring-search/init.zsh @@ -54,4 +54,6 @@ if [[ -n "$key_info" ]]; then bindkey -M "$keymap" "$key_info[Up]" history-substring-search-up bindkey -M "$keymap" "$key_info[Down]" history-substring-search-down done + + unset keymap fi diff --git a/.zprezto/modules/homebrew/README.md b/.zprezto/modules/homebrew/README.md index 84b4386..98a3444 100644 --- a/.zprezto/modules/homebrew/README.md +++ b/.zprezto/modules/homebrew/README.md @@ -12,8 +12,9 @@ Aliases - `brewC` cleans outdated brews, including keg-only, and their cached archives. - `brewi` installs a formula. - `brewl` lists installed formulae. + - `brewo` lists brews which have an update available. - `brews` searches for a formula. - - `brewu` updates Homebrew and formulae. + - `brewu` updates and upgrades Homebrew packages and formulae. - `brewx` uninstalls a formula. ### Homebrew Cask @@ -23,6 +24,7 @@ Aliases - `caskC` cleans up all cached downloads. - `caski` installs a cask. - `caskl` lists installed casks. + - `casko` lists casks which have an update available. - `casks` searches for a cask. - `caskx` uninstalls a cask. diff --git a/.zprezto/modules/homebrew/init.zsh b/.zprezto/modules/homebrew/init.zsh index 1ebe793..e517c0a 100644 --- a/.zprezto/modules/homebrew/init.zsh +++ b/.zprezto/modules/homebrew/init.zsh @@ -19,8 +19,9 @@ alias brewc='brew cleanup' alias brewC='brew cleanup --force' alias brewi='brew install' alias brewl='brew list' +alias brewo='brew outdated' alias brews='brew search' -alias brewu='brew update && brew upgrade --all' +alias brewu='brew update && brew upgrade' alias brewx='brew remove' # Homebrew Cask @@ -29,5 +30,6 @@ alias caskc='brew cask cleanup --outdated' alias caskC='brew cask cleanup' alias caski='brew cask install' alias caskl='brew cask list' +alias casko='brew cask outdated' alias casks='brew cask search' alias caskx='brew cask uninstall' diff --git a/.zprezto/modules/node/README.md b/.zprezto/modules/node/README.md index 5f0c3ca..951f2a7 100644 --- a/.zprezto/modules/node/README.md +++ b/.zprezto/modules/node/README.md @@ -10,6 +10,13 @@ nvm [nvm][5] allows for managing multiple, isolated Node.js installations in the home directory. +nodenv +------ + +[nodenv][6] does one thing well. nodenv is concerned solely with switching +Node versions. It's simple and predictable, Just Works, and is rock solid in +production. nodenv is forked from the popular [rbenv][7]. + Functions --------- @@ -24,8 +31,10 @@ Theming To display the version number of the current Node.js version, define the following style inside the `prompt_name_setup` function. - # %v - Node.js version. - zstyle ':prezto:module:node:info:version' format 'version:%v' +```sh +# %v - Node.js version. +zstyle ':prezto:module:node:info:version' format 'version:%v' +``` Then add `$node_info[version]` to either `$PROMPT` or `$RPROMPT` and call `node-info` in `prompt_name_preexec` hook function. @@ -43,3 +52,5 @@ Authors [3]: http://nodejs.org/api [4]: https://github.com/sorin-ionescu/prezto/issues [5]: https://github.com/creationix/nvm +[6]: https://github.com/nodenv/nodenv +[7]: https://github.com/sstephenson/rbenv diff --git a/.zprezto/modules/node/functions/node-doc b/.zprezto/modules/node/functions/node-doc index 24f5641..b1a048b 100644 --- a/.zprezto/modules/node/functions/node-doc +++ b/.zprezto/modules/node/functions/node-doc @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function node-doc { + if [[ -z "$BROWSER" ]]; then print "$0: no web browser defined" >&2 return 1 @@ -12,3 +14,5 @@ fi # TODO: Make the sections easier to use. "$BROWSER" "http://nodejs.org/docs/$(node --version | sed 's/-.*//')/api/all.html#${1}" + +# } diff --git a/.zprezto/modules/node/functions/node-info b/.zprezto/modules/node/functions/node-info index 7742f90..9feca3e 100644 --- a/.zprezto/modules/node/functions/node-info +++ b/.zprezto/modules/node/functions/node-info @@ -6,6 +6,8 @@ # Zeh Rizzatti # +# function node-info { + local version local version_format local version_formatted @@ -15,6 +17,10 @@ typeset -gA node_info if (( $+functions[nvm_version] )); then version="${$(nvm_version)#v}" +elif (( $+commands[nodenv] )); then + version="${${$(nodenv version)#v}[(w)0]}" +elif (( $+commands[node] )) ; then + version="${$(node -v)#v}" fi if [[ "$version" != (none|) ]]; then @@ -22,3 +28,5 @@ if [[ "$version" != (none|) ]]; then zformat -f version_formatted "$version_format" "v:$version" node_info[version]="$version_formatted" fi + +# } diff --git a/.zprezto/modules/node/init.zsh b/.zprezto/modules/node/init.zsh index 6d60078..0a516f0 100644 --- a/.zprezto/modules/node/init.zsh +++ b/.zprezto/modules/node/init.zsh @@ -11,8 +11,17 @@ if [[ -s "$HOME/.nvm/nvm.sh" ]]; then source "$HOME/.nvm/nvm.sh" # Load package manager installed NVM into the shell session. -elif (( $+commands[brew] )) && [[ -d "$(brew --prefix nvm 2>/dev/null)" ]]; then - source $(brew --prefix nvm)/nvm.sh +elif (( $+commands[brew] )) && [[ -d "$(brew --prefix nvm 2> /dev/null)" ]]; then + source "$(brew --prefix nvm)/nvm.sh" + +# Load manually installed nodenv into the shell session. +elif [[ -s "$HOME/.nodenv/bin/nodenv" ]]; then + path=("$HOME/.nodenv/bin" $path) + eval "$(nodenv init - --no-rehash zsh)" + +# Load package manager installed nodenv into the shell session. +elif (( $+commands[nodenv] )); then + eval "$(nodenv init - --no-rehash zsh)" # Return if requirements are not found. elif (( ! $+commands[node] )); then @@ -21,9 +30,11 @@ fi # Load NPM completion. if (( $+commands[npm] )); then - cache_file="${0:h}/cache.zsh" + cache_file="${TMPDIR:-/tmp}/prezto-node-cache.$UID.zsh" - if [[ "$commands[npm]" -nt "$cache_file" || ! -s "$cache_file" ]]; then + if [[ "$commands[npm]" -nt "$cache_file" \ + || "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" \ + || ! -s "$cache_file" ]]; then # npm is slow; cache its output. npm completion >! "$cache_file" 2> /dev/null fi diff --git a/.zprezto/modules/osx/README.md b/.zprezto/modules/osx/README.md index d8eff0f..1f93a2c 100644 --- a/.zprezto/modules/osx/README.md +++ b/.zprezto/modules/osx/README.md @@ -1,7 +1,20 @@ OSX === -Defines [Mac OS X][1] aliases and functions. +Defines [macOS][1] aliases and functions. + +Settings +-------- + +### Dash Keyword + +To change the keyword used by `mand` to open man pages in [_Dash.app_][2] from +its default value of 'manpages', add the following line in *zpreztorc* and +replace the **keyword** with the one configured in [_Dash.app_][2]. + +```sh +zstyle ':prezto:module:osx:man' dash-keyword 'keyword' +``` Aliases ------- @@ -21,8 +34,8 @@ Functions - `tab` creates a new tab (works in both _Terminal_ and [_iTerm_][3]). - `ql` previews files in Quick Look. - `osx-rm-dir-metadata` deletes .DS\_Store, \_\_MACOSX cruft. - - `osx-ls-download-history` displays the Mac OS X download history. - - `osx-rm-download-history` deletes the Mac OS X download history. + - `osx-ls-download-history` displays the macOS download history. + - `osx-rm-download-history` deletes the macOS download history. Authors ------- diff --git a/.zprezto/modules/osx/functions/_manb_mand_manp b/.zprezto/modules/osx/functions/_mand_manp similarity index 100% rename from .zprezto/modules/osx/functions/_manb_mand_manp rename to .zprezto/modules/osx/functions/_mand_manp diff --git a/.zprezto/modules/osx/functions/mand b/.zprezto/modules/osx/functions/mand index 7a9653a..2902c76 100644 --- a/.zprezto/modules/osx/functions/mand +++ b/.zprezto/modules/osx/functions/mand @@ -7,7 +7,8 @@ function mand { if (( $# > 0 )); then - open "dash://manpages:$1" 2>/dev/null + zstyle -s ':prezto:module:osx:man' dash-keyword 'dashkw' || dashkw='manpages' + open "dash://$dashkw:$1" 2> /dev/null if (( $? != 0 )); then print "$0: Dash is not installed" >&2 break @@ -15,6 +16,8 @@ function mand { else print 'What manual page do you want?' >&2 fi + + unset dashkw } mand "$@" diff --git a/.zprezto/modules/osx/functions/osx-ls-download-history b/.zprezto/modules/osx/functions/osx-ls-download-history index 5727c1b..8b6eaab 100644 --- a/.zprezto/modules/osx/functions/osx-ls-download-history +++ b/.zprezto/modules/osx/functions/osx-ls-download-history @@ -1,13 +1,17 @@ # -# Displays the Mac OS X download history. +# Displays the macOS download history. # # Authors: # Sorin Ionescu # +# function osx-ls-download-history { + local db for db in ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV*; do if grep -q 'LSQuarantineEvent' < <(sqlite3 "$db" .tables); then sqlite3 "$db" 'SELECT LSQuarantineDataURLString FROM LSQuarantineEvent' fi done + +# } diff --git a/.zprezto/modules/osx/functions/osx-rm-dir-metadata b/.zprezto/modules/osx/functions/osx-rm-dir-metadata index 0a91ced..f15f4ed 100644 --- a/.zprezto/modules/osx/functions/osx-rm-dir-metadata +++ b/.zprezto/modules/osx/functions/osx-rm-dir-metadata @@ -5,7 +5,11 @@ # Sorin Ionescu # +# function osx-rm-dir-metadata { + find "${@:-$PWD}" \( \ -type f -name '.DS_Store' -o \ -type d -name '__MACOSX' \ \) -print0 | xargs -0 rm -rf + +# } diff --git a/.zprezto/modules/osx/functions/osx-rm-download-history b/.zprezto/modules/osx/functions/osx-rm-download-history index 3837709..068ba3d 100644 --- a/.zprezto/modules/osx/functions/osx-rm-download-history +++ b/.zprezto/modules/osx/functions/osx-rm-download-history @@ -1,13 +1,17 @@ # -# Deletes the Mac OS X download history. +# Deletes the macOS download history. # # Authors: # Sorin Ionescu # +# function osx-rm-download-history { + local db for db in ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV*; do if grep -q 'LSQuarantineEvent' < <(sqlite3 "$db" .tables); then sqlite3 "$db" 'DELETE FROM LSQuarantineEvent; VACUUM' fi done + +# } diff --git a/.zprezto/modules/osx/functions/pfd b/.zprezto/modules/osx/functions/pfd index a4d4b68..264b40b 100644 --- a/.zprezto/modules/osx/functions/pfd +++ b/.zprezto/modules/osx/functions/pfd @@ -5,8 +5,12 @@ # Sorin Ionescu # -osascript 2>/dev/null < /dev/null < # +# function pfs { + osascript 2>&1 <&1 < # +# function ql { + if (( $# > 0 )); then qlmanage -p "$@" &> /dev/null fi + +# } diff --git a/.zprezto/modules/osx/functions/tab b/.zprezto/modules/osx/functions/tab index e95afbf..c39a6a8 100644 --- a/.zprezto/modules/osx/functions/tab +++ b/.zprezto/modules/osx/functions/tab @@ -5,11 +5,13 @@ # Sorin Ionescu # +# function tab { + local command="cd \\\"$PWD\\\"" (( $# > 0 )) && command="${command}; $*" the_app=$( - osascript 2>/dev/null < /dev/null </dev/null < /dev/null </dev/null < /dev/null < /dev/null < diff --git a/.zprezto/modules/pacman/README.md b/.zprezto/modules/pacman/README.md index fb07407..a619a74 100644 --- a/.zprezto/modules/pacman/README.md +++ b/.zprezto/modules/pacman/README.md @@ -7,17 +7,22 @@ frontends. Settings -------- -To enable a Pacman frontend, for example, [Yaourt][2], add the following line to -*zpreztorc*: +It is possible to use a Pacman frontend with the pacman aliases provided by this +package as long as that frontend supports the same command line options (The +[AUR Helpers][2] page has a good comparison which lists if the command line +options are pacman compatible). - zstyle ':prezto:module:pacman' frontend 'yaourt' +Please note that installing packages with an AUR Helper is not officially +supported by Archlinux. It is currently recommended to manually build AUR +packages using the [provided instructions][3]. The [aurutils][4] project has a +set of small utilities to make this easier. -If you have enabled color globally in *zpreztorc*, you may disable it for certain -commands. +To enable a Pacman frontend, add the following line to *zpreztorc*, substituting +`pacman_frontend` with the name of the frontent: -To disable `yaourt` highlighting, add the following line to *zpreztorc*: - - zstyle ':prezto:module:pacman:yaourt' color 'no' +```sh +zstyle ':prezto:module:pacman' frontend 'pacman_frontend' +``` Aliases ------- @@ -42,24 +47,23 @@ Aliases ### Frontends -#### Yaourt - - - `pacc` manages *.pac\** files. - Functions --------- + - `aurget` clone an aur package - `pacman-list-explicit` lists explicitly installed pacman packages. - `pacman-list-disowned` lists pacman disowned files. Authors ------- -*The authors of this module should be contacted via the [issue tracker][3].* +*The authors of this module should be contacted via the [issue tracker][5].* - [Benjamin Boudreau](https://github.com/dreur) - [Sorin Ionescu](https://github.com/sorin-ionescu) [1]: http://www.archlinux.org/pacman/ -[2]: http://archlinux.fr/yaourt-en -[3]: https://github.com/sorin-ionescu/prezto/issues +[2]: https://wiki.archlinux.org/index.php/AUR_helpers#Comparison_table +[3]: https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packages +[4]: https://github.com/AladW/aurutils +[5]: https://github.com/sorin-ionescu/prezto/issues diff --git a/.zprezto/modules/pacman/functions/pacman-list-disowned b/.zprezto/modules/pacman/functions/pacman-list-disowned index a097c9d..9c8f56a 100644 --- a/.zprezto/modules/pacman/functions/pacman-list-disowned +++ b/.zprezto/modules/pacman/functions/pacman-list-disowned @@ -6,6 +6,8 @@ # Sorin Ionescu # +# function pacman-list-disowned { + local tmp="${TMPDIR:-/tmp}/pacman-disowned-$UID-$$" local db="$tmp/db" local fs="$tmp/fs" @@ -20,3 +22,5 @@ find /bin /etc /lib /sbin /usr \ \( -type d -printf '%p/\n' -o -print \) | sort > "$fs" comm -23 "$fs" "$db" + +# } diff --git a/.zprezto/modules/pacman/functions/pacman-list-explicit b/.zprezto/modules/pacman/functions/pacman-list-explicit index 2967834..7c9b08f 100644 --- a/.zprezto/modules/pacman/functions/pacman-list-explicit +++ b/.zprezto/modules/pacman/functions/pacman-list-explicit @@ -6,6 +6,8 @@ # Sorin Ionescu # +# function pacman-list-explicit { + pacman --query --explicit --info \ | awk ' BEGIN { @@ -18,3 +20,5 @@ pacman --query --explicit --info \ print $2 } ' + +# } diff --git a/.zprezto/modules/pacman/init.zsh b/.zprezto/modules/pacman/init.zsh index 9d752a9..88c977f 100644 --- a/.zprezto/modules/pacman/init.zsh +++ b/.zprezto/modules/pacman/init.zsh @@ -23,10 +23,6 @@ zstyle -s ':prezto:module:pacman' frontend '_pacman_frontend' if (( $+commands[$_pacman_frontend] )); then alias pacman="$_pacman_frontend" - - if [[ -s "${0:h}/${_pacman_frontend}.zsh" ]]; then - source "${0:h}/${_pacman_frontend}.zsh" - fi else _pacman_frontend='pacman' _pacman_sudo='sudo ' @@ -70,9 +66,9 @@ alias pacman-list-orphans="${_pacman_sudo}${_pacman_frontend} --query --deps --u alias pacman-remove-orphans="${_pacman_sudo}${_pacman_frontend} --remove --recursive \$(${_pacman_frontend} --quiet --query --deps --unrequired)" # Synchronizes the local package and Arch Build System databases against the -# repositories. -if (( $+commands[abs] )); then - alias pacu="${_pacman_sudo}${_pacman_frontend} --sync --refresh && sudo abs" +# repositories using the asp tool. +if (( $+commands[asp] )); then + alias pacu="${_pacman_sudo}${_pacman_frontend} --sync --refresh && sudo asp update" else alias pacu="${_pacman_sudo}${_pacman_frontend} --sync --refresh" fi @@ -81,4 +77,12 @@ fi # upgrades outdated packages. alias pacU="${_pacman_sudo}${_pacman_frontend} --sync --refresh --sysupgrade" +function aurget { + local target_dir="$1" + if [[ -n "$2" ]]; then + target_dir="$2" + fi + git clone "https://aur.archlinux.org/$1" "$target_dir" +} + unset _pacman_{frontend,sudo} diff --git a/.zprezto/modules/pacman/yaourt.zsh b/.zprezto/modules/pacman/yaourt.zsh deleted file mode 100644 index 819fad1..0000000 --- a/.zprezto/modules/pacman/yaourt.zsh +++ /dev/null @@ -1,18 +0,0 @@ -# -# Defines Yaourt aliases. -# -# Authors: -# Sorin Ionescu -# - -# -# Aliases -# - -# Disable color. -if ! zstyle -t ':prezto:module:pacman:yaourt' color; then - alias pacman='yaourt --nocolor' -fi - -# Manages .pac* files. -alias pacc='yaourt -C' diff --git a/.zprezto/modules/perl/README.md b/.zprezto/modules/perl/README.md index 90af1eb..67f2a17 100644 --- a/.zprezto/modules/perl/README.md +++ b/.zprezto/modules/perl/README.md @@ -1,28 +1,32 @@ Perl ==== -Enables local [Perl][1] module installation on Mac OS X and defines aliases. +Enables local [Perl][1] module installation on macOS and defines aliases. Local Module Installation ------------------------- Perl versions older than 5.14 do not support the local installation of Perl modules natively. This module allows for local installation of Perl modules on -Mac OS X in *~/Library/Perl/5.12* by altering the environment. +macOS in *~/Library/Perl/5.12* by altering the environment. ### Usage For Perl versions older than 5.14, install *local::lib*. - curl -L -C - -O http://search.cpan.org/CPAN/authors/id/A/AP/APEIRON/local-lib-1.008004.tar.gz - tar xvf local-lib-1.008004.tar.gz - cd local-lib-1.008004 - perl Makefile.PL --bootstrap=$HOME/Library/Perl/5.12 - make && make test && make install +```console +curl -L -C - -O http://search.cpan.org/CPAN/authors/id/A/AP/APEIRON/local-lib-1.008004.tar.gz +tar xvf local-lib-1.008004.tar.gz +cd local-lib-1.008004 +perl Makefile.PL --bootstrap=$HOME/Library/Perl/5.12 +make && make test && make install +``` Install *cpanminus*: - curl -L http://cpanmin.us | perl - --self-upgrade +```console +curl -L http://cpanmin.us | perl - --self-upgrade +``` Perlbrew -------- @@ -30,6 +34,14 @@ Perlbrew An alternative to the above is to use [Perlbrew][2], which allows for the management of multiple, isolated Perl installations in the home directory. +plenv +----- + +Yet another alternative is [plenv][3]. This is inspired from rbenv and enables +switching between multiple binary installations. + +The subcommands of plenv is similar with rbenv. + Aliases ------- @@ -51,13 +63,52 @@ Aliases - `plbu` uninstalls a Perl version. - `plbx` temporarily sets the Perl version to use. +### plenv + + - `plv` manages Perl environments. + - `plvc` List all available plenv commands. + - `plvl` Set or show the local application-specific Perl version. + - `plvg` Set or show the global Perl version. + - `plvs` Set or show the shell-specific Perl version. + - `plvi` Install a Perl version using the perl-build plugin. + - `plvu` Uninstall a specific Perl version. + - `plvr` Rehash plenv shims (run this after installing executables). + - `plvv` Show the current Perl version and its origin. + - `plvV` List all Perl versions available to plenv. + - `plvw` Display the full path to an executable. + - `plvW` List all Perl versions that contain the given executable. + - `plvm` List cpan modules in current perl. + - `plvM` Migrate cpan modules from other version. + - `plvI` Install cpanm. + +Functions +--------- + + - `perl-info` exposes information about the Perl environment via the + `$perl_info` associative array. + +Theming +------- + +To display the name of the current Perl version in a prompt, define the +following style in the `prompt_name_setup` function. + +```sh +# %v - perl version. +zstyle ':prezto:module:perl:info:version' format 'version:%v' +``` + +Then add `$perl_info[version]` to `$PROMPT` or `$RPROMPT` and call +`perl-info` in the `prompt_name_precmd` hook function. + Authors ------- -*The authors of this module should be contacted via the [issue tracker][3].* +*The authors of this module should be contacted via the [issue tracker][4].* - [Sorin Ionescu](https://github.com/sorin-ionescu) [1]: http://www.perl.org [2]: http://perlbrew.pl -[3]: https://github.com/sorin-ionescu/prezto/issues +[3]: https://github.com/tokuhirom/plenv +[4]: https://github.com/sorin-ionescu/prezto/issues diff --git a/.zprezto/modules/perl/functions/perl-info b/.zprezto/modules/perl/functions/perl-info new file mode 100644 index 0000000..b42e23d --- /dev/null +++ b/.zprezto/modules/perl/functions/perl-info @@ -0,0 +1,34 @@ +# +# Exposes information about the Perl environment via the $perl_info associative +# array. +# +# Authors: +# JINNOUCHI Yasushi +# + +# function perl-info { + +local version +local version_format +local version_formatted + +# Clean up previous $perl_info. +unset perl_info +typeset -gA perl_info + +if (( $+commands[perlbrew] )); then + version="${PERLBREW_PERL##*perl-}" +elif (( $+commands[plenv] )); then + version=$(plenv version-name) +elif (( $+commands[perl] )); then + version=$(perl -e 'printf "%vd", $^V') +fi + +# Format version. +if [[ -n "$version" ]]; then + zstyle -s ':prezto:module:perl:info:version' format 'version_format' + zformat -f version_formatted "$version_format" "v:$version" + perl_info[version]="$version_formatted" +fi + +# } diff --git a/.zprezto/modules/perl/init.zsh b/.zprezto/modules/perl/init.zsh index a8d5603..b7a7947 100644 --- a/.zprezto/modules/perl/init.zsh +++ b/.zprezto/modules/perl/init.zsh @@ -1,5 +1,5 @@ # -# Enables local Perl module installation on Mac OS X and defines aliases. +# Enables local Perl module installation on macOS and defines aliases. # # Authors: # Sorin Ionescu @@ -10,25 +10,47 @@ if (( ! $+commands[perl] )); then return 1 fi +# +# Load Perlbrew or plenv +# + +# Load Perlbrew into the shell session. +if [[ -s "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}/etc/bashrc" ]]; then + source "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}/etc/bashrc" + + # Load Perlbrew completion. + if [[ -s "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}/etc/perlbrew-completion.bash" ]]; then + source "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}/etc/perlbrew-completion.bash" + fi + +# Load manually installed plenv into the shell session. +elif [[ -s "$HOME/.plenv/bin/plenv" ]]; then + path=("$HOME/.plenv/bin" $path) + eval "$(plenv init - --no-rehash zsh)" + +# Load package manager installed plenv into the shell session. +elif (( $+commands[plenv] )); then + eval "$(plenv init - --no-rehash zsh)" +fi + # # Local Module Installation # if [[ "$OSTYPE" == darwin* ]]; then # Perl is slow; cache its output. - cache_file="${0:h}/cache.zsh" + cache_file="${TMPDIR:-/tmp}/prezto-perl-cache.$UID.zsh" perl_path="$HOME/Library/Perl/5.12" if [[ -f "$perl_path/lib/perl5/local/lib.pm" ]]; then - if [[ ! -s "$cache_file" ]]; then + if [[ "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" || ! -s "$cache_file" ]]; then perl -I$perl_path/lib/perl5 -Mlocal::lib=$perl_path >! "$cache_file" fi source "$cache_file" fi - unset perl_path - unset cache_file + unset cache_file perl_path fi # @@ -41,12 +63,31 @@ alias pld='perldoc' alias ple='perl -wlne' # Perlbrew -alias plb='perlbrew' -alias plba='perlbrew available' -alias plbi='perlbrew install' -alias plbl='perlbrew list' -alias plbo='perlbrew off' -alias plbO='perlbrew switch-off' -alias plbs='perlbrew switch' -alias plbu='perlbrew use' -alias plbx='perlbrew uninstall' +if (( $+commands[perlbrew] )); then + alias plb='perlbrew' + alias plba='perlbrew available' + alias plbi='perlbrew install' + alias plbl='perlbrew list' + alias plbo='perlbrew off' + alias plbO='perlbrew switch-off' + alias plbs='perlbrew switch' + alias plbu='perlbrew use' + alias plbx='perlbrew uninstall' + +elif (( $+commands[plenv] )); then + alias plv='plenv' + alias plvc='plenv commands' + alias plvl='plenv local' + alias plvg='plenv global' + alias plvs='plenv shell' + alias plvi='plenv install' + alias plvu='plenv uninstall' + alias plvr='plenv rehash' + alias plvv='plenv version' + alias plvV='plenv versions' + alias plvw='plenv which' + alias plvW='plenv whence' + alias plvm='plenv list-modules' + alias plvM='plenv migrate-modules' + alias plvI='plenv install-cpanm' +fi diff --git a/.zprezto/modules/prompt/README.md b/.zprezto/modules/prompt/README.md index dc02497..523c83e 100644 --- a/.zprezto/modules/prompt/README.md +++ b/.zprezto/modules/prompt/README.md @@ -6,11 +6,34 @@ Loads prompt [themes][1]. Settings -------- +### Prompt Theme + To select a prompt theme, add the following to *zpreztorc*, and replace **name** with the name of the theme you wish to load. Setting it to **random** will load a random theme. - zstyle ':prezto:module:prompt' theme 'name' +```sh +zstyle ':prezto:module:prompt' theme 'name' +``` + +### Prompt Display Length + +To change working directory prompt display length from 'short', set the +following to 'long' (without `~` expansion) or 'full' (with `~` expansion) +in *zpreztorc*. + +```sh +zstyle ':prezto:module:prompt' pwd-length 'short' +``` + +### Display Return Value + +Some prompts display the return value in the prompt. If a prompt has support, +this can be disabled with the following snippet. + +```sh +zstyle ':prezto:module:prompt' show-return-val 'no' +``` Theming ------- @@ -26,7 +49,7 @@ There are three theme functions, a setup function, a help function, and a preview function. The setup function **must** always be defined. The help function and the preview functions are optional. -#### prompt_name_setup +#### `prompt_name_setup` This function is called by the `prompt` function to install the theme. This function may define other functions as necessary to maintain the prompt, @@ -36,51 +59,57 @@ including a function that displays help or a function used to preview it. The most basic example of this function can be seen below. - function prompt_name_setup { - PROMPT='%m%# ' - RPROMPT='' - } +```sh +function prompt_name_setup { + PROMPT='%m%# ' + RPROMPT='' +} +``` -#### prompt_name_help +#### `prompt_name_help` If the `prompt_name_setup` function is customizable via parameters, a help function **should** be defined. The user will access it via `prompt -h name`. The most basic example of this function can be seen below. - function prompt_name_help { - cat <] [] + prompt theme [] [] - where the color is for the left-hand prompt. - EOH - } +where the color is for the left-hand prompt. +EOH +} +``` -#### prompt_name_preview +#### `prompt_name_preview` If the `prompt_name_setup` function is customizable via parameters, a preview function **should** be defined. The user will access it via `prompt -p name`. The most basic example of this function can be seen below. - function prompt_name_preview { - if (( $# > 0 )); then - prompt_preview_theme theme "$@" - else - prompt_preview_theme theme red green blue - print - prompt_preview_theme theme yellow magenta black - fi - } +```sh +function prompt_name_preview { + if (( $# > 0 )); then + prompt_preview_theme theme "$@" + else + prompt_preview_theme theme red green blue + print + prompt_preview_theme theme yellow magenta black + fi +} +``` ### Hook Functions There are many Zsh [hook][2] functions, but mostly the *precmd* hook will be used. -#### prompt_name_precmd +#### `prompt_name_precmd` This hook is called before the prompt is displayed and is useful for getting information to display in a prompt. @@ -93,11 +122,25 @@ a function before you calling it. The most basic example of this function can be seen below. - function prompt_name_precmd { - if (( $+functions[git-info] )); then - git-info - fi - } +```sh +function prompt_name_precmd { + if (( $+functions[git-info] )); then + git-info + fi +} +``` + +Troubleshooting +--------------- + +### Fonts aren't displaying properly. + +On most systems, themes which use special characters need to have a patched font +installed and configured properly. + +Powerline provides some information on [terminal support][4] and [how to install +patched fonts][5] which should fix most font issues. + Authors ------- @@ -109,3 +152,5 @@ Authors [1]: http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#Prompt-Themes [2]: http://zsh.sourceforge.net/Doc/Release/Functions.html#Hook-Functions [3]: https://github.com/sorin-ionescu/prezto/issues +[4]: http://powerline.readthedocs.io/en/master/usage.html#terminal-emulator-requirements +[5]: http://powerline.readthedocs.io/en/latest/installation.html#fonts-installation diff --git a/.zprezto/modules/prompt/external/agnoster/.git_backup b/.zprezto/modules/prompt/external/agnoster/.git_backup new file mode 100644 index 0000000..ce70968 --- /dev/null +++ b/.zprezto/modules/prompt/external/agnoster/.git_backup @@ -0,0 +1 @@ +gitdir: ../../../../.git/modules/modules/prompt/external/agnoster diff --git a/.zprezto/modules/prompt/external/agnoster/agnoster.zsh-theme b/.zprezto/modules/prompt/external/agnoster/agnoster.zsh-theme index 9304556..4eceafd 100644 --- a/.zprezto/modules/prompt/external/agnoster/agnoster.zsh-theme +++ b/.zprezto/modules/prompt/external/agnoster/agnoster.zsh-theme @@ -26,7 +26,9 @@ # A few utility functions to make it easy and re-usable to draw segmented prompts CURRENT_BG='NONE' -PRIMARY_FG=black +if [[ -z "$PRIMARY_FG" ]]; then + PRIMARY_FG=black +fi # Characters SEGMENT_SEPARATOR="\ue0b0" @@ -97,7 +99,7 @@ prompt_git() { ref="$DETACHED ${ref/.../}" fi prompt_segment $color $PRIMARY_FG - print -Pn " $ref" + print -n " $ref" fi } @@ -120,12 +122,22 @@ prompt_status() { [[ -n "$symbols" ]] && prompt_segment $PRIMARY_FG default " $symbols " } +# Display current virtual environment +prompt_virtualenv() { + if [[ -n $VIRTUAL_ENV ]]; then + color=cyan + prompt_segment $color $PRIMARY_FG + print -Pn " $(basename $VIRTUAL_ENV) " + fi +} + ## Main prompt prompt_agnoster_main() { RETVAL=$? CURRENT_BG='NONE' prompt_status prompt_context + prompt_virtualenv prompt_dir prompt_git prompt_end diff --git a/.zprezto/modules/prompt/external/async/.editorconfig_backup b/.zprezto/modules/prompt/external/async/.editorconfig_backup new file mode 100644 index 0000000..4655b13 --- /dev/null +++ b/.zprezto/modules/prompt/external/async/.editorconfig_backup @@ -0,0 +1,12 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = tab +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{yml,json}] +indent_style = space +indent_size = 2 diff --git a/.zprezto/modules/prompt/external/async/.git_backup b/.zprezto/modules/prompt/external/async/.git_backup new file mode 100644 index 0000000..5a65093 --- /dev/null +++ b/.zprezto/modules/prompt/external/async/.git_backup @@ -0,0 +1 @@ +gitdir: ../../../../.git/modules/modules/prompt/external/async diff --git a/.zprezto/modules/prompt/external/async/.travis.yml_backup b/.zprezto/modules/prompt/external/async/.travis.yml_backup new file mode 100644 index 0000000..2e0013b --- /dev/null +++ b/.zprezto/modules/prompt/external/async/.travis.yml_backup @@ -0,0 +1,54 @@ +language: sh + +addons: + apt: + packages: + - build-essential + +env: + global: + - ZSH_DIST=$HOME/.zshdist + matrix: + # Use _ZSH_VERSION since if ZSH_VERSION is present, travis cacher thinks it + # is running in zsh and tries to use zsh specific functions. + - _ZSH_VERSION=5.5.1 + - _ZSH_VERSION=5.4.2 + - _ZSH_VERSION=5.3.1 + - _ZSH_VERSION=5.3 + - _ZSH_VERSION=5.2 + - _ZSH_VERSION=5.1.1 + - _ZSH_VERSION=5.0.8 + - _ZSH_VERSION=5.0.2 + +cache: + directories: + - $ZSH_DIST + +before_script: + - > + setup_zsh() { + dest="$ZSH_DIST/$1" + if [[ ! -d $dest/bin ]]; then + tmp="$(mktemp --directory --tmpdir="${TMPDIR:/tmp}" zshbuild.XXXXXX)" + ( + cd "$tmp" && + curl -L http://downloads.sourceforge.net/zsh/zsh-${1}.tar.gz | tar zx && + cd zsh-$1 && + ./configure --prefix="$dest" && + make && + mkdir -p "$dest" && + make install || + echo "Failed to build zsh-${1}!" + ) + fi + export PATH="$dest/bin:$PATH" + } + - setup_zsh $_ZSH_VERSION + - zsh --version + +script: + - zsh test.zsh -v + +allow_failures: + - env: _ZSH_VERSION=5.0.2 + - env: _ZSH_VERSION=5.0.8 diff --git a/.zprezto/modules/prompt/external/async/LICENSE b/.zprezto/modules/prompt/external/async/LICENSE new file mode 100644 index 0000000..e63b31d --- /dev/null +++ b/.zprezto/modules/prompt/external/async/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Mathias Fredriksson + +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/.zprezto/modules/prompt/external/async/README.md b/.zprezto/modules/prompt/external/async/README.md new file mode 100644 index 0000000..3f2b060 --- /dev/null +++ b/.zprezto/modules/prompt/external/async/README.md @@ -0,0 +1,163 @@ +# zsh-async + +``` +Because your terminal should be able to perform tasks asynchronously without external tools! +``` + +## Intro (TL;DR) + +With `zsh-async` you can run multiple asynchronous jobs, enforce unique jobs (multiple instances of the same job will not run), flush all currently running jobs and create multiple workers (each with their own jobs). For each worker you can register a callback-function through which you will be notified about the job results (job name, return code, output and execution time). + +## Overview + +`zsh-async` is a small library for running asynchronous tasks in zsh without requiring any external tools. It utilizes `zsh/zpty` to launch a pseudo-terminal in which all commands get executed without blocking any other processes. Checking for completed tasks can be done manually, by polling, or better yet, automatically whenever a process has finished executing by notifying through a `SIGWINCH` kill-signal. + +This library bridges the gap between spawning child processes and disowning them. Child processes launched by normal means clutter the terminal with output about their state, and disowned processes become separate entities, no longer under control of the parent. Now you can have both! + +## Usage + +The async worker is a separate environment (think web worker). You send it a job (command + parameters) to execute and it returns the result of that execution through a callback function. If you find that you need to stop/start a worker to update global state (variables) you should consider refactoring so that state is passed during the `async_job` call (e.g. `async_job my_worker my_function $state1 $state2`). + +### Installation + +#### Manual + +You can either source the `async.zsh` script directly or insert under your `$fpath` as async and autoload it through `autoload -Uz async && async`. + +#### Integration + +##### zplug + +``` +zplug "mafredri/zsh-async", from:"github", use:"async.zsh" +``` + +### Functions + +The `zsh-async` library has a bunch of functions that need to be used to perform async actions: + +#### `async_init` + +Initializes the async library (not required if using async from `$fpath` with autoload.) + +#### `async_start_worker [-u] [-n] [-p ]` + +Start a new async worker with optional parameters, a worker can be told to only run unique tasks and to notify a process when tasks are complete. + +* `-u` unique. Only unique job names can run, e.g. the command `git status` will have `git` as the unique job name identifier + +* `-n` notify through `SIGWINCH` signal. Needs to be caught with a `trap '' WINCH` in the process defined by `-p` + + **NOTE:** When `zsh-async` is used in an interactive shell with ZLE enabled this option is not needed. Signaling through `SIGWINCH` has been replaced by a ZLE watcher that is triggered on output from the `zpty` instance (still requires a callback function through `async_register_callback` though). Technically zsh versions prior to `5.2` do not return the file descriptor for zpty instances, however, `zsh-async` attempts to deduce it anyway. + +* `-p` pid to notify (defaults to current pid) + +#### `async_stop_worker []` + +Simply stops a worker and all active jobs will be terminated immediately. + +#### `async_job []` + +Start a new asynchronous job on specified worker, assumes the worker is running. + +#### `async_process_results ` + +Get results from finished jobs and pass it to the to callback function. This is the only way to reliably return the job name, return code, output and execution time and with minimal effort. + +The `callback_function` is called with the following parameters: + +* `$1` job name, e.g. the function passed to async_job +* `$2` return code + * Returns `-1` if return code is missing, this should never happen, if it does, you have likely run into a bug. Please open a new [issue](https://github.com/mafredri/zsh-async/issues/new) with a detailed description of what you were doing. +* `$3` resulting (stdout) output from job execution +* `$4` execution time, floating point e.g. 0.0076138973 seconds +* `$5` resulting (stderr) error output from job execution +* `$6` has next result in buffer (0 = buffer empty, 1 = yes) + * This means another async job has completed and is pending in the buffer, it's very likely that your callback function will be called a second time (or more) in this execution. It's generally a good idea to e.g. delay prompt updates (`zle reset-prompt`) until the buffer is empty to prevent strange states in ZLE. + +#### `async_register_callback ` + +Register a callback for completed jobs. As soon as a job is finished, `async_process_results` will be called with the specified callback function. This requires that a worker is initialized with the -n (notify) option. + +#### `async_unregister_callback ` + +Unregister the callback for a specific worker. + +#### `async_flush_jobs ` + +Flush all current jobs running on a worker. This will terminate any and all running processes under the worker by sending a `SIGTERM` to the entire process group, use with caution. + +## Example code + +```zsh +#!/usr/bin/env zsh +source ./async.zsh +async_init + +# Initialize a new worker (with notify option) +async_start_worker my_worker -n + +# Create a callback function to process results +COMPLETED=0 +completed_callback() { + COMPLETED=$(( COMPLETED + 1 )) + print $@ +} + +# Register callback function for the workers completed jobs +async_register_callback my_worker completed_callback + +# Give the worker some tasks to perform +async_job my_worker print hello +async_job my_worker sleep 0.3 + +# Wait for the two tasks to be completed +while (( COMPLETED < 2 )); do + print "Waiting..." + sleep 0.1 +done + +print "Completed $COMPLETED tasks!" + +# Output: +# Waiting... +# print 0 hello 0.001583099365234375 +# Waiting... +# Waiting... +# sleep 0 0.30631208419799805 +# Completed 2 tasks! +``` + +## Testing + +Tests are located in `*_test.zsh` and can be run by executing the test runner: `./test.zsh`. + +Example: + +```console +$ ./test.zsh +ok ./async_test.zsh 2.334s +``` + +The test suite can also run specific tasks that match a pattern, for example: + +```console +$ ./test.zsh -v -run zle +=== RUN test_zle_watcher +--- PASS: test_zle_watcher (0.07s) +PASS +ok ./async_test.zsh 0.070s +``` + +## Limitations + +* A NULL-character (`$'\0'`) is used by `async_job` to signify the end of the command, it is recommended not to pass them as arguments, although they should work when passing multiple arguments to `async_job` (because of quoting). +* Tell me? :) + +## Tips + +If you do not wish to use the `notify` feature, you can couple `zsh-async` with `zsh/sched` or the zsh `periodic` function for scheduling the worker results to be processed. + +## Why did I make this? + +I found a great theme for zsh, [Pure](https://github.com/sindresorhus/pure) by Sindre Sorhus. After using it for a while I noticed some graphical glitches due to the terminal being updated by a disowned process. Thus, I became inspired to get my hands dirty and find a solution. I tried many things, coprocesses (seemed too limited by themselves), different combinations of trapping kill-signals, etc. I also had problems with the zsh process ending up in a deadlock due to some zsh bug. After working out the kinks, I ended up with this and thought, hey, why not make it a library. diff --git a/.zprezto/modules/prompt/external/async/async.plugin.zsh b/.zprezto/modules/prompt/external/async/async.plugin.zsh new file mode 100644 index 0000000..e50b25e --- /dev/null +++ b/.zprezto/modules/prompt/external/async/async.plugin.zsh @@ -0,0 +1,2 @@ +0=${(%):-%N} +source ${0:A:h}/async.zsh diff --git a/.zprezto/modules/prompt/external/async/async.zsh b/.zprezto/modules/prompt/external/async/async.zsh new file mode 100644 index 0000000..1257029 --- /dev/null +++ b/.zprezto/modules/prompt/external/async/async.zsh @@ -0,0 +1,499 @@ +#!/usr/bin/env zsh + +# +# zsh-async +# +# version: 1.6.2 +# author: Mathias Fredriksson +# url: https://github.com/mafredri/zsh-async +# + +typeset -g ASYNC_VERSION=1.6.2 +# Produce debug output from zsh-async when set to 1. +typeset -g ASYNC_DEBUG=${ASYNC_DEBUG:-0} + +# Wrapper for jobs executed by the async worker, gives output in parseable format with execution time +_async_job() { + # Disable xtrace as it would mangle the output. + setopt localoptions noxtrace + + # Store start time for job. + float -F duration=$EPOCHREALTIME + + # Run the command and capture both stdout (`eval`) and stderr (`cat`) in + # separate subshells. When the command is complete, we grab write lock + # (mutex token) and output everything except stderr inside the command + # block, after the command block has completed, the stdin for `cat` is + # closed, causing stderr to be appended with a $'\0' at the end to mark the + # end of output from this job. + local stdout stderr ret tok + { + stdout=$(eval "$@") + ret=$? + duration=$(( EPOCHREALTIME - duration )) # Calculate duration. + + # Grab mutex lock, stalls until token is available. + read -r -k 1 -p tok || exit 1 + + # Return output ( ). + print -r -n - ${(q)1} $ret ${(q)stdout} $duration + } 2> >(stderr=$(cat) && print -r -n - " "${(q)stderr}$'\0') + + # Unlock mutex by inserting a token. + print -n -p $tok +} + +# The background worker manages all tasks and runs them without interfering with other processes +_async_worker() { + # Reset all options to defaults inside async worker. + emulate -R zsh + + # Make sure monitor is unset to avoid printing the + # pids of child processes. + unsetopt monitor + + # Redirect stderr to `/dev/null` in case unforseen errors produced by the + # worker. For example: `fork failed: resource temporarily unavailable`. + # Some older versions of zsh might also print malloc errors (know to happen + # on at least zsh 5.0.2 and 5.0.8) likely due to kill signals. + exec 2>/dev/null + + # When a zpty is deleted (using -d) all the zpty instances created before + # the one being deleted receive a SIGHUP, unless we catch it, the async + # worker would simply exit (stop working) even though visible in the list + # of zpty's (zpty -L). + TRAPHUP() { + return 0 # Return 0, indicating signal was handled. + } + + local -A storage + local unique=0 + local notify_parent=0 + local parent_pid=0 + local coproc_pid=0 + local processing=0 + + local -a zsh_hooks zsh_hook_functions + zsh_hooks=(chpwd periodic precmd preexec zshexit zshaddhistory) + zsh_hook_functions=(${^zsh_hooks}_functions) + unfunction $zsh_hooks &>/dev/null # Deactivate all zsh hooks inside the worker. + unset $zsh_hook_functions # And hooks with registered functions. + unset zsh_hooks zsh_hook_functions # Cleanup. + + child_exit() { + local -a pids + pids=(${${(v)jobstates##*:*:}%\=*}) + + # If coproc (cat) is the only child running, we close it to avoid + # leaving it running indefinitely and cluttering the process tree. + if (( ! processing )) && [[ $#pids = 1 ]] && [[ $coproc_pid = $pids[1] ]]; then + coproc : + coproc_pid=0 + fi + + # On older version of zsh (pre 5.2) we notify the parent through a + # SIGWINCH signal because `zpty` did not return a file descriptor (fd) + # prior to that. + if (( notify_parent )); then + # We use SIGWINCH for compatibility with older versions of zsh + # (pre 5.1.1) where other signals (INFO, ALRM, USR1, etc.) could + # cause a deadlock in the shell under certain circumstances. + kill -WINCH $parent_pid + fi + } + + # Register a SIGCHLD trap to handle the completion of child processes. + trap child_exit CHLD + + # Process option parameters passed to worker + while getopts "np:u" opt; do + case $opt in + n) notify_parent=1;; + p) parent_pid=$OPTARG;; + u) unique=1;; + esac + done + + killjobs() { + local tok + local -a pids + pids=(${${(v)jobstates##*:*:}%\=*}) + + # No need to send SIGHUP if no jobs are running. + (( $#pids == 0 )) && continue + (( $#pids == 1 )) && [[ $coproc_pid = $pids[1] ]] && continue + + # Grab lock to prevent half-written output in case a child + # process is in the middle of writing to stdin during kill. + (( coproc_pid )) && read -r -k 1 -p tok + + kill -HUP -$$ # Send to entire process group. + coproc : # Quit coproc. + coproc_pid=0 # Reset pid. + } + + local request + local -a cmd + while :; do + # Wait for jobs sent by async_job. + read -r -d $'\0' request || { + # Since we handle SIGHUP above (and thus do not know when `zpty -d`) + # occurs, a failure to read probably indicates that stdin has + # closed. This is why we propagate the signal to all children and + # exit manually. + kill -HUP -$$ # Send SIGHUP to all jobs. + exit 0 + } + + # Check for non-job commands sent to worker + case $request in + _unset_trap) notify_parent=0; continue;; + _killjobs) killjobs; continue;; + esac + + # Parse the request using shell parsing (z) to allow commands + # to be parsed from single strings and multi-args alike. + cmd=("${(z)request}") + + # Name of the job (first argument). + local job=$cmd[1] + + # If worker should perform unique jobs + if (( unique )); then + # Check if a previous job is still running, if yes, let it finnish + for pid in ${${(v)jobstates##*:*:}%\=*}; do + if [[ ${storage[$job]} == $pid ]]; then + continue 2 + fi + done + fi + + # Guard against closing coproc from trap before command has started. + processing=1 + + # Because we close the coproc after the last job has completed, we must + # recreate it when there are no other jobs running. + if (( ! coproc_pid )); then + # Use coproc as a mutex for synchronized output between children. + coproc cat + coproc_pid="$!" + # Insert token into coproc + print -n -p "t" + fi + + # Run job in background, completed jobs are printed to stdout. + _async_job $cmd & + # Store pid because zsh job manager is extremely unflexible (show jobname as non-unique '$job')... + storage[$job]="$!" + + processing=0 # Disable guard. + done +} + +# +# Get results from finnished jobs and pass it to the to callback function. This is the only way to reliably return the +# job name, return code, output and execution time and with minimal effort. +# +# usage: +# async_process_results +# +# callback_function is called with the following parameters: +# $1 = job name, e.g. the function passed to async_job +# $2 = return code +# $3 = resulting stdout from execution +# $4 = execution time, floating point e.g. 2.05 seconds +# $5 = resulting stderr from execution +# $6 = has next result in buffer (0 = buffer empty, 1 = yes) +# +async_process_results() { + setopt localoptions unset noshwordsplit noksharrays noposixidentifiers noposixstrings + + local worker=$1 + local callback=$2 + local caller=$3 + local -a items + local null=$'\0' data + integer -l len pos num_processed has_next + + typeset -gA ASYNC_PROCESS_BUFFER + + # Read output from zpty and parse it if available. + while zpty -r -t $worker data 2>/dev/null; do + ASYNC_PROCESS_BUFFER[$worker]+=$data + len=${#ASYNC_PROCESS_BUFFER[$worker]} + pos=${ASYNC_PROCESS_BUFFER[$worker][(i)$null]} # Get index of NULL-character (delimiter). + + # Keep going until we find a NULL-character. + if (( ! len )) || (( pos > len )); then + continue + fi + + while (( pos <= len )); do + # Take the content from the beginning, until the NULL-character and + # perform shell parsing (z) and unquoting (Q) as an array (@). + items=("${(@Q)${(z)ASYNC_PROCESS_BUFFER[$worker][1,$pos-1]}}") + + # Remove the extracted items from the buffer. + ASYNC_PROCESS_BUFFER[$worker]=${ASYNC_PROCESS_BUFFER[$worker][$pos+1,$len]} + + len=${#ASYNC_PROCESS_BUFFER[$worker]} + if (( len > 1 )); then + pos=${ASYNC_PROCESS_BUFFER[$worker][(i)$null]} # Get index of NULL-character (delimiter). + fi + + has_next=$(( len != 0 )) + if (( $#items == 5 )); then + items+=($has_next) + $callback "${(@)items}" # Send all parsed items to the callback. + else + # In case of corrupt data, invoke callback with *async* as job + # name, non-zero exit status and an error message on stderr. + $callback "async" 1 "" 0 "$0:$LINENO: error: bad format, got ${#items} items (${(q)items})" $has_next + fi + + (( num_processed++ )) + done + done + + (( num_processed )) && return 0 + + # Avoid printing exit value when `setopt printexitvalue` is active.` + [[ $caller = trap || $caller = watcher ]] && return 0 + + # No results were processed + return 1 +} + +# Watch worker for output +_async_zle_watcher() { + setopt localoptions noshwordsplit + typeset -gA ASYNC_PTYS ASYNC_CALLBACKS + local worker=$ASYNC_PTYS[$1] + local callback=$ASYNC_CALLBACKS[$worker] + + if [[ -n $callback ]]; then + async_process_results $worker $callback watcher + fi +} + +# +# Start a new asynchronous job on specified worker, assumes the worker is running. +# +# usage: +# async_job [] +# +async_job() { + setopt localoptions noshwordsplit noksharrays noposixidentifiers noposixstrings + + local worker=$1; shift + + local -a cmd + cmd=("$@") + if (( $#cmd > 1 )); then + cmd=(${(q)cmd}) # Quote special characters in multi argument commands. + fi + + # Quote the cmd in case RC_EXPAND_PARAM is set. + zpty -w $worker "$cmd"$'\0' +} + +# This function traps notification signals and calls all registered callbacks +_async_notify_trap() { + setopt localoptions noshwordsplit + + local k + for k in ${(k)ASYNC_CALLBACKS}; do + async_process_results $k ${ASYNC_CALLBACKS[$k]} trap + done +} + +# +# Register a callback for completed jobs. As soon as a job is finnished, async_process_results will be called with the +# specified callback function. This requires that a worker is initialized with the -n (notify) option. +# +# usage: +# async_register_callback +# +async_register_callback() { + setopt localoptions noshwordsplit nolocaltraps + + typeset -gA ASYNC_CALLBACKS + local worker=$1; shift + + ASYNC_CALLBACKS[$worker]="$*" + + # Enable trap when the ZLE watcher is unavailable, allows + # workers to notify (via -n) when a job is done. + if [[ ! -o interactive ]] || [[ ! -o zle ]]; then + trap '_async_notify_trap' WINCH + fi +} + +# +# Unregister the callback for a specific worker. +# +# usage: +# async_unregister_callback +# +async_unregister_callback() { + typeset -gA ASYNC_CALLBACKS + + unset "ASYNC_CALLBACKS[$1]" +} + +# +# Flush all current jobs running on a worker. This will terminate any and all running processes under the worker, use +# with caution. +# +# usage: +# async_flush_jobs +# +async_flush_jobs() { + setopt localoptions noshwordsplit + + local worker=$1; shift + + # Check if the worker exists + zpty -t $worker &>/dev/null || return 1 + + # Send kill command to worker + async_job $worker "_killjobs" + + # Clear the zpty buffer. + local junk + if zpty -r -t $worker junk '*'; then + (( ASYNC_DEBUG )) && print -n "async_flush_jobs $worker: ${(V)junk}" + while zpty -r -t $worker junk '*'; do + (( ASYNC_DEBUG )) && print -n "${(V)junk}" + done + (( ASYNC_DEBUG )) && print + fi + + # Finally, clear the process buffer in case of partially parsed responses. + typeset -gA ASYNC_PROCESS_BUFFER + unset "ASYNC_PROCESS_BUFFER[$worker]" +} + +# +# Start a new async worker with optional parameters, a worker can be told to only run unique tasks and to notify a +# process when tasks are complete. +# +# usage: +# async_start_worker [-u] [-n] [-p ] +# +# opts: +# -u unique (only unique job names can run) +# -n notify through SIGWINCH signal +# -p pid to notify (defaults to current pid) +# +async_start_worker() { + setopt localoptions noshwordsplit + + local worker=$1; shift + zpty -t $worker &>/dev/null && return + + typeset -gA ASYNC_PTYS + typeset -h REPLY + typeset has_xtrace=0 + + # Make sure async worker is started without xtrace + # (the trace output interferes with the worker). + [[ -o xtrace ]] && { + has_xtrace=1 + unsetopt xtrace + } + + if (( ! ASYNC_ZPTY_RETURNS_FD )) && [[ -o interactive ]] && [[ -o zle ]]; then + # When zpty doesn't return a file descriptor (on older versions of zsh) + # we try to guess it anyway. + integer -l zptyfd + exec {zptyfd}>&1 # Open a new file descriptor (above 10). + exec {zptyfd}>&- # Close it so it's free to be used by zpty. + fi + + zpty -b $worker _async_worker -p $$ $@ || { + async_stop_worker $worker + return 1 + } + + # Re-enable it if it was enabled, for debugging. + (( has_xtrace )) && setopt xtrace + + if [[ $ZSH_VERSION < 5.0.8 ]]; then + # For ZSH versions older than 5.0.8 we delay a bit to give + # time for the worker to start before issuing commands, + # otherwise it will not be ready to receive them. + sleep 0.001 + fi + + if [[ -o interactive ]] && [[ -o zle ]]; then + if (( ! ASYNC_ZPTY_RETURNS_FD )); then + REPLY=$zptyfd # Use the guessed value for the file desciptor. + fi + + ASYNC_PTYS[$REPLY]=$worker # Map the file desciptor to the worker. + zle -F $REPLY _async_zle_watcher # Register the ZLE handler. + + # Disable trap in favor of ZLE handler when notify is enabled (-n). + async_job $worker _unset_trap + fi +} + +# +# Stop one or multiple workers that are running, all unfetched and incomplete work will be lost. +# +# usage: +# async_stop_worker [] +# +async_stop_worker() { + setopt localoptions noshwordsplit + + local ret=0 worker k v + for worker in $@; do + # Find and unregister the zle handler for the worker + for k v in ${(@kv)ASYNC_PTYS}; do + if [[ $v == $worker ]]; then + zle -F $k + unset "ASYNC_PTYS[$k]" + fi + done + async_unregister_callback $worker + zpty -d $worker 2>/dev/null || ret=$? + + # Clear any partial buffers. + typeset -gA ASYNC_PROCESS_BUFFER + unset "ASYNC_PROCESS_BUFFER[$worker]" + done + + return $ret +} + +# +# Initialize the required modules for zsh-async. To be called before using the zsh-async library. +# +# usage: +# async_init +# +async_init() { + (( ASYNC_INIT_DONE )) && return + typeset -g ASYNC_INIT_DONE=1 + + zmodload zsh/zpty + zmodload zsh/datetime + + # Check if zsh/zpty returns a file descriptor or not, + # shell must also be interactive with zle enabled. + typeset -g ASYNC_ZPTY_RETURNS_FD=0 + [[ -o interactive ]] && [[ -o zle ]] && { + typeset -h REPLY + zpty _async_test : + (( REPLY )) && ASYNC_ZPTY_RETURNS_FD=1 + zpty -d _async_test + } +} + +async() { + async_init +} + +async "$@" diff --git a/.zprezto/modules/prompt/external/async/async_test.zsh b/.zprezto/modules/prompt/external/async/async_test.zsh new file mode 100644 index 0000000..0791fc7 --- /dev/null +++ b/.zprezto/modules/prompt/external/async/async_test.zsh @@ -0,0 +1,574 @@ +#!/usr/bin/env zsh + +test__async_job_print_hi() { + coproc cat + print -n -p t # Insert token into coproc. + + local line + local -a out + line=$(_async_job print hi) + # Remove trailing null, parse, unquote and interpret as array. + line=$line[1,$#line-1] + out=("${(@Q)${(z)line}}") + + coproc exit + + [[ $out[1] = print ]] || t_error "command name should be print, got" $out[1] + [[ $out[2] = 0 ]] || t_error "want exit code 0, got" $out[2] + [[ $out[3] = hi ]] || t_error "want output: hi, got" $out[3] +} + +test__async_job_stderr() { + coproc cat + print -n -p t # Insert token into coproc. + + local line + local -a out + line=$(_async_job print 'hi 1>&2') + # Remove trailing null, parse, unquote and interpret as array. + line=$line[1,$#line-1] + out=("${(@Q)${(z)line}}") + + coproc exit + + [[ $out[2] = 0 ]] || t_error "want status 0, got" $out[2] + [[ -z $out[3] ]] || t_error "want empty output, got" $out[3] + [[ $out[5] = hi ]] || t_error "want stderr: hi, got" $out[5] +} + +test__async_job_wait_for_token() { + float start duration + coproc cat + + _async_job print hi >/dev/null & + job=$! + start=$EPOCHREALTIME + { + sleep 0.1 + print -n -p t + } & + + wait $job + + coproc exit + + duration=$(( EPOCHREALTIME - start )) + # Fail if the execution time was faster than 0.1 seconds. + (( duration >= 0.1 )) || t_error "execution was too fast, want >= 0.1, got" $duration +} + +test__async_job_multiple_commands() { + coproc cat + print -n -p t + + local line + local -a out + line="$(_async_job print '-n hi; for i in "1 2" 3 4; do print -n $i; done')" + # Remove trailing null, parse, unquote and interpret as array. + line=$line[1,$#line-1] + out=("${(@Q)${(z)line}}") + + coproc exit + + # $out[1] here will be the entire string passed to _async_job() + # ('print -n hi...') since proper command parsing is done by + # the async worker. + [[ $out[3] = "hi1 234" ]] || t_error "want output hi1 234, got " $out[3] +} + +test_async_start_stop_worker() { + local out + + async_start_worker test + out=$(zpty -L) + [[ $out =~ "test _async_worker" ]] || t_error "want zpty worker running, got ${(Vq-)out}" + + async_stop_worker test || t_error "stop worker: want exit code 0, got $?" + out=$(zpty -L) + [[ -z $out ]] || t_error "want no zpty worker running, got ${(Vq-)out}" + + async_stop_worker nonexistent && t_error "stop non-existent worker: want exit code 1, got $?" +} + +test_async_job_print_matches_input_exactly() { + local -a result + cb() { result=("$@") } + + async_start_worker test + t_defer async_stop_worker test + + want=' + Hello world! + Much *formatting*, + many space\t...\n\n + Such "quote", v '$'\'quote\''' + ' + + async_job test print -r - "$want" + while ! async_process_results test cb; do :; done + + [[ $result[3] = $want ]] || t_error "output, want ${(Vqqqq)want}, got ${(Vqqqq)result[3]}" +} + +test_async_process_results() { + local -a r + cb() { r+=("$@") } + + async_start_worker test + t_defer async_stop_worker test + + async_process_results test cb # No results. + ret=$? + (( ret == 1 )) || t_error "want exit code 1, got $ret" + + async_job test print -n hi + while ! async_process_results test cb; do :; done + (( $#r == 6 )) || t_error "want one result, got $(( $#r % 6 ))" +} + +test_async_process_results_stress() { + # NOTE: This stress test does not always pass properly on older versions of + # zsh, sometimes writing to zpty can hang and other times reading can hang, + # etc. + local -a r + cb() { r+=("$@") } + + async_start_worker test + t_defer async_stop_worker test + + integer iter=40 timeout=5 + for i in {1..$iter}; do + async_job test "print -n $i" + + # TODO: Figure out how we can remove sleep & process here. + + # If we do not sleep here, we end up losing some of the commands sent to + # async_job (~90 get sent). This could possibly be due to the zpty + # buffer being full (see below). + sleep 0.00001 + # Without processing resuls we occasionally run into 'print -n 39' + # failing due to the command name and exit status missing. Sample output + # from processing for 39 (stdout, time, stderr): + # $'39 0.0056798458 ' + # This is again, probably due to the zpty buffer being full, we only + # need to ensure that not too many commands are run before we process. + (( iter % 6 == 0 )) && async_process_results test cb + done + + float start=$EPOCHSECONDS + + while (( $#r / 6 < iter )); do + async_process_results test cb + (( EPOCHSECONDS - start > timeout )) && { + t_log "timed out after ${timeout}s" + t_fatal "wanted $iter results, got $(( $#r / 6 ))" + } + done + + local -a stdouts + while (( $#r > 0 )); do + [[ $r[1] = print ]] || t_error "want 'print', got ${(Vq-)r[1]}" + [[ $r[2] = 0 ]] || t_error "want exit 0, got $r[2]" + stdouts+=($r[3]) + [[ -z $r[5] ]] || t_error "want no stderr, got ${(Vq-)r[5]}" + shift 6 r + done + + local got want + # Check that we received all numbers. + got=(${(on)stdouts}) + want=({1..$iter}) + [[ $want = $got ]] || t_error "want stdout: ${(Vq-)want}, got ${(Vq-)got}" + + # Test with longer running commands (sleep, then print). + iter=40 + for i in {1..$iter}; do + async_job test "sleep 1 && print -n $i" + sleep 0.00001 + (( iter % 6 == 0 )) && async_process_results test cb + done + + start=$EPOCHSECONDS + + while (( $#r / 6 < iter )); do + async_process_results test cb + (( EPOCHSECONDS - start > timeout )) && { + t_log "timed out after ${timeout}s" + t_fatal "wanted $iter results, got $(( $#r / 6 ))" + } + done + + stdouts=() + while (( $#r > 0 )); do + [[ $r[1] = sleep ]] || t_error "want 'sleep', got ${(Vq-)r[1]}" + [[ $r[2] = 0 ]] || t_error "want exit 0, got $r[2]" + stdouts+=($r[3]) + [[ -z $r[5] ]] || t_error "want no stderr, got ${(Vq-)r[5]}" + shift 6 r + done + + # Check that we received all numbers. + got=(${(on)stdouts}) + want=({1..$iter}) + [[ $want = $got ]] || t_error "want stdout: ${(Vq-)want}, got ${(Vq-)got}" +} + +test_async_job_multiple_commands_in_multiline_string() { + local -a result + cb() { result=("$@") } + + async_start_worker test + # Test multi-line (single string) command. + async_job test 'print "hi\n 123 "'$'\nprint -n bye' + while ! async_process_results test cb; do :; done + async_stop_worker test + + [[ $result[1] = print ]] || t_error "want command name: print, got" $result[1] + local want=$'hi\n 123 \nbye' + [[ $result[3] = $want ]] || t_error "want output: ${(Vq-)want}, got ${(Vq-)result[3]}" +} + +test_async_job_git_status() { + local -a result + cb() { result=("$@") } + + async_start_worker test + async_job test git status --porcelain + while ! async_process_results test cb; do :; done + async_stop_worker test + + [[ $result[1] = git ]] || t_error "want command name: git, got" $result[1] + [[ $result[2] = 0 ]] || t_error "want exit code: 0, got" $result[2] + + want=$(git status --porcelain) + got=$result[3] + [[ $got = $want ]] || t_error "want ${(Vq-)want}, got ${(Vq-)got}" +} + +test_async_job_multiple_arguments_and_spaces() { + local -a result + cb() { result=("$@") } + + async_start_worker test + async_job test print "hello world" + while ! async_process_results test cb; do :; done + async_stop_worker test + + [[ $result[1] = print ]] || t_error "want command name: print, got" $result[1] + [[ $result[2] = 0 ]] || t_error "want exit code: 0, got" $result[2] + + [[ $result[3] = "hello world" ]] || { + t_error "want output: \"hello world\", got" ${(Vq-)result[3]} + } +} + +test_async_job_unique_worker() { + local -a result + cb() { + # Add to result so we can detect if it was called multiple times. + result+=("$@") + } + helper() { + sleep 0.1; print $1 + } + + # Start a unique (job) worker. + async_start_worker test -u + + # Launch two jobs with the same name, the first one should be + # allowed to complete whereas the second one is never run. + async_job test helper one + async_job test helper two + + while ! async_process_results test cb; do :; done + + # If both jobs were running but only one was complete, + # async_process_results() could've returned true for + # the first job, wait a little extra to make sure the + # other didn't run. + sleep 0.1 + async_process_results test cb + + async_stop_worker test + + # Ensure that cb was only called once with correc output. + [[ ${#result} = 6 ]] || t_error "result: want 6 elements, got" ${#result} + [[ $result[3] = one ]] || t_error "output: want 'one', got" ${(Vq-)result[3]} +} + +test_async_job_error_and_nonzero_exit() { + local -a r + cb() { r+=("$@") } + error() { + print "Errors!" + 12345 + 54321 + print "Done!" + exit 99 + } + + async_start_worker test + async_job test error + + while ! async_process_results test cb; do :; done + + [[ $r[1] = error ]] || t_error "want 'error', got ${(Vq-)r[1]}" + [[ $r[2] = 99 ]] || t_error "want exit code 99, got $r[2]" + + want=$'Errors!\nDone!' + [[ $r[3] = $want ]] || t_error "want ${(Vq-)want}, got ${(Vq-)r[3]}" + + want=$'.*command not found: 12345\n.*command not found: 54321' + [[ $r[5] =~ $want ]] || t_error "want ${(Vq-)want}, got ${(Vq-)r[5]}" +} + +test_async_worker_notify_sigwinch() { + local -a result + cb() { result=("$@") } + + ASYNC_USE_ZLE_HANDLER=0 + + async_start_worker test -n + async_register_callback test cb + + async_job test 'sleep 0.1; print hi' + + while (( ! $#result )); do sleep 0.01; done + + async_stop_worker test + + [[ $result[3] = hi ]] || t_error "expected output: hi, got" $result[3] +} + +test_async_job_keeps_nulls() { + local -a r + cb() { r=("$@") } + null_echo() { + print Hello$'\0' with$'\0' nulls! + print "Did we catch them all?"$'\0' + print $'\0'"What about the errors?"$'\0' 1>&2 + } + + async_start_worker test + async_job test null_echo + + while ! async_process_results test cb; do :; done + + async_stop_worker test + + local want + want=$'Hello\0 with\0 nulls!\nDid we catch them all?\0' + [[ $r[3] = $want ]] || t_error stdout: want ${(Vq-)want}, got ${(Vq-)r[3]} + want=$'\0What about the errors?\0' + [[ $r[5] = $want ]] || t_error stderr: want ${(Vq-)want}, got ${(Vq-)r[5]} +} + +test_async_flush_jobs() { + local -a r + cb() { r=+("$@") } + + print_four() { print -n 4 } + print_123_delayed_exit() { + print -n 1 + { sleep 0.25 && print -n 2 } &! + { sleep 0.3 && print -n 3 } &! + } + + async_start_worker test + + # Start a job that prints 1 and starts two disowned child processes that + # print 2 and 3, respectively, after a timeout. The job will not exit + # immediately (and thus print 1) because the child processes are still + # running. + async_job test print_123_delayed_exit + + # Check that the job is waiting for the child processes. + sleep 0.05 + async_process_results test cb + (( $#r == 0 )) || t_error "want no output, got ${(Vq-)r}" + + # Start a job that prints four, it will produce + # output but we will not process it. + async_job test print_four + sleep 0.2 + + # Flush jobs, this kills running jobs and discards unprocessed results. + # TODO: Confirm that they no longer exist in the process tree. + local output + output="${(Q)$(ASYNC_DEBUG=1 async_flush_jobs test)}" + [[ $output = *'print_four 0 4'* ]] || { + t_error "want discarded output 'print_four 0 4' when ASYNC_DEBUG=1, got ${(Vq-)output}" + } + + # Check that the killed job did not produce output. + sleep 0.1 + async_process_results test cb + (( $#r == 0 )) || t_error "want no output, got ${(Vq-)r}" + + async_stop_worker test +} + +test_async_worker_survives_termination_of_other_worker() { + local -a result + cb() { result+=("$@") } + + async_start_worker test1 + t_defer async_stop_worker test1 + + # Start and stop a worker, will send SIGHUP to previous worker + # (probably has to do with some shell inheritance). + async_start_worker test2 + async_stop_worker test2 + + async_job test1 print hi + + integer start=$EPOCHREALTIME + while (( EPOCHREALTIME - start < 2.0 )); do + async_process_results test1 cb && break + done + + (( $#result == 6 )) || t_error "wanted a result, got (${(@Vq)result})" +} + +setopt_helper() { + setopt localoptions $1 + + # Make sure to test with multiple options + local -a result + cb() { result=("$@") } + + async_start_worker test + async_job test print "hello world" + while ! async_process_results test cb; do :; done + async_stop_worker test + + # At this point, ksh arrays will only mess with the test. + setopt noksharrays + + [[ $result[1] = print ]] || t_fatal "$1 want command name: print, got" $result[1] + [[ $result[2] = 0 ]] || t_fatal "$1 want exit code: 0, got" $result[2] + + [[ $result[3] = "hello world" ]] || { + t_fatal "$1 want output: \"hello world\", got" ${(Vq-)result[3]} + } +} + +test_all_options() { + local -a opts exclude + + if [[ $ZSH_VERSION == 5.0.? ]]; then + t_skip "Test is not reliable on zsh 5.0.X" + fi + + # Make sure worker is stopped, even if tests fail. + t_defer async_stop_worker test + + { sleep 15 && t_fatal "timed out" } & + local tpid=$! + + opts=(${(k)options}) + + # These options can't be tested. + exclude=( + zle interactive restricted shinstdin stdin onecmd singlecommand + warnnestedvar errreturn + ) + + for opt in ${opts:|exclude}; do + if [[ $options[$opt] = on ]]; then + setopt_helper no$opt + else + setopt_helper $opt + fi + done 2>/dev/null # Remove redirect to see output. + + kill $tpid # Stop timeout. +} + +test_async_job_with_rc_expand_param() { + setopt localoptions rcexpandparam + + # Make sure to test with multiple options + local -a result + cb() { result=("$@") } + + async_start_worker test + async_job test print "hello world" + while ! async_process_results test cb; do :; done + async_stop_worker test + + [[ $result[1] = print ]] || t_error "want command name: print, got" $result[1] + [[ $result[2] = 0 ]] || t_error "want exit code: 0, got" $result[2] + + [[ $result[3] = "hello world" ]] || { + t_error "want output: \"hello world\", got" ${(Vq-)result[3]} + } +} + +zpty_init() { + zmodload zsh/zpty + + export PS1="" + zpty zsh 'zsh -f +Z' + zpty -r zsh zpty_init1 "**" || { + t_log "initial prompt missing" + return 1 + } + + zpty -w zsh "{ $@ }" + zpty -r -m zsh zpty_init2 "**" || { + t_log "prompt missing" + return 1 + } +} + +zpty_run() { + zpty -w zsh "$*" + zpty -r -m zsh zpty_run "**" || { + t_log "prompt missing after ${(Vq-)*}" + return 1 + } +} + +zpty_deinit() { + zpty -d zsh +} + +test_zle_watcher() { + zpty_init ' + emulate -R zsh + setopt zle + stty 38400 columns 80 rows 24 tabs -icanon -iexten + TERM=vt100 + + . "'$PWD'/async.zsh" + async_init + + print_result_cb() { print ${(Vq-)@} } + async_start_worker test + async_register_callback test print_result_cb + ' || { + zpty_deinit + t_fatal "failed to init zpty" + } + + t_defer zpty_deinit # Deinit after test completion. + + zpty -w zsh "zle -F" + zpty -r -m zsh result "*_async_zle_watcher*" || { + t_fatal "want _async_zle_watcher to be registered as zle watcher, got output ${(Vq-)result}" + } + + zpty_run async_job test 'print hello world' || t_fatal "could not send async_job command" + + zpty -r -m zsh result "*print 0 'hello world'*" || { + t_fatal "want \"print 0 'hello world'\", got output ${(Vq-)result}" + } +} + +test_main() { + # Load zsh-async before running each test. + zmodload zsh/datetime + . ./async.zsh + async_init +} diff --git a/.zprezto/modules/prompt/external/async/test.zsh b/.zprezto/modules/prompt/external/async/test.zsh new file mode 100755 index 0000000..98d44e1 --- /dev/null +++ b/.zprezto/modules/prompt/external/async/test.zsh @@ -0,0 +1,263 @@ +#!/usr/bin/env zsh +# +# zsh-async test runner. +# Checks for test files named *_test.zsh or *_test.sh and runs all functions +# named test_*. +# +emulate -R zsh + +zmodload zsh/datetime +zmodload zsh/parameter +zmodload zsh/zutil +zmodload zsh/system +zmodload zsh/zselect + +TEST_GLOB=. +TEST_RUN= +TEST_VERBOSE=0 +TEST_TRACE=1 +TEST_CODE_SKIP=100 +TEST_CODE_ERROR=101 +TEST_CODE_TIMEOUT=102 + +show_help() { + print "usage: ./test.zsh [-v] [-x] [-run pattern] [search pattern]" +} + +parse_opts() { + local -a verbose debug trace help run + + local out + zparseopts -E -D \ + v=verbose verbose=verbose -verbose=verbose \ + d=debug debug=debug -debug=debug \ + x=trace trace=trace -trace=trace \ + h=help -help=help \ + \?=help \ + run:=run -run:=run + + (( $? )) || (( $+help[1] )) && show_help && exit 0 + + if (( $#@ > 1 )); then + print -- "unknown arguments: $@" + show_help + exit 1 + fi + + [[ -n $1 ]] && TEST_GLOB=$1 + TEST_VERBOSE=$+verbose[1] + TEST_TRACE=$+trace[1] + ZTEST_DEBUG=$+debug[1] + (( $+run[2] )) && TEST_RUN=$run[2] +} + +t_runner_init() { + emulate -L zsh + + zmodload zsh/parameter + + # _t_runner is the main loop that waits for tests, + # used to abort test execution by exec. + _t_runner() { + local -a _test_defer_funcs + integer _test_errors=0 + while read -r; do + eval "$REPLY" + done + } + + _t_log() { + local trace=$1; shift + local -a lines indent + lines=("${(@f)@}") + indent=($'\t\t'${^lines[2,$#lines]}) + print -u7 -lr - $'\t'"$trace: $lines[1]" ${(F)indent} + } + + # t_log is for printing log output, visible in verbose (-v) mode. + t_log() { + local line=$funcfiletrace[1] + [[ ${line%:[0-9]*} = "" ]] && line=ztest:$functrace[1] # Not from a file. + _t_log $line "$*" + } + + # t_skip is for skipping a test. + t_skip() { + _t_log $funcfiletrace[1] "$*" + () { return 100 } + t_done + } + + # t_error logs the error and fails the test without aborting. + t_error() { + (( _test_errors++ )) + _t_log $funcfiletrace[1] "$*" + } + + # t_fatal fails the test and halts execution immediately. + t_fatal() { + _t_log $funcfiletrace[1] "$*" + () { return 101 } + t_done + } + + # t_defer takes a function (and optionally, arguments) + # to be executed after the test has completed. + t_defer() { + _test_defer_funcs+=("$*") + } + + # t_done completes the test execution, called automatically after a test. + # Can also be called manually when the test is done. + t_done() { + local ret=$? w=${1:-1} + (( _test_errors )) && ret=101 + + (( w )) && wait # Wait for test children to exit. + for d in $_test_defer_funcs; do + eval "$d" + done + print -n -u8 $ret # Send exit code to ztest. + exec _t_runner # Replace shell, wait for new test. + } + + source $1 # Load the test module. + + # Send available test functions to main process. + print -u7 ${(R)${(okM)functions:#test_*}:#test_main} + + # Run test_main. + if [[ -n $functions[test_main] ]]; then + test_main + fi + + exec _t_runner # Wait for commands. +} + +# run_test_module runs all the tests from a test module (asynchronously). +run_test_module() { + local module=$1 + local -a tests + float start module_time + + # Create fd's for communication with test runner. + integer run_pid cmdoutfd cmdinfd outfd infd doneoutfd doneinfd + + coproc cat; exec {cmdoutfd}>&p; exec {cmdinfd}<&p + coproc cat; exec {outfd}>&p; exec {infd}<&p + coproc cat; exec {doneoutfd}>&p; exec {doneinfd}<&p + + # No need to keep coproc (&p) open since we + # have redirected the outputs and inputs. + coproc exit + + # Launch a new interactive zsh test runner. We don't capture stdout + typeset -a run_args + (( TEST_TRACE )) && run_args+=('-x') + zsh -s $run_args <&$cmdinfd 7>&$outfd 8>&$doneoutfd & + run_pid=$! + + # Initialize by sending function body from t_runner_init + # and immediately execute it as an anonymous function. + syswrite -o $cmdoutfd "() { ${functions[t_runner_init]} } $module"$'\n' + sysread -i $infd + tests=(${(@)=REPLY}) + [[ -n $TEST_RUN ]] && tests=(${(M)tests:#*$TEST_RUN*}) + + integer mod_exit=0 + float mod_start mod_time + + mod_start=$EPOCHREALTIME # Store the module start time. + + # Run all tests. + local test_out + float test_start test_time + integer text_exit + + for test in $tests; do + (( TEST_VERBOSE )) && print "=== RUN $test" + + test_start=$EPOCHREALTIME # Store the test start time. + + # Start the test. + syswrite -o $cmdoutfd "$test; t_done"$'\n' + + test_out= + test_exit=-1 + while (( test_exit == -1 )); do + # Block until there is data to be read. + zselect -r $doneinfd -r $infd + + if [[ $reply[2] = $doneinfd ]]; then + sysread -i $doneinfd + test_exit=$REPLY # Store reply from sysread + # Store the test execution time. + test_time=$(( EPOCHREALTIME - test_start )) + fi + + # Read all output from the test output channel. + while sysread -i $infd -t 0; do + test_out+=$REPLY + unset REPLY + done + done + + case $test_exit in + (0|1) state=PASS;; + (100) state=SKIP;; + (101|102) state=FAIL; mod_exit=1;; + *) state="????";; + esac + + if [[ $state = FAIL ]] || (( TEST_VERBOSE )); then + printf -- "--- $state: $test (%.2fs)\n" $test_time + print -n $test_out + fi + done + + # Store module execution time. + mod_time=$(( EPOCHREALTIME - mod_start )) + + # Perform cleanup. + kill -HUP $run_pid + exec {outfd}>&- + exec {infd}<&- + exec {cmdinfd}>&- + exec {cmdoutfd}<&- + exec {doneinfd}<&- + exec {doneoutfd}>&- + + if (( mod_exit )); then + print "FAIL" + (( TEST_VERBOSE )) && print "exit code $mod_exit" + printf "FAIL\t$module\t%.3fs\n" $mod_time + else + (( TEST_VERBOSE )) && print "PASS" + printf "ok\t$module\t%.3fs\n" $mod_time + fi + + return $mod_exit +} + +cleanup() { + trap - HUP + kill -HUP $$ 2>/dev/null + kill -HUP -$$ 2>/dev/null +} + +trap cleanup EXIT INT HUP QUIT TERM USR1 + +# Parse command arguments. +parse_opts $@ + +(( ZTEST_DEBUG )) && setopt xtrace + +# Execute tests modules. +failed=0 +for tf in ${~TEST_GLOB}/*_test.(zsh|sh); do + run_test_module $tf & + wait $! + (( $? )) && failed=1 +done + +exit $failed diff --git a/.zprezto/modules/prompt/external/powerlevel9k/.git_backup b/.zprezto/modules/prompt/external/powerlevel9k/.git_backup new file mode 100644 index 0000000..ee40b25 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/.git_backup @@ -0,0 +1 @@ +gitdir: ../../../../.git/modules/modules/prompt/external/powerlevel9k diff --git a/.zprezto/modules/prompt/external/powerlevel9k/.github_backup/ISSUE_TEMPLATE.md b/.zprezto/modules/prompt/external/powerlevel9k/.github_backup/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..01fbc41 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/.github_backup/ISSUE_TEMPLATE.md @@ -0,0 +1,35 @@ +Thanks for opening an issue! For a project that deals with as many different things as P9k, debugging problems can be difficult. Please follow the guide, below, to create a bug report that will help us help you! + +### Before Opening a Bug +P9k is lovingly maintained by volunteers, and we are happy to help you! You can help us by first making sure your issue hasn't already been solved before opening a new one. Please check the [Troubleshooting Guide](https://github.com/bhilburn/powerlevel9k/wiki/Troubleshooting) first. Many issues are actually local configuration problems, which may have previously been solved by another user - be sure to also [search the existing issues](https://github.com/bhilburn/powerlevel9k/issues?utf8=%E2%9C%93&q=is%3Aissue) before opening a new one. + +Once you've done these things, you can delete this section and proceed `=)` + +----- + +#### Describe Your Issue +What is happening? + +Most issues are best explained with a screenshot. Please share one if you can! + +#### Have you tried to debug or fix it? + + +Have you tinkered with your settings, and what happened when you did? Did you find a bit of code that you think might be the culprit? Let us know what you've done so far! + +#### Environment Information +This information will help us understand your configuration. + + - What version of ZSH are you using? You can use `zsh --version` to see this. + - Do you use a ZSH framework (e.g., Oh-My-ZSH, Antigen)? + - How did you install P9k (cloning the repo, by tarball, a package from your OS, etc.,)? + - What version of P9k are you using? + - Which terminal emulator do you use? + +#### Issues with Fonts & Icons +You may delete this section if your issue is not font / icon related. + + - Which font do you use? + - Which [font configuration mode](https://github.com/bhilburn/powerlevel9k/wiki/About-Fonts) are you using? You can check this with (`echo $POWERLEVEL9K_MODE`). + - Please share the contents of `$P9k/debug/font-issues.zsh`. + - If this is an icon problem, does the output of `$ get_icon_names` look correct? diff --git a/.zprezto/modules/prompt/external/powerlevel9k/.github_backup/PULL_REQUEST_TEMPLATE.md b/.zprezto/modules/prompt/external/powerlevel9k/.github_backup/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..4ade805 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/.github_backup/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,32 @@ +Thank you so much for opening a PR for P9k! Many of our best features and segments have come from the community, and we are excited to see your contribution. + +To help you make the best PR, here are some guidelines: + + - The `master` branch is our *stable* branch, and the `next` branch is our development branch. If you are submitting a bug fix, please file your PR against `master`. If it is a new feature, enhancement, segment, or something similar, please submit it against `next`. For more information, please see our [Developer's Guide](https://github.com/bhilburn/powerlevel9k/wiki/Developer's-Guide). + - We maintain unit tests for segments and features in the `test` directory. Please add unit tests for anything new you have developed! If you aren't sure how to do this, go ahead and file your PR and ask for help! + - For running manual tests in different environments, we have Vagrant and Docker configurations. Please see the [Test README](https://github.com/bhilburn/powerlevel9k/blob/next/TESTS.md) and make sure your new feature is working as expected! + - If your PR requires user configuration, please make sure that it includes an update to the README describing this. + - P9k maintains a lot of useful information in our [Wiki](https://github.com/bhilburn/powerlevel9k/wiki). Depending on the content of your PR, we might ask you to update the Wiki (or provide text for us to use) to document your work. Most PRs don't require this. + - Please make your commit messages useful! Here is a [great short guide on useful commit messages](https://code.likeagirl.io/useful-tips-for-writing-better-git-commit-messages-808770609503). + +Once you have submitted your PR, P9k core contributors will review the code and work with you to get it merged. During this process, we might request changes to your code and discuss different ways of doing things. This is all part of the open source process, and our goal is to help you create the best contribution possible for P9k `=)`. + +Please follow this template for creating your PR: + +#### Title +Please make the title of your PR descriptive! If appropriate, please prefix the title with one of these tags: + + - [Bugfix] + - [New Segment] + - [Docs] + - [Enhancement] + +#### Description +Please describe the contribution your PR makes! Screenshots are especially helpful, here, if it's a new segment. + +If your PR is addressing an issue, please reference the Issue number here. + +#### Questions +Is there something in your PR you're not sure about or need help with? Is there a particular piece of code you would like feedback on? Let us know here! + + diff --git a/.zprezto/modules/prompt/external/powerlevel9k/.gitignore_backup b/.zprezto/modules/prompt/external/powerlevel9k/.gitignore_backup new file mode 100644 index 0000000..83a6246 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/.gitignore_backup @@ -0,0 +1,3 @@ +test-vm/.vagrant +*.swp +.idea \ No newline at end of file diff --git a/.zprezto/modules/prompt/external/powerlevel9k/.gitmodules_backup b/.zprezto/modules/prompt/external/powerlevel9k/.gitmodules_backup new file mode 100644 index 0000000..743b8e9 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/.gitmodules_backup @@ -0,0 +1,3 @@ +[submodule "shunit2"] + path = shunit2 + url = https://github.com/kward/shunit2.git diff --git a/.zprezto/modules/prompt/external/powerlevel9k/.travis.yml_backup b/.zprezto/modules/prompt/external/powerlevel9k/.travis.yml_backup new file mode 100644 index 0000000..648499a --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/.travis.yml_backup @@ -0,0 +1,32 @@ +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 + - test/segments/kubecontext.spec + - test/segments/laravel_version.spec diff --git a/.zprezto/modules/prompt/external/powerlevel9k/CHANGELOG.md b/.zprezto/modules/prompt/external/powerlevel9k/CHANGELOG.md new file mode 100644 index 0000000..02341f4 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/CHANGELOG.md @@ -0,0 +1,432 @@ +## v0.6.5 + +- Multiple PRs: General fixes to README, improved documentation. +- Multiple PRs: Improvements to icons / glyphs. +- PR #777: now possible to always show the Ruby env segment. +- PR #773: Fixed issue with home abbreviation in directory segment. +- PR #789: Now properly working around some odd ZSH status return codes. +- PR #716: Now possible to configure the colors of the VCS segment in rebase mode. +- PR #722: Removed dependency on `bc` for `load` segment. +- PR #686: Fixed issue where whitespaces in path occasionally broke `dir` segment. +- PR #685: No longer accidentally invoking user `grep` aliases. +- PR #680: Using env variable for `PYENV` properly, now. +- PR #676, #611: Fixes for Kubernetes segment. +- PR #667: Supporting multiple AWS profiles. +- PR #660: Fixing directory parsing issue with PYTHONPATH. +- PR #663: Fixed silly issues causing ZSH warnings. +- PR #647: Fixing `public_ip` segment for macOS. +- PR #643: Fixing `vpn_ip` segment naming. +- PR #636: `context` segment now grabs user with command rather than env. +- PR #618: Fix issue where `su -` didn't change context segment. +- PR #608: Load average selection in `load` segment. + +### New Segment: `laravel_version` + +Displays the current laravel version. + +## v0.6.4 + +- `load` segment now has configurable averages. +- Update to `dir` segment to add `dir_writable` feature. +- `status` segment can now display POSIX signal name of exit code. +- Added `teardown` command to turn off P9k prompt. +- Fixes for P9k in Cygwin and 32-bit systems. +- Better colors in virtualization segments. +- Added 'Gopher' icon to the `go_version` segment. +- Improved detection in `nvm` +- Added option to support command status reading from piped command sequences. +- Fixed issue with visual artifacts with quick consecutive commands. +- Updated 'ananconda' segment for more uniform styling. +- `rvm` segment can now support usernames with dashes. +- Fixed Python icon reference in some font configurations. +- Vi mode indicator fixed. +- Fixes for Docker segment. +- Added new Docker-based testing system. +- Significant enhancements to the `battery` segment. Check out the README to + read more! +- New truncation strategy that truncates until the path becomes unique. + +### New Segments: `host` and `user` + +Provides two separate segments for `host` and `user` in case you don't wont both +in one (per the `context` segment). + +### New Segment: `newline` + +Allows you to split segments across multiple lines. + +### New Segment: `kubecontext` + +Shows the current context of your `kubectl` configuration. + +### New Segment: `vpn` + +Shows current `vpn` interface. + +## v0.6.3 + +- Fixed susceptibility to [pw3nage exploit](https://github.com/njhartwell/pw3nage). +- Added support for Android +- The abbreviation for $HOME is now configurable (doesn't have to be `~`). +- Fixed colorization of VCS segment in Subversion repos. +- Improved handling of symlinks in installation paths. + +## v0.6.2 + +- Fixed some issues with the new `nerdfont-fontconfig` option. +- Fixed typo in README. +- The `get_icon_names` function can now print sorted output, and show which + icons users have overridden. +- Added a FreeBSD VM for testing. + +### Add debug script for iTerm2 issues + +A new script `debug/iterm.zsh` was added for easier spotting problems with your iTerm2 configuration. + +### Add debug script for font issues + +A new script `debug/font-issues.zsh` was added, so that problems with your font could be spotted easier. + +### `ram` changes + +The `ram` segment now shows the available ram instead of free. + +### Add new segments `host` and `user` + +The user and host segments allow you to have different icons and colors for both the user and host segments +depending on their state. + +## v0.6.0 + +- Fixed a bug where the tag display was broken on detached HEADs. +- Fixed a bug where SVN detection sometimes failed. +- Fixed the `load` and `ram` segments for BSD. +- Fixed code-points that changed in Awesome fonts. +- Fixed display of "OK_ICON" in `status` segment in non-verbose mode. +- Fixed an issue where dir name truncation that was very short sometimes failed. +- Speed & accuracy improvements to the battery segment. +- Added Github syntax highlighting to README. +- Various documentation cleanup. + +### New Font Option: nerd-fonts + +There is now an option to use [nerd-fonts](https://github.com/ryanoasis/nerd-fonts) with P9k. Simply configure the `nerdfont-fontconfig`, and you'll be set! + +### `vcs` changes + +The VCS segment can now display icons for remote repo hosting services, including Github, Gitlab, and 'other'. + +### `dir` changes + +Added an option to configure the path separator. If you want something +else than an ordinary slash, you could set +`POWERLEVEL9K_DIR_PATH_SEPARATOR` to whatever you want. + +#### `truncate_with_package_name` now searches for `composer.json` as well + +Now `composer.json` files are searched as well. By default `package.json` still takes +precedence. If you want to change that, set `POWERLEVEL9K_DIR_PACKAGE_FILES=(composer.json package.json)`. + +### New segment `command_execution_time` added + +Shows the duration a command needed to run. By default only durations over 3 seconds +are shown (can be adjusted by setting POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD). + +### New segment `dir_writable` added + +This segment displays a lock icon if your user has no write permissions in the current folder. + +### New segment `disk_usage` added + +This segment will show the usage level of your current partition. + +### New segment `public_ip` added + +Fetches your Public IP (using ident.me) and displays it in your prompt. + +### New segment `swift_version` added + +This segment displays the version of Swift that is installed / in your path. + +### New segment `detect_virt` added + +Detects and reports if you are in a virtualized session using `systemd`. + +## v0.5.0 + +### `load` and `ram` changes + +These two segments now support BSD. + +### `vcs` changes + +- We implemented a huge speed improvement for this segment. +- Now this segment supports Subversion repositories. +- Add ability to hide tags by setting `POWERLEVEL9K_VCS_HIDE_TAGS` to true. + +## `anaconda` changes + +Speed improvements for `anaconda` segment. + +## v0.4.0 + +### Development changes + +From now on, development makes use of a CI system "travis". + +### `vcs` changes + +The default state was renamed to `clean`. If you overrode foreground +or background color in the past, you need to rename your variables to: + +```zsh +POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan' +POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white' +``` + +Additionaly the vcs segment now has an `untracked` state which +indicates that you have untracked files in your repository. + +The foreground color of actionformat is now configurable via: +```zsh +POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND='green' +``` + +Also, the vcs segment uses the foreground color it was configured to. +That said, the variables `POWERLEVEL9K_VCS_FOREGROUND` and +`POWERLEVEL9K_VCS_DARK_FOREGROUND` are no longer used. Instead use +the proper variable `POWERLEVEL9K_VCS__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/.zprezto/modules/prompt/external/powerlevel9k/CODE_OF_CONDUCT.md b/.zprezto/modules/prompt/external/powerlevel9k/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..22c9ebb --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at bhilburn@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/LICENSE b/.zprezto/modules/prompt/external/powerlevel9k/LICENSE new file mode 100644 index 0000000..812d306 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/LICENSE @@ -0,0 +1,20 @@ +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/.zprezto/modules/prompt/external/powerlevel9k/README.md b/.zprezto/modules/prompt/external/powerlevel9k/README.md new file mode 100644 index 0000000..90680ac --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/README.md @@ -0,0 +1,739 @@ +![](https://raw.githubusercontent.com/bhilburn/powerlevel9k-logo/master/logo-banner.png) +--- +[![Build Status](https://travis-ci.org/bhilburn/powerlevel9k.svg?branch=master)](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. +* [`date`](#date) - System date. +* [`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. +* [`host`](#host) - Your current host name +* [`ip`](#ip) - Shows the current IP address. +* [`vpn_ip`](#vpn_ip) - Shows the current VPN IP address. +* [`public_ip`](#public_ip) - Shows your public IP address. +* [`load`](#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. +* [`user`](#user) - Your current username +* [`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. + * `laravel_version` - Show the current Laravel 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. + * `rvm` - Ruby environment information using `$GEM_HOME` and `$MY_RUBY_HOME` (if one is active). +* **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. +* **Java Segments:** + * `java_version` - Show the current Java version. + +**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. +* `kubecontext` - The current context of your `kubectl` configuration. +* `dropbox` - Indicates Dropbox directory and syncing status using `dropbox-cli` + +**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 +* `newline` - Continues the prompt on a new line. +* `openfoam` - Shows the currently sourced [OpenFOAM](https://openfoam.org/) environment. + +--------------------------------------------------------------------------------- + + +##### 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.| +`POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS`|`false`|Always show the jobs count (even if it's zero).| + +##### battery + +The default settings for 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. + +You can also change the battery icon automatically depending on the battery +level. This will override the default battery icon. In order to do this, you +need to define the `POWERLEVEL9k_BATTERY_STAGES` variable. + + +| Variable | Default Value | Description | +|-------------------------------|---------------|---------------------------------------------------------------| +| `POWERLEVEL9K_BATTERY_STAGES` | Unset | A string or array, which each index indicates a charge level. | + +Powerlevel9k will use each index of the string or array as a stage to indicate battery +charge level, progressing from left to right. You can provide any number of +stages. The setting below, for example, provides 8 stages for Powerlevel9k to use. +```zsh +POWERLEVEL9K_BATTERY_STAGES="▁▂▃▄▅▆▇█" +``` + +If you require extra spacing after the icon, you will have to set it as an array, +since spaces in the string will be used as one of the stages and you will get a +missing icon. To do this, declare the variable as follows: +```zsh +POWERLEVEL9K_BATTERY_STAGES=($'\u2581 ' $'\u2582 ' $'\u2583 ' $'\u2584 ' $'\u2585 ' $'\u2586 ' $'\u2587 ' $'\u2588 ') +``` + +Using the array syntax, you can create stages comprised of multiple characters. +The below setting provides 40 battery stages. +```zsh +POWERLEVEL9K_BATTERY_STAGES=( + $'▏ ▏' $'▎ ▏' $'▍ ▏' $'▌ ▏' $'▋ ▏' $'▊ ▏' $'▉ ▏' $'█ ▏' + $'█▏ ▏' $'█▎ ▏' $'█▍ ▏' $'█▌ ▏' $'█▋ ▏' $'█▊ ▏' $'█▉ ▏' $'██ ▏' + $'██ ▏' $'██▎ ▏' $'██▍ ▏' $'██▌ ▏' $'██▋ ▏' $'██▊ ▏' $'██▉ ▏' $'███ ▏' + $'███ ▏' $'███▎ ▏' $'███▍ ▏' $'███▌ ▏' $'███▋ ▏' $'███▊ ▏' $'███▉ ▏' $'████ ▏' + $'████ ▏' $'████▎▏' $'████▍▏' $'████▌▏' $'████▋▏' $'████▊▏' $'████▉▏' $'█████▏' ) +``` + +You can also change the background of the segment automatically depending on the +battery level. This will override the following variables: +`POWERLEVEL9K_BATTERY_CHARGING`, `POWERLEVEL9K_BATTERY_CHARGED`, +`POWERLEVEL9K_BATTERY_DISCONNECTED`, and `POWERLEVEL9K_BATTERY_LOW_COLOR`. In +order to do this, define a color array, from low to high, as shown below: +```zsh +POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND=(red1 orangered1 darkorange orange1 gold1 yellow1 yellow2 greenyellow chartreuse1 chartreuse2 green1) +``` + +As with the battery stages, you can use any number of colors and Powerlevel9k +will automatically use all of them appropriately. + +Some example settings: + +| Brightness | Possible Array | +|----------------|---------------------------------------------------------------------------------------------------------------| +| Bright Colors | `(red1 orangered1 darkorange orange1 gold1 yellow1 yellow2 greenyellow chartreuse1 chartreuse2 green1)` | +| Normal Colors | `(red3 darkorange3 darkgoldenrod gold3 yellow3 chartreuse2 mediumspringgreen green3 green3 green4 darkgreen)` | +| Subdued Colors | `(darkred orange4 yellow4 yellow4 chartreuse3 green3 green4 darkgreen)` | + +##### chruby + +This segment shows the version of Ruby being used when using `chruby` to change your current Ruby stack. + +It uses `$RUBY_ENGINE` and `$RUBY_VERSION` as set by `chruby`. + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`POWERLEVEL9K_CHRUBY_SHOW_ENGINE`|true|Show the currently selected Ruby engine (e.g. `ruby`, `jruby`, `rbx`, etc) +|`POWERLEVEL9K_CHRUBY_SHOW_VERSION`|true|Shows the currently selected engine's version (e.g. `2.5.1`) + +##### 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. `SUDO` and `REMOTE_SUDO` states are also available to show whether the current user or remote user has superuser privileges. + +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.| + +##### date + +The `date` segment shows the current system date. + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`POWERLEVEL9K_DATE_FORMAT`|`%D{%d.%m.%y}`|[ZSH time format](http://zsh.sourceforge.net/Doc/Release Prompt-Expansion.html) to use in this segment.| + +##### 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_DIR_PATH_ABSOLUTE`|None|If set to `true`, will use absolute paths instead of home folder abbreviation `~`| +|`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_absolute_chars`|Truncates an absolute number of characters from the left such that the number of characters that your path displays (with or without `POWERLEVEL9K_SHORTEN_DELIMITER`) is no more than `POWERLEVEL9K_SHORTEN_DIR_LENGTH` + the length of `POWERLEVEL9K_SHORTEN_DELIMITER` | +|`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_absolute`|Truncates everything exept the last few characters in the path. E.g. if you are in a folder named "~/Projects/powerlevel9k" and you have set `POWERLEVEL9K_SHORTEN_DIR_LENGTH=3`, you will get "..l9k".| +|`truncate_to_last`|Truncates everything before the last folder in the path.| +|`truncate_to_first_and_last|Truncate middle directories from the path. How many directories will be untouched is controlled by POWERLEVEL9K_SHORTER_DIR_LENGTH. E.g. if you are in a folder named "~/Projects/powerlevel9k" and you have set `POWERLEVEL9K_SHORTEN_DIR_LENGTH=1`, you will get "~/../powerlevel9k".|| +|`truncate_to_unique`|Parse all parent path components and truncate them to the shortest unique length. If you copy & paste the result to a shell, after hitting `TAB` it should expand to the original path unambiguously.| +|`truncate_with_package_name`|Search for a `package.json` or `composer.json` and prints the `name` field to abbreviate the directory path. The precedence and/or files could be set by `POWERLEVEL9K_DIR_PACKAGE_FILES=(package.json composer.json)`. If you have [jq](https://stedolan.github.io/jq/) installed, it will dramatically improve the speed of this strategy.| +|`truncate_with_folder_marker`|Search for a file that is specified by `POWERLEVEL9K_SHORTEN_FOLDER_MARKER` and truncate everything before that (if found, otherwise stop on $HOME and ROOT).| + +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}" +``` +You can also configure the `dir` segment to show when you are in a directory without write permissions, using the variable below. + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`POWERLEVEL9K_DIR_SHOW_WRITABLE`|`false`|If set to `true` and you are in a directory that you do not have write permissions for, this segment will display a lock icon and enter the `NOT_WRITABLE` state (which can be customized per [our usual process](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt#segment-color-customization)). Note that this functionality is also available in a separate segment, `dir_writable`.| + +If you want to customize the last directory of the path, you can now set `POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND` to a custom color and/or `POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true` to display that part in bold. + +You can also color the separator separately by setting the color using `POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND`. + +##### 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.| + +##### host + +The `host` segment will print the hostname. + +You can set the `POWERLEVEL9K_HOST_TEMPLATE` 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. + +``` +POWERLEVEL9K_HOST_TEMPLATE="%2m" +``` + +By default, LOCAL hosts will show the host icon and remote hosts will show the SSH icon. You can override them by setting +``` +POWERLEVEL9K_HOST_ICON="\uF109 " +POWERLEVEL9K_SSH_ICON="\uF489 " +``` + + +##### 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`.| + +##### vpn_ip + +This segment tries to extract the VPN related IP addresses from nmcli, based on the NIC type: + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`POWERLEVEL9K_VPN_IP_INTERFACE`|`tun`|The VPN interface.| + +##### 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. + +If you activate a VPN, the icon for this segment will change to the defined VPN icon. + +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/p9k_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| + +##### load + +Displays one of your load averages with appropriate state coloring. The thresholds are: +- `0.7 * NUM_CORES <`: critical +- `0.5 * NUM_CORES <`: warning +- `less`: normal + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`POWERLEVEL9K_LOAD_WHICH`|5|Which average to show. Possible values: 1, 5 or 15| + +##### newline + +Puts a newline in your prompt so you can continue using segments on the next +line. This allows you to use segments on both lines, unlike +`POWERLEVEL9K_PROMPT_ON_NEWLINE`, which simply separates segments from the +prompt itself. + +This only works on the left side. On the right side it does nothing. + +##### 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. +* By default, if the current local Ruby version is the same as the global Ruby version, nothing will be shown. See the configuration variable, below, to modify this behavior. + +Variable | Default Value | Description | +|----------|---------------|-------------| +|`POWERLEVEL9K_RBENV_ALWAYS`|'false'|Always show the `rbenv` segment, even if the local version matches the global.| + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW`|`false`|Set to true if you wish to show the rbenv segment even if the current Ruby version is the same as the global Ruby version| + +##### 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_CROSS`|`false`|Set to true if you wish not to 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` to false.| +|`POWERLEVEL9K_STATUS_OK`|`true`|Set to true if you wish to show this segment when the last command completed successfully, false to hide it.| +|`POWERLEVEL9K_STATUS_SHOW_PIPESTATUS`|`true`|Set to true if you wish to show the exit status for all piped commands.| +|`POWERLEVEL9K_STATUS_HIDE_SIGNAME`|`false`|Set to true return the raw exit code (`1-255`). When set to false, values over 128 are shown as `SIGNAME(-n)` (e.g. `KILL(-9)`)| + +##### 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}" +``` +##### user + +The `user` segment will print the username. + +You can also override the icons by setting: + +``` +POWERLEVEL9K_USER_ICON="\uF415" #  +POWERLEVEL9K_ROOT_ICON="#" +POWERLEVEL9K_SUDO_ICON=$'\uF09C' #  +``` + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`DEFAULT_USER`|None|Username to consider a "default context".| +|`POWERLEVEL9K_ALWAYS_SHOW_USER`|`false`|Always print this segment.| +|`POWERLEVEL9K_USER_TEMPLATE`|`%n`|Default username prompt. Refer to the [ZSH Documentation](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) for all possible expansions| + +##### 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.| +|`POWERLEVEL9K_VCS_GIT_HOOKS`|`(vcs-detect-changes git-untracked git-aheadbehind git-stash git-remotebranch git-tagname)`|Layout of the segment for git repositories.| +|`POWERLEVEL9K_VCS_HG_HOOKS`|`(vcs-detect-changes)`|Layout of the segment for Mercurial repositories.| +|`POWERLEVEL9K_VCS_SVN_HOOKS`|`(vcs-detect-changes svn-detect-changes)`|Layout of the segment for SVN repositories.| +|`POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND`|`red`|The color of the foreground font during actions (e.g., `REBASE`).| + + +##### 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 + +##### vcs truncation + +You can limit the branch name to a certain length by truncating long names. +Customizations available are: + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`POWERLEVEL9K_VCS_SHORTEN_LENGTH`|None|This field determines how many characters to show.| +|`POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH`|None|This field determines minimum branch length. Branch name will be truncated if its length greater than this field.| +|`POWERLEVEL9K_VCS_SHORTEN_STRATEGY`|None|This field determines how branch name should be truncated. See the table below for more information.| +|`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 | +|---------------|-------------| +|`truncate_middle`|Truncates the middle part of a branch. E.g. branch name is `1234-super_super_long_branch_name`, then it will truncated to `1234-..._name`, if `POWERLEVEL9K_VCS_SHORTEN_LENGTH=5` is also set (controls the amount of characters to be left).| +|`truncate_from_right`|Just leaves the beginning of a branch name untouched. E.g. branch name will be truncated like so: `1234-...`. How many characters will be untouched is controlled by `POWERLEVEL9K_VCS_SHORTEN_LENGTH`.| + +For example, if you want to truncate `1234-super_super_long_branch_name` to `1234-..` and don't do it with `development`: +```zsh +POWERLEVEL9K_VCS_SHORTEN_LENGTH=4 +POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=11 +POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right" +POWERLEVEL9K_VCS_SHORTEN_DELIMITER=".." +``` + +##### 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.| + +To hide the segment entirely when in `INSERT` mode, set `POWERLEVEL9K_VI_INSERT_MODE_STRING=''` + +#### 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. + +### Disabling / Enabling Powerlevel9k + +You can disable P9k and return to a very basic prompt at any time simply by +calling: + +```zsh +$ prompt_powerlevel9k_teardown +``` + +You can then re-enable it by calling: + +```zsh +$ prompt_powerlevel9k_setup +``` + +### 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/.zprezto/modules/prompt/external/powerlevel9k/TESTS.md b/.zprezto/modules/prompt/external/powerlevel9k/TESTS.md new file mode 100644 index 0000000..eb5db70 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/TESTS.md @@ -0,0 +1,49 @@ +# 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`. + +# Manual Testing + +If unit tests are not sufficient (e.g. you have an issue with your prompt that +occurs only in a specific ZSH framework) then you can use either Docker or +or our Vagrant. + +## Docker + +This is the easiest to use _if_ you have Docker already installed and running. + +The command `./test-in-docker` should make it fairly easy to get into a running +container with the framework of your choice. + +Examples: + +``` zsh +# Test Antigen with the oldest version of ZSH +$ ./test-in-docker antigen +``` + +``` zsh +# Test Prezto with ZSH version 5.2 +$ ./test-in-docker --zsh 5.2 prezto +``` + +You can get Docker at . + +**Note:** Not all frameworks work with all versions of ZSH (or the underlying OS). + +## Vagrant + +Currently there are two test VMs. `test-vm` is an Ubuntu machine with several +pre-installed ZSH frameworks. And there is `test-bsd-vm` which is a FreeBSD! +For how to run the machines see [here](test-vm/README.md). diff --git a/.zprezto/modules/prompt/external/powerlevel9k/debug/font-issues.zsh b/.zprezto/modules/prompt/external/powerlevel9k/debug/font-issues.zsh new file mode 100755 index 0000000..166a6ac --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/debug/font-issues.zsh @@ -0,0 +1,182 @@ +#!/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/.zprezto/modules/prompt/external/powerlevel9k/debug/iterm.zsh b/.zprezto/modules/prompt/external/powerlevel9k/debug/iterm.zsh new file mode 100755 index 0000000..702175f --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/debug/iterm.zsh @@ -0,0 +1,86 @@ +#!/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/.zprezto/modules/prompt/external/powerlevel9k/docker/antibody/Dockerfile b/.zprezto/modules/prompt/external/powerlevel9k/docker/antibody/Dockerfile new file mode 100644 index 0000000..84a60a8 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/antibody/Dockerfile @@ -0,0 +1,8 @@ +ARG base +FROM p9k:${base} + +COPY docker/antibody/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/antibody/zshrc .zshrc diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/antibody/install.zsh b/.zprezto/modules/prompt/external/powerlevel9k/docker/antibody/install.zsh new file mode 100644 index 0000000..4c54fa6 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/antibody/install.zsh @@ -0,0 +1 @@ +curl -sL https://git.io/antibody | bash -s diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/antibody/zshrc b/.zprezto/modules/prompt/external/powerlevel9k/docker/antibody/zshrc new file mode 100644 index 0000000..d516b67 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/antibody/zshrc @@ -0,0 +1,2 @@ +source <(antibody init) +antibody bundle ~/p9k/ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/antigen/Dockerfile b/.zprezto/modules/prompt/external/powerlevel9k/docker/antigen/Dockerfile new file mode 100644 index 0000000..d8d0a4b --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/antigen/Dockerfile @@ -0,0 +1,8 @@ +ARG base +FROM p9k:${base} + +COPY docker/antigen/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/antigen/zshrc .zshrc diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/antigen/install.zsh b/.zprezto/modules/prompt/external/powerlevel9k/docker/antigen/install.zsh new file mode 100644 index 0000000..6bab8ab --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/antigen/install.zsh @@ -0,0 +1,12 @@ +#!/bin/zsh + +mkdir ~/antigen + +curl \ + -qLsSf \ + -o ~/antigen/antigen.zsh \ + https://git.io/antigen + +source ~/antigen/antigen.zsh + +# EOF diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/antigen/zshrc b/.zprezto/modules/prompt/external/powerlevel9k/docker/antigen/zshrc new file mode 100644 index 0000000..0f8d4da --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/antigen/zshrc @@ -0,0 +1,4 @@ +source ~/antigen/antigen.zsh + +antigen theme "${HOME}/p9k" powerlevel9k --no-local-clone +antigen apply diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/base-4.3.11/Dockerfile b/.zprezto/modules/prompt/external/powerlevel9k/docker/base-4.3.11/Dockerfile new file mode 100644 index 0000000..805a7ae --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/base-4.3.11/Dockerfile @@ -0,0 +1,31 @@ +FROM centos:6 + +RUN \ + yum install -y \ + curl \ + git \ + zsh \ + mercurial \ + subversion \ + golang \ + jq \ + node \ + ruby \ + python \ + python-virtualenv \ + sudo + +RUN adduser --shell /bin/zsh --comment 'fred' --user-group fred + +COPY docker/fred-sudoers /etc/sudoers.d/fred + +USER fred +WORKDIR /home/fred +ENV LANG=en_US.UTF-8 +ENV TERM=xterm-256color +ENV DEFAULT_USER=fred +ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true + +RUN touch .zshrc + +CMD ["/bin/zsh", "-l"] diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/base-5.0.3/Dockerfile b/.zprezto/modules/prompt/external/powerlevel9k/docker/base-5.0.3/Dockerfile new file mode 100644 index 0000000..e0b6c6c --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/base-5.0.3/Dockerfile @@ -0,0 +1,33 @@ +FROM ubuntu:14.04 + +RUN \ + apt-get update && \ + echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + curl \ + git \ + zsh \ + mercurial \ + subversion \ + golang \ + jq \ + node \ + ruby \ + python \ + python-virtualenv + +RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred +RUN locale-gen "en_US.UTF-8" + +COPY docker/fred-sudoers /etc/sudoers.d/fred + +USER fred +WORKDIR /home/fred +ENV LANG=en_US.UTF-8 +ENV TERM=xterm-256color +ENV DEFAULT_USER=fred +ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true + +RUN touch .zshrc + +CMD ["/bin/zsh", "-l"] diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/base-5.1.1/Dockerfile b/.zprezto/modules/prompt/external/powerlevel9k/docker/base-5.1.1/Dockerfile new file mode 100644 index 0000000..a7f644b --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/base-5.1.1/Dockerfile @@ -0,0 +1,35 @@ +FROM ubuntu:16.04 + +RUN \ + apt-get update && \ + echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + curl \ + git \ + zsh \ + mercurial \ + subversion \ + golang \ + jq \ + nodejs \ + ruby \ + python \ + python-virtualenv \ + sudo \ + locales + +RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred +RUN locale-gen "en_US.UTF-8" + +COPY docker/fred-sudoers /etc/sudoers.d/fred + +USER fred +WORKDIR /home/fred +ENV LANG=en_US.UTF-8 +ENV TERM=xterm-256color +ENV DEFAULT_USER=fred +ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true + +RUN touch .zshrc + +CMD ["/bin/zsh", "-l"] diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/base-5.2/Dockerfile b/.zprezto/modules/prompt/external/powerlevel9k/docker/base-5.2/Dockerfile new file mode 100644 index 0000000..62a1007 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/base-5.2/Dockerfile @@ -0,0 +1,35 @@ +FROM ubuntu:17.04 + +RUN \ + apt-get update && \ + echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + curl \ + git \ + zsh \ + mercurial \ + subversion \ + golang \ + jq \ + nodejs \ + ruby \ + python \ + python-virtualenv \ + sudo \ + locales + +RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred +RUN locale-gen "en_US.UTF-8" + +COPY docker/fred-sudoers /etc/sudoers.d/fred + +USER fred +WORKDIR /home/fred +ENV LANG=en_US.UTF-8 +ENV TERM=xterm-256color +ENV DEFAULT_USER=fred +ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true + +RUN touch .zshrc + +CMD ["/bin/zsh", "-l"] diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/dotfile/Dockerfile b/.zprezto/modules/prompt/external/powerlevel9k/docker/dotfile/Dockerfile new file mode 100644 index 0000000..f29c4d5 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/dotfile/Dockerfile @@ -0,0 +1,5 @@ +ARG base +FROM p9k:${base} + +COPY ./ p9k/ +COPY docker/dotfile/zshrc .zshrc diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/dotfile/zshrc b/.zprezto/modules/prompt/external/powerlevel9k/docker/dotfile/zshrc new file mode 100644 index 0000000..382b84a --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/dotfile/zshrc @@ -0,0 +1 @@ +source "${HOME}/p9k/prompt_powerlevel9k_setup" diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/fred-sudoers b/.zprezto/modules/prompt/external/powerlevel9k/docker/fred-sudoers new file mode 100644 index 0000000..5fcd646 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/fred-sudoers @@ -0,0 +1,2 @@ +Defaults:fred !requiretty +fred ALL=(ALL) NOPASSWD: ALL diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/omz/Dockerfile b/.zprezto/modules/prompt/external/powerlevel9k/docker/omz/Dockerfile new file mode 100644 index 0000000..1a417b9 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/omz/Dockerfile @@ -0,0 +1,8 @@ +ARG base +FROM p9k:${base} + +COPY docker/omz/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY docker/omz/zshrc .zshrc +COPY ./ p9k/ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/omz/install.zsh b/.zprezto/modules/prompt/external/powerlevel9k/docker/omz/install.zsh new file mode 100644 index 0000000..e2cdfa9 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/omz/install.zsh @@ -0,0 +1,4 @@ +sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" + +mkdir -p ~/.oh-my-zsh/custom/themes +ln -nsf ~/p9k/ ~/.oh-my-zsh/custom/themes/powerlevel9k diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/omz/zshrc b/.zprezto/modules/prompt/external/powerlevel9k/docker/omz/zshrc new file mode 100644 index 0000000..9e798e2 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/omz/zshrc @@ -0,0 +1,5 @@ +export ZSH=$HOME/.oh-my-zsh +ZSH_THEME="powerlevel9k/powerlevel9k" +plugins=(git rake ruby) + +source $ZSH/oh-my-zsh.sh diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/prezto/Dockerfile b/.zprezto/modules/prompt/external/powerlevel9k/docker/prezto/Dockerfile new file mode 100644 index 0000000..70f3b65 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/prezto/Dockerfile @@ -0,0 +1,7 @@ +ARG base +FROM p9k:${base} + +COPY docker/prezto/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/prezto/install.zsh b/.zprezto/modules/prompt/external/powerlevel9k/docker/prezto/install.zsh new file mode 100644 index 0000000..9cca57e --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/prezto/install.zsh @@ -0,0 +1,18 @@ +#!/bin/zsh + +set -eu + +git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto" + +setopt EXTENDED_GLOB +for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do + ln -nsf "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}" +done + +ln -s "${HOME}/p9k/powerlevel9k.zsh-theme" \ + "${HOME}/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup" + +echo "zstyle ':prezto:module:prompt' theme 'powerlevel9k'" \ + >> "${HOME}/.zpreztorc" + +# EOF diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/zgen/Dockerfile b/.zprezto/modules/prompt/external/powerlevel9k/docker/zgen/Dockerfile new file mode 100644 index 0000000..48e44c7 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/zgen/Dockerfile @@ -0,0 +1,8 @@ +ARG base +FROM p9k:${base} + +COPY docker/zgen/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/zgen/zshrc .zshrc diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/zgen/install.zsh b/.zprezto/modules/prompt/external/powerlevel9k/docker/zgen/install.zsh new file mode 100644 index 0000000..5cdc618 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/zgen/install.zsh @@ -0,0 +1,5 @@ +#!/bin/zsh + +git clone https://github.com/tarjoilija/zgen.git "${HOME}/.zgen" + +# EOF diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/zgen/zshrc b/.zprezto/modules/prompt/external/powerlevel9k/docker/zgen/zshrc new file mode 100644 index 0000000..1fcb75b --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/zgen/zshrc @@ -0,0 +1,10 @@ +# load zgen +source ~/.zgen/zgen.zsh + +# if the init scipt doesn't exist +if ! zgen saved; then + zgen load ~/p9k/powerlevel9k.zsh-theme + + # generate the init script from plugins above + zgen save +fi diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/zim/Dockerfile b/.zprezto/modules/prompt/external/powerlevel9k/docker/zim/Dockerfile new file mode 100644 index 0000000..cfe0fc9 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/zim/Dockerfile @@ -0,0 +1,7 @@ +ARG base +FROM p9k:${base} + +COPY docker/zim/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/zim/install.zsh b/.zprezto/modules/prompt/external/powerlevel9k/docker/zim/install.zsh new file mode 100644 index 0000000..d6c6006 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/zim/install.zsh @@ -0,0 +1,21 @@ +#!zsh + +git clone --recursive https://github.com/Eriner/zim.git "${ZDOTDIR:-${HOME}}/.zim" + +setopt EXTENDED_GLOB +for template_file ( ${ZDOTDIR:-${HOME}}/.zim/templates/* ); do + user_file="${ZDOTDIR:-${HOME}}/.${template_file:t}" + touch ${user_file} + ( print -rn "$(<${template_file})$(<${user_file})" >! ${user_file} ) 2>/dev/null +done + +source "${ZDOTDIR:-${HOME}}/.zlogin" + +ln -nsf \ + ~/p9k/ \ + ~/.zim/modules/prompt/external-themes/powerlevel9k +ln -nsf \ + ~/.zim/modules/prompt/external-themes/powerlevel9k/powerlevel9k.zsh-theme \ + ~/.zim/modules/prompt/functions/prompt_powerlevel9k_setup + +sed -i "s/zprompt_theme='steeef'/zprompt_theme='powerlevel9k'/g" ~/.zimrc diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/zplug/Dockerfile b/.zprezto/modules/prompt/external/powerlevel9k/docker/zplug/Dockerfile new file mode 100644 index 0000000..89c23d5 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/zplug/Dockerfile @@ -0,0 +1,8 @@ +ARG base +FROM p9k:${base} + +COPY docker/zplug/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/zplug/zshrc .zshrc diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/zplug/install.zsh b/.zprezto/modules/prompt/external/powerlevel9k/docker/zplug/install.zsh new file mode 100644 index 0000000..b01ff6e --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/zplug/install.zsh @@ -0,0 +1,5 @@ +#!zsh + +curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh| zsh + +# git clone https://github.com/zplug/zplug "${HOME}/.zplug" diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/zplug/zshrc b/.zprezto/modules/prompt/external/powerlevel9k/docker/zplug/zshrc new file mode 100644 index 0000000..0a4ceb8 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/zplug/zshrc @@ -0,0 +1,5 @@ +#!zsh + +source ~/.zplug/init.zsh +zplug "${HOME}/p9k", use:"powerlevel9k.zsh-theme", from:local, as:theme +zplug load --verbose diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/zplugin/Dockerfile b/.zprezto/modules/prompt/external/powerlevel9k/docker/zplugin/Dockerfile new file mode 100644 index 0000000..90c35c0 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/zplugin/Dockerfile @@ -0,0 +1,8 @@ +ARG base +FROM p9k:${base} + +COPY docker/zplugin/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/zplugin/zshrc.plugins .zshrc.plugins diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/zplugin/install.zsh b/.zprezto/modules/prompt/external/powerlevel9k/docker/zplugin/install.zsh new file mode 100644 index 0000000..fec4249 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/zplugin/install.zsh @@ -0,0 +1,12 @@ +sh -c "$(curl -fsSL https://raw.githubusercontent.com/psprint/zplugin/master/doc/install.sh)" + +# The 'zplugin snippet' only copies the .zsh-theme file, not everything else. +mkdir -p ~/.zplugin/snippets +ln -nsf \ + ~/p9k/ \ +~/.zplugin/snippets/--SLASH--home--SLASH--fred--SLASH--p9k--SLASH--powerlevel9k--DOT--zsh-theme + +{ + echo + echo "source ~/.zshrc.plugins" +} >> ~/.zshrc diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/zplugin/zshrc.plugins b/.zprezto/modules/prompt/external/powerlevel9k/docker/zplugin/zshrc.plugins new file mode 100644 index 0000000..2e9ba7a --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/zplugin/zshrc.plugins @@ -0,0 +1,5 @@ +#!zsh + +zplugin load psprint zsh-navigation-tools +zplugin load psprint---zprompts +zplugin snippet ~/p9k/powerlevel9k.zsh-theme diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/zpm/Dockerfile b/.zprezto/modules/prompt/external/powerlevel9k/docker/zpm/Dockerfile new file mode 100644 index 0000000..c1c44e3 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/zpm/Dockerfile @@ -0,0 +1,8 @@ +ARG base +FROM p9k:${base} + +COPY docker/zpm/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/zpm/zshrc .zshrc diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/zpm/install.zsh b/.zprezto/modules/prompt/external/powerlevel9k/docker/zpm/install.zsh new file mode 100644 index 0000000..6f74e8e --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/zpm/install.zsh @@ -0,0 +1,6 @@ +# install zpm +git clone --recursive https://github.com/zpm-zsh/zpm.git ~/.zpm + +# Install powerlevel9k +mkdir ~/.zpm/plugins/powerlevel9k +ln -s ~/p9k/powerlevel9k.zsh-theme ~/.zpm/plugins/powerlevel9k/powerlevel9k.plugin.zsh diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/zpm/zshrc b/.zprezto/modules/prompt/external/powerlevel9k/docker/zpm/zshrc new file mode 100644 index 0000000..b107976 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/zpm/zshrc @@ -0,0 +1,3 @@ +source ~/.zpm/zpm.zsh + +zpm load powerlevel9k diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/zulu/Dockerfile b/.zprezto/modules/prompt/external/powerlevel9k/docker/zulu/Dockerfile new file mode 100644 index 0000000..880a07d --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/zulu/Dockerfile @@ -0,0 +1,7 @@ +ARG base +FROM p9k:${base} + +COPY docker/zulu/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/docker/zulu/install.zsh b/.zprezto/modules/prompt/external/powerlevel9k/docker/zulu/install.zsh new file mode 100644 index 0000000..0ad6aae --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/docker/zulu/install.zsh @@ -0,0 +1,10 @@ +#!zsh + +# install zulu https://github.com/zulu-zsh/zulu +curl -L https://git.io/zulu-install | zsh && zsh + +{ +echo 'zulu fpath add ~/p9k' +echo 'zulu fpath add ~/p9k/functions' +echo 'zulu theme powerlevel9k' +} >> ~/.zshrc diff --git a/.zprezto/modules/prompt/external/powerlevel9k/functions/colors.zsh b/.zprezto/modules/prompt/external/powerlevel9k/functions/colors.zsh new file mode 100755 index 0000000..e98bfd4 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/functions/colors.zsh @@ -0,0 +1,377 @@ +# 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 +################################################################ + +function termColors() { + if [[ $POWERLEVEL9K_IGNORE_TERM_COLORS == true ]]; then + return + fi + + local term_colors + + if which tput &>/dev/null; then + term_colors=$(tput colors) + else + term_colors=$(echotc Co) + fi + if (( ! $? && ${term_colors:-0} < 256 )); then + print -P "%F{red}WARNING!%f Your terminal appears to support fewer 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 +} + +# get the proper color code if it does not exist as a name. +function getColor() { + # no need to check numerical values + if [[ "$1" = <-> ]]; then + if [[ "$1" = <8-15> ]]; then + 1=$(($1 - 8)) + fi + else + # named color added to parameter expansion print -P to test if the name exists in terminal + local named="%K{$1}" + # https://misc.flogisoft.com/bash/tip_colors_and_formatting + local default="$'\033'\[49m" + # http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html + local quoted=$(printf "%q" $(print -P "$named")) + if [[ $quoted = "$'\033'\[49m" && $1 != "black" ]]; then + # color not found, so try to get the code + 1=$(getColorCode $1) + fi + fi + echo -n "$1" +} + +# empty paramenter resets (stops) background color +function backgroundColor() { + if [[ -z $1 ]]; then + echo -n "%k" + else + echo -n "%K{$(getColor $1)}" + fi +} + +# empty paramenter resets (stops) foreground color +function foregroundColor() { + if [[ -z $1 ]]; then + echo -n "%f" + else + echo -n "%F{$(getColor $1)}" + fi +} + +# 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 -n $(($1 - 8)) + else + echo -n "$1" + fi + else + typeset -A codes + # https://jonasjacek.github.io/colors/ + # use color names by default to allow dark/light themes to adjust colors based on names + codes[black]=000 + codes[maroon]=001 + codes[green]=002 + codes[olive]=003 + codes[navy]=004 + codes[purple]=005 + codes[teal]=006 + codes[silver]=007 + codes[grey]=008 + codes[red]=009 + codes[lime]=010 + codes[yellow]=011 + codes[blue]=012 + codes[fuchsia]=013 + codes[aqua]=014 + codes[white]=015 + codes[grey0]=016 + codes[navyblue]=017 + codes[darkblue]=018 + codes[blue3]=019 + codes[blue3]=020 + codes[blue1]=021 + codes[darkgreen]=022 + codes[deepskyblue4]=023 + codes[deepskyblue4]=024 + codes[deepskyblue4]=025 + codes[dodgerblue3]=026 + codes[dodgerblue2]=027 + codes[green4]=028 + codes[springgreen4]=029 + codes[turquoise4]=030 + codes[deepskyblue3]=031 + codes[deepskyblue3]=032 + codes[dodgerblue1]=033 + codes[green3]=034 + codes[springgreen3]=035 + codes[darkcyan]=036 + codes[lightseagreen]=037 + codes[deepskyblue2]=038 + codes[deepskyblue1]=039 + codes[green3]=040 + codes[springgreen3]=041 + codes[springgreen2]=042 + codes[cyan3]=043 + codes[darkturquoise]=044 + codes[turquoise2]=045 + codes[green1]=046 + codes[springgreen2]=047 + codes[springgreen1]=048 + codes[mediumspringgreen]=049 + codes[cyan2]=050 + codes[cyan1]=051 + codes[darkred]=052 + codes[deeppink4]=053 + codes[purple4]=054 + codes[purple4]=055 + codes[purple3]=056 + codes[blueviolet]=057 + codes[orange4]=058 + codes[grey37]=059 + codes[mediumpurple4]=060 + codes[slateblue3]=061 + codes[slateblue3]=062 + codes[royalblue1]=063 + codes[chartreuse4]=064 + codes[darkseagreen4]=065 + codes[paleturquoise4]=066 + codes[steelblue]=067 + codes[steelblue3]=068 + codes[cornflowerblue]=069 + codes[chartreuse3]=070 + codes[darkseagreen4]=071 + codes[cadetblue]=072 + codes[cadetblue]=073 + codes[skyblue3]=074 + codes[steelblue1]=075 + codes[chartreuse3]=076 + codes[palegreen3]=077 + codes[seagreen3]=078 + codes[aquamarine3]=079 + codes[mediumturquoise]=080 + codes[steelblue1]=081 + codes[chartreuse2]=082 + codes[seagreen2]=083 + codes[seagreen1]=084 + codes[seagreen1]=085 + codes[aquamarine1]=086 + codes[darkslategray2]=087 + codes[darkred]=088 + codes[deeppink4]=089 + codes[darkmagenta]=090 + codes[darkmagenta]=091 + codes[darkviolet]=092 + codes[purple]=093 + codes[orange4]=094 + codes[lightpink4]=095 + codes[plum4]=096 + codes[mediumpurple3]=097 + codes[mediumpurple3]=098 + codes[slateblue1]=099 + codes[yellow4]=100 + codes[wheat4]=101 + codes[grey53]=102 + codes[lightslategrey]=103 + codes[mediumpurple]=104 + codes[lightslateblue]=105 + codes[yellow4]=106 + codes[darkolivegreen3]=107 + codes[darkseagreen]=108 + codes[lightskyblue3]=109 + codes[lightskyblue3]=110 + codes[skyblue2]=111 + codes[chartreuse2]=112 + codes[darkolivegreen3]=113 + codes[palegreen3]=114 + codes[darkseagreen3]=115 + codes[darkslategray3]=116 + codes[skyblue1]=117 + codes[chartreuse1]=118 + codes[lightgreen]=119 + codes[lightgreen]=120 + codes[palegreen1]=121 + codes[aquamarine1]=122 + codes[darkslategray1]=123 + codes[red3]=124 + codes[deeppink4]=125 + codes[mediumvioletred]=126 + codes[magenta3]=127 + codes[darkviolet]=128 + codes[purple]=129 + codes[darkorange3]=130 + codes[indianred]=131 + codes[hotpink3]=132 + codes[mediumorchid3]=133 + codes[mediumorchid]=134 + codes[mediumpurple2]=135 + codes[darkgoldenrod]=136 + codes[lightsalmon3]=137 + codes[rosybrown]=138 + codes[grey63]=139 + codes[mediumpurple2]=140 + codes[mediumpurple1]=141 + codes[gold3]=142 + codes[darkkhaki]=143 + codes[navajowhite3]=144 + codes[grey69]=145 + codes[lightsteelblue3]=146 + codes[lightsteelblue]=147 + codes[yellow3]=148 + codes[darkolivegreen3]=149 + codes[darkseagreen3]=150 + codes[darkseagreen2]=151 + codes[lightcyan3]=152 + codes[lightskyblue1]=153 + codes[greenyellow]=154 + codes[darkolivegreen2]=155 + codes[palegreen1]=156 + codes[darkseagreen2]=157 + codes[darkseagreen1]=158 + codes[paleturquoise1]=159 + codes[red3]=160 + codes[deeppink3]=161 + codes[deeppink3]=162 + codes[magenta3]=163 + codes[magenta3]=164 + codes[magenta2]=165 + codes[darkorange3]=166 + codes[indianred]=167 + codes[hotpink3]=168 + codes[hotpink2]=169 + codes[orchid]=170 + codes[mediumorchid1]=171 + codes[orange3]=172 + codes[lightsalmon3]=173 + codes[lightpink3]=174 + codes[pink3]=175 + codes[plum3]=176 + codes[violet]=177 + codes[gold3]=178 + codes[lightgoldenrod3]=179 + codes[tan]=180 + codes[mistyrose3]=181 + codes[thistle3]=182 + codes[plum2]=183 + codes[yellow3]=184 + codes[khaki3]=185 + codes[lightgoldenrod2]=186 + codes[lightyellow3]=187 + codes[grey84]=188 + codes[lightsteelblue1]=189 + codes[yellow2]=190 + codes[darkolivegreen1]=191 + codes[darkolivegreen1]=192 + codes[darkseagreen1]=193 + codes[honeydew2]=194 + codes[lightcyan1]=195 + codes[red1]=196 + codes[deeppink2]=197 + codes[deeppink1]=198 + codes[deeppink1]=199 + codes[magenta2]=200 + codes[magenta1]=201 + codes[orangered1]=202 + codes[indianred1]=203 + codes[indianred1]=204 + codes[hotpink]=205 + codes[hotpink]=206 + codes[mediumorchid1]=207 + codes[darkorange]=208 + codes[salmon1]=209 + codes[lightcoral]=210 + codes[palevioletred1]=211 + codes[orchid2]=212 + codes[orchid1]=213 + codes[orange1]=214 + codes[sandybrown]=215 + codes[lightsalmon1]=216 + codes[lightpink1]=217 + codes[pink1]=218 + codes[plum1]=219 + codes[gold1]=220 + codes[lightgoldenrod2]=221 + codes[lightgoldenrod2]=222 + codes[navajowhite1]=223 + codes[mistyrose1]=224 + codes[thistle1]=225 + codes[yellow1]=226 + codes[lightgoldenrod1]=227 + codes[khaki1]=228 + codes[wheat1]=229 + codes[cornsilk1]=230 + codes[grey100]=231 + codes[grey3]=232 + codes[grey7]=233 + codes[grey11]=234 + codes[grey15]=235 + codes[grey19]=236 + codes[grey23]=237 + codes[grey27]=238 + codes[grey30]=239 + codes[grey35]=240 + codes[grey39]=241 + codes[grey42]=242 + codes[grey46]=243 + codes[grey50]=244 + codes[grey54]=245 + codes[grey58]=246 + codes[grey62]=247 + codes[grey66]=248 + codes[grey70]=249 + codes[grey74]=250 + codes[grey78]=251 + codes[grey82]=252 + codes[grey85]=253 + codes[grey89]=254 + codes[grey93]=255 + + # for testing purposes in terminal + if [[ "$1" == "foreground" ]]; then + # call via `getColorCode foreground` + for i in "${(k@)codes}"; do + print -P "$(foregroundColor $i)$(getColor $i) - $i$(foregroundColor)" + done + elif [[ "$1" == "background" ]]; then + # call via `getColorCode background` + for i in "${(k@)codes}"; do + print -P "$(backgroundColor $i)$(getColor $i) - $i$(backgroundColor)" + done + else + #[[ -n "$1" ]] bg="%K{$1}" || bg="%k" + # Strip eventual "bg-" prefixes + 1=${1#bg-} + # Strip eventual "fg-" prefixes + 1=${1#fg-} + # Strip eventual "br" prefixes ("bright" colors) + 1=${1#br} + echo -n $codes[$1] + fi + 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/.zprezto/modules/prompt/external/powerlevel9k/functions/icons.zsh b/.zprezto/modules/prompt/external/powerlevel9k/functions/icons.zsh new file mode 100755 index 0000000..358f958 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/functions/icons.zsh @@ -0,0 +1,560 @@ +# 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' #  + SUDO_ICON $'\uF09C' #  + 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 $'\u2714' # ✔ + FAIL_ICON $'\u2718' # ✘ + SYMFONY_ICON 'SF' + NODE_ICON $'\u2B22' # ⬢ + MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ + MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ + MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ + APPLE_ICON $'\uE26E' #  + WINDOWS_ICON $'\uE26F' #  + FREEBSD_ICON $'\U1F608 ' # 😈 + ANDROID_ICON $'\uE270' #  + LINUX_ICON $'\uE271' #  + LINUX_ARCH_ICON 'Arc' + LINUX_DEBIAN_ICON 'Deb' + LINUX_UBUNTU_ICON 'Ubu' + LINUX_CENTOS_ICON 'Cen' + LINUX_COREOS_ICON 'Cor' + LINUX_ELEMENTARY_ICON 'Elm' + LINUX_MINT_ICON 'LMi' + LINUX_FEDORA_ICON 'Fed' + LINUX_GENTOO_ICON 'Gen' + LINUX_MAGEIA_ICON 'Mag' + LINUX_NIXOS_ICON 'Nix' + LINUX_MANJARO_ICON 'Man' + LINUX_DEVUAN_ICON 'Dev' + LINUX_ALPINE_ICON 'Alp' + LINUX_AOSC_ICON 'Aos' + LINUX_OPENSUSE_ICON 'OSu' + LINUX_SABAYON_ICON 'Sab' + LINUX_SLACKWARE_ICON 'Sla' + SUNOS_ICON $'\U1F31E ' # 🌞 + HOME_ICON $'\uE12C' #  + HOME_SUB_ICON $'\uE18D' #  + FOLDER_ICON $'\uE818' #  + NETWORK_ICON $'\uE1AD' #  + ETC_ICON $'\uE82F' #  + 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 '(rust)' + PYTHON_ICON $'\ue63c' #  + SWIFT_ICON '' + GO_ICON '' + PUBLIC_IP_ICON '' + LOCK_ICON $'\UE138' #  + EXECUTION_TIME_ICON $'\UE89C' #  + SSH_ICON '(ssh)' + VPN_ICON '(vpn)' + KUBERNETES_ICON $'\U2388' # ⎈ + DROPBOX_ICON $'\UF16B' #  + DATE_ICON $'\uE184' #  + TIME_ICON $'\uE12E' #  + JAVA_ICON $'\U2615' # ☕︎ + LARAVEL_ICON '' + ) + ;; + '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' #  + SUDO_ICON $'\uF09C' #  + 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 $'\u2714' # ✔ + FAIL_ICON $'\u2718' # ✘ + SYMFONY_ICON 'SF' + NODE_ICON $'\u2B22' # ⬢ + MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ + MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ + MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ + APPLE_ICON $'\uF179' #  + WINDOWS_ICON $'\uF17A' #  + FREEBSD_ICON $'\U1F608 ' # 😈 + ANDROID_ICON $'\uE17B' #  + LINUX_ICON $'\uF17C' #  + LINUX_ARCH_ICON 'Arc' + LINUX_DEBIAN_ICON 'Deb' + LINUX_UBUNTU_ICON 'Ubu' + LINUX_CENTOS_ICON 'Cen' + LINUX_COREOS_ICON 'Cor' + LINUX_ELEMENTARY_ICON 'Elm' + LINUX_MINT_ICON 'LMi' + LINUX_FEDORA_ICON 'Fed' + LINUX_GENTOO_ICON 'Gen' + LINUX_MAGEIA_ICON 'Mag' + LINUX_NIXOS_ICON 'Nix' + LINUX_MANJARO_ICON 'Man' + LINUX_DEVUAN_ICON 'Dev' + LINUX_ALPINE_ICON 'Alp' + LINUX_AOSC_ICON 'Aos' + LINUX_OPENSUSE_ICON 'OSu' + LINUX_SABAYON_ICON 'Sab' + LINUX_SLACKWARE_ICON 'Sla' + SUNOS_ICON $'\uF185 ' #  + HOME_ICON $'\uF015' #  + HOME_SUB_ICON $'\uF07C' #  + FOLDER_ICON $'\uF115' #  + ETC_ICON $'\uF013 ' #  + 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 $'\ue63c' #  + SWIFT_ICON '' + GO_ICON '' + PUBLIC_IP_ICON '' + LOCK_ICON $'\UF023' #  + EXECUTION_TIME_ICON $'\uF253' + SSH_ICON '(ssh)' + VPN_ICON $'\uF023' + KUBERNETES_ICON $'\U2388' # ⎈ + DROPBOX_ICON $'\UF16B' #  + DATE_ICON $'\uF073 ' #  + TIME_ICON $'\uF017 ' #  + JAVA_ICON $'\U2615' # ☕︎ + LARAVEL_ICON '' + ) + ;; + 'awesome-mapped-fontconfig') + # mapped fontconfig with awesome-font required! See + # https://github.com/gabrielelana/awesome-terminal-fonts + # don't forget to source the font maps in your startup script + # Set the right locale to protect special characters + local LC_ALL="" LC_CTYPE="en_US.UTF-8" + + if [ -z "$AWESOME_GLYPHS_LOADED" ]; then + echo "Powerlevel9k warning: Awesome-Font mappings have not been loaded. + Source a font mapping in your shell config, per the Awesome-Font docs + (https://github.com/gabrielelana/awesome-terminal-fonts), + Or use a different Powerlevel9k font configuration."; + fi + + 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 '\u'$CODEPOINT_OF_OCTICONS_ZAP #  + SUDO_ICON '\u'$CODEPOINT_OF_AWESOME_UNLOCK #  + RUBY_ICON '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  + AWS_ICON '\u'$CODEPOINT_OF_AWESOME_SERVER #  + AWS_EB_ICON $'\U1F331 ' # 🌱 + BACKGROUND_JOBS_ICON '\u'$CODEPOINT_OF_AWESOME_COG' ' #  + TEST_ICON '\u'$CODEPOINT_OF_AWESOME_BUG #  + TODO_ICON '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O #  + BATTERY_ICON '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL #  + DISK_ICON '\u'$CODEPOINT_OF_AWESOME_HDD_O' ' #  + OK_ICON '\u'$CODEPOINT_OF_AWESOME_CHECK #  + FAIL_ICON '\u'$CODEPOINT_OF_AWESOME_TIMES #  + SYMFONY_ICON 'SF' + NODE_ICON $'\u2B22' # ⬢ + MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ + MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ + APPLE_ICON '\u'$CODEPOINT_OF_AWESOME_APPLE #  + FREEBSD_ICON $'\U1F608 ' # 😈 + LINUX_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  + LINUX_ARCH_ICON 'Arc' + LINUX_DEBIAN_ICON 'Deb' + LINUX_UBUNTU_ICON 'Ubu' + LINUX_CENTOS_ICON 'Cen' + LINUX_COREOS_ICON 'Cor' + LINUX_ELEMENTARY_ICON 'Elm' + LINUX_MINT_ICON 'LMi' + LINUX_FEDORA_ICON 'Fed' + LINUX_GENTOO_ICON 'Gen' + LINUX_MAGEIA_ICON 'Mag' + LINUX_NIXOS_ICON 'Nix' + LINUX_MANJARO_ICON 'Man' + LINUX_DEVUAN_ICON 'Dev' + LINUX_ALPINE_ICON 'Alp' + LINUX_AOSC_ICON 'Aos' + LINUX_OPENSUSE_ICON 'OSu' + LINUX_SABAYON_ICON 'Sab' + LINUX_SLACKWARE_ICON 'Sla' + SUNOS_ICON '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' #  + HOME_ICON '\u'$CODEPOINT_OF_AWESOME_HOME #  + HOME_SUB_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN #  + FOLDER_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_O #  + ETC_ICON '\u'$CODEPOINT_OF_AWESOME_COG' ' #  + NETWORK_ICON '\u'$CODEPOINT_OF_AWESOME_RSS #  + LOAD_ICON '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' #  + SWAP_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  + RAM_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  + SERVER_ICON '\u'$CODEPOINT_OF_AWESOME_SERVER #  + VCS_UNTRACKED_ICON '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE #  + VCS_UNSTAGED_ICON '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE #  + VCS_STAGED_ICON '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE #  + VCS_STASH_ICON '\u'$CODEPOINT_OF_AWESOME_INBOX' ' #  + VCS_INCOMING_CHANGES_ICON '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN' ' #  + VCS_OUTGOING_CHANGES_ICON '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP' ' #  + VCS_TAG_ICON '\u'$CODEPOINT_OF_AWESOME_TAG' ' #  + VCS_BOOKMARK_ICON '\u'$CODEPOINT_OF_OCTICONS_BOOKMARK #  + VCS_COMMIT_ICON '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' #  + VCS_BRANCH_ICON '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' #  + VCS_REMOTE_BRANCH_ICON '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH #  + VCS_GIT_ICON '\u'$CODEPOINT_OF_AWESOME_GIT' ' #  + VCS_GIT_GITHUB_ICON '\u'$CODEPOINT_OF_AWESOME_GITHUB_ALT' ' #  + VCS_GIT_BITBUCKET_ICON '\u'$CODEPOINT_OF_AWESOME_BITBUCKET' ' #  + VCS_GIT_GITLAB_ICON '\u'$CODEPOINT_OF_AWESOME_GITLAB' ' #  + VCS_HG_ICON '\u'$CODEPOINT_OF_AWESOME_FLASK' ' #  + VCS_SVN_ICON '(svn) ' + RUST_ICON $'\uE6A8' #  + PYTHON_ICON $'\U1F40D' # 🐍 + SWIFT_ICON $'\uE655' #  + PUBLIC_IP_ICON '\u'$CODEPOINT_OF_AWESOME_GLOBE #  + LOCK_ICON '\u'$CODEPOINT_OF_AWESOME_LOCK #  + EXECUTION_TIME_ICON '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END #  + SSH_ICON '(ssh)' + VPN_ICON '\u'$CODEPOINT_OF_AWESOME_LOCK + KUBERNETES_ICON $'\U2388' # ⎈ + DROPBOX_ICON '\u'$CODEPOINT_OF_AWESOME_DROPBOX #  + DATE_ICON $'\uF073 ' #  + TIME_ICON $'\uF017 ' #  + JAVA_ICON $'\U2615' # ☕︎ + LARAVEL_ICON '' + ) + ;; + 'nerdfont-complete'|'nerdfont-fontconfig') + # nerd-font patched (complete) font required! See + # https://github.com/ryanoasis/nerd-fonts + # http://nerdfonts.com/#cheat-sheet + # 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 ' #  + SUDO_ICON $'\uF09C' #  + 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_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ + MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ + APPLE_ICON $'\uF179' #  + WINDOWS_ICON $'\uF17A' #  + FREEBSD_ICON $'\UF30C ' #  + ANDROID_ICON $'\uF17B' #  + LINUX_ARCH_ICON $'\uF303' #  + LINUX_CENTOS_ICON $'\uF304' #  + LINUX_COREOS_ICON $'\uF305' #  + LINUX_DEBIAN_ICON $'\uF306' #  + LINUX_ELEMENTARY_ICON $'\uF309' #  + LINUX_FEDORA_ICON $'\uF30a' #  + LINUX_GENTOO_ICON $'\uF30d' #  + LINUX_MAGEIA_ICON $'\uF310' #  + LINUX_MINT_ICON $'\uF30e' #  + LINUX_NIXOS_ICON $'\uF313' #  + LINUX_MANJARO_ICON $'\uF312' #  + LINUX_DEVUAN_ICON $'\uF307' #  + LINUX_ALPINE_ICON $'\uF300' #  + LINUX_AOSC_ICON $'\uF301' #  + LINUX_OPENSUSE_ICON $'\uF314' #  + LINUX_SABAYON_ICON $'\uF317' #  + LINUX_SLACKWARE_ICON $'\uF319' #  + LINUX_UBUNTU_ICON $'\uF31b' #  + LINUX_ICON $'\uF17C' #  + SUNOS_ICON $'\uF185 ' #  + HOME_ICON $'\uF015' #  + HOME_SUB_ICON $'\uF07C' #  + FOLDER_ICON $'\uF115' #  + ETC_ICON $'\uF013' #  + 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 $'\uF1D3 ' #  + VCS_GIT_GITHUB_ICON $'\uF113 ' #  + 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' #  + VPN_ICON '(vpn)' + KUBERNETES_ICON $'\U2388' # ⎈ + DROPBOX_ICON $'\UF16B' #  + DATE_ICON $'\uF073 ' #  + TIME_ICON $'\uF017 ' #  + JAVA_ICON $'\U2615' # ☕︎ + LARAVEL_ICON $'\ue73f ' #  + ) + ;; + *) + # 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' # ⚡ + SUDO_ICON $'\uE0A2' #  + 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 $'\u2714' # ✔ + FAIL_ICON $'\u2718' # ✘ + SYMFONY_ICON 'SF' + NODE_ICON $'\u2B22' # ⬢ + MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ + MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ + MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ + APPLE_ICON 'OSX' + WINDOWS_ICON 'WIN' + FREEBSD_ICON 'BSD' + ANDROID_ICON 'And' + LINUX_ICON 'Lx' + LINUX_ARCH_ICON 'Arc' + LINUX_DEBIAN_ICON 'Deb' + LINUX_UBUNTU_ICON 'Ubu' + LINUX_CENTOS_ICON 'Cen' + LINUX_COREOS_ICON 'Cor' + LINUX_ELEMENTARY_ICON 'Elm' + LINUX_MINT_ICON 'LMi' + LINUX_FEDORA_ICON 'Fed' + LINUX_GENTOO_ICON 'Gen' + LINUX_MAGEIA_ICON 'Mag' + LINUX_NIXOS_ICON 'Nix' + LINUX_MANJARO_ICON 'Man' + LINUX_DEVUAN_ICON 'Dev' + LINUX_ALPINE_ICON 'Alp' + LINUX_AOSC_ICON 'Aos' + LINUX_OPENSUSE_ICON 'OSu' + LINUX_SABAYON_ICON 'Sab' + LINUX_SLACKWARE_ICON 'Sla' + SUNOS_ICON 'Sun' + HOME_ICON '' + HOME_SUB_ICON '' + FOLDER_ICON '' + ETC_ICON $'\u2699' # ⚙ + 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 'Rust' + PYTHON_ICON '' + SWIFT_ICON 'Swift' + GO_ICON 'Go' + PUBLIC_IP_ICON '' + LOCK_ICON $'\UE0A2' + EXECUTION_TIME_ICON 'Dur' + SSH_ICON '(ssh)' + VPN_ICON '(vpn)' + KUBERNETES_ICON $'\U2388' # ⎈ + DROPBOX_ICON 'Dropbox' + DATE_ICON '' + TIME_ICON '' + JAVA_ICON $'\U2615' # ☕︎ + LARAVEL_ICON '' + ) + ;; +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/.zprezto/modules/prompt/external/powerlevel9k/functions/utilities.zsh b/.zprezto/modules/prompt/external/powerlevel9k/functions/utilities.zsh new file mode 100755 index 0000000..69fd2ec --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/functions/utilities.zsh @@ -0,0 +1,375 @@ +# 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 + local idx + 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') + ;; + CYGWIN_NT-* | MSYS_NT-*) + OS='Windows' + OS_ICON=$(print_icon 'WINDOWS_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_release_id="$(grep -E '^ID=([a-zA-Z]*)' /etc/os-release | cut -d '=' -f 2)" + case "$os_release_id" in + *arch*) + OS_ICON=$(print_icon 'LINUX_ARCH_ICON') + ;; + *debian*) + OS_ICON=$(print_icon 'LINUX_DEBIAN_ICON') + ;; + *ubuntu*) + OS_ICON=$(print_icon 'LINUX_UBUNTU_ICON') + ;; + *elementary*) + OS_ICON=$(print_icon 'LINUX_ELEMENTARY_ICON') + ;; + *fedora*) + OS_ICON=$(print_icon 'LINUX_FEDORA_ICON') + ;; + *coreos*) + OS_ICON=$(print_icon 'LINUX_COREOS_ICON') + ;; + *gentoo*) + OS_ICON=$(print_icon 'LINUX_GENTOO_ICON') + ;; + *mageia*) + OS_ICON=$(print_icon 'LINUX_MAGEIA_ICON') + ;; + *centos*) + OS_ICON=$(print_icon 'LINUX_CENTOS_ICON') + ;; + *opensuse*|*tumbleweed*) + OS_ICON=$(print_icon 'LINUX_OPENSUSE_ICON') + ;; + *sabayon*) + OS_ICON=$(print_icon 'LINUX_SABAYON_ICON') + ;; + *slackware*) + OS_ICON=$(print_icon 'LINUX_SLACKWARE_ICON') + ;; + *linuxmint*) + OS_ICON=$(print_icon 'LINUX_MINT_ICON') + ;; + *alpine*) + OS_ICON=$(print_icon 'LINUX_ALPINE_ICON') + ;; + *aosc*) + OS_ICON=$(print_icon 'LINUX_AOSC_ICON') + ;; + *nixos*) + OS_ICON=$(print_icon 'LINUX_NIXOS_ICON') + ;; + *devuan*) + OS_ICON=$(print_icon 'LINUX_DEVUAN_ICON') + ;; + *manjaro*) + OS_ICON=$(print_icon 'LINUX_MANJARO_ICON') + ;; + *) + OS='Linux' + OS_ICON=$(print_icon 'LINUX_ICON') + ;; + esac + + # 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. +# Parameters: +# * $1 Path: string - the directory path to be truncated +# * $2 Length: integer - length to truncate to +# * $3 Delimiter: string - the delimiter to use +# * $4 From: string - "right" | "middle". If omited, assumes right. +function truncatePath() { + # if the current path is not 1 character long (e.g. "/" or "~") + if (( ${#1} > 1 )); then + # convert $2 from string to integer + 2=$(( $2 )) + # set $3 to "" if not defined + [[ -z $3 ]] && 3="" || 3=$(echo -n $3) + # set $4 to "right" if not defined + [[ -z $4 ]] && 4="right" + # create a variable for the truncated path. + local trunc_path + # if the path is in the home folder, add "~/" to the start otherwise "/" + [[ $1 == "~"* ]] && trunc_path='~/' || trunc_path='/' + # split the path into an array using "/" as the delimiter + local paths=$1 + paths=(${(s:/:)${paths//"~\/"/}}) + # declare locals for the directory being tested and its length + local test_dir test_dir_length + # do the needed truncation + case $4 in + right) + # include the delimiter length in the threshhold + local threshhold=$(( $2 + ${#3} )) + # loop through the paths + for (( i=1; i<${#paths}; i++ )); do + # get the current directory value + test_dir=$paths[$i] + test_dir_length=${#test_dir} + # only truncate if the resulting truncation will be shorter than + # the truncation + delimiter length and at least 3 characters + if (( $test_dir_length > $threshhold )) && (( $test_dir_length > 3 )); then + # use the first $2 characters and the delimiter + trunc_path+="${test_dir:0:$2}$3/" + else + # use the full path + trunc_path+="${test_dir}/" + fi + done + ;; + middle) + # we need double the length for start and end truncation + delimiter length + local threshhold=$(( $2 * 2 )) + # create a variable for the start of the end truncation + local last_pos + # loop through the paths + for (( i=1; i<${#paths}; i++ )); do + # get the current directory value + test_dir=$paths[$i] + test_dir_length=${#test_dir} + # only truncate if the resulting truncation will be shorter than + # the truncation + delimiter length + if (( $test_dir_length > $threshhold )); then + # use the first $2 characters, the delimiter and the last $2 characters + last_pos=$(( $test_dir_length - $2 )) + trunc_path+="${test_dir:0:$2}$3${test_dir:$last_pos:$test_dir_length}/" + else + # use the full path + trunc_path+="${test_dir}/" + fi + done + ;; + esac + # return the truncated path + the current directory + echo $trunc_path${1:t} + else # current path is 1 character long (e.g. "/" or "~") + echo $1 + fi +} + +# Given a directory path, truncate it according to the settings for +# `truncate_from_right` +function truncatePathFromRight() { + local delim_len=${#POWERLEVEL9K_SHORTEN_DELIMITER:-1} + 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/.zprezto/modules/prompt/external/powerlevel9k/functions/vcs.zsh b/.zprezto/modules/prompt/external/powerlevel9k/functions/vcs.zsh new file mode 100755 index 0000000..b99e7c8 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/functions/vcs.zsh @@ -0,0 +1,169 @@ +# 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 [[ $(command git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \ + -n $(command 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=$(command git symbolic-ref --short HEAD 2>/dev/null) + + # for git prior to 1.7 + # ahead=$(command git rev-list origin/${branch_name}..HEAD | wc -l) + ahead=$(command 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=$(command git rev-list HEAD..origin/${branch_name} | wc -l) + behind=$(command 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=${$(command git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/} + branch_name=$(command git symbolic-ref --short HEAD 2>/dev/null) + + if [[ -n "$POWERLEVEL9K_VCS_SHORTEN_LENGTH" ]] && [[ -n "$POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH" ]]; then + set_default POWERLEVEL9K_VCS_SHORTEN_DELIMITER $'\U2026' + + if [ ${#hook_com[branch]} -gt $POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH ] && [ ${#hook_com[branch]} -gt $POWERLEVEL9K_VCS_SHORTEN_LENGTH ]; then + case "$POWERLEVEL9K_VCS_SHORTEN_STRATEGY" in + truncate_middle) + hook_com[branch]="$(echo "${branch_name:0:$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")$POWERLEVEL9K_VCS_SHORTEN_DELIMITER$(echo "${branch_name: -$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")" + ;; + truncate_from_right) + hook_com[branch]="$(echo "${branch_name:0:$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")$POWERLEVEL9K_VCS_SHORTEN_DELIMITER" + ;; + esac + fi + fi + + 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=$(command 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 $(command 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=$(command 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 $(command git rev-parse --git-dir)/refs/stash ]] ; then + stashes=$(command 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=$(command 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" =~ "stash" ]] 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/.zprezto/modules/prompt/external/powerlevel9k/powerlevel9k.zsh-theme b/.zprezto/modules/prompt/external/powerlevel9k/powerlevel9k.zsh-theme new file mode 100755 index 0000000..c1ea754 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/powerlevel9k.zsh-theme @@ -0,0 +1,1912 @@ +# 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 +#PS4='%s%f%b%k%F{blue}%{λ%}%L %F{240}%N:%i%(?.. %F{red}%?) %1(_.%F{yellow}%-1_ .)%s%f%b%k ' +#zstyle ':vcs_info:*+*:*' debug true +#set -o xtrace + +# Try to set the installation path +if [[ -n "$POWERLEVEL9K_INSTALLATION_DIR" ]]; then + p9k_directory=${POWERLEVEL9K_INSTALLATION_DIR:A} +else + if [[ "${(%):-%N}" == '(eval)' ]]; then + if [[ "$0" == '-antigen-load' ]] && [[ -r "${PWD}/powerlevel9k.zsh-theme" ]]; then + # Antigen uses eval to load things so it can change the plugin (!!) + # https://github.com/zsh-users/antigen/issues/581 + p9k_directory=$PWD + else + print -P "%F{red}You must set POWERLEVEL9K_INSTALLATION_DIR work from within an (eval).%f" + return 1 + fi + else + # Get the path to file this code is executing in; then + # get the absolute path and strip the filename. + # See https://stackoverflow.com/a/28336473/108857 + p9k_directory=${${(%):-%x}:A:h} + fi +fi + +################################################################ +# Source icon functions +################################################################ + +source "${p9k_directory}/functions/icons.zsh" + +################################################################ +# Source utility functions +################################################################ + +source "${p9k_directory}/functions/utilities.zsh" + +################################################################ +# Source color functions +################################################################ + +source "${p9k_directory}/functions/colors.zsh" + +################################################################ +# Source VCS_INFO hooks / helper functions +################################################################ + +source "${p9k_directory}/functions/vcs.zsh" + +# cleanup temporary variables. +unset p9k_directory + +################################################################ +# 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="$(backgroundColor $3)" || bg="$(backgroundColor)" + [[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="$(foregroundColor)" + + 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="$fg" || complement="$(foregroundColor $DEFAULT_COLOR)" + echo -n "${bg}${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 + # Add an whitespace if we print more than just the visual identifier. + # To avoid cutting off the visual identifier in some terminal emulators (e.g., Konsole, st), + # we need to color both the visual identifier and the whitespace. + [[ -n "$5" ]] && visual_identifier="$visual_identifier " + # 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" + 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="$(backgroundColor $3)" || bg="$(backgroundColor)" + [[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="$(foregroundColor)" + + # If CURRENT_RIGHT_BG is "NONE", we are the first right segment. + + if [[ "$CURRENT_RIGHT_BG" != "NONE" ]]; then + # This is the closing whitespace for the previous segment + echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f" + fi + + 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="$fg" || complement="$(foregroundColor $DEFAULT_COLOR)" + echo -n "$complement$(print_icon 'RIGHT_SUBSEGMENT_SEPARATOR')%f" + else + # Use the new BG color for the foreground with separator + echo -n "$(foregroundColor $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 + # Add an whitespace if we print more than just the visual identifier. + # To avoid cutting off the visual identifier in some terminal emulators (e.g., Konsole, st), + # we need to color both the visual identifier and the whitespace. + [[ -n "$5" ]] && visual_identifier=" $visual_identifier" + # 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" + 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}" + + 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. + local _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_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 +set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS false +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 ]] || [[ "$POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS" == "true" ]]); 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 +} + +################################################################ +# A newline in your prompt, so you can segments on multiple lines. +prompt_newline() { + local lws newline + [[ "$1" == "right" ]] && return + newline=$'\n' + lws=$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS + if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then + newline="${newline}$(print_icon 'MULTILINE_NEWLINE_PROMPT_PREFIX')" + fi + POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS= + "$1_prompt_segment" \ + "$0" \ + "$2" \ + "NONE" "NONE" "${newline}" + POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws +} + +################################################################ +# 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 +} + +################################################################ +# Segment that displays the battery status in levels and colors +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 + + # override default icon if we are using battery stages + if [[ -n "$POWERLEVEL9K_BATTERY_STAGES" ]]; then + local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_STAGES} - 1 ) )) + if [[ $segment > 1 ]]; then + local offset=$(( ($bat_percent / $segment) + 1 )) + # check if the stages are in an array or a string + [[ "${(t)POWERLEVEL9K_BATTERY_STAGES}" =~ "array" ]] && POWERLEVEL9K_BATTERY_ICON="$POWERLEVEL9K_BATTERY_STAGES[$offset]" || POWERLEVEL9K_BATTERY_ICON=${POWERLEVEL9K_BATTERY_STAGES:$offset:1} + fi + fi + # return if POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD is set and the battery percentage is greater or equal + if [[ -v "POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD" && "${bat_percent}" -ge $POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD ]]; then + return + fi + + # override the default color if we are using a color level array + if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then + local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) )) + local offset=$(( ($bat_percent / $segment) + 1 )) + "$1_prompt_segment" "$0_${current_state}" "$2" "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" + else + # Draw the prompt_segment + "$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 + if [[ "$OS" == "OSX" ]]; then + timediff=$(($(date +%s) - $(stat -f "%m" $POWERLEVEL9K_PUBLIC_IP_FILE))) + else + timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) + fi + [[ $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 + icon='PUBLIC_IP_ICON' + # Check VPN is on if VPN interface is set + if [[ -n $POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]]; then + for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE" | cut -d":" -f1) + do + icon='VPN_ICON' + break + done + fi + $1_prompt_segment "$0" "$2" "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${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" + "SUDO" "yellow" + "DEFAULT" "yellow" + "REMOTE" "yellow" + "REMOTE_SUDO" "yellow" + ) + + local content="" + + if [[ "$POWERLEVEL9K_ALWAYS_SHOW_CONTEXT" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + content="${POWERLEVEL9K_CONTEXT_TEMPLATE}" + elif [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]]; then + content="$(whoami)" + else + return + fi + + if [[ $(print -P "%#") == '#' ]]; then + current_state="ROOT" + elif [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + if sudo -n true 2>/dev/null; then + current_state="REMOTE_SUDO" + else + current_state="REMOTE" + fi + elif sudo -n true 2>/dev/null; then + current_state="SUDO" + fi + + "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" +} + +################################################################ +# User: user (who am I) +# Note that if $DEFAULT_USER is not set, this prompt segment will always print +set_default POWERLEVEL9K_USER_TEMPLATE "%n" +prompt_user() { + local current_state="DEFAULT" + typeset -AH user_state + if [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]]; then + if [[ $(print -P "%#") == '#' ]]; then + user_state=( + "STATE" "ROOT" + "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "ROOT_ICON" + ) + elif sudo -n true 2>/dev/null; then + user_state=( + "STATE" "SUDO" + "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "SUDO_ICON" + ) + else + user_state=( + "STATE" "DEFAULT" + "CONTENT" "$(whoami)" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "USER_ICON" + ) + fi + "$1_prompt_segment" "${0}_${user_state[STATE]}" "$2" "${user_state[BACKGROUND_COLOR]}" "${user_state[FOREGROUND_COLOR]}" "${user_state[CONTENT]}" "${user_state[VISUAL_IDENTIFIER]}" + fi +} + +################################################################ +# Host: machine (where am I) +set_default POWERLEVEL9K_HOST_TEMPLATE "%m" +prompt_host() { + local current_state="LOCAL" + typeset -AH host_state + if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then + host_state=( + "STATE" "REMOTE" + "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "SSH_ICON" + ) + else + host_state=( + "STATE" "LOCAL" + "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "HOST_ICON" + ) + fi + "$1_prompt_segment" "$0_${host_state[STATE]}" "$2" "${host_state[BACKGROUND_COLOR]}" "${host_state[FOREGROUND_COLOR]}" "${host_state[CONTENT]}" "${host_state[VISUAL_IDENTIFIER]}" +} + +################################################################ +# 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" "yellow1" "${humanReadableDuration}" 'EXECUTION_TIME_ICON' + fi +} + +################################################################ +# Dir: current working directory +# Parameters: +# * $1 Alignment: string - left|right +# * $2 Index: integer +set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/" +set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" +set_default POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD false +prompt_dir() { + # using $PWD instead of "$(print -P '%~')" to allow use of POWERLEVEL9K_DIR_PATH_ABSOLUTE + local current_path=$PWD # WAS: local current_path="$(print -P '%~')" + # check if the user wants to use absolute paths or "~" paths + [[ ${(L)POWERLEVEL9K_DIR_PATH_ABSOLUTE} != "true" ]] && current_path=${current_path//$HOME/"~"} + # declare all local variables + local paths directory test_dir test_dir_length trunc_path threshhold + # if we are not in "~" or "/", split the paths into an array and exclude "~" + (( ${#current_path} > 1 )) && paths=(${(s:/:)${current_path//"~\/"/}}) || paths=() + # only run the code if SHORTEN_DIR_LENGTH is set, or we are using the two strategies that don't rely on it. + if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_to_last" ]]; then + set_default POWERLEVEL9K_SHORTEN_DELIMITER "\u2026" + # convert delimiter from unicode to literal character, so that we can get the correct length later + local delim=$(echo -n $POWERLEVEL9K_SHORTEN_DELIMITER) + + case "$POWERLEVEL9K_SHORTEN_STRATEGY" in + truncate_absolute_chars) + if [ ${#current_path} -gt $(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#POWERLEVEL9K_SHORTEN_DELIMITER} )) ]; then + current_path=$POWERLEVEL9K_SHORTEN_DELIMITER${current_path:(-POWERLEVEL9K_SHORTEN_DIR_LENGTH)} + fi + ;; + truncate_middle) + # truncate characters from the middle of the path + current_path=$(truncatePath $current_path $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER "middle") + ;; + truncate_from_right) + # truncate characters from the right of the path + current_path=$(truncatePath "$current_path" $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER) + ;; + truncate_absolute) + # truncate all characters except the last POWERLEVEL9K_SHORTEN_DIR_LENGTH characters + if [ ${#current_path} -gt $(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#POWERLEVEL9K_SHORTEN_DELIMITER} )) ]; then + current_path=$POWERLEVEL9K_SHORTEN_DELIMITER${current_path:(-POWERLEVEL9K_SHORTEN_DIR_LENGTH)} + fi + ;; + truncate_to_last) + # truncate all characters before the current directory + current_path=${current_path##*/} + ;; + truncate_to_first_and_last) + if (( ${#current_path} > 1 )) && (( ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} > 0 )); then + threshhold=$(( ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} * 2)) + # if we are in "~", add it back into the paths array + [[ $current_path == '~'* ]] && paths=("~" "${paths[@]}") + if (( ${#paths} > $threshhold )); then + local num=$(( ${#paths} - ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} )) + # repace the middle elements + for (( i=$POWERLEVEL9K_SHORTEN_DIR_LENGTH; i<$num; i++ )); do + paths[$i+1]=$POWERLEVEL9K_SHORTEN_DELIMITER + done + [[ $current_path != '~'* ]] && current_path="/" || current_path="" + current_path+="${(j:/:)paths}" + fi + fi + ;; + truncate_to_unique) + # for each parent path component find the shortest unique beginning + # characters sequence. Source: https://stackoverflow.com/a/45336078 + if (( ${#current_path} > 1 )); then # root and home are exceptions and won't have paths + local matching + local cur_path='/' + [[ $current_path != "~"* ]] && trunc_path='/' || trunc_path='' + for directory in ${paths[@]}; do + test_dir='' + for (( i=0; i<${#directory}; i++ )); do + test_dir+="${directory:$i:1}" + matching=("$cur_path"/"$test_dir"*/) + if [[ ${#matching[@]} -eq 1 ]]; then + break + fi + done + trunc_path+="$test_dir/" + cur_path+="$directory/" + done + [[ $current_path == "~"* ]] && trunc_path="~/$trunc_path" + current_path="${trunc_path: : -1}" + fi + ;; + truncate_with_folder_marker) + if (( ${#paths} > 0 )); then # root and home are exceptions and won't have paths, so skip this + 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. + trunc_path="/" + elif [[ "$marked_folder" == "$HOME" ]]; then + # If we reached home folder, stop upsearch. + trunc_path="~" + elif [[ "${marked_folder%/*}" == $last_marked_folder ]]; then + trunc_path="${trunc_path%/}/${marked_folder##*/}" + else + trunc_path="${trunc_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=$trunc_path${current_path#${last_marked_folder}*} + fi + ;; + 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]|){*})' + trunc_path=$(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=$(truncatePath "${trunc_path:${#${(S%%)package_path//$~zero/}}}" $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER) + # 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" + fi + ;; + *) + if [[ $current_path != "~" ]]; then + current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" + fi + ;; + esac + fi + + # save state of path for highlighting and bold options + local path_opt=$current_path + + typeset -AH dir_states + dir_states=( + "DEFAULT" "FOLDER_ICON" + "HOME" "HOME_ICON" + "HOME_SUBFOLDER" "HOME_SUB_ICON" + "NOT_WRITABLE" "LOCK_ICON" + "ETC" "ETC_ICON" + ) + local state_path="$(print -P '%~')" + local current_state="DEFAULT" + if [[ $state_path == '/etc'* ]]; then + current_state='ETC' + elif [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then + current_state="NOT_WRITABLE" + elif [[ $state_path == '~' ]]; then + current_state="HOME" + elif [[ $state_path == '~'* ]]; then + current_state="HOME_SUBFOLDER" + fi + + # declare variables used for bold and state colors + local bld_on bld_off dir_state_foreground dir_state_user_foreground + # test if user wants the last directory printed in bold + if [[ "${(L)POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD}" == "true" ]]; then + bld_on="%B" + bld_off="%b" + else + bld_on="" + bld_off="" + fi + # determine is the user has set a last directory color + local dir_state_user_foreground=POWERLEVEL9K_DIR_${current_state}_FOREGROUND + local dir_state_foreground=${(P)dir_state_user_foreground} + [[ -z ${dir_state_foreground} ]] && dir_state_foreground="${DEFAULT_COLOR}" + + local dir_name base_name + # use ZSH substitution to get the dirname and basename instead of calling external functions + dir_name=${path_opt%/*} + base_name=${path_opt##*/} + + # if the user wants the last directory colored... + if [[ -n ${POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND} ]]; then + # it the path is "/" or "~" + if [[ $path_opt == "/" || $path_opt == "~" ]]; then + current_path="${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${current_path}${bld_off}" + else # has a subfolder + # test if dirname != basename - they are equal if we use truncate_to_last or truncate_absolute + if [[ $dir_name != $base_name ]]; then + current_path="${dir_name}/${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${base_name}${bld_off}" + else + current_path="${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${base_name}${bld_off}" + fi + fi + else # no coloring + # it the path is "/" or "~" + if [[ $path_opt == "/" || $path_opt == "~" ]]; then + current_path="${bld_on}${current_path}${bld_off}" + else # has a subfolder + # test if dirname != basename - they are equal if we use truncate_to_last or truncate_absolute + if [[ $dir_name != $base_name ]]; then + current_path="${dir_name}/${bld_on}${base_name}${bld_off}" + else + current_path="${bld_on}${base_name}${bld_off}" + fi + fi + fi + + # check if we need to omit the first character and only do it if we are not in "~" or "/" + if [[ "${POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER}" == "true" && $path_opt != "/" && $path_opt != "~" ]]; then + current_path="${current_path[2,-1]}" + fi + + # check if the user wants the separator colored. + if [[ -n ${POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND} && $path_opt != "/" ]]; then + # because this contains color changing codes, it is easier to set a variable for what should be replaced + local repl="%F{$POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND}/%F{$dir_state_foreground}" + # escape the / with a \ + current_path=${current_path//\//$repl} + fi + + if [[ "${POWERLEVEL9K_DIR_PATH_SEPARATOR}" != "/" && $path_opt != "/" ]]; then + current_path=${current_path//\//$POWERLEVEL9K_DIR_PATH_SEPARATOR} + fi + + if [[ "${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}" != "~" && ! "${(L)POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER}" == "true" ]]; then + # use :s to only replace the first occurance + current_path=${current_path:s/~/$POWERLEVEL9K_HOME_FOLDER_ABBREVIATION} + 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" "grey93" "$go_version" "GO_ICON" + fi +} + +################################################################ +# Command number (in local history) +prompt_history() { + "$1_prompt_segment" "$0" "$2" "grey50" "$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" "$DEFAULT_COLOR" "yellow" "$virt" + else + ; + fi + else + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "$virt" + fi +} + +################################################################ +# Test icons +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 +} + +################################################################ +# Segment to display the current IP address +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' +} + +################################################################ +# Segment to display if VPN is active +set_default POWERLEVEL9K_VPN_IP_INTERFACE "tun" +# prompt if vpn active +prompt_vpn_ip() { + for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_VPN_IP_INTERFACE" | cut -d":" -f1) + do + ip=$(/sbin/ifconfig "$vpn_iface" | grep -o "inet\s.*" | cut -d' ' -f2) + "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON' + done +} + +################################################################ +# Segment to display laravel version +prompt_laravel_version() { + local laravel_version="$(php artisan --version 2>/dev/null)" + if [[ -n "${laravel_version}" ]]; then + # Remove unrelevant infos + laravel_version="${laravel_version//Laravel Framework version /}" + + "$1_prompt_segment" "$0" "$2" "maroon" "white" "${laravel_version}" 'LARAVEL_ICON' + fi +} + +################################################################ +# Segment to display load +set_default POWERLEVEL9K_LOAD_WHICH 5 +prompt_load() { + # The load segment can have three different states + local current_state="unknown" + local load_select=2 + local load_avg + local cores + + typeset -AH load_states + load_states=( + 'critical' 'red' + 'warning' 'yellow' + 'normal' 'green' + ) + + case "$POWERLEVEL9K_LOAD_WHICH" in + 1) + load_select=1 + ;; + 5) + load_select=2 + ;; + 15) + load_select=3 + ;; + esac + + case "$OS" in + OSX|BSD) + load_avg=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | sed -n ${load_select}p) + if [[ "$OS" == "OSX" ]]; then + cores=$(sysctl -n hw.logicalcpu) + else + cores=$(sysctl -n hw.ncpu) + fi + ;; + *) + load_avg=$(cut -d" " -f${load_select} /proc/loadavg) + cores=$(nproc) + esac + + # Replace comma + load_avg=${load_avg//,/.} + + if [[ "$load_avg" -gt $((${cores} * 0.7)) ]]; then + current_state="critical" + elif [[ "$load_avg" -gt $((${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" 'LOAD_ICON' +} + +################################################################ +# Segment to diplay 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' +} + +################################################################ +# Segment to display Node version from NVM +# Only prints the segment if different than the default value +prompt_nvm() { + local node_version nvm_default + (( $+functions[nvm_version] )) || return + + node_version=$(nvm_version current) + [[ -z "${node_version}" || ${node_version} == "none" ]] && return + + nvm_default=$(nvm_version default) + [[ "$node_version" =~ "$nvm_default" ]] && return + + $1_prompt_segment "$0" "$2" "magenta" "black" "${node_version:1}" 'NODE_ICON' +} + +################################################################ +# Segment to display NodeEnv +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 +} + +################################################################ +# Segment to print a little OS icon +prompt_os_icon() { + "$1_prompt_segment" "$0" "$2" "black" "white" "$OS_ICON" +} + +################################################################ +# Segment to display 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" "fuchsia" "grey93" "$php_version" + fi +} + +################################################################ +# Segment to display 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' +} + + +set_default POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW false +# rbenv information +prompt_rbenv() { + if command 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 + # unless `POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW` is set. + if [[ $rbenv_version_name == $rbenv_global && "$POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW" = false ]]; then + return + fi + + "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' + fi +} + +################################################################ +# Segment to display chruby information +# see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH +prompt_chruby() { + # Uses $RUBY_VERSION and $RUBY_ENGINE set by chruby + set_default POWERLEVEL9K_CHRUBY_SHOW_VERSION true + set_default POWERLEVEL9K_CHRUBY_SHOW_ENGINE true + local chruby_label="" + + if [[ "$POWERLEVEL9K_CHRUBY_SHOW_ENGINE" == true ]]; then + chruby_label+="$RUBY_ENGINE " + fi + if [[ "$POWERLEVEL9K_CHRUBY_SHOW_VERSION" == true ]]; then + chruby_label+="$RUBY_VERSION" + fi + + # Truncate trailing spaces + chruby_label="${chruby_label%"${chruby_label##*[![:space:]]}"}" + + # Don't show anything if the chruby did not change the default ruby + if [[ "$RUBY_ENGINE" != "" ]]; then + "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "${chruby_label}" 'RUBY_ICON' + fi +} + +################################################################ +# Segment to 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 +} + +################################################################ +# Segment to display Rust version number +prompt_rust_version() { + local rust_version + rust_version=$(command rustc --version 2>/dev/null) + # Remove "rustc " (including the whitespace) from the beginning + # of the version string and remove everything after the next + # whitespace. This way we'll end up with only the version. + rust_version=${${rust_version/rustc /}%% *} + + if [[ -n "$rust_version" ]]; then + "$1_prompt_segment" "$0" "$2" "darkorange" "$DEFAULT_COLOR" "$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 +} + +################################################################ +# Segment to display Ruby Version Manager information +prompt_rvm() { + local version_and_gemset=${rvm_env_string/ruby-} + + if [[ -n "$version_and_gemset" ]]; then + "$1_prompt_segment" "$0" "$2" "grey35" "$DEFAULT_COLOR" "$version_and_gemset" 'RUBY_ICON' + fi +} + +################################################################ +# Segment to display SSH icon when connected +prompt_ssh() { + if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "" 'SSH_ICON' + fi +} + +################################################################ +# Status: When an error occur, return the error code, or a cross icon if option is set +# Display an ok icon when no error occur, or hide the segment if option is set to false +# +set_default POWERLEVEL9K_STATUS_CROSS false +set_default POWERLEVEL9K_STATUS_OK true +set_default POWERLEVEL9K_STATUS_SHOW_PIPESTATUS true +set_default POWERLEVEL9K_STATUS_HIDE_SIGNAME false +# old options, retro compatibility +set_default POWERLEVEL9K_STATUS_VERBOSE true +set_default POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE false + +exit_code_or_status() { + local ec=$1 + if [[ "$POWERLEVEL9K_STATUS_HIDE_SIGNAME" = true ]]; then + echo "$ec" + elif (( ec <= 128 )); then + echo "$ec" + else + local sig=$(( ec - 128 )) + local idx=$(( sig + 1 )) + echo "SIG${signals[$idx]}(${sig})" + fi +} + +prompt_status() { + local ec_text + local ec_sum + local ec + + if [[ $POWERLEVEL9K_STATUS_SHOW_PIPESTATUS == true ]]; then + if (( $#RETVALS > 1 )); then + ec_text=$(exit_code_or_status "${RETVALS[1]}") + ec_sum=${RETVALS[1]} + else + ec_text=$(exit_code_or_status "${RETVAL}") + ec_sum=${RETVAL} + fi + + for ec in "${(@)RETVALS[2,-1]}"; do + ec_text="${ec_text}|$(exit_code_or_status "$ec")" + ec_sum=$(( $ec_sum + $ec )) + done + else + # We use RETVAL instead of the right-most RETVALS item because + # PIPE_FAIL may be set. + ec_text=$(exit_code_or_status "${RETVAL}") + ec_sum=${RETVAL} + fi + + if (( ec_sum > 0 )); then + if [[ "$POWERLEVEL9K_STATUS_CROSS" == false && "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then + "$1_prompt_segment" "$0_ERROR" "$2" "red" "yellow1" "$ec_text" 'CARRIAGE_RETURN_ICON' + else + "$1_prompt_segment" "$0_ERROR" "$2" "$DEFAULT_COLOR" "red" "" 'FAIL_ICON' + fi + elif [[ "$POWERLEVEL9K_STATUS_OK" == true ]] && [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true || "$POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE" == true ]]; then + "$1_prompt_segment" "$0_OK" "$2" "$DEFAULT_COLOR" "green" "" 'OK_ICON' + fi +} + +################################################################ +# Segment to display Swap information +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 +} + +################################################################ +# Segment to display 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" "grey35" "$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() { + set_default POWERLEVEL9K_TIME_FORMAT "%D{%H:%M:%S}" + + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$POWERLEVEL9K_TIME_FORMAT" "TIME_ICON" +} + +################################################################ +# System date +prompt_date() { + set_default POWERLEVEL9K_DATE_FORMAT "%D{%d.%m.%y}" + + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$POWERLEVEL9K_DATE_FORMAT" "DATE_ICON" +} + +################################################################ +# 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" "grey50" "$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 +} + +################################################################ +# Segment to show VCS information +prompt_vcs() { + VCS_WORKDIR_DIRTY=false + VCS_WORKDIR_HALF_DIRTY=false + local 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 + vicmd) + "$1_prompt_segment" "$0_NORMAL" "$2" "$DEFAULT_COLOR" "default" "$POWERLEVEL9K_VI_COMMAND_MODE_STRING" + ;; + main|viins|*) + if [[ -z $POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then return; fi + "$1_prompt_segment" "$0_INSERT" "$2" "$DEFAULT_COLOR" "blue" "$POWERLEVEL9K_VI_INSERT_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) +# https://github.com/pyenv/pyenv#choosing-the-python-version +prompt_pyenv() { + if [[ -n "$PYENV_VERSION" ]]; then + "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON' + fi +} + +################################################################ +# Display openfoam information +prompt_openfoam() { + local wm_project_version="$WM_PROJECT_VERSION" + local wm_fork="$WM_FORK" + if [[ -n "$wm_project_version" ]] && [[ -z "$wm_fork" ]] ; then + "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "OF: $(basename "$wm_project_version")" + elif [[ -n "$wm_project_version" ]] && [[ -n "$wm_fork" ]] ; then + "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "F-X: $(basename "$wm_project_version")" + fi +} + +################################################################ +# Segment to display 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" "yellow1" "" 'LOCK_ICON' + fi +} + +################################################################ +# Kubernetes Current Context/Namespace +prompt_kubecontext() { + local kubectl_version="$(kubectl version --client 2>/dev/null)" + + if [[ -n "$kubectl_version" ]]; then + # Get the current Kuberenetes context + local cur_ctx=$(kubectl config view -o=jsonpath='{.current-context}') + cur_namespace="$(kubectl config view -o=jsonpath="{.contexts[?(@.name==\"${cur_ctx}\")].context.namespace}")" + # If the namespace comes back empty set it default. + if [[ -z "${cur_namespace}" ]]; then + cur_namespace="default" + fi + + local k8s_final_text="" + + if [[ "$cur_ctx" == "$cur_namespace" ]]; then + # No reason to print out the same identificator twice + k8s_final_text="$cur_ctx" + else + k8s_final_text="$cur_ctx/$cur_namespace" + fi + + "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_final_text" "KUBERNETES_ICON" + fi +} + +################################################################ +# Dropbox status +prompt_dropbox() { + # The first column is just the directory, so cut it + local dropbox_status="$(dropbox-cli filestatus . | cut -d\ -f2-)" + + # Only show if the folder is tracked and dropbox is running + if [[ "$dropbox_status" != 'unwatched' && "$dropbox_status" != "isn't running!" ]]; then + # If "up to date", only show the icon + if [[ "$dropbox_status" =~ 'up to date' ]]; then + dropbox_status="" + fi + + "$1_prompt_segment" "$0" "$2" "white" "blue" "$dropbox_status" "DROPBOX_ICON" + fi +} + +# print Java version number +prompt_java_version() { + local java_version + # Stupid: Java prints its version on STDERR. + # The first version ouput will print nothing, we just + # use it to transport whether the command was successful. + # If yes, we parse the version string (and need to + # redirect the stderr to stdout to make the pipe work). + java_version=$(java -version 2>/dev/null && java -fullversion 2>&1 | cut -d '"' -f 2) + + if [[ -n "$java_version" ]]; then + "$1_prompt_segment" "$0" "$2" "red" "white" "$java_version" "JAVA_ICON" + fi +} + +################################################################ +# Prompt processing and drawing +################################################################ +# Main prompt +build_left_prompt() { + local index=1 + local element + 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 + local element + 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 + + # Clear to the end of the line + echo -n "%E" +} + +powerlevel9k_preexec() { + _P9K_TIMER_START=$EPOCHREALTIME +} + +set_default POWERLEVEL9K_PROMPT_ADD_NEWLINE false +powerlevel9k_prepare_prompts() { + local RETVAL RPROMPT_PREFIX RPROMPT_SUFFIX + RETVAL=$? + RETVALS=( "$pipestatus[@]" ) + + _P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START)) + + # Reset start time + _P9K_TIMER_START=0x7FFFFFFF + + if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then + PROMPT='$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt) +$(print_icon 'MULTILINE_LAST_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 + +local NEWLINE=' +' + + if [[ $POWERLEVEL9K_PROMPT_ADD_NEWLINE == true ]]; then + NEWLINES="" + repeat ${POWERLEVEL9K_PROMPT_ADD_NEWLINE_COUNT:-1} { NEWLINES+=$NEWLINE } + PROMPT="$NEWLINES$PROMPT" + fi + + # Allow iTerm integration to work + [[ $ITERM_SHELL_INTEGRATION_INSTALLED == "Yes" ]] && PROMPT="%{$(iterm2_prompt_mark)%}$PROMPT" +} + +zle-keymap-select () { + zle reset-prompt + zle -R +} + +set_default POWERLEVEL9K_IGNORE_TERM_COLORS false +set_default POWERLEVEL9K_IGNORE_TERM_LANG false + +prompt_powerlevel9k_setup() { + # The value below was set to better support 32-bit CPUs. + # It's the maximum _signed_ integer value on 32-bit CPUs. + # Please don't change it until 19 January of 2038. ;) + + # Disable false display of command execution time + _P9K_TIMER_START=0x7FFFFFFF + + # 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=(cr percent sp subst) + + # Borrowed from promptinit, sets the prompt options in case the theme was + # not initialized via promptinit. + setopt noprompt{bang,cr,percent,sp,subst} "prompt${^prompt_opts[@]}" + + # Display a warning if the terminal does not support 256 colors + termColors + + # If the terminal `LANG` is set to `C`, this theme will not work at all. + if [[ $POWERLEVEL9K_IGNORE_TERM_LANG == false ]]; then + 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 + 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 + + zle -N zle-keymap-select +} + +prompt_powerlevel9k_teardown() { + add-zsh-hook -D precmd powerlevel9k_\* + add-zsh-hook -D preexec powerlevel9k_\* + PROMPT='%m%# ' + RPROMPT= +} + +prompt_powerlevel9k_setup "$@" diff --git a/.zprezto/modules/prompt/external/powerlevel9k/prompt_powerlevel9k_setup b/.zprezto/modules/prompt/external/powerlevel9k/prompt_powerlevel9k_setup new file mode 100755 index 0000000..c1ea754 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/prompt_powerlevel9k_setup @@ -0,0 +1,1912 @@ +# 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 +#PS4='%s%f%b%k%F{blue}%{λ%}%L %F{240}%N:%i%(?.. %F{red}%?) %1(_.%F{yellow}%-1_ .)%s%f%b%k ' +#zstyle ':vcs_info:*+*:*' debug true +#set -o xtrace + +# Try to set the installation path +if [[ -n "$POWERLEVEL9K_INSTALLATION_DIR" ]]; then + p9k_directory=${POWERLEVEL9K_INSTALLATION_DIR:A} +else + if [[ "${(%):-%N}" == '(eval)' ]]; then + if [[ "$0" == '-antigen-load' ]] && [[ -r "${PWD}/powerlevel9k.zsh-theme" ]]; then + # Antigen uses eval to load things so it can change the plugin (!!) + # https://github.com/zsh-users/antigen/issues/581 + p9k_directory=$PWD + else + print -P "%F{red}You must set POWERLEVEL9K_INSTALLATION_DIR work from within an (eval).%f" + return 1 + fi + else + # Get the path to file this code is executing in; then + # get the absolute path and strip the filename. + # See https://stackoverflow.com/a/28336473/108857 + p9k_directory=${${(%):-%x}:A:h} + fi +fi + +################################################################ +# Source icon functions +################################################################ + +source "${p9k_directory}/functions/icons.zsh" + +################################################################ +# Source utility functions +################################################################ + +source "${p9k_directory}/functions/utilities.zsh" + +################################################################ +# Source color functions +################################################################ + +source "${p9k_directory}/functions/colors.zsh" + +################################################################ +# Source VCS_INFO hooks / helper functions +################################################################ + +source "${p9k_directory}/functions/vcs.zsh" + +# cleanup temporary variables. +unset p9k_directory + +################################################################ +# 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="$(backgroundColor $3)" || bg="$(backgroundColor)" + [[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="$(foregroundColor)" + + 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="$fg" || complement="$(foregroundColor $DEFAULT_COLOR)" + echo -n "${bg}${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 + # Add an whitespace if we print more than just the visual identifier. + # To avoid cutting off the visual identifier in some terminal emulators (e.g., Konsole, st), + # we need to color both the visual identifier and the whitespace. + [[ -n "$5" ]] && visual_identifier="$visual_identifier " + # 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" + 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="$(backgroundColor $3)" || bg="$(backgroundColor)" + [[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="$(foregroundColor)" + + # If CURRENT_RIGHT_BG is "NONE", we are the first right segment. + + if [[ "$CURRENT_RIGHT_BG" != "NONE" ]]; then + # This is the closing whitespace for the previous segment + echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f" + fi + + 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="$fg" || complement="$(foregroundColor $DEFAULT_COLOR)" + echo -n "$complement$(print_icon 'RIGHT_SUBSEGMENT_SEPARATOR')%f" + else + # Use the new BG color for the foreground with separator + echo -n "$(foregroundColor $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 + # Add an whitespace if we print more than just the visual identifier. + # To avoid cutting off the visual identifier in some terminal emulators (e.g., Konsole, st), + # we need to color both the visual identifier and the whitespace. + [[ -n "$5" ]] && visual_identifier=" $visual_identifier" + # 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" + 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}" + + 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. + local _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_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 +set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS false +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 ]] || [[ "$POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS" == "true" ]]); 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 +} + +################################################################ +# A newline in your prompt, so you can segments on multiple lines. +prompt_newline() { + local lws newline + [[ "$1" == "right" ]] && return + newline=$'\n' + lws=$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS + if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then + newline="${newline}$(print_icon 'MULTILINE_NEWLINE_PROMPT_PREFIX')" + fi + POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS= + "$1_prompt_segment" \ + "$0" \ + "$2" \ + "NONE" "NONE" "${newline}" + POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws +} + +################################################################ +# 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 +} + +################################################################ +# Segment that displays the battery status in levels and colors +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 + + # override default icon if we are using battery stages + if [[ -n "$POWERLEVEL9K_BATTERY_STAGES" ]]; then + local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_STAGES} - 1 ) )) + if [[ $segment > 1 ]]; then + local offset=$(( ($bat_percent / $segment) + 1 )) + # check if the stages are in an array or a string + [[ "${(t)POWERLEVEL9K_BATTERY_STAGES}" =~ "array" ]] && POWERLEVEL9K_BATTERY_ICON="$POWERLEVEL9K_BATTERY_STAGES[$offset]" || POWERLEVEL9K_BATTERY_ICON=${POWERLEVEL9K_BATTERY_STAGES:$offset:1} + fi + fi + # return if POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD is set and the battery percentage is greater or equal + if [[ -v "POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD" && "${bat_percent}" -ge $POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD ]]; then + return + fi + + # override the default color if we are using a color level array + if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then + local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) )) + local offset=$(( ($bat_percent / $segment) + 1 )) + "$1_prompt_segment" "$0_${current_state}" "$2" "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" + else + # Draw the prompt_segment + "$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 + if [[ "$OS" == "OSX" ]]; then + timediff=$(($(date +%s) - $(stat -f "%m" $POWERLEVEL9K_PUBLIC_IP_FILE))) + else + timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) + fi + [[ $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 + icon='PUBLIC_IP_ICON' + # Check VPN is on if VPN interface is set + if [[ -n $POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]]; then + for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE" | cut -d":" -f1) + do + icon='VPN_ICON' + break + done + fi + $1_prompt_segment "$0" "$2" "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${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" + "SUDO" "yellow" + "DEFAULT" "yellow" + "REMOTE" "yellow" + "REMOTE_SUDO" "yellow" + ) + + local content="" + + if [[ "$POWERLEVEL9K_ALWAYS_SHOW_CONTEXT" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + content="${POWERLEVEL9K_CONTEXT_TEMPLATE}" + elif [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]]; then + content="$(whoami)" + else + return + fi + + if [[ $(print -P "%#") == '#' ]]; then + current_state="ROOT" + elif [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + if sudo -n true 2>/dev/null; then + current_state="REMOTE_SUDO" + else + current_state="REMOTE" + fi + elif sudo -n true 2>/dev/null; then + current_state="SUDO" + fi + + "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" +} + +################################################################ +# User: user (who am I) +# Note that if $DEFAULT_USER is not set, this prompt segment will always print +set_default POWERLEVEL9K_USER_TEMPLATE "%n" +prompt_user() { + local current_state="DEFAULT" + typeset -AH user_state + if [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]]; then + if [[ $(print -P "%#") == '#' ]]; then + user_state=( + "STATE" "ROOT" + "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "ROOT_ICON" + ) + elif sudo -n true 2>/dev/null; then + user_state=( + "STATE" "SUDO" + "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "SUDO_ICON" + ) + else + user_state=( + "STATE" "DEFAULT" + "CONTENT" "$(whoami)" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "USER_ICON" + ) + fi + "$1_prompt_segment" "${0}_${user_state[STATE]}" "$2" "${user_state[BACKGROUND_COLOR]}" "${user_state[FOREGROUND_COLOR]}" "${user_state[CONTENT]}" "${user_state[VISUAL_IDENTIFIER]}" + fi +} + +################################################################ +# Host: machine (where am I) +set_default POWERLEVEL9K_HOST_TEMPLATE "%m" +prompt_host() { + local current_state="LOCAL" + typeset -AH host_state + if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then + host_state=( + "STATE" "REMOTE" + "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "SSH_ICON" + ) + else + host_state=( + "STATE" "LOCAL" + "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "HOST_ICON" + ) + fi + "$1_prompt_segment" "$0_${host_state[STATE]}" "$2" "${host_state[BACKGROUND_COLOR]}" "${host_state[FOREGROUND_COLOR]}" "${host_state[CONTENT]}" "${host_state[VISUAL_IDENTIFIER]}" +} + +################################################################ +# 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" "yellow1" "${humanReadableDuration}" 'EXECUTION_TIME_ICON' + fi +} + +################################################################ +# Dir: current working directory +# Parameters: +# * $1 Alignment: string - left|right +# * $2 Index: integer +set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/" +set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" +set_default POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD false +prompt_dir() { + # using $PWD instead of "$(print -P '%~')" to allow use of POWERLEVEL9K_DIR_PATH_ABSOLUTE + local current_path=$PWD # WAS: local current_path="$(print -P '%~')" + # check if the user wants to use absolute paths or "~" paths + [[ ${(L)POWERLEVEL9K_DIR_PATH_ABSOLUTE} != "true" ]] && current_path=${current_path//$HOME/"~"} + # declare all local variables + local paths directory test_dir test_dir_length trunc_path threshhold + # if we are not in "~" or "/", split the paths into an array and exclude "~" + (( ${#current_path} > 1 )) && paths=(${(s:/:)${current_path//"~\/"/}}) || paths=() + # only run the code if SHORTEN_DIR_LENGTH is set, or we are using the two strategies that don't rely on it. + if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_to_last" ]]; then + set_default POWERLEVEL9K_SHORTEN_DELIMITER "\u2026" + # convert delimiter from unicode to literal character, so that we can get the correct length later + local delim=$(echo -n $POWERLEVEL9K_SHORTEN_DELIMITER) + + case "$POWERLEVEL9K_SHORTEN_STRATEGY" in + truncate_absolute_chars) + if [ ${#current_path} -gt $(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#POWERLEVEL9K_SHORTEN_DELIMITER} )) ]; then + current_path=$POWERLEVEL9K_SHORTEN_DELIMITER${current_path:(-POWERLEVEL9K_SHORTEN_DIR_LENGTH)} + fi + ;; + truncate_middle) + # truncate characters from the middle of the path + current_path=$(truncatePath $current_path $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER "middle") + ;; + truncate_from_right) + # truncate characters from the right of the path + current_path=$(truncatePath "$current_path" $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER) + ;; + truncate_absolute) + # truncate all characters except the last POWERLEVEL9K_SHORTEN_DIR_LENGTH characters + if [ ${#current_path} -gt $(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#POWERLEVEL9K_SHORTEN_DELIMITER} )) ]; then + current_path=$POWERLEVEL9K_SHORTEN_DELIMITER${current_path:(-POWERLEVEL9K_SHORTEN_DIR_LENGTH)} + fi + ;; + truncate_to_last) + # truncate all characters before the current directory + current_path=${current_path##*/} + ;; + truncate_to_first_and_last) + if (( ${#current_path} > 1 )) && (( ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} > 0 )); then + threshhold=$(( ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} * 2)) + # if we are in "~", add it back into the paths array + [[ $current_path == '~'* ]] && paths=("~" "${paths[@]}") + if (( ${#paths} > $threshhold )); then + local num=$(( ${#paths} - ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} )) + # repace the middle elements + for (( i=$POWERLEVEL9K_SHORTEN_DIR_LENGTH; i<$num; i++ )); do + paths[$i+1]=$POWERLEVEL9K_SHORTEN_DELIMITER + done + [[ $current_path != '~'* ]] && current_path="/" || current_path="" + current_path+="${(j:/:)paths}" + fi + fi + ;; + truncate_to_unique) + # for each parent path component find the shortest unique beginning + # characters sequence. Source: https://stackoverflow.com/a/45336078 + if (( ${#current_path} > 1 )); then # root and home are exceptions and won't have paths + local matching + local cur_path='/' + [[ $current_path != "~"* ]] && trunc_path='/' || trunc_path='' + for directory in ${paths[@]}; do + test_dir='' + for (( i=0; i<${#directory}; i++ )); do + test_dir+="${directory:$i:1}" + matching=("$cur_path"/"$test_dir"*/) + if [[ ${#matching[@]} -eq 1 ]]; then + break + fi + done + trunc_path+="$test_dir/" + cur_path+="$directory/" + done + [[ $current_path == "~"* ]] && trunc_path="~/$trunc_path" + current_path="${trunc_path: : -1}" + fi + ;; + truncate_with_folder_marker) + if (( ${#paths} > 0 )); then # root and home are exceptions and won't have paths, so skip this + 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. + trunc_path="/" + elif [[ "$marked_folder" == "$HOME" ]]; then + # If we reached home folder, stop upsearch. + trunc_path="~" + elif [[ "${marked_folder%/*}" == $last_marked_folder ]]; then + trunc_path="${trunc_path%/}/${marked_folder##*/}" + else + trunc_path="${trunc_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=$trunc_path${current_path#${last_marked_folder}*} + fi + ;; + 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]|){*})' + trunc_path=$(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=$(truncatePath "${trunc_path:${#${(S%%)package_path//$~zero/}}}" $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER) + # 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" + fi + ;; + *) + if [[ $current_path != "~" ]]; then + current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" + fi + ;; + esac + fi + + # save state of path for highlighting and bold options + local path_opt=$current_path + + typeset -AH dir_states + dir_states=( + "DEFAULT" "FOLDER_ICON" + "HOME" "HOME_ICON" + "HOME_SUBFOLDER" "HOME_SUB_ICON" + "NOT_WRITABLE" "LOCK_ICON" + "ETC" "ETC_ICON" + ) + local state_path="$(print -P '%~')" + local current_state="DEFAULT" + if [[ $state_path == '/etc'* ]]; then + current_state='ETC' + elif [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then + current_state="NOT_WRITABLE" + elif [[ $state_path == '~' ]]; then + current_state="HOME" + elif [[ $state_path == '~'* ]]; then + current_state="HOME_SUBFOLDER" + fi + + # declare variables used for bold and state colors + local bld_on bld_off dir_state_foreground dir_state_user_foreground + # test if user wants the last directory printed in bold + if [[ "${(L)POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD}" == "true" ]]; then + bld_on="%B" + bld_off="%b" + else + bld_on="" + bld_off="" + fi + # determine is the user has set a last directory color + local dir_state_user_foreground=POWERLEVEL9K_DIR_${current_state}_FOREGROUND + local dir_state_foreground=${(P)dir_state_user_foreground} + [[ -z ${dir_state_foreground} ]] && dir_state_foreground="${DEFAULT_COLOR}" + + local dir_name base_name + # use ZSH substitution to get the dirname and basename instead of calling external functions + dir_name=${path_opt%/*} + base_name=${path_opt##*/} + + # if the user wants the last directory colored... + if [[ -n ${POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND} ]]; then + # it the path is "/" or "~" + if [[ $path_opt == "/" || $path_opt == "~" ]]; then + current_path="${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${current_path}${bld_off}" + else # has a subfolder + # test if dirname != basename - they are equal if we use truncate_to_last or truncate_absolute + if [[ $dir_name != $base_name ]]; then + current_path="${dir_name}/${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${base_name}${bld_off}" + else + current_path="${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${base_name}${bld_off}" + fi + fi + else # no coloring + # it the path is "/" or "~" + if [[ $path_opt == "/" || $path_opt == "~" ]]; then + current_path="${bld_on}${current_path}${bld_off}" + else # has a subfolder + # test if dirname != basename - they are equal if we use truncate_to_last or truncate_absolute + if [[ $dir_name != $base_name ]]; then + current_path="${dir_name}/${bld_on}${base_name}${bld_off}" + else + current_path="${bld_on}${base_name}${bld_off}" + fi + fi + fi + + # check if we need to omit the first character and only do it if we are not in "~" or "/" + if [[ "${POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER}" == "true" && $path_opt != "/" && $path_opt != "~" ]]; then + current_path="${current_path[2,-1]}" + fi + + # check if the user wants the separator colored. + if [[ -n ${POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND} && $path_opt != "/" ]]; then + # because this contains color changing codes, it is easier to set a variable for what should be replaced + local repl="%F{$POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND}/%F{$dir_state_foreground}" + # escape the / with a \ + current_path=${current_path//\//$repl} + fi + + if [[ "${POWERLEVEL9K_DIR_PATH_SEPARATOR}" != "/" && $path_opt != "/" ]]; then + current_path=${current_path//\//$POWERLEVEL9K_DIR_PATH_SEPARATOR} + fi + + if [[ "${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}" != "~" && ! "${(L)POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER}" == "true" ]]; then + # use :s to only replace the first occurance + current_path=${current_path:s/~/$POWERLEVEL9K_HOME_FOLDER_ABBREVIATION} + 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" "grey93" "$go_version" "GO_ICON" + fi +} + +################################################################ +# Command number (in local history) +prompt_history() { + "$1_prompt_segment" "$0" "$2" "grey50" "$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" "$DEFAULT_COLOR" "yellow" "$virt" + else + ; + fi + else + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "$virt" + fi +} + +################################################################ +# Test icons +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 +} + +################################################################ +# Segment to display the current IP address +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' +} + +################################################################ +# Segment to display if VPN is active +set_default POWERLEVEL9K_VPN_IP_INTERFACE "tun" +# prompt if vpn active +prompt_vpn_ip() { + for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_VPN_IP_INTERFACE" | cut -d":" -f1) + do + ip=$(/sbin/ifconfig "$vpn_iface" | grep -o "inet\s.*" | cut -d' ' -f2) + "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON' + done +} + +################################################################ +# Segment to display laravel version +prompt_laravel_version() { + local laravel_version="$(php artisan --version 2>/dev/null)" + if [[ -n "${laravel_version}" ]]; then + # Remove unrelevant infos + laravel_version="${laravel_version//Laravel Framework version /}" + + "$1_prompt_segment" "$0" "$2" "maroon" "white" "${laravel_version}" 'LARAVEL_ICON' + fi +} + +################################################################ +# Segment to display load +set_default POWERLEVEL9K_LOAD_WHICH 5 +prompt_load() { + # The load segment can have three different states + local current_state="unknown" + local load_select=2 + local load_avg + local cores + + typeset -AH load_states + load_states=( + 'critical' 'red' + 'warning' 'yellow' + 'normal' 'green' + ) + + case "$POWERLEVEL9K_LOAD_WHICH" in + 1) + load_select=1 + ;; + 5) + load_select=2 + ;; + 15) + load_select=3 + ;; + esac + + case "$OS" in + OSX|BSD) + load_avg=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | sed -n ${load_select}p) + if [[ "$OS" == "OSX" ]]; then + cores=$(sysctl -n hw.logicalcpu) + else + cores=$(sysctl -n hw.ncpu) + fi + ;; + *) + load_avg=$(cut -d" " -f${load_select} /proc/loadavg) + cores=$(nproc) + esac + + # Replace comma + load_avg=${load_avg//,/.} + + if [[ "$load_avg" -gt $((${cores} * 0.7)) ]]; then + current_state="critical" + elif [[ "$load_avg" -gt $((${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" 'LOAD_ICON' +} + +################################################################ +# Segment to diplay 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' +} + +################################################################ +# Segment to display Node version from NVM +# Only prints the segment if different than the default value +prompt_nvm() { + local node_version nvm_default + (( $+functions[nvm_version] )) || return + + node_version=$(nvm_version current) + [[ -z "${node_version}" || ${node_version} == "none" ]] && return + + nvm_default=$(nvm_version default) + [[ "$node_version" =~ "$nvm_default" ]] && return + + $1_prompt_segment "$0" "$2" "magenta" "black" "${node_version:1}" 'NODE_ICON' +} + +################################################################ +# Segment to display NodeEnv +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 +} + +################################################################ +# Segment to print a little OS icon +prompt_os_icon() { + "$1_prompt_segment" "$0" "$2" "black" "white" "$OS_ICON" +} + +################################################################ +# Segment to display 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" "fuchsia" "grey93" "$php_version" + fi +} + +################################################################ +# Segment to display 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' +} + + +set_default POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW false +# rbenv information +prompt_rbenv() { + if command 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 + # unless `POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW` is set. + if [[ $rbenv_version_name == $rbenv_global && "$POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW" = false ]]; then + return + fi + + "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' + fi +} + +################################################################ +# Segment to display chruby information +# see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH +prompt_chruby() { + # Uses $RUBY_VERSION and $RUBY_ENGINE set by chruby + set_default POWERLEVEL9K_CHRUBY_SHOW_VERSION true + set_default POWERLEVEL9K_CHRUBY_SHOW_ENGINE true + local chruby_label="" + + if [[ "$POWERLEVEL9K_CHRUBY_SHOW_ENGINE" == true ]]; then + chruby_label+="$RUBY_ENGINE " + fi + if [[ "$POWERLEVEL9K_CHRUBY_SHOW_VERSION" == true ]]; then + chruby_label+="$RUBY_VERSION" + fi + + # Truncate trailing spaces + chruby_label="${chruby_label%"${chruby_label##*[![:space:]]}"}" + + # Don't show anything if the chruby did not change the default ruby + if [[ "$RUBY_ENGINE" != "" ]]; then + "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "${chruby_label}" 'RUBY_ICON' + fi +} + +################################################################ +# Segment to 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 +} + +################################################################ +# Segment to display Rust version number +prompt_rust_version() { + local rust_version + rust_version=$(command rustc --version 2>/dev/null) + # Remove "rustc " (including the whitespace) from the beginning + # of the version string and remove everything after the next + # whitespace. This way we'll end up with only the version. + rust_version=${${rust_version/rustc /}%% *} + + if [[ -n "$rust_version" ]]; then + "$1_prompt_segment" "$0" "$2" "darkorange" "$DEFAULT_COLOR" "$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 +} + +################################################################ +# Segment to display Ruby Version Manager information +prompt_rvm() { + local version_and_gemset=${rvm_env_string/ruby-} + + if [[ -n "$version_and_gemset" ]]; then + "$1_prompt_segment" "$0" "$2" "grey35" "$DEFAULT_COLOR" "$version_and_gemset" 'RUBY_ICON' + fi +} + +################################################################ +# Segment to display SSH icon when connected +prompt_ssh() { + if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "" 'SSH_ICON' + fi +} + +################################################################ +# Status: When an error occur, return the error code, or a cross icon if option is set +# Display an ok icon when no error occur, or hide the segment if option is set to false +# +set_default POWERLEVEL9K_STATUS_CROSS false +set_default POWERLEVEL9K_STATUS_OK true +set_default POWERLEVEL9K_STATUS_SHOW_PIPESTATUS true +set_default POWERLEVEL9K_STATUS_HIDE_SIGNAME false +# old options, retro compatibility +set_default POWERLEVEL9K_STATUS_VERBOSE true +set_default POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE false + +exit_code_or_status() { + local ec=$1 + if [[ "$POWERLEVEL9K_STATUS_HIDE_SIGNAME" = true ]]; then + echo "$ec" + elif (( ec <= 128 )); then + echo "$ec" + else + local sig=$(( ec - 128 )) + local idx=$(( sig + 1 )) + echo "SIG${signals[$idx]}(${sig})" + fi +} + +prompt_status() { + local ec_text + local ec_sum + local ec + + if [[ $POWERLEVEL9K_STATUS_SHOW_PIPESTATUS == true ]]; then + if (( $#RETVALS > 1 )); then + ec_text=$(exit_code_or_status "${RETVALS[1]}") + ec_sum=${RETVALS[1]} + else + ec_text=$(exit_code_or_status "${RETVAL}") + ec_sum=${RETVAL} + fi + + for ec in "${(@)RETVALS[2,-1]}"; do + ec_text="${ec_text}|$(exit_code_or_status "$ec")" + ec_sum=$(( $ec_sum + $ec )) + done + else + # We use RETVAL instead of the right-most RETVALS item because + # PIPE_FAIL may be set. + ec_text=$(exit_code_or_status "${RETVAL}") + ec_sum=${RETVAL} + fi + + if (( ec_sum > 0 )); then + if [[ "$POWERLEVEL9K_STATUS_CROSS" == false && "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then + "$1_prompt_segment" "$0_ERROR" "$2" "red" "yellow1" "$ec_text" 'CARRIAGE_RETURN_ICON' + else + "$1_prompt_segment" "$0_ERROR" "$2" "$DEFAULT_COLOR" "red" "" 'FAIL_ICON' + fi + elif [[ "$POWERLEVEL9K_STATUS_OK" == true ]] && [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true || "$POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE" == true ]]; then + "$1_prompt_segment" "$0_OK" "$2" "$DEFAULT_COLOR" "green" "" 'OK_ICON' + fi +} + +################################################################ +# Segment to display Swap information +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 +} + +################################################################ +# Segment to display 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" "grey35" "$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() { + set_default POWERLEVEL9K_TIME_FORMAT "%D{%H:%M:%S}" + + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$POWERLEVEL9K_TIME_FORMAT" "TIME_ICON" +} + +################################################################ +# System date +prompt_date() { + set_default POWERLEVEL9K_DATE_FORMAT "%D{%d.%m.%y}" + + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$POWERLEVEL9K_DATE_FORMAT" "DATE_ICON" +} + +################################################################ +# 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" "grey50" "$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 +} + +################################################################ +# Segment to show VCS information +prompt_vcs() { + VCS_WORKDIR_DIRTY=false + VCS_WORKDIR_HALF_DIRTY=false + local 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 + vicmd) + "$1_prompt_segment" "$0_NORMAL" "$2" "$DEFAULT_COLOR" "default" "$POWERLEVEL9K_VI_COMMAND_MODE_STRING" + ;; + main|viins|*) + if [[ -z $POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then return; fi + "$1_prompt_segment" "$0_INSERT" "$2" "$DEFAULT_COLOR" "blue" "$POWERLEVEL9K_VI_INSERT_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) +# https://github.com/pyenv/pyenv#choosing-the-python-version +prompt_pyenv() { + if [[ -n "$PYENV_VERSION" ]]; then + "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON' + fi +} + +################################################################ +# Display openfoam information +prompt_openfoam() { + local wm_project_version="$WM_PROJECT_VERSION" + local wm_fork="$WM_FORK" + if [[ -n "$wm_project_version" ]] && [[ -z "$wm_fork" ]] ; then + "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "OF: $(basename "$wm_project_version")" + elif [[ -n "$wm_project_version" ]] && [[ -n "$wm_fork" ]] ; then + "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "F-X: $(basename "$wm_project_version")" + fi +} + +################################################################ +# Segment to display 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" "yellow1" "" 'LOCK_ICON' + fi +} + +################################################################ +# Kubernetes Current Context/Namespace +prompt_kubecontext() { + local kubectl_version="$(kubectl version --client 2>/dev/null)" + + if [[ -n "$kubectl_version" ]]; then + # Get the current Kuberenetes context + local cur_ctx=$(kubectl config view -o=jsonpath='{.current-context}') + cur_namespace="$(kubectl config view -o=jsonpath="{.contexts[?(@.name==\"${cur_ctx}\")].context.namespace}")" + # If the namespace comes back empty set it default. + if [[ -z "${cur_namespace}" ]]; then + cur_namespace="default" + fi + + local k8s_final_text="" + + if [[ "$cur_ctx" == "$cur_namespace" ]]; then + # No reason to print out the same identificator twice + k8s_final_text="$cur_ctx" + else + k8s_final_text="$cur_ctx/$cur_namespace" + fi + + "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_final_text" "KUBERNETES_ICON" + fi +} + +################################################################ +# Dropbox status +prompt_dropbox() { + # The first column is just the directory, so cut it + local dropbox_status="$(dropbox-cli filestatus . | cut -d\ -f2-)" + + # Only show if the folder is tracked and dropbox is running + if [[ "$dropbox_status" != 'unwatched' && "$dropbox_status" != "isn't running!" ]]; then + # If "up to date", only show the icon + if [[ "$dropbox_status" =~ 'up to date' ]]; then + dropbox_status="" + fi + + "$1_prompt_segment" "$0" "$2" "white" "blue" "$dropbox_status" "DROPBOX_ICON" + fi +} + +# print Java version number +prompt_java_version() { + local java_version + # Stupid: Java prints its version on STDERR. + # The first version ouput will print nothing, we just + # use it to transport whether the command was successful. + # If yes, we parse the version string (and need to + # redirect the stderr to stdout to make the pipe work). + java_version=$(java -version 2>/dev/null && java -fullversion 2>&1 | cut -d '"' -f 2) + + if [[ -n "$java_version" ]]; then + "$1_prompt_segment" "$0" "$2" "red" "white" "$java_version" "JAVA_ICON" + fi +} + +################################################################ +# Prompt processing and drawing +################################################################ +# Main prompt +build_left_prompt() { + local index=1 + local element + 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 + local element + 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 + + # Clear to the end of the line + echo -n "%E" +} + +powerlevel9k_preexec() { + _P9K_TIMER_START=$EPOCHREALTIME +} + +set_default POWERLEVEL9K_PROMPT_ADD_NEWLINE false +powerlevel9k_prepare_prompts() { + local RETVAL RPROMPT_PREFIX RPROMPT_SUFFIX + RETVAL=$? + RETVALS=( "$pipestatus[@]" ) + + _P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START)) + + # Reset start time + _P9K_TIMER_START=0x7FFFFFFF + + if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then + PROMPT='$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt) +$(print_icon 'MULTILINE_LAST_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 + +local NEWLINE=' +' + + if [[ $POWERLEVEL9K_PROMPT_ADD_NEWLINE == true ]]; then + NEWLINES="" + repeat ${POWERLEVEL9K_PROMPT_ADD_NEWLINE_COUNT:-1} { NEWLINES+=$NEWLINE } + PROMPT="$NEWLINES$PROMPT" + fi + + # Allow iTerm integration to work + [[ $ITERM_SHELL_INTEGRATION_INSTALLED == "Yes" ]] && PROMPT="%{$(iterm2_prompt_mark)%}$PROMPT" +} + +zle-keymap-select () { + zle reset-prompt + zle -R +} + +set_default POWERLEVEL9K_IGNORE_TERM_COLORS false +set_default POWERLEVEL9K_IGNORE_TERM_LANG false + +prompt_powerlevel9k_setup() { + # The value below was set to better support 32-bit CPUs. + # It's the maximum _signed_ integer value on 32-bit CPUs. + # Please don't change it until 19 January of 2038. ;) + + # Disable false display of command execution time + _P9K_TIMER_START=0x7FFFFFFF + + # 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=(cr percent sp subst) + + # Borrowed from promptinit, sets the prompt options in case the theme was + # not initialized via promptinit. + setopt noprompt{bang,cr,percent,sp,subst} "prompt${^prompt_opts[@]}" + + # Display a warning if the terminal does not support 256 colors + termColors + + # If the terminal `LANG` is set to `C`, this theme will not work at all. + if [[ $POWERLEVEL9K_IGNORE_TERM_LANG == false ]]; then + 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 + 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 + + zle -N zle-keymap-select +} + +prompt_powerlevel9k_teardown() { + add-zsh-hook -D precmd powerlevel9k_\* + add-zsh-hook -D preexec powerlevel9k_\* + PROMPT='%m%# ' + RPROMPT= +} + +prompt_powerlevel9k_setup "$@" diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/.git_backup b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/.git_backup new file mode 100644 index 0000000..009f04f --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/.git_backup @@ -0,0 +1 @@ +gitdir: ../../../../../.git/modules/modules/prompt/external/powerlevel9k/modules/shunit2 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/Makefile b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/Makefile new file mode 100644 index 0000000..effbcca --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/Makefile @@ -0,0 +1,89 @@ +# $Id$ + +PROG=shunit2 + +BIN_DIR=$(PWD)/bin +BUILD_DIR=$(PWD)/build +DIST_DIR=$(PWD)/dist +LIB_DIR=$(PWD)/lib +SHARE_DIR=$(PWD)/share +SRC_DIR=$(PWD)/src +TEST_DIR=$(PWD)/test +TMP_DIR=$(PWD)/tmp + +DOCBOOK_BUILD_DIR=$(BUILD_DIR)/docbook +DOCBOOK_SHARE_DIR=$(SHARE_DIR)/docbook + +DOCBOOK_SRC_DIR=$(SRC_DIR)/docbook +EXAMPLES_SRC_DIR=$(SRC_DIR)/examples +SHELL_SRC_DIR=$(SRC_DIR)/shell +TEST_SRC_DIR=$(SRC_DIR)/test + +HTML_XSL=$(SHARE_DIR)/docbook/tldp-xsl/21MAR2004/html/tldp-one-page.xsl + +all: build docs + +build: build-prep + cp -p $(SHELL_SRC_DIR)/$(PROG) $(BUILD_DIR) + +build-clean: + rm -fr $(BUILD_DIR) + +build-prep: + @mkdir -p $(BUILD_DIR) + +docs: docs-transform-shelldoc docs-transform-docbook + +docs-prep: + @mkdir -p $(DOCBOOK_BUILD_DIR) + @echo "Preparing documentation for parsing" + @isoDate=`date "+%Y-%m-%d"`; \ + find $(DOCBOOK_SRC_DIR) -name "*.xml" |\ + while read f; do \ + bn=`basename $$f`; \ + sed -e "s/@@ISO_DATE@@/$$isoDate/g" $$f >$(DOCBOOK_BUILD_DIR)/$$bn; \ + done + +docs-extract-shelldoc: docs-prep + @echo "Extracting the ShellDoc" + @$(BIN_DIR)/extractDocs.pl $(SHELL_SRC_DIR)/$(PROG) >$(BUILD_DIR)/$(PROG)_shelldoc.xml + +docs-transform-shelldoc: docs-prep docs-extract-shelldoc + @echo "Parsing the extracted ShellDoc" + @xsltproc $(SHARE_DIR)/resources/shelldoc.xslt $(BUILD_DIR)/$(PROG)_shelldoc.xml >$(DOCBOOK_BUILD_DIR)/functions.xml + +docs-transform-docbook: docs-docbook-prep docs-prep + @echo "Parsing the documentation with DocBook" + @xsltproc $(HTML_XSL) $(DOCBOOK_BUILD_DIR)/$(PROG).xml >$(BUILD_DIR)/$(PROG).html + +docs-docbook-prep: + @if [ ! -d "$(DOCBOOK_SHARE_DIR)/docbook-xml" \ + -o ! -d "$(DOCBOOK_SHARE_DIR)/docbook-xsl" ]; \ + then \ + echo "Preparing DocBook structure"; \ + $(BIN_DIR)/docbookPrep.sh "$(DOCBOOK_SHARE_DIR)"; \ + fi + +test: test-prep + @echo "executing $(PROG) unit tests" + ( cd $(TEST_DIR); $(TEST_SRC_DIR)/run-test-suite ) + +test-clean: + rm -fr $(TEST_DIR) + +test-prep: build test-clean + @mkdir -p $(TEST_DIR) + cp -p $(TEST_SRC_DIR)/test* $(TEST_DIR) + cp -p $(TEST_SRC_DIR)/run-test-suite $(TEST_DIR) + cp -p $(BUILD_DIR)/$(PROG) $(TEST_DIR) + +dist: dist-clean build docs + @mkdir $(DIST_DIR) + cp -p $(BUILD_DIR)/$(PROG) $(DIST_DIR) + cp -p $(BUILD_DIR)/$(PROG).html $(DIST_DIR) + +clean: build-clean test-clean + rm -fr $(TMP_DIR) + +dist-clean: clean + rm -fr $(DIST_DIR) diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/bin/docbookPrep.sh b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/bin/docbookPrep.sh new file mode 100755 index 0000000..eb7c270 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/bin/docbookPrep.sh @@ -0,0 +1,97 @@ +#! /bin/sh +# $Id$ + +XML_VERSION='4.4' +XML_FILE="docbook-xml-${XML_VERSION}" +XML_URL="http://www.docbook.org/xml/${XML_VERSION}/${XML_FILE}.zip" + +XSL_VERSION='1.72.0' +XSL_FILE="docbook-xsl-${XSL_VERSION}" +XSL_URL="http://downloads.sourceforge.net/docbook/${XSL_FILE}.tar.bz2" + +#----------------------------------------------------------------------------- +# do no edit below here +#----------------------------------------------------------------------------- + +PATH="${PATH}:${MY_DIR}" +PWD=${PWD:-`pwd`} + +MY_BASE=`basename "$0"` +MY_DIR=`dirname "$0"` + +# load shlib +. "${MY_DIR}/../lib/sh/shlib" + +BASE_DIR=`shlib_relToAbsPath "${MY_DIR}/.."` +DL_DIR="${BASE_DIR}/tmp" +DOCBOOK_DIR="${BASE_DIR}/share/docbook" + +CURL_OPTS='-C - -Os' +WGET_OPTS='-cq' + +METHOD_NONE=0 +METHOD_WGET=1 +METHOD_CURL=2 + +get_url() +{ + url=$1 + case ${method} in + ${METHOD_CURL}) ${curl} ${CURL_OPTS} "${url}" ;; + ${METHOD_WGET}) ${wget} ${WGET_OPTS} "${url}" ;; + esac +} + +# determine method +method=${METHOD_NONE} +wget=`which wget` +[ $? -eq 0 ] && method=${METHOD_WGET} +curl=`which curl` +[ $? -eq 0 -a ${method} -eq ${METHOD_NONE} ] && method=${METHOD_CURL} +if [ ${method} -eq ${METHOD_NONE} ]; then + echo "unable to locate wget or curl. cannot continue" + exit 1 +fi + +# create download dir +mkdir -p "${DL_DIR}" + +# get the docbook xml files +echo 'Docbook XML' +echo ' downloading' +cd ${DL_DIR} +get_url "${XML_URL}" +if [ -f "${DL_DIR}/${XML_FILE}.zip" ]; then + echo ' extracting' + xml_dir="${DOCBOOK_DIR}/docbook-xml/${XML_VERSION}" + rm -fr "${xml_dir}" + mkdir -p "${xml_dir}" + cd "${xml_dir}" + unzip -oq "${DL_DIR}/${XML_FILE}.zip" + cd .. + rm -f current + ln -s "${XML_VERSION}" current +else + echo "error: unable to extract (${XML_FILE}.zip)" >&2 + exit 1 +fi + +# get the docbook xslt files +echo 'Docbook XSLT' +echo ' downloading' +cd ${DL_DIR} +get_url "${XSL_URL}" +if [ -f "${DL_DIR}/${XSL_FILE}.tar.bz2" ]; then + echo ' extracting' + xsl_dir="${DOCBOOK_DIR}/docbook-xsl" + mkdir -p "${xsl_dir}" + cd "${xsl_dir}" + rm -fr ${XSL_VERSION} + bzip2 -dc "${DL_DIR}/${XSL_FILE}.tar.bz2" |tar xf - + mv ${XSL_FILE} ${XSL_VERSION} + rm -f current + ln -s "${XSL_VERSION}" current +else + echo "error: unable to extract (${XSL_FILE}.tar.bz2)" >&2 + exit 1 +fi diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/bin/extractDocs.pl b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/bin/extractDocs.pl new file mode 100755 index 0000000..a803526 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/bin/extractDocs.pl @@ -0,0 +1,40 @@ +#! /usr/bin/perl +# $Id$ + +if(@ARGV != 1) { + print "usage: $0 sourceFile\n"; + exit; +} + +$sourceFile = $ARGV[0]; + +# +# read in the source file +# +$rslt = open(FILE, $sourceFile) + || die "could not open file ($sourceFile)"; + +$inComment = 0; +while() { + next if /^[^#]/; + s/^# //; + s/^#//; + + if(/^\/\*\*/) { + $inComment = 1; + next; + } + if(/\*\/$/) { + $inComment = 0; + next; + } + + if ($inComment == 1) { print $_ }; + if ($inComment == 0 && /\/\/\*/) { + @line = split /\/\/\*/, $_, 2; + $line[1] =~ s/^ //; + print $line[1]; + } +} + +close(FILE); diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/bin/which b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/bin/which new file mode 100755 index 0000000..9d7cc9f --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/bin/which @@ -0,0 +1,36 @@ +#! /bin/sh +# $Id$ +# +# This is a simple implementation of the 'which' command for those OSes that +# don't have one. +# + +true; TRUE=$? +false; FALSE=$? + +showAll=${FALSE} + +# process command line flags +while getopts 'a' opt; do + case ${opt} in + a) showAll=${TRUE} + esac +done +shift `expr ${OPTIND} - 1` + +# exit if no arguments were given +[ $# -eq 0 ] && exit 1 + +command=$1 + +# search for command +out=`echo "${PATH}" |sed "s/:/\n/g" |\ +while read path; do + fullPath="${path}/${command}" + if [ -x "${fullPath}" ]; then + echo "${fullPath}" + [ ${showAll} -eq ${FALSE} ] && break + fi +done` +[ -z "${out}" ] && exit 1 +echo "${out}" diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/CHANGES-2.0.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/CHANGES-2.0.txt new file mode 100644 index 0000000..97ea3db --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/CHANGES-2.0.txt @@ -0,0 +1,68 @@ +CHANGES WITH 2.0.4 + +Unset additional variables that were missed. + +Fixed off-by-one in exit value for scripts caught by the trap handler. + +The library did not fail gracefully when the 'od' command was not installed. + + +CHANGES WITH 2.0.3 + +Back ported the Makefile from 2.1.1pre that included changes to the +docs-docbook-prep target. + +Changed the test in assertFalse() so that any non-zero value registers as +false. (Credits to Bryan Larsen) + +Updated the testPartyLikeItIs1999() function in the Quick Start documentation. +The 'expected' and 'actual' values were swapped. (Credits to Richard Jensen) + +It was pointed out that the simple 'failed' message for a failed assert was not +only insufficient, it was nonstandard (when compared to JUnit) and didn't +provide the user with an expected vs actual result. The code was revised +somewhat to bring closer into alignment with JUnit (v4.3.1 specifically) so +that it feels more "normal". (Credits to Richard Jensen) + +As part of the JUnit realignment, it was noticed that fail*() functions in +JUnit don't actually do any comparisons themselves. They only generate a +failure message. Updated the code to match. + +Added self-testing unit tests. Kinda horkey, but they did find bugs during the +JUnit realignment. + +Fixed the code for returning from asserts as the return was being called before +the unsetting of variables occurred. (Credits to Mathias Goldau) + +The assert(True|False)() functions now accept an integer value for a +conditional test. A value of '0' is considered 'true', while any non-zero value +is considered 'false'. + +All public functions now fill use default values to work properly with the '-x' +shell debugging flag. + +Fixed the method of percent calculation for the report to get achieve better +accuracy. + + +CHANGES WITH 2.0.2 + +Fixed problem with fail(). The failure message was not properly printed. + +Reworked the Makefile so that the DocBook XML and XSLT files are properly +downloaded before parsing can continue. + + +CHANGES WITH 2.0.1 + +Fixed some really stupid mistakes with the fail* functions. They were doing the +exact opposite of what they were supposed to be doing. + + +CHANGES WITH 2.0.0 + +Made the first stand-alone release! + + +$Revision$ +vim:spell diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/LGPL-2.1 b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/LGPL-2.1 new file mode 100644 index 0000000..b1e3f5a --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/LGPL-2.1 @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/README.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/README.txt new file mode 100644 index 0000000..538f4f4 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/README.txt @@ -0,0 +1,153 @@ +#------------------------------------------------------------------------------ +# SourceForge +# + +This project is stored on SourceForge as http://sf.net/projects/shunit2. The +source code can be accessed using the following information. + +* Subversion +$ svn co https://shunit2.svn.sourceforge.net/svnroot/shunit2/trunk/source shunit2 + +Subversion may also be browsed via a web browser at +http://svn.sourceforge.net/shunit2 + +#------------------------------------------------------------------------------ +# Making a release +# + +For these steps, it is assumed we are working with release 2.0.0. + +Steps: +* write release notes +* update version +* finish changelog +* check all the code in +* tag the release +* export the release +* create tarball +* md5sum the tarball and sign with gpg +* update website +* post to SourceForge and Freshmeat + +WRITE RELEASE NOTES + +This should be pretty self explainatory. Use one of the release notes from a +previous release as an example. + +To get the versions of the various shells, do the following: +Cygwin + bash: $ bash --version + ksh: actually pdksh + pdksh: look in the downloaded Cygwin directory +Linux + bash: $ bash --version + dash: look at installed version + ksh: $ ksh --version + pdksh: $ strings /bin/pdksh |grep 'PD KSH' + zsh: $ zsh --version +Solaris 10 + sh: not possible + bash: $ bash --version + ksh: $ strings /usr/bin/ksh |grep 'Version' + +UPDATE VERSION + +Edit the shunit2 source code, and change the version number in the comment, as +well as in the __SHUNIT_VERSION variable. Next, edit the +src/docbook/shunit2.xml file, edit the version in the element, and make +sure there is a revision section for this release. + +FINISH DOCUMENTATION + +Make sure that any remaning changes get put into the CHANGES-X.X.txt file. + +Finish writing the RELEASE_NOTES-X.X.X.txt. Once it is finished, run it through +the 'fmt' command to make it pretty. + +$ fmt -w 80 RELEASE_NOTES-2.0.0.txt >RELEASE_NOTES-2.0.0.txt.new +$ mv RELEASE_NOTES-2.0.0.txt.new RELEASE_NOTES-2.0.0.txt + +We want to have an up-to-date version of the documentation in the release, so +we'd better build it. + +$ pwd +.../shunit2/source/2.0 +$ make docs +... +$ cp -p build/shunit2.html doc +$ svn ci -m "" doc/shunit2.html + +CHECK IN ALL THE CODE + +This step is pretty self-explainatory + +TAG THE RELEASE + +$ pwd +.../shunit2/source +$ ls +2.0 2.1 +$ svn cp -m "Release 2.0.0" \ +2.0 https://shunit2.svn.sourceforge.net/svnroot/shunit2/tags/source/2.0.0 + +EXPORT THE RELEASE + +$ pwd +.../shunit2/builds +$ svn export \ +https://shunit2.svn.sourceforge.net/svnroot/shunit2/tags/source/2.0.0 \ +shunit2-2.0.0 + +CREATE TARBALL + +$ tar cfz ../releases/shunit2-2.0.0.tgz shunit2-2.0.0 + +MD5SUM THE TARBALL AND SIGN WITH GPG + +$ cd ../releases +$ md5sum shunit2-2.0.0.tgz >shunit2-2.0.0.tgz.md5 +$ gpg --default-key kate.ward@forestent.com --detach-sign shunit2-2.0.0.tgz + +UPDATE WEBSITE + +Again, pretty self-explainatory. Make sure to copy the MD5 and GPG signature +files. Once that is done, make sure to tag the website so we can go back in +time if needed. + +$ pwd +.../shunit2 +$ ls +source website +$ svn cp -m "Release 2.0.0" \ +website https://shunit2.svn.sourceforge.net/svnroot/shunit2/tags/website/20060916 + +Now, update the website. It too is held in Subversion, so ssh into SourceForge +and use 'svn up' to grab the latest version. + +POST TO SOURCEFORGE AND FRESHMEAT + +http://sourceforge.net/projects/shunit2/ +http://freshmeat.net/ + +#------------------------------------------------------------------------------ +# Related documentation +# + +Docbook XML + docbook-xml-4.4.zip + http://www.docbook.org/xml/4.4/docbook-xml-4.4.zip + http://www.oasis-open.org/docbook/xml/4.4/docbook-xml-4.4.zip + docbook-xml-4.5.zip + http://www.docbook.org/xml/4.5/docbook-xml-4.5.zip + +Docbook XSL + docbook-xsl-1.71.0.tar.bz2 + http://prdownloads.sourceforge.net/docbook/docbook-xsl-1.71.0.tar.bz2?download + docbook-xsl-1.71.1.tar.bz2 + http://downloads.sourceforge.net/docbook/docbook-xsl-1.71.1.tar.bz2?use_mirror=puzzle + +JUnit + http://www.junit.org + + +$Revision$ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/RELEASE_NOTES-2.0.0.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/RELEASE_NOTES-2.0.0.txt new file mode 100644 index 0000000..947eea9 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/RELEASE_NOTES-2.0.0.txt @@ -0,0 +1,71 @@ +RELEASE NOTES FOR 2.0.0 + +This is the initial release of shunit2. It was originally included in log4sh +1.3.5 [http://log4sh.sourceforge.net/] as a unit testing framework for that +product. It has since grown table enough to warrant being released into the +wild on its own. + + +TESTED PLATFORMS + +This list of platforms comes from the latest version of log4sh as shunit2 is +used in the testing of log4sh on each of these platforms. + +Cygwin ++ bash 3.2.9(10) ++ pdksh 5.2.14 + +Linux ++ bash 3.1.17(1) ++ dash 0.5.3 ++ ksh 1993-12-28 ++ pdksh 5.2.14 ++ zsh 4.3.2 (does not work) + +Mac OS X 1.4.8 (Darwin 8.8) ++ bash 2.05b.0(1) ++ ksh 1993-12-28 + +Solaris 8 U3 (x86) ++ /bin/sh ++ bash 2.03.0(1) ++ ksh M-11/16/88i + +Solaris 10 U2 (sparc) ++ /bin/sh ++ bash 3.00.16(1) ++ ksh M-11/16/88i + +Solaris 10 U2 (x86) ++ /bin/sh ++ bash 3.00.16(1) ++ ksh M-11/16/88i + + +NEW FEATURES + +None. + + +CHANGES AND ENHANCEMENTS + +None. + + +BUG FIXES + +None. + + +DEPRECATED FEATURES + +None. + + +KNOWN BUGS AND ISSUES + +None. + + +$Revision$ +vim:spell diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/RELEASE_NOTES-2.0.1.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/RELEASE_NOTES-2.0.1.txt new file mode 100644 index 0000000..110a37a --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/RELEASE_NOTES-2.0.1.txt @@ -0,0 +1,73 @@ +RELEASE NOTES FOR 2.0.1 + +This release is mostly a brown-bag release. Not so nice for the second release +ever of the product, but that's what I get for trying to get something out +there that I hadn't fully looked through one last time. + + +TESTED PLATFORMS + +This list of platforms comes from the latest version of log4sh as shunit2 is +used in the testing of log4sh on each of these platforms. + +Cygwin ++ bash 3.2.9(10) ++ pdksh 5.2.14 + +Linux ++ bash 3.1.17(1) ++ dash 0.5.3 ++ ksh 1993-12-28 ++ pdksh 5.2.14 ++ zsh 4.3.2 (does not work) + +Mac OS X 1.4.8 (Darwin 8.8) ++ bash 2.05b.0(1) ++ ksh 1993-12-28 + +Solaris 8 U3 (x86) ++ /bin/sh ++ bash 2.03.0(1) ++ ksh M-11/16/88i + +Solaris 10 U2 (sparc) ++ /bin/sh ++ bash 3.00.16(1) ++ ksh M-11/16/88i + +Solaris 10 U2 (x86) ++ /bin/sh ++ bash 3.00.16(1) ++ ksh M-11/16/88i + + +NEW FEATURES + +None. + + +CHANGES AND ENHANCEMENTS + +The documentation regarding the assertTrue() and assertFalse() functions was +updated to reflect their proper usage. They are shell test condition evaluators +(e.g. "[1 -eq 2]") rather than simple 0/1 comparators. + + +BUG FIXES + +The fail*() functions were doing the exact opposite of what they were supposed +to be doing. They have been fixed. + + +DEPRECATED FEATURES + +None. + + +KNOWN BUGS AND ISSUES + +None. + + +$Revision$ +vim:spell diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/RELEASE_NOTES-2.0.2.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/RELEASE_NOTES-2.0.2.txt new file mode 100644 index 0000000..e7bcad6 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/RELEASE_NOTES-2.0.2.txt @@ -0,0 +1,71 @@ +RELEASE NOTES FOR 2.0.2 + +This is solely a bug-fix release. + + +TESTED PLATFORMS + +This list of platforms comes from the latest version of log4sh as shUnit2 is +used in the testing of log4sh on each of these platforms. + +Cygwin ++ bash 3.2.9(10) ++ pdksh 5.2.14 + +Linux ++ bash 3.1.17(1) ++ dash 0.5.3 ++ ksh 1993-12-28 ++ pdksh 5.2.14 ++ zsh 4.3.2 (does not work) + +Mac OS X 1.4.8 (Darwin 8.8) ++ bash 2.05b.0(1) ++ ksh 1993-12-28 + +Solaris 8 U3 (x86) ++ /bin/sh ++ bash 2.03.0(1) ++ ksh M-11/16/88i + +Solaris 10 U2 (sparc) ++ /bin/sh ++ bash 3.00.16(1) ++ ksh M-11/16/88i + +Solaris 10 U2 (x86) ++ /bin/sh ++ bash 3.00.16(1) ++ ksh M-11/16/88i + + +NEW FEATURES + +None. + + +CHANGES AND ENHANCEMENTS + +None. + + +BUG FIXES + +The fail() function did not output the optional failure message. + +Fixed the Makefile so that the DocBook XML and XSLT files would be downloaded +before parsing can continue. + + +DEPRECATED FEATURES + +None. + + +KNOWN BUGS AND ISSUES + +None. + + +$Revision$ +vim:spell diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/RELEASE_NOTES-2.0.3.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/RELEASE_NOTES-2.0.3.txt new file mode 100644 index 0000000..7e12684 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/RELEASE_NOTES-2.0.3.txt @@ -0,0 +1,60 @@ +RELEASE NOTES FOR 2.0.3 + +This release incorporates a realignment with the JUnit 4 code. Asserts now +provide better failure messages, and the failure functions no longer perform +tests. + +See the CHANGES-2.0.txt file for a full list of changes. + + +TESTED PLATFORMS + +This list of platforms comes from the latest version of log4sh as shUnit2 is +used in the testing of log4sh on each of these platforms. + +Cygwin -- untested + +Linux +- bash 3.2.13(1) +- dash 0.5.3 +- ksh 1993-12-28 +- pdksh 5.2.14 + +Mac OS X -- untested +Solaris 8 -- untested +Solaris 10 -- untested + + +NEW FEATURES + +None. + + +CHANGES AND ENHANCEMENTS + +The internal test in assertFalse() was changed so that any non-zero value is +considered false, rather than any only values equal to 1. + +The assertTrue() and assertFalse() functions now accept an integer value for a +conditional test. A value of '0' is considered 'true', while any non-zero value +is considered 'false'. + +Self-testing unit tests were added. + + +BUG FIXES + +All asserts now properly unset their variables. + + +DEPRECATED FEATURES + +None. + + +KNOWN BUGS AND ISSUES + +Functions do not properly test for an invalid number of arguments. + + +vim:spell diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/RELEASE_NOTES-2.0.4.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/RELEASE_NOTES-2.0.4.txt new file mode 100644 index 0000000..64fb417 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/RELEASE_NOTES-2.0.4.txt @@ -0,0 +1,51 @@ +RELEASE NOTES FOR 2.0.4 + +This is a minor bugfix release. + +See the CHANGES-2.0.txt file for a full list of changes. + + +TESTED PLATFORMS + +This list of platforms comes from the latest version of log4sh as shUnit2 is +used in the testing of log4sh on each of these platforms. + +Cygwin -- untested + +Linux +- bash 3.2.13(1) +- dash 0.5.3 +- ksh 1993-12-28 +- pdksh 5.2.14 + +Mac OS X -- untested +Solaris 8 -- untested +Solaris 10 -- untested + + +NEW FEATURES + +None. + + +CHANGES AND ENHANCEMENTS + +None. + + +BUG FIXES + +The library no longer fails when the 'od' command is not present. + + +DEPRECATED FEATURES + +None. + + +KNOWN BUGS AND ISSUES + +Functions do not properly test for an invalid number of arguments. + + +vim:spell diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/TODO.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/TODO.txt new file mode 100644 index 0000000..7fd6314 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/TODO.txt @@ -0,0 +1,5 @@ +Make it possible to execute a single test by passing the name of the test on +the command line + + +$Revision$ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/contributors.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/contributors.txt new file mode 100644 index 0000000..69da654 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/contributors.txt @@ -0,0 +1,10 @@ +The original author of shunit2 is Kate Ward. The following people have +contributed in some way or another to shunit2. + +Bryan Larsen +Kevin Van Horn +Mathias Goldau +Richard Jensen +Rob Holland + +$Revision$ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/design_doc.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/design_doc.txt new file mode 100644 index 0000000..2849e55 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/design_doc.txt @@ -0,0 +1,54 @@ +Design Doc for shUnit2 +====================== + +shUnit is based upon JUnit. The initial ideas for the script came from the book +"Pragmatic Unit Testing - In Java with JUnit" by Andrew Hunt and David Thomas. + +The script was written to perform unit testing for log4sh. log4sh had grown +enough that it was becoming difficult to easily test and and verify that the +tests passed for the many different operating systems on which it was being +used. + +The functions in shUnit are meant to match those in JUnit as much as possible +where shell allows. In the initial version, there will be no concept of +exceptions (as normal POSIX shell has no concept of them) but attempts to trap +problems will be done. + +Programatic Standards +--------------------- + +* SHUNIT_TRUE - public global constant +* __SHUNIT_SHELL_FLAGS - private global constant +* __shunit_oldShellFlags - private global variable + +* assertEquals - public unit test function +* shunit_publicFunc - public shUnit function; can be called from parent unit + test script +* _shunit_privateFunc - private shUnit function; should not be called from + parent script. meant for internal use by shUnit + +* _su_myVar - variable inside a public function. prefixing with '_su_' to + reduce the chances that a variable outside of shUnit will be overridden. +* _su__myVar - variable inside a private function. prefixing with '_su__' to + reduce the chances that a variable in a shUnit public function, or a variable + outside of shUnit will be overridden. + +List of functions +----------------- + +assertTrue([message,] boolean) +assertFalse([message,] boolean) +fail([message]) +assertEquals([message,] expected, actual) +#isEquals(expected, actual) +#assertArrayEquals([message,] expecteds, actuals) +#isArray(expected) +assertNotNull([message,] object) +assertNull([message,], object) +assertSame([message,], expected, actual) +assertNotSame([message,], unexpected, actual) +failSame(message) +failNotSame([message,] expected, actual) + +.. $Revision$ +.. vim:syntax=rst diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/shunit2.html b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/shunit2.html new file mode 100644 index 0000000..6690867 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/shunit2.html @@ -0,0 +1,218 @@ +<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>shUnit2

shUnit2 version 2.0.3

Kate Ward


+            
+          

2007-07-12

Revision History
Revision 2.0.32007-07-12Kate Ward <kate.ward@forestent.com>
Revision 2.0.22007-04-22Kate Ward <kate.ward@forestent.com>
Revision 2.0.12007-02-21Kate Ward <kate.ward@forestent.com>
Revision 2.0.02007-02-20Kate Ward <kate.ward@forestent.com>

Abstract

shUnit2 is a unit test framework for Bourne based shell scripts, and it is designed to work in a similar manner to JUnit, PyUnit, etc.


List of Tables

3.1. asserts
3.2. failures
3.3. suites

Chapter 1. Introduction

shUnit2 is a unit test framework for Bourne based shell scripts, and it is designed to work in a similar manner to JUnit, PyUnit, etc.

shUnit2 was originally developed to provide a consistent testing solution for log4sh, a shell based logging framework similar to log4j. During the development of that product, the problem of having things work just fine under one shell (/bin/bash on Linux to be specific), and then not working under another shell (/bin/sh on Solaris), kept coming up. Although there were several simple tests ran, they were not adaquate and did not catch very many corner cases. The decision was finally made to write a proper unit test framework after after multiple brown-bag releases were made.

Tested Operating Systems

Tested Shells

  • Bourne Shell (sh)

  • BASH - GNU Bourne Again SHell (bash)

  • DASH (dash)

  • Korn Shell (ksh)

  • pdksh - Public Domain Korn Shell (pdksh)

See the appropriate Release Notes (doc/RELEASE_NOTES-X.X.X.txt) for this release for the actual versions tested.

1. Credits / Contributors

A list of contributors to shUnit2 can be found in the source archive as doc/contributors.txt. I want to personally thank all those who have contributed to make this a better tool.

2. Feedback

Feedback is most certainly welcome for this document. Send your additions, comments and criticisms to the following email address: .

Chapter 2. Quickstart

This chapter will give a very quick start to running unit tests with shUnit2. More information is located in other chapters.

Here is a quick sample script to show how easy it is to write a unit test in shell. It expects that you have a copy of shunit2 in the same directory as the script.

+
+#! /bin/sh
+
+testEquality()
+{
+  assertEquals 1 1
+}
+
+# load shunit2
+. ./shunit2
+
+  

Running the unit test should give results similar to the following.

+
+#
+# Performing tests
+#
+testEquality
+
+#
+# Test report
+#
+tests passed: 1
+tests failed: 0
+tests total:  1
+success rate: 100%
+
+  

Wohoo! You've just run your first successful unit test. So, what just happened? Quite a bit really, and it all happened simply by sourcing the shunit2 script. The basic functionality for the script above goes like this.

When shUnit2 is sourced, it first looks to see if a suite() function has been declared. If it exists, it is called as it is expected to contain a list of tests to be executed. If it doesn't exist (and it doesn't in the above example), shUnit2 will look on its own for any functions that start with the string test, and adds those to an internal list of tests to execute. Once a list of test functions to be run has been determined, shunit2 will go to work.

Before any tests are executed, shUnit2 again looks for a function, this time one named oneTimeSetUp(). If it exists, it will be run. This function is normally used to setup the environment for all tests to be run. Things like creating directories for output or setting environment variables are good to place here. Just so you know, you can also declare a corresponding function named oneTimeTearDown() function that does the same thing, but once all the tests have been completed. It is good for removing temporary directories, etc.

shUnit2 is now ready to run tests. Before doing so though, it again looks for another function that might be declared, one named setUp(). If the function exists, it will be run before each test. It is good for resetting the environment so that each test starts with a clean slate. At this stage, the first test is finally run. The success of the test is recorded for a report that will be generated later. After the test is run, shUnit2 looks for a final function that might be declared, one named tearDown(). If it exists, it will be run after each test. It is a good place for cleaning up after each test, maybe doing things like removing files that were created, or removing directories. This set of steps, setUp() > test() > tearDown(), is repeated for all of the available tests.

Once all the work is done, shUnit2 will generate the nice report you saw above. A summary of all the successes and failures will be given so that you know how well your code is doing.

We should now try adding a test that fails. Change your unit test to look like this.

+
+#! /bin/sh
+
+testEquality()
+{
+  assertEquals 1 1
+}
+
+testPartyLikeItIs1999()
+{
+  year=`date '+%Y'`
+  assertEquals "It's not 1999 :-( This is ${year}." \
+      '1999' "${year}"
+}
+
+# load shunit2
+. ./shunit2
+
+  

So, what did you get? I guess it told you that this isn't 1999. Bummer, eh? Hopefully, you noticed a couple of things that were different about the second test. First, we added an optional message that the user will see if the assert fails. Second, we did comparisons of strings instead of integers as in the first test. It doesn't matter whether you are testing for equality of strings or integers. Both work equally well with shUnit2.

Hopefully, this is enough to get you started with unit testing. If you want a ton more examples, take a look at the tests provided with log4sh. Examples of much more advanced usage can be seen there. shUnit2 was after all written to help with the unit testing problems that log4sh had.

Chapter 3. Function Reference

1. asserts

Table 3.1. asserts

+ void + +
+ assertEquals + ([message],  
 expected,  
 actual); 
string  [message];
string  expected;
string  actual;
+

Asserts that expected and + actual are equal to one another. The message is + optional.

+
+ void + +
+ assertNull + ([message],  
 value); 
string  [message];
string  value;
+

Asserts that value is null, + or in shell terms a zero-length string. The message is optional.

+
+ void + +
+ assertNotNull + ([message],  
 value); 
string  [message];
string  value;
+

Asserts that value is notnull, or in shell terms not + a zero-length string. The message is optional.

+
+ void + +
+ assertSame + ([message],  
 expected,  
 actual); 
string  [message];
string  expected;
string  actual;
+

This function is functionally equivalent to + assertEquals.

+
+ void + +
+ assertNotSame + ([message],  
 unexpected,  
 actual); 
string  [message];
string  unexpected;
string  actual;
+

Asserts that unexpected and + actual are not + equal to one another. The message is optional.

+
+ void + +
+ assertTrue + ([message],  
 condition); 
string  [message];
string  condition;
+

Asserts that a given shell test condition is true. The message is + optional.

+

Testing whether something is true or false is easy enough by using + the assertEquals/assertNotSame functions. Shell supports much more + complicated tests though, and a means to support them was needed. As such, + this function tests that conditions are true or false through evaluation + rather than just looking for a true or false.

+
+ The following test will succeed:
assertTrue "[ 34 -gt 23 ]"
+ The folloing test will fail with a message:
assertTrue "test failed" "[ -r '/non/existant/file' ]"
+
+ void + +
+ assertFalse + ([message],  
 condition); 
string  [message];
string  condition;
+

Asserts that a given shell test condition is false. The message is + optional.

+

Testing whether something is true or false is easy enough by using + the assertEquals/assertNotSame functions. Shell supports much more + complicated tests though, and a means to support them was needed. As such, + this function tests that conditions are true or false through evaluation + rather than just looking for a true or false.

+
+ The following test will succeed:
assertFalse "[ 'apples' = 'oranges' ]"
+ The folloing test will fail with a message:
assertFalse "test failed" "[ 1 -eq 1 -a 2 -eq 2 ]"
+

2. failures

Table 3.2. failures

+ void + +
+ fail + ([message]); 
string  [message];
+

Fails the test immediately, with the optional message.

+
+ void + +
+ failNotEquals + ([message],  
 unexpected,  
 actual); 
string  [message];
string  unexpected;
string  actual;
+

Fails the test if unexpected and + actual are not + equal to one another. The message is optional.

+
+ void + +
+ failSame + ([message]); 
string  [message];
+

Indicate test failure because arguments were not the same. The + message is optional.

+
+ void + +
+ failNotSame + ([message],  
 expected,  
 actual); 
string  [message];
string  expected;
string  actual;
+

Fails the test if expected and + actual are equal to one another. The message is + optional.

+

3. suites

Table 3.3. suites

+ void + +
+ suite + (); 
 ;
+

This function can be optionally overridden by the user in their test + suite.

+

If this function exists, it will be called when + shunit2 is sourced. If it does not exist, shUnit2 will + search the parent script for all functions beginning with the word + test, and they will be added dynamically to the test + suite.

+
+ void + +
+ suite_addTest + (function); 
string  function;
+

This function adds a function name to the list of tests scheduled for + execution as part of this test suite. This function should only be called + from within the suite() function.

+
+ void + +
+ oneTimeSetUp + (); 
 ;
+

This function can be be optionally overridden by the user in their + test suite.

+

If this function exists, it will be called once before any tests are + run. It is useful to prepare a common environment for all tests.

+
+ void + +
+ oneTimeTearDown + (); 
 ;
+

This function can be be optionally overridden by the user in their + test suite.

+

If this function exists, it will be called once after all tests are + completed. It is useful to clean up the environment after all tests.

+
+ void + +
+ setUp + (); 
 ;
+

This function can be be optionally overridden by the user in their + test suite.

+

If this function exists, it will be called before each test is run. + It is useful to reset the environment before each test.

+
+ void + +
+ tearDown + (); 
 ;
+

This function can be be optionally overridden by the user in their + test suite.

+

If this function exists, it will be called after each test completes. + It is useful to clean up the environment after each test.

+

diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/style.css b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/style.css new file mode 100644 index 0000000..c1d2f43 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/doc/style.css @@ -0,0 +1,33 @@ +/* $Id$ */ +/* + style.css +*/ + + +body { + +/* + Style the HMTL tag with a sans-serif font and 6% margin. + A sans-serif font makes documents easier to read when displayed on + a computer screen. Whitespace surrounding the document should + make it easier to read both on screen and on printed paper. The + value of 6% was chosen because it closely approximates a one-half + inch margin on a US letter (8.5" by 11") paper. Since the margin + is expressed as a percentage it should scale well in a web browser + window. +*/ + + font-family: sans-serif; + margin: 6%; +} + +/* +table { + font-size: 0.9em; +} +*/ + +.toc { + background: #f0f0f0; + padding: 5px; +} diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/lib/sh/shlib b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/lib/sh/shlib new file mode 100644 index 0000000..00aadcb --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/lib/sh/shlib @@ -0,0 +1,23 @@ +# $Id$ +# vim:syntax=sh +# +# library of shell functions +# + +shlib_relToAbsPath() +{ + _shlib_path=$1 + + # deal with paths that start with / + echo "${_shlib_path}" |grep '^/' >/dev/null 2>&1 + if [ $? -ne 0 ]; then + _shlib_pwd=`pwd` + _shlib_path="${_shlib_pwd}/${_shlib_path}" + unset _shlib_pwd + fi + + # clean up the path + echo "${_shlib_path}" |sed 's/[^/]*\/*\.\.\/*//g;s/\/\.\//\//' + + unset _shlib_path +} diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/share/docbook/tldp-xsl/21MAR2004/fo/tldp-print.xsl b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/share/docbook/tldp-xsl/21MAR2004/fo/tldp-print.xsl new file mode 100644 index 0000000..b7a7d43 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/share/docbook/tldp-xsl/21MAR2004/fo/tldp-print.xsl @@ -0,0 +1,26 @@ + + + + + + + + + + + +start + + + + + + + + diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/share/docbook/tldp-xsl/21MAR2004/html/tldp-common.xsl b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/share/docbook/tldp-xsl/21MAR2004/html/tldp-common.xsl new file mode 100644 index 0000000..f8cf7b1 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/share/docbook/tldp-xsl/21MAR2004/html/tldp-common.xsl @@ -0,0 +1,22 @@ + + + + + + + +text/css + + + + + + + diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/share/docbook/tldp-xsl/21MAR2004/html/tldp-one-page.xsl b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/share/docbook/tldp-xsl/21MAR2004/html/tldp-one-page.xsl new file mode 100644 index 0000000..16994ad --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/share/docbook/tldp-xsl/21MAR2004/html/tldp-one-page.xsl @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/share/resources/shelldoc.xslt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/share/resources/shelldoc.xslt new file mode 100644 index 0000000..45d5f92 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/share/resources/shelldoc.xslt @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + Function Reference + + + +
+ shelldoc-section- + <xsl:value-of select="@group"/> + + shelldoc-function- + <xsl:value-of select="@group"/> + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + + + + + +
diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/docbook/functions.xml b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/docbook/functions.xml new file mode 100644 index 0000000..c960e55 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/docbook/functions.xml @@ -0,0 +1,14 @@ + + + + + + + Functions + This XML file is a placeholder. It is meant to be overwritten with the dynamically generated XML document that is extracted from the source code. + diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/docbook/introduction.xml b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/docbook/introduction.xml new file mode 100644 index 0000000..d71b091 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/docbook/introduction.xml @@ -0,0 +1,50 @@ + + + + + + + + Introduction + shUnit2 is a unit test framework for Bourne based shell scripts, and it is designed to work in a similar manner to JUnit, PyUnit, etc. + + shUnit2 was originally developed to provide a consistent testing solution for log4sh, a shell based logging framework similar to log4j. During the development of that product, the problem of having things work just fine under one shell (/bin/bash on Linux to be specific), and then not working under another shell (/bin/sh on Solaris), kept coming up. Although there were several simple tests ran, they were not adaquate and did not catch very many corner cases. The decision was finally made to write a proper unit test framework after after multiple brown-bag releases were made. + +
Tested Operating Systems + + Cygwin + FreeBSD (user supported) + Linux (Gentoo, Ubuntu) + Mac OS X + Solaris 8, 9, 10 + +
+ +
Tested Shells + + Bourne Shell (sh) + BASH - GNU Bourne Again SHell (bash) + DASH (dash) + Korn Shell (ksh) + pdksh - Public Domain Korn Shell (pdksh) + +
+ + See the appropriate Release Notes (doc/RELEASE_NOTES-X.X.X.txt) for this release for the actual versions tested. + + +
Credits / Contributors + A list of contributors to shUnit2 can be found in the source archive as doc/contributors.txt. I want to personally thank all those who have contributed to make this a better tool. +
+ + +
Feedback + Feedback is most certainly welcome for this document. Send your additions, comments and criticisms to the following email address: &myEmail;. +
+ +
diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/docbook/quickstart.xml b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/docbook/quickstart.xml new file mode 100644 index 0000000..d009cb6 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/docbook/quickstart.xml @@ -0,0 +1,86 @@ + + + + + + Quickstart + + This chapter will give a very quick start to running unit tests with shUnit2. More information is located in other chapters. + + Here is a quick sample script to show how easy it is to write a unit test in shell. It expects that you have a copy of &shunit2; in the same directory as the script. + + + + + + Running the unit test should give results similar to the following. + + + + + + Wohoo! You've just run your first successful unit test. So, what just happened? Quite a bit really, and it all happened simply by sourcing the &shunit2; script. The basic functionality for the script above goes like this. + + When shUnit2 is sourced, it first looks to see if a suite() function has been declared. If it exists, it is called as it is expected to contain a list of tests to be executed. If it doesn't exist (and it doesn't in the above example), shUnit2 will look on its own for any functions that start with the string test, and adds those to an internal list of tests to execute. Once a list of test functions to be run has been determined, shunit2 will go to work. + + Before any tests are executed, shUnit2 again looks for a function, this time one named oneTimeSetUp(). If it exists, it will be run. This function is normally used to setup the environment for all tests to be run. Things like creating directories for output or setting environment variables are good to place here. Just so you know, you can also declare a corresponding function named oneTimeTearDown() function that does the same thing, but once all the tests have been completed. It is good for removing temporary directories, etc. + + shUnit2 is now ready to run tests. Before doing so though, it again looks for another function that might be declared, one named setUp(). If the function exists, it will be run before each test. It is good for resetting the environment so that each test starts with a clean slate. At this stage, the first test is finally run. The success of the test is recorded for a report that will be generated later. After the test is run, shUnit2 looks for a final function that might be declared, one named tearDown(). If it exists, it will be run after each test. It is a good place for cleaning up after each test, maybe doing things like removing files that were created, or removing directories. This set of steps, setUp() > test() > tearDown(), is repeated for all of the available tests. + + Once all the work is done, shUnit2 will generate the nice report you saw above. A summary of all the successes and failures will be given so that you know how well your code is doing. + + We should now try adding a test that fails. Change your unit test to look like this. + + + + + + So, what did you get? I guess it told you that this isn't 1999. Bummer, eh? Hopefully, you noticed a couple of things that were different about the second test. First, we added an optional message that the user will see if the assert fails. Second, we did comparisons of strings instead of integers as in the first test. It doesn't matter whether you are testing for equality of strings or integers. Both work equally well with shUnit2. + + Hopefully, this is enough to get you started with unit testing. If you want a ton more examples, take a look at the tests provided with log4sh. Examples of much more advanced usage can be seen there. shUnit2 was after all written to help with the unit testing problems that log4sh had. + diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/docbook/shunit2.xml b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/docbook/shunit2.xml new file mode 100644 index 0000000..25b3fed --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/docbook/shunit2.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + shunit2"> +]> + +shUnit2 + + shUnit2 version 2.0.3 + + + KateWard + +
+ &myEmail; +
+
+
+
+ + + &isoDate; + + + + + + + 2.0.3 + 2007-07-12 + Kate Ward <&myEmail;> + + + + 2.0.2 + 2007-04-22 + Kate Ward <&myEmail;> + + + + 2.0.1 + 2007-02-21 + Kate Ward <&myEmail;> + + + + 2.0.0 + 2007-02-20 + Kate Ward <&myEmail;> + + + + + + shUnit2 is a unit test framework for Bourne based shell scripts, and it is designed to work in a similar manner to JUnit, PyUnit, etc. + +
+ + &introduction; + &quickstart; + &functions; +
diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/shell/shunit2 b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/shell/shunit2 new file mode 100644 index 0000000..4e82e5b --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/shell/shunit2 @@ -0,0 +1,799 @@ +# $Id$ +# vim:syntax=sh:sts=2 +# vim:foldmethod=marker:foldmarker=/**,*/ +# +#/** +# +# +# +# shUnit 2.0.4 +# Shell Unit Test Framework +# +# http://code.google.com/p/shunit2/ +# +# written by Kate Ward <kate.ward@forestent.com> +# released under the LGPL +# +# this module implements a xUnit based unit test framework similar to JUnit +# +#*/ + +# shell flags for shunit: +# u - treat unset variables as an error when performing parameter expansion +__SHUNIT_SHELL_FLAGS='u' + +# save the current set of shell flags, and then set some for ourselves +__shunit_oldShellFlags="$-" +for _shunit_shellFlag in `echo "${__SHUNIT_SHELL_FLAGS}" |sed 's/\(.\)/\1 /g'` +do + set -${_shunit_shellFlag} +done +unset _shunit_shellFlag + +# constants + +__SHUNIT_VERSION='2.0.4pre' + +__SHUNIT_TRUE=0 +__SHUNIT_FALSE=1 +__SHUNIT_ERROR=2 + +__SHUNIT_ASSERT_MSG_PREFIX='ASSERT:' + +for _su_const in `set |grep "^__SHUNIT_" |cut -d= -f1`; do + readonly ${_su_const} +done +unset _su_const + +# variables +__shunit_suite='' + +__shunit_testsPassed=0 +__shunit_testsFailed=0 +__shunit_testsTotal=0 + +#----------------------------------------------------------------------------- +# assert functions +# + +#/** +# +# +# void +# +# +# +# +# assertEquals +# string [message] +# string expected +# string actual +# +# +# Asserts that expected and +# actual are equal to one another. The message is +# optional. +# +# +#*/ +assertEquals() +{ + _su_message='' + if [ $# -eq 3 ]; then + _su_message=$1 + shift + fi + _su_expected=${1:-} + _su_actual=${2:-} + + shunit_return=${__SHUNIT_TRUE} + if [ "${_su_expected}" = "${_su_actual}" ]; then + _shunit_testPassed + else + failNotEquals "${_su_message}" "${_su_expected}" "${_su_actual}" + shunit_return=${__SHUNIT_FALSE} + fi + + unset _su_message _su_expected _su_actual + return ${shunit_return} +} + +#/** +# +# +# void +# +# +# +# +# assertNull +# string [message] +# string value +# +# +# Asserts that value is null, +# or in shell terms a zero-length string. The message is optional. +# +# +#*/ +assertNull() +{ + if [ $# -eq 2 ]; then + assertTrue "$1" "[ -z '$2' ]" + else + assertTrue "[ -z '${1:-}' ]" + fi +} + +#/** +# +# +# void +# +# +# +# +# assertNotNull +# string [message] +# string value +# +# +# Asserts that value is not null, or in shell terms not +# a zero-length string. The message is optional. +# +# +#*/ +assertNotNull() +{ + if [ $# -eq 2 ]; then + assertTrue "$1" "[ -n '$2' ]" + else + assertTrue "[ -n '${1:-}' ]" + fi +} + +#/** +# +# +# void +# +# +# +# +# assertSame +# string [message] +# string expected +# string actual +# +# +# This function is functionally equivalent to +# assertEquals. +# +# +#*/ +assertSame() +{ + assertEquals "${@:-}" +} + +#/** +# +# +# void +# +# +# +# +# assertNotSame +# string [message] +# string unexpected +# string actual +# +# +# Asserts that unexpected and +# actual are not +# equal to one another. The message is optional. +# +# +#*/ +assertNotSame() +{ + _su_message='' + if [ $# -eq 3 ]; then + _su_message=$1 + shift + fi + _su_unexpected=${1:-} + _su_actual=${2:-} + + shunit_return=${__SHUNIT_TRUE} + if [ "${_su_unexpected}" != "${_su_actual}" ]; then + _shunit_testPassed + else + failSame "${_su_message}" + shunit_return=${__SHUNIT_FALSE} + fi + + unset _su_message _su_unexpected _su_actual + return ${shunit_return} +} + +#/** +# +# +# void +# +# +# +# +# assertTrue +# string [message] +# string condition +# +# +# Asserts that a given shell test condition is true. The message is +# optional. +# Testing whether something is true or false is easy enough by using +# the assertEquals/assertNotSame functions. Shell supports much more +# complicated tests though, and a means to support them was needed. As such, +# this function tests that conditions are true or false through evaluation +# rather than just looking for a true or false. +# +# The following test will succeed: assertTrue "[ 34 -gt 23 ]" +# The folloing test will fail with a message: assertTrue "test failed" "[ -r '/non/existant/file' ]" +# +# +# +#*/ +assertTrue() +{ + _su_message='' + if [ $# -eq 2 ]; then + _su_message=$1 + shift + fi + _su_condition=${1:-} + + shunit_return=${__SHUNIT_TRUE} + + # see if condition is an integer, i.e. a return value + _su_match=`expr "${_su_condition}" : '\([0-9]*\)'` + if [ -z "${_su_condition}" ]; then + # null condition + shunit_return=${__SHUNIT_FALSE} + elif [ "${_su_condition}" = "${_su_match}" ]; then + # possible return value. treating 0 as true, and non-zero as false. + [ ${_su_condition} -ne 0 ] && shunit_return=${__SHUNIT_FALSE} + else + # (hopefully) a condition + ( eval ${_su_condition} ) >/dev/null 2>&1 + [ $? -ne 0 ] && shunit_return=${__SHUNIT_FALSE} + fi + + # record the test + if [ ${shunit_return} -eq ${__SHUNIT_TRUE} ]; then + _shunit_testPassed + else + _shunit_testFailed "${_su_message}" + fi + + unset _su_message _su_condition _su_match + return ${shunit_return} +} + +#/** +# +# +# void +# +# +# +# +# assertFalse +# string [message] +# string condition +# +# +# Asserts that a given shell test condition is false. The message is +# optional. +# Testing whether something is true or false is easy enough by using +# the assertEquals/assertNotSame functions. Shell supports much more +# complicated tests though, and a means to support them was needed. As such, +# this function tests that conditions are true or false through evaluation +# rather than just looking for a true or false. +# +# The following test will succeed: assertFalse "[ 'apples' = 'oranges' ]" +# The folloing test will fail with a message: assertFalse "test failed" "[ 1 -eq 1 -a 2 -eq 2 ]" +# +# +# +#*/ +assertFalse() +{ + _su_message='' + if [ $# -eq 2 ]; then + _su_message=$1 + shift + fi + _su_condition=${1:-} + + shunit_return=${__SHUNIT_TRUE} + + # see if condition is an integer, i.e. a return value + _su_match=`expr "${_su_condition}" : '\([0-9]*\)'` + if [ -z "${_su_condition}" ]; then + # null condition + shunit_return=${__SHUNIT_FALSE} + elif [ "${_su_condition}" = "${_su_match}" ]; then + # possible return value. treating 0 as true, and non-zero as false. + [ ${_su_condition} -eq 0 ] && shunit_return=${__SHUNIT_FALSE} + else + # (hopefully) a condition + ( eval ${_su_condition} ) >/dev/null 2>&1 + [ $? -eq 0 ] && shunit_return=${__SHUNIT_FALSE} + fi + + # record the test + if [ ${shunit_return} -eq ${__SHUNIT_TRUE} ]; then + _shunit_testPassed + else + _shunit_testFailed "${_su_message}" + fi + + unset _su_message _su_condition _su_match + return ${shunit_return} +} + +#----------------------------------------------------------------------------- +# failure functions +# + +#/** +# +# +# void +# +# +# +# +# fail +# string [message] +# +# +# Fails the test immediately, with the optional message. +# +# +#*/ +fail() +{ + _su_message=${1:-} + + _shunit_testFailed "${_su_message}" + + unset _su_message +} + +#/** +# +# +# void +# +# +# +# +# failNotEquals +# string [message] +# string unexpected +# string actual +# +# +# Fails the test if unexpected and +# actual are not +# equal to one another. The message is optional. +# +# +#*/ +failNotEquals() +{ + _su_message='' + if [ $# -eq 3 ]; then + _su_message=$1 + shift + fi + _su_unexpected=${1:-} + _su_actual=${2:-} + + _shunit_testFailed "${_su_message:+${_su_message} }expected:<${_su_unexpected}> but was:<${_su_actual}>" + + unset _su_message _su_unexpected _su_actual +} + +#/** +# +# +# void +# +# +# +# +# failSame +# string [message] +# +# +# Indicate test failure because arguments were not the same. The +# message is optional. +# +# +#*/ +failSame() +{ + _su_message=${1:-} + + _shunit_testFailed "${_su_message:+${_su_message} }expected not same" + + unset _su_message +} + +#/** +# +# +# void +# +# +# +# +# failNotSame +# string [message] +# string expected +# string actual +# +# +# Fails the test if expected and +# actual are equal to one another. The message is +# optional. +# +# +#*/ +failNotSame() +{ + failNotEquals "${@:-}" +} + +#----------------------------------------------------------------------------- +# suite functions +# + +#/** +# +# +# void +# +# +# +# +# suite +# +# +# +# This function can be optionally overridden by the user in their test +# suite. +# If this function exists, it will be called when +# shunit2 is sourced. If it does not exist, shUnit2 will +# search the parent script for all functions beginning with the word +# test, and they will be added dynamically to the test +# suite. +# +# +#*/ +# Note: see _shunit_mktempFunc() for actual implementation +# suite() { :; } + +#/** +# +# +# void +# +# +# +# +# suite_addTest +# string function +# +# +# This function adds a function name to the list of tests scheduled for +# execution as part of this test suite. This function should only be called +# from within the suite() function. +# +# +#*/ +suite_addTest() +{ + _su_func=${1:-} + + __shunit_suite="${__shunit_suite:+${__shunit_suite} }${_su_func}" + + unset _su_func +} + +#/** +# +# +# void +# +# +# +# +# oneTimeSetUp +# +# +# +# This function can be be optionally overridden by the user in their +# test suite. +# If this function exists, it will be called once before any tests are +# run. It is useful to prepare a common environment for all tests. +# +# +#*/ +# Note: see _shunit_mktempFunc() for actual implementation +# oneTimeSetUp() { :; } + +#/** +# +# +# void +# +# +# +# +# oneTimeTearDown +# +# +# +# This function can be be optionally overridden by the user in their +# test suite. +# If this function exists, it will be called once after all tests are +# completed. It is useful to clean up the environment after all tests. +# +# +#*/ +# Note: see _shunit_mktempFunc() for actual implementation +# oneTimeTearDown() { :; } + +#/** +# +# +# void +# +# +# +# +# setUp +# +# +# +# This function can be be optionally overridden by the user in their +# test suite. +# If this function exists, it will be called before each test is run. +# It is useful to reset the environment before each test. +# +# +#*/ +# Note: see _shunit_mktempFunc() for actual implementation +# setUp() { :; } + +#/** +# +# +# void +# +# +# +# +# tearDown +# +# +# +# This function can be be optionally overridden by the user in their +# test suite. +# If this function exists, it will be called after each test completes. +# It is useful to clean up the environment after each test. +# +# +#*/ +# Note: see _shunit_mktempFunc() for actual implementation +# tearDown() { :; } + +#------------------------------------------------------------------------------ +# internal shUnit2 functions +# + +_shunit_cleanup() +{ + name=$1 + + case ${name} in + EXIT) signal=0 ;; + INT) signal=2 ;; + TERM) signal=15 ;; + esac + + # do our work + rm -fr "${__shunit_tmpDir}" + + # exit for all non-EXIT signals + if [ ${name} != 'EXIT' ]; then + echo "trapped and now handling the ${name} signal" >&2 + _shunit_generateReport + # disable EXIT trap + trap 0 + # add 128 to signal and exit + exit `expr ${signal} + 128` + fi +} + +_shunit_execSuite() +{ + echo '#' + echo '# Performing tests' + echo '#' + for _su_func in ${__shunit_suite}; do + # execute the per-test setup function + setUp + + # execute the test + echo "${_su_func}" + eval ${_su_func} + + # execute the per-test tear-down function + tearDown + done + + unset _su_func +} + +_shunit_functionExists() +{ + _su__func=$1 + type ${_su__func} 2>/dev/null |grep "is a function$" >/dev/null + _su__return=$? + unset _su__func + return ${_su__return} +} + +_shunit_generateReport() +{ + _su__awkPercent='{printf("%0.0f%%", $1*100/$2)}' + if [ ${__shunit_testsTotal} -gt 0 ]; then + _su__success=`echo ${__shunit_testsPassed} ${__shunit_testsTotal} |\ + awk "${_su__awkPercent}"` + else + _su__success=0 + fi + + cat </dev/null ) && return + + # the standard mktemp didn't work. doing our own. + if [ -r '/dev/urandom' -a -x '/usr/bin/od' ]; then + _su__random=`/usr/bin/od -vAn -N4 -tx4
&2 + return ${__SHUNIT_ERROR} + } + + echo ${_su__tmpDir} + unset _su__date _su__random _su__tmpDir +} + +# this function is here to work around issues in Cygwin +_shunit_mktempFunc() +{ + for _su__func in oneTimeSetUp oneTimeTearDown setUp tearDown suite; do + _su__file="${__shunit_tmpDir}/${_su__func}" + cat <"${_su__file}" +#! /bin/sh +exit 0 +EOF + chmod +x "${_su__file}" + done + + unset _su__file +} + +_shunit_testPassed() +{ + __shunit_testsPassed=`expr ${__shunit_testsPassed} + 1` + __shunit_testsTotal=`expr ${__shunit_testsTotal} + 1` +} + +_shunit_testFailed() +{ + _su__msg=$1 + + __shunit_testsFailed=`expr ${__shunit_testsFailed} + 1` + __shunit_testsTotal=`expr ${__shunit_testsTotal} + 1` + echo "${__SHUNIT_ASSERT_MSG_PREFIX}${_su__msg}" >&2 + + unset _su__msg +} + +#------------------------------------------------------------------------------ +# main +# + +# create a temporary storage location +__shunit_tmpDir=`_shunit_mktempDir` || exit ${__SHUNIT_ERROR} + +# setup traps to clean up after ourselves +trap '_shunit_cleanup EXIT' 0 +trap '_shunit_cleanup INT' 2 +trap '_shunit_cleanup TERM' 15 + +# create phantom functions to work around issues with Cygwin +_shunit_mktempFunc +PATH="${__shunit_tmpDir}:${PATH}" + +# execute the oneTimeSetUp function (if it exists) +#_shunit_functionExists oneTimeSetUp && oneTimeSetUp +oneTimeSetUp + +# deprecated: execute the suite function defined in the parent test script +suite + +# if no suite function was defined, dynamically build a list of functions +if [ -z "${__shunit_suite}" ]; then + funcs=`grep "^[ \t]*test[A-Za-z0-9_]* *()" $0 |sed 's/[^A-Za-z0-9_]//g'` + for func in ${funcs}; do + suite_addTest ${func} + done +fi + +# execute the tests +_shunit_execSuite + +# execute the oneTimeTearDown function (if it exists) +oneTimeTearDown + +# generate report +_shunit_generateReport + +# restore the previous set of shell flags +for _shunit_shellFlag in ${__SHUNIT_SHELL_FLAGS}; do + echo ${__shunit_oldShellFlags} |grep ${_shunit_shellFlag} >/dev/null \ + || set +${_shunit_shellFlag} +done +unset _shunit_shellFlag + +#/** +# +#*/ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/test/run-test-suite b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/test/run-test-suite new file mode 100755 index 0000000..8710a36 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/test/run-test-suite @@ -0,0 +1,116 @@ +#! /bin/sh +# $Id: run-test-suite 432 2007-01-05 14:58:37Z sfsetse $ + +MY_NAME=`basename $0` +MY_PATH=`dirname $0` + +SHELLS='/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh' +for f in test[A-Z]*; do + [ -x "${f}" ] && TESTS="${TESTS:+${TESTS} }${f}" +done + +# load common unit test functions +. "${MY_PATH}/test-functions.inc" + +usage() +{ + echo "usage: ${MY_NAME} [-e key=val ...] [-s shell(s)] [-t test(s)]" +} + +# process command line flags +while getopts 'e:hs:t:' opt; do + case ${opt} in + e) + key=`expr "${OPTARG}" : '\([^=]*\)='` + val=`expr "${OPTARG}" : '[^=]*=\(.*\)'` + if [ -z "${key}" -o -z "${val}" ]; then + usage + exit 1 + fi + eval "${key}='${val}'" + export ${key} + env="${env:+${env} }${key}" + ;; + h) usage; exit 0 ;; + s) shells=${OPTARG} ;; + t) tests=${OPTARG} ;; + *) usage; exit 1 ;; + esac +done +shift `expr ${OPTIND} - 1` + +# fill shells and/or tests +shells=${shells:-${SHELLS}} +tests=${tests:-${TESTS}} + +# error checking +if [ -z "${tests}" ]; then + tf_error 'no tests found to run; exiting' + exit 1 +fi + +cat <&1` + exitVal=$? + if [ ${exitVal} -eq 2 ]; then + echo + echo "${version}" + fi + ;; + pdksh) ;; + zsh) ;; + esac + + # execute the tests + for suite in ${tests}; do + suiteName=`expr "${suite}" : 'test\(.*\)'` + echo + echo "--- Executing the '${suiteName}' test suite ---" >&2 + ( exec ${shell} ./${suite}; ) + done +done diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/test/test-functions.inc b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/test/test-functions.inc new file mode 100644 index 0000000..88764c5 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/test/test-functions.inc @@ -0,0 +1,84 @@ +# $Id: test-functions.inc 416 2007-01-04 00:50:14Z sfsetse $ +# vim:syntax=sh:sts=2 + +# +# constants +# + +# configure debugging. set the DEBUG environment variable to any +# non-empty value to enable debug output, or TRACE to enable trace +# output. +TRACE=${TRACE:+'tf_trace '} +[ -n "${TRACE}" ] && DEBUG=1 +[ -z "${TRACE}" ] && TRACE=':' + +DEBUG=${DEBUG:+'tf_debug '} +[ -z "${DEBUG}" ] && DEBUG=':' + +# +# variables +# + +tf_RANDOM=0 + +# +# functions +# + +# message functions +tf_trace() { echo "${MY_NAME}:TRACE $@" >&2; } +tf_debug() { echo "${MY_NAME}:DEBUG $@" >&2; } +tf_info() { echo "${MY_NAME}:INFO $@" >&2; } +tf_warn() { echo "${MY_NAME}:WARN $@" >&2; } +tf_error() { echo "${MY_NAME}:ERROR $@" >&2; } +tf_fatal() { echo "${MY_NAME}:FATAL $@" >&2; } + +# generate a random number +tf_generateRandom() +{ + tfgr_random=${tf_RANDOM} + + while [ "${tfgr_random}" = "${tf_RANDOM}" ]; do + if [ -n "${RANDOM:-}" ]; then + # $RANDOM works + tfgr_random=${RANDOM}${RANDOM}${RANDOM}$$ + elif [ -r '/dev/urandom' ]; then + tfgr_random=`od -vAn -N4 -tu4
+# +# Self-testing unit tests for shUnit2 asserts +# + +MSG='This is a test message' + +#----------------------------------------------------------------------------- +# suite tests +# + +commonEqualsSame() +{ + fn=$1 + + msg='same, with message' + rslt=`${fn} "${MSG}" 'x' 'x' 2>&1` + rtrn=$? + assertSame "${msg}" '' "${rslt}" + assertTrue "${msg}; failure" ${rtrn} + + msg='same' + rslt=`${fn} 'x' 'x' 2>&1` + rtrn=$? + assertSame "${msg}" '' "${rslt}" + assertTrue "${msg}; failure" ${rtrn} + + msg='not same' + rslt=`${fn} 'x' 'y' 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} + + msg='null values' + rslt=`${fn} '' '' 2>&1` + rtrn=$? + assertSame "${msg}" '' "${rslt}" + assertTrue "${msg}; failure" ${rtrn} + + msg='too few arguments' + rslt=`${fn} 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} +} + +testAssertEquals() +{ + commonEqualsSame 'assertEquals' +} + +testAssertSame() +{ + commonEqualsSame 'assertSame' +} + +testAssertNotSame() +{ + msg='not same, with message' + rslt=`assertNotSame "${MSG}" 'x' 'y' 2>&1` + rtrn=$? + assertSame "${msg}" '' "${rslt}" + assertTrue "${msg}; failure" ${rtrn} + + msg='not same' + rslt=`assertNotSame 'x' 'y' 2>&1` + rtrn=$? + assertSame "${msg}" '' "${rslt}" + assertTrue "${msg}; failure" ${rtrn} + + msg='same' + rslt=`assertNotSame 'x' 'x' 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} + + msg='null values' + rslt=`assertNotSame '' '' 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} + + msg='too few arguments' + rslt=`assertNotSame 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} +} + +testAssertNull() +{ + msg='null, with message' + rslt=`assertNull "${MSG}" '' 2>&1` + rtrn=$? + assertSame "${msg}" '' "${rslt}" + assertTrue "${msg}; failure" ${rtrn} + + msg='null' + rslt=`assertNull '' 2>&1` + rtrn=$? + assertSame "${msg}" '' "${rslt}" + assertTrue "${msg}; failure" ${rtrn} + + msg='not null' + rslt=`assertNull 'x' 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} + + msg='too few arguments' + rslt=`assertNull 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} +} + +testAssertNotNull() +{ + msg='not null, with message' + rslt=`assertNotNull "${MSG}" 'x' 2>&1` + rtrn=$? + assertSame "${msg}" '' "${rslt}" + assertTrue "${msg}; failure" ${rtrn} + + msg='not null' + rslt=`assertNotNull 'x' 2>&1` + rtrn=$? + assertSame "${msg}" '' "${rslt}" + assertTrue "${msg}; failure" ${rtrn} + + msg='null' + rslt=`assertNotNull '' 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} + + msg='too few arguments' + rslt=`assertNotNull 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} +} + +testAssertTrue() +{ + msg='true, with message' + rslt=`assertTrue "${MSG}" 0 2>&1` + rtrn=$? + assertSame "${msg}" '' "${rslt}" + assertTrue "${msg}; failure" ${rtrn} + + msg='true' + rslt=`assertTrue 0 2>&1` + rtrn=$? + assertSame "${msg}" '' "${rslt}" + assertTrue "${msg}; failure" ${rtrn} + + msg='true condition' + rslt=`assertTrue "[ 0 -eq 0 ]" 2>&1` + rtrn=$? + assertSame "${msg}" '' "${rslt}" + assertTrue "${msg}; failure" ${rtrn} + + msg='false' + rslt=`assertTrue 1 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} + + msg='false condition' + rslt=`assertTrue "[ 0 -eq 1 ]" 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} + + msg='null value' + rslt=`assertTrue '' 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} + + msg='too few arguments' + rslt=`assertTrue 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} +} + +testAssertFalse() +{ + msg='false, with message' + rslt=`assertFalse "${MSG}" 1 2>&1` + rtrn=$? + assertSame "${msg}" '' "${rslt}" + assertTrue "${msg}; failure" ${rtrn} + + msg='false' + rslt=`assertFalse 1 2>&1` + rtrn=$? + assertSame "${msg}" '' "${rslt}" + assertTrue "${msg}; failure" ${rtrn} + + msg='false condition' + rslt=`assertFalse "[ 0 -eq 1 ]" 2>&1` + rtrn=$? + assertSame "${msg}" '' "${rslt}" + assertTrue "${msg}; failure" ${rtrn} + + msg='true' + rslt=`assertFalse 0 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} + + msg='true condition' + rslt=`assertFalse "[ 0 -eq 0 ]" 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} + + msg='null value' + rslt=`assertFalse '' 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} + + msg='too few arguments' + rslt=`assertFalse 2>&1` + rtrn=$? + assertNotSame "${msg}" '' "${rslt}" + assertFalse "${msg}; failure" ${rtrn} +} + +#----------------------------------------------------------------------------- +# suite functions +# + +# load and run shUnit2 +. ./shunit2 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/test/testFailures b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/test/testFailures new file mode 100755 index 0000000..9410510 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/test/testFailures @@ -0,0 +1,89 @@ +#! /bin/sh +# $Id$ +# vim: expandtab +# author: Kate Ward +# +# Self-testing unit tests for shUnit2 failures +# + +MSG='This is a test message' + +#----------------------------------------------------------------------------- +# suite tests +# + +commonNotEqualsSame() +{ + fn=$1 + + msg='same, with message' + rslt=`${fn} "${MSG}" 'x' 'x' 2>&1` + assertNotSame "${msg}" '' "${rslt}" + + msg='same' + rslt=`${fn} 'x' 'x' 2>&1` + assertNotSame "${msg}" '' "${rslt}" + + msg='not same' + rslt=`${fn} 'x' 'y' 2>&1` + assertNotSame "${msg}" '' "${rslt}" + + msg='null values' + rslt=`${fn} '' '' 2>&1` + assertNotSame "${msg}" '' "${rslt}" + + msg='too few arguments' + rslt=`${fn} 2>&1` + assertNotSame "${msg}" '' "${rslt}" +} + +testFail() +{ + msg='with message' + rslt=`fail "${MSG}" 2>&1` + assertNotSame "${msg}" '' "${rslt}" + + msg='without message' + rslt=`fail 2>&1` + assertNotSame "${msg}" '' "${rslt}" +} + +testFailNotEquals() +{ + commonNotEqualsSame 'failNotEquals' +} + +testFailSame() +{ + msg='same, with message' + rslt=`failSame "${MSG}" 'x' 'x' 2>&1` + assertNotSame "${msg}" '' "${rslt}" + + msg='same' + rslt=`failSame 'x' 'x' 2>&1` + assertNotSame "${msg}" '' "${rslt}" + + msg='not same' + rslt=`failSame 'x' 'y' 2>&1` + assertNotSame "${msg}" '' "${rslt}" + + msg='null values' + rslt=`failSame '' '' 2>&1` + assertNotSame "${msg}" '' "${rslt}" + + msg='too few arguments' + rslt=`failSame 2>&1` + assertNotSame "${msg}" '' "${rslt}" +} + +testFailNotSame() +{ + commonNotEqualsSame 'failNotSame' +} + +#----------------------------------------------------------------------------- +# suite functions +# + +# load and run shUnit2 +. ./shunit2 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/test/testInternalFx b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/test/testInternalFx new file mode 100755 index 0000000..9409dc2 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/test/testInternalFx @@ -0,0 +1,23 @@ +#! /bin/sh +# $Id$ +# vim: expandtab +# author: Kate Ward +# +# Self-testing unit tests for shUnit2 internal functions +# + +#----------------------------------------------------------------------------- +# suite tests +# + +testGenerateReport() +{ + : +} + +#----------------------------------------------------------------------------- +# suite functions +# + +# load and run shUnit2 +. ./shunit2 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/test/testSuiteFx b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/test/testSuiteFx new file mode 100755 index 0000000..c0e6ab8 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.0/src/test/testSuiteFx @@ -0,0 +1,23 @@ +#! /bin/sh +# $Id$ +# vim: expandtab +# author: Kate Ward +# +# Self-testing unit tests for shUnit2 suite functions +# + +#----------------------------------------------------------------------------- +# suite tests +# + +testAddTest() +{ + : +} + +#----------------------------------------------------------------------------- +# suite functions +# + +# load and run shUnit2 +. ./shunit2 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/bin/gen_test_results.flags b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/bin/gen_test_results.flags new file mode 100644 index 0000000..18495de --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/bin/gen_test_results.flags @@ -0,0 +1,12 @@ +# $Id: gen_test_results.flags 145 2011-06-10 11:45:17Z kate.ward@forestent.com $ +# vim:et:ft=sh:sts=2:sw=2 +# +# Copyright 2011 Kate Ward. All Rights Reserved. +# Released under the LGPL (GNU Lesser General Public License) +# +# Author: kate.ward@forestent.com (Kate Ward) +# +# Flag definition overrides for the gen_test_results.sh script. +# + +DEFINE_string suite 'shunit2_test.sh' 'unit test suite' s diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/bin/gen_test_results.sh b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/bin/gen_test_results.sh new file mode 100755 index 0000000..3f55493 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/bin/gen_test_results.sh @@ -0,0 +1,88 @@ +#! /bin/sh +# $Id: gen_test_results.sh 187 2013-01-15 00:01:51Z kate.ward@forestent.com $ +# vim:et:ft=sh:sts=2:sw=2 +# +# Copyright 2008 Kate Ward. All Rights Reserved. +# Released under the LGPL (GNU Lesser General Public License) +# +# Author: kate.ward@forestent.com (Kate Ward) +# +# This script runs the provided unit tests and sends the output to the +# appropriate file. +# + +# treat unset variables as an error +set -u + +die() +{ + [ $# -gt 0 ] && echo "error: $@" >&2 + exit 1 +} + +BASE_DIR="`dirname $0`/.." +LIB_DIR="${BASE_DIR}/lib" + +# load libraries +. ${LIB_DIR}/shflags || die 'unable to load shflags library' +. ${LIB_DIR}/shlib || die 'unable to load shlib library' +. ${LIB_DIR}/versions || die 'unable to load versions library' + +# redefining BASE_DIR now that we have the shlib functions +BASE_DIR=`shlib_relToAbsPath "${BASE_DIR}"` +BIN_DIR="${BASE_DIR}/bin" +SRC_DIR="${BASE_DIR}/src" + +os_name=`versions_osName |sed 's/ /_/g'` +os_version=`versions_osVersion` + +# load external flags +. ${BIN_DIR}/gen_test_results.flags + +# define flags +DEFINE_boolean force false 'force overwrite' f +DEFINE_string output_dir "`pwd`" 'output dir' d +DEFINE_string output_file "${os_name}-${os_version}.txt" 'output file' o +DEFINE_boolean dry_run false "supress logging to a file" n + +main() +{ + # determine output filename + output="${FLAGS_output_dir:+${FLAGS_output_dir}/}${FLAGS_output_file}" + output=`shlib_relToAbsPath "${output}"` + + # checks + [ -n "${FLAGS_suite:-}" ] || die 'suite flag missing' + + if [ ${FLAGS_dry_run} -eq ${FLAGS_FALSE} -a -f "${output}" ]; then + if [ ${FLAGS_force} -eq ${FLAGS_TRUE} ]; then + rm -f "${output}" + else + echo "not overwriting '${output}'" >&2 + exit ${FLAGS_ERROR} + fi + fi + if [ ${FLAGS_dry_run} -eq ${FLAGS_FALSE} ]; then + touch "${output}" 2>/dev/null || die "unable to write to '${output}'" + fi + + # run tests + ( + cd "${SRC_DIR}"; + if [ ${FLAGS_dry_run} -eq ${FLAGS_FALSE} ]; then + ./${FLAGS_suite} |tee "${output}" + else + ./${FLAGS_suite} + fi + ) + + if [ ! ${FLAGS_dry_run} ]; then + echo >&2 + echo "output written to '${output}'" >&2 + fi +} + +FLAGS "$@" || exit $? +[ ${FLAGS_help} -eq ${FALSE} ] || exit +eval set -- "${FLAGS_ARGV}" +main "${@:-}" diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/bin/which b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/bin/which new file mode 100755 index 0000000..9d7cc9f --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/bin/which @@ -0,0 +1,36 @@ +#! /bin/sh +# $Id$ +# +# This is a simple implementation of the 'which' command for those OSes that +# don't have one. +# + +true; TRUE=$? +false; FALSE=$? + +showAll=${FALSE} + +# process command line flags +while getopts 'a' opt; do + case ${opt} in + a) showAll=${TRUE} + esac +done +shift `expr ${OPTIND} - 1` + +# exit if no arguments were given +[ $# -eq 0 ] && exit 1 + +command=$1 + +# search for command +out=`echo "${PATH}" |sed "s/:/\n/g" |\ +while read path; do + fullPath="${path}/${command}" + if [ -x "${fullPath}" ]; then + echo "${fullPath}" + [ ${showAll} -eq ${FALSE} ] && break + fi +done` +[ -z "${out}" ] && exit 1 +echo "${out}" diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/CHANGES-2.1.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/CHANGES-2.1.txt new file mode 100644 index 0000000..8cde2f3 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/CHANGES-2.1.txt @@ -0,0 +1,221 @@ +Changes in shUnit2 2.1.X +======================== + +Changes with 2.1.7 +------------------ + +Updated the LGPL license from http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. + + +Changes with 2.1.6 +------------------ + +Removed all references to the DocBook documentation. + +Simplified the 'src' structure. + +Fixed error message in fail() that stated wrong number of required arguments. + +Updated lib/versions. + +Fixed bug in _shunit_mktempDir() where a failure occurred when the 'od' command +was not present in /usr/bin. + +Renamed shunit_tmpDir variable to SHUNIT_TMPDIR to closer match the standard +TMPDIR variable. + +Added support for calling shunit2 as an executable, in addition to the existing +method of sourcing it in as a library. This allows users to keep tests working +despite the location of the shunit2 executable being different for each OS +distribution. + +Issue #14: Improved handling of some strange chars (e.g. single and double +quotes) in messages. + +Issue# 27: Fixed error message for assertSame(). + +Issue# 25: Added check and error message to user when phantom functions are +written to a partition mounted with noexec. + +Issue# 11: Added support for defining functions like 'function someFunction()'. + + +Changes with 2.1.5 +------------------ + +Issue# 1: Fixed bug pointed out by R Bernstein in the trap code where certain +types of exit conditions did not generate the ending report. + +Issue# 2: Added assertNotEquals() assert. + +Issue# 3: Moved check for unset variables out of shUnit2 into the unit tests. +Testing poorly written software blows up if this check is in, but it is only +interesting for shUnit2 itself. Added shunit_test_output.sh unit test for this. +Some shells still do not catch such errors properly (e.g. Bourne shell and BASH +2.x). + +Added new custom assert in test_helpers to check for output to STDOUT, and none +to STDERR. + +Replaced fatal message in the temp directory creation with a _shunit_fatal() +function call. + +Fixed test_output unit test so it works now that the 'set -u' stuff was removed +for Issue# 3. + +Flushed out the coding standards in the README.txt a bit more, and brought the +shunit2 code up to par with the documented standards. + +Issue# 4: Completely changed the reporting output to be a closer match for +JUnit and PyUnit. As a result, tests are counted separately from assertions. + +Provide public shunit_tmpDir variable that can be used by unit test scripts that +need automated and guaranteed cleanup. + +Issue# 7: Fixed duplicated printing of messages passed to asserts. + +Per code review, fixed wording of failSame() and failNotSame() messages. + +Replaced version_info.sh with versions library and made appropriate changes in +other scripts to use it. + +Added gen_test_results.sh to make releases easier. + +Fixed bugs in shlib_relToAbsPath() in shlib. + +Converted DocBook documentation to reStructuredText for easier maintenance. The +DocBook documentation is now considered obsolete, and will be removed in a +future release. + +Issue# 5: Fixed the documentation around the usage of failures. + +Issue# 9: Added unit tests and updated documentation to demonstrate the +requirement of quoting values twice when macros are used. This is due to how +shell parses arguments. + +When an invalid number of arguments is passed to a function, the invalid number +is returned to the user so they are more aware of what the cause might be. + + +Changes with 2.1.4 +------------------ + +Removed the _shunit_functionExists() function as it was dead code. + +Fixed zsh version number check in version_info. + +Fixed bug in last resort temporary directory creation. + +Fixed off-by-one in exit value for scripts caught by the trap handler. + +Added argument count error checking to all functions. + +Added mkdir_test.sh example. + +Moved src/test into src/shell to better match structure used with shFlags. + +Fixed problem where null values were not handled properly under ksh. + +Added support for outputting line numbers as part of assert messages. + +Started documenting the coding standards, and changed some variable names as a +result. + +Improved zsh version and option checks. + +Renamed the __SHUNIT_VERSION variable to SHUNIT_VERSION. + + +Changes with 2.1.3 +------------------ + +Added some explicit variable defaults, even though the variables are set, as +they sometimes behave strange when the script is canceled. + +Additional workarounds for zsh compatibility. + +shUnit2 now exits with a non-zero exit code if any of the tests failed. This was +done for automated testing frameworks. Tests that were skipped are not +considered failures, and do not affect the exit code. + +Changed detection of STDERR output in unit tests. + + +Changes with 2.1.2 +------------------ + +Unset additional variables that were missed. + +Added checks and workarounds to improve zsh compatibility. + +Added some argument count checks ``assertEquals()``, ``assertNull()``, and +``assertSame()`` + + +Changes with 2.1.1 +------------------ + +Fixed bug where ``fail()`` was not honoring skipping. + +Fixed problem with ``docs-docbook-prep`` target that prevented it from working. +(Thanks to Bryan Larsen for pointing this out.) + +Changed the test in ``assertFalse()`` so that any non-zero value registers as +false. (Credits to Bryan Larsen) + +Major fiddling to bring more in line with `JUnit `. Asserts +give better output when no message is given, and failures now just fail. + +It was pointed out that the simple 'failed' message for a failed assert was not +only insufficient, it was nonstandard (when compared to JUnit) and didn't +provide the user with an expected vs actual result. The code was revised +somewhat to bring closer into alignment with JUnit (v4.3.1 specifically) so +that it feels more "normal". (Credits to Richard Jensen) + +As part of the JUnit realignment, it was noticed that fail*() functions in +JUnit don't actually do any comparisons themselves. They only generate a +failure message. Updated the code to match. + +Added self-testing unit tests. Kinda horkey, but they did find bugs during the +JUnit realignment. + +Fixed the code for returning from asserts as the return was being called before +the unsetting of variables occurred. (Credits to Mathias Goldau) + +The assert(True|False)() functions now accept an integer value for a +conditional test. A value of '0' is considered 'true', while any non-zero value +is considered 'false'. + +All public functions now fill use default values to work properly with the '-x' +shell debugging flag. + +Fixed the method of percent calculation for the report to get achieve better +accuracy. + + +Changes with 2.1.0 (since 2.0.1) +-------------------------------- + +This release is a branch of the 2.0.1 release. + +Moving to `reStructured Text `_ for +the documentation. + +Fixed problem with ``fail()``. The failure message was not properly printed. + +Fixed the ``Makefile`` so that the DocBook XML and XSLT files would be +downloaded before parsing can continue. + +Renamed the internal ``__SHUNIT_TRUE`` and ``__SHUNIT_FALSE`` variables to +``SHUNIT_TRUE`` and ``SHUNIT_FALSE`` so that unit tests can "use" them. + +Added support for test "skipping". If skipping is turned on with the +``startSkip()`` function, ``assert`` and ``fail`` functions will return +immediately, and the skip will be recorded. + +The report output format was changed to include the percentage for each test +result, rather than just those successful. + + +.. $Revision$ +.. vim:fileencoding=latin1:ft=text:spell:tw=80 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/README.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/README.txt new file mode 100644 index 0000000..0e71fa2 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/README.txt @@ -0,0 +1,212 @@ +==================== +shUnit2 2.1.x README +==================== + +code.google.com +=============== + +This project is stored on code.google.com as http://code.google.com/p/shunit2/. +All releases as of 2.1.4 and full source are available there. Documentation is +included as part of the source and each release. Source code is stored in +Subversion and can be accessed using the following information. + +Browse the code in a web browser: + +- http://code.google.com/p/shunit2/source/browse +- svn > trunk > source > 2.1 + +Check out the code locally :: + + $ svn checkout http://shunit2.googlecode.com/svn/trunk/ shflags-read-only + + +SourceForge +=========== + +DEPRECATED + +This project is stored on SourceForge as http://sf.net/projects/shunit2. The +source code is stored in Subversion and can be accessed using the following +information. + +Check out the code locally :: + + $ svn co https://shunit2.svn.sourceforge.net/svnroot/shunit2/trunk/source/2.1 shunit2 + +Browse the code in a web browser: + +- http://shunit2.svn.sourceforge.net/viewvc/shunit2/trunk/source/2.1/ +- http://shunit2.svn.sourceforge.net/svnroot/shunit2/trunk/source/2.1/ + + +Making a release +================ + +For these steps, it is assumed we are working with release 2.0.0. + +Steps: + +- write release notes +- update version +- finish changelog +- check all the code in +- tag the release +- export the release +- create tarball +- md5sum the tarball and sign with gpg +- update website +- post to SourceForge and Freshmeat + +Write Release Notes +------------------- + +This should be pretty self explanatory. Use one of the release notes from a +previous release as an example. + +The versions of the various platforms and shells are included when the +master unit test script is run, or when ``bin/gen_test_results.sh`` is +used. To determine the versions of the installed shells by hand, use the +``lib/versions`` script. + +Alternatively, do the following: + ++-------+---------+-----------------------------------------------------------+ +| Shell | OS | Notes | ++=======+=========+===========================================================+ +| bash | | ``$ bash --version`` | ++-------+---------+-----------------------------------------------------------+ +| dash | Linux | ``$ dpkg -l |grep dash`` | ++-------+---------+-----------------------------------------------------------+ +| ksh | | ``$ ksh --version`` | +| | | -or- | +| | | ``$ echo 'echo $KSH_VERSION' |ksh`` | +| +---------+-----------------------------------------------------------+ +| | Cygwin | see pdksh | +| +---------+-----------------------------------------------------------+ +| | Solaris | ``$ strings /usr/bin/ksh |grep 'Version'`` | ++-------+---------+-----------------------------------------------------------+ +| pdksh | | ``$ strings /bin/pdksh |grep 'PD KSH'`` | +| +---------+-----------------------------------------------------------+ +| | Cygwin | look in the downloaded Cygwin directory | ++-------+---------+-----------------------------------------------------------+ +| sh | Solaris | not possible | ++-------+---------+-----------------------------------------------------------+ +| zsh | | ``$ zsh --version`` | ++-------+---------+-----------------------------------------------------------+ + +Update Version +-------------- + +Edit ``src/shell/shunit2`` and change the version number in the comment, as well +as in the ``SHUNIT_VERSION`` variable. + +Finish Documentation +-------------------- + +Make sure that any remaining changes get put into the ``CHANGES-X.X.txt`` file. + +Finish writing the ``RELEASE_NOTES-X.X.X.txt``. If necessary, run it +through the **fmt** command to make it pretty (hopefully it is already). :: + + $ fmt -w 80 RELEASE_NOTES-2.0.0.txt >RELEASE_NOTES-2.0.0.txt.new + $ mv RELEASE_NOTES-2.0.0.txt.new RELEASE_NOTES-2.0.0.txt + +We want to have an up-to-date version of the documentation in the release, so +we'd better build it. :: + + $ pwd + .../shunit2/source/2.1 + $ cd doc + $ RST2HTML_OPTS='--stylesheet-path=rst2html.css' + $ rst2html ${RST2HTML_OPTS} shunit2.txt >shunit2.html + +Check In All the Code +--------------------- + +This step is pretty self-explanatory :: + + $ pwd + .../shunit2/source/2.0 + $ svn ci -m "finalizing release" + +Tag the Release +--------------- +:: + + $ pwd + .../shunit2/source + $ ls + 2.0 2.1 + $ svn cp -m "Release 2.0.0" 2.0 https://shunit2.googlecode.com/svn/tags/source/2.0.0 + +Export the Release +------------------ +:: + + $ pwd + .../shunit2/builds + $ svn export https://shunit2.googlecode.com/svn/tags/source/2.0.0 shunit2-2.0.0 + +Create Tarball +-------------- +:: + + $ tar cfz ../releases/shunit2-2.0.0.tgz shunit2-2.0.0 + +Sign the Tarball with gpg +------------------------- +:: + + $ cd ../releases + $ gpg --default-key kate.ward@forestent.com --detach-sign shunit2-2.0.0.tgz + +Update Website +-------------- + +Again, pretty self-explanatory. Make sure to copy the GPG signature file. Once +done, make sure to tag the website so we can go back in time if needed. :: + + $ pwd + .../shunit2 + $ ls + source website + $ svn cp -m "Release 2.0.0" \ + website https://shunit2.googlecode.com/svn/tags/website/20060916 + +Now, update the website. It too is held in Subversion, so **ssh** into the web +server and use ``svn up`` to grab the latest version. + +Post to code.google.com and Freshmeat +------------------------------------- + +- http://code.google.com/p/shunit2/ +- http://freshmeat.net/ + + +Related Documentation +===================== + +Docbook: + http://www.docbook.org/ + +Docbook XML + docbook-xml-4.4.zip: + http://www.docbook.org/xml/4.4/docbook-xml-4.4.zip + http://www.oasis-open.org/docbook/xml/4.4/docbook-xml-4.4.zip + docbook-xml-4.5.zip: + http://www.docbook.org/xml/4.5/docbook-xml-4.5.zip +Docbook XSL + docbook-xsl-1.71.0.tar.bz2: + http://prdownloads.sourceforge.net/docbook/docbook-xsl-1.71.0.tar.bz2?download + docbook-xsl-1.71.1.tar.bz2: + http://downloads.sourceforge.net/docbook/docbook-xsl-1.71.1.tar.bz2?use_mirror=puzzle +JUnit: + http://www.junit.org/ +reStructuredText: + http://docutils.sourceforge.net/docs/user/rst/quickstart.html + +.. generate HTML using rst2html from Docutils of +.. http://docutils.sourceforge.net/ +.. +.. vim:fileencoding=latin1:ft=rst:spell:tw=80 +.. $Revision$ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.0.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.0.txt new file mode 100644 index 0000000..c99f746 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.0.txt @@ -0,0 +1,104 @@ +Release Notes for shUnit2 2.1.0 +=============================== + +This release was branched from shUnit2 2.0.1. It mostly adds new functionality, +but there are couple of bugs fixed from the previous release. + +See the ``CHANGES-2.1.rst`` file for a full list of changes. + + +Tested Platforms +---------------- + +This list of platforms comes from the latest version of log4sh as shUnit2 is +used in the testing of log4sh on each of these platforms. + +Cygwin + +- bash 3.2.9(10) +- pdksh 5.2.14 + +Linux + +- bash 3.1.17(1), 3.2.10(1) +- dash 0.5.3 +- ksh 1993-12-28 +- pdksh 5.2.14 +- zsh 4.3.2 (does not work) + +Mac OS X 10.4.8 (Darwin 8.8) + +- bash 2.05b.0(1) +- ksh 1993-12-28 + +Solaris 8 U3 (x86) + +- /bin/sh +- bash 2.03.0(1) +- ksh M-11/16/88i + +Solaris 10 U2 (sparc) + +- /bin/sh +- bash 3.00.16(1) +- ksh M-11/16/88i + +Solaris 10 U2 (x86) + +- /bin/sh +- bash 3.00.16(1) +- ksh M-11/16/88i + + +New Features +------------ + +Test skipping + + Support added for test "skipping". A skip mode can be enabled so that + subsequent ``assert`` and ``fail`` functions that are called will be recorded + as "skipped" rather than as "passed" or "failed". This functionality can be + used such that when a set of tests makes sense on one platform but not on + another, they can be effectively disabled without altering the total number + of tests. + + One example might be when something is supported under ``bash``, but not + under a standard Bourne shell. + + New functions: ``startSkipping()``, ``endSkipping``, ``isSkipping`` + + +Changes and Enhancements +------------------------ + +Moving to the use of `reStructured Text +`_ for documentation. It is easy to +read and edit in textual form, but converts nicely to HTML. + +The report format has changed. Rather than including a simple "success" +percentage at the end, a percentage is given for each type of test. + + +Bug Fixes +--------- + +The ``fail()`` function did not output the optional failure message. + +Fixed the ``Makefile`` so that the DocBook XML and XSLT files would be +downloaded before documentation parsing will continue. + + +Deprecated Features +------------------- + +None. + + +Known Bugs and Issues +--------------------- + +None. + + +.. $Revision$ +.. vim:fileencoding=latin1:spell:syntax=rst:textwidth=80 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.1.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.1.txt new file mode 100644 index 0000000..4c61005 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.1.txt @@ -0,0 +1,88 @@ +Release Notes for shUnit2 2.1.1 +=============================== + +This is mainly a bug fix release, but it also incorporates a realignment with +the JUnit 4 code. Asserts now provide better failure messages, and the failure +functions no longer perform tests. + +See the ``CHANGES-2.1.txt`` file for a full list of changes. + + +Tested Platforms +---------------- + +This list of platforms comes from the latest version of log4sh as shUnit2 is +used in the testing of log4sh on each of these platforms. + +Cygwin + +- bash 3.2.15(13) +- pdksh 5.2.14 + +Linux + +- bash 3.1.17(1), 3.2.10(1) +- dash 0.5.3 +- ksh 1993-12-28 +- pdksh 5.2.14 +- zsh 4.3.2 (does not work) + +Mac OS X 10.4.9 (Darwin 8.9.1) + +- bash 2.05b.0(1) +- ksh 1993-12-28 + +Solaris 8 U3 (x86) + +- /bin/sh +- bash 2.03.0(1) +- ksh M-11/16/88i + +Solaris 10 U2 (sparc, x86) + +- /bin/sh +- bash 3.00.16(1) +- ksh M-11/16/88i + + +New Features +------------ + +None. + + +Changes and Enhancements +------------------------ + +The internal test in ``assertFalse()`` now accepts any non-zero value as false. + +The ``assertTrue()`` and ``assertFalse()`` functions now accept an integer value +for a conditional test. A value of '0' is considered 'true', while any non-zero +value is considered 'false'. + +Self-testing unit tests were added. + + +Bug Fixes +--------- + +The ``fail()`` assert now honors skipping. + +The ``docs-docbook-prep`` target now works properly. + +All asserts now properly unset their variables. + + +Deprecated Features +------------------- + +None. + + +Known Bugs and Issues +--------------------- + +Functions do not properly test for an invalid number of arguments. + + +.. vim:fileencoding=latin1:ft=rst:spell:textwidth=80 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.2.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.2.txt new file mode 100644 index 0000000..5492984 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.2.txt @@ -0,0 +1,83 @@ +Release Notes for shUnit2 2.1.2 +=============================== + +This release adds initial support for the zsh shell. Due to some differences +with this shell as compared with others, some special checks have been added, +and there are some extra requirements necessary when this shell is to be used. + +To use zsh with shUnit2, the following two requirements must be met: +* The ``shwordsplit`` option must be set. +* The ``function_argzero`` option must be unset. + +Please read the Shell Errata section of the documentation for guidance on how +to meet these requirements. + + +See the ``CHANGES-2.1.txt`` file for a full list of changes. + + +Tested Platforms +---------------- + +This list of platforms comes from the latest version of log4sh as shUnit2 is +used in the testing of log4sh on each of these platforms. + +Linux + +- bash 3.1.17(1), 3.2.25(1) +- dash 0.5.4 +- ksh 1993-12-28 +- pdksh 5.2.14 +- zsh 4.2.5, 4.3.4 + +Mac OS X 10.4.11 (Darwin 8.11.1) + +- bash 2.05b.0(1) +- ksh 1993-12-28 +- zsh 4.2.3 + +Solaris 10 U3 (x86) + +- /bin/sh +- bash 3.00.16(1) +- ksh M-11/16/88i +- zsh 4.2.1 + + +New Features +------------ + +Support for the zsh shell. + + +Changes and Enhancements +------------------------ + +Added some argument count checks. + + +Bug Fixes +--------- + +None. + + +Deprecated Features +------------------- + +None. + + +Known Bugs and Issues +--------------------- + +Functions do not properly test for an invalid number of arguments. + +ksh and pdksh do not pass null arguments (i.e. empty strings as '') properly, +and as such checks do not work properly. + +zsh requires the ``shwordsplit`` option to be set, and the ``function_argzero`` +option to be unset for proper operation. + + +.. vim:fileencoding=latin1:ft=rst:spell:textwidth=80 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.3.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.3.txt new file mode 100644 index 0000000..7d1c9f6 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.3.txt @@ -0,0 +1,84 @@ +Release Notes for shUnit2 2.1.3 +=============================== + +This release is minor feature release. It improves support for zsh (although it +still isn't what it could be) and adds automated testing framework support by +returning a non-zero exit when tests fail. + +To use zsh with shUnit2, the following two requirements must be met: +* The ``shwordsplit`` option must be set. +* The ``function_argzero`` option must be unset. + +Please read the Shell Errata section of the documentation for guidance on how +to meet these requirements. + +See the ``CHANGES-2.1.txt`` file for a full list of changes. + + +Tested Platforms +---------------- + +Cygwin + +- bash 3.2.33(18) +- pdksh 5.2.14 + +Linux + +- bash 3.2.33(1) +- dash 0.5.4 +- ksh 1993-12-28 +- pdksh 5.2.14 +- zsh 4.3.4 + +Mac OS X 10.5.2 (Darwin 9.2.2) + +- bash 3.2.17(1) +- ksh 1993-12-28 +- zsh 4.3.4 + +Solaris 11 x86 (Nevada 77) + +- /bin/sh +- bash 3.2.25(1) +- ksh M-11/16/88i +- zsh 4.3.4 + + +New Features +------------ + +None. + + +Changes and Enhancements +------------------------ + +Support for automated testing frameworks. + + +Bug Fixes +--------- + +Fixed some issues with zsh support. + + +Deprecated Features +------------------- + +None. + + +Known Bugs and Issues +--------------------- + +Functions do not properly test for an invalid number of arguments. + +ksh and pdksh do not pass null arguments (i.e. empty strings as '') properly, +and as such checks do not work properly. + +zsh requires the ``shwordsplit`` option to be set, and the ``function_argzero`` +option to be unset for proper operation. + + +.. vim:fileencoding=latin1:ft=rst:spell:textwidth=80 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.4.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.4.txt new file mode 100644 index 0000000..007b5c3 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.4.txt @@ -0,0 +1,100 @@ +Release Notes for shUnit2 2.1.4 +=============================== + +This release contains lots of bug fixes and changes. Mostly, it fixes zsh +support in zsh 3.0, and the handling of null values in ksh. + +To use zsh with shUnit2, the following requirement must be met: + +- The ``shwordsplit`` option must be set. + +Please read the Shell Errata section of the documentation for guidance on how +to meet these requirements. + +See the ``CHANGES-2.1.txt`` file for a full list of changes. + + +Tested Platforms +---------------- + +Cygwin + +- bash 3.2.39(19) +- pdksh 5.2.14 +- zsh 4.3.4 + +Linux (Ubuntu Dapper 6.06) + +- bash 3.1.17(1) +- pdksh 5.2.14 +- zsh 4.2.5 + +Linux (Ubuntu Hardy 8.04) + +- bash 3.2.39(1) +- dash 0.5.4 +- ksh 1993-12-28 +- pdksh 5.2.14 +- zsh 4.3.4 + +Mac OS X 10.5.4 (Darwin 9.4.0) + +- bash 3.2.17(1) +- ksh 1993-12-28 +- zsh 4.3.4 + +Solaris 9 U6 x86 + +- /bin/sh +- bash 2.05.0(1) +- ksh M-11/16/88i +- zsh 3.0.8 + +Solaris 11 x86 (Nevada 77) + +- /bin/sh +- bash 3.2.25(1) +- ksh M-11/16/88i +- zsh 4.3.4 + + +New Features +------------ + +Support added to output assert source line number as part of assert messages. + + +Changes and Enhancements +------------------------ + +Support for automated testing frameworks. + +Added argument count error checking to all functions. + + +Bug Fixes +--------- + +Fixed some issues with ksh and zsh support. + +Fixed off-by-one of exit value in trap handler. + +Fixed handling of null values under ksh. + +Fixed bug in last resort temporary directory creation. + + +Deprecated Features +------------------- + +None. + + +Known Bugs and Issues +--------------------- + +zsh requires the ``shwordsplit`` option to be set. + +Line numbers in assert messages do not work properly with Bash 2.x. + +.. vim:fileencoding=latin1:ft=rst:spell:tw=80 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.5.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.5.txt new file mode 100644 index 0000000..d9f26ce --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.5.txt @@ -0,0 +1,128 @@ +Release Notes for shUnit2 2.1.5 +=============================== + +This release contains several bug fixes and changes. Additionally, it includes +a rewrite of the test output to better match JUnit and PyUnit. + +This version also includes a slightly expanded set of coding standards by which +shUnit2 is coded. It should help anyone reading the code to better understand +it. + + + +Please read the Shell Errata section of the documentation for guidance on how +to meet these requirements. + +See the ``CHANGES-2.1.txt`` file for a full list of changes. + + +Tested Platforms +---------------- + +Cygwin + +- bash 3.2.39(20) +- ksh (sym-link to pdksh) +- pdksh 5.2.14 +- zsh 4.3.4 + +Linux (Ubuntu Dapper 6.06) + +- bash 3.1.17(1) +- ksh M-1993-12-28 +- pdksh 5.2.14-99/07/13.2 +- zsh 4.2.5 + +Linux (Ubuntu Hardy 8.04) + +- bash 3.2.39(1) +- dash 0.5.4 +- ksh M-1993-12-28 +- pdksh 5.2.14-99/07/13.2 +- zsh 4.3.4 + +Mac OS X 10.5.4 (Darwin 9.4.0) + +- bash 3.2.17(1) +- ksh M-1993-12-28 +- zsh 4.3.4 + +Solaris 9 U6 x86 + +- /bin/sh +- bash 2.05.0(1) +- ksh M-11/16/88i +- zsh 3.0.8 + +Solaris 11 x86 (Nevada 77) + +- /bin/sh +- bash 3.2.25(1) +- ksh M-11/16/88i +- zsh 4.3.4 + + +New Features +------------ + +Support added for output assert source line number as part of assert messages. + +Issue #2: Added assertNotEquals() assert. + +Provided a public ``shunit_tmpDir`` variable that can be used by unit test +scripts that need automated and guaranteed cleanup. + + +Changes and Enhancements +------------------------ + +Issue #3: Removed the check for unset variables as shUnit2 should not expect +scripts being tested to be clean. + +Issue #4: Rewrote the test summary. It is now greatly simplified and much more +script friendly. + +Issue #5: Fixed the documentation around the usage of failures. + +Issue #9: Added unit tests and improved documentation around the use of macros. + +Code updated to meet documented coding standards. + +Improved code reuse of ``_shunit_exit()`` and ``_shunit_fatal()`` functions. + +All output except shUnit2 error messages now goes to STDOUT. + +Converted DocBook documentation to reStructuredText for easier maintenance. + + +Bug Fixes +--------- + +Issue #1: Fixed bug in rap code where certain types of exit conditions did not +generate the ending report. + +Issue #7: Fixed duplicated printing of messages passed to asserts. + +Fixed bugs in ``shlib_relToAbsPath()`` in ``shlib``. + + +Deprecated Features +------------------- + +None. + + +Known Bugs and Issues +--------------------- + +Zsh requires the ``shwordsplit`` option to be set. See the documentation for +examples of how to do this. + +Line numbers in assert messages do not work properly with BASH 2.x. + +The Bourne shell of Solaris, BASH 2.x, and Zsh 3.0.x do not properly catch the +SIGTERM signal. As such, shell interpreter failures due to such things as +unbound variables cannot be caught. (See ``shunit_test_misc.sh``) + + +.. vim:fileencoding=latin1:ft=rst:spell:tw=80 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.6.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.6.txt new file mode 100644 index 0000000..50087fe --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/RELEASE_NOTES-2.1.6.txt @@ -0,0 +1,112 @@ +Release Notes for shUnit2 2.1.6 +=============================== + +This release contains bug fixes and changes. It is also the first release to +support running shunit2 as a standalone program. + +Please read the Shell Errata section of the documentation for guidance on how +to meet these requirements. + +See the ``CHANGES-2.1.txt`` file for a full list of changes. + +New Features +------------ + +Support for running shUnit2 as a standalone program. This makes it possible for +users to execute their unit tests in a manner that is not dependent on the +location an OS distribution maintainer chose to place shUnit2 in the file +system. + +Added support for functions defined like 'function someFunction()'. + +Changes and Enhancements +------------------------ + +Renamed the public ``shunit_tmpDir`` variable to ``SHUNIT_TMPDIR`` to be more +consistent with the ``TMPDIR`` variable. + +Bug Fixes +--------- + +Fixed issue where shunit2 would fail on some distributions when creating a +temporary directory because the **od** command was not present. + +Deprecated Features +------------------- + +None. + +Known Bugs and Issues +--------------------- + +Zsh requires the ``shwordsplit`` option to be set. See the documentation for +examples of how to do this. + +Line numbers in assert messages do not work properly with BASH 2.x. + +The Bourne shell of Solaris, BASH 2.x, and Zsh 3.0.x do not properly catch the +SIGTERM signal. As such, shell interpreter failures due to such things as +unbound variables cannot be caught. (See ``shunit_test_misc.sh``) + +Tested Platforms +---------------- + +Cygwin 1.7.9 (Windows XP SP2) + +- bash 4.1.10(4) +- dash 0.5.6.1 +- ksh (sym-link to pdksh) +- pdksh 5.2.14 +- zsh 4.3.11 + +Linux (Ubuntu Dapper 6.06.2 LTS) + +- bash 3.1.17(1) +- dash 0.5.3 +- ksh (sym-link to pdksh) +- pdksh 5.2.14-99/07/13.2 +- zsh 4.2.5 + +Linux (Ubuntu Hardy 8.04.4 LTS) + +- bash 3.2.39(1) +- dash 0.5.4 +- ksh M-1993-12-28 +- pdksh 5.2.14-99/07/13.2 +- zsh 4.3.4 + +Linux (Ubuntu Lucid 10.04.2 LTS) + +- bash 4.1.5(1) +- dash 0.5.5.1 +- ksh JM-93t+-2009-05-01 +- pdksh 5.2.14-99/07/13.2 +- zsh 4.3.10 + +Mac OS X 10.6.7 + +- bash 3.2.48(1) +- ksh M-1993-12-28 +- zsh 4.3.9 + +Solaris 8 U7 x86 + +- /bin/sh +- bash 2.03.0(1) +- ksh M-11/16/88i +- zsh 3.0.6 + +Solaris 9 U6 x86 + +- /bin/sh +- bash 2.05.0(1) +- ksh M-11/16/88i +- zsh 3.0.8 + +OpenSolaris 2009.06(snv_111b) x86 + +- /bin/sh +- bash 3.2.25(1) +- ksh 2008-11-04 + +.. vim:fileencoding=latin1:ft=rst:spell:tw=80 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/TODO.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/TODO.txt new file mode 100644 index 0000000..cecc17d --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/TODO.txt @@ -0,0 +1,13 @@ +Make it possible to execute a single test by passing the name of the test on +the command line + +Add support for '--randomize-order' so that the test order is randomized to +check for dependencies (which shouldn't be there) between tests. + +--debug option to display point in source code (line number and such) where the +problem showed up. + +assertTrue() just gives 'ASSERT:', nothing else :-(. others too? +upd: assertNull() will give message passed, but nothing else useful :-( + +$Revision$ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/coding_standards.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/coding_standards.txt new file mode 100644 index 0000000..e5dee4f --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/coding_standards.txt @@ -0,0 +1,74 @@ +Coding Standards +================ + +Variable and Function Names +--------------------------- + +All shUnit2 specific constants, variables, and functions will be prefixed +appropriately with 'shunit'. This is to distinguish usage in the shUnit2 code +from users own scripts so that the shell name space remains predictable to +users. The exceptions here are the standard ``assertEquals``, etc. functions. + +All non-builtin constants and variables will be surrouned with squiggle +brackets, e.g. '${shunit_someVariable}' to improve code readability. + +Due to some shells not supporting local variables in functions, care in the +naming and use of variables, both public and private, is very important. +Accidental overriding of the variables can occur easily if care is not taken as +all variables are technically global variables in some shells. + ++----------------------------------+---------------------------+ +| *type* | *sample* | ++==================================+===========================+ +| global public constant | ``SHUNIT_TRUE`` | ++----------------------------------+---------------------------+ +| global private constant | ``__SHUNIT_SHELL_FLAGS`` | ++----------------------------------+---------------------------+ +| global public variable | not used | ++----------------------------------+---------------------------+ +| global private variable | ``__shunit_someVariable`` | ++----------------------------------+---------------------------+ +| global macro | ``_SHUNIT_SOME_MACRO_`` | ++----------------------------------+---------------------------+ +| public function | ``assertEquals`` | ++----------------------------------+---------------------------+ +| public function, local variable | ``shunit_someVariable_`` | ++----------------------------------+---------------------------+ +| private function | ``_shunit_someFunction`` | ++----------------------------------+---------------------------+ +| private function, local variable | ``_shunit_someVariable_`` | ++----------------------------------+---------------------------+ + +Where it makes sense, variables can have the first letter of the second and +later words capitalized. For example, the local variable name for the total +number of test cases seen might be ``shunit_totalTestsSeen_``. + +Local Variable Cleanup +---------------------- + +As many shells do not support local variables, no support for cleanup of +variables is present either. As such, all variables local to a function must be +cleared up with the ``unset`` command at the end of each function. + +Indentation +----------- + +Code block indentation is two (2) spaces, and tabs may not be used. :: + + if [ -z 'some string' ]; then + someFunction + fi + +Lines of code should be no longer than 80 characters unless absolutely +necessary. When lines are wrapped using the backslash character '\', subsequent +lines should be indented with four (4) spaces so as to differentiate from the +standard spacing of two characters. Tabs may *not* be used. :: + + for x in some set of very long set of arguments that make for a very long \ + that extends much too long for one line + do + echo ${x} + done + +.. vim:fileencoding=latin1:ft=rst:spell:tw=80 +.. $Revision$ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/contributors.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/contributors.txt new file mode 100644 index 0000000..7623c66 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/contributors.txt @@ -0,0 +1,14 @@ +The original author of shunit2 is Kate Ward. The following people have +contributed in some way or another to shunit2. + +Bryan Larsen +Kevin Van Horn +Maciej Bliziński +Mario Sparada +Mathias Goldau +Richard Jensen +Rob Holland +Rocky Bernstein +wood4321 (of code.google.com) + +$Revision$ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/design_doc.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/design_doc.txt new file mode 100644 index 0000000..24d41ff --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/design_doc.txt @@ -0,0 +1,34 @@ +Design Doc for shUnit + +shUnit is based upon JUnit. The initial ideas for the script came from the book +"Pragmatic Unit Testing - In Java with JUnit" by Andrew Hunt and David Thomas. + +The script was written to perform unit testing for log4sh. log4sh had grown +enough that it was becoming difficult to easily test and and verify that the +tests passed for the many different operating systems on which it was being +used. + +The functions in shUnit are meant to match those in JUnit as much as possible +where shell allows. In the initial version, there will be no concept of +exceptions (as normal POSIX shell has no concept of them) but attempts to trap +problems will be done. + +Programatic Standards: + +* SHUNIT_TRUE - public global constant +* __SHUNIT_SHELL_FLAGS - private global constant +* __shunit_oldShellFlags - private global variable + +* assertEquals - public unit test function +* shunit_publicFunc - public shUnit function; can be called from parent unit + test script +* _shunit_privateFunc - private shUnit function; should not be called from + parent script. meant for internal use by shUnit + +* _su_myVar - variable inside a public function. prefixing with '_su_' to + reduce the chances that a variable outside of shUnit will be overridden. +* _su__myVar - variable inside a private function. prefixing with '_su__' to + reduce the chances that a variable in a shUnit public function, or a variable + outside of shUnit will be overridden. + +$Revision$ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/lgpl-2.1.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/lgpl-2.1.txt new file mode 100644 index 0000000..4362b49 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/lgpl-2.1.txt @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/rst2html.css b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/rst2html.css new file mode 100644 index 0000000..01983a5 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/rst2html.css @@ -0,0 +1,292 @@ +/* +:Author: David Goodger +:Contact: goodger@users.sourceforge.net +:Date: $Date: 2007-04-11 11:48:16 +0100 (Wed, 11 Apr 2007) $ +:Revision: $Revision: 2791 $ +:Copyright: This stylesheet has been placed in the public domain. +:Modified by: Kate Ward + +Default cascading style sheet for the HTML output of Docutils. + +See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to +customize this style sheet. +*/ + +/* used to remove borders from tables and images */ +.borderless, table.borderless td, table.borderless th { + border: 0 } + +table.borderless td, table.borderless th { + /* Override padding for "table.docutils td" with "! important". + The right padding separates the table cells. */ + padding: 0 0.5em 0 0 ! important } + +.first { + /* Override more specific margin styles with "! important". */ + margin-top: 0 ! important } + +.last, .with-subtitle { + margin-bottom: 0 ! important } + +.hidden { + display: none } + +a.toc-backref { + text-decoration: none ; + color: black } + +blockquote.epigraph { + margin: 2em 5em ; } + +dl.docutils dd { + margin-bottom: 0.5em } + +/* Uncomment (and remove this text!) to get bold-faced definition list terms +dl.docutils dt { + font-weight: bold } +*/ + +div.abstract { + margin: 2em 5em } + +div.abstract p.topic-title { + font-weight: bold ; + text-align: center } + +div.admonition, div.attention, div.caution, div.danger, div.error, +div.hint, div.important, div.note, div.tip, div.warning { + margin: 2em ; + border: medium outset ; + padding: 1em } + +div.admonition p.admonition-title, div.hint p.admonition-title, +div.important p.admonition-title, div.note p.admonition-title, +div.tip p.admonition-title { + font-weight: bold ; + font-family: sans-serif } + +div.attention p.admonition-title, div.caution p.admonition-title, +div.danger p.admonition-title, div.error p.admonition-title, +div.warning p.admonition-title { + color: red ; + font-weight: bold ; + font-family: sans-serif } + +/* Uncomment (and remove this text!) to get reduced vertical space in + compound paragraphs. +div.compound .compound-first, div.compound .compound-middle { + margin-bottom: 0.5em } + +div.compound .compound-last, div.compound .compound-middle { + margin-top: 0.5em } +*/ + +div.dedication { + margin: 2em 5em ; + text-align: center ; + font-style: italic } + +div.dedication p.topic-title { + font-weight: bold ; + font-style: normal } + +div.figure { + margin-left: 2em ; + margin-right: 2em } + +div.footer, div.header { + clear: both; + font-size: smaller } + +div.line-block { + display: block ; + margin-top: 1em ; + margin-bottom: 1em } + +div.line-block div.line-block { + margin-top: 0 ; + margin-bottom: 0 ; + margin-left: 1.5em } + +div.sidebar { + margin-left: 1em ; + border: medium outset ; + padding: 1em ; + background-color: #ffffee ; + width: 40% ; + float: right ; + clear: right } + +div.sidebar p.rubric { + font-family: sans-serif ; + font-size: medium } + +div.system-messages { + margin: 5em } + +div.system-messages h1 { + color: red } + +div.system-message { + border: medium outset ; + padding: 1em } + +div.system-message p.system-message-title { + color: red ; + font-weight: bold } + +div.topic { + margin: 2em } + +h1.section-subtitle, h2.section-subtitle, h3.section-subtitle, +h4.section-subtitle, h5.section-subtitle, h6.section-subtitle { + margin-top: 0.4em } + +h1.title { + text-align: center } + +h2.subtitle { + text-align: center } + +hr.docutils { + width: 75% } + +img.align-left { + clear: left } + +img.align-right { + clear: right } + +ol.simple, ul.simple { + margin-bottom: 1em } + +ol.arabic { + list-style: decimal } + +ol.loweralpha { + list-style: lower-alpha } + +ol.upperalpha { + list-style: upper-alpha } + +ol.lowerroman { + list-style: lower-roman } + +ol.upperroman { + list-style: upper-roman } + +p.attribution { + text-align: right ; + margin-left: 50% } + +p.caption { + font-style: italic } + +p.credits { + font-style: italic ; + font-size: smaller } + +p.label { + white-space: nowrap } + +p.rubric { + font-weight: bold ; + font-size: larger ; + color: maroon ; + text-align: center } + +p.sidebar-title { + font-family: sans-serif ; + font-weight: bold ; + font-size: larger } + +p.sidebar-subtitle { + font-family: sans-serif ; + font-weight: bold } + +p.topic-title { + font-weight: bold } + +pre.address { + margin-bottom: 0 ; + margin-top: 0 ; + font-family: serif ; + font-size: 100% } + +pre.literal-block, pre.doctest-block { + margin-left: 2em ; + margin-right: 2em ; + background-color: #eeeeee } + +span.classifier { + font-family: sans-serif ; + font-style: oblique } + +span.classifier-delimiter { + font-family: sans-serif ; + font-weight: bold } + +span.interpreted { + font-family: sans-serif } + +span.option { + white-space: nowrap } + +span.pre { + white-space: pre } + +span.problematic { + color: red } + +span.section-subtitle { + /* font-size relative to parent (h1..h6 element) */ + font-size: 80% } + +table.citation { + border-left: solid 1px gray; + margin-left: 1px } + +table.docinfo { + margin: 2em 4em } + +/* +table.docutils { + margin-top: 0.5em ; + margin-bottom: 0.5em } +*/ + +table.footnote { + border-left: solid 1px black; + margin-left: 1px ; + font-size: 80% } + } + +table.docutils td, table.docutils th, +table.docinfo td, table.docinfo th { + padding-left: 0.5em ; + padding-right: 0.5em ; + vertical-align: top } + +table.docutils th.field-name, table.docinfo th.docinfo-name { + font-weight: bold ; + text-align: left ; + white-space: nowrap ; + padding-left: 0 } + +h1 tt.docutils, h2 tt.docutils, h3 tt.docutils, +h4 tt.docutils, h5 tt.docutils, h6 tt.docutils { + font-size: 100% } + +/* +tt.docutils { + background-color: #eeeeee } +*/ + +ul.auto-toc { + list-style-type: none } + +/* customizations by kward */ + +h1 { font-size: 133%; border-top:1px solid #CCCCFF; } +h1.title { font-size: 150%; border-top:0px; padding-top: 1em; } +/* div.document { font-size: 90% } */ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/shunit2.html b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/shunit2.html new file mode 100644 index 0000000..3ef771b --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/shunit2.html @@ -0,0 +1,880 @@ + + + + + + +shUnit2 2.1.x Documentation + + + +
+

shUnit2 2.1.x Documentation

+ +
+

Abstract

+

shUnit2 is a xUnit unit test framework for Bourne based shell scripts, and it +is designed to work in a similar manner to JUnit, PyUnit, etc.. If you have +ever had the desire to write a unit test for a shell script, shUnit2 can do the +job.

+ +
+
+

Introduction

+

shUnit2 was originally developed to provide a consistent testing solution for +log4sh, a shell based logging framework similar to log4j. During the +development of that product, a repeated problem of having things work just fine +under one shell (/bin/bash on Linux to be specific), and then not working +under another shell (/bin/sh on Solaris) kept coming up. Although several +simple tests were run, they were not adequate and did not catch some corner +cases. The decision was finally made to write a proper unit test framework after +multiple brown-bag releases were made. Research was done to look for an +existing product that met the testing requirements, but no adequate product was +found.

+

Tested Operating Systems (varies over time)

+
    +
  • Cygwin
  • +
  • FreeBSD (user supported)
  • +
  • Linux (Gentoo, Ubuntu)
  • +
  • Mac OS X
  • +
  • Solaris 8, 9, 10 (inc. OpenSolaris)
  • +
+

Tested Shells

+
    +
  • Bourne Shell (sh)
  • +
  • BASH - GNU Bourne Again SHell (bash)
  • +
  • DASH (dash)
  • +
  • Korn Shell (ksh)
  • +
  • pdksh - Public Domain Korn Shell (pdksh)
  • +
  • zsh - Zsh (zsh) (since 2.1.2) please see the Zsh shell errata for more +information
  • +
+

See the appropriate Release Notes for this release +(doc/RELEASE_NOTES-X.X.X.txt) for the list of actual versions tested.

+
+

Credits / Contributors

+

A list of contributors to shUnit2 can be found in the source archive in +doc/contributors.txt. Many thanks go out to all those who have contributed +to make this a better tool.

+

shUnit2 is the original product of many hours of work by Kate Ward, the primary +author of the code. For other products by her, look up log4sh or shFlags, or +visit her website at http://forestent.com/.

+
+
+

Feedback

+

Feedback is most certainly welcome for this document. Send your additions, +comments and criticisms to the shunit2-users@google.com mailing list.

+
+
+
+

Quickstart

+

This section will give a very quick start to running unit tests with shUnit2. +More information is located in later sections.

+

Here is a quick sample script to show how easy it is to write a unit test in +shell. Note: the script as it stands expects that you are running it from the +``examples`` directory.

+
+#! /bin/sh
+# file: examples/equality_test.sh
+
+testEquality()
+{
+  assertEquals 1 1
+}
+
+# load shunit2
+. ../src/shell/shunit2
+
+

Running the unit test should give results similar to the following.

+
+testEquality
+
+Ran 1 test.
+
+OK
+
+

W00t! You've just run your first successful unit test. So, what just happened? +Quite a bit really, and it all happened simply by sourcing the shunit2 +library. The basic functionality for the script above goes like this:

+
    +
  • When shUnit2 is sourced, it will walk through any functions defined whose +namestart with the string test and add those to an internal list of tests +to execute. Once a list of test functions to be run has been determined, +shunit2 will go to work.
  • +
  • Before any tests are executed, shUnit2 again looks for a function, this time +one named oneTimeSetUp(). If it exists, it will be run. This function is +normally used to setup the environment for all tests to be run. Things like +creating directories for output or setting environment variables are good to +place here. Just so you know, you can also declare a corresponding function +named oneTimeTearDown() function that does the same thing, but once all +the tests have been completed. It is good for removing temporary directories, +etc.
  • +
  • shUnit2 is now ready to run tests. Before doing so though, it again looks for +another function that might be declared, one named setUp(). If the +function exists, it will be run before each test. It is good for resetting the +environment so that each test starts with a clean slate. At this stage, the +first test is finally run. The success of the test is recorded for a report +that will be generated later. After the test is run, shUnit2 looks for a final +function that might be declared, one named tearDown(). If it exists, it +will be run after each test. It is a good place for cleaning up after each +test, maybe doing things like removing files that were created, or removing +directories. This set of steps, setUp() > test() > tearDown(), is +repeated for all of the available tests.
  • +
  • Once all the work is done, shUnit2 will generate the nice report you saw +above. A summary of all the successes and failures will be given so that you +know how well your code is doing.
  • +
+

We should now try adding a test that fails. Change your unit test to look like +this.

+
+#! /bin/sh
+# file: examples/party_test.sh
+
+testEquality()
+{
+  assertEquals 1 1
+}
+
+testPartyLikeItIs1999()
+{
+  year=`date '+%Y'`
+  assertEquals "It's not 1999 :-(" \
+      '1999' "${year}"
+}
+
+# load shunit2
+. ../src/shell/shunit2
+
+

So, what did you get? I guess it told you that this isn't 1999. Bummer, eh? +Hopefully, you noticed a couple of things that were different about the second +test. First, we added an optional message that the user will see if the assert +fails. Second, we did comparisons of strings instead of integers as in the first +test. It doesn't matter whether you are testing for equality of strings or +integers. Both work equally well with shUnit2.

+

Hopefully, this is enough to get you started with unit testing. If you want a +ton more examples, take a look at the tests provided with log4sh or shFlags. +Both provide excellent examples of more advanced usage. shUnit2 was after all +written to help with the unit testing problems that log4sh had.

+
+
+

Function Reference

+
+

General Info

+

Any string values passed should be properly quoted -- they should must be +surrounded by single-quote (') or double-quote (") characters -- so that the +shell will properly parse them.

+
+
+

Asserts

+
+
assertEquals [message] expected actual
+
Asserts that expected and actual are equal to one another. The expected +and actual values can be either strings or integer values as both will be +treated as strings. The message is optional, and must be quoted.
+
assertNotEquals [message] expected actual
+
Asserts that unexpected and actual are not equal to one another. The +unexpected and actual values can be either strings or integer values as +both will be treaded as strings. The message is optional, and must be +quoted.
+
assertSame [message] expected actual
+
This function is functionally equivalent to assertEquals.
+
assertNotSame [message] unexpected actual
+
This function is functionally equivalent to assertNotEquals.
+
assertNull [message] value
+
Asserts that value is null, or in shell terms, a zero-length string. The +value must be a string as an integer value does not translate into a +zero-length string. The message is optional, and must be quoted.
+
assertNotNull [message] value
+
Asserts that value is not null, or in shell terms, a non-empty string. The +value may be a string or an integer as the later will be parsed as a +non-empty string value. The message is optional, and must be quoted.
+
assertTrue [message] condition
+

Asserts that a given shell test condition is true. The condition can be as +simple as a shell true value (the value 0 -- equivalent to +${SHUNIT_TRUE}), or a more sophisticated shell conditional expression. The +message is optional, and must be quoted.

+

A sophisticated shell conditional expression is equivalent to what the if +or while shell built-ins would use (more specifically, what the test +command would use). Testing for example whether some value is greater than +another value can be done this way.

+
+assertTrue "[ 34 -gt 23 ]"
+
+

Testing for the ability to read a file can also be done. This particular test +will fail.

+
+assertTrue 'test failed' "[ -r /some/non-existant/file' ]"
+
+

As the expressions are standard shell test expressions, it is possible to +string multiple expressions together with -a and -o in the standard +fashion. This test will succeed as the entire expression evaluates to true.

+
+assertTrue 'test failed' '[ 1 -eq 1 -a 2 -eq 2 ]'
+
+

One word of warning: be very careful with your quoting as shell is not the +most forgiving of bad quoting, and things will fail in strange ways.

+
+
assertFalse [message] condition
+

Asserts that a given shell test condition is false. The condition can be +as simple as a shell false value (the value 1 -- equivalent to +${SHUNIT_FALSE}), or a more sophisticated shell conditional expression. +The message is optional, and must be quoted.

+

For examples of more sophisticated expressions, see ``assertTrue``.

+
+
+
+
+

Failures

+

Just to clarify, failures do not test the various arguments against one +another. Failures simply fail, optionally with a message, and that is all they +do. If you need to test arguments against one another, use asserts.

+

If all failures do is fail, why might one use them? There are times when you may +have some very complicated logic that you need to test, and the simple asserts +provided are simply not adequate. You can do your own validation of the code, +use an assertTrue ${SHUNIT_TRUE} if your own tests succeeded, and use a +failure to record a failure.

+
+
fail [message]
+
Fails the test immediately. The message is optional, and must be quoted.
+
failNotEquals [message] unexpected actual
+

Fails the test immediately, reporting that the unexpected and actual +values are not equal to one another. The message is optional, and must be +quoted.

+

Note: no actual comparison of unexpected and actual is done.

+
+
failSame [message] expected actual
+

Fails the test immediately, reporting that the expected and actual values +are the same. The message is optional, and must be quoted.

+

Note: no actual comparison of expected and actual is done.

+
+
failNotSame [message] expected actual
+

Fails the test immediately, reporting that the expected and actual values +are not the same. The message is optional, and must be quoted.

+

Note: no actual comparison of expected and actual is done.

+
+
+
+
+

Setup/Teardown

+
+
oneTimeSetUp
+

This function can be be optionally overridden by the user in their test suite.

+

If this function exists, it will be called once before any tests are run. It +is useful to prepare a common environment for all tests.

+
+
oneTimeTearDown
+

This function can be be optionally overridden by the user in their test suite.

+

If this function exists, it will be called once after all tests are completed. +It is useful to clean up the environment after all tests.

+
+
setUp
+

This function can be be optionally overridden by the user in their test suite.

+

If this function exists, it will be called before each test is run. It is +useful to reset the environment before each test.

+
+
tearDown
+

This function can be be optionally overridden by the user in their test suite.

+

If this function exists, it will be called after each test completes. It is +useful to clean up the environment after each test.

+
+
+
+
+

Skipping

+
+
startSkipping
+
This function forces the remaining assert and fail functions to be +"skipped", i.e. they will have no effect. Each function skipped will be +recorded so that the total of asserts and fails will not be altered.
+
endSkipping
+
This function returns calls to the assert and fail functions to their +default behavior, i.e. they will be called.
+
isSkipping
+
This function returns the current state of skipping. It can be compared +against ${SHUNIT_TRUE} or ${SHUNIT_FALSE} if desired.
+
+
+
+

Suites

+

The default behavior of shUnit2 is that all tests will be found dynamically. If +you have a specific set of tests you want to run, or you don't want to use the +standard naming scheme of prefixing your tests with test, these functions +are for you. Most users will never use them though.

+
+
suite
+

This function can be optionally overridden by the user in their test suite.

+

If this function exists, it will be called when shunit2 is sourced. If it +does not exist, shUnit2 will search the parent script for all functions +beginning with the word test, and they will be added dynamically to the +test suite.

+
+
suite_addTest name
+
This function adds a function named name to the list of tests scheduled for +execution as part of this test suite. This function should only be called from +within the suite() function.
+
+
+
+
+

Advanced Usage

+

This section covers several advanced usage topics.

+
+

Some constants you can use

+

There are several constants provided by shUnit2 as variables that might be of +use to you.

+

Predefined

+ ++++ + + + + + + + + + + + + + + + + + +
SHUNIT_VERSIONThe version of shUnit2 you are running.
SHUNIT_TRUEStandard shell true value (the integer value 0).
SHUNIT_FALSEStandard shell false value (the integer value 1).
SHUNIT_ERRORThe integer value 2.
SHUNIT_TMPDIRPath to temporary directory that will be automatically +cleaned up upon exit of shUnit2.
+

User defined

+ ++++ + + + + + +
SHUNIT_PARENTThe filename of the shell script containing the tests. This +is needed specifically for Zsh support.
+
+
+

Error handling

+

The constants values SHUNIT_TRUE, SHUNIT_FALSE, and SHUNIT_ERROR are +returned from nearly every function to indicate the success or failure of the +function. Additionally the variable flags_error is filled with a detailed +error message if any function returns with a SHUNIT_ERROR value.

+
+
+

Including Line Numbers in Asserts (Macros)

+

If you include lots of assert statements in an individual test function, it can +become difficult to determine exactly which assert was thrown unless your +messages are unique. To help somewhat, line numbers can be included in the +assert messages. To enable this, a special shell "macro" must be used rather +than the standard assert calls. Shell doesn't actually have macros; the name is +used here as the operation is similar to a standard macro.

+

For example, to include line numbers for a assertEquals() function call, +replace the assertEquals() with ${_ASSERT_EQUALS_}.

+

Example -- Asserts with and without line numbers

+
+#! /bin/sh
+# file: examples/lineno_test.sh
+
+testLineNo()
+{
+  # this assert will have line numbers included (e.g. "ASSERT:[123] ...")
+  echo "ae: ${_ASSERT_EQUALS_}"
+  ${_ASSERT_EQUALS_} 'not equal' 1 2
+
+  # this assert will not have line numbers included (e.g. "ASSERT: ...")
+  assertEquals 'not equal' 1 2
+}
+
+# load shunit2
+. ../src/shell/shunit2
+
+

Notes:

+
    +
  1. Due to how shell parses command-line arguments, all strings used with macros +should be quoted twice. Namely, single-quotes must be converted to +single-double-quotes, and vice-versa. If the string being passed is +absolutely for sure not empty, the extra quoting is not necessary.

    +

    Normal assertEquals call.

    +
    +assertEquals 'some message' 'x' ''
    +
    +

    Macro _ASSERT_EQUALS_ call. Note the extra quoting around the message +and the null value.

    +
    +_ASSERT_EQUALS_ '"some message"' 'x' '""'
    +
    +
  2. +
  3. Line numbers are not supported in all shells. If a shell does not support +them, no errors will be thrown. Supported shells include: bash (>=3.0), +ksh, pdksh, and zsh.

    +
  4. +
+
+
+

Test Skipping

+

There are times where the test code you have written is just not applicable to +the system you are running on. This section describes how to skip these tests +but maintain the total test count.

+

Probably the easiest example would be shell code that is meant to run under the +bash shell, but the unit test is running under the Bourne shell. There are +things that just won't work. The following test code demonstrates two sample +functions, one that will be run under any shell, and the another that will run +only under the bash shell.

+

Example -- math include

+
+# available as examples/math.inc
+
+add_generic()
+{
+  num_a=$1
+  num_b=$2
+
+  expr $1 + $2
+}
+
+add_bash()
+{
+  num_a=$1
+  num_b=$2
+
+  echo $(($1 + $2))
+}
+
+

And here is a corresponding unit test that correctly skips the add_bash() +function when the unit test is not running under the bash shell.

+

Example -- math unit test

+
+#! /bin/sh
+# available as examples/math_test.sh
+
+testAdding()
+{
+  result=`add_generic 1 2`
+  assertEquals \
+      "the result of '${result}' was wrong" \
+      3 "${result}"
+
+  # disable non-generic tests
+  [ -z "${BASH_VERSION:-}" ] && startSkipping
+
+  result=`add_bash 1 2`
+  assertEquals \
+      "the result of '${result}' was wrong" \
+      3 "${result}"
+}
+
+oneTimeSetUp()
+{
+  # load include to test
+  . ./math.inc
+}
+
+# load and run shUnit2
+. ../src/shell/shunit2
+
+

Running the above test under the bash shell will result in the following +output.

+
+$ /bin/bash math_test.sh
+testAdding
+
+Ran 1 test.
+
+OK
+
+

But, running the test under any other Unix shell will result in the following +output.

+
+$ /bin/ksh math_test.sh
+testAdding
+
+Ran 1 test.
+
+OK (skipped=1)
+
+

As you can see, the total number of tests has not changed, but the report +indicates that some tests were skipped.

+

Skipping can be controlled with the following functions: startSkipping(), +endSkipping(), and isSkipping(). Once skipping is enabled, it will +remain enabled until the end of the current test function call, after which +skipping is disabled.

+
+
+
+

Appendix

+
+

Getting help

+

For help, please send requests to either the shunit2-users@googlegroups.com +mailing list (archives available on the web at +http://groups.google.com/group/shunit2-users) or directly to +Kate Ward <kate dot ward at forestent dot com>.

+
+
+

Zsh

+

For compatibility with Zsh, there is one requirement that must be met -- the +shwordsplit option must be set. There are three ways to accomplish this.

+
    +
  1. In the unit-test script, add the following shell code snippet before sourcing +the shunit2 library.

    +
    +setopt shwordsplit
    +
    +
  2. +
  3. When invoking zsh from either the command-line or as a script with +#!, add the -y parameter.

    +
    +#! /bin/zsh -y
    +
    +
  4. +
  5. When invoking zsh from the command-line, add -o shwordsplit -- as +parameters before the script name.

    +
    +$ zsh -o shwordsplit -- some_script
    +
    +
  6. +
+ + + + + +
+
+
+ + diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/shunit2.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/shunit2.txt new file mode 100644 index 0000000..034c6fc --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/doc/shunit2.txt @@ -0,0 +1,562 @@ +=========================== +shUnit2 2.1.x Documentation +=========================== + +Abstract +======== + +shUnit2_ is a xUnit_ unit test framework for Bourne based shell scripts, and it +is designed to work in a similar manner to JUnit_, PyUnit_, etc.. If you have +ever had the desire to write a unit test for a shell script, shUnit2 can do the +job. + +.. contents:: Table of Contents + :depth: 2 + +Introduction +============ + +shUnit2 was originally developed to provide a consistent testing solution for +log4sh_, a shell based logging framework similar to log4j_. During the +development of that product, a repeated problem of having things work just fine +under one shell (``/bin/bash`` on Linux to be specific), and then not working +under another shell (``/bin/sh`` on Solaris) kept coming up. Although several +simple tests were run, they were not adequate and did not catch some corner +cases. The decision was finally made to write a proper unit test framework after +multiple brown-bag releases were made. *Research was done to look for an +existing product that met the testing requirements, but no adequate product was +found.* + +Tested Operating Systems (varies over time) + +- Cygwin +- FreeBSD (user supported) +- Linux (Gentoo, Ubuntu) +- Mac OS X +- Solaris 8, 9, 10 (inc. OpenSolaris) + +Tested Shells + +- Bourne Shell (**sh**) +- BASH - GNU Bourne Again SHell (**bash**) +- DASH (**dash**) +- Korn Shell (**ksh**) +- pdksh - Public Domain Korn Shell (**pdksh**) +- zsh - Zsh (**zsh**) (since 2.1.2) *please see the Zsh shell errata for more + information* + +See the appropriate Release Notes for this release +(``doc/RELEASE_NOTES-X.X.X.txt``) for the list of actual versions tested. + +Credits / Contributors +---------------------- + +A list of contributors to shUnit2 can be found in the source archive in +``doc/contributors.txt``. Many thanks go out to all those who have contributed +to make this a better tool. + +shUnit2 is the original product of many hours of work by Kate Ward, the primary +author of the code. For other products by her, look up log4sh_ or shFlags_, or +visit her website at http://forestent.com/. + +Feedback +-------- + +Feedback is most certainly welcome for this document. Send your additions, +comments and criticisms to the shunit2-users@google.com mailing list. + +Quickstart +========== + +This section will give a very quick start to running unit tests with shUnit2. +More information is located in later sections. + +Here is a quick sample script to show how easy it is to write a unit test in +shell. *Note: the script as it stands expects that you are running it from the +``examples`` directory.* :: + + #! /bin/sh + # file: examples/equality_test.sh + + testEquality() + { + assertEquals 1 1 + } + + # load shunit2 + . ../src/shell/shunit2 + +Running the unit test should give results similar to the following. :: + + testEquality + + Ran 1 test. + + OK + +W00t! You've just run your first successful unit test. So, what just happened? +Quite a bit really, and it all happened simply by sourcing the ``shunit2`` +library. The basic functionality for the script above goes like this: + +- When shUnit2 is sourced, it will walk through any functions defined whose + namestart with the string ``test`` and add those to an internal list of tests + to execute. Once a list of test functions to be run has been determined, + shunit2 will go to work. +- Before any tests are executed, shUnit2 again looks for a function, this time + one named ``oneTimeSetUp()``. If it exists, it will be run. This function is + normally used to setup the environment for all tests to be run. Things like + creating directories for output or setting environment variables are good to + place here. Just so you know, you can also declare a corresponding function + named ``oneTimeTearDown()`` function that does the same thing, but once all + the tests have been completed. It is good for removing temporary directories, + etc. +- shUnit2 is now ready to run tests. Before doing so though, it again looks for + another function that might be declared, one named ``setUp()``. If the + function exists, it will be run before each test. It is good for resetting the + environment so that each test starts with a clean slate. At this stage, the + first test is finally run. The success of the test is recorded for a report + that will be generated later. After the test is run, shUnit2 looks for a final + function that might be declared, one named ``tearDown()``. If it exists, it + will be run after each test. It is a good place for cleaning up after each + test, maybe doing things like removing files that were created, or removing + directories. This set of steps, ``setUp()`` > ``test()`` > ``tearDown()``, is + repeated for all of the available tests. +- Once all the work is done, shUnit2 will generate the nice report you saw + above. A summary of all the successes and failures will be given so that you + know how well your code is doing. + +We should now try adding a test that fails. Change your unit test to look like +this. :: + + #! /bin/sh + # file: examples/party_test.sh + + testEquality() + { + assertEquals 1 1 + } + + testPartyLikeItIs1999() + { + year=`date '+%Y'` + assertEquals "It's not 1999 :-(" \ + '1999' "${year}" + } + + # load shunit2 + . ../src/shell/shunit2 + +So, what did you get? I guess it told you that this isn't 1999. Bummer, eh? +Hopefully, you noticed a couple of things that were different about the second +test. First, we added an optional message that the user will see if the assert +fails. Second, we did comparisons of strings instead of integers as in the first +test. It doesn't matter whether you are testing for equality of strings or +integers. Both work equally well with shUnit2. + +Hopefully, this is enough to get you started with unit testing. If you want a +ton more examples, take a look at the tests provided with log4sh_ or shFlags_. +Both provide excellent examples of more advanced usage. shUnit2 was after all +written to help with the unit testing problems that log4sh_ had. + +Function Reference +================== + +General Info +------------ + +Any string values passed should be properly quoted -- they should must be +surrounded by single-quote (') or double-quote (") characters -- so that the +shell will properly parse them. + +Asserts +------- + +``assertEquals [message] expected actual`` + Asserts that *expected* and *actual* are equal to one another. The *expected* + and *actual* values can be either strings or integer values as both will be + treated as strings. The *message* is optional, and must be quoted. + +``assertNotEquals [message] expected actual`` + Asserts that *unexpected* and *actual* are not equal to one another. The + *unexpected* and *actual* values can be either strings or integer values as + both will be treaded as strings. The *message* is optional, and must be + quoted. + +``assertSame [message] expected actual`` + This function is functionally equivalent to ``assertEquals``. + +``assertNotSame [message] unexpected actual`` + This function is functionally equivalent to ``assertNotEquals``. + +``assertNull [message] value`` + Asserts that *value* is *null*, or in shell terms, a zero-length string. The + *value* must be a string as an integer value does not translate into a + zero-length string. The *message* is optional, and must be quoted. + +``assertNotNull [message] value`` + Asserts that *value* is *not null*, or in shell terms, a non-empty string. The + *value* may be a string or an integer as the later will be parsed as a + non-empty string value. The *message* is optional, and must be quoted. + +``assertTrue [message] condition`` + Asserts that a given shell test *condition* is *true*. The condition can be as + simple as a shell *true* value (the value ``0`` -- equivalent to + ``${SHUNIT_TRUE}``), or a more sophisticated shell conditional expression. The + *message* is optional, and must be quoted. + + A sophisticated shell conditional expression is equivalent to what the **if** + or **while** shell built-ins would use (more specifically, what the **test** + command would use). Testing for example whether some value is greater than + another value can be done this way. :: + + assertTrue "[ 34 -gt 23 ]" + + Testing for the ability to read a file can also be done. This particular test + will fail. :: + + assertTrue 'test failed' "[ -r /some/non-existant/file' ]" + + As the expressions are standard shell **test** expressions, it is possible to + string multiple expressions together with ``-a`` and ``-o`` in the standard + fashion. This test will succeed as the entire expression evaluates to *true*. + :: + + assertTrue 'test failed' '[ 1 -eq 1 -a 2 -eq 2 ]' + + *One word of warning: be very careful with your quoting as shell is not the + most forgiving of bad quoting, and things will fail in strange ways.* + +``assertFalse [message] condition`` + Asserts that a given shell test *condition* is *false*. The condition can be + as simple as a shell *false* value (the value ``1`` -- equivalent to + ``${SHUNIT_FALSE}``), or a more sophisticated shell conditional expression. + The *message* is optional, and must be quoted. + + *For examples of more sophisticated expressions, see ``assertTrue``.* + +Failures +-------- + +Just to clarify, failures **do not** test the various arguments against one +another. Failures simply fail, optionally with a message, and that is all they +do. If you need to test arguments against one another, use asserts. + +If all failures do is fail, why might one use them? There are times when you may +have some very complicated logic that you need to test, and the simple asserts +provided are simply not adequate. You can do your own validation of the code, +use an ``assertTrue ${SHUNIT_TRUE}`` if your own tests succeeded, and use a +failure to record a failure. + +``fail [message]`` + Fails the test immediately. The *message* is optional, and must be quoted. + +``failNotEquals [message] unexpected actual`` + Fails the test immediately, reporting that the *unexpected* and *actual* + values are not equal to one another. The *message* is optional, and must be + quoted. + + *Note: no actual comparison of unexpected and actual is done.* + +``failSame [message] expected actual`` + Fails the test immediately, reporting that the *expected* and *actual* values + are the same. The *message* is optional, and must be quoted. + + *Note: no actual comparison of expected and actual is done.* + +``failNotSame [message] expected actual`` + Fails the test immediately, reporting that the *expected* and *actual* values + are not the same. The *message* is optional, and must be quoted. + + *Note: no actual comparison of expected and actual is done.* + +Setup/Teardown +-------------- + +``oneTimeSetUp`` + This function can be be optionally overridden by the user in their test suite. + + If this function exists, it will be called once before any tests are run. It + is useful to prepare a common environment for all tests. + +``oneTimeTearDown`` + This function can be be optionally overridden by the user in their test suite. + + If this function exists, it will be called once after all tests are completed. + It is useful to clean up the environment after all tests. + +``setUp`` + This function can be be optionally overridden by the user in their test suite. + + If this function exists, it will be called before each test is run. It is + useful to reset the environment before each test. + +``tearDown`` + This function can be be optionally overridden by the user in their test suite. + + If this function exists, it will be called after each test completes. It is + useful to clean up the environment after each test. + +Skipping +-------- + +``startSkipping`` + This function forces the remaining *assert* and *fail* functions to be + "skipped", i.e. they will have no effect. Each function skipped will be + recorded so that the total of asserts and fails will not be altered. + +``endSkipping`` + This function returns calls to the *assert* and *fail* functions to their + default behavior, i.e. they will be called. + +``isSkipping`` + This function returns the current state of skipping. It can be compared + against ``${SHUNIT_TRUE}`` or ``${SHUNIT_FALSE}`` if desired. + +Suites +------ + +The default behavior of shUnit2 is that all tests will be found dynamically. If +you have a specific set of tests you want to run, or you don't want to use the +standard naming scheme of prefixing your tests with ``test``, these functions +are for you. Most users will never use them though. + +``suite`` + This function can be optionally overridden by the user in their test suite. + + If this function exists, it will be called when ``shunit2`` is sourced. If it + does not exist, shUnit2 will search the parent script for all functions + beginning with the word ``test``, and they will be added dynamically to the + test suite. + +``suite_addTest name`` + This function adds a function named *name* to the list of tests scheduled for + execution as part of this test suite. This function should only be called from + within the ``suite()`` function. + +Advanced Usage +============== + +This section covers several advanced usage topics. + +Some constants you can use +-------------------------- + +There are several constants provided by shUnit2 as variables that might be of +use to you. + +Predefined + +================== =========================================================== +``SHUNIT_VERSION`` The version of shUnit2 you are running. +``SHUNIT_TRUE`` Standard shell *true* value (the integer value 0). +``SHUNIT_FALSE`` Standard shell *false* value (the integer value 1). +``SHUNIT_ERROR`` The integer value 2. +``SHUNIT_TMPDIR`` Path to temporary directory that will be automatically + cleaned up upon exit of shUnit2. +================== =========================================================== + +User defined + +================== =========================================================== +``SHUNIT_PARENT`` The filename of the shell script containing the tests. This + is needed specifically for Zsh support. +================== =========================================================== + +Error handling +-------------- + +The constants values ``SHUNIT_TRUE``, ``SHUNIT_FALSE``, and ``SHUNIT_ERROR`` are +returned from nearly every function to indicate the success or failure of the +function. Additionally the variable ``flags_error`` is filled with a detailed +error message if any function returns with a ``SHUNIT_ERROR`` value. + +Including Line Numbers in Asserts (Macros) +------------------------------------------ + +If you include lots of assert statements in an individual test function, it can +become difficult to determine exactly which assert was thrown unless your +messages are unique. To help somewhat, line numbers can be included in the +assert messages. To enable this, a special shell "macro" must be used rather +than the standard assert calls. *Shell doesn't actually have macros; the name is +used here as the operation is similar to a standard macro.* + +For example, to include line numbers for a ``assertEquals()`` function call, +replace the ``assertEquals()`` with ``${_ASSERT_EQUALS_}``. + +Example--Asserts with and without line numbers :: + + #! /bin/sh + # file: examples/lineno_test.sh + + testLineNo() + { + # this assert will have line numbers included (e.g. "ASSERT:[123] ...") + echo "ae: ${_ASSERT_EQUALS_}" + ${_ASSERT_EQUALS_} 'not equal' 1 2 + + # this assert will not have line numbers included (e.g. "ASSERT: ...") + assertEquals 'not equal' 1 2 + } + + # load shunit2 + . ../src/shell/shunit2 + +Notes: + +#. Due to how shell parses command-line arguments, all strings used with macros + should be quoted twice. Namely, single-quotes must be converted to + single-double-quotes, and vice-versa. If the string being passed is + absolutely for sure not empty, the extra quoting is not necessary. + + Normal ``assertEquals`` call. :: + + assertEquals 'some message' 'x' '' + + Macro ``_ASSERT_EQUALS_`` call. Note the extra quoting around the *message* + and the *null* value. :: + + _ASSERT_EQUALS_ '"some message"' 'x' '""' + +#. Line numbers are not supported in all shells. If a shell does not support + them, no errors will be thrown. Supported shells include: **bash** (>=3.0), + **ksh**, **pdksh**, and **zsh**. + +Test Skipping +------------- + +There are times where the test code you have written is just not applicable to +the system you are running on. This section describes how to skip these tests +but maintain the total test count. + +Probably the easiest example would be shell code that is meant to run under the +**bash** shell, but the unit test is running under the Bourne shell. There are +things that just won't work. The following test code demonstrates two sample +functions, one that will be run under any shell, and the another that will run +only under the **bash** shell. + +Example-- math include :: + + # available as examples/math.inc + + add_generic() + { + num_a=$1 + num_b=$2 + + expr $1 + $2 + } + + add_bash() + { + num_a=$1 + num_b=$2 + + echo $(($1 + $2)) + } + +And here is a corresponding unit test that correctly skips the ``add_bash()`` +function when the unit test is not running under the **bash** shell. + +Example-- math unit test :: + + #! /bin/sh + # available as examples/math_test.sh + + testAdding() + { + result=`add_generic 1 2` + assertEquals \ + "the result of '${result}' was wrong" \ + 3 "${result}" + + # disable non-generic tests + [ -z "${BASH_VERSION:-}" ] && startSkipping + + result=`add_bash 1 2` + assertEquals \ + "the result of '${result}' was wrong" \ + 3 "${result}" + } + + oneTimeSetUp() + { + # load include to test + . ./math.inc + } + + # load and run shUnit2 + . ../src/shell/shunit2 + +Running the above test under the **bash** shell will result in the following +output. :: + + $ /bin/bash math_test.sh + testAdding + + Ran 1 test. + + OK + +But, running the test under any other Unix shell will result in the following +output. :: + + $ /bin/ksh math_test.sh + testAdding + + Ran 1 test. + + OK (skipped=1) + +As you can see, the total number of tests has not changed, but the report +indicates that some tests were skipped. + +Skipping can be controlled with the following functions: ``startSkipping()``, +``endSkipping()``, and ``isSkipping()``. Once skipping is enabled, it will +remain enabled until the end of the current test function call, after which +skipping is disabled. + +Appendix +======== + +Getting help +------------ + +For help, please send requests to either the shunit2-users@googlegroups.com +mailing list (archives available on the web at +http://groups.google.com/group/shunit2-users) or directly to +Kate Ward . + +Zsh +--- + +For compatibility with Zsh, there is one requirement that must be met -- the +``shwordsplit`` option must be set. There are three ways to accomplish this. + +#. In the unit-test script, add the following shell code snippet before sourcing + the ``shunit2`` library. :: + + setopt shwordsplit + +#. When invoking **zsh** from either the command-line or as a script with + ``#!``, add the ``-y`` parameter. :: + + #! /bin/zsh -y + +#. When invoking **zsh** from the command-line, add ``-o shwordsplit --`` as + parameters before the script name. :: + + $ zsh -o shwordsplit -- some_script + +.. _log4sh: http://log4sh.sourceforge.net/ +.. _log4j: http://logging.apache.org/ +.. _JUnit: http://www.junit.org/ +.. _PyUnit: http://pyunit.sourceforge.net/ +.. _shFlags: http://shflags.googlecode.com/ +.. _shUnit2: http://shunit2.googlecode.com/ +.. _xUnit: http://en.wikipedia.org/wiki/XUnit + +.. generate HTML using rst2html from Docutils of +.. http://docutils.sourceforge.net/ +.. +.. vim:fileencoding=latin1:ft=rst:spell:sts=2:sw=2:tw=80 +.. $Revision: 233 $ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/equality_test.sh b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/equality_test.sh new file mode 100755 index 0000000..e0d68a5 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/equality_test.sh @@ -0,0 +1,10 @@ +#! /bin/sh +# file: examples/equality_test.sh + +testEquality() +{ + assertEquals 1 1 +} + +# load shunit2 +. ../src/shunit2 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/lineno_test.sh b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/lineno_test.sh new file mode 100755 index 0000000..9c05f1e --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/lineno_test.sh @@ -0,0 +1,16 @@ +#! /bin/sh +# file: examples/lineno_test.sh + +testLineNo() +{ + # this assert will have line numbers included (e.g. "ASSERT:[123] ...") if + # they are supported. + echo "_ASSERT_EQUALS_ macro value: ${_ASSERT_EQUALS_}" + ${_ASSERT_EQUALS_} 'not equal' 1 2 + + # this assert will not have line numbers included (e.g. "ASSERT: ...") + assertEquals 'not equal' 1 2 +} + +# load shunit2 +. ../src/shunit2 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/math.inc b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/math.inc new file mode 100644 index 0000000..4097106 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/math.inc @@ -0,0 +1,17 @@ +# available as examples/math.inc + +add_generic() +{ + num_a=$1 + num_b=$2 + + expr $1 + $2 +} + +add_bash() +{ + num_a=$1 + num_b=$2 + + echo $(($1 + $2)) +} diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/math_test.sh b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/math_test.sh new file mode 100755 index 0000000..41be5ff --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/math_test.sh @@ -0,0 +1,27 @@ +#! /bin/sh +# available as examples/math_test.sh + +testAdding() +{ + result=`add_generic 1 2` + assertEquals \ + "the result of '${result}' was wrong" \ + 3 "${result}" + + # disable non-generic tests + [ -z "${BASH_VERSION:-}" ] && startSkipping + + result=`add_bash 1 2` + assertEquals \ + "the result of '${result}' was wrong" \ + 3 "${result}" +} + +oneTimeSetUp() +{ + # load include to test + . ./math.inc +} + +# load and run shUnit2 +. ../src/shunit2 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/mkdir_test.sh b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/mkdir_test.sh new file mode 100755 index 0000000..28d8d94 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/mkdir_test.sh @@ -0,0 +1,89 @@ +#!/bin/sh +# vim:et:ft=sh:sts=2:sw=2 +# +# Copyright 2008 Kate Ward. All Rights Reserved. +# Released under the LGPL (GNU Lesser General Public License) +# +# Author: kate.ward@forestent.com (Kate Ward) +# +# Example unit test for the mkdir command. +# +# There are times when an existing shell script needs to be tested. In this +# example, we will test several aspects of the the mkdir command, but the +# techniques could be used for any existing shell script. + +#----------------------------------------------------------------------------- +# suite tests +# + +testMissingDirectoryCreation() +{ + ${mkdirCmd} "${testDir}" >${stdoutF} 2>${stderrF} + rtrn=$? + th_assertTrueWithNoOutput ${rtrn} "${stdoutF}" "${stderrF}" + + assertTrue 'directory missing' "[ -d '${testDir}' ]" +} + +testExistingDirectoryCreationFails() +{ + # create a directory to test against + ${mkdirCmd} "${testDir}" + + # test for expected failure while trying to create directory that exists + ${mkdirCmd} "${testDir}" >${stdoutF} 2>${stderrF} + rtrn=$? + assertFalse 'expecting return code of 1 (false)' ${rtrn} + assertNull 'unexpected output to stdout' "`cat ${stdoutF}`" + assertNotNull 'expected error message to stderr' "`cat ${stderrF}`" + + assertTrue 'directory missing' "[ -d '${testDir}' ]" +} + +testRecursiveDirectoryCreation() +{ + testDir2="${testDir}/test2" + + ${mkdirCmd} -p "${testDir2}" >${stdoutF} 2>${stderrF} + rtrn=$? + th_assertTrueWithNoOutput ${rtrn} "${stdoutF}" "${stderrF}" + + assertTrue 'first directory missing' "[ -d '${testDir}' ]" + assertTrue 'second directory missing' "[ -d '${testDir2}' ]" +} + +#----------------------------------------------------------------------------- +# suite functions +# + +th_assertTrueWithNoOutput() +{ + th_return_=$1 + th_stdout_=$2 + th_stderr_=$3 + + assertFalse 'unexpected output to STDOUT' "[ -s '${th_stdout_}' ]" + assertFalse 'unexpected output to STDERR' "[ -s '${th_stderr_}' ]" + + unset th_return_ th_stdout_ th_stderr_ +} + +oneTimeSetUp() +{ + outputDir="${SHUNIT_TMPDIR}/output" + mkdir "${outputDir}" + stdoutF="${outputDir}/stdout" + stderrF="${outputDir}/stderr" + + mkdirCmd='mkdir' # save command name in variable to make future changes easy + testDir="${SHUNIT_TMPDIR}/some_test_dir" +} + +tearDown() +{ + rm -fr "${testDir}" +} + +# load and run shUnit2 +[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0 +. ../src/shunit2 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/party_test.sh b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/party_test.sh new file mode 100755 index 0000000..5ca2583 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/examples/party_test.sh @@ -0,0 +1,17 @@ +#! /bin/sh +# file: examples/party_test.sh + +testEquality() +{ + assertEquals 1 1 +} + +testPartyLikeItIs1999() +{ + year=`date '+%Y'` + assertEquals "It's not 1999 :-(" \ + '1999' "${year}" +} + +# load shunit2 +. ../src/shunit2 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/lib/shflags b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/lib/shflags new file mode 100644 index 0000000..9e69e64 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/lib/shflags @@ -0,0 +1,1156 @@ +# $Id: shflags 189 2013-01-15 00:13:10Z kate.ward@forestent.com $ +# vim:et:ft=sh:sts=2:sw=2 +# +# Copyright 2008 Kate Ward. All Rights Reserved. +# Released under the LGPL (GNU Lesser General Public License) +# +# shFlags -- Advanced command-line flag library for Unix shell scripts. +# http://code.google.com/p/shflags/ +# +# Author: kate.ward@forestent.com (Kate Ward) +# +# This module implements something like the google-gflags library available +# from http://code.google.com/p/google-gflags/. +# +# FLAG TYPES: This is a list of the DEFINE_*'s that you can do. All flags take +# a name, default value, help-string, and optional 'short' name (one-letter +# name). Some flags have other arguments, which are described with the flag. +# +# DEFINE_string: takes any input, and intreprets it as a string. +# +# DEFINE_boolean: does not take any arguments. Say --myflag to set +# FLAGS_myflag to true, or --nomyflag to set FLAGS_myflag to false. For short +# flags, passing the flag on the command-line negates the default value, i.e. +# if the default is true, passing the flag sets the value to false. +# +# DEFINE_float: takes an input and intreprets it as a floating point number. As +# shell does not support floats per-se, the input is merely validated as +# being a valid floating point value. +# +# DEFINE_integer: takes an input and intreprets it as an integer. +# +# SPECIAL FLAGS: There are a few flags that have special meaning: +# --help (or -?) prints a list of all the flags in a human-readable fashion +# --flagfile=foo read flags from foo. (not implemented yet) +# -- as in getopt(), terminates flag-processing +# +# EXAMPLE USAGE: +# +# -- begin hello.sh -- +# #! /bin/sh +# . ./shflags +# DEFINE_string name 'world' "somebody's name" n +# FLAGS "$@" || exit $? +# eval set -- "${FLAGS_ARGV}" +# echo "Hello, ${FLAGS_name}." +# -- end hello.sh -- +# +# $ ./hello.sh -n Kate +# Hello, Kate. +# +# CUSTOMIZABLE BEHAVIOR: +# +# A script can override the default 'getopt' command by providing the path to +# an alternate implementation by defining the FLAGS_GETOPT_CMD variable. +# +# NOTES: +# +# * Not all systems include a getopt version that supports long flags. On these +# systems, only short flags are recognized. + +#============================================================================== +# shFlags +# +# Shared attributes: +# flags_error: last error message +# flags_output: last function output (rarely valid) +# flags_return: last return value +# +# __flags_longNames: list of long names for all flags +# __flags_shortNames: list of short names for all flags +# __flags_boolNames: list of boolean flag names +# +# __flags_opts: options parsed by getopt +# +# Per-flag attributes: +# FLAGS_: contains value of flag named 'flag_name' +# __flags__default: the default flag value +# __flags__help: the flag help string +# __flags__short: the flag short name +# __flags__type: the flag type +# +# Notes: +# - lists of strings are space separated, and a null value is the '~' char. + +# return if FLAGS already loaded +[ -n "${FLAGS_VERSION:-}" ] && return 0 +FLAGS_VERSION='1.0.4pre' + +# return values that scripts can use +FLAGS_TRUE=0 +FLAGS_FALSE=1 +FLAGS_ERROR=2 + +# determine some reasonable command defaults +__FLAGS_UNAME_S=`uname -s` +case "${__FLAGS_UNAME_S}" in + BSD) __FLAGS_EXPR_CMD='gexpr' ;; + *) __FLAGS_EXPR_CMD='expr' ;; +esac + +# commands a user can override if needed +FLAGS_EXPR_CMD=${FLAGS_EXPR_CMD:-${__FLAGS_EXPR_CMD}} +FLAGS_GETOPT_CMD=${FLAGS_GETOPT_CMD:-getopt} + +# specific shell checks +if [ -n "${ZSH_VERSION:-}" ]; then + setopt |grep "^shwordsplit$" >/dev/null + if [ $? -ne ${FLAGS_TRUE} ]; then + _flags_fatal 'zsh shwordsplit option is required for proper zsh operation' + fi + if [ -z "${FLAGS_PARENT:-}" ]; then + _flags_fatal "zsh does not pass \$0 through properly. please declare' \ +\"FLAGS_PARENT=\$0\" before calling shFlags" + fi +fi + +# can we use built-ins? +( echo "${FLAGS_TRUE#0}"; ) >/dev/null 2>&1 +if [ $? -eq ${FLAGS_TRUE} ]; then + __FLAGS_USE_BUILTIN=${FLAGS_TRUE} +else + __FLAGS_USE_BUILTIN=${FLAGS_FALSE} +fi + +# +# constants +# + +# reserved flag names +__FLAGS_RESERVED_LIST=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE ' +__FLAGS_RESERVED_LIST="${__FLAGS_RESERVED_LIST} VERSION " + +# getopt version +__FLAGS_GETOPT_VERS_STD=0 +__FLAGS_GETOPT_VERS_ENH=1 +__FLAGS_GETOPT_VERS_BSD=2 + +${FLAGS_GETOPT_CMD} >/dev/null 2>&1 +case $? in + 0) __FLAGS_GETOPT_VERS=${__FLAGS_GETOPT_VERS_STD} ;; # bsd getopt + 2) + # TODO(kward): look into '-T' option to test the internal getopt() version + if [ "`${FLAGS_GETOPT_CMD} --version`" = '-- ' ]; then + __FLAGS_GETOPT_VERS=${__FLAGS_GETOPT_VERS_STD} + else + __FLAGS_GETOPT_VERS=${__FLAGS_GETOPT_VERS_ENH} + fi + ;; + *) _flags_fatal 'unable to determine getopt version' ;; +esac + +# getopt optstring lengths +__FLAGS_OPTSTR_SHORT=0 +__FLAGS_OPTSTR_LONG=1 + +__FLAGS_NULL='~' + +# flag info strings +__FLAGS_INFO_DEFAULT='default' +__FLAGS_INFO_HELP='help' +__FLAGS_INFO_SHORT='short' +__FLAGS_INFO_TYPE='type' + +# flag lengths +__FLAGS_LEN_SHORT=0 +__FLAGS_LEN_LONG=1 + +# flag types +__FLAGS_TYPE_NONE=0 +__FLAGS_TYPE_BOOLEAN=1 +__FLAGS_TYPE_FLOAT=2 +__FLAGS_TYPE_INTEGER=3 +__FLAGS_TYPE_STRING=4 + +# set the constants readonly +__flags_constants=`set |awk -F= '/^FLAGS_/ || /^__FLAGS_/ {print $1}'` +for __flags_const in ${__flags_constants}; do + # skip certain flags + case ${__flags_const} in + FLAGS_HELP) continue ;; + FLAGS_PARENT) continue ;; + esac + # set flag readonly + if [ -z "${ZSH_VERSION:-}" ]; then + readonly ${__flags_const} + else # handle zsh + case ${ZSH_VERSION} in + [123].*) readonly ${__flags_const} ;; + *) readonly -g ${__flags_const} ;; # declare readonly constants globally + esac + fi +done +unset __flags_const __flags_constants + +# +# internal variables +# + +# space separated lists +__flags_boolNames=' ' # boolean flag names +__flags_longNames=' ' # long flag names +__flags_shortNames=' ' # short flag names +__flags_definedNames=' ' # defined flag names (used for validation) + +__flags_columns='' # screen width in columns +__flags_opts='' # temporary storage for parsed getopt flags + +#------------------------------------------------------------------------------ +# private functions +# + +# logging functions +_flags_debug() { echo "flags:DEBUG $@" >&2; } +_flags_warn() { echo "flags:WARN $@" >&2; } +_flags_error() { echo "flags:ERROR $@" >&2; } +_flags_fatal() { echo "flags:FATAL $@" >&2; exit ${FLAGS_ERROR}; } + +# Define a flag. +# +# Calling this function will define the following info variables for the +# specified flag: +# FLAGS_flagname - the name for this flag (based upon the long flag name) +# __flags__default - the default value +# __flags_flagname_help - the help string +# __flags_flagname_short - the single letter alias +# __flags_flagname_type - the type of flag (one of __FLAGS_TYPE_*) +# +# Args: +# _flags__type: integer: internal type of flag (__FLAGS_TYPE_*) +# _flags__name: string: long flag name +# _flags__default: default flag value +# _flags__help: string: help string +# _flags__short: string: (optional) short flag name +# Returns: +# integer: success of operation, or error +_flags_define() +{ + if [ $# -lt 4 ]; then + flags_error='DEFINE error: too few arguments' + flags_return=${FLAGS_ERROR} + _flags_error "${flags_error}" + return ${flags_return} + fi + + _flags_type_=$1 + _flags_name_=$2 + _flags_default_=$3 + _flags_help_=$4 + _flags_short_=${5:-${__FLAGS_NULL}} + + _flags_return_=${FLAGS_TRUE} + _flags_usName_=`_flags_underscoreName ${_flags_name_}` + + # check whether the flag name is reserved + _flags_itemInList ${_flags_usName_} "${__FLAGS_RESERVED_LIST}" + if [ $? -eq ${FLAGS_TRUE} ]; then + flags_error="flag name (${_flags_name_}) is reserved" + _flags_return_=${FLAGS_ERROR} + fi + + # require short option for getopt that don't support long options + if [ ${_flags_return_} -eq ${FLAGS_TRUE} \ + -a ${__FLAGS_GETOPT_VERS} -ne ${__FLAGS_GETOPT_VERS_ENH} \ + -a "${_flags_short_}" = "${__FLAGS_NULL}" ] + then + flags_error="short flag required for (${_flags_name_}) on this platform" + _flags_return_=${FLAGS_ERROR} + fi + + # check for existing long name definition + if [ ${_flags_return_} -eq ${FLAGS_TRUE} ]; then + if _flags_itemInList ${_flags_usName_} ${__flags_definedNames}; then + flags_error="definition for ([no]${_flags_name_}) already exists" + _flags_warn "${flags_error}" + _flags_return_=${FLAGS_FALSE} + fi + fi + + # check for existing short name definition + if [ ${_flags_return_} -eq ${FLAGS_TRUE} \ + -a "${_flags_short_}" != "${__FLAGS_NULL}" ] + then + if _flags_itemInList "${_flags_short_}" ${__flags_shortNames}; then + flags_error="flag short name (${_flags_short_}) already defined" + _flags_warn "${flags_error}" + _flags_return_=${FLAGS_FALSE} + fi + fi + + # handle default value. note, on several occasions the 'if' portion of an + # if/then/else contains just a ':' which does nothing. a binary reversal via + # '!' is not done because it does not work on all shells. + if [ ${_flags_return_} -eq ${FLAGS_TRUE} ]; then + case ${_flags_type_} in + ${__FLAGS_TYPE_BOOLEAN}) + if _flags_validBool "${_flags_default_}"; then + case ${_flags_default_} in + true|t|0) _flags_default_=${FLAGS_TRUE} ;; + false|f|1) _flags_default_=${FLAGS_FALSE} ;; + esac + else + flags_error="invalid default flag value '${_flags_default_}'" + _flags_return_=${FLAGS_ERROR} + fi + ;; + + ${__FLAGS_TYPE_FLOAT}) + if _flags_validFloat "${_flags_default_}"; then + : + else + flags_error="invalid default flag value '${_flags_default_}'" + _flags_return_=${FLAGS_ERROR} + fi + ;; + + ${__FLAGS_TYPE_INTEGER}) + if _flags_validInt "${_flags_default_}"; then + : + else + flags_error="invalid default flag value '${_flags_default_}'" + _flags_return_=${FLAGS_ERROR} + fi + ;; + + ${__FLAGS_TYPE_STRING}) ;; # everything in shell is a valid string + + *) + flags_error="unrecognized flag type '${_flags_type_}'" + _flags_return_=${FLAGS_ERROR} + ;; + esac + fi + + if [ ${_flags_return_} -eq ${FLAGS_TRUE} ]; then + # store flag information + eval "FLAGS_${_flags_usName_}='${_flags_default_}'" + eval "__flags_${_flags_usName_}_${__FLAGS_INFO_TYPE}=${_flags_type_}" + eval "__flags_${_flags_usName_}_${__FLAGS_INFO_DEFAULT}=\ +\"${_flags_default_}\"" + eval "__flags_${_flags_usName_}_${__FLAGS_INFO_HELP}=\"${_flags_help_}\"" + eval "__flags_${_flags_usName_}_${__FLAGS_INFO_SHORT}='${_flags_short_}'" + + # append flag names to name lists + __flags_shortNames="${__flags_shortNames}${_flags_short_} " + __flags_longNames="${__flags_longNames}${_flags_name_} " + [ ${_flags_type_} -eq ${__FLAGS_TYPE_BOOLEAN} ] && \ + __flags_boolNames="${__flags_boolNames}no${_flags_name_} " + + # append flag names to defined names for later validation checks + __flags_definedNames="${__flags_definedNames}${_flags_usName_} " + [ ${_flags_type_} -eq ${__FLAGS_TYPE_BOOLEAN} ] && \ + __flags_definedNames="${__flags_definedNames}no${_flags_usName_} " + fi + + flags_return=${_flags_return_} + unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ \ + _flags_short_ _flags_type_ _flags_usName_ + [ ${flags_return} -eq ${FLAGS_ERROR} ] && _flags_error "${flags_error}" + return ${flags_return} +} + +# Underscore a flag name by replacing dashes with underscores. +# +# Args: +# unnamed: string: log flag name +# Output: +# string: underscored name +_flags_underscoreName() +{ + echo $1 |tr '-' '_' +} + +# Return valid getopt options using currently defined list of long options. +# +# This function builds a proper getopt option string for short (and long) +# options, using the current list of long options for reference. +# +# Args: +# _flags_optStr: integer: option string type (__FLAGS_OPTSTR_*) +# Output: +# string: generated option string for getopt +# Returns: +# boolean: success of operation (always returns True) +_flags_genOptStr() +{ + _flags_optStrType_=$1 + + _flags_opts_='' + + for _flags_name_ in ${__flags_longNames}; do + _flags_usName_=`_flags_underscoreName ${_flags_name_}` + _flags_type_=`_flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE}` + [ $? -eq ${FLAGS_TRUE} ] || _flags_fatal 'call to _flags_type_ failed' + case ${_flags_optStrType_} in + ${__FLAGS_OPTSTR_SHORT}) + _flags_shortName_=`_flags_getFlagInfo \ + ${_flags_usName_} ${__FLAGS_INFO_SHORT}` + if [ "${_flags_shortName_}" != "${__FLAGS_NULL}" ]; then + _flags_opts_="${_flags_opts_}${_flags_shortName_}" + # getopt needs a trailing ':' to indicate a required argument + [ ${_flags_type_} -ne ${__FLAGS_TYPE_BOOLEAN} ] && \ + _flags_opts_="${_flags_opts_}:" + fi + ;; + + ${__FLAGS_OPTSTR_LONG}) + _flags_opts_="${_flags_opts_:+${_flags_opts_},}${_flags_name_}" + # getopt needs a trailing ':' to indicate a required argument + [ ${_flags_type_} -ne ${__FLAGS_TYPE_BOOLEAN} ] && \ + _flags_opts_="${_flags_opts_}:" + ;; + esac + done + + echo "${_flags_opts_}" + unset _flags_name_ _flags_opts_ _flags_optStrType_ _flags_shortName_ \ + _flags_type_ _flags_usName_ + return ${FLAGS_TRUE} +} + +# Returns flag details based on a flag name and flag info. +# +# Args: +# string: underscored flag name +# string: flag info (see the _flags_define function for valid info types) +# Output: +# string: value of dereferenced flag variable +# Returns: +# integer: one of FLAGS_{TRUE|FALSE|ERROR} +_flags_getFlagInfo() +{ + # note: adding gFI to variable names to prevent naming conflicts with calling + # functions + _flags_gFI_usName_=$1 + _flags_gFI_info_=$2 + + _flags_infoVar_="__flags_${_flags_gFI_usName_}_${_flags_gFI_info_}" + _flags_strToEval_="_flags_infoValue_=\"\${${_flags_infoVar_}:-}\"" + eval "${_flags_strToEval_}" + if [ -n "${_flags_infoValue_}" ]; then + flags_return=${FLAGS_TRUE} + else + # see if the _flags_gFI_usName_ variable is a string as strings can be + # empty... + # note: the DRY principle would say to have this function call itself for + # the next three lines, but doing so results in an infinite loop as an + # invalid _flags_name_ will also not have the associated _type variable. + # Because it doesn't (it will evaluate to an empty string) the logic will + # try to find the _type variable of the _type variable, and so on. Not so + # good ;-) + _flags_typeVar_="__flags_${_flags_gFI_usName_}_${__FLAGS_INFO_TYPE}" + _flags_strToEval_="_flags_typeValue_=\"\${${_flags_typeVar_}:-}\"" + eval "${_flags_strToEval_}" + if [ "${_flags_typeValue_}" = "${__FLAGS_TYPE_STRING}" ]; then + flags_return=${FLAGS_TRUE} + else + flags_return=${FLAGS_ERROR} + flags_error="missing flag info variable (${_flags_infoVar_})" + fi + fi + + echo "${_flags_infoValue_}" + unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ \ + _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ + [ ${flags_return} -eq ${FLAGS_ERROR} ] && _flags_error "${flags_error}" + return ${flags_return} +} + +# Check for presense of item in a list. +# +# Passed a string (e.g. 'abc'), this function will determine if the string is +# present in the list of strings (e.g. ' foo bar abc '). +# +# Args: +# _flags_str_: string: string to search for in a list of strings +# unnamed: list: list of strings +# Returns: +# boolean: true if item is in the list +_flags_itemInList() { + _flags_str_=$1 + shift + + echo " ${*:-} " |grep " ${_flags_str_} " >/dev/null + if [ $? -eq 0 ]; then + flags_return=${FLAGS_TRUE} + else + flags_return=${FLAGS_FALSE} + fi + + unset _flags_str_ + return ${flags_return} +} + +# Returns the width of the current screen. +# +# Output: +# integer: width in columns of the current screen. +_flags_columns() +{ + if [ -z "${__flags_columns}" ]; then + # determine the value and store it + if eval stty size >/dev/null 2>&1; then + # stty size worked :-) + set -- `stty size` + __flags_columns=$2 + elif eval tput cols >/dev/null 2>&1; then + set -- `tput cols` + __flags_columns=$1 + else + __flags_columns=80 # default terminal width + fi + fi + echo ${__flags_columns} +} + +# Validate a boolean. +# +# Args: +# _flags__bool: boolean: value to validate +# Returns: +# bool: true if the value is a valid boolean +_flags_validBool() +{ + _flags_bool_=$1 + + flags_return=${FLAGS_TRUE} + case "${_flags_bool_}" in + true|t|0) ;; + false|f|1) ;; + *) flags_return=${FLAGS_FALSE} ;; + esac + + unset _flags_bool_ + return ${flags_return} +} + +# Validate a float. +# +# Args: +# _flags_float_: float: value to validate +# Returns: +# bool: true if the value is a valid integer +_flags_validFloat() +{ + flags_return=${FLAGS_FALSE} + [ -n "$1" ] || return ${flags_return} + _flags_float_=$1 + + if _flags_validInt ${_flags_float_}; then + flags_return=${FLAGS_TRUE} + elif _flags_useBuiltin; then + _flags_float_whole_=${_flags_float_%.*} + _flags_float_fraction_=${_flags_float_#*.} + if _flags_validInt ${_flags_float_whole_:-0} -a \ + _flags_validInt ${_flags_float_fraction_}; then + flags_return=${FLAGS_TRUE} + fi + unset _flags_float_whole_ _flags_float_fraction_ + else + flags_return=${FLAGS_TRUE} + case ${_flags_float_} in + -*) # negative floats + _flags_test_=`${FLAGS_EXPR_CMD} -- "${_flags_float_}" :\ + '\(-[0-9]*\.[0-9]*\)'` + ;; + *) # positive floats + _flags_test_=`${FLAGS_EXPR_CMD} -- "${_flags_float_}" :\ + '\([0-9]*\.[0-9]*\)'` + ;; + esac + [ "${_flags_test_}" != "${_flags_float_}" ] && flags_return=${FLAGS_FALSE} + unset _flags_test_ + fi + + unset _flags_float_ _flags_float_whole_ _flags_float_fraction_ + return ${flags_return} +} + +# Validate an integer. +# +# Args: +# _flags_int_: integer: value to validate +# Returns: +# bool: true if the value is a valid integer +_flags_validInt() +{ + flags_return=${FLAGS_FALSE} + [ -n "$1" ] || return ${flags_return} + _flags_int_=$1 + + case ${_flags_int_} in + -*.*) ;; # ignore negative floats (we'll invalidate them later) + -*) # strip possible leading negative sign + if _flags_useBuiltin; then + _flags_int_=${_flags_int_#-} + else + _flags_int_=`${FLAGS_EXPR_CMD} -- "${_flags_int_}" : '-\([0-9][0-9]*\)'` + fi + ;; + esac + + case ${_flags_int_} in + *[!0-9]*) flags_return=${FLAGS_FALSE} ;; + *) flags_return=${FLAGS_TRUE} ;; + esac + + unset _flags_int_ + return ${flags_return} +} + +# Parse command-line options using the standard getopt. +# +# Note: the flag options are passed around in the global __flags_opts so that +# the formatting is not lost due to shell parsing and such. +# +# Args: +# @: varies: command-line options to parse +# Returns: +# integer: a FLAGS success condition +_flags_getoptStandard() +{ + flags_return=${FLAGS_TRUE} + _flags_shortOpts_=`_flags_genOptStr ${__FLAGS_OPTSTR_SHORT}` + + # check for spaces in passed options + for _flags_opt_ in "$@"; do + # note: the silliness with the x's is purely for ksh93 on Ubuntu 6.06 + _flags_match_=`echo "x${_flags_opt_}x" |sed 's/ //g'` + if [ "${_flags_match_}" != "x${_flags_opt_}x" ]; then + flags_error='the available getopt does not support spaces in options' + flags_return=${FLAGS_ERROR} + break + fi + done + + if [ ${flags_return} -eq ${FLAGS_TRUE} ]; then + __flags_opts=`getopt ${_flags_shortOpts_} $@ 2>&1` + _flags_rtrn_=$? + if [ ${_flags_rtrn_} -ne ${FLAGS_TRUE} ]; then + _flags_warn "${__flags_opts}" + flags_error='unable to parse provided options with getopt.' + flags_return=${FLAGS_ERROR} + fi + fi + + unset _flags_match_ _flags_opt_ _flags_rtrn_ _flags_shortOpts_ + return ${flags_return} +} + +# Parse command-line options using the enhanced getopt. +# +# Note: the flag options are passed around in the global __flags_opts so that +# the formatting is not lost due to shell parsing and such. +# +# Args: +# @: varies: command-line options to parse +# Returns: +# integer: a FLAGS success condition +_flags_getoptEnhanced() +{ + flags_return=${FLAGS_TRUE} + _flags_shortOpts_=`_flags_genOptStr ${__FLAGS_OPTSTR_SHORT}` + _flags_boolOpts_=`echo "${__flags_boolNames}" \ + |sed 's/^ *//;s/ *$//;s/ /,/g'` + _flags_longOpts_=`_flags_genOptStr ${__FLAGS_OPTSTR_LONG}` + + __flags_opts=`${FLAGS_GETOPT_CMD} \ + -o ${_flags_shortOpts_} \ + -l "${_flags_longOpts_},${_flags_boolOpts_}" \ + -- "$@" 2>&1` + _flags_rtrn_=$? + if [ ${_flags_rtrn_} -ne ${FLAGS_TRUE} ]; then + _flags_warn "${__flags_opts}" + flags_error='unable to parse provided options with getopt.' + flags_return=${FLAGS_ERROR} + fi + + unset _flags_boolOpts_ _flags_longOpts_ _flags_rtrn_ _flags_shortOpts_ + return ${flags_return} +} + +# Dynamically parse a getopt result and set appropriate variables. +# +# This function does the actual conversion of getopt output and runs it through +# the standard case structure for parsing. The case structure is actually quite +# dynamic to support any number of flags. +# +# Args: +# argc: int: original command-line argument count +# @: varies: output from getopt parsing +# Returns: +# integer: a FLAGS success condition +_flags_parseGetopt() +{ + _flags_argc_=$1 + shift + + flags_return=${FLAGS_TRUE} + + if [ ${__FLAGS_GETOPT_VERS} -ne ${__FLAGS_GETOPT_VERS_ENH} ]; then + set -- $@ + else + # note the quotes around the `$@' -- they are essential! + eval set -- "$@" + fi + + # Provide user with the number of arguments to shift by later. + # NOTE: the FLAGS_ARGC variable is obsolete as of 1.0.3 because it does not + # properly give user access to non-flag arguments mixed in between flag + # arguments. Its usage was replaced by FLAGS_ARGV, and it is being kept only + # for backwards compatibility reasons. + FLAGS_ARGC=`_flags_math "$# - 1 - ${_flags_argc_}"` + + # handle options. note options with values must do an additional shift + while true; do + _flags_opt_=$1 + _flags_arg_=${2:-} + _flags_type_=${__FLAGS_TYPE_NONE} + _flags_name_='' + + # determine long flag name + case "${_flags_opt_}" in + --) shift; break ;; # discontinue option parsing + + --*) # long option + if _flags_useBuiltin; then + _flags_opt_=${_flags_opt_#*--} + else + _flags_opt_=`${FLAGS_EXPR_CMD} -- "${_flags_opt_}" : '--\(.*\)'` + fi + _flags_len_=${__FLAGS_LEN_LONG} + if _flags_itemInList "${_flags_opt_}" ${__flags_longNames}; then + _flags_name_=${_flags_opt_} + else + # check for negated long boolean version + if _flags_itemInList "${_flags_opt_}" ${__flags_boolNames}; then + if _flags_useBuiltin; then + _flags_name_=${_flags_opt_#*no} + else + _flags_name_=`${FLAGS_EXPR_CMD} -- "${_flags_opt_}" : 'no\(.*\)'` + fi + _flags_type_=${__FLAGS_TYPE_BOOLEAN} + _flags_arg_=${__FLAGS_NULL} + fi + fi + ;; + + -*) # short option + if _flags_useBuiltin; then + _flags_opt_=${_flags_opt_#*-} + else + _flags_opt_=`${FLAGS_EXPR_CMD} -- "${_flags_opt_}" : '-\(.*\)'` + fi + _flags_len_=${__FLAGS_LEN_SHORT} + if _flags_itemInList "${_flags_opt_}" ${__flags_shortNames}; then + # yes. match short name to long name. note purposeful off-by-one + # (too high) with awk calculations. + _flags_pos_=`echo "${__flags_shortNames}" \ + |awk 'BEGIN{RS=" ";rn=0}$0==e{rn=NR}END{print rn}' \ + e=${_flags_opt_}` + _flags_name_=`echo "${__flags_longNames}" \ + |awk 'BEGIN{RS=" "}rn==NR{print $0}' rn="${_flags_pos_}"` + fi + ;; + esac + + # die if the flag was unrecognized + if [ -z "${_flags_name_}" ]; then + flags_error="unrecognized option (${_flags_opt_})" + flags_return=${FLAGS_ERROR} + break + fi + + # set new flag value + _flags_usName_=`_flags_underscoreName ${_flags_name_}` + [ ${_flags_type_} -eq ${__FLAGS_TYPE_NONE} ] && \ + _flags_type_=`_flags_getFlagInfo \ + "${_flags_usName_}" ${__FLAGS_INFO_TYPE}` + case ${_flags_type_} in + ${__FLAGS_TYPE_BOOLEAN}) + if [ ${_flags_len_} -eq ${__FLAGS_LEN_LONG} ]; then + if [ "${_flags_arg_}" != "${__FLAGS_NULL}" ]; then + eval "FLAGS_${_flags_usName_}=${FLAGS_TRUE}" + else + eval "FLAGS_${_flags_usName_}=${FLAGS_FALSE}" + fi + else + _flags_strToEval_="_flags_val_=\ +\${__flags_${_flags_usName_}_${__FLAGS_INFO_DEFAULT}}" + eval "${_flags_strToEval_}" + if [ ${_flags_val_} -eq ${FLAGS_FALSE} ]; then + eval "FLAGS_${_flags_usName_}=${FLAGS_TRUE}" + else + eval "FLAGS_${_flags_usName_}=${FLAGS_FALSE}" + fi + fi + ;; + + ${__FLAGS_TYPE_FLOAT}) + if _flags_validFloat "${_flags_arg_}"; then + eval "FLAGS_${_flags_usName_}='${_flags_arg_}'" + else + flags_error="invalid float value (${_flags_arg_})" + flags_return=${FLAGS_ERROR} + break + fi + ;; + + ${__FLAGS_TYPE_INTEGER}) + if _flags_validInt "${_flags_arg_}"; then + eval "FLAGS_${_flags_usName_}='${_flags_arg_}'" + else + flags_error="invalid integer value (${_flags_arg_})" + flags_return=${FLAGS_ERROR} + break + fi + ;; + + ${__FLAGS_TYPE_STRING}) + eval "FLAGS_${_flags_usName_}='${_flags_arg_}'" + ;; + esac + + # handle special case help flag + if [ "${_flags_usName_}" = 'help' ]; then + if [ ${FLAGS_help} -eq ${FLAGS_TRUE} ]; then + flags_help + flags_error='help requested' + flags_return=${FLAGS_TRUE} + break + fi + fi + + # shift the option and non-boolean arguements out. + shift + [ ${_flags_type_} != ${__FLAGS_TYPE_BOOLEAN} ] && shift + done + + # give user back non-flag arguments + FLAGS_ARGV='' + while [ $# -gt 0 ]; do + FLAGS_ARGV="${FLAGS_ARGV:+${FLAGS_ARGV} }'$1'" + shift + done + + unset _flags_arg_ _flags_len_ _flags_name_ _flags_opt_ _flags_pos_ \ + _flags_strToEval_ _flags_type_ _flags_usName_ _flags_val_ + return ${flags_return} +} + +# Perform some path using built-ins. +# +# Args: +# $@: string: math expression to evaluate +# Output: +# integer: the result +# Returns: +# bool: success of math evaluation +_flags_math() +{ + if [ $# -eq 0 ]; then + flags_return=${FLAGS_FALSE} + elif _flags_useBuiltin; then + # Variable assignment is needed as workaround for Solaris Bourne shell, + # which cannot parse a bare $((expression)). + _flags_expr_='$(($@))' + eval echo ${_flags_expr_} + flags_return=$? + unset _flags_expr_ + else + eval expr $@ + flags_return=$? + fi + + return ${flags_return} +} + +# Cross-platform strlen() implementation. +# +# Args: +# _flags_str: string: to determine length of +# Output: +# integer: length of string +# Returns: +# bool: success of strlen evaluation +_flags_strlen() +{ + _flags_str_=${1:-} + + if [ -z "${_flags_str_}" ]; then + flags_output=0 + elif _flags_useBuiltin; then + flags_output=${#_flags_str_} + else + flags_output=`${FLAGS_EXPR_CMD} -- "${_flags_str_}" : '.*'` + fi + flags_return=$? + + unset _flags_str_ + echo ${flags_output} + return ${flags_return} +} + +# Use built-in helper function to enable unit testing. +# +# Args: +# None +# Returns: +# bool: true if built-ins should be used +_flags_useBuiltin() +{ + return ${__FLAGS_USE_BUILTIN} +} + +#------------------------------------------------------------------------------ +# public functions +# +# A basic boolean flag. Boolean flags do not take any arguments, and their +# value is either 1 (false) or 0 (true). For long flags, the false value is +# specified on the command line by prepending the word 'no'. With short flags, +# the presense of the flag toggles the current value between true and false. +# Specifying a short boolean flag twice on the command results in returning the +# value back to the default value. +# +# A default value is required for boolean flags. +# +# For example, lets say a Boolean flag was created whose long name was 'update' +# and whose short name was 'x', and the default value was 'false'. This flag +# could be explicitly set to 'true' with '--update' or by '-x', and it could be +# explicitly set to 'false' with '--noupdate'. +DEFINE_boolean() { _flags_define ${__FLAGS_TYPE_BOOLEAN} "$@"; } + +# Other basic flags. +DEFINE_float() { _flags_define ${__FLAGS_TYPE_FLOAT} "$@"; } +DEFINE_integer() { _flags_define ${__FLAGS_TYPE_INTEGER} "$@"; } +DEFINE_string() { _flags_define ${__FLAGS_TYPE_STRING} "$@"; } + +# Parse the flags. +# +# Args: +# unnamed: list: command-line flags to parse +# Returns: +# integer: success of operation, or error +FLAGS() +{ + # define a standard 'help' flag if one isn't already defined + [ -z "${__flags_help_type:-}" ] && \ + DEFINE_boolean 'help' false 'show this help' 'h' + + # parse options + if [ $# -gt 0 ]; then + if [ ${__FLAGS_GETOPT_VERS} -ne ${__FLAGS_GETOPT_VERS_ENH} ]; then + _flags_getoptStandard "$@" + else + _flags_getoptEnhanced "$@" + fi + flags_return=$? + else + # nothing passed; won't bother running getopt + __flags_opts='--' + flags_return=${FLAGS_TRUE} + fi + + if [ ${flags_return} -eq ${FLAGS_TRUE} ]; then + _flags_parseGetopt $# "${__flags_opts}" + flags_return=$? + fi + + [ ${flags_return} -eq ${FLAGS_ERROR} ] && _flags_fatal "${flags_error}" + return ${flags_return} +} + +# This is a helper function for determining the 'getopt' version for platforms +# where the detection isn't working. It simply outputs debug information that +# can be included in a bug report. +# +# Args: +# none +# Output: +# debug info that can be included in a bug report +# Returns: +# nothing +flags_getoptInfo() +{ + # platform info + _flags_debug "uname -a: `uname -a`" + _flags_debug "PATH: ${PATH}" + + # shell info + if [ -n "${BASH_VERSION:-}" ]; then + _flags_debug 'shell: bash' + _flags_debug "BASH_VERSION: ${BASH_VERSION}" + elif [ -n "${ZSH_VERSION:-}" ]; then + _flags_debug 'shell: zsh' + _flags_debug "ZSH_VERSION: ${ZSH_VERSION}" + fi + + # getopt info + ${FLAGS_GETOPT_CMD} >/dev/null + _flags_getoptReturn=$? + _flags_debug "getopt return: ${_flags_getoptReturn}" + _flags_debug "getopt --version: `${FLAGS_GETOPT_CMD} --version 2>&1`" + + unset _flags_getoptReturn +} + +# Returns whether the detected getopt version is the enhanced version. +# +# Args: +# none +# Output: +# none +# Returns: +# bool: true if getopt is the enhanced version +flags_getoptIsEnh() +{ + test ${__FLAGS_GETOPT_VERS} -eq ${__FLAGS_GETOPT_VERS_ENH} +} + +# Returns whether the detected getopt version is the standard version. +# +# Args: +# none +# Returns: +# bool: true if getopt is the standard version +flags_getoptIsStd() +{ + test ${__FLAGS_GETOPT_VERS} -eq ${__FLAGS_GETOPT_VERS_STD} +} + +# This is effectively a 'usage()' function. It prints usage information and +# exits the program with ${FLAGS_FALSE} if it is ever found in the command line +# arguments. Note this function can be overridden so other apps can define +# their own --help flag, replacing this one, if they want. +# +# Args: +# none +# Returns: +# integer: success of operation (always returns true) +flags_help() +{ + if [ -n "${FLAGS_HELP:-}" ]; then + echo "${FLAGS_HELP}" >&2 + else + echo "USAGE: ${FLAGS_PARENT:-$0} [flags] args" >&2 + fi + if [ -n "${__flags_longNames}" ]; then + echo 'flags:' >&2 + for flags_name_ in ${__flags_longNames}; do + flags_flagStr_='' + flags_boolStr_='' + flags_usName_=`_flags_underscoreName ${flags_name_}` + + flags_default_=`_flags_getFlagInfo \ + "${flags_usName_}" ${__FLAGS_INFO_DEFAULT}` + flags_help_=`_flags_getFlagInfo \ + "${flags_usName_}" ${__FLAGS_INFO_HELP}` + flags_short_=`_flags_getFlagInfo \ + "${flags_usName_}" ${__FLAGS_INFO_SHORT}` + flags_type_=`_flags_getFlagInfo \ + "${flags_usName_}" ${__FLAGS_INFO_TYPE}` + + [ "${flags_short_}" != "${__FLAGS_NULL}" ] && \ + flags_flagStr_="-${flags_short_}" + + if [ ${__FLAGS_GETOPT_VERS} -eq ${__FLAGS_GETOPT_VERS_ENH} ]; then + [ "${flags_short_}" != "${__FLAGS_NULL}" ] && \ + flags_flagStr_="${flags_flagStr_}," + # add [no] to long boolean flag names, except the 'help' flag + [ ${flags_type_} -eq ${__FLAGS_TYPE_BOOLEAN} \ + -a "${flags_usName_}" != 'help' ] && \ + flags_boolStr_='[no]' + flags_flagStr_="${flags_flagStr_}--${flags_boolStr_}${flags_name_}:" + fi + + case ${flags_type_} in + ${__FLAGS_TYPE_BOOLEAN}) + if [ ${flags_default_} -eq ${FLAGS_TRUE} ]; then + flags_defaultStr_='true' + else + flags_defaultStr_='false' + fi + ;; + ${__FLAGS_TYPE_FLOAT}|${__FLAGS_TYPE_INTEGER}) + flags_defaultStr_=${flags_default_} ;; + ${__FLAGS_TYPE_STRING}) flags_defaultStr_="'${flags_default_}'" ;; + esac + flags_defaultStr_="(default: ${flags_defaultStr_})" + + flags_helpStr_=" ${flags_flagStr_} ${flags_help_} ${flags_defaultStr_}" + _flags_strlen "${flags_helpStr_}" >/dev/null + flags_helpStrLen_=${flags_output} + flags_columns_=`_flags_columns` + + if [ ${flags_helpStrLen_} -lt ${flags_columns_} ]; then + echo "${flags_helpStr_}" >&2 + else + echo " ${flags_flagStr_} ${flags_help_}" >&2 + # note: the silliness with the x's is purely for ksh93 on Ubuntu 6.06 + # because it doesn't like empty strings when used in this manner. + flags_emptyStr_="`echo \"x${flags_flagStr_}x\" \ + |awk '{printf "%"length($0)-2"s", ""}'`" + flags_helpStr_=" ${flags_emptyStr_} ${flags_defaultStr_}" + _flags_strlen "${flags_helpStr_}" >/dev/null + flags_helpStrLen_=${flags_output} + + if [ ${__FLAGS_GETOPT_VERS} -eq ${__FLAGS_GETOPT_VERS_STD} \ + -o ${flags_helpStrLen_} -lt ${flags_columns_} ]; then + # indented to match help string + echo "${flags_helpStr_}" >&2 + else + # indented four from left to allow for longer defaults as long flag + # names might be used too, making things too long + echo " ${flags_defaultStr_}" >&2 + fi + fi + done + fi + + unset flags_boolStr_ flags_default_ flags_defaultStr_ flags_emptyStr_ \ + flags_flagStr_ flags_help_ flags_helpStr flags_helpStrLen flags_name_ \ + flags_columns_ flags_short_ flags_type_ flags_usName_ + return ${FLAGS_TRUE} +} + +# Reset shflags back to an uninitialized state. +# +# Args: +# none +# Returns: +# nothing +flags_reset() +{ + for flags_name_ in ${__flags_longNames}; do + flags_usName_=`_flags_underscoreName ${flags_name_}` + flags_strToEval_="unset FLAGS_${flags_usName_}" + for flags_type_ in \ + ${__FLAGS_INFO_DEFAULT} \ + ${__FLAGS_INFO_HELP} \ + ${__FLAGS_INFO_SHORT} \ + ${__FLAGS_INFO_TYPE} + do + flags_strToEval_=\ +"${flags_strToEval_} __flags_${flags_usName_}_${flags_type_}" + done + eval ${flags_strToEval_} + done + + # reset internal variables + __flags_boolNames=' ' + __flags_longNames=' ' + __flags_shortNames=' ' + __flags_definedNames=' ' + + unset flags_name_ flags_type_ flags_strToEval_ flags_usName_ +} diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/lib/shlib b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/lib/shlib new file mode 100644 index 0000000..a843043 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/lib/shlib @@ -0,0 +1,39 @@ +# vim:et:ft=sh:sts=2:sw=2 +# +# Copyright 2008 Kate Ward. All Rights Reserved. +# Released under the LGPL (GNU Lesser General Public License). +# +# Author: kate.ward@forestent.com (Kate Ward) +# +# Library of shell functions. + +# Convert a relative path into it's absolute equivalent. +# +# This function will automatically prepend the current working directory if the +# path is not already absolute. It then removes all parent references (../) to +# reconstruct the proper absolute path. +# +# Args: +# shlib_path_: string: relative path +# Outputs: +# string: absolute path +shlib_relToAbsPath() +{ + shlib_path_=$1 + + # prepend current directory to relative paths + echo "${shlib_path_}" |grep '^/' >/dev/null 2>&1 \ + || shlib_path_="${PWD}/${shlib_path_}" + + # clean up the path. if all seds supported true regular expressions, then + # this is what it would be: + shlib_old_=${shlib_path_} + while true; do + shlib_new_=`echo "${shlib_old_}" |sed 's/[^/]*\/\.\.\/*//;s/\/\.\//\//'` + [ "${shlib_old_}" = "${shlib_new_}" ] && break + shlib_old_=${shlib_new_} + done + echo "${shlib_new_}" + + unset shlib_path_ shlib_old_ shlib_new_ +} diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/lib/versions b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/lib/versions new file mode 100755 index 0000000..e03f4f4 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/lib/versions @@ -0,0 +1,239 @@ +#! /bin/sh +# $Id: versions 175 2013-01-14 22:16:01Z kate.ward@forestent.com $ +# vim:et:ft=sh:sts=2:sw=2 +# +# Copyright 2008 Kate Ward. All Rights Reserved. +# Released under the LGPL (GNU Lesser General Public License) +# +# Author: kate.ward@forestent.com (Kate Ward) +# +# This library provides reusable functions that determine actual names and +# versions of installed shells and the OS. The library can also be run as a +# script if set execuatable. + +ARGV0=`basename "$0"` +LSB_RELEASE='/etc/lsb-release' +VERSIONS_SHELLS="/bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/sh /bin/zsh" + +TRUE=0 +FALSE=1 +ERROR=2 + +UNAME_R=`uname -r` +UNAME_S=`uname -s` + +__versions_haveStrings=${ERROR} + +#------------------------------------------------------------------------------ +# functions +# + +versions_osName() +{ + os_name_='unrecognized' + os_system_=${UNAME_S} + case ${os_system_} in + CYGWIN_NT-*) os_name_='Cygwin' ;; + Darwin) os_name_='Mac OS X' ;; + FreeBSD) os_name_='FreeBSD' ;; + Linux) os_name_='Linux' ;; + SunOS) + if grep 'OpenSolaris' /etc/release >/dev/null; then + os_name_='OpenSolaris' + else + os_name_='Solaris' + fi + ;; + esac + + echo ${os_name_} + unset os_name_ os_system_ +} + +versions_osVersion() +{ + os_version_='unrecognized' + os_system_=${UNAME_S} + os_release_=${UNAME_R} + case ${os_system_} in + CYGWIN_NT-*) + os_version_=`expr "${os_release_}" : '\([0-9]*\.[0-9]\.[0-9]*\).*'` + ;; + Darwin) + major_='10' + sub_=`echo ${os_release_} |sed 's/^[0-9]*\.\([0-9]*\)\.[0-9]*$/\1/'` + case ${os_release_} in + 8.*) minor_='4' ;; + 9.*) minor_='5' ;; + 10.*) minor_='6' ;; + 11.*) minor_='7' ;; + 12.*) minor_='8' ;; + *) minor_='X'; sub_='X' ;; + esac + os_version_="${major_}.${minor_}.${sub_}" + ;; + FreeBSD) + os_version_=`expr "${os_release_}" : '\([0-9]*\.[0-9]*\)-.*'` + ;; + Linux) + if [ -r "${LSB_RELEASE}" ]; then + if grep -q 'DISTRIB_ID=Ubuntu' "${LSB_RELEASE}"; then + os_version_=`cat "${LSB_RELEASE}" \ + |awk -F= '$1~/DISTRIB_DESCRIPTION/{print $2}' \ + |sed 's/"//g;s/ /-/g'` + fi + elif [ -r '/etc/redhat-release' ]; then + os_version_=`cat /etc/redhat-release` + fi + ;; + SunOS) + if grep 'OpenSolaris' /etc/release >/dev/null; then + os_version_=`grep 'OpenSolaris' /etc/release |awk '{print $2"("$3")"}'` + else + major_=`echo ${os_release_} |sed 's/[0-9]*\.\([0-9]*\)/\1/'` + minor_=`grep Solaris /etc/release |sed 's/[^u]*\(u[0-9]*\).*/\1/'` + os_version_="${major_}${minor_}" + fi + ;; + esac + + echo ${os_version_} + unset os_name_ os_release_ os_version_ major_ minor_ sub_ +} + +versions_shellVersion() +{ + shell_=$1 + + if [ ! -x "${shell_}" ]; then + echo 'not installed' + return + fi + + version_='' + case ${shell_} in + */sh) + # TODO(kward): fix this + ## this could be one of any number of shells. try until one fits. + #version_=`versions_shell_bash ${shell_}` + ## dash cannot be self determined yet + #[ -z "${version_}" ] && version_=`versions_shell_ksh ${shell_}` + ## pdksh is covered in versions_shell_ksh() + #[ -z "${version_}" ] && version_=`versions_shell_zsh ${shell_}` + ;; + */bash) version_=`versions_shell_bash ${shell_}` ;; + */dash) + # simply assuming Ubuntu Linux until somebody comes up with a better + # test. the following test will return an empty string if dash is not + # installed. + version_=`versions_shell_dash` + ;; + */ksh) version_=`versions_shell_ksh ${shell_}` ;; + */pdksh) version_=`versions_shell_pdksh ${shell_}` ;; + */zsh) version_=`versions_shell_zsh ${shell_}` ;; + *) version_='invalid' + esac + + echo ${version_:-unknown} + unset shell_ version_ +} + +versions_shell_bash() +{ + $1 --version 2>&1 |grep 'GNU bash' |sed 's/.*version \([^ ]*\).*/\1/' +} + +versions_shell_dash() +{ + eval dpkg >/dev/null 2>&1 + [ $? -eq 127 ] && return # return if dpkg not found + + dpkg -l |grep ' dash ' |awk '{print $3}' +} + +versions_shell_ksh() +{ + versions_shell_=$1 + + # try a few different ways to figure out the version + versions_version_=`${versions_shell_} --version : 2>&1` + if [ $? -eq 0 ]; then + versions_version_=`echo "${versions_version_}" \ + |sed 's/.*\([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\).*/\1/'` + else + versions_version_='' + fi + + if [ -z "${versions_version_}" ]; then + _versions_have_strings + versions_version_=`strings ${versions_shell_} 2>&1 \ + |grep Version \ + |sed 's/^.*Version \(.*\)$/\1/;s/ s+ \$$//;s/ /-/g'` + fi + + if [ -z "${versions_version_}" ]; then + versions_version_=`versions_shell_pdksh ${versions_shell_}` + fi + + echo ${versions_version_} + unset versions_shell_ versions_version_ +} + +versions_shell_pdksh() +{ + _versions_have_strings + strings $1 2>&1 \ + |grep 'PD KSH' \ + |sed -e 's/.*PD KSH \(.*\)/\1/;s/ /-/g' +} + +versions_shell_zsh() +{ + versions_shell_=$1 + + # try a few different ways to figure out the version + versions_version_=`echo 'echo ${ZSH_VERSION}' |${versions_shell_}` + + if [ -z "${versions_version_}" ]; then + versions_version_=`${versions_shell_} --version 2>&1 |awk '{print $2}'` + fi + + echo ${versions_version_} + unset versions_shell_ versions_version_ +} + +# Determine if the 'strings' binary installed. +_versions_have_strings() +{ + [ ${__versions_haveStrings} -ne ${ERROR} ] && return + eval strings /dev/null >/dev/null 2>&1 + if [ $? -eq 0 ]; then + __versions_haveStrings=${TRUE} + else + echo 'WARN: strings not installed. try installing binutils?' >&2 + __versions_haveStrings=${FALSE} + fi +} + +#------------------------------------------------------------------------------ +# main +# + +versions_main() +{ + # treat unset variables as an error + set -u + + os_name=`versions_osName` + os_version=`versions_osVersion` + echo "os: ${os_name} version: ${os_version}" + + for shell in ${VERSIONS_SHELLS}; do + shell_version=`versions_shellVersion ${shell}` + echo "shell: ${shell} version: ${shell_version}" + done +} + +if [ "${ARGV0}" = 'versions' ]; then + versions_main "$@" +fi diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2 b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2 new file mode 100755 index 0000000..d6e7503 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2 @@ -0,0 +1,1067 @@ +#! /bin/sh +# $Id$ +# vim:et:ft=sh:sts=2:sw=2 +# +# Copyright 2008 Kate Ward. All Rights Reserved. +# Released under the LGPL (GNU Lesser General Public License) +# +# shUnit2 -- Unit testing framework for Unix shell scripts. +# http://code.google.com/p/shunit2/ +# +# Author: kate.ward@forestent.com (Kate Ward) +# +# shUnit2 is a xUnit based unit test framework for Bourne shell scripts. It is +# based on the popular JUnit unit testing framework for Java. + +# return if shunit already loaded +[ -n "${SHUNIT_VERSION:-}" ] && exit 0 +SHUNIT_VERSION='2.1.7pre' + +# return values that scripts can use +SHUNIT_TRUE=0 +SHUNIT_FALSE=1 +SHUNIT_ERROR=2 + +# logging functions +_shunit_warn() { echo "shunit2:WARN $@" >&2; } +_shunit_error() { echo "shunit2:ERROR $@" >&2; } +_shunit_fatal() { echo "shunit2:FATAL $@" >&2; exit ${SHUNIT_ERROR}; } + +# determine some reasonable command defaults +__SHUNIT_UNAME_S=`uname -s` +case "${__SHUNIT_UNAME_S}" in + BSD) __SHUNIT_EXPR_CMD='gexpr' ;; + *) __SHUNIT_EXPR_CMD='expr' ;; +esac + +# commands a user can override if needed +SHUNIT_EXPR_CMD=${SHUNIT_EXPR_CMD:-${__SHUNIT_EXPR_CMD}} + +# enable strict mode by default +SHUNIT_STRICT=${SHUNIT_STRICT:-${SHUNIT_TRUE}} + +# specific shell checks +if [ -n "${ZSH_VERSION:-}" ]; then + setopt |grep "^shwordsplit$" >/dev/null + if [ $? -ne ${SHUNIT_TRUE} ]; then + _shunit_fatal 'zsh shwordsplit option is required for proper operation' + fi + if [ -z "${SHUNIT_PARENT:-}" ]; then + _shunit_fatal "zsh does not pass \$0 through properly. please declare \ +\"SHUNIT_PARENT=\$0\" before calling shUnit2" + fi +fi + +# +# constants +# + +__SHUNIT_ASSERT_MSG_PREFIX='ASSERT:' +__SHUNIT_MODE_SOURCED='sourced' +__SHUNIT_MODE_STANDALONE='standalone' +__SHUNIT_PARENT=${SHUNIT_PARENT:-$0} + +# set the constants readonly +__shunit_constants=`set |grep '^__SHUNIT_' |cut -d= -f1` +echo "${__shunit_constants}" |grep '^Binary file' >/dev/null && \ + __shunit_constants=`set |grep -a '^__SHUNIT_' |cut -d= -f1` +for __shunit_const in ${__shunit_constants}; do + if [ -z "${ZSH_VERSION:-}" ]; then + readonly ${__shunit_const} + else + case ${ZSH_VERSION} in + [123].*) readonly ${__shunit_const} ;; + *) readonly -g ${__shunit_const} # declare readonly constants globally + esac + fi +done +unset __shunit_const __shunit_constants + +# +# internal variables +# + +# variables +__shunit_lineno='' # line number of executed test +__shunit_mode=${__SHUNIT_MODE_SOURCED} # operating mode +__shunit_reportGenerated=${SHUNIT_FALSE} # is report generated +__shunit_script='' # filename of unittest script (standalone mode) +__shunit_skip=${SHUNIT_FALSE} # is skipping enabled +__shunit_suite='' # suite of tests to execute + +# counts of tests +__shunit_testSuccess=${SHUNIT_TRUE} +__shunit_testsTotal=0 +__shunit_testsPassed=0 +__shunit_testsFailed=0 + +# counts of asserts +__shunit_assertsTotal=0 +__shunit_assertsPassed=0 +__shunit_assertsFailed=0 +__shunit_assertsSkipped=0 + +# macros +_SHUNIT_LINENO_='eval __shunit_lineno=""; if [ "${1:-}" = "--lineno" ]; then [ -n "$2" ] && __shunit_lineno="[$2] "; shift 2; fi' + +#----------------------------------------------------------------------------- +# private functions + +#----------------------------------------------------------------------------- +# assert functions +# + +# Assert that two values are equal to one another. +# +# Args: +# message: string: failure message [optional] +# expected: string: expected value +# actual: string: actual value +# Returns: +# integer: success (TRUE/FALSE/ERROR constant) +assertEquals() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "assertEquals() requires two or three arguments; $# given" + _shunit_error "1: ${1:+$1} 2: ${2:+$2} 3: ${3:+$3}${4:+ 4: $4}" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + shunit_expected_=$1 + shunit_actual_=$2 + + shunit_return=${SHUNIT_TRUE} + if [ "${shunit_expected_}" = "${shunit_actual_}" ]; then + _shunit_assertPass + else + failNotEquals "${shunit_message_}" "${shunit_expected_}" "${shunit_actual_}" + shunit_return=${SHUNIT_FALSE} + fi + + unset shunit_message_ shunit_expected_ shunit_actual_ + return ${shunit_return} +} +_ASSERT_EQUALS_='eval assertEquals --lineno "${LINENO:-}"' + +# Assert that two values are not equal to one another. +# +# Args: +# message: string: failure message [optional] +# expected: string: expected value +# actual: string: actual value +# Returns: +# integer: success (TRUE/FALSE/ERROR constant) +assertNotEquals() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "assertNotEquals() requires two or three arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + shunit_expected_=$1 + shunit_actual_=$2 + + shunit_return=${SHUNIT_TRUE} + if [ "${shunit_expected_}" != "${shunit_actual_}" ]; then + _shunit_assertPass + else + failSame "${shunit_message_}" "$@" + shunit_return=${SHUNIT_FALSE} + fi + + unset shunit_message_ shunit_expected_ shunit_actual_ + return ${shunit_return} +} +_ASSERT_NOT_EQUALS_='eval assertNotEquals --lineno "${LINENO:-}"' + +# Assert that a value is null (i.e. an empty string) +# +# Args: +# message: string: failure message [optional] +# actual: string: actual value +# Returns: +# integer: success (TRUE/FALSE/ERROR constant) +assertNull() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 1 -o $# -gt 2 ]; then + _shunit_error "assertNull() requires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 2 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + assertTrue "${shunit_message_}" "[ -z '$1' ]" + shunit_return=$? + + unset shunit_message_ + return ${shunit_return} +} +_ASSERT_NULL_='eval assertNull --lineno "${LINENO:-}"' + +# Assert that a value is not null (i.e. a non-empty string) +# +# Args: +# message: string: failure message [optional] +# actual: string: actual value +# Returns: +# integer: success (TRUE/FALSE/ERROR constant) +assertNotNull() +{ + ${_SHUNIT_LINENO_} + if [ $# -gt 2 ]; then # allowing 0 arguments as $1 might actually be null + _shunit_error "assertNotNull() requires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 2 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + shunit_actual_=`_shunit_escapeCharactersInString "${1:-}"` + test -n "${shunit_actual_}" + assertTrue "${shunit_message_}" $? + shunit_return=$? + + unset shunit_actual_ shunit_message_ + return ${shunit_return} +} +_ASSERT_NOT_NULL_='eval assertNotNull --lineno "${LINENO:-}"' + +# Assert that two values are the same (i.e. equal to one another). +# +# Args: +# message: string: failure message [optional] +# expected: string: expected value +# actual: string: actual value +# Returns: +# integer: success (TRUE/FALSE/ERROR constant) +assertSame() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "assertSame() requires two or three arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + assertEquals "${shunit_message_}" "$1" "$2" + shunit_return=$? + + unset shunit_message_ + return ${shunit_return} +} +_ASSERT_SAME_='eval assertSame --lineno "${LINENO:-}"' + +# Assert that two values are not the same (i.e. not equal to one another). +# +# Args: +# message: string: failure message [optional] +# expected: string: expected value +# actual: string: actual value +# Returns: +# integer: success (TRUE/FALSE/ERROR constant) +assertNotSame() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "assertNotSame() requires two or three arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_:-}$1" + shift + fi + assertNotEquals "${shunit_message_}" "$1" "$2" + shunit_return=$? + + unset shunit_message_ + return ${shunit_return} +} +_ASSERT_NOT_SAME_='eval assertNotSame --lineno "${LINENO:-}"' + +# Assert that a value or shell test condition is true. +# +# In shell, a value of 0 is true and a non-zero value is false. Any integer +# value passed can thereby be tested. +# +# Shell supports much more complicated tests though, and a means to support +# them was needed. As such, this function tests that conditions are true or +# false through evaluation rather than just looking for a true or false. +# +# The following test will succeed: +# assertTrue 0 +# assertTrue "[ 34 -gt 23 ]" +# The folloing test will fail with a message: +# assertTrue 123 +# assertTrue "test failed" "[ -r '/non/existant/file' ]" +# +# Args: +# message: string: failure message [optional] +# condition: string: integer value or shell conditional statement +# Returns: +# integer: success (TRUE/FALSE/ERROR constant) +assertTrue() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 1 -o $# -gt 2 ]; then + _shunit_error "assertTrue() takes one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 2 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + shunit_condition_=$1 + + # see if condition is an integer, i.e. a return value + shunit_match_=`expr "${shunit_condition_}" : '\([0-9]*\)'` + shunit_return=${SHUNIT_TRUE} + if [ -z "${shunit_condition_}" ]; then + # null condition + shunit_return=${SHUNIT_FALSE} + elif [ -n "${shunit_match_}" -a "${shunit_condition_}" = "${shunit_match_}" ] + then + # possible return value. treating 0 as true, and non-zero as false. + [ ${shunit_condition_} -ne 0 ] && shunit_return=${SHUNIT_FALSE} + else + # (hopefully) a condition + ( eval ${shunit_condition_} ) >/dev/null 2>&1 + [ $? -ne 0 ] && shunit_return=${SHUNIT_FALSE} + fi + + # record the test + if [ ${shunit_return} -eq ${SHUNIT_TRUE} ]; then + _shunit_assertPass + else + _shunit_assertFail "${shunit_message_}" + fi + + unset shunit_message_ shunit_condition_ shunit_match_ + return ${shunit_return} +} +_ASSERT_TRUE_='eval assertTrue --lineno "${LINENO:-}"' + +# Assert that a value or shell test condition is false. +# +# In shell, a value of 0 is true and a non-zero value is false. Any integer +# value passed can thereby be tested. +# +# Shell supports much more complicated tests though, and a means to support +# them was needed. As such, this function tests that conditions are true or +# false through evaluation rather than just looking for a true or false. +# +# The following test will succeed: +# assertFalse 1 +# assertFalse "[ 'apples' = 'oranges' ]" +# The folloing test will fail with a message: +# assertFalse 0 +# assertFalse "test failed" "[ 1 -eq 1 -a 2 -eq 2 ]" +# +# Args: +# message: string: failure message [optional] +# condition: string: integer value or shell conditional statement +# Returns: +# integer: success (TRUE/FALSE/ERROR constant) +assertFalse() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 1 -o $# -gt 2 ]; then + _shunit_error "assertFalse() quires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 2 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + shunit_condition_=$1 + + # see if condition is an integer, i.e. a return value + shunit_match_=`expr "${shunit_condition_}" : '\([0-9]*\)'` + shunit_return=${SHUNIT_TRUE} + if [ -z "${shunit_condition_}" ]; then + # null condition + shunit_return=${SHUNIT_FALSE} + elif [ -n "${shunit_match_}" -a "${shunit_condition_}" = "${shunit_match_}" ] + then + # possible return value. treating 0 as true, and non-zero as false. + [ ${shunit_condition_} -eq 0 ] && shunit_return=${SHUNIT_FALSE} + else + # (hopefully) a condition + ( eval ${shunit_condition_} ) >/dev/null 2>&1 + [ $? -eq 0 ] && shunit_return=${SHUNIT_FALSE} + fi + + # record the test + if [ ${shunit_return} -eq ${SHUNIT_TRUE} ]; then + _shunit_assertPass + else + _shunit_assertFail "${shunit_message_}" + fi + + unset shunit_message_ shunit_condition_ shunit_match_ + return ${shunit_return} +} +_ASSERT_FALSE_='eval assertFalse --lineno "${LINENO:-}"' + +#----------------------------------------------------------------------------- +# failure functions +# + +# Records a test failure. +# +# Args: +# message: string: failure message [optional] +# Returns: +# integer: success (TRUE/FALSE/ERROR constant) +fail() +{ + ${_SHUNIT_LINENO_} + if [ $# -gt 1 ]; then + _shunit_error "fail() requires zero or one arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 1 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + + _shunit_assertFail "${shunit_message_}" + + unset shunit_message_ + return ${SHUNIT_FALSE} +} +_FAIL_='eval fail --lineno "${LINENO:-}"' + +# Records a test failure, stating two values were not equal. +# +# Args: +# message: string: failure message [optional] +# expected: string: expected value +# actual: string: actual value +# Returns: +# integer: success (TRUE/FALSE/ERROR constant) +failNotEquals() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "failNotEquals() requires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + shunit_expected_=$1 + shunit_actual_=$2 + + _shunit_assertFail "${shunit_message_:+${shunit_message_} }expected:<${shunit_expected_}> but was:<${shunit_actual_}>" + + unset shunit_message_ shunit_expected_ shunit_actual_ + return ${SHUNIT_FALSE} +} +_FAIL_NOT_EQUALS_='eval failNotEquals --lineno "${LINENO:-}"' + +# Records a test failure, stating two values should have been the same. +# +# Args: +# message: string: failure message [optional] +# expected: string: expected value +# actual: string: actual value +# Returns: +# integer: success (TRUE/FALSE/ERROR constant) +failSame() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "failSame() requires two or three arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + + _shunit_assertFail "${shunit_message_:+${shunit_message_} }expected not same" + + unset shunit_message_ + return ${SHUNIT_FALSE} +} +_FAIL_SAME_='eval failSame --lineno "${LINENO:-}"' + +# Records a test failure, stating two values were not equal. +# +# This is functionally equivalent to calling failNotEquals(). +# +# Args: +# message: string: failure message [optional] +# expected: string: expected value +# actual: string: actual value +# Returns: +# integer: success (TRUE/FALSE/ERROR constant) +failNotSame() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "failNotEquals() requires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + failNotEquals "${shunit_message_}" "$1" "$2" + shunit_return=$? + + unset shunit_message_ + return ${shunit_return} +} +_FAIL_NOT_SAME_='eval failNotSame --lineno "${LINENO:-}"' + +#----------------------------------------------------------------------------- +# skipping functions +# + +# Force remaining assert and fail functions to be "skipped". +# +# This function forces the remaining assert and fail functions to be "skipped", +# i.e. they will have no effect. Each function skipped will be recorded so that +# the total of asserts and fails will not be altered. +# +# Args: +# None +startSkipping() +{ + __shunit_skip=${SHUNIT_TRUE} +} + +# Resume the normal recording behavior of assert and fail calls. +# +# Args: +# None +endSkipping() +{ + __shunit_skip=${SHUNIT_FALSE} +} + +# Returns the state of assert and fail call skipping. +# +# Args: +# None +# Returns: +# boolean: (TRUE/FALSE constant) +isSkipping() +{ + return ${__shunit_skip} +} + +#----------------------------------------------------------------------------- +# suite functions +# + +# Stub. This function should contains all unit test calls to be made. +# +# DEPRECATED (as of 2.1.0) +# +# This function can be optionally overridden by the user in their test suite. +# +# If this function exists, it will be called when shunit2 is sourced. If it +# does not exist, shunit2 will search the parent script for all functions +# beginning with the word 'test', and they will be added dynamically to the +# test suite. +# +# This function should be overridden by the user in their unit test suite. +# Note: see _shunit_mktempFunc() for actual implementation +# +# Args: +# None +#suite() { :; } # DO NOT UNCOMMENT THIS FUNCTION + +# Adds a function name to the list of tests schedule for execution. +# +# This function should only be called from within the suite() function. +# +# Args: +# function: string: name of a function to add to current unit test suite +suite_addTest() +{ + shunit_func_=${1:-} + + __shunit_suite="${__shunit_suite:+${__shunit_suite} }${shunit_func_}" + __shunit_testsTotal=`expr ${__shunit_testsTotal} + 1` + + unset shunit_func_ +} + +# Stub. This function will be called once before any tests are run. +# +# Common one-time environment preparation tasks shared by all tests can be +# defined here. +# +# This function should be overridden by the user in their unit test suite. +# Note: see _shunit_mktempFunc() for actual implementation +# +# Args: +# None +#oneTimeSetUp() { :; } # DO NOT UNCOMMENT THIS FUNCTION + +# Stub. This function will be called once after all tests are finished. +# +# Common one-time environment cleanup tasks shared by all tests can be defined +# here. +# +# This function should be overridden by the user in their unit test suite. +# Note: see _shunit_mktempFunc() for actual implementation +# +# Args: +# None +#oneTimeTearDown() { :; } # DO NOT UNCOMMENT THIS FUNCTION + +# Stub. This function will be called before each test is run. +# +# Common environment preparation tasks shared by all tests can be defined here. +# +# This function should be overridden by the user in their unit test suite. +# Note: see _shunit_mktempFunc() for actual implementation +# +# Args: +# None +#setUp() { :; } + +# Note: see _shunit_mktempFunc() for actual implementation +# Stub. This function will be called after each test is run. +# +# Common environment cleanup tasks shared by all tests can be defined here. +# +# This function should be overridden by the user in their unit test suite. +# Note: see _shunit_mktempFunc() for actual implementation +# +# Args: +# None +#tearDown() { :; } # DO NOT UNCOMMENT THIS FUNCTION + +#------------------------------------------------------------------------------ +# internal shUnit2 functions +# + +# Create a temporary directory to store various run-time files in. +# +# This function is a cross-platform temporary directory creation tool. Not all +# OSes have the mktemp function, so one is included here. +# +# Args: +# None +# Outputs: +# string: the temporary directory that was created +_shunit_mktempDir() +{ + # try the standard mktemp function + ( exec mktemp -dqt shunit.XXXXXX 2>/dev/null ) && return + + # the standard mktemp didn't work. doing our own. + if [ -r '/dev/urandom' -a -x '/usr/bin/od' ]; then + _shunit_random_=`/usr/bin/od -vAn -N4 -tx4
"${_shunit_file_}" +#! /bin/sh +exit ${SHUNIT_TRUE} +EOF + chmod +x "${_shunit_file_}" + done + + unset _shunit_file_ +} + +# Final cleanup function to leave things as we found them. +# +# Besides removing the temporary directory, this function is in charge of the +# final exit code of the unit test. The exit code is based on how the script +# was ended (e.g. normal exit, or via Ctrl-C). +# +# Args: +# name: string: name of the trap called (specified when trap defined) +_shunit_cleanup() +{ + _shunit_name_=$1 + + case ${_shunit_name_} in + EXIT) _shunit_signal_=0 ;; + INT) _shunit_signal_=2 ;; + TERM) _shunit_signal_=15 ;; + *) + _shunit_warn "unrecognized trap value (${_shunit_name_})" + _shunit_signal_=0 + ;; + esac + + # do our work + rm -fr "${__shunit_tmpDir}" + + # exit for all non-EXIT signals + if [ ${_shunit_name_} != 'EXIT' ]; then + _shunit_warn "trapped and now handling the (${_shunit_name_}) signal" + # disable EXIT trap + trap 0 + # add 128 to signal and exit + exit `expr ${_shunit_signal_} + 128` + elif [ ${__shunit_reportGenerated} -eq ${SHUNIT_FALSE} ] ; then + _shunit_assertFail 'Unknown failure encountered running a test' + _shunit_generateReport + exit ${SHUNIT_ERROR} + fi + + unset _shunit_name_ _shunit_signal_ +} + +# The actual running of the tests happens here. +# +# Args: +# None +_shunit_execSuite() +{ + for _shunit_test_ in ${__shunit_suite}; do + __shunit_testSuccess=${SHUNIT_TRUE} + + # disable skipping + endSkipping + + # execute the per-test setup function + setUp + + # execute the test + echo "${_shunit_test_}" + eval ${_shunit_test_} + + # execute the per-test tear-down function + tearDown + + # update stats + if [ ${__shunit_testSuccess} -eq ${SHUNIT_TRUE} ]; then + __shunit_testsPassed=`expr ${__shunit_testsPassed} + 1` + else + __shunit_testsFailed=`expr ${__shunit_testsFailed} + 1` + fi + done + + unset _shunit_test_ +} + +# Generates the user friendly report with appropriate OK/FAILED message. +# +# Args: +# None +# Output: +# string: the report of successful and failed tests, as well as totals. +_shunit_generateReport() +{ + _shunit_ok_=${SHUNIT_TRUE} + + # if no exit code was provided one, determine an appropriate one + [ ${__shunit_testsFailed} -gt 0 \ + -o ${__shunit_testSuccess} -eq ${SHUNIT_FALSE} ] \ + && _shunit_ok_=${SHUNIT_FALSE} + + echo + if [ ${__shunit_testsTotal} -eq 1 ]; then + echo "Ran ${__shunit_testsTotal} test." + else + echo "Ran ${__shunit_testsTotal} tests." + fi + + _shunit_failures_='' + _shunit_skipped_='' + [ ${__shunit_assertsFailed} -gt 0 ] \ + && _shunit_failures_="failures=${__shunit_assertsFailed}" + [ ${__shunit_assertsSkipped} -gt 0 ] \ + && _shunit_skipped_="skipped=${__shunit_assertsSkipped}" + + if [ ${_shunit_ok_} -eq ${SHUNIT_TRUE} ]; then + _shunit_msg_='OK' + [ -n "${_shunit_skipped_}" ] \ + && _shunit_msg_="${_shunit_msg_} (${_shunit_skipped_})" + else + _shunit_msg_="FAILED (${_shunit_failures_}" + [ -n "${_shunit_skipped_}" ] \ + && _shunit_msg_="${_shunit_msg_},${_shunit_skipped_}" + _shunit_msg_="${_shunit_msg_})" + fi + + echo + echo ${_shunit_msg_} + __shunit_reportGenerated=${SHUNIT_TRUE} + + unset _shunit_failures_ _shunit_msg_ _shunit_ok_ _shunit_skipped_ +} + +# Test for whether a function should be skipped. +# +# Args: +# None +# Returns: +# boolean: whether the test should be skipped (TRUE/FALSE constant) +_shunit_shouldSkip() +{ + [ ${__shunit_skip} -eq ${SHUNIT_FALSE} ] && return ${SHUNIT_FALSE} + _shunit_assertSkip +} + +# Records a successful test. +# +# Args: +# None +_shunit_assertPass() +{ + __shunit_assertsPassed=`expr ${__shunit_assertsPassed} + 1` + __shunit_assertsTotal=`expr ${__shunit_assertsTotal} + 1` +} + +# Records a test failure. +# +# Args: +# message: string: failure message to provide user +_shunit_assertFail() +{ + _shunit_msg_=$1 + + __shunit_testSuccess=${SHUNIT_FALSE} + __shunit_assertsFailed=`expr ${__shunit_assertsFailed} + 1` + __shunit_assertsTotal=`expr ${__shunit_assertsTotal} + 1` + echo "${__SHUNIT_ASSERT_MSG_PREFIX}${_shunit_msg_}" + + unset _shunit_msg_ +} + +# Records a skipped test. +# +# Args: +# None +_shunit_assertSkip() +{ + __shunit_assertsSkipped=`expr ${__shunit_assertsSkipped} + 1` + __shunit_assertsTotal=`expr ${__shunit_assertsTotal} + 1` +} + +# Prepare a script filename for sourcing. +# +# Args: +# script: string: path to a script to source +# Returns: +# string: filename prefixed with ./ (if necessary) +_shunit_prepForSourcing() +{ + _shunit_script_=$1 + case "${_shunit_script_}" in + /*|./*) echo "${_shunit_script_}" ;; + *) echo "./${_shunit_script_}" ;; + esac + unset _shunit_script_ +} + +# Escape a character in a string. +# +# Args: +# c: string: unescaped character +# s: string: to escape character in +# Returns: +# string: with escaped character(s) +_shunit_escapeCharInStr() +{ + [ -n "$2" ] || return # no point in doing work on an empty string + + # Note: using shorter variable names to prevent conflicts with + # _shunit_escapeCharactersInString(). + _shunit_c_=$1 + _shunit_s_=$2 + + + # escape the character + echo ''${_shunit_s_}'' |sed 's/\'${_shunit_c_}'/\\\'${_shunit_c_}'/g' + + unset _shunit_c_ _shunit_s_ +} + +# Escape a character in a string. +# +# Args: +# str: string: to escape characters in +# Returns: +# string: with escaped character(s) +_shunit_escapeCharactersInString() +{ + [ -n "$1" ] || return # no point in doing work on an empty string + + _shunit_str_=$1 + + # Note: using longer variable names to prevent conflicts with + # _shunit_escapeCharInStr(). + for _shunit_char_ in '"' '$' "'" '`'; do + _shunit_str_=`_shunit_escapeCharInStr "${_shunit_char_}" "${_shunit_str_}"` + done + + echo "${_shunit_str_}" + unset _shunit_char_ _shunit_str_ +} + +# Extract list of functions to run tests against. +# +# Args: +# script: string: name of script to extract functions from +# Returns: +# string: of function names +_shunit_extractTestFunctions() +{ + _shunit_script_=$1 + + # extract the lines with test function names, strip of anything besides the + # function name, and output everything on a single line. + _shunit_regex_='^[ ]*(function )*test[A-Za-z0-9_]* *\(\)' + egrep "${_shunit_regex_}" "${_shunit_script_}" \ + |sed 's/^[^A-Za-z0-9_]*//;s/^function //;s/\([A-Za-z0-9_]*\).*/\1/g' \ + |xargs + + unset _shunit_regex_ _shunit_script_ +} + +#------------------------------------------------------------------------------ +# main +# + +# determine the operating mode +if [ $# -eq 0 ]; then + __shunit_script=${__SHUNIT_PARENT} + __shunit_mode=${__SHUNIT_MODE_SOURCED} +else + __shunit_script=$1 + [ -r "${__shunit_script}" ] || \ + _shunit_fatal "unable to read from ${__shunit_script}" + __shunit_mode=${__SHUNIT_MODE_STANDALONE} +fi + +# create a temporary storage location +__shunit_tmpDir=`_shunit_mktempDir` + +# provide a public temporary directory for unit test scripts +# TODO(kward): document this +SHUNIT_TMPDIR="${__shunit_tmpDir}/tmp" +mkdir "${SHUNIT_TMPDIR}" + +# setup traps to clean up after ourselves +trap '_shunit_cleanup EXIT' 0 +trap '_shunit_cleanup INT' 2 +trap '_shunit_cleanup TERM' 15 + +# create phantom functions to work around issues with Cygwin +_shunit_mktempFunc +PATH="${__shunit_tmpDir}:${PATH}" + +# make sure phantom functions are executable. this will bite if /tmp (or the +# current $TMPDIR) points to a path on a partition that was mounted with the +# 'noexec' option. the noexec command was created with _shunit_mktempFunc(). +noexec 2>/dev/null || _shunit_fatal \ + 'please declare TMPDIR with path on partition with exec permission' + +# we must manually source the tests in standalone mode +if [ "${__shunit_mode}" = "${__SHUNIT_MODE_STANDALONE}" ]; then + . "`_shunit_prepForSourcing \"${__shunit_script}\"`" +fi + +# execute the oneTimeSetUp function (if it exists) +oneTimeSetUp + +# execute the suite function defined in the parent test script +# deprecated as of 2.1.0 +suite + +# if no suite function was defined, dynamically build a list of functions +if [ -z "${__shunit_suite}" ]; then + shunit_funcs_=`_shunit_extractTestFunctions "${__shunit_script}"` + for shunit_func_ in ${shunit_funcs_}; do + suite_addTest ${shunit_func_} + done +fi +unset shunit_func_ shunit_funcs_ + +# execute the tests +_shunit_execSuite + +# execute the oneTimeTearDown function (if it exists) +oneTimeTearDown + +# generate the report +_shunit_generateReport + +# that's it folks +[ ${__shunit_testsFailed} -eq 0 ] +exit $? diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test.sh b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test.sh new file mode 100755 index 0000000..d8f5a9c --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test.sh @@ -0,0 +1,124 @@ +#! /bin/sh +# $Id$ +# vim:et:ft=sh:sts=2:sw=2 +# +# Copyright 2008 Kate Ward. All Rights Reserved. +# Released under the LGPL (GNU Lesser General Public License) +# Author: kate.ward@forestent.com (Kate Ward) +# +# shUnit2 unit test suite runner. +# +# This script runs all the unit tests that can be found, and generates a nice +# report of the tests. + +MY_NAME=`basename $0` +MY_PATH=`dirname $0` + +PREFIX='shunit2_test_' +SHELLS='/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh' +TESTS='' +for test in ${PREFIX}[a-z]*.sh; do + TESTS="${TESTS} ${test}" +done + +# load common unit test functions +. ../lib/versions +. ./shunit2_test_helpers + +usage() +{ + echo "usage: ${MY_NAME} [-e key=val ...] [-s shell(s)] [-t test(s)]" +} + +env='' + +# process command line flags +while getopts 'e:hs:t:' opt; do + case ${opt} in + e) # set an environment variable + key=`expr "${OPTARG}" : '\([^=]*\)='` + val=`expr "${OPTARG}" : '[^=]*=\(.*\)'` + if [ -z "${key}" -o -z "${val}" ]; then + usage + exit 1 + fi + eval "${key}='${val}'" + export ${key} + env="${env:+${env} }${key}" + ;; + h) usage; exit 0 ;; # output help + s) shells=${OPTARG} ;; # list of shells to run + t) tests=${OPTARG} ;; # list of tests to run + *) usage; exit 1 ;; + esac +done +shift `expr ${OPTIND} - 1` + +# fill shells and/or tests +shells=${shells:-${SHELLS}} +tests=${tests:-${TESTS}} + +# error checking +if [ -z "${tests}" ]; then + th_error 'no tests found to run; exiting' + exit 1 +fi + +cat <&1; ) + done +done diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_asserts.sh b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_asserts.sh new file mode 100755 index 0000000..38647ec --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_asserts.sh @@ -0,0 +1,206 @@ +#! /bin/sh +# $Id$ +# vim:et:ft=sh:sts=2:sw=2 +# +# Copyright 2008 Kate Ward. All Rights Reserved. +# Released under the LGPL (GNU Lesser General Public License) +# +# Author: kate.ward@forestent.com (Kate Ward) +# +# shUnit2 unit test for assert functions + +# load test helpers +. ./shunit2_test_helpers + +#------------------------------------------------------------------------------ +# suite tests +# + +commonEqualsSame() +{ + fn=$1 + + ( ${fn} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'equal' $? "${stdoutF}" "${stderrF}" + + ( ${fn} "${MSG}" 'x' 'x' >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'equal; with msg' $? "${stdoutF}" "${stderrF}" + + ( ${fn} 'abc def' 'abc def' >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'equal with spaces' $? "${stdoutF}" "${stderrF}" + + ( ${fn} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'not equal' $? "${stdoutF}" "${stderrF}" + + ( ${fn} '' '' >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'null values' $? "${stdoutF}" "${stderrF}" + + ( ${fn} arg1 >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}" + + ( ${fn} arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}" +} + +commonNotEqualsSame() +{ + fn=$1 + + ( ${fn} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'not same' $? "${stdoutF}" "${stderrF}" + + ( ${fn} "${MSG}" 'x' 'y' >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'not same, with msg' $? "${stdoutF}" "${stderrF}" + + ( ${fn} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'same' $? "${stdoutF}" "${stderrF}" + + ( ${fn} '' '' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'null values' $? "${stdoutF}" "${stderrF}" + + ( ${fn} arg1 >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}" + + ( ${fn} arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}" +} + +testAssertEquals() +{ + commonEqualsSame 'assertEquals' +} + +testAssertNotEquals() +{ + commonNotEqualsSame 'assertNotEquals' +} + +testAssertSame() +{ + commonEqualsSame 'assertSame' +} + +testAssertNotSame() +{ + commonNotEqualsSame 'assertNotSame' +} + +testAssertNull() +{ + ( assertNull '' >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'null' $? "${stdoutF}" "${stderrF}" + + ( assertNull "${MSG}" '' >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'null, with msg' $? "${stdoutF}" "${stderrF}" + + ( assertNull 'x' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'not null' $? "${stdoutF}" "${stderrF}" + + ( assertNull >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}" + + ( assertNull arg1 arg2 arg3 >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}" +} + +testAssertNotNull() +{ + ( assertNotNull 'x' >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'not null' $? "${stdoutF}" "${stderrF}" + + ( assertNotNull "${MSG}" 'x' >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'not null, with msg' $? "${stdoutF}" "${stderrF}" + + ( assertNotNull 'x"b' >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'not null, with double-quote' $? \ + "${stdoutF}" "${stderrF}" + + ( assertNotNull "x'b" >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'not null, with single-quote' $? \ + "${stdoutF}" "${stderrF}" + + ( assertNotNull 'x$b' >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'not null, with dollar' $? \ + "${stdoutF}" "${stderrF}" + + ( assertNotNull 'x`b' >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'not null, with backtick' $? \ + "${stdoutF}" "${stderrF}" + + ( assertNotNull '' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'null' $? "${stdoutF}" "${stderrF}" + + # there is no test for too few arguments as $1 might actually be null + + ( assertNotNull arg1 arg2 arg3 >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}" +} + +testAssertTrue() +{ + ( assertTrue 0 >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'true' $? "${stdoutF}" "${stderrF}" + + ( assertTrue "${MSG}" 0 >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'true, with msg' $? "${stdoutF}" "${stderrF}" + + ( assertTrue '[ 0 -eq 0 ]' >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'true condition' $? "${stdoutF}" "${stderrF}" + + ( assertTrue 1 >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'false' $? "${stdoutF}" "${stderrF}" + + ( assertTrue '[ 0 -eq 1 ]' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'false condition' $? "${stdoutF}" "${stderrF}" + + ( assertTrue '' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'null' $? "${stdoutF}" "${stderrF}" + + ( assertTrue >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}" + + ( assertTrue arg1 arg2 arg3 >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}" +} + +testAssertFalse() +{ + ( assertFalse 1 >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'false' $? "${stdoutF}" "${stderrF}" + + ( assertFalse "${MSG}" 1 >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'false, with msg' $? "${stdoutF}" "${stderrF}" + + ( assertFalse '[ 0 -eq 1 ]' >"${stdoutF}" 2>"${stderrF}" ) + th_assertTrueWithNoOutput 'false condition' $? "${stdoutF}" "${stderrF}" + + ( assertFalse 0 >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'true' $? "${stdoutF}" "${stderrF}" + + ( assertFalse '[ 0 -eq 0 ]' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'true condition' $? "${stdoutF}" "${stderrF}" + + ( assertFalse '' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'true condition' $? "${stdoutF}" "${stderrF}" + + ( assertFalse >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}" + + ( assertFalse arg1 arg2 arg3 >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}" +} + +#------------------------------------------------------------------------------ +# suite functions +# + +oneTimeSetUp() +{ + th_oneTimeSetUp + + MSG='This is a test message' +} + +# load and run shUnit2 +[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0 +. ${TH_SHUNIT} diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_failures.sh b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_failures.sh new file mode 100755 index 0000000..933a0b1 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_failures.sh @@ -0,0 +1,86 @@ +#! /bin/sh +# $Id$ +# vim:et:ft=sh:sts=2:sw=2 +# +# Copyright 2008 Kate Ward. All Rights Reserved. +# Released under the LGPL (GNU Lesser General Public License) +# +# Author: kate.ward@forestent.com (Kate Ward) +# +# shUnit2 unit test for failure functions + +# load common unit-test functions +. ./shunit2_test_helpers + +#----------------------------------------------------------------------------- +# suite tests +# + +testFail() +{ + ( fail >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'fail' $? "${stdoutF}" "${stderrF}" + + ( fail "${MSG}" >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'fail with msg' $? "${stdoutF}" "${stderrF}" + + ( fail arg1 >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'too many arguments' $? "${stdoutF}" "${stderrF}" +} + +testFailNotEquals() +{ + ( failNotEquals 'x' 'x' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'same' $? "${stdoutF}" "${stderrF}" + + ( failNotEquals "${MSG}" 'x' 'x' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'same with msg' $? "${stdoutF}" "${stderrF}" + + ( failNotEquals 'x' 'y' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'not same' $? "${stdoutF}" "${stderrF}" + + ( failNotEquals '' '' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'null values' $? "${stdoutF}" "${stderrF}" + + ( failNotEquals >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}" + + ( failNotEquals arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}" +} + +testFailSame() +{ + ( failSame 'x' 'x' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'same' $? "${stdoutF}" "${stderrF}" + + ( failSame "${MSG}" 'x' 'x' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'same with msg' $? "${stdoutF}" "${stderrF}" + + ( failSame 'x' 'y' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'not same' $? "${stdoutF}" "${stderrF}" + + ( failSame '' '' >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithOutput 'null values' $? "${stdoutF}" "${stderrF}" + + ( failSame >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}" + + ( failSame arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}" ) + th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}" +} + +#----------------------------------------------------------------------------- +# suite functions +# + +oneTimeSetUp() +{ + th_oneTimeSetUp + + MSG='This is a test message' +} + +# load and run shUnit2 +[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0 +. ${TH_SHUNIT} diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_helpers b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_helpers new file mode 100644 index 0000000..a9989d6 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_helpers @@ -0,0 +1,229 @@ +# $Id$ +# vim:et:ft=sh:sts=2:sw=2 +# +# Copyright 2008 Kate Ward. All Rights Reserved. +# Released under the LGPL (GNU Lesser General Public License) +# +# Author: kate.ward@forestent.com (Kate Ward) +# +# shUnit2 unit test common functions + +# treat unset variables as an error when performing parameter expansion +set -u + +# set shwordsplit for zsh +[ -n "${ZSH_VERSION:-}" ] && setopt shwordsplit + +# +# constants +# + +# path to shUnit2 library. can be overridden by setting SHUNIT_INC +TH_SHUNIT=${SHUNIT_INC:-./shunit2} + +# configure debugging. set the DEBUG environment variable to any +# non-empty value to enable debug output, or TRACE to enable trace +# output. +TRACE=${TRACE:+'th_trace '} +[ -n "${TRACE}" ] && DEBUG=1 +[ -z "${TRACE}" ] && TRACE=':' + +DEBUG=${DEBUG:+'th_debug '} +[ -z "${DEBUG}" ] && DEBUG=':' + +# +# variables +# + +th_RANDOM=0 + +# +# functions +# + +# message functions +th_trace() { echo "${MY_NAME}:TRACE $@" >&2; } +th_debug() { echo "${MY_NAME}:DEBUG $@" >&2; } +th_info() { echo "${MY_NAME}:INFO $@" >&2; } +th_warn() { echo "${MY_NAME}:WARN $@" >&2; } +th_error() { echo "${MY_NAME}:ERROR $@" >&2; } +th_fatal() { echo "${MY_NAME}:FATAL $@" >&2; } + +# output subtest name +th_subtest() { echo " $@" >&2; } + +th_oneTimeSetUp() +{ + # these files will be cleaned up automatically by shUnit2 + stdoutF="${SHUNIT_TMPDIR}/stdout" + stderrF="${SHUNIT_TMPDIR}/stderr" + returnF="${SHUNIT_TMPDIR}/return" + expectedF="${SHUNIT_TMPDIR}/expected" +} + +# generate a random number +th_generateRandom() +{ + tfgr_random=${th_RANDOM} + + while [ "${tfgr_random}" = "${th_RANDOM}" ]; do + if [ -n "${RANDOM:-}" ]; then + # $RANDOM works + tfgr_random=${RANDOM}${RANDOM}${RANDOM}$$ + elif [ -r '/dev/urandom' ]; then + tfgr_random=`od -vAn -N4 -tu4
>> STDOUT' >&2 + cat "${_th_stdout_}" >&2 + fi + if [ -n "${_th_stderr_}" -a -s "${_th_stderr_}" ]; then + echo '>>> STDERR' >&2 + cat "${_th_stderr_}" >&2 + fi + if [ -n "${_th_stdout_}" -o -n "${_th_stderr_}" ]; then + echo '<<< end output' >&2 + fi + fi + + unset _th_return_ _th_stdout_ _th_stderr_ +} + +# +# main +# + +${TRACE} 'trace output enabled' +${DEBUG} 'debug output enabled' diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_macros.sh b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_macros.sh new file mode 100755 index 0000000..ce57b14 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_macros.sh @@ -0,0 +1,246 @@ +#! /bin/sh +# $Id$ +# vim:et:ft=sh:sts=2:sw=2 +# +# Copyright 2008 Kate Ward. All Rights Reserved. +# Released under the LGPL (GNU Lesser General Public License) +# Author: kate.ward@forestent.com (Kate Ward) +# +# shUnit2 unit test for macros. + +# load test helpers +. ./shunit2_test_helpers + +#------------------------------------------------------------------------------ +# suite tests +# + +testAssertEquals() +{ + # start skipping if LINENO not available + [ -z "${LINENO:-}" ] && startSkipping + + ( ${_ASSERT_EQUALS_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_ASSERT_EQUALS_ failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 + + ( ${_ASSERT_EQUALS_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_ASSERT_EQUALS_ w/ msg failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 +} + +testAssertNotEquals() +{ + # start skipping if LINENO not available + [ -z "${LINENO:-}" ] && startSkipping + + ( ${_ASSERT_NOT_EQUALS_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_ASSERT_NOT_EQUALS_ failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 + + ( ${_ASSERT_NOT_EQUALS_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_ASSERT_NOT_EQUALS_ w/ msg failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 +} + +testSame() +{ + # start skipping if LINENO not available + [ -z "${LINENO:-}" ] && startSkipping + + ( ${_ASSERT_SAME_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_ASSERT_SAME_ failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 + + ( ${_ASSERT_SAME_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_ASSERT_SAME_ w/ msg failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 +} + +testNotSame() +{ + # start skipping if LINENO not available + [ -z "${LINENO:-}" ] && startSkipping + + ( ${_ASSERT_NOT_SAME_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_ASSERT_NOT_SAME_ failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 + + ( ${_ASSERT_NOT_SAME_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_ASSERT_NOT_SAME_ w/ msg failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 +} + +testNull() +{ + # start skipping if LINENO not available + [ -z "${LINENO:-}" ] && startSkipping + + ( ${_ASSERT_NULL_} 'x' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_ASSERT_NULL_ failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 + + ( ${_ASSERT_NULL_} '"some msg"' 'x' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_ASSERT_NULL_ w/ msg failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 +} + +testNotNull() +{ + # start skipping if LINENO not available + [ -z "${LINENO:-}" ] && startSkipping + + ( ${_ASSERT_NOT_NULL_} '' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_ASSERT_NOT_NULL_ failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 + + ( ${_ASSERT_NOT_NULL_} '"some msg"' '""' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_ASSERT_NOT_NULL_ w/ msg failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stdoutF}" "${stderrF}" >&2 +} + +testAssertTrue() +{ + # start skipping if LINENO not available + [ -z "${LINENO:-}" ] && startSkipping + + ( ${_ASSERT_TRUE_} ${SHUNIT_FALSE} >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_ASSERT_TRUE_ failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 + + + ( ${_ASSERT_TRUE_} '"some msg"' ${SHUNIT_FALSE} >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_ASSERT_TRUE_ w/ msg failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 +} + +testAssertFalse() +{ + # start skipping if LINENO not available + [ -z "${LINENO:-}" ] && startSkipping + + ( ${_ASSERT_FALSE_} ${SHUNIT_TRUE} >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_ASSERT_FALSE_ failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 + + ( ${_ASSERT_FALSE_} '"some msg"' ${SHUNIT_TRUE} >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_ASSERT_FALSE_ w/ msg failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 +} + +testFail() +{ + # start skipping if LINENO not available + [ -z "${LINENO:-}" ] && startSkipping + + ( ${_FAIL_} >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_FAIL_ failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 + + ( ${_FAIL_} '"some msg"' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_FAIL_ w/ msg failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 +} + +testFailNotEquals() +{ + # start skipping if LINENO not available + [ -z "${LINENO:-}" ] && startSkipping + + ( ${_FAIL_NOT_EQUALS_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_FAIL_NOT_EQUALS_ failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 + + ( ${_FAIL_NOT_EQUALS_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_FAIL_NOT_EQUALS_ w/ msg failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 +} + +testFailSame() +{ + # start skipping if LINENO not available + [ -z "${LINENO:-}" ] && startSkipping + + ( ${_FAIL_SAME_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_FAIL_SAME_ failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 + + ( ${_FAIL_SAME_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_FAIL_SAME_ w/ msg failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 +} + +testFailNotSame() +{ + # start skipping if LINENO not available + [ -z "${LINENO:-}" ] && startSkipping + + ( ${_FAIL_NOT_SAME_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_FAIL_NOT_SAME_ failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 + + ( ${_FAIL_NOT_SAME_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" ) + grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null + rtrn=$? + assertTrue '_FAIL_NOT_SAME_ w/ msg failure' ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 +} + +#------------------------------------------------------------------------------ +# suite functions +# + +oneTimeSetUp() +{ + th_oneTimeSetUp +} + +# load and run shUnit2 +[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0 +. ${TH_SHUNIT} diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_misc.sh b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_misc.sh new file mode 100755 index 0000000..d264628 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_misc.sh @@ -0,0 +1,160 @@ +#! /bin/sh +# $Id$ +# vim:et:ft=sh:sts=2:sw=2 +# +# Copyright 2008 Kate Ward. All Rights Reserved. +# Released under the LGPL (GNU Lesser General Public License) +# +# Author: kate.ward@forestent.com (Kate Ward) +# +# shUnit2 unit tests of miscellaneous things + +# load test helpers +. ./shunit2_test_helpers + +#------------------------------------------------------------------------------ +# suite tests +# + +# Note: the test script is prefixed with '#' chars so that shUnit2 does not +# incorrectly interpret the embedded functions as real functions. +testUnboundVariable() +{ + unittestF="${SHUNIT_TMPDIR}/unittest" + sed 's/^#//' >"${unittestF}" <"${stdoutF}" 2>"${stderrF}" ) + assertFalse 'expected a non-zero exit value' $? + grep '^ASSERT:Unknown failure' "${stdoutF}" >/dev/null + assertTrue 'assert message was not generated' $? + grep '^Ran [0-9]* test' "${stdoutF}" >/dev/null + assertTrue 'test count message was not generated' $? + grep '^FAILED' "${stdoutF}" >/dev/null + assertTrue 'failure message was not generated' $? +} + +testIssue7() +{ + ( assertEquals 'Some message.' 1 2 >"${stdoutF}" 2>"${stderrF}" ) + diff "${stdoutF}" - >/dev/null < but was:<2> +EOF + rtrn=$? + assertEquals ${SHUNIT_TRUE} ${rtrn} + [ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2 +} + +testPrepForSourcing() +{ + assertEquals '/abc' `_shunit_prepForSourcing '/abc'` + assertEquals './abc' `_shunit_prepForSourcing './abc'` + assertEquals './abc' `_shunit_prepForSourcing 'abc'` +} + +testEscapeCharInStr() +{ + actual=`_shunit_escapeCharInStr '\' ''` + assertEquals '' "${actual}" + assertEquals 'abc\\' `_shunit_escapeCharInStr '\' 'abc\'` + assertEquals 'abc\\def' `_shunit_escapeCharInStr '\' 'abc\def'` + assertEquals '\\def' `_shunit_escapeCharInStr '\' '\def'` + + actual=`_shunit_escapeCharInStr '"' ''` + assertEquals '' "${actual}" + assertEquals 'abc\"' `_shunit_escapeCharInStr '"' 'abc"'` + assertEquals 'abc\"def' `_shunit_escapeCharInStr '"' 'abc"def'` + assertEquals '\"def' `_shunit_escapeCharInStr '"' '"def'` + + actual=`_shunit_escapeCharInStr '$' ''` + assertEquals '' "${actual}" + assertEquals 'abc\$' `_shunit_escapeCharInStr '$' 'abc$'` + assertEquals 'abc\$def' `_shunit_escapeCharInStr '$' 'abc$def'` + assertEquals '\$def' `_shunit_escapeCharInStr '$' '$def'` + +# actual=`_shunit_escapeCharInStr "'" ''` +# assertEquals '' "${actual}" +# assertEquals "abc\\'" `_shunit_escapeCharInStr "'" "abc'"` +# assertEquals "abc\\'def" `_shunit_escapeCharInStr "'" "abc'def"` +# assertEquals "\\'def" `_shunit_escapeCharInStr "'" "'def"` + +# # must put the backtick in a variable so the shell doesn't misinterpret it +# # while inside a backticked sequence (e.g. `echo '`'` would fail). +# backtick='`' +# actual=`_shunit_escapeCharInStr ${backtick} ''` +# assertEquals '' "${actual}" +# assertEquals '\`abc' \ +# `_shunit_escapeCharInStr "${backtick}" ${backtick}'abc'` +# assertEquals 'abc\`' \ +# `_shunit_escapeCharInStr "${backtick}" 'abc'${backtick}` +# assertEquals 'abc\`def' \ +# `_shunit_escapeCharInStr "${backtick}" 'abc'${backtick}'def'` +} + +testEscapeCharInStr_specialChars() +{ + # make sure our forward slash doesn't upset sed + assertEquals '/' `_shunit_escapeCharInStr '\' '/'` + + # some shells escape these differently + #assertEquals '\\a' `_shunit_escapeCharInStr '\' '\a'` + #assertEquals '\\b' `_shunit_escapeCharInStr '\' '\b'` +} + +# Test the various ways of declaring functions. +# +# Prefixing (then stripping) with comment symbol so these functions aren't +# treated as real functions by shUnit2. +testExtractTestFunctions() +{ + f="${SHUNIT_TMPDIR}/extract_test_functions" + sed 's/^#//' <"${f}" +#testABC() { echo 'ABC'; } +#test_def() { +# echo 'def' +#} +#testG3 () +#{ +# echo 'G3' +#} +#function test4() { echo '4'; } +# test5() { echo '5'; } +#some_test_function() { echo 'some func'; } +#func_with_test_vars() { +# testVariable=1234 +#} +EOF + + actual=`_shunit_extractTestFunctions "${f}"` + assertEquals 'testABC test_def testG3 test4 test5' "${actual}" +} + +#------------------------------------------------------------------------------ +# suite functions +# + +setUp() +{ + for f in ${expectedF} ${stdoutF} ${stderrF}; do + cp /dev/null ${f} + done +} + +oneTimeSetUp() +{ + th_oneTimeSetUp +} + +# load and run shUnit2 +[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0 +. ${TH_SHUNIT} diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_standalone.sh b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_standalone.sh new file mode 100755 index 0000000..2ac4725 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/source/2.1/src/shunit2_test_standalone.sh @@ -0,0 +1,41 @@ +#! /bin/sh +# $Id$ +# vim:et:ft=sh:sts=2:sw=2 +# +# Copyright 2010 Kate Ward. All Rights Reserved. +# Released under the LGPL (GNU Lesser General Public License) +# Author: kate.ward@forestent.com (Kate Ward) +# +# shUnit2 unit test for standalone operation. +# +# This unit test is purely to test that calling shunit2 directly, while passing +# the name of a unit test script, works. When run, this script determines if it +# is running as a standalone program, and calls main() if it is. + +ARGV0=`basename "$0"` + +# load test helpers +. ./shunit2_test_helpers + +#------------------------------------------------------------------------------ +# suite tests +# + +testStandalone() +{ + assertTrue ${SHUNIT_TRUE} +} + +#------------------------------------------------------------------------------ +# main +# + +main() +{ + ${TH_SHUNIT} "${ARGV0}" +} + +# are we running as a standalone? +if [ "${ARGV0}" = 'shunit2_test_standalone.sh' ]; then + if [ $# -gt 0 ]; then main "$@"; else main; fi +fi diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/README.html b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/README.html new file mode 100644 index 0000000..0ee9e34 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/README.html @@ -0,0 +1,23 @@ + + + + + + + +

Please visit the shUnit2 website at http://code.google.com/p/shunit2/.

+ + + + + + + diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/.htaccess_backup b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/.htaccess_backup new file mode 100644 index 0000000..8bdc4c0 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/.htaccess_backup @@ -0,0 +1,14 @@ +# $Id$ + +Options +Indexes +IndexOptions NameWidth=* + +AddType multipart/digest .md5 + + RemoveEncoding .tgz + + +AddType application/gpg-signature .sig + + RemoveEncoding .tgz + diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.0.tgz.md5 b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.0.tgz.md5 new file mode 100644 index 0000000..6821d75 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.0.tgz.md5 @@ -0,0 +1 @@ +bdede699570ba09a8c820af2c0c3db34 shunit2-2.0.0.tgz diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.0.tgz.sig b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.0.tgz.sig new file mode 100644 index 0000000..e1c65e8 Binary files /dev/null and b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.0.tgz.sig differ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.1.tgz.md5 b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.1.tgz.md5 new file mode 100644 index 0000000..6f64c39 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.1.tgz.md5 @@ -0,0 +1 @@ +0741e65e1261285e1676e487077b0bf2 shunit2-2.0.1.tgz diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.1.tgz.sig b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.1.tgz.sig new file mode 100644 index 0000000..4d2a403 Binary files /dev/null and b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.1.tgz.sig differ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.2.tgz.md5 b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.2.tgz.md5 new file mode 100644 index 0000000..e31a8e0 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.2.tgz.md5 @@ -0,0 +1 @@ +ab8ba8a532da33645c9a6b8ee6783f3c shunit2-2.0.2.tgz diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.2.tgz.sig b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.2.tgz.sig new file mode 100644 index 0000000..d1d6d77 Binary files /dev/null and b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.2.tgz.sig differ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.3.tgz.md5 b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.3.tgz.md5 new file mode 100644 index 0000000..8c8c1f7 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.3.tgz.md5 @@ -0,0 +1 @@ +9c947dc31e53c7008b3e665c1e6057e0 shunit2-2.0.3.tgz diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.3.tgz.sig b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.3.tgz.sig new file mode 100644 index 0000000..4f0d907 Binary files /dev/null and b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.0.3.tgz.sig differ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.0.tgz.md5 b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.0.tgz.md5 new file mode 100644 index 0000000..02dda5c --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.0.tgz.md5 @@ -0,0 +1 @@ +8d0e775f811d2a936c5994e5a4add170 shunit2-2.1.0.tgz diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.0.tgz.sig b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.0.tgz.sig new file mode 100644 index 0000000..c8e726c Binary files /dev/null and b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.0.tgz.sig differ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.1.tgz.md5 b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.1.tgz.md5 new file mode 100644 index 0000000..c74bb34 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.1.tgz.md5 @@ -0,0 +1 @@ +4e6aa6d54a6beac8435bfddad8d97db3 shunit2-2.1.1.tgz diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.1.tgz.sig b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.1.tgz.sig new file mode 100644 index 0000000..729adf1 Binary files /dev/null and b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.1.tgz.sig differ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.2.tgz.md5 b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.2.tgz.md5 new file mode 100644 index 0000000..51376c0 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.2.tgz.md5 @@ -0,0 +1 @@ +6f7355ba449f421320045337c62652a3 shunit2-2.1.2.tgz diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.2.tgz.sig b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.2.tgz.sig new file mode 100644 index 0000000..a90ec02 Binary files /dev/null and b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.2.tgz.sig differ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.3.tgz.md5 b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.3.tgz.md5 new file mode 100644 index 0000000..ee8b080 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.3.tgz.md5 @@ -0,0 +1 @@ +156a2491925a269fe09b70562deae091 shunit2-2.1.3.tgz diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.3.tgz.sig b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.3.tgz.sig new file mode 100644 index 0000000..c8a3617 Binary files /dev/null and b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.3.tgz.sig differ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.4.tgz.sig b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.4.tgz.sig new file mode 100644 index 0000000..88ff460 Binary files /dev/null and b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.4.tgz.sig differ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.5.tgz.sig b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.5.tgz.sig new file mode 100644 index 0000000..f97dab2 Binary files /dev/null and b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/releases/shunit2-2.1.5.tgz.sig differ diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.2/Linux-Ubuntu_Dapper-6.04.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.2/Linux-Ubuntu_Dapper-6.04.txt new file mode 100644 index 0000000..2886741 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.2/Linux-Ubuntu_Dapper-6.04.txt @@ -0,0 +1,236 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests="testAsserts testFailures" + +# system info +$ date +Mon Dec 31 00:51:14 GMT 2007 +$ uname -mprsv +Linux 2.6.18.5-gg19workstation-mixed64-32 #1 SMP Tue Nov 20 16:02:52 PST 2007 x86_64 unknown + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# + +GNU bash, version 3.1.17(1)-release (i486-pc-linux-gnu) +Copyright (C) 2005 Free Software Foundation, Inc. + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + +run-test-suite:WARN unable to run tests with the /bin/dash shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +ASSERT:null values; failure +shunit2:ERROR assertEquals()/assertSame() require at least two arguments +ASSERT:expected no output to STDERR +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 76 97% +tests failed: 2 3% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +ASSERT:null values; failure +shunit2:ERROR assertEquals()/assertSame() require at least two arguments +ASSERT:expected no output to STDERR +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 76 97% +tests failed: 2 3% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# + +zsh 4.2.5 (i686-pc-linux-gnu) + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.2/Linux-Ubuntu_Gutsy-7.10.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.2/Linux-Ubuntu_Gutsy-7.10.txt new file mode 100644 index 0000000..b8546b9 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.2/Linux-Ubuntu_Gutsy-7.10.txt @@ -0,0 +1,278 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests="testAsserts testFailures" + +# system info +$ date +Mon Dec 24 21:45:53 GMT 2007 +$ uname -mprsv +Linux 2.6.22-14-server #1 SMP Tue Dec 18 08:31:40 UTC 2007 i686 unknown + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# + +GNU bash, version 3.2.25(1)-release (i486-pc-linux-gnu) +Copyright (C) 2005 Free Software Foundation, Inc. + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/dash +# + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# + + version sh (AT&T Labs Research) 1993-12-28 r + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +ASSERT:null values; failure +shunit2:ERROR assertEquals()/assertSame() require at least two arguments +ASSERT:expected no output to STDERR +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 76 97% +tests failed: 2 3% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +ASSERT:null values; failure +shunit2:ERROR assertEquals()/assertSame() require at least two arguments +ASSERT:expected no output to STDERR +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 76 97% +tests failed: 2 3% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# + +zsh 4.3.4 (i686-pc-linux-gnu) + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.2/Mac_OS_X-10.4.1.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.2/Mac_OS_X-10.4.1.txt new file mode 100644 index 0000000..af4ce02 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.2/Mac_OS_X-10.4.1.txt @@ -0,0 +1,195 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests="testAsserts testFailures" + +# system info +$ date +Mon Dec 31 00:47:18 GMT 2007 +$ uname -mprsv +Darwin 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 i386 i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# + +GNU bash, version 2.05b.0(1)-release (powerpc-apple-darwin8.0) +Copyright (C) 2002 Free Software Foundation, Inc. + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + +run-test-suite:WARN unable to run tests with the /bin/dash shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# + + version sh (AT&T Labs Research) 1993-12-28 p + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +ASSERT:null values; failure +shunit2:ERROR assertEquals()/assertSame() require at least two arguments +ASSERT:expected no output to STDERR +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 76 97% +tests failed: 2 3% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + +run-test-suite:WARN unable to run tests with the /bin/pdksh shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# + +zsh 4.2.3 (powerpc-apple-darwin8.0) + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.2/Solaris-10-U3-x86.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.2/Solaris-10-U3-x86.txt new file mode 100644 index 0000000..1e8d440 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.2/Solaris-10-U3-x86.txt @@ -0,0 +1,196 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests="testAsserts testFailures" + +# system info +$ date +Mon Dec 31 00:48:41 GMT 2007 +$ uname -mprsv +SunOS 5.10 Generic_127112-05 i86pc i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +ASSERT:null values; failure +shunit2:ERROR assertEquals()/assertSame() require at least two arguments +ASSERT:expected no output to STDERR +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 76 97% +tests failed: 2 3% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# + +GNU bash, version 3.00.16(1)-release (i386-pc-solaris2.10) +Copyright (C) 2004 Free Software Foundation, Inc. + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + +run-test-suite:WARN unable to run tests with the /bin/dash shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +ASSERT:null values; failure +shunit2:ERROR assertEquals()/assertSame() require at least two arguments +ASSERT:expected no output to STDERR +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 76 97% +tests failed: 2 3% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + +run-test-suite:WARN unable to run tests with the /bin/pdksh shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# + +zsh 4.2.1 (i386-pc-solaris2.10) + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.3/Cygwin.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.3/Cygwin.txt new file mode 100755 index 0000000..7a1ed7d --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.3/Cygwin.txt @@ -0,0 +1,180 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests="testAsserts testFailures" + +# system info +$ date +Sun May 11 00:16:31 GMTDT 2008 +$ uname -mprsv +CYGWIN_NT-5.1 1.5.25(0.156/4/2) 2008-03-05 19:27 i686 unknown + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# + +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# + +GNU bash, version 3.2.33(18)-release (i686-pc-cygwin) +Copyright (C) 2007 Free Software Foundation, Inc. + +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# + +# +# Performing tests +# +testAssertEquals +testAssertSame +shunit2:ERROR assertEquals()/assertSame() require at least two arguments +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 76 97% +tests failed: 2 3% +tests skipped: 0 0% +tests total: 78 100% + +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# + +# +# Performing tests +# +testAssertEquals +testAssertSame +shunit2:ERROR assertEquals()/assertSame() require at least two arguments +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 76 97% +tests failed: 2 3% +tests skipped: 0 0% +tests total: 78 100% + +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.3/Linux-Ubuntu_Hardy-8.04.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.3/Linux-Ubuntu_Hardy-8.04.txt new file mode 100644 index 0000000..f8e3820 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.3/Linux-Ubuntu_Hardy-8.04.txt @@ -0,0 +1,278 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests="testAsserts testFailures" + +# system info +$ date +Sat May 10 22:07:59 UTC 2008 +$ uname -mprsv +Linux 2.6.24-16-generic #1 SMP Thu Apr 10 13:23:42 UTC 2008 i686 unknown + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# + +GNU bash, version 3.2.33(1)-release (i486-pc-linux-gnu) +Copyright (C) 2007 Free Software Foundation, Inc. + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/dash +# + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# + + version sh (AT&T Research) 1993-12-28 s+ + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +ASSERT:null values; failure +shunit2:ERROR assertEquals()/assertSame() require at least two arguments +ASSERT:expected no output to STDERR +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 76 97% +tests failed: 2 3% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +ASSERT:null values; failure +shunit2:ERROR assertEquals()/assertSame() require at least two arguments +ASSERT:expected no output to STDERR +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 76 97% +tests failed: 2 3% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# + +zsh 4.3.4 (i686-pc-linux-gnu) + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.3/Mac_OS_X-10.5.2.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.3/Mac_OS_X-10.5.2.txt new file mode 100644 index 0000000..62a678e --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.3/Mac_OS_X-10.5.2.txt @@ -0,0 +1,164 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests="testAsserts testFailures" + +# system info +$ date +Sat May 10 23:03:34 IST 2008 +$ uname -mprsv +Darwin 9.2.2 Darwin Kernel Version 9.2.2: Tue Mar 4 21:17:34 PST 2008; root:xnu-1228.4.31~1/RELEASE_I386 i386 i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# + +GNU bash, version 3.2.17(1)-release (i386-apple-darwin9.0) +Copyright (C) 2005 Free Software Foundation, Inc. + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + +run-test-suite:WARN unable to run tests with the /bin/dash shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# + + version sh (AT&T Research) 1993-12-28 s+ + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +ASSERT:null values; failure +shunit2:ERROR assertEquals()/assertSame() require at least two arguments +ASSERT:expected no output to STDERR +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 76 97% +tests failed: 2 3% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + +run-test-suite:WARN unable to run tests with the /bin/pdksh shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# + +zsh 4.3.4 (i386-apple-darwin9.0) + +--- Executing the 'Asserts' test suite --- +shunit2:FATAL zsh does not pass $0 through properly. please declare' "SHUNIT_PARENT=$0" before calling shUnit2 + +--- Executing the 'Failures' test suite --- +shunit2:FATAL zsh does not pass $0 through properly. please declare' "SHUNIT_PARENT=$0" before calling shUnit2 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.3/Solaris-11-x86.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.3/Solaris-11-x86.txt new file mode 100644 index 0000000..4852cee --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.3/Solaris-11-x86.txt @@ -0,0 +1,196 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests="testAsserts testFailures" + +# system info +$ date +Mon Apr 21 12:01:47 GMT 2008 +$ uname -mprsv +SunOS 5.11 snv_77 i86pc i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +ASSERT:null values; failure +shunit2:ERROR assertEquals()/assertSame() require at least two arguments +ASSERT:expected no output to STDERR +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 76 97% +tests failed: 2 3% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# + +GNU bash, version 3.2.25(1)-release (i386-pc-solaris2.11) +Copyright (C) 2005 Free Software Foundation, Inc. + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + +run-test-suite:WARN unable to run tests with the /bin/dash shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +ASSERT:null values; failure +shunit2:ERROR assertEquals()/assertSame() require at least two arguments +ASSERT:expected no output to STDERR +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 76 97% +tests failed: 2 3% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% + +run-test-suite:WARN unable to run tests with the /bin/pdksh shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# + +zsh 4.3.4 (i386-pc-solaris2.11) + +--- Executing the 'Asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 78 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 78 100% + +--- Executing the 'Failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame +testFailNotSame + +# +# Test report +# +tests passed: 17 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 17 100% diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Cygwin-Windows_XP.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Cygwin-Windows_XP.txt new file mode 100644 index 0000000..697111e --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Cygwin-Windows_XP.txt @@ -0,0 +1,295 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests=" shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh" + +# system info +$ date +Fri Jul 11 12:58:40 GMTDT 2008 +$ uname -mprsv +CYGWIN_NT-5.1 1.5.25(0.156/4/2) 2008-06-12 19:34 i686 unknown + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# + +GNU bash, version 3.2.39(19)-release (i686-pc-cygwin) +Copyright (C) 2007 Free Software Foundation, Inc. + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + +shunit2_test.sh:WARN unable to run tests with the /bin/dash shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# + +version: 4.3.4 + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Linux-Ubuntu_Dapper-6.06.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Linux-Ubuntu_Dapper-6.06.txt new file mode 100644 index 0000000..ec89b5a --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Linux-Ubuntu_Dapper-6.06.txt @@ -0,0 +1,295 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests=" shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh" + +# system info +$ date +Fri Jul 11 12:51:35 IST 2008 +$ uname -mprsv +Linux 2.6.18.5-gg34workstation-mixed64-32 #1 SMP Thu May 8 01:31:23 UTC 2008 x86_64 unknown + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# + +GNU bash, version 3.1.17(1)-release (i486-pc-linux-gnu) +Copyright (C) 2005 Free Software Foundation, Inc. + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + +shunit2_test.sh:WARN unable to run tests with the /bin/dash shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# + +version: 4.2.5 + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Linux-Ubuntu_Hardy-8.04.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Linux-Ubuntu_Hardy-8.04.txt new file mode 100644 index 0000000..9fb145f --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Linux-Ubuntu_Hardy-8.04.txt @@ -0,0 +1,350 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests=" shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh" + +# system info +$ date +Fri Jul 11 11:54:41 GMT 2008 +$ uname -mprsv +Linux 2.6.24-19-server #1 SMP Wed Jun 18 15:18:00 UTC 2008 i686 unknown + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 0 0% +tests failed: 0 0% +tests skipped: 12 100% +tests total: 12 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# + +GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu) +Copyright (C) 2007 Free Software Foundation, Inc. + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/dash +# + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 0 0% +tests failed: 0 0% +tests skipped: 12 100% +tests total: 12 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# + +version: version sh (AT&T Research) 1993-12-28 s+ + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# + +version: 4.3.4 + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Mac_OS_X-10.5.4.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Mac_OS_X-10.5.4.txt new file mode 100644 index 0000000..3e9a834 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Mac_OS_X-10.5.4.txt @@ -0,0 +1,244 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests=" shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh" + +# system info +$ date +Fri Jul 11 12:47:23 IST 2008 +$ uname -mprsv +Darwin 9.4.0 Darwin Kernel Version 9.4.0: Mon Jun 9 19:30:53 PDT 2008; root:xnu-1228.5.20~1/RELEASE_I386 i386 i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# + +GNU bash, version 3.2.17(1)-release (i386-apple-darwin9.0) +Copyright (C) 2005 Free Software Foundation, Inc. + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + +shunit2_test.sh:WARN unable to run tests with the /bin/dash shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# + +version: version sh (AT&T Research) 1993-12-28 s+ + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + +shunit2_test.sh:WARN unable to run tests with the /bin/pdksh shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# + +version: 4.3.4 + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Solaris-9-U6-x86.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Solaris-9-U6-x86.txt new file mode 100644 index 0000000..4dcc56f --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Solaris-9-U6-x86.txt @@ -0,0 +1,266 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests=" shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh" + +# system info +$ date +Fri Jul 11 12:06:35 GMT 2008 +$ uname -mprsv +SunOS 5.9 Generic_117172-08 i86pc i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 0 0% +tests failed: 0 0% +tests skipped: 12 100% +tests total: 12 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# + +GNU bash, version 2.05.0(1)-release (i386-pc-solaris2.9) +Copyright 2000 Free Software Foundation, Inc. + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo +ASSERT:_ASSERT_EQUALS_ failure +ASSERT:[-19][-19] expected: but was: +ASSERT:_ASSERT_NULL_ failure +ASSERT:[-970] +ASSERT:_ASSERT_NOT_NULL_ failure +ASSERT:[-970] +ASSERT:_ASSERT_SAME_ failure +ASSERT:[-970][-970] expected: but was: +ASSERT:_ASSERT_NOT_SAME_ failure +ASSERT:[-970][-970] expected not same +ASSERT:_ASSERT_TRUE_ failure +ASSERT:[-970] +ASSERT:_ASSERT_FALSE_ failure +ASSERT:[-970] +ASSERT:_ASSERT_FALSE_ failure +ASSERT:[-970] +ASSERT:_FAIL_ failure +ASSERT:[-970] +ASSERT:_FAIL_NOT_EQUALS_ failure +ASSERT:[-970] expected: but was: +ASSERT:_FAIL_SAME_ failure +ASSERT:[-970] expected not same +ASSERT:_FAIL_NOT_SAME_ failure +ASSERT:[-970] expected: but was: + +# +# Test report +# +tests passed: 0 0% +tests failed: 12 100% +tests skipped: 0 0% +tests total: 12 100% + +shunit2_test.sh:WARN unable to run tests with the /bin/dash shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + +shunit2_test.sh:WARN unable to run tests with the /bin/pdksh shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# + +version: 3.0.8 + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Solaris-nv-77-x86.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Solaris-nv-77-x86.txt new file mode 100644 index 0000000..ee8df72 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.4/Solaris-nv-77-x86.txt @@ -0,0 +1,242 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests=" shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh" + +# system info +$ date +Fri Jul 11 12:01:03 GMT 2008 +$ uname -mprsv +SunOS 5.11 snv_77 i86pc i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 0 0% +tests failed: 0 0% +tests skipped: 12 100% +tests total: 12 100% + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# + +GNU bash, version 3.2.25(1)-release (i386-pc-solaris2.11) +Copyright (C) 2005 Free Software Foundation, Inc. + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + +shunit2_test.sh:WARN unable to run tests with the /bin/dash shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% + +shunit2_test.sh:WARN unable to run tests with the /bin/pdksh shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# + +version: 4.3.4 + +--- Executing the 'asserts' test suite --- +# +# Performing tests +# +testAssertEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +# +# Test report +# +tests passed: 138 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 138 100% + +--- Executing the 'failures' test suite --- +# +# Performing tests +# +testFail +testFailNotEquals +testFailSame + +# +# Test report +# +tests passed: 45 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 45 100% + +--- Executing the 'macros' test suite --- +# +# Performing tests +# +testLineNo + +# +# Test report +# +tests passed: 12 100% +tests failed: 0 0% +tests skipped: 0 0% +tests total: 12 100% diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Cygwin-5.1.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Cygwin-5.1.txt new file mode 100755 index 0000000..391bdb4 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Cygwin-5.1.txt @@ -0,0 +1,295 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests=" shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh" + +# system info +$ date +Wed Oct 29 00:37:38 GMTST 2008 +$ uname -mprsv +CYGWIN_NT-5.1 1.5.25(0.156/4/2) 2008-06-12 19:34 i686 unknown + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 3.2.39(20)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK + +shunit2_test.sh:WARN unable to run tests with the /bin/dash shell + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# +shell name: pdksh +shell version: + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 4.3.4 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Linux-Ubuntu-6.06.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Linux-Ubuntu-6.06.txt new file mode 100644 index 0000000..e609394 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Linux-Ubuntu-6.06.txt @@ -0,0 +1,294 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests=" shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh" + +# system info +$ date +Tue Oct 28 19:28:31 GMT 2008 +$ uname -mprsv +Linux 2.6.18.5-gg38server-xenU-3.1 #1 SMP Fri Jul 18 13:02:34 IST 2008 x86_64 unknown + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 3.1.17(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: M-1993-12-28-r--$ + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# +shell name: pdksh +shell version: v5.2.14-99/07/13.2 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 4.2.5 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Linux-Ubuntu-8.04.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Linux-Ubuntu-8.04.txt new file mode 100644 index 0000000..2e88cec --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Linux-Ubuntu-8.04.txt @@ -0,0 +1,349 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests=" shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh" + +# system info +$ date +Mon Oct 27 18:34:47 UTC 2008 +$ uname -mprsv +Linux 2.6.24-21-generic #1 SMP Mon Aug 25 17:32:09 UTC 2008 i686 unknown + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 3.2.39(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/dash +# +shell name: dash +shell version: 0.5.4-8ubuntu1 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: M-1993-12-28 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# +shell name: pdksh +shell version: v5.2.14-99/07/13.2 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 4.3.4 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Mac_OS_X-10.5.5.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Mac_OS_X-10.5.5.txt new file mode 100644 index 0000000..6159b4a --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Mac_OS_X-10.5.5.txt @@ -0,0 +1,239 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests=" shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh" + +# system info +$ date +Mon Oct 27 18:32:53 GMT 2008 +$ uname -mprsv +Darwin 9.5.0 Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1/RELEASE_I386 i386 i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 3.2.17(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: M-1993-12-28 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 4.3.4 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 + +Ran 2 tests. + +OK diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Solaris-11.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Solaris-11.txt new file mode 100644 index 0000000..4012ef1 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Solaris-11.txt @@ -0,0 +1,251 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests=" shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh" + +# system info +$ date +Sat Jul 12 11:43:59 GMT 2008 +$ uname -mprsv +SunOS 5.11 snv_77 i86pc i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 + +Ran 2 tests. + +FAILED (failures=3) + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 3.2.25(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 + +Ran 2 tests. + +FAILED (failures=3) + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: M-11/16/88i + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 + +Ran 2 tests. + +FAILED (failures=3) + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 4.3.4 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 + +Ran 2 tests. + +FAILED (failures=3) diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Solaris-9.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Solaris-9.txt new file mode 100644 index 0000000..3e22e94 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.5/Solaris-9.txt @@ -0,0 +1,276 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells="/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh" +tests=" shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh" + +# system info +$ date +Tue Oct 28 23:46:44 GMT 2008 +$ uname -mprsv +SunOS 5.9 Generic_117172-08 i86pc i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 + +Ran 2 tests. + +FAILED (failures=3) + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 2.05.0(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +ASSERT:_ASSERT_EQUALS_ failure +ASSERT:_ASSERT_EQUALS_ w/ msg failure +testAssertNotEquals +ASSERT:_ASSERT_NOT_EQUALS_ failure +ASSERT:_ASSERT_NOT_EQUALS_ w/ msg failure +testSame +ASSERT:_ASSERT_SAME_ failure +ASSERT:_ASSERT_SAME_ w/ msg failure +testNotSame +ASSERT:_ASSERT_NOT_SAME_ failure +ASSERT:_ASSERT_NOT_SAME_ w/ msg failure +testNull +ASSERT:_ASSERT_NULL_ failure +ASSERT:_ASSERT_NULL_ w/ msg failure +testNotNull +ASSERT:_ASSERT_NOT_NULL_ failure +ASSERT:_ASSERT_NOT_NULL_ w/ msg failure +ASSERT:[-1045] some msg +testAssertTrue +ASSERT:_ASSERT_TRUE_ failure +ASSERT:_ASSERT_TRUE_ w/ msg failure +testAssertFalse +ASSERT:_ASSERT_FALSE_ failure +ASSERT:_ASSERT_FALSE_ w/ msg failure +testFail +ASSERT:_FAIL_ failure +ASSERT:_FAIL_ w/ msg failure +testFailNotEquals +ASSERT:_FAIL_NOT_EQUALS_ failure +ASSERT:_FAIL_NOT_EQUALS_ w/ msg failure +testFailSame +ASSERT:_FAIL_SAME_ failure +ASSERT:_FAIL_SAME_ w/ msg failure +testFailNotSame +ASSERT:_FAIL_NOT_SAME_ failure +ASSERT:_FAIL_NOT_SAME_ w/ msg failure + +Ran 12 tests. + +FAILED (failures=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 + +Ran 2 tests. + +FAILED (failures=3) + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: M-11/16/88i + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 + +Ran 2 tests. + +FAILED (failures=3) + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 3.0.8 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 + +Ran 2 tests. + +FAILED (failures=3) diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Cygwin-1.7.9.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Cygwin-1.7.9.txt new file mode 100644 index 0000000..757c5b1 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Cygwin-1.7.9.txt @@ -0,0 +1,416 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells: /bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh +tests: shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh shunit2_test_standalone.sh + +# system info +$ date +Thu Apr 28 00:23:02 GMTDT 2011 + +$ uname -mprsv +CYGWIN_NT-5.1 1.7.9(0.237/5/3) 2011-03-29 10:10 i686 unknown + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 4.1.10(4)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/dash +# +shell name: dash +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: v5.2.14-99/07/13.2 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# +shell name: pdksh +shell version: v5.2.14-99/07/13.2 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 4.3.11 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Linux-Ubuntu-10.04.2-LTS.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Linux-Ubuntu-10.04.2-LTS.txt new file mode 100644 index 0000000..d450c3c --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Linux-Ubuntu-10.04.2-LTS.txt @@ -0,0 +1,416 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells: /bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh +tests: shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh shunit2_test_standalone.sh + +# system info +$ date +Wed Apr 27 23:40:39 UTC 2011 + +$ uname -mprsv +Linux 2.6.32-31-server #61-Ubuntu SMP Fri Apr 8 19:44:42 UTC 2011 x86_64 unknown + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 4.1.5(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/dash +# +shell name: dash +shell version: 0.5.5.1-3ubuntu2 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: JM-93t+-2009-05-01-$ + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# +shell name: pdksh +shell version: v5.2.14-99/07/13.2 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 4.3.10 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Linux-Ubuntu-6.06.2-LTS.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Linux-Ubuntu-6.06.2-LTS.txt new file mode 100644 index 0000000..c48a7a5 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Linux-Ubuntu-6.06.2-LTS.txt @@ -0,0 +1,416 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells: /bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh +tests: shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh shunit2_test_standalone.sh + +# system info +$ date +Wed Apr 27 16:24:19 MDT 2011 + +$ uname -mprsv +Linux 2.6.15-57-server #1 SMP Mon Feb 28 22:43:23 UTC 2011 i686 unknown + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 3.1.17(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/dash +# +shell name: dash +shell version: 0.5.3-1ubuntu1 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: v5.2.14-99/07/13.2 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# +shell name: pdksh +shell version: v5.2.14-99/07/13.2 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 4.2.5 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Linux-Ubuntu-8.04.4-LTS.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Linux-Ubuntu-8.04.4-LTS.txt new file mode 100644 index 0000000..9865b16 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Linux-Ubuntu-8.04.4-LTS.txt @@ -0,0 +1,416 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells: /bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh +tests: shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh shunit2_test_standalone.sh + +# system info +$ date +Wed Apr 27 17:24:17 CDT 2011 + +$ uname -mprsv +Linux 2.6.24-29-server #1 SMP Wed Mar 16 19:04:28 UTC 2011 x86_64 unknown + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 3.2.39(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/dash +# +shell name: dash +shell version: 0.5.4-8ubuntu1.1 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: M-1993-12-28 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# +shell name: pdksh +shell version: v5.2.14-99/07/13.2 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 4.3.4 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Mac_OS_X-10.6.7.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Mac_OS_X-10.6.7.txt new file mode 100644 index 0000000..c706bc4 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Mac_OS_X-10.6.7.txt @@ -0,0 +1,284 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells: /bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh +tests: shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh shunit2_test_standalone.sh + +# system info +$ date +Thu Apr 28 00:42:17 IST 2011 + +$ uname -mprsv +Darwin 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386 i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 3.2.48(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: M-1993-12-28 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 4.3.9 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/OpenSolaris-2009.06.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/OpenSolaris-2009.06.txt new file mode 100644 index 0000000..9d1a309 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/OpenSolaris-2009.06.txt @@ -0,0 +1,227 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells: /bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh +tests: shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh shunit2_test_standalone.sh + +# system info +$ date +Thu Apr 28 01:49:38 IST 2011 + +$ uname -mprsv +SunOS 5.11 snv_111b i86pc i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:expected a non-zero exit value +ASSERT:assert message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 3.2.25(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:expected a non-zero exit value +ASSERT:assert message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: 2008-11-04 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:expected a non-zero exit value +ASSERT:assert message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Solaris-8u7.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Solaris-8u7.txt new file mode 100644 index 0000000..a41cc06 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Solaris-8u7.txt @@ -0,0 +1,321 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells: /bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh +tests: shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh shunit2_test_standalone.sh + +# system info +$ date +Wed Apr 27 23:37:38 IST 2011 + +$ uname -mprsv +SunOS 5.8 Generic_108529-13 i86pc i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 2.03.0(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +ASSERT:_ASSERT_EQUALS_ failure +ASSERT:_ASSERT_EQUALS_ w/ msg failure +testAssertNotEquals +ASSERT:_ASSERT_NOT_EQUALS_ failure +ASSERT:_ASSERT_NOT_EQUALS_ w/ msg failure +testSame +ASSERT:_ASSERT_SAME_ failure +ASSERT:_ASSERT_SAME_ w/ msg failure +testNotSame +ASSERT:_ASSERT_NOT_SAME_ failure +ASSERT:_ASSERT_NOT_SAME_ w/ msg failure +testNull +ASSERT:_ASSERT_NULL_ failure +ASSERT:_ASSERT_NULL_ w/ msg failure +testNotNull +ASSERT:_ASSERT_NOT_NULL_ failure +ASSERT:_ASSERT_NOT_NULL_ w/ msg failure +ASSERT:[-875] some msg +testAssertTrue +ASSERT:_ASSERT_TRUE_ failure +ASSERT:_ASSERT_TRUE_ w/ msg failure +testAssertFalse +ASSERT:_ASSERT_FALSE_ failure +ASSERT:_ASSERT_FALSE_ w/ msg failure +testFail +ASSERT:_FAIL_ failure +ASSERT:_FAIL_ w/ msg failure +testFailNotEquals +ASSERT:_FAIL_NOT_EQUALS_ failure +ASSERT:_FAIL_NOT_EQUALS_ w/ msg failure +testFailSame +ASSERT:_FAIL_SAME_ failure +ASSERT:_FAIL_SAME_ w/ msg failure +testFailNotSame +ASSERT:_FAIL_NOT_SAME_ failure +ASSERT:_FAIL_NOT_SAME_ w/ msg failure + +Ran 12 tests. + +FAILED (failures=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: M-11/16/88i + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 3.0.6 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Solaris-9u6.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Solaris-9u6.txt new file mode 100644 index 0000000..11daebb --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Solaris-9u6.txt @@ -0,0 +1,321 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells: /bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh +tests: shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh shunit2_test_standalone.sh + +# system info +$ date +Wed Apr 27 23:17:50 GMT 2011 + +$ uname -mprsv +SunOS 5.9 Generic_117172-08 i86pc i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 2.05.0(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +ASSERT:_ASSERT_EQUALS_ failure +ASSERT:_ASSERT_EQUALS_ w/ msg failure +testAssertNotEquals +ASSERT:_ASSERT_NOT_EQUALS_ failure +ASSERT:_ASSERT_NOT_EQUALS_ w/ msg failure +testSame +ASSERT:_ASSERT_SAME_ failure +ASSERT:_ASSERT_SAME_ w/ msg failure +testNotSame +ASSERT:_ASSERT_NOT_SAME_ failure +ASSERT:_ASSERT_NOT_SAME_ w/ msg failure +testNull +ASSERT:_ASSERT_NULL_ failure +ASSERT:_ASSERT_NULL_ w/ msg failure +testNotNull +ASSERT:_ASSERT_NOT_NULL_ failure +ASSERT:_ASSERT_NOT_NULL_ w/ msg failure +ASSERT:[-875] some msg +testAssertTrue +ASSERT:_ASSERT_TRUE_ failure +ASSERT:_ASSERT_TRUE_ w/ msg failure +testAssertFalse +ASSERT:_ASSERT_FALSE_ failure +ASSERT:_ASSERT_FALSE_ w/ msg failure +testFail +ASSERT:_FAIL_ failure +ASSERT:_FAIL_ w/ msg failure +testFailNotEquals +ASSERT:_FAIL_NOT_EQUALS_ failure +ASSERT:_FAIL_NOT_EQUALS_ w/ msg failure +testFailSame +ASSERT:_FAIL_SAME_ failure +ASSERT:_FAIL_SAME_ w/ msg failure +testFailNotSame +ASSERT:_FAIL_NOT_SAME_ failure +ASSERT:_FAIL_NOT_SAME_ w/ msg failure + +Ran 12 tests. + +FAILED (failures=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: M-11/16/88i + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 3.0.8 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Solaris-9u8.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Solaris-9u8.txt new file mode 100644 index 0000000..db2661c --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.6/Solaris-9u8.txt @@ -0,0 +1,321 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells: /bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh +tests: shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh shunit2_test_standalone.sh + +# system info +$ date +Fri Apr 22 11:25:16 GMT 2011 + +$ uname -mprsv +SunOS 5.9 Generic_118559-11 i86pc i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 2.05.0(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +ASSERT:_ASSERT_EQUALS_ failure +ASSERT:_ASSERT_EQUALS_ w/ msg failure +testAssertNotEquals +ASSERT:_ASSERT_NOT_EQUALS_ failure +ASSERT:_ASSERT_NOT_EQUALS_ w/ msg failure +testSame +ASSERT:_ASSERT_SAME_ failure +ASSERT:_ASSERT_SAME_ w/ msg failure +testNotSame +ASSERT:_ASSERT_NOT_SAME_ failure +ASSERT:_ASSERT_NOT_SAME_ w/ msg failure +testNull +ASSERT:_ASSERT_NULL_ failure +ASSERT:_ASSERT_NULL_ w/ msg failure +testNotNull +ASSERT:_ASSERT_NOT_NULL_ failure +ASSERT:_ASSERT_NOT_NULL_ w/ msg failure +ASSERT:[-875] some msg +testAssertTrue +ASSERT:_ASSERT_TRUE_ failure +ASSERT:_ASSERT_TRUE_ w/ msg failure +testAssertFalse +ASSERT:_ASSERT_FALSE_ failure +ASSERT:_ASSERT_FALSE_ w/ msg failure +testFail +ASSERT:_FAIL_ failure +ASSERT:_FAIL_ w/ msg failure +testFailNotEquals +ASSERT:_FAIL_NOT_EQUALS_ failure +ASSERT:_FAIL_NOT_EQUALS_ w/ msg failure +testFailSame +ASSERT:_FAIL_SAME_ failure +ASSERT:_FAIL_SAME_ w/ msg failure +testFailNotSame +ASSERT:_FAIL_NOT_SAME_ failure +ASSERT:_FAIL_NOT_SAME_ w/ msg failure + +Ran 12 tests. + +FAILED (failures=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: M-11/16/88i + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 3.0.8 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.7/Linux-Ubuntu-10.04.4-LTS.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.7/Linux-Ubuntu-10.04.4-LTS.txt new file mode 100644 index 0000000..699662f --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.7/Linux-Ubuntu-10.04.4-LTS.txt @@ -0,0 +1,416 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells: /bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh +tests: shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh shunit2_test_standalone.sh + +# system info +$ date +Mon May 20 17:55:52 CEST 2013 + +$ uname -mprsv +Linux 2.6.32-45-server #101-Ubuntu SMP Mon Dec 3 15:54:27 UTC 2012 x86_64 unknown + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 4.1.5(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/dash +# +shell name: dash +shell version: 0.5.5.1-3ubuntu2 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: JM-93t+-2009-05-01-$ + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# +shell name: pdksh +shell version: v5.2.14-99/07/13.2 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 4.3.10 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.7/Linux-Ubuntu-12.04.2-LTS.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.7/Linux-Ubuntu-12.04.2-LTS.txt new file mode 100644 index 0000000..857fb74 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.7/Linux-Ubuntu-12.04.2-LTS.txt @@ -0,0 +1,416 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells: /bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh +tests: shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh shunit2_test_standalone.sh + +# system info +$ date +Mon May 20 16:57:14 CEST 2013 + +$ uname -mprsv +Linux 3.2.0-40-generic #64-Ubuntu SMP Mon Mar 25 21:22:10 UTC 2013 x86_64 x86_64 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 4.2.25(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/dash +# +shell name: dash +shell version: 0.5.7-2ubuntu2 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: JM-93u-2011-02-08-$ + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# +shell name: pdksh +shell version: v5.2.14-99/07/13.2 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 4.3.17 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.7/Linux-Ubuntu-8.04.4-LTS.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.7/Linux-Ubuntu-8.04.4-LTS.txt new file mode 100644 index 0000000..e3ec84e --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.7/Linux-Ubuntu-8.04.4-LTS.txt @@ -0,0 +1,416 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells: /bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh +tests: shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh shunit2_test_standalone.sh + +# system info +$ date +Mon May 20 17:55:54 CEST 2013 + +$ uname -mprsv +Linux 2.6.24-32-server #1 SMP Mon Dec 3 15:54:12 UTC 2012 x86_64 unknown + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 3.2.39(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/dash +# +shell name: dash +shell version: 0.5.4-8ubuntu1.1 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: M-1993-12-28 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/pdksh +# +shell name: pdksh +shell version: v5.2.14-99/07/13.2 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 4.3.4 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +OK + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.7/OpenSolaris-2009.06(snv_111b).txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.7/OpenSolaris-2009.06(snv_111b).txt new file mode 100644 index 0000000..e4df26e --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.7/OpenSolaris-2009.06(snv_111b).txt @@ -0,0 +1,227 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells: /bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh +tests: shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh shunit2_test_standalone.sh + +# system info +$ date +Mon May 20 17:55:59 CEST 2013 + +$ uname -mprsv +SunOS 5.11 snv_111b i86pc i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:expected a non-zero exit value +ASSERT:assert message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 3.2.25(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:expected a non-zero exit value +ASSERT:assert message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:expected a non-zero exit value +ASSERT:assert message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + diff --git a/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.7/Solaris-10u10.txt b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.7/Solaris-10u10.txt new file mode 100644 index 0000000..9367c5f --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/shunit2/website/testresults/2.1.7/Solaris-10u10.txt @@ -0,0 +1,296 @@ +#------------------------------------------------------------------------------ +# System data +# + +# test run info +shells: /bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh +tests: shunit2_test_asserts.sh shunit2_test_failures.sh shunit2_test_macros.sh shunit2_test_misc.sh shunit2_test_standalone.sh + +# system info +$ date +Mon May 20 17:56:24 CEST 2013 + +$ uname -mprsv +SunOS 5.10 Generic_147441-01 i86pc i386 + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/sh +# +shell name: sh +shell version: unknown + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK (skipped=24) + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/bash +# +shell name: bash +shell version: 3.2.51(1)-release + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/ksh +# +shell name: ksh +shell version: M-11/16/88i + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK + + + +#------------------------------------------------------------------------------ +# Running the test suite with /bin/zsh +# +shell name: zsh +shell version: 4.2.1 + +--- Executing the 'asserts' test suite --- +testAssertEquals +testAssertNotEquals +testAssertSame +testAssertNotSame +testAssertNull +testAssertNotNull +testAssertTrue +testAssertFalse + +Ran 8 tests. + +OK + +--- Executing the 'failures' test suite --- +testFail +testFailNotEquals +testFailSame + +Ran 3 tests. + +OK + +--- Executing the 'macros' test suite --- +testAssertEquals +testAssertNotEquals +testSame +testNotSame +testNull +testNotNull +testAssertTrue +testAssertFalse +testFail +testFailNotEquals +testFailSame +testFailNotSame + +Ran 12 tests. + +OK + +--- Executing the 'misc' test suite --- +testUnboundVariable +ASSERT:assert message was not generated +ASSERT:test count message was not generated +ASSERT:failure message was not generated +testIssue7 +testPrepForSourcing +testEscapeCharInStr +testEscapeCharInStr_specialChars +testExtractTestFunctions + +Ran 6 tests. + +FAILED (failures=3) + +--- Executing the 'standalone' test suite --- +testStandalone + +Ran 1 test. + +OK diff --git a/.zprezto/modules/prompt/external/powerlevel9k/test-bsd-vm/Vagrantfile b/.zprezto/modules/prompt/external/powerlevel9k/test-bsd-vm/Vagrantfile new file mode 100644 index 0000000..7df512a --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test-bsd-vm/Vagrantfile @@ -0,0 +1,87 @@ +# -*- 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/.zprezto/modules/prompt/external/powerlevel9k/test-bsd-vm/bootstrap-zero.sh b/.zprezto/modules/prompt/external/powerlevel9k/test-bsd-vm/bootstrap-zero.sh new file mode 100644 index 0000000..35dcd7f --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test-bsd-vm/bootstrap-zero.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +pkg install -y sudo \ No newline at end of file diff --git a/.zprezto/modules/prompt/external/powerlevel9k/test-bsd-vm/bootstrap.sh b/.zprezto/modules/prompt/external/powerlevel9k/test-bsd-vm/bootstrap.sh new file mode 100644 index 0000000..ba27ffb --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test-bsd-vm/bootstrap.sh @@ -0,0 +1,13 @@ +#!/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/.zprezto/modules/prompt/external/powerlevel9k/test-in-docker b/.zprezto/modules/prompt/external/powerlevel9k/test-in-docker new file mode 100755 index 0000000..3c7255e --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test-in-docker @@ -0,0 +1,179 @@ +#!/usr/bin/env zsh + +set -eu + +# The default ZSH to use. +default_version='4.3.11' + +setopt extended_glob glob_subst numeric_glob_sort +cd "${${(%):-%x}:A:h}" + +# TODO: Crazy Logic to munge TERM to something supported in Ubuntu 14.04 +term=screen-256color + +# Note: If versions and frameworks looks complicated, it isn't that bad... +# ...see Modifiers in zshexpn(1) for details. + +# List of ZSH versions +typeset -a versions +versions=( docker/base-*/Dockerfile(N.on:h:t:s/base-//) ) + +# List of frameworks +typeset -a frameworks +frameworks=( docker/*/Dockerfile(N.on:h:t) ) +frameworks=${(@)frameworks:#base-*} + +# Known Issues +typeset -A known_issues +known_issues["4.3.11-antigen"]="Antigen commands that need git won't work; it needs a newer version of git." +known_issues["4.3.11-zim"]="BROKEN: Zim wants ZSH 5.2 or newer." +known_issues["5.0.3-zim"]="DEPRECATED: Zim wants ZSH 5.2 or newer." +known_issues["5.1.1-zim"]="DEPRECATED: Zim wants ZSH 5.2 or newer." +known_issues["4.3.11-zulu"]="Zulu doesn't work; it needs a newer version of git." + +err() +{ + print -P "%F{red}Error:%f $*" + exit 2 +} + +resolve_framework() { + local f=$1 found + found=${frameworks[(In:-1:)$f*]} + if (( found <= $#frameworks )); then + echo "${frameworks[$found]}" + fi +} + +resolve_version() { + local v=$1 found + found=${versions[(In:-1:)$v*]} + if (( found <= $#versions )); then + echo "${versions[$found]}" + fi +} + +check_for_known_issues() { + local version="$1" + local framework="$2" + local name="${version}-${framework}" + + if (( ${+known_issues["$name"]} )); then + echo + print -P "%F{red}Known Issue: %F{yellow}${known_issues["$name"]}%f" + echo + fi +} + +build_and_run() { + local version="$1" + local framework="$2" + local name="${version}-${framework}" + + check_for_known_issues "$version" "$framework" + + print -P "%F{green}Preparing containers...%f" + + echo -n "p9k:base-${version}: " + docker build \ + --quiet \ + --tag "p9k:base-${version}" \ + --file "docker/base-${version}/Dockerfile" \ + . + + echo -n "p9k:${version}-${framework}: " + docker build \ + --quiet \ + --build-arg="base=base-${version}" \ + --tag "p9k:${version}-${framework}" \ + --file "docker/${framework}/Dockerfile" \ + . + + print -P "%F{green}Starting ${name} container...%f" + exec docker run \ + --rm \ + --interactive \ + --tty \ + --hostname="${name//./_}" \ + --env="TERM=${term}" \ + "p9k:${version}-${framework}" +} + +show_help() { + local f v + echo "Usage: ${(%):-%x} |--list" + echo + echo "Loads up a docker image with powershell9k configured in " + echo + echo " --frameworks Lists all available frameworks, newline separated." + echo " --versions Lists all available ZSH versions, newline separated." + echo " --zsh VER Uses ZSH with version VER." + echo " --help You're soaking in it." + echo + echo "ZSH versions:" + for v in "${(@)versions}"; do + echo " $v" + done + echo + echo "Framework containers:" + for f in "${(@)frameworks}"; do + echo " $f" + done +} + +# No arguments +if (( $# == 0 )); then + show_help + exit +fi + +# Parse flags and such. +use_version=$default_version +use_framework= +while (( $# > 0 )); do + case "$1" in + -f | --frameworks ) + print -l "${(@)frameworks}" + exit + ;; + -v | --versions ) + print -l "${(@)versions}" + exit + ;; + -z | --zsh ) + shift + local v="$(resolve_version "$1")" + if [[ -n "$v" ]]; then + use_version=$v + else + err "No such ZSH version '${1}'" + fi + ;; + -h | --help ) + show_help + exit + ;;; + -* ) + err "Unknown option ${1}" + show_help + exit 1 + ;; + * ) + if [[ -z "$use_framework" ]]; then + local f="$(resolve_framework "$1")" + if [[ -n "$f" ]]; then + use_framework=$f + else + err "No such framework '${1}'" + fi + else + err "You can only specify one framework at a time; you already specified '${use_framework}'" + fi + ;; + esac + shift +done + +build_and_run "$use_version" "$use_framework" + +# EOF diff --git a/.zprezto/modules/prompt/external/powerlevel9k/test-vm-providers/plain.sh b/.zprezto/modules/prompt/external/powerlevel9k/test-vm-providers/plain.sh new file mode 100644 index 0000000..b827a0c --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test-vm-providers/plain.sh @@ -0,0 +1,9 @@ +#!/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/.zprezto/modules/prompt/external/powerlevel9k/test-vm-providers/setup-environment.sh b/.zprezto/modules/prompt/external/powerlevel9k/test-vm-providers/setup-environment.sh new file mode 100755 index 0000000..0e8beb6 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test-vm-providers/setup-environment.sh @@ -0,0 +1,44 @@ +#!/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/.zprezto/modules/prompt/external/powerlevel9k/test-vm/README.md b/.zprezto/modules/prompt/external/powerlevel9k/test-vm/README.md new file mode 100644 index 0000000..9f0861e --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test-vm/README.md @@ -0,0 +1,25 @@ +# 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/.zprezto/modules/prompt/external/powerlevel9k/test-vm/Vagrantfile b/.zprezto/modules/prompt/external/powerlevel9k/test-vm/Vagrantfile new file mode 100644 index 0000000..a421c70 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test-vm/Vagrantfile @@ -0,0 +1,82 @@ +# -*- 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/.zprezto/modules/prompt/external/powerlevel9k/test-vm/antigen.sh b/.zprezto/modules/prompt/external/powerlevel9k/test-vm/antigen.sh new file mode 100644 index 0000000..2c56332 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test-vm/antigen.sh @@ -0,0 +1,30 @@ +#!/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/.zprezto/modules/prompt/external/powerlevel9k/test-vm/bootstrap.sh b/.zprezto/modules/prompt/external/powerlevel9k/test-vm/bootstrap.sh new file mode 100644 index 0000000..f680d4b --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test-vm/bootstrap.sh @@ -0,0 +1,19 @@ +#!/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/.zprezto/modules/prompt/external/powerlevel9k/test-vm/omz.sh b/.zprezto/modules/prompt/external/powerlevel9k/test-vm/omz.sh new file mode 100644 index 0000000..73b659f --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test-vm/omz.sh @@ -0,0 +1,33 @@ +#!/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/.zprezto/modules/prompt/external/powerlevel9k/test-vm/prezto.sh b/.zprezto/modules/prompt/external/powerlevel9k/test-vm/prezto.sh new file mode 100644 index 0000000..3ac3850 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test-vm/prezto.sh @@ -0,0 +1,29 @@ +#!/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/.zprezto/modules/prompt/external/powerlevel9k/test/functions/colors.spec b/.zprezto/modules/prompt/external/powerlevel9k/test/functions/colors.spec new file mode 100755 index 0000000..61a4008 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test/functions/colors.spec @@ -0,0 +1,42 @@ +#!/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/.zprezto/modules/prompt/external/powerlevel9k/test/functions/icons.spec b/.zprezto/modules/prompt/external/powerlevel9k/test/functions/icons.spec new file mode 100755 index 0000000..c8d8864 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test/functions/icons.spec @@ -0,0 +1,362 @@ +#!/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/.zprezto/modules/prompt/external/powerlevel9k/test/functions/utilities.spec b/.zprezto/modules/prompt/external/powerlevel9k/test/functions/utilities.spec new file mode 100755 index 0000000..a9bd67e --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test/functions/utilities.spec @@ -0,0 +1,109 @@ +#!/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/.zprezto/modules/prompt/external/powerlevel9k/test/powerlevel9k.spec b/.zprezto/modules/prompt/external/powerlevel9k/test/powerlevel9k.spec new file mode 100755 index 0000000..0ddf36c --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test/powerlevel9k.spec @@ -0,0 +1,136 @@ +#!/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 +} + +function testNewlineOnRpromptCanBeDisabled() { + POWERLEVEL9K_PROMPT_ON_NEWLINE=true + POWERLEVEL9K_RPROMPT_ON_NEWLINE=false + POWERLEVEL9K_CUSTOM_WORLD='echo world' + POWERLEVEL9K_CUSTOM_RWORLD='echo rworld' + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world) + POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_rworld) + + powerlevel9k_prepare_prompts + assertEquals '$(print_icon MULTILINE_FIRST_PROMPT_PREFIX) world  $(print_icon MULTILINE_LAST_PROMPT_PREFIX) rworld' "$(print -P ${PROMPT}${RPROMPT})" + + unset POWERLEVEL9K_PROMPT_ON_NEWLINE + unset POWERLEVEL9K_RPROMPT_ON_NEWLINE + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS + unset POWERLEVEL9K_CUSTOM_WORLD + unset POWERLEVEL9K_CUSTOM_RWORLD +} + +source shunit2/source/2.1/src/shunit2 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/test/segments/command_execution_time.spec b/.zprezto/modules/prompt/external/powerlevel9k/test/segments/command_execution_time.spec new file mode 100755 index 0000000..d3588d8 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test/segments/command_execution_time.spec @@ -0,0 +1,96 @@ +#!/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{yellow1%}Dur %f%F{yellow1}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{yellow1%}Dur %f%F{yellow1}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{yellow1%}Dur %f%F{yellow1}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{yellow1%}Dur %f%F{yellow1}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{yellow1%}Dur %f%F{yellow1}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{yellow1%}Dur %f%F{yellow1}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/.zprezto/modules/prompt/external/powerlevel9k/test/segments/dir.spec b/.zprezto/modules/prompt/external/powerlevel9k/test/segments/dir.spec new file mode 100755 index 0000000..b5fce59 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test/segments/dir.spec @@ -0,0 +1,647 @@ +#!/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 testDirPathAbsoluteWorks() { + POWERLEVEL9K_DIR_PATH_ABSOLUTE=true + + cd ~ + assertEquals "%K{blue} %F{black}/home/travis %k%F{blue}%f " "$(build_left_prompt)" + + cd - + unset POWERLEVEL9K_DIR_PATH_ABSOLUTE +} + +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 testTruncateFolderWithHomeDirWorks() { + POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 + CURRENT_DIR=$(pwd) + + cd ~ + FOLDER="powerlevel9k-test-${RANDOM}" + mkdir -p $FOLDER + cd $FOLDER + # Switch back to home folder as this causes the problem. + cd .. + + assertEquals "%K{blue} %F{black}~ %k%F{blue}%f " "$(build_left_prompt)" + + rmdir $FOLDER + cd ${CURRENT_DIR} + + unset CURRENT_DIR + unset FOLDER + unset POWERLEVEL9K_SHORTEN_DIR_LENGTH +} + +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 testTruncateToLastWorks() { + POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_last" + + FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 + mkdir -p $FOLDER + cd $FOLDER + + assertEquals "%K{blue} %F{black}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 testTruncateToFirstAndLastWorks() { + POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_first_and_last" + + FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 + mkdir -p $FOLDER + cd $FOLDER + + assertEquals "%K{blue} %F{black}/tmp/powerlevel9k-test/…/…/…/…/…/…/…/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 testTruncateAbsoluteWorks() { + POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + POWERLEVEL9K_SHORTEN_STRATEGY="truncate_absolute" + + FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 + mkdir -p $FOLDER + cd $FOLDER + + assertEquals "%K{blue} %F{black}…89 %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 testTruncationFromRightWithEmptyDelimiter() { + POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + POWERLEVEL9K_SHORTEN_DELIMITER="" + 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_DELIMITER + 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 testHomeFolderAbbreviation() { + local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION + local dir=$PWD + + cd ~/ + # default + POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~' + assertEquals "%K{blue} %F{black}~ %k%F{blue}%f " "$(build_left_prompt)" + + # substituted + POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq' + assertEquals "%K{blue} %F{black}qQq %k%F{blue}%f " "$(build_left_prompt)" + + cd /tmp + # default + POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~' + assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + + # substituted + POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq' + assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + + cd "$dir" +} + +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 +} + +function testTruncateToUniqueWorks() { + POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true + POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' + POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + POWERLEVEL9K_SHORTEN_STRATEGY='truncate_to_unique' + mkdir -p /tmp/powerlevel9k-test/adam/devl + mkdir -p /tmp/powerlevel9k-test/alice/devl + mkdir -p /tmp/powerlevel9k-test/alice/docs + mkdir -p /tmp/powerlevel9k-test/bob/docs + cd /tmp/powerlevel9k-test/alice/devl + + assertEquals "%K{blue} %F{black}txXxpxXxalxXxde %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 testBoldHomeDirWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + cd ~ + + assertEquals "%K{blue} %F{black}%B~%b %k%F{blue}%f " "$(build_left_prompt)" + + cd - + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD +} + +function testBoldHomeSubdirWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + mkdir -p ~/powerlevel9k-test + cd ~/powerlevel9k-test + + assertEquals "%K{blue} %F{black}~/%Bpowerlevel9k-test%b %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr ~/powerlevel9k-test + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD +} + +function testBoldRootDirWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + cd / + + assertEquals "%K{blue} %F{black}%B/%b %k%F{blue}%f " "$(build_left_prompt)" + + cd - + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD +} + +function testBoldRootSubdirWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + cd /tmp + + assertEquals "%K{blue} %F{black}/%Btmp%b %k%F{blue}%f " "$(build_left_prompt)" + + cd - + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD +} + +function testBoldRootSubSubdirWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + mkdir -p /tmp/powerlevel9k-test + cd /tmp/powerlevel9k-test + + assertEquals "%K{blue} %F{black}/tmp/%Bpowerlevel9k-test%b %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD +} + +function testHighlightHomeWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + cd ~ + + assertEquals "%K{blue} %F{black}%F{red}~ %k%F{blue}%f " "$(build_left_prompt)" + + cd - + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND +} + +function testHighlightHomeSubdirWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + mkdir -p ~/powerlevel9k-test + cd ~/powerlevel9k-test + + assertEquals "%K{blue} %F{black}~/%F{red}powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr ~/powerlevel9k-test + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND +} + +function testHighlightRootWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + cd / + + assertEquals "%K{blue} %F{black}%F{red}/ %k%F{blue}%f " "$(build_left_prompt)" + + cd - + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND +} + +function testHighlightRootSubdirWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + cd /tmp + + assertEquals "%K{blue} %F{black}/%F{red}tmp %k%F{blue}%f " "$(build_left_prompt)" + + cd - + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND +} + +function testHighlightRootSubSubdirWorks() { + POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + mkdir /tmp/powerlevel9k-test + cd /tmp/powerlevel9k-test + + assertEquals "%K{blue} %F{black}/tmp/%F{red}powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND +} + +function testDirSeparatorColorHomeSubdirWorks() { + POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND='red' + mkdir -p ~/powerlevel9k-test + cd ~/powerlevel9k-test + + assertEquals "%K{blue} %F{black}~%F{red}/%F{black}powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr ~/powerlevel9k-test + unset POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND +} + +function testDirSeparatorColorRootSubSubdirWorks() { + POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND='red' + mkdir -p /tmp/powerlevel9k-test + cd /tmp/powerlevel9k-test + + assertEquals "%K{blue} %F{black}%F{red}/%F{black}tmp%F{red}/%F{black}powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + unset POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND +} + +source shunit2/source/2.1/src/shunit2 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/test/segments/go_version.spec b/.zprezto/modules/prompt/external/powerlevel9k/test/segments/go_version.spec new file mode 100755 index 0000000..9104ac8 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test/segments/go_version.spec @@ -0,0 +1,86 @@ +#!/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{grey93%} %f%F{grey93}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/.zprezto/modules/prompt/external/powerlevel9k/test/segments/kubecontext.spec b/.zprezto/modules/prompt/external/powerlevel9k/test/segments/kubecontext.spec new file mode 100755 index 0000000..6381037 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test/segments/kubecontext.spec @@ -0,0 +1,98 @@ +#!/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 mockKubectl() { + case "$1" in + 'version') + echo 'non-empty text' + ;; + 'config') + case "$2" in + 'view') + case "$3" in + '-o=jsonpath={.current-context}') + echo 'minikube' + ;; + '-o=jsonpath={.contexts'*) + echo '' + ;; + *) + echo "Mock value missed" + exit 1 + ;; + esac + ;; + esac + ;; + esac +} + +function mockKubectlOtherNamespace() { + case "$1" in + 'version') + echo 'non-empty text' + ;; + 'config') + case "$2" in + 'view') + case "$3" in + # Get Current Context + '-o=jsonpath={.current-context}') + echo 'minikube' + ;; + # Get current namespace + '-o=jsonpath={.contexts'*) + echo 'kube-system' + ;; + *) + echo "Mock value missed" + exit 1 + ;; + esac + ;; + esac + ;; + esac +} + +function testKubeContext() { + alias kubectl=mockKubectl + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext) + + assertEquals "%K{magenta} %F{white%}⎈ %f%F{white}minikube/default %k%F{magenta}%f " "$(build_left_prompt)" + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unalias kubectl +} +function testKubeContextOtherNamespace() { + alias kubectl=mockKubectlOtherNamespace + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext) + + assertEquals "%K{magenta} %F{white%}⎈ %f%F{white}minikube/kube-system %k%F{magenta}%f " "$(build_left_prompt)" + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unalias kubectl +} +function testKubeContextPrintsNothingIfKubectlNotAvailable() { + alias kubectl=noKubectl + POWERLEVEL9K_CUSTOM_WORLD='echo world' + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world kubecontext) + + assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset POWERLEVEL9K_CUSTOM_WORLD + unalias kubectl +} + +source shunit2/source/2.1/src/shunit2 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/test/segments/laravel_version.spec b/.zprezto/modules/prompt/external/powerlevel9k/test/segments/laravel_version.spec new file mode 100755 index 0000000..40b130d --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test/segments/laravel_version.spec @@ -0,0 +1,69 @@ +#!/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 mockLaravelVersion() { + case "$1" in + "artisan") + echo "Laravel Framework version 5.4.23" + ;; + default) + esac +} + +function mockNoLaravelVersion() { + # This should output some error + >&2 echo "Artisan not available" + return 1 +} + +function testLaravelVersionSegment() { + alias php=mockLaravelVersion + POWERLEVEL9K_LARAVEL_ICON='x' + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(laravel_version) + + assertEquals "%K{001} %F{white%}x %f%F{white}5.4.23 %k%F{maroon}%f " "$(build_left_prompt)" + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset POWERLEVEL9K_LARAVEL_ICON + unalias php +} + +function testLaravelVersionSegmentIfArtisanIsNotAvailable() { + alias php=mockNoLaravelVersion + POWERLEVEL9K_CUSTOM_WORLD='echo world' + POWERLEVEL9K_LARAVEL_ICON='x' + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world laravel_version) + + assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset POWERLEVEL9K_LARAVEL_ICON + unset POWERLEVEL9K_CUSTOM_WORLD + unalias php +} + +function testLaravelVersionSegmentPrintsNothingIfPhpIsNotAvailable() { + alias php=noPhp + POWERLEVEL9K_CUSTOM_WORLD='echo world' + POWERLEVEL9K_LARAVEL_ICON='x' + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world laravel_version) + + assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset POWERLEVEL9K_LARAVEL_ICON + unset POWERLEVEL9K_CUSTOM_WORLD + unalias php +} + +source shunit2/source/2.1/src/shunit2 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/test/segments/rust_version.spec b/.zprezto/modules/prompt/external/powerlevel9k/test/segments/rust_version.spec new file mode 100755 index 0000000..34883a1 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test/segments/rust_version.spec @@ -0,0 +1,50 @@ +#!/usr/bin/env zsh +#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 + +# Required for shunit2 to run correctly +setopt shwordsplit +SHUNIT_PARENT=$0 + +TEST_BASE_FOLDER=/tmp/powerlevel9k-test +RUST_TEST_FOLDER="${TEST_BASE_FOLDER}/rust-test" + +function setUp() { + OLDPATH="${PATH}" + mkdir -p "${RUST_TEST_FOLDER}" + PATH="${RUST_TEST_FOLDER}:${PATH}" + + export TERM="xterm-256color" + # Load Powerlevel9k + source powerlevel9k.zsh-theme +} + +function tearDown() { + PATH="${OLDPATH}" + rm -fr "${TEST_BASE_FOLDER}" +} + +function mockRust() { + echo "#!/bin/sh\n\necho 'rustc 0.4.1a-alpha'" > "${RUST_TEST_FOLDER}/rustc" + chmod +x "${RUST_TEST_FOLDER}/rustc" +} + +function testRust() { + mockRust + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version) + + assertEquals "%K{208} %F{black%}Rust %f%F{black}0.4.1a-alpha %k%F{darkorange}%f " "$(build_left_prompt)" + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS +} + +function testRustPrintsNothingIfRustIsNotAvailable() { + 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 +} + +source shunit2/source/2.1/src/shunit2 diff --git a/.zprezto/modules/prompt/external/powerlevel9k/test/segments/vcs.spec b/.zprezto/modules/prompt/external/powerlevel9k/test/segments/vcs.spec new file mode 100755 index 0000000..f6474f6 --- /dev/null +++ b/.zprezto/modules/prompt/external/powerlevel9k/test/segments/vcs.spec @@ -0,0 +1,161 @@ +#!/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 +} + +function testBranchNameTruncatingShortenLength() { + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) + POWERLEVEL9K_VCS_SHORTEN_LENGTH=6 + POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=3 + POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right" + + FOLDER=/tmp/powerlevel9k-test/vcs-test + mkdir -p $FOLDER + cd $FOLDER + git init 1>/dev/null + touch testfile + + assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)" + + POWERLEVEL9K_VCS_SHORTEN_LENGTH=3 + assertEquals "%K{green} %F{black} mas… ? %k%F{green}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset POWERLEVEL9K_VCS_SHORTEN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY +} + +function testBranchNameTruncatingMinLength() { + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) + POWERLEVEL9K_VCS_SHORTEN_LENGTH=3 + POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=6 + POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right" + + FOLDER=/tmp/powerlevel9k-test/vcs-test + mkdir -p $FOLDER + cd $FOLDER + git init 1>/dev/null + touch testfile + + assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)" + + POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=7 + + assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset POWERLEVEL9K_VCS_SHORTEN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY +} + +function testBranchNameTruncatingShortenStrategy() { + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) + POWERLEVEL9K_VCS_SHORTEN_LENGTH=3 + POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=3 + POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right" + + FOLDER=/tmp/powerlevel9k-test/vcs-test + mkdir -p $FOLDER + cd $FOLDER + git init 1>/dev/null + touch testfile + + assertEquals "%K{green} %F{black} mas… ? %k%F{green}%f " "$(build_left_prompt)" + + POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_middle" + + assertEquals "%K{green} %F{black} mas…ter ? %k%F{green}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset POWERLEVEL9K_VCS_SHORTEN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY +} + +source shunit2/source/2.1/src/shunit2 diff --git a/.zprezto/modules/prompt/external/powerline/.git_backup b/.zprezto/modules/prompt/external/powerline/.git_backup new file mode 100644 index 0000000..c70a88e --- /dev/null +++ b/.zprezto/modules/prompt/external/powerline/.git_backup @@ -0,0 +1 @@ +gitdir: ../../../../.git/modules/modules/prompt/external/powerline diff --git a/.zprezto/modules/prompt/external/powerline/prompt_powerline_setup b/.zprezto/modules/prompt/external/powerline/prompt_powerline_setup index 1f13956..a27b67b 100644 --- a/.zprezto/modules/prompt/external/powerline/prompt_powerline_setup +++ b/.zprezto/modules/prompt/external/powerline/prompt_powerline_setup @@ -15,19 +15,19 @@ ZSH_THEME_REP_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}" ZSH_THEME_REP_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}" # returns the time since last git commit -function git_time_details() { +git_time_details()() { # only proceed if there is actually a git repository - if `git rev-parse --git-dir > /dev/null 2>&1`; then + if $(git rev-parse --git-dir > /dev/null 2>&1); then # only proceed if there is actually a commit if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then # get the last commit hash - # lc_hash=`git log --pretty=format:'%h' -1 2> /dev/null` + # lc_hash=$(git log --pretty=format:'%h' -1 2> /dev/null) # get the last commit time - lc_time=`git log --pretty=format:'%at' -1 2> /dev/null` + lc_time=$(git log --pretty=format:'%at' -1 2> /dev/null) - now=`date +%s` + now=$(date +%s) seconds_since_last_commit=$((now-lc_time)) - lc_time_since=`time_since_commit $seconds_since_last_commit` + lc_time_since=$(time_since_commit $seconds_since_last_commit) echo "$lc_time_since" else @@ -39,7 +39,7 @@ function git_time_details() { } # returns the time by given seconds -function time_since_commit() { +time_since_commit()() { seconds_since_last_commit=$(($1 + 0)) # totals @@ -60,7 +60,7 @@ function time_since_commit() { fi } -function rvm_info_for_prompt { +rvm_info_for_prompt() { if [[ -d ~/.rvm/ ]]; then local ruby_version=$(~/.rvm/bin/rvm-prompt) if [ -n "$ruby_version" ]; then @@ -71,7 +71,7 @@ function rvm_info_for_prompt { fi } -function prompt_powerline_precmd { +prompt_powerline_precmd() { # Check for untracked files or updated submodules since vcs_info doesn't. if [[ ! -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then fmt_branch="%b%u%c${__PROMPT_SKWP_COLORS[4]}●%f" @@ -86,7 +86,7 @@ function prompt_powerline_precmd { # zstyle ':prezto:module:ruby' rvm '%r' } -function prompt_powerline_setup { +prompt_powerline_setup() { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS prompt_opts=(cr percent subst) @@ -166,8 +166,8 @@ function prompt_powerline_setup { POWERLINE_COLOR_FG_LIGHT_GRAY=%F{240} POWERLINE_COLOR_FG_WHITE=%F{255} - POWERLINE_SEPARATOR=$'\u2b80' - POWERLINE_R_SEPARATOR=$'\u2b82' + POWERLINE_SEPARATOR=$'\uE0B0' + POWERLINE_R_SEPARATOR=$'\uE0B2' POWERLINE_LEFT_A="%K{green}%F{white} %~ %k%f%F{green}%K{blue}"$POWERLINE_SEPARATOR POWERLINE_LEFT_B="%k%f%F{white}%K{blue} "'${vcs_info_msg_0_}'" %k%f%F{blue}%K{black}"$POWERLINE_SEPARATOR diff --git a/.zprezto/modules/prompt/external/pure/.editorconfig b/.zprezto/modules/prompt/external/pure/.editorconfig_backup similarity index 100% rename from .zprezto/modules/prompt/external/pure/.editorconfig rename to .zprezto/modules/prompt/external/pure/.editorconfig_backup diff --git a/.zprezto/modules/prompt/external/pure/.git_backup b/.zprezto/modules/prompt/external/pure/.git_backup new file mode 100644 index 0000000..e1ddc81 --- /dev/null +++ b/.zprezto/modules/prompt/external/pure/.git_backup @@ -0,0 +1 @@ +gitdir: ../../../../.git/modules/modules/prompt/functions/pure diff --git a/.zprezto/modules/prompt/external/pure/.gitattributes b/.zprezto/modules/prompt/external/pure/.gitattributes_backup similarity index 100% rename from .zprezto/modules/prompt/external/pure/.gitattributes rename to .zprezto/modules/prompt/external/pure/.gitattributes_backup diff --git a/.zprezto/modules/prompt/external/pure/.github_backup/issue_template.md b/.zprezto/modules/prompt/external/pure/.github_backup/issue_template.md new file mode 100644 index 0000000..6e09db0 --- /dev/null +++ b/.zprezto/modules/prompt/external/pure/.github_backup/issue_template.md @@ -0,0 +1,34 @@ + + +### General information + +- Pure version: 1.x.x +- ZSH version: 5.x.x +- Terminal program & version: +- Operating system: +- ZSH framework: + +I have: +- [ ] Tested with another terminal program and can reproduce the issue: +- [ ] Followed the [Integration](https://github.com/sindresorhus/pure#integration) instructions for my framework + +### Problem description + + +### Reproduction steps + +1. +2. +3. + +### My `.zshrc`: + + + +```shell +autoload -U promptinit; promptinit +prompt pure +``` diff --git a/.zprezto/modules/prompt/external/pure/async.zsh b/.zprezto/modules/prompt/external/pure/async.zsh index 0a0f1b9..3e3830d 100644 --- a/.zprezto/modules/prompt/external/pure/async.zsh +++ b/.zprezto/modules/prompt/external/pure/async.zsh @@ -3,103 +3,189 @@ # # zsh-async # -# version: 1.0.0 +# version: 1.6.0 # author: Mathias Fredriksson # url: https://github.com/mafredri/zsh-async # +# Produce debug output from zsh-async when set to 1. +typeset -g ASYNC_DEBUG=${ASYNC_DEBUG:-0} + # Wrapper for jobs executed by the async worker, gives output in parseable format with execution time _async_job() { - # Store start time as double precision (+E disables scientific notation) + # Disable xtrace as it would mangle the output. + setopt localoptions noxtrace + + # Store start time for job. float -F duration=$EPOCHREALTIME - # Run the command - # - # What is happening here is that we are assigning stdout, stderr and ret to - # variables, and then we are printing out the variable assignment through - # typeset -p. This way when we run eval we get something along the lines of: - # eval " - # typeset stdout=' M async.test.sh\n M async.zsh' - # typeset ret=0 - # typeset stderr='' - # " - unset stdout stderr ret - eval "$( - { - stdout=$(eval "$@") - ret=$? - typeset -p stdout ret - } 2> >(stderr=$(cat); typeset -p stderr) - )" + # Run the command and capture both stdout (`eval`) and stderr (`cat`) in + # separate subshells. When the command is complete, we grab write lock + # (mutex token) and output everything except stderr inside the command + # block, after the command block has completed, the stdin for `cat` is + # closed, causing stderr to be appended with a $'\0' at the end to mark the + # end of output from this job. + local stdout stderr ret tok + { + stdout=$(eval "$@") + ret=$? + duration=$(( EPOCHREALTIME - duration )) # Calculate duration. - # Calculate duration - duration=$(( EPOCHREALTIME - duration )) + # Grab mutex lock, stalls until token is available. + read -r -k 1 -p tok || exit 1 - # stip all null-characters from stdout and stderr - stdout="${stdout//$'\0'/}" - stderr="${stderr//$'\0'/}" + # Return output ( ). + print -r -n - ${(q)1} $ret ${(q)stdout} $duration + } 2> >(stderr=$(cat) && print -r -n - " "${(q)stderr}$'\0') - # if ret is missing for some unknown reason, set it to -1 to indicate we - # have run into a bug - ret=${ret:--1} - - # Grab mutex lock - read -ep >/dev/null - - # return output ( ) - print -r -N -n -- "$1" "$ret" "$stdout" "$duration" "$stderr"$'\0' - - # Unlock mutex - print -p "t" + # Unlock mutex by inserting a token. + print -n -p $tok } # The background worker manages all tasks and runs them without interfering with other processes _async_worker() { + # Reset all options to defaults inside async worker. + emulate -R zsh + + # Make sure monitor is unset to avoid printing the + # pids of child processes. + unsetopt monitor + + # Redirect stderr to `/dev/null` in case unforseen errors produced by the + # worker. For example: `fork failed: resource temporarily unavailable`. + # Some older versions of zsh might also print malloc errors (know to happen + # on at least zsh 5.0.2 and 5.0.8) likely due to kill signals. + exec 2>/dev/null + + # When a zpty is deleted (using -d) all the zpty instances created before + # the one being deleted receive a SIGHUP, unless we catch it, the async + # worker would simply exit (stop working) even though visible in the list + # of zpty's (zpty -L). + TRAPHUP() { + return 0 # Return 0, indicating signal was handled. + } + local -A storage local unique=0 + local notify_parent=0 + local parent_pid=0 + local coproc_pid=0 + local processing=0 + + local -a zsh_hooks zsh_hook_functions + zsh_hooks=(chpwd periodic precmd preexec zshexit zshaddhistory) + zsh_hook_functions=(${^zsh_hooks}_functions) + unfunction $zsh_hooks &>/dev/null # Deactivate all zsh hooks inside the worker. + unset $zsh_hook_functions # And hooks with registered functions. + unset zsh_hooks zsh_hook_functions # Cleanup. + + child_exit() { + local -a pids + pids=(${${(v)jobstates##*:*:}%\=*}) + + # If coproc (cat) is the only child running, we close it to avoid + # leaving it running indefinitely and cluttering the process tree. + if (( ! processing )) && [[ $#pids = 1 ]] && [[ $coproc_pid = $pids[1] ]]; then + coproc : + coproc_pid=0 + fi + + # On older version of zsh (pre 5.2) we notify the parent through a + # SIGWINCH signal because `zpty` did not return a file descriptor (fd) + # prior to that. + if (( notify_parent )); then + # We use SIGWINCH for compatibility with older versions of zsh + # (pre 5.1.1) where other signals (INFO, ALRM, USR1, etc.) could + # cause a deadlock in the shell under certain circumstances. + kill -WINCH $parent_pid + fi + } + + # Register a SIGCHLD trap to handle the completion of child processes. + trap child_exit CHLD # Process option parameters passed to worker while getopts "np:u" opt; do - case "$opt" in - # Use SIGWINCH since many others seem to cause zsh to freeze, e.g. ALRM, INFO, etc. - n) trap 'kill -WINCH $ASYNC_WORKER_PARENT_PID' CHLD;; - p) ASYNC_WORKER_PARENT_PID=$OPTARG;; - u) unique=1;; + case $opt in + n) notify_parent=1;; + p) parent_pid=$OPTARG;; + u) unique=1;; esac done - # Create a mutex for writing to the terminal through coproc - coproc cat - # Insert token into coproc - print -p "t" + killjobs() { + local tok + local -a pids + pids=(${${(v)jobstates##*:*:}%\=*}) - while read -r cmd; do - # Separate on spaces into an array - cmd=(${=cmd}) - local job=$cmd[1] + # No need to send SIGHUP if no jobs are running. + (( $#pids == 0 )) && continue + (( $#pids == 1 )) && [[ $coproc_pid = $pids[1] ]] && continue + + # Grab lock to prevent half-written output in case a child + # process is in the middle of writing to stdin during kill. + (( coproc_pid )) && read -r -k 1 -p tok + + kill -HUP -$$ # Send to entire process group. + coproc : # Quit coproc. + coproc_pid=0 # Reset pid. + } + + local request + local -a cmd + while :; do + # Wait for jobs sent by async_job. + read -r -d $'\0' request || { + # Since we handle SIGHUP above (and thus do not know when `zpty -d`) + # occurs, a failure to read probably indicates that stdin has + # closed. This is why we propagate the signal to all children and + # exit manually. + kill -HUP -$$ # Send SIGHUP to all jobs. + exit 0 + } # Check for non-job commands sent to worker - case "$job" in - _killjobs) - kill -KILL ${${(v)jobstates##*:*:}%\=*} &>/dev/null - continue - ;; + case $request in + _unset_trap) notify_parent=0; continue;; + _killjobs) killjobs; continue;; esac + # Parse the request using shell parsing (z) to allow commands + # to be parsed from single strings and multi-args alike. + cmd=("${(z)request}") + + # Name of the job (first argument). + local job=$cmd[1] + # If worker should perform unique jobs - if ((unique)); then + if (( unique )); then # Check if a previous job is still running, if yes, let it finnish for pid in ${${(v)jobstates##*:*:}%\=*}; do - if [[ "${storage[$job]}" == "$pid" ]]; then + if [[ ${storage[$job]} == $pid ]]; then continue 2 fi done fi - # run task in background + # Guard against closing coproc from trap before command has started. + processing=1 + + # Because we close the coproc after the last job has completed, we must + # recreate it when there are no other jobs running. + if (( ! coproc_pid )); then + # Use coproc as a mutex for synchronized output between children. + coproc cat + coproc_pid="$!" + # Insert token into coproc + print -n -p "t" + fi + + # Run job in background, completed jobs are printed to stdout. _async_job $cmd & - # store pid because zsh job manager is extremely unflexible (show jobname as non-unique '$job')... - storage[$job]=$! + # Store pid because zsh job manager is extremely unflexible (show jobname as non-unique '$job')... + storage[$job]="$!" + + processing=0 # Disable guard. done } @@ -116,45 +202,78 @@ _async_worker() { # $3 = resulting stdout from execution # $4 = execution time, floating point e.g. 2.05 seconds # $5 = resulting stderr from execution +# $6 = has next result in buffer (0 = buffer empty, 1 = yes) # async_process_results() { - integer count=0 + setopt localoptions unset noshwordsplit noksharrays noposixidentifiers noposixstrings + local worker=$1 local callback=$2 + local caller=$3 local -a items - local IFS=$'\0' + local null=$'\0' data + integer -l len pos num_processed typeset -gA ASYNC_PROCESS_BUFFER - # Read output from zpty and parse it if available - while zpty -rt "$worker" line 2>/dev/null; do - # Remove unwanted \r from output - ASYNC_PROCESS_BUFFER[$worker]+=${line//$'\r'$'\n'/$'\n'} - # Split buffer on null characters, preserve empty elements - items=("${(@)=ASYNC_PROCESS_BUFFER[$worker]}") - # Remove last element since it's due to the return string separator structure - items=("${(@)items[1,${#items}-1]}") - # Continue until we receive all information - (( ${#items} % 5 )) && continue + # Read output from zpty and parse it if available. + while zpty -r -t $worker data 2>/dev/null; do + ASYNC_PROCESS_BUFFER[$worker]+=$data + len=${#ASYNC_PROCESS_BUFFER[$worker]} + pos=${ASYNC_PROCESS_BUFFER[$worker][(i)$null]} # Get index of NULL-character (delimiter). - # Work through all results - while (( ${#items} > 0 )); do - "$callback" "${(@)=items[1,5]}" - shift 5 items - count+=1 + # Keep going until we find a NULL-character. + if (( ! len )) || (( pos > len )); then + continue + fi + + while (( pos <= len )); do + # Take the content from the beginning, until the NULL-character and + # perform shell parsing (z) and unquoting (Q) as an array (@). + items=("${(@Q)${(z)ASYNC_PROCESS_BUFFER[$worker][1,$pos-1]}}") + + # Remove the extracted items from the buffer. + ASYNC_PROCESS_BUFFER[$worker]=${ASYNC_PROCESS_BUFFER[$worker][$pos+1,$len]} + + len=${#ASYNC_PROCESS_BUFFER[$worker]} + if (( len > 1 )); then + pos=${ASYNC_PROCESS_BUFFER[$worker][(i)$null]} # Get index of NULL-character (delimiter). + fi + + if (( $#items == 5 )); then + items+=($(( len != 0 ))) + $callback "${(@)items}" # Send all parsed items to the callback. + else + # In case of corrupt data, invoke callback with *async* as job + # name, non-zero exit status and an error message on stderr. + $callback "async" 1 "" 0 "$0:$LINENO: error: bad format, got ${#items} items (${(@q)items})" + fi + + (( num_processed++ )) done - - # Empty the buffer - ASYNC_PROCESS_BUFFER[$worker]="" done - # If we processed any results, return success - (( $count )) && return 0 + (( num_processed )) && return 0 + + # Avoid printing exit value when `setopt printexitvalue` is active.` + [[ $caller = trap || $caller = watcher ]] && return 0 # No results were processed return 1 } +# Watch worker for output +_async_zle_watcher() { + setopt localoptions noshwordsplit + typeset -gA ASYNC_PTYS ASYNC_CALLBACKS + local worker=$ASYNC_PTYS[$1] + local callback=$ASYNC_CALLBACKS[$worker] + + if [[ -n $callback ]]; then + async_process_results $worker $callback watcher + fi +} + # # Start a new asynchronous job on specified worker, assumes the worker is running. # @@ -162,14 +281,27 @@ async_process_results() { # async_job [] # async_job() { + setopt localoptions noshwordsplit noksharrays noposixidentifiers noposixstrings + local worker=$1; shift - zpty -w "$worker" "$@" + + local -a cmd + cmd=("$@") + if (( $#cmd > 1 )); then + cmd=(${(q)cmd}) # Quote special characters in multi argument commands. + fi + + # Quote the cmd in case RC_EXPAND_PARAM is set. + zpty -w $worker "$cmd"$'\0' } # This function traps notification signals and calls all registered callbacks _async_notify_trap() { + setopt localoptions noshwordsplit + + local k for k in ${(k)ASYNC_CALLBACKS}; do - async_process_results "${k}" "${ASYNC_CALLBACKS[$k]}" + async_process_results $k ${ASYNC_CALLBACKS[$k]} trap done } @@ -181,12 +313,18 @@ _async_notify_trap() { # async_register_callback # async_register_callback() { + setopt localoptions noshwordsplit nolocaltraps + typeset -gA ASYNC_CALLBACKS local worker=$1; shift ASYNC_CALLBACKS[$worker]="$*" - trap '_async_notify_trap' WINCH + # Enable trap when the ZLE watcher is unavailable, allows + # workers to notify (via -n) when a job is done. + if [[ ! -o interactive ]] || [[ ! -o zle ]]; then + trap '_async_notify_trap' WINCH + fi } # @@ -209,20 +347,29 @@ async_unregister_callback() { # async_flush_jobs # async_flush_jobs() { + setopt localoptions noshwordsplit + local worker=$1; shift # Check if the worker exists - zpty -t "$worker" &>/dev/null || return 1 + zpty -t $worker &>/dev/null || return 1 # Send kill command to worker - zpty -w "$worker" "_killjobs" + async_job $worker "_killjobs" - # Clear all output buffers - while zpty -r "$worker" line; do true; done + # Clear the zpty buffer. + local junk + if zpty -r -t $worker junk '*'; then + (( ASYNC_DEBUG )) && print -n "async_flush_jobs $worker: ${(V)junk}" + while zpty -r -t $worker junk '*'; do + (( ASYNC_DEBUG )) && print -n "${(V)junk}" + done + (( ASYNC_DEBUG )) && print + fi - # Clear any partial buffers + # Finally, clear the process buffer in case of partially parsed responses. typeset -gA ASYNC_PROCESS_BUFFER - ASYNC_PROCESS_BUFFER[$worker]="" + unset "ASYNC_PROCESS_BUFFER[$worker]" } # @@ -238,8 +385,56 @@ async_flush_jobs() { # -p pid to notify (defaults to current pid) # async_start_worker() { + setopt localoptions noshwordsplit + local worker=$1; shift - zpty -t "$worker" &>/dev/null || zpty -b "$worker" _async_worker -p $$ "$@" || async_stop_worker "$worker" + zpty -t $worker &>/dev/null && return + + typeset -gA ASYNC_PTYS + typeset -h REPLY + typeset has_xtrace=0 + + # Make sure async worker is started without xtrace + # (the trace output interferes with the worker). + [[ -o xtrace ]] && { + has_xtrace=1 + unsetopt xtrace + } + + if (( ! ASYNC_ZPTY_RETURNS_FD )) && [[ -o interactive ]] && [[ -o zle ]]; then + # When zpty doesn't return a file descriptor (on older versions of zsh) + # we try to guess it anyway. + integer -l zptyfd + exec {zptyfd}>&1 # Open a new file descriptor (above 10). + exec {zptyfd}>&- # Close it so it's free to be used by zpty. + fi + + zpty -b $worker _async_worker -p $$ $@ || { + async_stop_worker $worker + return 1 + } + + # Re-enable it if it was enabled, for debugging. + (( has_xtrace )) && setopt xtrace + + if [[ $ZSH_VERSION < 5.0.8 ]]; then + # For ZSH versions older than 5.0.8 we delay a bit to give + # time for the worker to start before issuing commands, + # otherwise it will not be ready to receive them. + sleep 0.001 + fi + + if [[ -o interactive ]] && [[ -o zle ]]; then + if (( ! ASYNC_ZPTY_RETURNS_FD )); then + REPLY=$zptyfd # Use the guessed value for the file desciptor. + fi + + ASYNC_PTYS[$REPLY]=$worker # Map the file desciptor to the worker. + zle -F $REPLY _async_zle_watcher # Register the ZLE handler. + + # Disable trap in favor of ZLE handler when notify is enabled (-n). + async_job $worker _unset_trap + fi } # @@ -249,10 +444,23 @@ async_start_worker() { # async_stop_worker [] # async_stop_worker() { - local ret=0 - for worker in "$@"; do - async_unregister_callback "$worker" - zpty -d "$worker" 2>/dev/null || ret=$? + setopt localoptions noshwordsplit + + local ret=0 worker k v + for worker in $@; do + # Find and unregister the zle handler for the worker + for k v in ${(@kv)ASYNC_PTYS}; do + if [[ $v == $worker ]]; then + zle -F $k + unset "ASYNC_PTYS[$k]" + fi + done + async_unregister_callback $worker + zpty -d $worker 2>/dev/null || ret=$? + + # Clear any partial buffers. + typeset -gA ASYNC_PROCESS_BUFFER + unset "ASYNC_PROCESS_BUFFER[$worker]" done return $ret @@ -265,8 +473,21 @@ async_stop_worker() { # async_init # async_init() { + (( ASYNC_INIT_DONE )) && return + typeset -g ASYNC_INIT_DONE=1 + zmodload zsh/zpty zmodload zsh/datetime + + # Check if zsh/zpty returns a file descriptor or not, + # shell must also be interactive with zle enabled. + typeset -g ASYNC_ZPTY_RETURNS_FD=0 + [[ -o interactive ]] && [[ -o zle ]] && { + typeset -h REPLY + zpty _async_test : + (( REPLY )) && ASYNC_ZPTY_RETURNS_FD=1 + zpty -d _async_test + } } async() { diff --git a/.zprezto/modules/prompt/external/pure/package.json b/.zprezto/modules/prompt/external/pure/package.json index a96668f..0d5a8cc 100644 --- a/.zprezto/modules/prompt/external/pure/package.json +++ b/.zprezto/modules/prompt/external/pure/package.json @@ -1,6 +1,6 @@ { "name": "pure-prompt", - "version": "1.2.0", + "version": "1.7.0", "description": "Pretty, minimal and fast ZSH prompt", "license": "MIT", "repository": "sindresorhus/pure", @@ -19,7 +19,9 @@ "node": ">=0.10.0" }, "scripts": { - "postinstall": "dest=/usr/local/share/zsh/site-functions/; mkdir -p $dest && ln -sf \"$PWD/pure.zsh\" $dest/prompt_pure_setup && ln -sf \"$PWD/async.zsh\" $dest/async || echo 'Could not automagically symlink the prompt. Check out the readme on how to do it manually: https://github.com/sindresorhus/pure#manually'" + "postinstall": "PURE_DEST=/usr/local/share/zsh/site-functions npm run --silent postinstall-link && exit 0; PURE_DEST=\"$PWD/functions\" npm run postinstall-link && npm run postinstall-fail-instructions", + "postinstall-link": "mkdir -p \"$PURE_DEST\" && ln -sf \"$PWD/pure.zsh\" \"$PURE_DEST/prompt_pure_setup\" && ln -sf \"$PWD/async.zsh\" \"$PURE_DEST/async\"", + "postinstall-fail-instructions": "echo \"ERROR: Could not automagically symlink the prompt. Either:\\n1. Check out the readme on how to do it manually: https://github.com/sindresorhus/pure#manually\\n2. Or add the following to your \\`.zshrc\\`:\\n\\n fpath+=('$PWD/functions')\"" }, "files": [ "pure.zsh", diff --git a/.zprezto/modules/prompt/external/pure/pure.plugin.zsh b/.zprezto/modules/prompt/external/pure/pure.plugin.zsh deleted file mode 120000 index f5f60e7..0000000 --- a/.zprezto/modules/prompt/external/pure/pure.plugin.zsh +++ /dev/null @@ -1 +0,0 @@ -pure.zsh \ No newline at end of file diff --git a/.zprezto/modules/prompt/external/pure/pure.plugin.zsh b/.zprezto/modules/prompt/external/pure/pure.plugin.zsh new file mode 100644 index 0000000..2fd19e8 --- /dev/null +++ b/.zprezto/modules/prompt/external/pure/pure.plugin.zsh @@ -0,0 +1,486 @@ +# Pure +# by Sindre Sorhus +# https://github.com/sindresorhus/pure +# MIT License + +# For my own and others sanity +# git: +# %b => current branch +# %a => current action (rebase/merge) +# prompt: +# %F => color dict +# %f => reset color +# %~ => current path +# %* => time +# %n => username +# %m => shortname host +# %(?..) => prompt conditional - %(condition.true.false) +# terminal codes: +# \e7 => save cursor position +# \e[2A => move cursor 2 lines up +# \e[1G => go to position 1 in terminal +# \e8 => restore cursor position +# \e[K => clears everything after the cursor on the current line +# \e[2K => clear everything on the current line + + +# turns seconds into human readable time +# 165392 => 1d 21h 56m 32s +# https://github.com/sindresorhus/pretty-time-zsh +prompt_pure_human_time_to_var() { + local human total_seconds=$1 var=$2 + local days=$(( total_seconds / 60 / 60 / 24 )) + local hours=$(( total_seconds / 60 / 60 % 24 )) + local minutes=$(( total_seconds / 60 % 60 )) + local seconds=$(( total_seconds % 60 )) + (( days > 0 )) && human+="${days}d " + (( hours > 0 )) && human+="${hours}h " + (( minutes > 0 )) && human+="${minutes}m " + human+="${seconds}s" + + # store human readable time in variable as specified by caller + typeset -g "${var}"="${human}" +} + +# stores (into prompt_pure_cmd_exec_time) the exec time of the last command if set threshold was exceeded +prompt_pure_check_cmd_exec_time() { + integer elapsed + (( elapsed = EPOCHSECONDS - ${prompt_pure_cmd_timestamp:-$EPOCHSECONDS} )) + typeset -g prompt_pure_cmd_exec_time= + (( elapsed > ${PURE_CMD_MAX_EXEC_TIME:-5} )) && { + prompt_pure_human_time_to_var $elapsed "prompt_pure_cmd_exec_time" + } +} + +prompt_pure_set_title() { + setopt localoptions noshwordsplit + + # emacs terminal does not support settings the title + (( ${+EMACS} )) && return + + case $TTY in + # Don't set title over serial console. + /dev/ttyS[0-9]*) return;; + esac + + # tell the terminal we are setting the title + print -n '\e]0;' + # show hostname if connected through ssh + [[ -n $SSH_CONNECTION ]] && print -Pn '(%m) ' + case $1 in + expand-prompt) + print -Pn $2;; + ignore-escape) + print -rn $2;; + esac + # end set title + print -n '\a' +} + +prompt_pure_preexec() { + if [[ -n $prompt_pure_git_fetch_pattern ]]; then + # detect when git is performing pull/fetch (including git aliases). + local -H MATCH MBEGIN MEND match mbegin mend + if [[ $2 =~ (git|hub)\ (.*\ )?($prompt_pure_git_fetch_pattern)(\ .*)?$ ]]; then + # we must flush the async jobs to cancel our git fetch in order + # to avoid conflicts with the user issued pull / fetch. + async_flush_jobs 'prompt_pure' + fi + fi + + typeset -g prompt_pure_cmd_timestamp=$EPOCHSECONDS + + # shows the current dir and executed command in the title while a process is active + prompt_pure_set_title 'ignore-escape' "$PWD:t: $2" + + # Disallow python virtualenv from updating the prompt, set it to 12 if + # untouched by the user to indicate that Pure modified it. Here we use + # magic number 12, same as in psvar. + export VIRTUAL_ENV_DISABLE_PROMPT=${VIRTUAL_ENV_DISABLE_PROMPT:-12} +} + +# string length ignoring ansi escapes +prompt_pure_string_length_to_var() { + local str=$1 var=$2 length + # perform expansion on str and check length + length=$(( ${#${(S%%)str//(\%([KF1]|)\{*\}|\%[Bbkf])}} )) + + # store string length in variable as specified by caller + typeset -g "${var}"="${length}" +} + +prompt_pure_preprompt_render() { + setopt localoptions noshwordsplit + + # Set color for git branch/dirty status, change color if dirty checking has + # been delayed. + local git_color=242 + [[ -n ${prompt_pure_git_last_dirty_check_timestamp+x} ]] && git_color=red + + # Initialize the preprompt array. + local -a preprompt_parts + + # Set the path. + preprompt_parts+=('%F{blue}%~%f') + + # Add git branch and dirty status info. + typeset -gA prompt_pure_vcs_info + if [[ -n $prompt_pure_vcs_info[branch] ]]; then + preprompt_parts+=("%F{$git_color}"'${prompt_pure_vcs_info[branch]}${prompt_pure_git_dirty}%f') + fi + # Git pull/push arrows. + if [[ -n $prompt_pure_git_arrows ]]; then + preprompt_parts+=('%F{cyan}${prompt_pure_git_arrows}%f') + fi + + # Username and machine, if applicable. + [[ -n $prompt_pure_username ]] && preprompt_parts+=('$prompt_pure_username') + # Execution time. + [[ -n $prompt_pure_cmd_exec_time ]] && preprompt_parts+=('%F{yellow}${prompt_pure_cmd_exec_time}%f') + + local cleaned_ps1=$PROMPT + local -H MATCH MBEGIN MEND + if [[ $PROMPT = *$prompt_newline* ]]; then + # When the prompt contains newlines, we keep everything before the first + # and after the last newline, leaving us with everything except the + # preprompt. This is needed because some software prefixes the prompt + # (e.g. virtualenv). + cleaned_ps1=${PROMPT%%${prompt_newline}*}${PROMPT##*${prompt_newline}} + fi + unset MATCH MBEGIN MEND + + # Construct the new prompt with a clean preprompt. + local -ah ps1 + ps1=( + $prompt_newline # Initial newline, for spaciousness. + ${(j. .)preprompt_parts} # Join parts, space separated. + $prompt_newline # Separate preprompt and prompt. + $cleaned_ps1 + ) + + PROMPT="${(j..)ps1}" + + # Expand the prompt for future comparision. + local expanded_prompt + expanded_prompt="${(S%%)PROMPT}" + + if [[ $1 != precmd ]] && [[ $prompt_pure_last_prompt != $expanded_prompt ]]; then + # Redraw the prompt. + zle && zle .reset-prompt + fi + + typeset -g prompt_pure_last_prompt=$expanded_prompt +} + +prompt_pure_precmd() { + # check exec time and store it in a variable + prompt_pure_check_cmd_exec_time + unset prompt_pure_cmd_timestamp + + # shows the full path in the title + prompt_pure_set_title 'expand-prompt' '%~' + + # preform async git dirty check and fetch + prompt_pure_async_tasks + + # Check if we should display the virtual env, we use a sufficiently high + # index of psvar (12) here to avoid collisions with user defined entries. + psvar[12]= + # When VIRTUAL_ENV_DISABLE_PROMPT is empty, it was unset by the user and + # Pure should take back control. + if [[ -n $VIRTUAL_ENV ]] && [[ -z $VIRTUAL_ENV_DISABLE_PROMPT || $VIRTUAL_ENV_DISABLE_PROMPT = 12 ]]; then + psvar[12]="${VIRTUAL_ENV:t}" + export VIRTUAL_ENV_DISABLE_PROMPT=12 + fi + + # print the preprompt + prompt_pure_preprompt_render "precmd" +} + +prompt_pure_async_git_aliases() { + setopt localoptions noshwordsplit + local dir=$1 + local -a gitalias pullalias + + # we enter repo to get local aliases as well. + builtin cd -q $dir + + # list all aliases and split on newline. + gitalias=(${(@f)"$(command git config --get-regexp "^alias\.")"}) + for line in $gitalias; do + parts=(${(@)=line}) # split line on spaces + aliasname=${parts[1]#alias.} # grab the name (alias.[name]) + shift parts # remove aliasname + + # check alias for pull or fetch (must be exact match). + if [[ $parts =~ ^(.*\ )?(pull|fetch)(\ .*)?$ ]]; then + pullalias+=($aliasname) + fi + done + + print -- ${(j:|:)pullalias} # join on pipe (for use in regex). +} + +prompt_pure_async_vcs_info() { + setopt localoptions noshwordsplit + builtin cd -q $1 2>/dev/null + + # configure vcs_info inside async task, this frees up vcs_info + # to be used or configured as the user pleases. + zstyle ':vcs_info:*' enable git + zstyle ':vcs_info:*' use-simple true + # only export two msg variables from vcs_info + zstyle ':vcs_info:*' max-exports 2 + # export branch (%b) and git toplevel (%R) + zstyle ':vcs_info:git*' formats '%b' '%R' + zstyle ':vcs_info:git*' actionformats '%b|%a' '%R' + + vcs_info + + local -A info + info[top]=$vcs_info_msg_1_ + info[branch]=$vcs_info_msg_0_ + + print -r - ${(@kvq)info} +} + +# fastest possible way to check if repo is dirty +prompt_pure_async_git_dirty() { + setopt localoptions noshwordsplit + local untracked_dirty=$1 dir=$2 + + # use cd -q to avoid side effects of changing directory, e.g. chpwd hooks + builtin cd -q $dir + + if [[ $untracked_dirty = 0 ]]; then + command git diff --no-ext-diff --quiet --exit-code + else + test -z "$(command git status --porcelain --ignore-submodules -unormal)" + fi + + return $? +} + +prompt_pure_async_git_fetch() { + setopt localoptions noshwordsplit + # use cd -q to avoid side effects of changing directory, e.g. chpwd hooks + builtin cd -q $1 + + # set GIT_TERMINAL_PROMPT=0 to disable auth prompting for git fetch (git 2.3+) + export GIT_TERMINAL_PROMPT=0 + # set ssh BachMode to disable all interactive ssh password prompting + export GIT_SSH_COMMAND=${GIT_SSH_COMMAND:-"ssh -o BatchMode=yes"} + + command git -c gc.auto=0 fetch &>/dev/null || return 99 + + # check arrow status after a successful git fetch + prompt_pure_async_git_arrows $1 +} + +prompt_pure_async_git_arrows() { + setopt localoptions noshwordsplit + builtin cd -q $1 + command git rev-list --left-right --count HEAD...@'{u}' +} + +prompt_pure_async_tasks() { + setopt localoptions noshwordsplit + + # initialize async worker + ((!${prompt_pure_async_init:-0})) && { + async_start_worker "prompt_pure" -u -n + async_register_callback "prompt_pure" prompt_pure_async_callback + typeset -g prompt_pure_async_init=1 + } + + typeset -gA prompt_pure_vcs_info + + local -H MATCH MBEGIN MEND + if ! [[ $PWD = ${prompt_pure_vcs_info[pwd]}* ]]; then + # stop any running async jobs + async_flush_jobs "prompt_pure" + + # reset git preprompt variables, switching working tree + unset prompt_pure_git_dirty + unset prompt_pure_git_last_dirty_check_timestamp + unset prompt_pure_git_arrows + unset prompt_pure_git_fetch_pattern + prompt_pure_vcs_info[branch]= + prompt_pure_vcs_info[top]= + fi + unset MATCH MBEGIN MEND + + async_job "prompt_pure" prompt_pure_async_vcs_info $PWD + + # # only perform tasks inside git working tree + [[ -n $prompt_pure_vcs_info[top] ]] || return + + prompt_pure_async_refresh +} + +prompt_pure_async_refresh() { + setopt localoptions noshwordsplit + + if [[ -z $prompt_pure_git_fetch_pattern ]]; then + # we set the pattern here to avoid redoing the pattern check until the + # working three has changed. pull and fetch are always valid patterns. + typeset -g prompt_pure_git_fetch_pattern="pull|fetch" + async_job "prompt_pure" prompt_pure_async_git_aliases $working_tree + fi + + async_job "prompt_pure" prompt_pure_async_git_arrows $PWD + + # do not preform git fetch if it is disabled or working_tree == HOME + if (( ${PURE_GIT_PULL:-1} )) && [[ $working_tree != $HOME ]]; then + # tell worker to do a git fetch + async_job "prompt_pure" prompt_pure_async_git_fetch $PWD + fi + + # if dirty checking is sufficiently fast, tell worker to check it again, or wait for timeout + integer time_since_last_dirty_check=$(( EPOCHSECONDS - ${prompt_pure_git_last_dirty_check_timestamp:-0} )) + if (( time_since_last_dirty_check > ${PURE_GIT_DELAY_DIRTY_CHECK:-1800} )); then + unset prompt_pure_git_last_dirty_check_timestamp + # check check if there is anything to pull + async_job "prompt_pure" prompt_pure_async_git_dirty ${PURE_GIT_UNTRACKED_DIRTY:-1} $PWD + fi +} + +prompt_pure_check_git_arrows() { + setopt localoptions noshwordsplit + local arrows left=${1:-0} right=${2:-0} + + (( right > 0 )) && arrows+=${PURE_GIT_DOWN_ARROW:-⇣} + (( left > 0 )) && arrows+=${PURE_GIT_UP_ARROW:-⇡} + + [[ -n $arrows ]] || return + typeset -g REPLY=$arrows +} + +prompt_pure_async_callback() { + setopt localoptions noshwordsplit + local job=$1 code=$2 output=$3 exec_time=$4 next_pending=$6 + local do_render=0 + + case $job in + prompt_pure_async_vcs_info) + local -A info + typeset -gA prompt_pure_vcs_info + + # parse output (z) and unquote as array (Q@) + info=("${(Q@)${(z)output}}") + local -H MATCH MBEGIN MEND + # check if git toplevel has changed + if [[ $info[top] = $prompt_pure_vcs_info[top] ]]; then + # if stored pwd is part of $PWD, $PWD is shorter and likelier + # to be toplevel, so we update pwd + if [[ $prompt_pure_vcs_info[pwd] = ${PWD}* ]]; then + prompt_pure_vcs_info[pwd]=$PWD + fi + else + # store $PWD to detect if we (maybe) left the git path + prompt_pure_vcs_info[pwd]=$PWD + fi + unset MATCH MBEGIN MEND + + # update has a git toplevel set which means we just entered a new + # git directory, run the async refresh tasks + [[ -n $info[top] ]] && [[ -z $prompt_pure_vcs_info[top] ]] && prompt_pure_async_refresh + + # always update branch and toplevel + prompt_pure_vcs_info[branch]=$info[branch] + prompt_pure_vcs_info[top]=$info[top] + + do_render=1 + ;; + prompt_pure_async_git_aliases) + if [[ -n $output ]]; then + # append custom git aliases to the predefined ones. + prompt_pure_git_fetch_pattern+="|$output" + fi + ;; + prompt_pure_async_git_dirty) + local prev_dirty=$prompt_pure_git_dirty + if (( code == 0 )); then + unset prompt_pure_git_dirty + else + typeset -g prompt_pure_git_dirty="*" + fi + + [[ $prev_dirty != $prompt_pure_git_dirty ]] && do_render=1 + + # When prompt_pure_git_last_dirty_check_timestamp is set, the git info is displayed in a different color. + # To distinguish between a "fresh" and a "cached" result, the preprompt is rendered before setting this + # variable. Thus, only upon next rendering of the preprompt will the result appear in a different color. + (( $exec_time > 5 )) && prompt_pure_git_last_dirty_check_timestamp=$EPOCHSECONDS + ;; + prompt_pure_async_git_fetch|prompt_pure_async_git_arrows) + # prompt_pure_async_git_fetch executes prompt_pure_async_git_arrows + # after a successful fetch. + if (( code == 0 )); then + local REPLY + prompt_pure_check_git_arrows ${(ps:\t:)output} + if [[ $prompt_pure_git_arrows != $REPLY ]]; then + typeset -g prompt_pure_git_arrows=$REPLY + do_render=1 + fi + elif (( code != 99 )); then + # Unless the exit code is 99, prompt_pure_async_git_arrows + # failed with a non-zero exit status, meaning there is no + # upstream configured. + if [[ -n $prompt_pure_git_arrows ]]; then + unset prompt_pure_git_arrows + do_render=1 + fi + fi + ;; + esac + + if (( next_pending )); then + (( do_render )) && typeset -g prompt_pure_async_render_requested=1 + return + fi + + [[ ${prompt_pure_async_render_requested:-$do_render} = 1 ]] && prompt_pure_preprompt_render + unset prompt_pure_async_render_requested +} + +prompt_pure_setup() { + # Prevent percentage showing up if output doesn't end with a newline. + export PROMPT_EOL_MARK='' + + prompt_opts=(subst percent) + + # borrowed from promptinit, sets the prompt options in case pure was not + # initialized via promptinit. + setopt noprompt{bang,cr,percent,subst} "prompt${^prompt_opts[@]}" + + if [[ -z $prompt_newline ]]; then + # This variable needs to be set, usually set by promptinit. + typeset -g prompt_newline=$'\n%{\r%}' + fi + + zmodload zsh/datetime + zmodload zsh/zle + zmodload zsh/parameter + + autoload -Uz add-zsh-hook + autoload -Uz vcs_info + autoload -Uz async && async + + add-zsh-hook precmd prompt_pure_precmd + add-zsh-hook preexec prompt_pure_preexec + + # show username@host if logged in through SSH + [[ "$SSH_CONNECTION" != '' ]] && prompt_pure_username='%F{242}%n@%m%f' + + # show username@host if root, with username in white + [[ $UID -eq 0 ]] && prompt_pure_username='%F{white}%n%f%F{242}@%m%f' + + # if a virtualenv is activated, display it in grey + PROMPT='%(12V.%F{242}%12v%f .)' + + # prompt turns red if the previous command didn't exit with 0 + PROMPT+='%(?.%F{magenta}.%F{red})${PURE_PROMPT_SYMBOL:-❯}%f ' +} + +prompt_pure_setup "$@" diff --git a/.zprezto/modules/prompt/external/pure/pure.zsh b/.zprezto/modules/prompt/external/pure/pure.zsh index b7acaee..2fd19e8 100644 --- a/.zprezto/modules/prompt/external/pure/pure.zsh +++ b/.zprezto/modules/prompt/external/pure/pure.zsh @@ -28,7 +28,7 @@ # 165392 => 1d 21h 56m 32s # https://github.com/sindresorhus/pretty-time-zsh prompt_pure_human_time_to_var() { - local human=" " total_seconds=$1 var=$2 + local human total_seconds=$1 var=$2 local days=$(( total_seconds / 60 / 60 / 24 )) local hours=$(( total_seconds / 60 / 60 % 24 )) local minutes=$(( total_seconds / 60 % 60 )) @@ -46,45 +46,23 @@ prompt_pure_human_time_to_var() { prompt_pure_check_cmd_exec_time() { integer elapsed (( elapsed = EPOCHSECONDS - ${prompt_pure_cmd_timestamp:-$EPOCHSECONDS} )) - prompt_pure_cmd_exec_time= - (( elapsed > ${PURE_CMD_MAX_EXEC_TIME:=5} )) && { + typeset -g prompt_pure_cmd_exec_time= + (( elapsed > ${PURE_CMD_MAX_EXEC_TIME:-5} )) && { prompt_pure_human_time_to_var $elapsed "prompt_pure_cmd_exec_time" } } -prompt_pure_clear_screen() { - # enable output to terminal - zle -I - # clear screen and move cursor to (0, 0) - print -n '\e[2J\e[0;0H' - # print preprompt - prompt_pure_preprompt_render precmd -} - -prompt_pure_check_git_arrows() { - # reset git arrows - prompt_pure_git_arrows= - - # check if there is an upstream configured for this branch - command git rev-parse --abbrev-ref @'{u}' &>/dev/null || return - - local arrow_status - # check git left and right arrow_status - arrow_status="$(command git rev-list --left-right --count HEAD...@'{u}' 2>/dev/null)" - # exit if the command failed - (( !$? )) || return - - # left and right are tab-separated, split on tab and store as array - arrow_status=(${(ps:\t:)arrow_status}) - local arrows left=${arrow_status[1]} right=${arrow_status[2]} - - (( ${right:-0} > 0 )) && arrows+="${PURE_GIT_DOWN_ARROW:-⇣}" - (( ${left:-0} > 0 )) && arrows+="${PURE_GIT_UP_ARROW:-⇡}" - - [[ -n $arrows ]] && prompt_pure_git_arrows=" ${arrows}" -} - prompt_pure_set_title() { + setopt localoptions noshwordsplit + + # emacs terminal does not support settings the title + (( ${+EMACS} )) && return + + case $TTY in + # Don't set title over serial console. + /dev/ttyS[0-9]*) return;; + esac + # tell the terminal we are setting the title print -n '\e]0;' # show hostname if connected through ssh @@ -100,10 +78,25 @@ prompt_pure_set_title() { } prompt_pure_preexec() { - prompt_pure_cmd_timestamp=$EPOCHSECONDS + if [[ -n $prompt_pure_git_fetch_pattern ]]; then + # detect when git is performing pull/fetch (including git aliases). + local -H MATCH MBEGIN MEND match mbegin mend + if [[ $2 =~ (git|hub)\ (.*\ )?($prompt_pure_git_fetch_pattern)(\ .*)?$ ]]; then + # we must flush the async jobs to cancel our git fetch in order + # to avoid conflicts with the user issued pull / fetch. + async_flush_jobs 'prompt_pure' + fi + fi + + typeset -g prompt_pure_cmd_timestamp=$EPOCHSECONDS # shows the current dir and executed command in the title while a process is active prompt_pure_set_title 'ignore-escape' "$PWD:t: $2" + + # Disallow python virtualenv from updating the prompt, set it to 12 if + # untouched by the user to indicate that Pure modified it. Here we use + # magic number 12, same as in psvar. + export VIRTUAL_ENV_DISABLE_PROMPT=${VIRTUAL_ENV_DISABLE_PROMPT:-12} } # string length ignoring ansi escapes @@ -117,159 +110,230 @@ prompt_pure_string_length_to_var() { } prompt_pure_preprompt_render() { - # check that no command is currently running, the preprompt will otherwise be rendered in the wrong place - [[ -n ${prompt_pure_cmd_timestamp+x} && "$1" != "precmd" ]] && return + setopt localoptions noshwordsplit - # set color for git branch/dirty status, change color if dirty checking has been delayed + # Set color for git branch/dirty status, change color if dirty checking has + # been delayed. local git_color=242 [[ -n ${prompt_pure_git_last_dirty_check_timestamp+x} ]] && git_color=red - # construct preprompt, beginning with path - local preprompt="%F{blue}%~%f" - # git info - preprompt+="%F{$git_color}${vcs_info_msg_0_}${prompt_pure_git_dirty}%f" - # git pull/push arrows - preprompt+="%F{cyan}${prompt_pure_git_arrows}%f" - # username and machine if applicable - preprompt+=$prompt_pure_username - # execution time - preprompt+="%F{yellow}${prompt_pure_cmd_exec_time}%f" + # Initialize the preprompt array. + local -a preprompt_parts - # if executing through precmd, do not perform fancy terminal editing - if [[ "$1" == "precmd" ]]; then - print -P "\n${preprompt}" - else - # only redraw if preprompt has changed - [[ "${prompt_pure_last_preprompt}" != "${preprompt}" ]] || return + # Set the path. + preprompt_parts+=('%F{blue}%~%f') - # calculate length of preprompt and store it locally in preprompt_length - integer preprompt_length lines - prompt_pure_string_length_to_var "${preprompt}" "preprompt_length" - - # calculate number of preprompt lines for redraw purposes - (( lines = ( preprompt_length - 1 ) / COLUMNS + 1 )) - - # calculate previous preprompt lines to figure out how the new preprompt should behave - integer last_preprompt_length last_lines - prompt_pure_string_length_to_var "${prompt_pure_last_preprompt}" "last_preprompt_length" - (( last_lines = ( last_preprompt_length - 1 ) / COLUMNS + 1 )) - - # clr_prev_preprompt erases visual artifacts from previous preprompt - local clr_prev_preprompt - if (( last_lines > lines )); then - # move cursor up by last_lines, clear the line and move it down by one line - clr_prev_preprompt="\e[${last_lines}A\e[2K\e[1B" - while (( last_lines - lines > 1 )); do - # clear the line and move cursor down by one - clr_prev_preprompt+='\e[2K\e[1B' - (( last_lines-- )) - done - - # move cursor into correct position for preprompt update - clr_prev_preprompt+="\e[${lines}B" - # create more space for preprompt if new preprompt has more lines than last - elif (( last_lines < lines )); then - # move cursor using newlines because ansi cursor movement can't push the cursor beyond the last line - printf $'\n'%.0s {1..$(( lines - last_lines ))} - - # redraw the prompt since it has been moved by print - zle && zle .reset-prompt - fi - - # disable clearing of line if last char of preprompt is last column of terminal - local clr='\e[K' - (( COLUMNS * lines == preprompt_length )) && clr= - - # modify previous preprompt - print -Pn "\e7${clr_prev_preprompt}\e[${lines}A\e[1G${preprompt}${clr}\e8" + # Add git branch and dirty status info. + typeset -gA prompt_pure_vcs_info + if [[ -n $prompt_pure_vcs_info[branch] ]]; then + preprompt_parts+=("%F{$git_color}"'${prompt_pure_vcs_info[branch]}${prompt_pure_git_dirty}%f') + fi + # Git pull/push arrows. + if [[ -n $prompt_pure_git_arrows ]]; then + preprompt_parts+=('%F{cyan}${prompt_pure_git_arrows}%f') fi - # store previous preprompt for comparison - prompt_pure_last_preprompt=$preprompt + # Username and machine, if applicable. + [[ -n $prompt_pure_username ]] && preprompt_parts+=('$prompt_pure_username') + # Execution time. + [[ -n $prompt_pure_cmd_exec_time ]] && preprompt_parts+=('%F{yellow}${prompt_pure_cmd_exec_time}%f') + + local cleaned_ps1=$PROMPT + local -H MATCH MBEGIN MEND + if [[ $PROMPT = *$prompt_newline* ]]; then + # When the prompt contains newlines, we keep everything before the first + # and after the last newline, leaving us with everything except the + # preprompt. This is needed because some software prefixes the prompt + # (e.g. virtualenv). + cleaned_ps1=${PROMPT%%${prompt_newline}*}${PROMPT##*${prompt_newline}} + fi + unset MATCH MBEGIN MEND + + # Construct the new prompt with a clean preprompt. + local -ah ps1 + ps1=( + $prompt_newline # Initial newline, for spaciousness. + ${(j. .)preprompt_parts} # Join parts, space separated. + $prompt_newline # Separate preprompt and prompt. + $cleaned_ps1 + ) + + PROMPT="${(j..)ps1}" + + # Expand the prompt for future comparision. + local expanded_prompt + expanded_prompt="${(S%%)PROMPT}" + + if [[ $1 != precmd ]] && [[ $prompt_pure_last_prompt != $expanded_prompt ]]; then + # Redraw the prompt. + zle && zle .reset-prompt + fi + + typeset -g prompt_pure_last_prompt=$expanded_prompt } prompt_pure_precmd() { # check exec time and store it in a variable prompt_pure_check_cmd_exec_time - - # by making sure that prompt_pure_cmd_timestamp is defined here the async functions are prevented from interfering - # with the initial preprompt rendering - prompt_pure_cmd_timestamp= - - # check for git arrows - prompt_pure_check_git_arrows + unset prompt_pure_cmd_timestamp # shows the full path in the title prompt_pure_set_title 'expand-prompt' '%~' - # get vcs info - vcs_info - # preform async git dirty check and fetch prompt_pure_async_tasks + # Check if we should display the virtual env, we use a sufficiently high + # index of psvar (12) here to avoid collisions with user defined entries. + psvar[12]= + # When VIRTUAL_ENV_DISABLE_PROMPT is empty, it was unset by the user and + # Pure should take back control. + if [[ -n $VIRTUAL_ENV ]] && [[ -z $VIRTUAL_ENV_DISABLE_PROMPT || $VIRTUAL_ENV_DISABLE_PROMPT = 12 ]]; then + psvar[12]="${VIRTUAL_ENV:t}" + export VIRTUAL_ENV_DISABLE_PROMPT=12 + fi + # print the preprompt prompt_pure_preprompt_render "precmd" +} - # remove the prompt_pure_cmd_timestamp, indicating that precmd has completed - unset prompt_pure_cmd_timestamp +prompt_pure_async_git_aliases() { + setopt localoptions noshwordsplit + local dir=$1 + local -a gitalias pullalias + + # we enter repo to get local aliases as well. + builtin cd -q $dir + + # list all aliases and split on newline. + gitalias=(${(@f)"$(command git config --get-regexp "^alias\.")"}) + for line in $gitalias; do + parts=(${(@)=line}) # split line on spaces + aliasname=${parts[1]#alias.} # grab the name (alias.[name]) + shift parts # remove aliasname + + # check alias for pull or fetch (must be exact match). + if [[ $parts =~ ^(.*\ )?(pull|fetch)(\ .*)?$ ]]; then + pullalias+=($aliasname) + fi + done + + print -- ${(j:|:)pullalias} # join on pipe (for use in regex). +} + +prompt_pure_async_vcs_info() { + setopt localoptions noshwordsplit + builtin cd -q $1 2>/dev/null + + # configure vcs_info inside async task, this frees up vcs_info + # to be used or configured as the user pleases. + zstyle ':vcs_info:*' enable git + zstyle ':vcs_info:*' use-simple true + # only export two msg variables from vcs_info + zstyle ':vcs_info:*' max-exports 2 + # export branch (%b) and git toplevel (%R) + zstyle ':vcs_info:git*' formats '%b' '%R' + zstyle ':vcs_info:git*' actionformats '%b|%a' '%R' + + vcs_info + + local -A info + info[top]=$vcs_info_msg_1_ + info[branch]=$vcs_info_msg_0_ + + print -r - ${(@kvq)info} } # fastest possible way to check if repo is dirty prompt_pure_async_git_dirty() { - local untracked_dirty=$1; shift + setopt localoptions noshwordsplit + local untracked_dirty=$1 dir=$2 # use cd -q to avoid side effects of changing directory, e.g. chpwd hooks - cd -q "$*" + builtin cd -q $dir - if [[ "$untracked_dirty" == "0" ]]; then + if [[ $untracked_dirty = 0 ]]; then command git diff --no-ext-diff --quiet --exit-code else test -z "$(command git status --porcelain --ignore-submodules -unormal)" fi - (( $? )) && echo "*" + return $? } prompt_pure_async_git_fetch() { + setopt localoptions noshwordsplit # use cd -q to avoid side effects of changing directory, e.g. chpwd hooks - cd -q "$*" + builtin cd -q $1 # set GIT_TERMINAL_PROMPT=0 to disable auth prompting for git fetch (git 2.3+) - GIT_TERMINAL_PROMPT=0 command git -c gc.auto=0 fetch + export GIT_TERMINAL_PROMPT=0 + # set ssh BachMode to disable all interactive ssh password prompting + export GIT_SSH_COMMAND=${GIT_SSH_COMMAND:-"ssh -o BatchMode=yes"} + + command git -c gc.auto=0 fetch &>/dev/null || return 99 + + # check arrow status after a successful git fetch + prompt_pure_async_git_arrows $1 +} + +prompt_pure_async_git_arrows() { + setopt localoptions noshwordsplit + builtin cd -q $1 + command git rev-list --left-right --count HEAD...@'{u}' } prompt_pure_async_tasks() { + setopt localoptions noshwordsplit + # initialize async worker ((!${prompt_pure_async_init:-0})) && { async_start_worker "prompt_pure" -u -n async_register_callback "prompt_pure" prompt_pure_async_callback - prompt_pure_async_init=1 + typeset -g prompt_pure_async_init=1 } - # store working_tree without the "x" prefix - local working_tree="${vcs_info_msg_1_#x}" + typeset -gA prompt_pure_vcs_info - # check if the working tree changed (prompt_pure_current_working_tree is prefixed by "x") - if [[ ${prompt_pure_current_working_tree#x} != $working_tree ]]; then + local -H MATCH MBEGIN MEND + if ! [[ $PWD = ${prompt_pure_vcs_info[pwd]}* ]]; then # stop any running async jobs async_flush_jobs "prompt_pure" # reset git preprompt variables, switching working tree unset prompt_pure_git_dirty unset prompt_pure_git_last_dirty_check_timestamp + unset prompt_pure_git_arrows + unset prompt_pure_git_fetch_pattern + prompt_pure_vcs_info[branch]= + prompt_pure_vcs_info[top]= + fi + unset MATCH MBEGIN MEND - # set the new working tree and prefix with "x" to prevent the creation of a named path by AUTO_NAME_DIRS - prompt_pure_current_working_tree="x${working_tree}" + async_job "prompt_pure" prompt_pure_async_vcs_info $PWD + + # # only perform tasks inside git working tree + [[ -n $prompt_pure_vcs_info[top] ]] || return + + prompt_pure_async_refresh +} + +prompt_pure_async_refresh() { + setopt localoptions noshwordsplit + + if [[ -z $prompt_pure_git_fetch_pattern ]]; then + # we set the pattern here to avoid redoing the pattern check until the + # working three has changed. pull and fetch are always valid patterns. + typeset -g prompt_pure_git_fetch_pattern="pull|fetch" + async_job "prompt_pure" prompt_pure_async_git_aliases $working_tree fi - # only perform tasks inside git working tree - [[ -n $working_tree ]] || return + async_job "prompt_pure" prompt_pure_async_git_arrows $PWD # do not preform git fetch if it is disabled or working_tree == HOME if (( ${PURE_GIT_PULL:-1} )) && [[ $working_tree != $HOME ]]; then # tell worker to do a git fetch - async_job "prompt_pure" prompt_pure_async_git_fetch "${working_tree}" + async_job "prompt_pure" prompt_pure_async_git_fetch $PWD fi # if dirty checking is sufficiently fast, tell worker to check it again, or wait for timeout @@ -277,41 +341,128 @@ prompt_pure_async_tasks() { if (( time_since_last_dirty_check > ${PURE_GIT_DELAY_DIRTY_CHECK:-1800} )); then unset prompt_pure_git_last_dirty_check_timestamp # check check if there is anything to pull - async_job "prompt_pure" prompt_pure_async_git_dirty "${PURE_GIT_UNTRACKED_DIRTY:-1}" "${working_tree}" + async_job "prompt_pure" prompt_pure_async_git_dirty ${PURE_GIT_UNTRACKED_DIRTY:-1} $PWD fi } -prompt_pure_async_callback() { - local job=$1 - local output=$3 - local exec_time=$4 +prompt_pure_check_git_arrows() { + setopt localoptions noshwordsplit + local arrows left=${1:-0} right=${2:-0} - case "${job}" in + (( right > 0 )) && arrows+=${PURE_GIT_DOWN_ARROW:-⇣} + (( left > 0 )) && arrows+=${PURE_GIT_UP_ARROW:-⇡} + + [[ -n $arrows ]] || return + typeset -g REPLY=$arrows +} + +prompt_pure_async_callback() { + setopt localoptions noshwordsplit + local job=$1 code=$2 output=$3 exec_time=$4 next_pending=$6 + local do_render=0 + + case $job in + prompt_pure_async_vcs_info) + local -A info + typeset -gA prompt_pure_vcs_info + + # parse output (z) and unquote as array (Q@) + info=("${(Q@)${(z)output}}") + local -H MATCH MBEGIN MEND + # check if git toplevel has changed + if [[ $info[top] = $prompt_pure_vcs_info[top] ]]; then + # if stored pwd is part of $PWD, $PWD is shorter and likelier + # to be toplevel, so we update pwd + if [[ $prompt_pure_vcs_info[pwd] = ${PWD}* ]]; then + prompt_pure_vcs_info[pwd]=$PWD + fi + else + # store $PWD to detect if we (maybe) left the git path + prompt_pure_vcs_info[pwd]=$PWD + fi + unset MATCH MBEGIN MEND + + # update has a git toplevel set which means we just entered a new + # git directory, run the async refresh tasks + [[ -n $info[top] ]] && [[ -z $prompt_pure_vcs_info[top] ]] && prompt_pure_async_refresh + + # always update branch and toplevel + prompt_pure_vcs_info[branch]=$info[branch] + prompt_pure_vcs_info[top]=$info[top] + + do_render=1 + ;; + prompt_pure_async_git_aliases) + if [[ -n $output ]]; then + # append custom git aliases to the predefined ones. + prompt_pure_git_fetch_pattern+="|$output" + fi + ;; prompt_pure_async_git_dirty) - prompt_pure_git_dirty=$output - prompt_pure_preprompt_render + local prev_dirty=$prompt_pure_git_dirty + if (( code == 0 )); then + unset prompt_pure_git_dirty + else + typeset -g prompt_pure_git_dirty="*" + fi + + [[ $prev_dirty != $prompt_pure_git_dirty ]] && do_render=1 # When prompt_pure_git_last_dirty_check_timestamp is set, the git info is displayed in a different color. # To distinguish between a "fresh" and a "cached" result, the preprompt is rendered before setting this # variable. Thus, only upon next rendering of the preprompt will the result appear in a different color. - (( $exec_time > 2 )) && prompt_pure_git_last_dirty_check_timestamp=$EPOCHSECONDS + (( $exec_time > 5 )) && prompt_pure_git_last_dirty_check_timestamp=$EPOCHSECONDS ;; - prompt_pure_async_git_fetch) - prompt_pure_check_git_arrows - prompt_pure_preprompt_render + prompt_pure_async_git_fetch|prompt_pure_async_git_arrows) + # prompt_pure_async_git_fetch executes prompt_pure_async_git_arrows + # after a successful fetch. + if (( code == 0 )); then + local REPLY + prompt_pure_check_git_arrows ${(ps:\t:)output} + if [[ $prompt_pure_git_arrows != $REPLY ]]; then + typeset -g prompt_pure_git_arrows=$REPLY + do_render=1 + fi + elif (( code != 99 )); then + # Unless the exit code is 99, prompt_pure_async_git_arrows + # failed with a non-zero exit status, meaning there is no + # upstream configured. + if [[ -n $prompt_pure_git_arrows ]]; then + unset prompt_pure_git_arrows + do_render=1 + fi + fi ;; esac + + if (( next_pending )); then + (( do_render )) && typeset -g prompt_pure_async_render_requested=1 + return + fi + + [[ ${prompt_pure_async_render_requested:-$do_render} = 1 ]] && prompt_pure_preprompt_render + unset prompt_pure_async_render_requested } prompt_pure_setup() { - # prevent percentage showing up - # if output doesn't end with a newline + # Prevent percentage showing up if output doesn't end with a newline. export PROMPT_EOL_MARK='' prompt_opts=(subst percent) + # borrowed from promptinit, sets the prompt options in case pure was not + # initialized via promptinit. + setopt noprompt{bang,cr,percent,subst} "prompt${^prompt_opts[@]}" + + if [[ -z $prompt_newline ]]; then + # This variable needs to be set, usually set by promptinit. + typeset -g prompt_newline=$'\n%{\r%}' + fi + zmodload zsh/datetime zmodload zsh/zle + zmodload zsh/parameter + autoload -Uz add-zsh-hook autoload -Uz vcs_info autoload -Uz async && async @@ -319,30 +470,17 @@ prompt_pure_setup() { add-zsh-hook precmd prompt_pure_precmd add-zsh-hook preexec prompt_pure_preexec - zstyle ':vcs_info:*' enable git - zstyle ':vcs_info:*' use-simple true - # only export two msg variables from vcs_info - zstyle ':vcs_info:*' max-exports 2 - # vcs_info_msg_0_ = ' %b' (for branch) - # vcs_info_msg_1_ = 'x%R' git top level (%R), x-prefix prevents creation of a named path (AUTO_NAME_DIRS) - zstyle ':vcs_info:git*' formats ' %b' 'x%R' - zstyle ':vcs_info:git*' actionformats ' %b|%a' 'x%R' - - # if the user has not registered a custom zle widget for clear-screen, - # override the builtin one so that the preprompt is displayed correctly when - # ^L is issued. - if [[ $widgets[clear-screen] == 'builtin' ]]; then - zle -N clear-screen prompt_pure_clear_screen - fi - # show username@host if logged in through SSH - [[ "$SSH_CONNECTION" != '' ]] && prompt_pure_username=' %F{242}%n@%m%f' + [[ "$SSH_CONNECTION" != '' ]] && prompt_pure_username='%F{242}%n@%m%f' # show username@host if root, with username in white - [[ $UID -eq 0 ]] && prompt_pure_username=' %F{white}%n%f%F{242}@%m%f' + [[ $UID -eq 0 ]] && prompt_pure_username='%F{white}%n%f%F{242}@%m%f' + + # if a virtualenv is activated, display it in grey + PROMPT='%(12V.%F{242}%12v%f .)' # prompt turns red if the previous command didn't exit with 0 - PROMPT="%(?.%F{magenta}.%F{red})${PURE_PROMPT_SYMBOL:-❯}%f " + PROMPT+='%(?.%F{magenta}.%F{red})${PURE_PROMPT_SYMBOL:-❯}%f ' } prompt_pure_setup "$@" diff --git a/.zprezto/modules/prompt/external/pure/readme.md b/.zprezto/modules/prompt/external/pure/readme.md index 326a397..e3d9958 100644 --- a/.zprezto/modules/prompt/external/pure/readme.md +++ b/.zprezto/modules/prompt/external/pure/readme.md @@ -2,7 +2,7 @@ > Pretty, minimal and fast ZSH prompt -![](screenshot.png) + ## Overview @@ -11,10 +11,10 @@ Most prompts are cluttered, ugly and slow. I wanted something visually pleasing ### Why? -- Comes with the perfect prompt character. +- Comes with the perfect prompt character. Author went through the whole Unicode range to find it. - Shows `git` branch and whether it's dirty (with a `*`). -- Indicates when you have unpushed/unpulled `git` commits with up/down arrows. +- Indicates when you have unpushed/unpulled `git` commits with up/down arrows. *(Check is done asynchronously!)* - Prompt character turns red if the last command didn't exit with `0`. - Command execution time will be displayed if it exceeds the set threshold. - Username and host only displayed when in an SSH session. @@ -24,11 +24,11 @@ Most prompts are cluttered, ugly and slow. I wanted something visually pleasing ## Install -Can be installed with `npm` or manually. Requires git 2.0.0+ and ZSH 5.0.0+. +Can be installed with `npm` or manually. Requires Git 2.0.0+ and ZSH 5.2+. Older versions of ZSH are known to work, but they are **not** recommended. ### npm -``` +```console $ npm install --global pure-prompt ``` @@ -39,7 +39,7 @@ That's it. Skip to [Getting started](#getting-started). 1. Either… - Clone this repo - add it as a submodule, or - - just download `pure.zsh` + - just download [`pure.zsh`](pure.zsh) and [`async.zsh`](async.zsh) 2. Symlink `pure.zsh` to somewhere in [`$fpath`](http://www.refining-linux.org/archives/46/ZSH-Gem-12-Autoloading-functions/) with the name `prompt_pure_setup`. @@ -47,7 +47,7 @@ That's it. Skip to [Getting started](#getting-started). #### Example -``` +```console $ ln -s "$PWD/pure.zsh" /usr/local/share/zsh/site-functions/prompt_pure_setup $ ln -s "$PWD/async.zsh" /usr/local/share/zsh/site-functions/async ``` @@ -62,7 +62,7 @@ fpath=( "$HOME/.zfunctions" $fpath ) Then install the theme there: -```sh +```console $ ln -s "$PWD/pure.zsh" "$HOME/.zfunctions/prompt_pure_setup" $ ln -s "$PWD/async.zsh" "$HOME/.zfunctions/async" ``` @@ -74,7 +74,7 @@ Initialize the prompt system (if not so already) and choose `pure`: ```sh # .zshrc -autoload -U promptinit && promptinit +autoload -U promptinit; promptinit prompt pure ``` @@ -95,7 +95,7 @@ Set `PURE_GIT_UNTRACKED_DIRTY=0` to not include untracked files in dirtiness che ### `PURE_GIT_DELAY_DIRTY_CHECK` -Time in seconds to delay git dirty checking for large repositories (git status takes > 2 seconds). The check is performed asynchronously, this is to save CPU. Defaults to `1800` seconds. +Time in seconds to delay git dirty checking for large repositories (git status takes > 5 seconds). The check is performed asynchronously, this is to save CPU. Defaults to `1800` seconds. ### `PURE_PROMPT_SYMBOL` @@ -114,7 +114,7 @@ Defines the git up arrow symbol. The default value is `⇡`. ```sh # .zshrc -autoload -U promptinit && promptinit +autoload -U promptinit; promptinit # optionally define some options PURE_CMD_MAX_EXEC_TIME=10 @@ -125,42 +125,74 @@ prompt pure ## Tips -[Tomorrow Night Eighties](https://github.com/chriskempson/tomorrow-theme) theme with the [Droid Sans Mono](http://www.google.com/webfonts/specimen/Droid+Sans+Mono) font (15pt) is a beautiful combination, as seen in the screenshot above. Just make sure you have anti-aliasing enabled in your Terminal. +In the screenshot you see Pure running in [Hyper](https://hyper.is) with the [hyper-snazzy](https://github.com/sindresorhus/hyper-snazzy) theme and Menlo font. -To have commands colorized as seen in the screenshot install [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting). +The [Tomorrow Night Eighties](https://github.com/chriskempson/tomorrow-theme) theme with the [Droid Sans Mono](https://www.fontsquirrel.com/fonts/droid-sans-mono) font (15pt) is also a [nice combination](https://github.com/sindresorhus/pure/blob/95ee3e7618c6e2162a1e3cdac2a88a20ac3beb27/screenshot.png).
+*Just make sure you have anti-aliasing enabled in your terminal.* + +To have commands colorized as seen in the screenshot, install [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting). ## Integration ### [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) -1. Remove competing theme included in oh-my-zsh `~/.oh-my-zsh/themes/pure.zsh-theme` -2. Symlink (or copy) `pure.zsh` to `~/.oh-my-zsh/custom/pure.zsh-theme` -3. Symlink (or copy) `async.zsh` to `~/.oh-my-zsh/custom/async.zsh` -4. Add `ZSH_THEME="pure"` to your `.zshrc` file. +1. Set `ZSH_THEME=""` in your `.zshrc` to disable oh-my-zsh themes. +2. Follow the Pure [Install](#install) instructions. + +**NOTE:** `oh-my-zsh` overrides the prompt so Pure must be activated *after* `source $ZSH/oh-my-zsh.sh`. ### [prezto](https://github.com/sorin-ionescu/prezto) -Set `zstyle ':prezto:module:prompt' theme 'pure'` in `~/.zpreztorc`. +Pure is bundled with Prezto. No need to install it. + +Add `prompt pure` to your `~/.zpreztorc`. + +### [zim](https://github.com/Eriner/zim) + +Pure is bundled with Zim. No need to install it. + +Set `zprompt_theme='pure'` in `~/.zimrc`. ### [antigen](https://github.com/zsh-users/antigen) Update your `.zshrc` file with the following two lines (order matters). Do not use the `antigen theme` function. -``` +```sh antigen bundle mafredri/zsh-async antigen bundle sindresorhus/pure ``` +### [antibody](https://github.com/getantibody/antibody) + +Update your `.zshrc` file with the following two lines (order matters): + +```sh +antibody bundle mafredri/zsh-async +antibody bundle sindresorhus/pure +``` + +### [zplug](https://github.com/zplug/zplug) + +Update your `.zshrc` file with the following two lines: + +```sh +zplug mafredri/zsh-async, from:github +zplug sindresorhus/pure, use:pure.zsh, from:github, as:theme +``` + +### [zplugin](https://github.com/zdharma/zplugin) + +Update your `.zshrc` file with the following two lines (order matters): + +```sh +zplugin ice pick"async.zsh" src"pure.zsh" +zplugin light sindresorhus/pure +``` + ## FAQ -### My preprompt is missing when I clear the screen with Ctrl+L - -Pure doesn't register its custom *clear-screen* widget if it has been previously modified. If you haven't registered your own zle widget with `zle -N clear-screen custom-clear-screen` it might have been done by third-party modules. For example `zsh-syntax-highlighting` and `zsh-history-substring-search` are known to do this and they should for that reason be **the very last thing** in your `.zshrc` (as pointed out in their documentation). - -To find out the culprit that is overriding your *clear-screen* widget, you can run the following command: `zle -l | grep clear-screen`. - -### I am stuck in a shell loop in my terminal that ask me to authenticate. What should I do ? +### I am stuck in a shell loop in my terminal that asks me to authenticate. What should I do? [This is a known issue](https://github.com/sindresorhus/pure/issues/76). Using `git pull` when you get the username prompt should help you to break the loop by giving you a real prompt for this. **[This has been fixed in git 2.3](https://github.com/sindresorhus/pure/commit/f43ab97e1cf4a276b7a6e33eac055ee16610be15)** @@ -171,22 +203,38 @@ Using `git pull` when you get the username prompt should help you to break the l #### Gentoo -``` -sudo sh -c "echo 'SANDBOX_WRITE=\"/dev/ptmx\"' > /etc/sandbox.d/10zsh" -sudo emerge -1 zsh +```console +$ sudo sh -c "echo 'SANDBOX_WRITE=\"/dev/ptmx\"' > /etc/sandbox.d/10zsh" +$ sudo emerge -1 zsh ``` #### FreeBSD 10.1 On a default setup, running the command `kldload pty` should do the trick. If you have a custom kernel, you might need to add `device pty` to the configuration file ([example](https://github.com/nbari/freebsd/blob/58646a9c3c4aaabf6f6467ff505f27f09e29dc75/kernels/xen.kernel#L188)). + +## Ports + +- **ZSH** + - [therealklanni/purity](https://github.com/therealklanni/purity) - More compact current working directory, important details on the main prompt line, and extra Git indicators. + - [intelfx/pure](https://github.com/intelfx/pure) - Solarized-friendly colors, highly verbose, and fully async Git integration. + - [dfurnes/purer](https://github.com/dfurnes/purer) - Compact single-line prompt with built-in Vim-mode indicator. +- **Bash** + - [sapegin/dotfiles](https://github.com/sapegin/dotfiles) - [Prompt](https://github.com/sapegin/dotfiles/blob/dd063f9c30de7d2234e8accdb5272a5cc0a3388b/includes/bash_prompt.bash) and [color theme](https://github.com/sapegin/dotfiles/tree/master/color) for Terminal.app. +- **Fish** + - [brandonweiss/pure.fish](https://github.com/brandonweiss/pure.fish) - Pure-inspired prompt for Fish. Not intended to have feature parity. + - [rafaelrinaldi/pure](https://github.com/rafaelrinaldi/pure) - Support for bare Fish and various framework ([Oh-My-Fish](https://github.com//oh-my-fish/oh-my-fish), [Fisherman](https://github.com//fisherman/fisherman), and [Wahoo](https://github.com//bucaran/wahoo)). +- **Rust** + - [xcambar/purs](https://github.com/xcambar/purs) - Pure-inspired prompt in Rust. + + ## Team -[![Sindre Sorhus](https://avatars.githubusercontent.com/u/170270?v=3&s=100)](http://sindresorhus.com) | [![Mathias Fredriksson](https://avatars.githubusercontent.com/u/147409?v=3&s=100)](https://github.com/mafredri) +[![Sindre Sorhus](https://github.com/sindresorhus.png?size=100)](http://sindresorhus.com) | [![Mathias Fredriksson](https://github.com/mafredri.png?size=100)](https://github.com/mafredri) ---|--- -[Sindre Sorhus](http://sindresorhus.com) | [Mathias Fredriksson](https://github.com/mafredri) +[Sindre Sorhus](https://github.com/sindresorhus) | [Mathias Fredriksson](https://github.com/mafredri) ## License -MIT © [Sindre Sorhus](http://sindresorhus.com) +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/.zprezto/modules/prompt/external/pure/screenshot.png b/.zprezto/modules/prompt/external/pure/screenshot.png index dd7db79..1a27678 100644 Binary files a/.zprezto/modules/prompt/external/pure/screenshot.png and b/.zprezto/modules/prompt/external/pure/screenshot.png differ diff --git a/.zprezto/modules/prompt/functions/async b/.zprezto/modules/prompt/functions/async deleted file mode 120000 index d4b591e..0000000 --- a/.zprezto/modules/prompt/functions/async +++ /dev/null @@ -1 +0,0 @@ -../external/pure/async.zsh \ No newline at end of file diff --git a/.zprezto/modules/prompt/functions/async b/.zprezto/modules/prompt/functions/async new file mode 100644 index 0000000..1257029 --- /dev/null +++ b/.zprezto/modules/prompt/functions/async @@ -0,0 +1,499 @@ +#!/usr/bin/env zsh + +# +# zsh-async +# +# version: 1.6.2 +# author: Mathias Fredriksson +# url: https://github.com/mafredri/zsh-async +# + +typeset -g ASYNC_VERSION=1.6.2 +# Produce debug output from zsh-async when set to 1. +typeset -g ASYNC_DEBUG=${ASYNC_DEBUG:-0} + +# Wrapper for jobs executed by the async worker, gives output in parseable format with execution time +_async_job() { + # Disable xtrace as it would mangle the output. + setopt localoptions noxtrace + + # Store start time for job. + float -F duration=$EPOCHREALTIME + + # Run the command and capture both stdout (`eval`) and stderr (`cat`) in + # separate subshells. When the command is complete, we grab write lock + # (mutex token) and output everything except stderr inside the command + # block, after the command block has completed, the stdin for `cat` is + # closed, causing stderr to be appended with a $'\0' at the end to mark the + # end of output from this job. + local stdout stderr ret tok + { + stdout=$(eval "$@") + ret=$? + duration=$(( EPOCHREALTIME - duration )) # Calculate duration. + + # Grab mutex lock, stalls until token is available. + read -r -k 1 -p tok || exit 1 + + # Return output ( ). + print -r -n - ${(q)1} $ret ${(q)stdout} $duration + } 2> >(stderr=$(cat) && print -r -n - " "${(q)stderr}$'\0') + + # Unlock mutex by inserting a token. + print -n -p $tok +} + +# The background worker manages all tasks and runs them without interfering with other processes +_async_worker() { + # Reset all options to defaults inside async worker. + emulate -R zsh + + # Make sure monitor is unset to avoid printing the + # pids of child processes. + unsetopt monitor + + # Redirect stderr to `/dev/null` in case unforseen errors produced by the + # worker. For example: `fork failed: resource temporarily unavailable`. + # Some older versions of zsh might also print malloc errors (know to happen + # on at least zsh 5.0.2 and 5.0.8) likely due to kill signals. + exec 2>/dev/null + + # When a zpty is deleted (using -d) all the zpty instances created before + # the one being deleted receive a SIGHUP, unless we catch it, the async + # worker would simply exit (stop working) even though visible in the list + # of zpty's (zpty -L). + TRAPHUP() { + return 0 # Return 0, indicating signal was handled. + } + + local -A storage + local unique=0 + local notify_parent=0 + local parent_pid=0 + local coproc_pid=0 + local processing=0 + + local -a zsh_hooks zsh_hook_functions + zsh_hooks=(chpwd periodic precmd preexec zshexit zshaddhistory) + zsh_hook_functions=(${^zsh_hooks}_functions) + unfunction $zsh_hooks &>/dev/null # Deactivate all zsh hooks inside the worker. + unset $zsh_hook_functions # And hooks with registered functions. + unset zsh_hooks zsh_hook_functions # Cleanup. + + child_exit() { + local -a pids + pids=(${${(v)jobstates##*:*:}%\=*}) + + # If coproc (cat) is the only child running, we close it to avoid + # leaving it running indefinitely and cluttering the process tree. + if (( ! processing )) && [[ $#pids = 1 ]] && [[ $coproc_pid = $pids[1] ]]; then + coproc : + coproc_pid=0 + fi + + # On older version of zsh (pre 5.2) we notify the parent through a + # SIGWINCH signal because `zpty` did not return a file descriptor (fd) + # prior to that. + if (( notify_parent )); then + # We use SIGWINCH for compatibility with older versions of zsh + # (pre 5.1.1) where other signals (INFO, ALRM, USR1, etc.) could + # cause a deadlock in the shell under certain circumstances. + kill -WINCH $parent_pid + fi + } + + # Register a SIGCHLD trap to handle the completion of child processes. + trap child_exit CHLD + + # Process option parameters passed to worker + while getopts "np:u" opt; do + case $opt in + n) notify_parent=1;; + p) parent_pid=$OPTARG;; + u) unique=1;; + esac + done + + killjobs() { + local tok + local -a pids + pids=(${${(v)jobstates##*:*:}%\=*}) + + # No need to send SIGHUP if no jobs are running. + (( $#pids == 0 )) && continue + (( $#pids == 1 )) && [[ $coproc_pid = $pids[1] ]] && continue + + # Grab lock to prevent half-written output in case a child + # process is in the middle of writing to stdin during kill. + (( coproc_pid )) && read -r -k 1 -p tok + + kill -HUP -$$ # Send to entire process group. + coproc : # Quit coproc. + coproc_pid=0 # Reset pid. + } + + local request + local -a cmd + while :; do + # Wait for jobs sent by async_job. + read -r -d $'\0' request || { + # Since we handle SIGHUP above (and thus do not know when `zpty -d`) + # occurs, a failure to read probably indicates that stdin has + # closed. This is why we propagate the signal to all children and + # exit manually. + kill -HUP -$$ # Send SIGHUP to all jobs. + exit 0 + } + + # Check for non-job commands sent to worker + case $request in + _unset_trap) notify_parent=0; continue;; + _killjobs) killjobs; continue;; + esac + + # Parse the request using shell parsing (z) to allow commands + # to be parsed from single strings and multi-args alike. + cmd=("${(z)request}") + + # Name of the job (first argument). + local job=$cmd[1] + + # If worker should perform unique jobs + if (( unique )); then + # Check if a previous job is still running, if yes, let it finnish + for pid in ${${(v)jobstates##*:*:}%\=*}; do + if [[ ${storage[$job]} == $pid ]]; then + continue 2 + fi + done + fi + + # Guard against closing coproc from trap before command has started. + processing=1 + + # Because we close the coproc after the last job has completed, we must + # recreate it when there are no other jobs running. + if (( ! coproc_pid )); then + # Use coproc as a mutex for synchronized output between children. + coproc cat + coproc_pid="$!" + # Insert token into coproc + print -n -p "t" + fi + + # Run job in background, completed jobs are printed to stdout. + _async_job $cmd & + # Store pid because zsh job manager is extremely unflexible (show jobname as non-unique '$job')... + storage[$job]="$!" + + processing=0 # Disable guard. + done +} + +# +# Get results from finnished jobs and pass it to the to callback function. This is the only way to reliably return the +# job name, return code, output and execution time and with minimal effort. +# +# usage: +# async_process_results +# +# callback_function is called with the following parameters: +# $1 = job name, e.g. the function passed to async_job +# $2 = return code +# $3 = resulting stdout from execution +# $4 = execution time, floating point e.g. 2.05 seconds +# $5 = resulting stderr from execution +# $6 = has next result in buffer (0 = buffer empty, 1 = yes) +# +async_process_results() { + setopt localoptions unset noshwordsplit noksharrays noposixidentifiers noposixstrings + + local worker=$1 + local callback=$2 + local caller=$3 + local -a items + local null=$'\0' data + integer -l len pos num_processed has_next + + typeset -gA ASYNC_PROCESS_BUFFER + + # Read output from zpty and parse it if available. + while zpty -r -t $worker data 2>/dev/null; do + ASYNC_PROCESS_BUFFER[$worker]+=$data + len=${#ASYNC_PROCESS_BUFFER[$worker]} + pos=${ASYNC_PROCESS_BUFFER[$worker][(i)$null]} # Get index of NULL-character (delimiter). + + # Keep going until we find a NULL-character. + if (( ! len )) || (( pos > len )); then + continue + fi + + while (( pos <= len )); do + # Take the content from the beginning, until the NULL-character and + # perform shell parsing (z) and unquoting (Q) as an array (@). + items=("${(@Q)${(z)ASYNC_PROCESS_BUFFER[$worker][1,$pos-1]}}") + + # Remove the extracted items from the buffer. + ASYNC_PROCESS_BUFFER[$worker]=${ASYNC_PROCESS_BUFFER[$worker][$pos+1,$len]} + + len=${#ASYNC_PROCESS_BUFFER[$worker]} + if (( len > 1 )); then + pos=${ASYNC_PROCESS_BUFFER[$worker][(i)$null]} # Get index of NULL-character (delimiter). + fi + + has_next=$(( len != 0 )) + if (( $#items == 5 )); then + items+=($has_next) + $callback "${(@)items}" # Send all parsed items to the callback. + else + # In case of corrupt data, invoke callback with *async* as job + # name, non-zero exit status and an error message on stderr. + $callback "async" 1 "" 0 "$0:$LINENO: error: bad format, got ${#items} items (${(q)items})" $has_next + fi + + (( num_processed++ )) + done + done + + (( num_processed )) && return 0 + + # Avoid printing exit value when `setopt printexitvalue` is active.` + [[ $caller = trap || $caller = watcher ]] && return 0 + + # No results were processed + return 1 +} + +# Watch worker for output +_async_zle_watcher() { + setopt localoptions noshwordsplit + typeset -gA ASYNC_PTYS ASYNC_CALLBACKS + local worker=$ASYNC_PTYS[$1] + local callback=$ASYNC_CALLBACKS[$worker] + + if [[ -n $callback ]]; then + async_process_results $worker $callback watcher + fi +} + +# +# Start a new asynchronous job on specified worker, assumes the worker is running. +# +# usage: +# async_job [] +# +async_job() { + setopt localoptions noshwordsplit noksharrays noposixidentifiers noposixstrings + + local worker=$1; shift + + local -a cmd + cmd=("$@") + if (( $#cmd > 1 )); then + cmd=(${(q)cmd}) # Quote special characters in multi argument commands. + fi + + # Quote the cmd in case RC_EXPAND_PARAM is set. + zpty -w $worker "$cmd"$'\0' +} + +# This function traps notification signals and calls all registered callbacks +_async_notify_trap() { + setopt localoptions noshwordsplit + + local k + for k in ${(k)ASYNC_CALLBACKS}; do + async_process_results $k ${ASYNC_CALLBACKS[$k]} trap + done +} + +# +# Register a callback for completed jobs. As soon as a job is finnished, async_process_results will be called with the +# specified callback function. This requires that a worker is initialized with the -n (notify) option. +# +# usage: +# async_register_callback +# +async_register_callback() { + setopt localoptions noshwordsplit nolocaltraps + + typeset -gA ASYNC_CALLBACKS + local worker=$1; shift + + ASYNC_CALLBACKS[$worker]="$*" + + # Enable trap when the ZLE watcher is unavailable, allows + # workers to notify (via -n) when a job is done. + if [[ ! -o interactive ]] || [[ ! -o zle ]]; then + trap '_async_notify_trap' WINCH + fi +} + +# +# Unregister the callback for a specific worker. +# +# usage: +# async_unregister_callback +# +async_unregister_callback() { + typeset -gA ASYNC_CALLBACKS + + unset "ASYNC_CALLBACKS[$1]" +} + +# +# Flush all current jobs running on a worker. This will terminate any and all running processes under the worker, use +# with caution. +# +# usage: +# async_flush_jobs +# +async_flush_jobs() { + setopt localoptions noshwordsplit + + local worker=$1; shift + + # Check if the worker exists + zpty -t $worker &>/dev/null || return 1 + + # Send kill command to worker + async_job $worker "_killjobs" + + # Clear the zpty buffer. + local junk + if zpty -r -t $worker junk '*'; then + (( ASYNC_DEBUG )) && print -n "async_flush_jobs $worker: ${(V)junk}" + while zpty -r -t $worker junk '*'; do + (( ASYNC_DEBUG )) && print -n "${(V)junk}" + done + (( ASYNC_DEBUG )) && print + fi + + # Finally, clear the process buffer in case of partially parsed responses. + typeset -gA ASYNC_PROCESS_BUFFER + unset "ASYNC_PROCESS_BUFFER[$worker]" +} + +# +# Start a new async worker with optional parameters, a worker can be told to only run unique tasks and to notify a +# process when tasks are complete. +# +# usage: +# async_start_worker [-u] [-n] [-p ] +# +# opts: +# -u unique (only unique job names can run) +# -n notify through SIGWINCH signal +# -p pid to notify (defaults to current pid) +# +async_start_worker() { + setopt localoptions noshwordsplit + + local worker=$1; shift + zpty -t $worker &>/dev/null && return + + typeset -gA ASYNC_PTYS + typeset -h REPLY + typeset has_xtrace=0 + + # Make sure async worker is started without xtrace + # (the trace output interferes with the worker). + [[ -o xtrace ]] && { + has_xtrace=1 + unsetopt xtrace + } + + if (( ! ASYNC_ZPTY_RETURNS_FD )) && [[ -o interactive ]] && [[ -o zle ]]; then + # When zpty doesn't return a file descriptor (on older versions of zsh) + # we try to guess it anyway. + integer -l zptyfd + exec {zptyfd}>&1 # Open a new file descriptor (above 10). + exec {zptyfd}>&- # Close it so it's free to be used by zpty. + fi + + zpty -b $worker _async_worker -p $$ $@ || { + async_stop_worker $worker + return 1 + } + + # Re-enable it if it was enabled, for debugging. + (( has_xtrace )) && setopt xtrace + + if [[ $ZSH_VERSION < 5.0.8 ]]; then + # For ZSH versions older than 5.0.8 we delay a bit to give + # time for the worker to start before issuing commands, + # otherwise it will not be ready to receive them. + sleep 0.001 + fi + + if [[ -o interactive ]] && [[ -o zle ]]; then + if (( ! ASYNC_ZPTY_RETURNS_FD )); then + REPLY=$zptyfd # Use the guessed value for the file desciptor. + fi + + ASYNC_PTYS[$REPLY]=$worker # Map the file desciptor to the worker. + zle -F $REPLY _async_zle_watcher # Register the ZLE handler. + + # Disable trap in favor of ZLE handler when notify is enabled (-n). + async_job $worker _unset_trap + fi +} + +# +# Stop one or multiple workers that are running, all unfetched and incomplete work will be lost. +# +# usage: +# async_stop_worker [] +# +async_stop_worker() { + setopt localoptions noshwordsplit + + local ret=0 worker k v + for worker in $@; do + # Find and unregister the zle handler for the worker + for k v in ${(@kv)ASYNC_PTYS}; do + if [[ $v == $worker ]]; then + zle -F $k + unset "ASYNC_PTYS[$k]" + fi + done + async_unregister_callback $worker + zpty -d $worker 2>/dev/null || ret=$? + + # Clear any partial buffers. + typeset -gA ASYNC_PROCESS_BUFFER + unset "ASYNC_PROCESS_BUFFER[$worker]" + done + + return $ret +} + +# +# Initialize the required modules for zsh-async. To be called before using the zsh-async library. +# +# usage: +# async_init +# +async_init() { + (( ASYNC_INIT_DONE )) && return + typeset -g ASYNC_INIT_DONE=1 + + zmodload zsh/zpty + zmodload zsh/datetime + + # Check if zsh/zpty returns a file descriptor or not, + # shell must also be interactive with zle enabled. + typeset -g ASYNC_ZPTY_RETURNS_FD=0 + [[ -o interactive ]] && [[ -o zle ]] && { + typeset -h REPLY + zpty _async_test : + (( REPLY )) && ASYNC_ZPTY_RETURNS_FD=1 + zpty -d _async_test + } +} + +async() { + async_init +} + +async "$@" diff --git a/.zprezto/modules/prompt/functions/prompt-pwd b/.zprezto/modules/prompt/functions/prompt-pwd new file mode 100644 index 0000000..53613e7 --- /dev/null +++ b/.zprezto/modules/prompt/functions/prompt-pwd @@ -0,0 +1,30 @@ +# +# Prompt setup function commonly used by prompt themes. +# +# Authors: +# Sorin Ionescu +# + +# function prompt-pwd { + +setopt localoptions extendedglob + +local current_pwd="${PWD/#$HOME/~}" +local ret_directory + +if [[ "$current_pwd" == (#m)[/~] ]]; then + ret_directory="$MATCH" + unset MATCH +elif zstyle -m ':prezto:module:prompt' pwd-length 'full'; then + ret_directory=${PWD} +elif zstyle -m ':prezto:module:prompt' pwd-length 'long'; then + ret_directory=${current_pwd} +else + ret_directory="${${${${(@j:/:M)${(@s:/:)current_pwd}##.#?}:h}%/}//\%/%%}/${${current_pwd:t}//\%/%%}" +fi + +unset current_pwd + +print "$ret_directory" + +# } diff --git a/.zprezto/modules/prompt/functions/prompt_abra_setup b/.zprezto/modules/prompt/functions/prompt_abra_setup deleted file mode 100644 index 6e76ed8..0000000 --- a/.zprezto/modules/prompt/functions/prompt_abra_setup +++ /dev/null @@ -1,89 +0,0 @@ -pmodload 'helper' - -# %F{color}...%f -- foreground colors -# %B...%b -- bold -# %(x.a.b) -- if - -# color chart: https://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg -# COLOR_PWD='141' -# COLOR_PWD_ROOT='201' -# COLOR_PROMPT_STARTER='85' -# COLOR_TIME='244' -# COLOR_USERNAME='34' -# COLOR_AT='244' -# COLOR_HOSTNAME='162' - -COLOR_PWD='cyan' -COLOR_PWD_ROOT='red' -COLOR_PROMPT_STARTER='green' -COLOR_TIME='green' -COLOR_USERNAME='blue' -COLOR_AT=$COLOR_USERNAME -COLOR_HOSTNAME=$COLOR_USERNAME - -NEWLINE=$'\n' - -function prompt_abra_precmd { - setopt LOCAL_OPTIONS - unsetopt XTRACE KSH_ARRAYS - - # Get Git repository information. - if [[ -z $NOGIT ]] && (( $+functions[git-info] )); then - git-info || true - fi - - PRE_LENGTH=$(($COLUMNS*2/3)) - - PRE='%$PRE_LENGTH<...<%~ %<<' - PRE=$(print -P $PRE) - PRE=$(print ${(l:$COLUMNS:)PRE}) - print -P '%(!.%F{$COLOR_PWD_ROOT}.%F{$COLOR_PWD})$PRE%f' -} - -function prompt_abra_setup { - setopt LOCAL_OPTIONS - unsetopt XTRACE KSH_ARRAYS - prompt_opts=(cr percent subst) - - # Load required functions. - autoload -Uz add-zsh-hook - - # Add hook for calling git-info before each command. - add-zsh-hook precmd prompt_abra_precmd - - # Set git-info parameters. - zstyle ':prezto:module:git:info' verbose 'yes' - zstyle ':prezto:module:git:info:action' format ':%%B%F{yellow}%s%f%%b' - zstyle ':prezto:module:git:info:added' format ' %%B%F{green}✚%f%%b' - zstyle ':prezto:module:git:info:ahead' format ' %%B%F{yellow}⬆%f%%b' - zstyle ':prezto:module:git:info:behind' format ' %%B%F{yellow}⬇%f%%b' - zstyle ':prezto:module:git:info:branch' format ':%F{green}%b%f' - zstyle ':prezto:module:git:info:commit' format ':%F{green}%.7c%f' - zstyle ':prezto:module:git:info:deleted' format ' %%B%F{red}✖%f%%b' - zstyle ':prezto:module:git:info:modified' format ' %%B%F{blue}✱%f%%b' - zstyle ':prezto:module:git:info:position' format ':%F{red}%p%f' - zstyle ':prezto:module:git:info:renamed' format ' %%B%F{magenta}➜%f%%b' - zstyle ':prezto:module:git:info:stashed' format ' %%B%F{cyan}✭%f%%b' - zstyle ':prezto:module:git:info:unmerged' format ' %%B%F{yellow}═%f%%b' - zstyle ':prezto:module:git:info:untracked' format ' %%B%F{white}◼%f%%b' - zstyle ':prezto:module:git:info:keys' format \ - 'prompt' '%b ' \ - 'rprompt' '%A%B%S%a%d%m%r%U%u' - - - - PROMPT='' - PROMPT=$PROMPT'${git_info:+${(e)git_info[prompt]}}' - PROMPT=$PROMPT'%(?.%F{$COLOR_PROMPT_STARTER}.%F{red})➤ %f' - - RPROMPT='' - RPROMPT=$RPROMPT'%(?::%F{red}%?%f )' # last command code if nonzero - RPROMPT=$RPROMPT'%B%F{$COLOR_USERNAME}%n%f%b' - RPROMPT=$RPROMPT'%B%F{$COLOR_AT}@%f%b' - RPROMPT=$RPROMPT'%B%F{$COLOR_HOSTNAME}%2m%f%b' - RPROMPT=$RPROMPT'${git_info[rprompt]} ' - RPROMPT=$RPROMPT'%F{$COLOR_TIME}%*%f' -} - -prompt_abra_setup "$@" - diff --git a/.zprezto/modules/prompt/functions/prompt_abra_setup b/.zprezto/modules/prompt/functions/prompt_abra_setup new file mode 120000 index 0000000..8ce3587 --- /dev/null +++ b/.zprezto/modules/prompt/functions/prompt_abra_setup @@ -0,0 +1 @@ +/Users/svxf/.zprezto/abra/prompt_abra_setup.zsh \ No newline at end of file diff --git a/.zprezto/modules/prompt/functions/prompt_agnoster_setup b/.zprezto/modules/prompt/functions/prompt_agnoster_setup deleted file mode 120000 index 34d8bc6..0000000 --- a/.zprezto/modules/prompt/functions/prompt_agnoster_setup +++ /dev/null @@ -1 +0,0 @@ -../external/agnoster/agnoster.zsh-theme \ No newline at end of file diff --git a/.zprezto/modules/prompt/functions/prompt_agnoster_setup b/.zprezto/modules/prompt/functions/prompt_agnoster_setup new file mode 100644 index 0000000..4eceafd --- /dev/null +++ b/.zprezto/modules/prompt/functions/prompt_agnoster_setup @@ -0,0 +1,165 @@ +# vim:ft=zsh ts=2 sw=2 sts=2 +# +# agnoster's Theme - https://gist.github.com/3712874 +# A Powerline-inspired theme for ZSH +# +# # README +# +# In order for this theme to render correctly, you will need a +# [Powerline-patched font](https://gist.github.com/1595572). +# +# In addition, I recommend the +# [Solarized theme](https://github.com/altercation/solarized/) and, if you're +# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app - +# it has significantly better color fidelity. +# +# # Goals +# +# The aim of this theme is to only show you *relevant* information. Like most +# prompts, it will only show git information when in a git working directory. +# However, it goes a step further: everything from the current user and +# hostname to whether the last call exited with an error to whether background +# jobs are running in this shell will all be displayed automatically when +# appropriate. + +### Segment drawing +# A few utility functions to make it easy and re-usable to draw segmented prompts + +CURRENT_BG='NONE' +if [[ -z "$PRIMARY_FG" ]]; then + PRIMARY_FG=black +fi + +# Characters +SEGMENT_SEPARATOR="\ue0b0" +PLUSMINUS="\u00b1" +BRANCH="\ue0a0" +DETACHED="\u27a6" +CROSS="\u2718" +LIGHTNING="\u26a1" +GEAR="\u2699" + +# Begin a segment +# Takes two arguments, background and foreground. Both can be omitted, +# rendering default background/foreground. +prompt_segment() { + local bg fg + [[ -n $1 ]] && bg="%K{$1}" || bg="%k" + [[ -n $2 ]] && fg="%F{$2}" || fg="%f" + if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then + print -n "%{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%}" + else + print -n "%{$bg%}%{$fg%}" + fi + CURRENT_BG=$1 + [[ -n $3 ]] && print -n $3 +} + +# End the prompt, closing any open segments +prompt_end() { + if [[ -n $CURRENT_BG ]]; then + print -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" + else + print -n "%{%k%}" + fi + print -n "%{%f%}" + CURRENT_BG='' +} + +### Prompt components +# Each component will draw itself, and hide itself if no information needs to be shown + +# Context: user@hostname (who am I and where am I) +prompt_context() { + local user=`whoami` + + if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CONNECTION" ]]; then + prompt_segment $PRIMARY_FG default " %(!.%{%F{yellow}%}.)$user@%m " + fi +} + +# Git: branch/detached head, dirty status +prompt_git() { + local color ref + is_dirty() { + test -n "$(git status --porcelain --ignore-submodules)" + } + ref="$vcs_info_msg_0_" + if [[ -n "$ref" ]]; then + if is_dirty; then + color=yellow + ref="${ref} $PLUSMINUS" + else + color=green + ref="${ref} " + fi + if [[ "${ref/.../}" == "$ref" ]]; then + ref="$BRANCH $ref" + else + ref="$DETACHED ${ref/.../}" + fi + prompt_segment $color $PRIMARY_FG + print -n " $ref" + fi +} + +# Dir: current working directory +prompt_dir() { + prompt_segment blue $PRIMARY_FG ' %~ ' +} + +# Status: +# - was there an error +# - am I root +# - are there background jobs? +prompt_status() { + local symbols + symbols=() + [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}$CROSS" + [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}$LIGHTNING" + [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}$GEAR" + + [[ -n "$symbols" ]] && prompt_segment $PRIMARY_FG default " $symbols " +} + +# Display current virtual environment +prompt_virtualenv() { + if [[ -n $VIRTUAL_ENV ]]; then + color=cyan + prompt_segment $color $PRIMARY_FG + print -Pn " $(basename $VIRTUAL_ENV) " + fi +} + +## Main prompt +prompt_agnoster_main() { + RETVAL=$? + CURRENT_BG='NONE' + prompt_status + prompt_context + prompt_virtualenv + prompt_dir + prompt_git + prompt_end +} + +prompt_agnoster_precmd() { + vcs_info + PROMPT='%{%f%b%k%}$(prompt_agnoster_main) ' +} + +prompt_agnoster_setup() { + autoload -Uz add-zsh-hook + autoload -Uz vcs_info + + prompt_opts=(cr subst percent) + + add-zsh-hook precmd prompt_agnoster_precmd + + zstyle ':vcs_info:*' enable git + zstyle ':vcs_info:*' check-for-changes false + zstyle ':vcs_info:git*' formats '%b' + zstyle ':vcs_info:git*' actionformats '%b (%a)' +} + +prompt_agnoster_setup "$@" diff --git a/.zprezto/modules/prompt/functions/prompt_cloud_setup b/.zprezto/modules/prompt/functions/prompt_cloud_setup index 3b048df..0637208 100644 --- a/.zprezto/modules/prompt/functions/prompt_cloud_setup +++ b/.zprezto/modules/prompt/functions/prompt_cloud_setup @@ -76,7 +76,7 @@ function prompt_cloud_preview { function prompt_cloud_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS - prompt_opts=(cr percent subst) + prompt_opts=(cr percent sp subst) # Set the theme prefix to a cloud or to the user's given characters. if [[ -n "$1" ]]; then diff --git a/.zprezto/modules/prompt/functions/prompt_damoekri_setup b/.zprezto/modules/prompt/functions/prompt_damoekri_setup index 58c4d35..4fe132d 100644 --- a/.zprezto/modules/prompt/functions/prompt_damoekri_setup +++ b/.zprezto/modules/prompt/functions/prompt_damoekri_setup @@ -11,23 +11,12 @@ # Load dependencies. pmodload 'helper' -function prompt_damoekri_pwd { - local pwd="${PWD/#$HOME/~}" - - if [[ "$pwd" == (#m)[/~] ]]; then - _prompt_damoekri_pwd="$MATCH" - unset MATCH - else - _prompt_damoekri_pwd="${${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}//\%/%%}/${${pwd:t}//\%/%%}" - fi -} - -function prompt_damoekri_precmd { +prompt_damoekri_precmd() { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS # Format PWD. - prompt_damoekri_pwd + _prompt_damoekri_pwd=$(prompt-pwd) # Get Git repository information. if (( $+functions[git-info] )); then @@ -43,7 +32,7 @@ function prompt_damoekri_precmd { function prompt_damoekri_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS - prompt_opts=(cr percent subst) + prompt_opts=(cr percent sp subst) # Load required functions. autoload -Uz add-zsh-hook diff --git a/.zprezto/modules/prompt/functions/prompt_giddie_setup b/.zprezto/modules/prompt/functions/prompt_giddie_setup index 5a14ffe..3c194fb 100644 --- a/.zprezto/modules/prompt/functions/prompt_giddie_setup +++ b/.zprezto/modules/prompt/functions/prompt_giddie_setup @@ -38,7 +38,7 @@ function prompt_giddie_precmd { function prompt_giddie_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS - prompt_opts=(cr percent subst) + prompt_opts=(cr percent sp subst) # Load required functions. autoload -Uz vcs_info diff --git a/.zprezto/modules/prompt/functions/prompt_kylewest_setup b/.zprezto/modules/prompt/functions/prompt_kylewest_setup index e4ee0c0..70b6a54 100644 --- a/.zprezto/modules/prompt/functions/prompt_kylewest_setup +++ b/.zprezto/modules/prompt/functions/prompt_kylewest_setup @@ -32,7 +32,7 @@ function prompt_kylewest_precmd { function prompt_kylewest_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS - prompt_opts=(cr percent subst) + prompt_opts=(cr percent sp subst) # Load required functions. autoload -Uz add-zsh-hook diff --git a/.zprezto/modules/prompt/functions/prompt_minimal_setup b/.zprezto/modules/prompt/functions/prompt_minimal_setup index 8c07e70..7456ffd 100644 --- a/.zprezto/modules/prompt/functions/prompt_minimal_setup +++ b/.zprezto/modules/prompt/functions/prompt_minimal_setup @@ -23,7 +23,7 @@ function prompt_minimal_precmd { function prompt_minimal_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS - prompt_opts=(cr percent subst) + prompt_opts=(cr percent sp subst) # Load required functions. autoload -Uz add-zsh-hook diff --git a/.zprezto/modules/prompt/functions/prompt_nicoulaj_setup b/.zprezto/modules/prompt/functions/prompt_nicoulaj_setup index 241c8b6..447ba1f 100644 --- a/.zprezto/modules/prompt/functions/prompt_nicoulaj_setup +++ b/.zprezto/modules/prompt/functions/prompt_nicoulaj_setup @@ -26,7 +26,7 @@ function prompt_nicoulaj_precmd { function prompt_nicoulaj_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS - prompt_opts=(cr percent subst) + prompt_opts=(cr percent sp subst) # Load required functions. autoload -Uz add-zsh-hook diff --git a/.zprezto/modules/prompt/functions/prompt_paradox_setup b/.zprezto/modules/prompt/functions/prompt_paradox_setup index 36ae40e..4f19989 100644 --- a/.zprezto/modules/prompt/functions/prompt_paradox_setup +++ b/.zprezto/modules/prompt/functions/prompt_paradox_setup @@ -8,6 +8,7 @@ # Isaac Wolkerstorfer # Jeff Sandberg # Sorin Ionescu +# Patrick Bos # # Screenshots: # http://i.imgur.com/0XIWX.png @@ -52,21 +53,14 @@ function prompt_paradox_build_prompt { prompt_paradox_start_segment green black '${(e)git_info[ref]}${(e)git_info[status]}' fi + if [[ -n "$python_info" ]]; then + prompt_paradox_start_segment white black '${(e)python_info[virtualenv]}' + fi + prompt_paradox_end_segment } -function prompt_paradox_pwd { - local pwd="${PWD/#$HOME/~}" - - if [[ "$pwd" == (#m)[/~] ]]; then - _prompt_paradox_pwd="$MATCH" - unset MATCH - else - _prompt_paradox_pwd="${${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}//\%/%%}/${${pwd:t}//\%/%%}" - fi -} - -function prompt_paradox_print_elapsed_time { +prompt_paradox_print_elapsed_time() { local end_time=$(( SECONDS - _prompt_paradox_start_time )) local hours minutes seconds remainder @@ -90,13 +84,18 @@ function prompt_paradox_precmd { unsetopt XTRACE KSH_ARRAYS # Format PWD. - prompt_paradox_pwd + _prompt_paradox_pwd=$(prompt-pwd) # Get Git repository information. if (( $+functions[git-info] )); then git-info fi + # Get Python environment information. + if (( $+functions[python-info] )); then + python-info + fi + # Calculate and print the elapsed time. prompt_paradox_print_elapsed_time } @@ -108,7 +107,7 @@ function prompt_paradox_preexec { function prompt_paradox_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS - prompt_opts=(cr percent subst) + prompt_opts=(cr percent sp subst) # Load required functions. autoload -Uz add-zsh-hook @@ -143,6 +142,9 @@ function prompt_paradox_setup { 'ref' '$(coalesce "%b" "%p" "%c")' \ 'status' '%s%D%A%B%S%a%d%m%r%U%u' + # %v - virtualenv name. + zstyle ':prezto:module:python:info:virtualenv' format 'virtualenv:%v' + # Define prompts. PROMPT=' ${(e)$(prompt_paradox_build_prompt)} diff --git a/.zprezto/modules/prompt/functions/prompt_peepcode_setup b/.zprezto/modules/prompt/functions/prompt_peepcode_setup index c70fb9a..2081961 100644 --- a/.zprezto/modules/prompt/functions/prompt_peepcode_setup +++ b/.zprezto/modules/prompt/functions/prompt_peepcode_setup @@ -25,7 +25,7 @@ function prompt_peepcode_precmd { function prompt_peepcode_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS - prompt_opts=(cr percent subst) + prompt_opts=(cr percent sp subst) # Load required functions. autoload -Uz add-zsh-hook diff --git a/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup b/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup new file mode 100755 index 0000000..c1ea754 --- /dev/null +++ b/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup @@ -0,0 +1,1912 @@ +# 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 +#PS4='%s%f%b%k%F{blue}%{λ%}%L %F{240}%N:%i%(?.. %F{red}%?) %1(_.%F{yellow}%-1_ .)%s%f%b%k ' +#zstyle ':vcs_info:*+*:*' debug true +#set -o xtrace + +# Try to set the installation path +if [[ -n "$POWERLEVEL9K_INSTALLATION_DIR" ]]; then + p9k_directory=${POWERLEVEL9K_INSTALLATION_DIR:A} +else + if [[ "${(%):-%N}" == '(eval)' ]]; then + if [[ "$0" == '-antigen-load' ]] && [[ -r "${PWD}/powerlevel9k.zsh-theme" ]]; then + # Antigen uses eval to load things so it can change the plugin (!!) + # https://github.com/zsh-users/antigen/issues/581 + p9k_directory=$PWD + else + print -P "%F{red}You must set POWERLEVEL9K_INSTALLATION_DIR work from within an (eval).%f" + return 1 + fi + else + # Get the path to file this code is executing in; then + # get the absolute path and strip the filename. + # See https://stackoverflow.com/a/28336473/108857 + p9k_directory=${${(%):-%x}:A:h} + fi +fi + +################################################################ +# Source icon functions +################################################################ + +source "${p9k_directory}/functions/icons.zsh" + +################################################################ +# Source utility functions +################################################################ + +source "${p9k_directory}/functions/utilities.zsh" + +################################################################ +# Source color functions +################################################################ + +source "${p9k_directory}/functions/colors.zsh" + +################################################################ +# Source VCS_INFO hooks / helper functions +################################################################ + +source "${p9k_directory}/functions/vcs.zsh" + +# cleanup temporary variables. +unset p9k_directory + +################################################################ +# 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="$(backgroundColor $3)" || bg="$(backgroundColor)" + [[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="$(foregroundColor)" + + 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="$fg" || complement="$(foregroundColor $DEFAULT_COLOR)" + echo -n "${bg}${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 + # Add an whitespace if we print more than just the visual identifier. + # To avoid cutting off the visual identifier in some terminal emulators (e.g., Konsole, st), + # we need to color both the visual identifier and the whitespace. + [[ -n "$5" ]] && visual_identifier="$visual_identifier " + # 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" + 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="$(backgroundColor $3)" || bg="$(backgroundColor)" + [[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="$(foregroundColor)" + + # If CURRENT_RIGHT_BG is "NONE", we are the first right segment. + + if [[ "$CURRENT_RIGHT_BG" != "NONE" ]]; then + # This is the closing whitespace for the previous segment + echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}%f" + fi + + 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="$fg" || complement="$(foregroundColor $DEFAULT_COLOR)" + echo -n "$complement$(print_icon 'RIGHT_SUBSEGMENT_SEPARATOR')%f" + else + # Use the new BG color for the foreground with separator + echo -n "$(foregroundColor $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 + # Add an whitespace if we print more than just the visual identifier. + # To avoid cutting off the visual identifier in some terminal emulators (e.g., Konsole, st), + # we need to color both the visual identifier and the whitespace. + [[ -n "$5" ]] && visual_identifier=" $visual_identifier" + # 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" + 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}" + + 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. + local _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_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 +set_default POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS false +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 ]] || [[ "$POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE_ALWAYS" == "true" ]]); 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 +} + +################################################################ +# A newline in your prompt, so you can segments on multiple lines. +prompt_newline() { + local lws newline + [[ "$1" == "right" ]] && return + newline=$'\n' + lws=$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS + if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then + newline="${newline}$(print_icon 'MULTILINE_NEWLINE_PROMPT_PREFIX')" + fi + POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS= + "$1_prompt_segment" \ + "$0" \ + "$2" \ + "NONE" "NONE" "${newline}" + POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws +} + +################################################################ +# 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 +} + +################################################################ +# Segment that displays the battery status in levels and colors +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 + + # override default icon if we are using battery stages + if [[ -n "$POWERLEVEL9K_BATTERY_STAGES" ]]; then + local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_STAGES} - 1 ) )) + if [[ $segment > 1 ]]; then + local offset=$(( ($bat_percent / $segment) + 1 )) + # check if the stages are in an array or a string + [[ "${(t)POWERLEVEL9K_BATTERY_STAGES}" =~ "array" ]] && POWERLEVEL9K_BATTERY_ICON="$POWERLEVEL9K_BATTERY_STAGES[$offset]" || POWERLEVEL9K_BATTERY_ICON=${POWERLEVEL9K_BATTERY_STAGES:$offset:1} + fi + fi + # return if POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD is set and the battery percentage is greater or equal + if [[ -v "POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD" && "${bat_percent}" -ge $POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD ]]; then + return + fi + + # override the default color if we are using a color level array + if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then + local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) )) + local offset=$(( ($bat_percent / $segment) + 1 )) + "$1_prompt_segment" "$0_${current_state}" "$2" "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON" + else + # Draw the prompt_segment + "$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 + if [[ "$OS" == "OSX" ]]; then + timediff=$(($(date +%s) - $(stat -f "%m" $POWERLEVEL9K_PUBLIC_IP_FILE))) + else + timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) + fi + [[ $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 + icon='PUBLIC_IP_ICON' + # Check VPN is on if VPN interface is set + if [[ -n $POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]]; then + for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE" | cut -d":" -f1) + do + icon='VPN_ICON' + break + done + fi + $1_prompt_segment "$0" "$2" "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${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" + "SUDO" "yellow" + "DEFAULT" "yellow" + "REMOTE" "yellow" + "REMOTE_SUDO" "yellow" + ) + + local content="" + + if [[ "$POWERLEVEL9K_ALWAYS_SHOW_CONTEXT" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + content="${POWERLEVEL9K_CONTEXT_TEMPLATE}" + elif [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]]; then + content="$(whoami)" + else + return + fi + + if [[ $(print -P "%#") == '#' ]]; then + current_state="ROOT" + elif [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + if sudo -n true 2>/dev/null; then + current_state="REMOTE_SUDO" + else + current_state="REMOTE" + fi + elif sudo -n true 2>/dev/null; then + current_state="SUDO" + fi + + "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" +} + +################################################################ +# User: user (who am I) +# Note that if $DEFAULT_USER is not set, this prompt segment will always print +set_default POWERLEVEL9K_USER_TEMPLATE "%n" +prompt_user() { + local current_state="DEFAULT" + typeset -AH user_state + if [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]] || [[ "$(whoami)" != "$DEFAULT_USER" ]]; then + if [[ $(print -P "%#") == '#' ]]; then + user_state=( + "STATE" "ROOT" + "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "ROOT_ICON" + ) + elif sudo -n true 2>/dev/null; then + user_state=( + "STATE" "SUDO" + "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "SUDO_ICON" + ) + else + user_state=( + "STATE" "DEFAULT" + "CONTENT" "$(whoami)" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "USER_ICON" + ) + fi + "$1_prompt_segment" "${0}_${user_state[STATE]}" "$2" "${user_state[BACKGROUND_COLOR]}" "${user_state[FOREGROUND_COLOR]}" "${user_state[CONTENT]}" "${user_state[VISUAL_IDENTIFIER]}" + fi +} + +################################################################ +# Host: machine (where am I) +set_default POWERLEVEL9K_HOST_TEMPLATE "%m" +prompt_host() { + local current_state="LOCAL" + typeset -AH host_state + if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then + host_state=( + "STATE" "REMOTE" + "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "SSH_ICON" + ) + else + host_state=( + "STATE" "LOCAL" + "CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "HOST_ICON" + ) + fi + "$1_prompt_segment" "$0_${host_state[STATE]}" "$2" "${host_state[BACKGROUND_COLOR]}" "${host_state[FOREGROUND_COLOR]}" "${host_state[CONTENT]}" "${host_state[VISUAL_IDENTIFIER]}" +} + +################################################################ +# 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" "yellow1" "${humanReadableDuration}" 'EXECUTION_TIME_ICON' + fi +} + +################################################################ +# Dir: current working directory +# Parameters: +# * $1 Alignment: string - left|right +# * $2 Index: integer +set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/" +set_default POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" +set_default POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD false +prompt_dir() { + # using $PWD instead of "$(print -P '%~')" to allow use of POWERLEVEL9K_DIR_PATH_ABSOLUTE + local current_path=$PWD # WAS: local current_path="$(print -P '%~')" + # check if the user wants to use absolute paths or "~" paths + [[ ${(L)POWERLEVEL9K_DIR_PATH_ABSOLUTE} != "true" ]] && current_path=${current_path//$HOME/"~"} + # declare all local variables + local paths directory test_dir test_dir_length trunc_path threshhold + # if we are not in "~" or "/", split the paths into an array and exclude "~" + (( ${#current_path} > 1 )) && paths=(${(s:/:)${current_path//"~\/"/}}) || paths=() + # only run the code if SHORTEN_DIR_LENGTH is set, or we are using the two strategies that don't rely on it. + if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_to_last" ]]; then + set_default POWERLEVEL9K_SHORTEN_DELIMITER "\u2026" + # convert delimiter from unicode to literal character, so that we can get the correct length later + local delim=$(echo -n $POWERLEVEL9K_SHORTEN_DELIMITER) + + case "$POWERLEVEL9K_SHORTEN_STRATEGY" in + truncate_absolute_chars) + if [ ${#current_path} -gt $(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#POWERLEVEL9K_SHORTEN_DELIMITER} )) ]; then + current_path=$POWERLEVEL9K_SHORTEN_DELIMITER${current_path:(-POWERLEVEL9K_SHORTEN_DIR_LENGTH)} + fi + ;; + truncate_middle) + # truncate characters from the middle of the path + current_path=$(truncatePath $current_path $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER "middle") + ;; + truncate_from_right) + # truncate characters from the right of the path + current_path=$(truncatePath "$current_path" $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER) + ;; + truncate_absolute) + # truncate all characters except the last POWERLEVEL9K_SHORTEN_DIR_LENGTH characters + if [ ${#current_path} -gt $(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#POWERLEVEL9K_SHORTEN_DELIMITER} )) ]; then + current_path=$POWERLEVEL9K_SHORTEN_DELIMITER${current_path:(-POWERLEVEL9K_SHORTEN_DIR_LENGTH)} + fi + ;; + truncate_to_last) + # truncate all characters before the current directory + current_path=${current_path##*/} + ;; + truncate_to_first_and_last) + if (( ${#current_path} > 1 )) && (( ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} > 0 )); then + threshhold=$(( ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} * 2)) + # if we are in "~", add it back into the paths array + [[ $current_path == '~'* ]] && paths=("~" "${paths[@]}") + if (( ${#paths} > $threshhold )); then + local num=$(( ${#paths} - ${POWERLEVEL9K_SHORTEN_DIR_LENGTH} )) + # repace the middle elements + for (( i=$POWERLEVEL9K_SHORTEN_DIR_LENGTH; i<$num; i++ )); do + paths[$i+1]=$POWERLEVEL9K_SHORTEN_DELIMITER + done + [[ $current_path != '~'* ]] && current_path="/" || current_path="" + current_path+="${(j:/:)paths}" + fi + fi + ;; + truncate_to_unique) + # for each parent path component find the shortest unique beginning + # characters sequence. Source: https://stackoverflow.com/a/45336078 + if (( ${#current_path} > 1 )); then # root and home are exceptions and won't have paths + local matching + local cur_path='/' + [[ $current_path != "~"* ]] && trunc_path='/' || trunc_path='' + for directory in ${paths[@]}; do + test_dir='' + for (( i=0; i<${#directory}; i++ )); do + test_dir+="${directory:$i:1}" + matching=("$cur_path"/"$test_dir"*/) + if [[ ${#matching[@]} -eq 1 ]]; then + break + fi + done + trunc_path+="$test_dir/" + cur_path+="$directory/" + done + [[ $current_path == "~"* ]] && trunc_path="~/$trunc_path" + current_path="${trunc_path: : -1}" + fi + ;; + truncate_with_folder_marker) + if (( ${#paths} > 0 )); then # root and home are exceptions and won't have paths, so skip this + 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. + trunc_path="/" + elif [[ "$marked_folder" == "$HOME" ]]; then + # If we reached home folder, stop upsearch. + trunc_path="~" + elif [[ "${marked_folder%/*}" == $last_marked_folder ]]; then + trunc_path="${trunc_path%/}/${marked_folder##*/}" + else + trunc_path="${trunc_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=$trunc_path${current_path#${last_marked_folder}*} + fi + ;; + 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]|){*})' + trunc_path=$(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=$(truncatePath "${trunc_path:${#${(S%%)package_path//$~zero/}}}" $POWERLEVEL9K_SHORTEN_DIR_LENGTH $POWERLEVEL9K_SHORTEN_DELIMITER) + # 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" + fi + ;; + *) + if [[ $current_path != "~" ]]; then + current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" + fi + ;; + esac + fi + + # save state of path for highlighting and bold options + local path_opt=$current_path + + typeset -AH dir_states + dir_states=( + "DEFAULT" "FOLDER_ICON" + "HOME" "HOME_ICON" + "HOME_SUBFOLDER" "HOME_SUB_ICON" + "NOT_WRITABLE" "LOCK_ICON" + "ETC" "ETC_ICON" + ) + local state_path="$(print -P '%~')" + local current_state="DEFAULT" + if [[ $state_path == '/etc'* ]]; then + current_state='ETC' + elif [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then + current_state="NOT_WRITABLE" + elif [[ $state_path == '~' ]]; then + current_state="HOME" + elif [[ $state_path == '~'* ]]; then + current_state="HOME_SUBFOLDER" + fi + + # declare variables used for bold and state colors + local bld_on bld_off dir_state_foreground dir_state_user_foreground + # test if user wants the last directory printed in bold + if [[ "${(L)POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD}" == "true" ]]; then + bld_on="%B" + bld_off="%b" + else + bld_on="" + bld_off="" + fi + # determine is the user has set a last directory color + local dir_state_user_foreground=POWERLEVEL9K_DIR_${current_state}_FOREGROUND + local dir_state_foreground=${(P)dir_state_user_foreground} + [[ -z ${dir_state_foreground} ]] && dir_state_foreground="${DEFAULT_COLOR}" + + local dir_name base_name + # use ZSH substitution to get the dirname and basename instead of calling external functions + dir_name=${path_opt%/*} + base_name=${path_opt##*/} + + # if the user wants the last directory colored... + if [[ -n ${POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND} ]]; then + # it the path is "/" or "~" + if [[ $path_opt == "/" || $path_opt == "~" ]]; then + current_path="${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${current_path}${bld_off}" + else # has a subfolder + # test if dirname != basename - they are equal if we use truncate_to_last or truncate_absolute + if [[ $dir_name != $base_name ]]; then + current_path="${dir_name}/${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${base_name}${bld_off}" + else + current_path="${bld_on}%F{$POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND}${base_name}${bld_off}" + fi + fi + else # no coloring + # it the path is "/" or "~" + if [[ $path_opt == "/" || $path_opt == "~" ]]; then + current_path="${bld_on}${current_path}${bld_off}" + else # has a subfolder + # test if dirname != basename - they are equal if we use truncate_to_last or truncate_absolute + if [[ $dir_name != $base_name ]]; then + current_path="${dir_name}/${bld_on}${base_name}${bld_off}" + else + current_path="${bld_on}${base_name}${bld_off}" + fi + fi + fi + + # check if we need to omit the first character and only do it if we are not in "~" or "/" + if [[ "${POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER}" == "true" && $path_opt != "/" && $path_opt != "~" ]]; then + current_path="${current_path[2,-1]}" + fi + + # check if the user wants the separator colored. + if [[ -n ${POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND} && $path_opt != "/" ]]; then + # because this contains color changing codes, it is easier to set a variable for what should be replaced + local repl="%F{$POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND}/%F{$dir_state_foreground}" + # escape the / with a \ + current_path=${current_path//\//$repl} + fi + + if [[ "${POWERLEVEL9K_DIR_PATH_SEPARATOR}" != "/" && $path_opt != "/" ]]; then + current_path=${current_path//\//$POWERLEVEL9K_DIR_PATH_SEPARATOR} + fi + + if [[ "${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}" != "~" && ! "${(L)POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER}" == "true" ]]; then + # use :s to only replace the first occurance + current_path=${current_path:s/~/$POWERLEVEL9K_HOME_FOLDER_ABBREVIATION} + 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" "grey93" "$go_version" "GO_ICON" + fi +} + +################################################################ +# Command number (in local history) +prompt_history() { + "$1_prompt_segment" "$0" "$2" "grey50" "$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" "$DEFAULT_COLOR" "yellow" "$virt" + else + ; + fi + else + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "$virt" + fi +} + +################################################################ +# Test icons +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 +} + +################################################################ +# Segment to display the current IP address +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' +} + +################################################################ +# Segment to display if VPN is active +set_default POWERLEVEL9K_VPN_IP_INTERFACE "tun" +# prompt if vpn active +prompt_vpn_ip() { + for vpn_iface in $(/sbin/ifconfig | grep -e ^"$POWERLEVEL9K_VPN_IP_INTERFACE" | cut -d":" -f1) + do + ip=$(/sbin/ifconfig "$vpn_iface" | grep -o "inet\s.*" | cut -d' ' -f2) + "$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'VPN_ICON' + done +} + +################################################################ +# Segment to display laravel version +prompt_laravel_version() { + local laravel_version="$(php artisan --version 2>/dev/null)" + if [[ -n "${laravel_version}" ]]; then + # Remove unrelevant infos + laravel_version="${laravel_version//Laravel Framework version /}" + + "$1_prompt_segment" "$0" "$2" "maroon" "white" "${laravel_version}" 'LARAVEL_ICON' + fi +} + +################################################################ +# Segment to display load +set_default POWERLEVEL9K_LOAD_WHICH 5 +prompt_load() { + # The load segment can have three different states + local current_state="unknown" + local load_select=2 + local load_avg + local cores + + typeset -AH load_states + load_states=( + 'critical' 'red' + 'warning' 'yellow' + 'normal' 'green' + ) + + case "$POWERLEVEL9K_LOAD_WHICH" in + 1) + load_select=1 + ;; + 5) + load_select=2 + ;; + 15) + load_select=3 + ;; + esac + + case "$OS" in + OSX|BSD) + load_avg=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | sed -n ${load_select}p) + if [[ "$OS" == "OSX" ]]; then + cores=$(sysctl -n hw.logicalcpu) + else + cores=$(sysctl -n hw.ncpu) + fi + ;; + *) + load_avg=$(cut -d" " -f${load_select} /proc/loadavg) + cores=$(nproc) + esac + + # Replace comma + load_avg=${load_avg//,/.} + + if [[ "$load_avg" -gt $((${cores} * 0.7)) ]]; then + current_state="critical" + elif [[ "$load_avg" -gt $((${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" 'LOAD_ICON' +} + +################################################################ +# Segment to diplay 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' +} + +################################################################ +# Segment to display Node version from NVM +# Only prints the segment if different than the default value +prompt_nvm() { + local node_version nvm_default + (( $+functions[nvm_version] )) || return + + node_version=$(nvm_version current) + [[ -z "${node_version}" || ${node_version} == "none" ]] && return + + nvm_default=$(nvm_version default) + [[ "$node_version" =~ "$nvm_default" ]] && return + + $1_prompt_segment "$0" "$2" "magenta" "black" "${node_version:1}" 'NODE_ICON' +} + +################################################################ +# Segment to display NodeEnv +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 +} + +################################################################ +# Segment to print a little OS icon +prompt_os_icon() { + "$1_prompt_segment" "$0" "$2" "black" "white" "$OS_ICON" +} + +################################################################ +# Segment to display 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" "fuchsia" "grey93" "$php_version" + fi +} + +################################################################ +# Segment to display 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' +} + + +set_default POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW false +# rbenv information +prompt_rbenv() { + if command 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 + # unless `POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW` is set. + if [[ $rbenv_version_name == $rbenv_global && "$POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW" = false ]]; then + return + fi + + "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' + fi +} + +################################################################ +# Segment to display chruby information +# see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH +prompt_chruby() { + # Uses $RUBY_VERSION and $RUBY_ENGINE set by chruby + set_default POWERLEVEL9K_CHRUBY_SHOW_VERSION true + set_default POWERLEVEL9K_CHRUBY_SHOW_ENGINE true + local chruby_label="" + + if [[ "$POWERLEVEL9K_CHRUBY_SHOW_ENGINE" == true ]]; then + chruby_label+="$RUBY_ENGINE " + fi + if [[ "$POWERLEVEL9K_CHRUBY_SHOW_VERSION" == true ]]; then + chruby_label+="$RUBY_VERSION" + fi + + # Truncate trailing spaces + chruby_label="${chruby_label%"${chruby_label##*[![:space:]]}"}" + + # Don't show anything if the chruby did not change the default ruby + if [[ "$RUBY_ENGINE" != "" ]]; then + "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "${chruby_label}" 'RUBY_ICON' + fi +} + +################################################################ +# Segment to 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 +} + +################################################################ +# Segment to display Rust version number +prompt_rust_version() { + local rust_version + rust_version=$(command rustc --version 2>/dev/null) + # Remove "rustc " (including the whitespace) from the beginning + # of the version string and remove everything after the next + # whitespace. This way we'll end up with only the version. + rust_version=${${rust_version/rustc /}%% *} + + if [[ -n "$rust_version" ]]; then + "$1_prompt_segment" "$0" "$2" "darkorange" "$DEFAULT_COLOR" "$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 +} + +################################################################ +# Segment to display Ruby Version Manager information +prompt_rvm() { + local version_and_gemset=${rvm_env_string/ruby-} + + if [[ -n "$version_and_gemset" ]]; then + "$1_prompt_segment" "$0" "$2" "grey35" "$DEFAULT_COLOR" "$version_and_gemset" 'RUBY_ICON' + fi +} + +################################################################ +# Segment to display SSH icon when connected +prompt_ssh() { + if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "" 'SSH_ICON' + fi +} + +################################################################ +# Status: When an error occur, return the error code, or a cross icon if option is set +# Display an ok icon when no error occur, or hide the segment if option is set to false +# +set_default POWERLEVEL9K_STATUS_CROSS false +set_default POWERLEVEL9K_STATUS_OK true +set_default POWERLEVEL9K_STATUS_SHOW_PIPESTATUS true +set_default POWERLEVEL9K_STATUS_HIDE_SIGNAME false +# old options, retro compatibility +set_default POWERLEVEL9K_STATUS_VERBOSE true +set_default POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE false + +exit_code_or_status() { + local ec=$1 + if [[ "$POWERLEVEL9K_STATUS_HIDE_SIGNAME" = true ]]; then + echo "$ec" + elif (( ec <= 128 )); then + echo "$ec" + else + local sig=$(( ec - 128 )) + local idx=$(( sig + 1 )) + echo "SIG${signals[$idx]}(${sig})" + fi +} + +prompt_status() { + local ec_text + local ec_sum + local ec + + if [[ $POWERLEVEL9K_STATUS_SHOW_PIPESTATUS == true ]]; then + if (( $#RETVALS > 1 )); then + ec_text=$(exit_code_or_status "${RETVALS[1]}") + ec_sum=${RETVALS[1]} + else + ec_text=$(exit_code_or_status "${RETVAL}") + ec_sum=${RETVAL} + fi + + for ec in "${(@)RETVALS[2,-1]}"; do + ec_text="${ec_text}|$(exit_code_or_status "$ec")" + ec_sum=$(( $ec_sum + $ec )) + done + else + # We use RETVAL instead of the right-most RETVALS item because + # PIPE_FAIL may be set. + ec_text=$(exit_code_or_status "${RETVAL}") + ec_sum=${RETVAL} + fi + + if (( ec_sum > 0 )); then + if [[ "$POWERLEVEL9K_STATUS_CROSS" == false && "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then + "$1_prompt_segment" "$0_ERROR" "$2" "red" "yellow1" "$ec_text" 'CARRIAGE_RETURN_ICON' + else + "$1_prompt_segment" "$0_ERROR" "$2" "$DEFAULT_COLOR" "red" "" 'FAIL_ICON' + fi + elif [[ "$POWERLEVEL9K_STATUS_OK" == true ]] && [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true || "$POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE" == true ]]; then + "$1_prompt_segment" "$0_OK" "$2" "$DEFAULT_COLOR" "green" "" 'OK_ICON' + fi +} + +################################################################ +# Segment to display Swap information +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 +} + +################################################################ +# Segment to display 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" "grey35" "$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() { + set_default POWERLEVEL9K_TIME_FORMAT "%D{%H:%M:%S}" + + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$POWERLEVEL9K_TIME_FORMAT" "TIME_ICON" +} + +################################################################ +# System date +prompt_date() { + set_default POWERLEVEL9K_DATE_FORMAT "%D{%d.%m.%y}" + + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$POWERLEVEL9K_DATE_FORMAT" "DATE_ICON" +} + +################################################################ +# 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" "grey50" "$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 +} + +################################################################ +# Segment to show VCS information +prompt_vcs() { + VCS_WORKDIR_DIRTY=false + VCS_WORKDIR_HALF_DIRTY=false + local 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 + vicmd) + "$1_prompt_segment" "$0_NORMAL" "$2" "$DEFAULT_COLOR" "default" "$POWERLEVEL9K_VI_COMMAND_MODE_STRING" + ;; + main|viins|*) + if [[ -z $POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then return; fi + "$1_prompt_segment" "$0_INSERT" "$2" "$DEFAULT_COLOR" "blue" "$POWERLEVEL9K_VI_INSERT_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) +# https://github.com/pyenv/pyenv#choosing-the-python-version +prompt_pyenv() { + if [[ -n "$PYENV_VERSION" ]]; then + "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON' + fi +} + +################################################################ +# Display openfoam information +prompt_openfoam() { + local wm_project_version="$WM_PROJECT_VERSION" + local wm_fork="$WM_FORK" + if [[ -n "$wm_project_version" ]] && [[ -z "$wm_fork" ]] ; then + "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "OF: $(basename "$wm_project_version")" + elif [[ -n "$wm_project_version" ]] && [[ -n "$wm_fork" ]] ; then + "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "F-X: $(basename "$wm_project_version")" + fi +} + +################################################################ +# Segment to display 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" "yellow1" "" 'LOCK_ICON' + fi +} + +################################################################ +# Kubernetes Current Context/Namespace +prompt_kubecontext() { + local kubectl_version="$(kubectl version --client 2>/dev/null)" + + if [[ -n "$kubectl_version" ]]; then + # Get the current Kuberenetes context + local cur_ctx=$(kubectl config view -o=jsonpath='{.current-context}') + cur_namespace="$(kubectl config view -o=jsonpath="{.contexts[?(@.name==\"${cur_ctx}\")].context.namespace}")" + # If the namespace comes back empty set it default. + if [[ -z "${cur_namespace}" ]]; then + cur_namespace="default" + fi + + local k8s_final_text="" + + if [[ "$cur_ctx" == "$cur_namespace" ]]; then + # No reason to print out the same identificator twice + k8s_final_text="$cur_ctx" + else + k8s_final_text="$cur_ctx/$cur_namespace" + fi + + "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_final_text" "KUBERNETES_ICON" + fi +} + +################################################################ +# Dropbox status +prompt_dropbox() { + # The first column is just the directory, so cut it + local dropbox_status="$(dropbox-cli filestatus . | cut -d\ -f2-)" + + # Only show if the folder is tracked and dropbox is running + if [[ "$dropbox_status" != 'unwatched' && "$dropbox_status" != "isn't running!" ]]; then + # If "up to date", only show the icon + if [[ "$dropbox_status" =~ 'up to date' ]]; then + dropbox_status="" + fi + + "$1_prompt_segment" "$0" "$2" "white" "blue" "$dropbox_status" "DROPBOX_ICON" + fi +} + +# print Java version number +prompt_java_version() { + local java_version + # Stupid: Java prints its version on STDERR. + # The first version ouput will print nothing, we just + # use it to transport whether the command was successful. + # If yes, we parse the version string (and need to + # redirect the stderr to stdout to make the pipe work). + java_version=$(java -version 2>/dev/null && java -fullversion 2>&1 | cut -d '"' -f 2) + + if [[ -n "$java_version" ]]; then + "$1_prompt_segment" "$0" "$2" "red" "white" "$java_version" "JAVA_ICON" + fi +} + +################################################################ +# Prompt processing and drawing +################################################################ +# Main prompt +build_left_prompt() { + local index=1 + local element + 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 + local element + 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 + + # Clear to the end of the line + echo -n "%E" +} + +powerlevel9k_preexec() { + _P9K_TIMER_START=$EPOCHREALTIME +} + +set_default POWERLEVEL9K_PROMPT_ADD_NEWLINE false +powerlevel9k_prepare_prompts() { + local RETVAL RPROMPT_PREFIX RPROMPT_SUFFIX + RETVAL=$? + RETVALS=( "$pipestatus[@]" ) + + _P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START)) + + # Reset start time + _P9K_TIMER_START=0x7FFFFFFF + + if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then + PROMPT='$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt) +$(print_icon 'MULTILINE_LAST_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 + +local NEWLINE=' +' + + if [[ $POWERLEVEL9K_PROMPT_ADD_NEWLINE == true ]]; then + NEWLINES="" + repeat ${POWERLEVEL9K_PROMPT_ADD_NEWLINE_COUNT:-1} { NEWLINES+=$NEWLINE } + PROMPT="$NEWLINES$PROMPT" + fi + + # Allow iTerm integration to work + [[ $ITERM_SHELL_INTEGRATION_INSTALLED == "Yes" ]] && PROMPT="%{$(iterm2_prompt_mark)%}$PROMPT" +} + +zle-keymap-select () { + zle reset-prompt + zle -R +} + +set_default POWERLEVEL9K_IGNORE_TERM_COLORS false +set_default POWERLEVEL9K_IGNORE_TERM_LANG false + +prompt_powerlevel9k_setup() { + # The value below was set to better support 32-bit CPUs. + # It's the maximum _signed_ integer value on 32-bit CPUs. + # Please don't change it until 19 January of 2038. ;) + + # Disable false display of command execution time + _P9K_TIMER_START=0x7FFFFFFF + + # 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=(cr percent sp subst) + + # Borrowed from promptinit, sets the prompt options in case the theme was + # not initialized via promptinit. + setopt noprompt{bang,cr,percent,sp,subst} "prompt${^prompt_opts[@]}" + + # Display a warning if the terminal does not support 256 colors + termColors + + # If the terminal `LANG` is set to `C`, this theme will not work at all. + if [[ $POWERLEVEL9K_IGNORE_TERM_LANG == false ]]; then + 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 + 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 + + zle -N zle-keymap-select +} + +prompt_powerlevel9k_teardown() { + add-zsh-hook -D precmd powerlevel9k_\* + add-zsh-hook -D preexec powerlevel9k_\* + PROMPT='%m%# ' + RPROMPT= +} + +prompt_powerlevel9k_setup "$@" diff --git a/.zprezto/modules/prompt/functions/prompt_powerline_setup b/.zprezto/modules/prompt/functions/prompt_powerline_setup deleted file mode 120000 index 3715d75..0000000 --- a/.zprezto/modules/prompt/functions/prompt_powerline_setup +++ /dev/null @@ -1 +0,0 @@ -../external/powerline/prompt_powerline_setup \ No newline at end of file diff --git a/.zprezto/modules/prompt/functions/prompt_powerline_setup b/.zprezto/modules/prompt/functions/prompt_powerline_setup new file mode 100644 index 0000000..a27b67b --- /dev/null +++ b/.zprezto/modules/prompt/functions/prompt_powerline_setup @@ -0,0 +1,185 @@ +# +# A ZSH theme based on a combination of the skwp prezto theme and the robl ohmyzsh theme. +# * RVM info shown on the right +# * Git branch info on the left +# * Single line prompt +# * Time since last commit on the left +# * Time in place of user@hostname +# +# Authors: +# David Rice + +ZSH_THEME_REP_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}" +ZSH_THEME_REP_TIME_SINCE_COMMIT_MEDIUM="%{$fg[yellow]%}" +ZSH_THEME_REP_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}" +ZSH_THEME_REP_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}" + +# returns the time since last git commit +git_time_details()() { + # only proceed if there is actually a git repository + if $(git rev-parse --git-dir > /dev/null 2>&1); then + # only proceed if there is actually a commit + if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then + # get the last commit hash + # lc_hash=$(git log --pretty=format:'%h' -1 2> /dev/null) + # get the last commit time + lc_time=$(git log --pretty=format:'%at' -1 2> /dev/null) + + now=$(date +%s) + seconds_since_last_commit=$((now-lc_time)) + lc_time_since=$(time_since_commit $seconds_since_last_commit) + + echo "$lc_time_since" + else + echo "" + fi + else + echo "" + fi +} + +# returns the time by given seconds +time_since_commit()() { + seconds_since_last_commit=$(($1 + 0)) + + # totals + MINUTES=$((seconds_since_last_commit / 60)) + HOURS=$((seconds_since_last_commit/3600)) + + # sub-hours and sub-minutes + DAYS=$((seconds_since_last_commit / 86400)) + SUB_HOURS=$((HOURS % 24)) + SUB_MINUTES=$((MINUTES % 60)) + + if [ "$HOURS" -gt 24 ]; then + echo "${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m" + elif [ "$MINUTES" -gt 60 ]; then + echo "${HOURS}h${SUB_MINUTES}m" + else + echo "${MINUTES}m" + fi +} + +rvm_info_for_prompt() { + if [[ -d ~/.rvm/ ]]; then + local ruby_version=$(~/.rvm/bin/rvm-prompt) + if [ -n "$ruby_version" ]; then + echo "$ruby_version" + fi + else + echo "" + fi +} + +prompt_powerline_precmd() { + # Check for untracked files or updated submodules since vcs_info doesn't. + if [[ ! -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then + fmt_branch="%b%u%c${__PROMPT_SKWP_COLORS[4]}●%f" + else + fmt_branch="%b%u%c" + fi + zstyle ':vcs_info:*:prompt:*' formats "${fmt_branch}" + + vcs_info 'prompt' + RVM_PRECMD_INFO=$(rvm_info_for_prompt) + + # zstyle ':prezto:module:ruby' rvm '%r' +} + +prompt_powerline_setup() { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + prompt_opts=(cr percent subst) + + autoload -Uz add-zsh-hook + autoload -Uz vcs_info + + add-zsh-hook precmd prompt_powerline_precmd + + # Use extended color pallete if available. + if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then + __PROMPT_SKWP_COLORS=( + "%F{81}" # turquoise + "%F{166}" # orange + "%F{135}" # purple + "%F{161}" # hotpink + "%F{118}" # limegreen + ) + else + __PROMPT_SKWP_COLORS=( + "%F{cyan}" + "%F{yellow}" + "%F{magenta}" + "%F{red}" + "%F{green}" + ) + fi + + # Enable VCS systems you use. + zstyle ':vcs_info:*' enable bzr git hg svn + + # check-for-changes can be really slow. + # You should disable it if you work with large repositories. + zstyle ':vcs_info:*:prompt:*' check-for-changes true + + # Formats: + # %b - branchname + # %u - unstagedstr (see below) + # %c - stagedstr (see below) + # %a - action (e.g. rebase-i) + # %R - repository path + # %S - path in the repository + # %n - user + # %m - machine hostname + + # local fmt_branch="(${__PROMPT_SKWP_COLORS[1]}%b%f%u%c)" + local fmt_branch="${__PROMPT_SKWP_COLORS[2]}%b%f%u%c" + local fmt_action="${__PROMPT_SKWP_COLORS[5]}%a%f" + local fmt_unstaged="${__PROMPT_SKWP_COLORS[2]}●%f" + local fmt_staged="${__PROMPT_SKWP_COLORS[5]}●%f" + + zstyle ':vcs_info:*:prompt:*' unstagedstr "${fmt_unstaged}" + zstyle ':vcs_info:*:prompt:*' stagedstr "${fmt_staged}" + zstyle ':vcs_info:*:prompt:*' actionformats "${fmt_branch}${fmt_action}" + zstyle ':vcs_info:*:prompt:*' formats "${fmt_branch}" + zstyle ':vcs_info:*:prompt:*' nvcsformats "" + + # SPLIT RVM PROMPT INFO + # TODO: should assign this to local variable? somehow doesn't work correctly. + rvm_split=("${(s/@/)$(rvm_info_for_prompt)}") + + # if [ "$POWERLINE_RIGHT_B" = "" ]; then + # POWERLINE_RIGHT_B=%D{%H:%M:%S} + local powerline_right_b=$rvm_split[1] + # fi + + # if [ "$POWERLINE_RIGHT_A" = "" ]; then + local powerline_right_a=$rvm_split[2] + # fi + + # Setup powerline style colouring + POWERLINE_COLOR_BG_GRAY=%K{240} + POWERLINE_COLOR_BG_LIGHT_GRAY=%K{240} + POWERLINE_COLOR_BG_WHITE=%K{255} + + POWERLINE_COLOR_FG_GRAY=%F{240} + POWERLINE_COLOR_FG_LIGHT_GRAY=%F{240} + POWERLINE_COLOR_FG_WHITE=%F{255} + + POWERLINE_SEPARATOR=$'\uE0B0' + POWERLINE_R_SEPARATOR=$'\uE0B2' + + POWERLINE_LEFT_A="%K{green}%F{white} %~ %k%f%F{green}%K{blue}"$POWERLINE_SEPARATOR + POWERLINE_LEFT_B="%k%f%F{white}%K{blue} "'${vcs_info_msg_0_}'" %k%f%F{blue}%K{black}"$POWERLINE_SEPARATOR + POWERLINE_LEFT_C=" %k%f%F{white}%K{black}"'$(git_time_details)'" %k%f%F{black}"$POWERLINE_SEPARATOR"%f " + + PROMPT=$POWERLINE_LEFT_A$POWERLINE_LEFT_B$POWERLINE_LEFT_C + # RPROMPT=$POWERLINE_COLOR_FG_WHITE$POWERLINE_R_SEPARATOR"%f$POWERLINE_COLOR_BG_WHITE $POWERLINE_COLOR_FG_GRAY$powerline_right_b "$POWERLINE_R_SEPARATOR"%f%k$POWERLINE_COLOR_BG_GRAY$POWERLINE_COLOR_FG_WHITE $powerline_right_a %f%k" + # RPROMPT=$POWERLINE_COLOR_FG_WHITE$POWERLINE_R_SEPARATOR"%f$POWERLINE_COLOR_BG_WHITE $POWERLINE_COLOR_FG_GRAY"'$powerline_right_b'" "$POWERLINE_R_SEPARATOR"%f%k$POWERLINE_COLOR_BG_GRAY$POWERLINE_COLOR_FG_WHITE "'$powerline_right_a'" %f%k" + RPROMPT=$POWERLINE_COLOR_FG_WHITE$POWERLINE_R_SEPARATOR"%f$POWERLINE_COLOR_BG_WHITE $POWERLINE_COLOR_FG_GRAY"'$(rvm_info_for_prompt)'" " +} + +prompt_powerline_setup "$@" + + + diff --git a/.zprezto/modules/prompt/functions/prompt_pure_setup b/.zprezto/modules/prompt/functions/prompt_pure_setup deleted file mode 120000 index 1480fcf..0000000 --- a/.zprezto/modules/prompt/functions/prompt_pure_setup +++ /dev/null @@ -1 +0,0 @@ -../external/pure/pure.zsh \ No newline at end of file diff --git a/.zprezto/modules/prompt/functions/prompt_pure_setup b/.zprezto/modules/prompt/functions/prompt_pure_setup new file mode 100644 index 0000000..2fd19e8 --- /dev/null +++ b/.zprezto/modules/prompt/functions/prompt_pure_setup @@ -0,0 +1,486 @@ +# Pure +# by Sindre Sorhus +# https://github.com/sindresorhus/pure +# MIT License + +# For my own and others sanity +# git: +# %b => current branch +# %a => current action (rebase/merge) +# prompt: +# %F => color dict +# %f => reset color +# %~ => current path +# %* => time +# %n => username +# %m => shortname host +# %(?..) => prompt conditional - %(condition.true.false) +# terminal codes: +# \e7 => save cursor position +# \e[2A => move cursor 2 lines up +# \e[1G => go to position 1 in terminal +# \e8 => restore cursor position +# \e[K => clears everything after the cursor on the current line +# \e[2K => clear everything on the current line + + +# turns seconds into human readable time +# 165392 => 1d 21h 56m 32s +# https://github.com/sindresorhus/pretty-time-zsh +prompt_pure_human_time_to_var() { + local human total_seconds=$1 var=$2 + local days=$(( total_seconds / 60 / 60 / 24 )) + local hours=$(( total_seconds / 60 / 60 % 24 )) + local minutes=$(( total_seconds / 60 % 60 )) + local seconds=$(( total_seconds % 60 )) + (( days > 0 )) && human+="${days}d " + (( hours > 0 )) && human+="${hours}h " + (( minutes > 0 )) && human+="${minutes}m " + human+="${seconds}s" + + # store human readable time in variable as specified by caller + typeset -g "${var}"="${human}" +} + +# stores (into prompt_pure_cmd_exec_time) the exec time of the last command if set threshold was exceeded +prompt_pure_check_cmd_exec_time() { + integer elapsed + (( elapsed = EPOCHSECONDS - ${prompt_pure_cmd_timestamp:-$EPOCHSECONDS} )) + typeset -g prompt_pure_cmd_exec_time= + (( elapsed > ${PURE_CMD_MAX_EXEC_TIME:-5} )) && { + prompt_pure_human_time_to_var $elapsed "prompt_pure_cmd_exec_time" + } +} + +prompt_pure_set_title() { + setopt localoptions noshwordsplit + + # emacs terminal does not support settings the title + (( ${+EMACS} )) && return + + case $TTY in + # Don't set title over serial console. + /dev/ttyS[0-9]*) return;; + esac + + # tell the terminal we are setting the title + print -n '\e]0;' + # show hostname if connected through ssh + [[ -n $SSH_CONNECTION ]] && print -Pn '(%m) ' + case $1 in + expand-prompt) + print -Pn $2;; + ignore-escape) + print -rn $2;; + esac + # end set title + print -n '\a' +} + +prompt_pure_preexec() { + if [[ -n $prompt_pure_git_fetch_pattern ]]; then + # detect when git is performing pull/fetch (including git aliases). + local -H MATCH MBEGIN MEND match mbegin mend + if [[ $2 =~ (git|hub)\ (.*\ )?($prompt_pure_git_fetch_pattern)(\ .*)?$ ]]; then + # we must flush the async jobs to cancel our git fetch in order + # to avoid conflicts with the user issued pull / fetch. + async_flush_jobs 'prompt_pure' + fi + fi + + typeset -g prompt_pure_cmd_timestamp=$EPOCHSECONDS + + # shows the current dir and executed command in the title while a process is active + prompt_pure_set_title 'ignore-escape' "$PWD:t: $2" + + # Disallow python virtualenv from updating the prompt, set it to 12 if + # untouched by the user to indicate that Pure modified it. Here we use + # magic number 12, same as in psvar. + export VIRTUAL_ENV_DISABLE_PROMPT=${VIRTUAL_ENV_DISABLE_PROMPT:-12} +} + +# string length ignoring ansi escapes +prompt_pure_string_length_to_var() { + local str=$1 var=$2 length + # perform expansion on str and check length + length=$(( ${#${(S%%)str//(\%([KF1]|)\{*\}|\%[Bbkf])}} )) + + # store string length in variable as specified by caller + typeset -g "${var}"="${length}" +} + +prompt_pure_preprompt_render() { + setopt localoptions noshwordsplit + + # Set color for git branch/dirty status, change color if dirty checking has + # been delayed. + local git_color=242 + [[ -n ${prompt_pure_git_last_dirty_check_timestamp+x} ]] && git_color=red + + # Initialize the preprompt array. + local -a preprompt_parts + + # Set the path. + preprompt_parts+=('%F{blue}%~%f') + + # Add git branch and dirty status info. + typeset -gA prompt_pure_vcs_info + if [[ -n $prompt_pure_vcs_info[branch] ]]; then + preprompt_parts+=("%F{$git_color}"'${prompt_pure_vcs_info[branch]}${prompt_pure_git_dirty}%f') + fi + # Git pull/push arrows. + if [[ -n $prompt_pure_git_arrows ]]; then + preprompt_parts+=('%F{cyan}${prompt_pure_git_arrows}%f') + fi + + # Username and machine, if applicable. + [[ -n $prompt_pure_username ]] && preprompt_parts+=('$prompt_pure_username') + # Execution time. + [[ -n $prompt_pure_cmd_exec_time ]] && preprompt_parts+=('%F{yellow}${prompt_pure_cmd_exec_time}%f') + + local cleaned_ps1=$PROMPT + local -H MATCH MBEGIN MEND + if [[ $PROMPT = *$prompt_newline* ]]; then + # When the prompt contains newlines, we keep everything before the first + # and after the last newline, leaving us with everything except the + # preprompt. This is needed because some software prefixes the prompt + # (e.g. virtualenv). + cleaned_ps1=${PROMPT%%${prompt_newline}*}${PROMPT##*${prompt_newline}} + fi + unset MATCH MBEGIN MEND + + # Construct the new prompt with a clean preprompt. + local -ah ps1 + ps1=( + $prompt_newline # Initial newline, for spaciousness. + ${(j. .)preprompt_parts} # Join parts, space separated. + $prompt_newline # Separate preprompt and prompt. + $cleaned_ps1 + ) + + PROMPT="${(j..)ps1}" + + # Expand the prompt for future comparision. + local expanded_prompt + expanded_prompt="${(S%%)PROMPT}" + + if [[ $1 != precmd ]] && [[ $prompt_pure_last_prompt != $expanded_prompt ]]; then + # Redraw the prompt. + zle && zle .reset-prompt + fi + + typeset -g prompt_pure_last_prompt=$expanded_prompt +} + +prompt_pure_precmd() { + # check exec time and store it in a variable + prompt_pure_check_cmd_exec_time + unset prompt_pure_cmd_timestamp + + # shows the full path in the title + prompt_pure_set_title 'expand-prompt' '%~' + + # preform async git dirty check and fetch + prompt_pure_async_tasks + + # Check if we should display the virtual env, we use a sufficiently high + # index of psvar (12) here to avoid collisions with user defined entries. + psvar[12]= + # When VIRTUAL_ENV_DISABLE_PROMPT is empty, it was unset by the user and + # Pure should take back control. + if [[ -n $VIRTUAL_ENV ]] && [[ -z $VIRTUAL_ENV_DISABLE_PROMPT || $VIRTUAL_ENV_DISABLE_PROMPT = 12 ]]; then + psvar[12]="${VIRTUAL_ENV:t}" + export VIRTUAL_ENV_DISABLE_PROMPT=12 + fi + + # print the preprompt + prompt_pure_preprompt_render "precmd" +} + +prompt_pure_async_git_aliases() { + setopt localoptions noshwordsplit + local dir=$1 + local -a gitalias pullalias + + # we enter repo to get local aliases as well. + builtin cd -q $dir + + # list all aliases and split on newline. + gitalias=(${(@f)"$(command git config --get-regexp "^alias\.")"}) + for line in $gitalias; do + parts=(${(@)=line}) # split line on spaces + aliasname=${parts[1]#alias.} # grab the name (alias.[name]) + shift parts # remove aliasname + + # check alias for pull or fetch (must be exact match). + if [[ $parts =~ ^(.*\ )?(pull|fetch)(\ .*)?$ ]]; then + pullalias+=($aliasname) + fi + done + + print -- ${(j:|:)pullalias} # join on pipe (for use in regex). +} + +prompt_pure_async_vcs_info() { + setopt localoptions noshwordsplit + builtin cd -q $1 2>/dev/null + + # configure vcs_info inside async task, this frees up vcs_info + # to be used or configured as the user pleases. + zstyle ':vcs_info:*' enable git + zstyle ':vcs_info:*' use-simple true + # only export two msg variables from vcs_info + zstyle ':vcs_info:*' max-exports 2 + # export branch (%b) and git toplevel (%R) + zstyle ':vcs_info:git*' formats '%b' '%R' + zstyle ':vcs_info:git*' actionformats '%b|%a' '%R' + + vcs_info + + local -A info + info[top]=$vcs_info_msg_1_ + info[branch]=$vcs_info_msg_0_ + + print -r - ${(@kvq)info} +} + +# fastest possible way to check if repo is dirty +prompt_pure_async_git_dirty() { + setopt localoptions noshwordsplit + local untracked_dirty=$1 dir=$2 + + # use cd -q to avoid side effects of changing directory, e.g. chpwd hooks + builtin cd -q $dir + + if [[ $untracked_dirty = 0 ]]; then + command git diff --no-ext-diff --quiet --exit-code + else + test -z "$(command git status --porcelain --ignore-submodules -unormal)" + fi + + return $? +} + +prompt_pure_async_git_fetch() { + setopt localoptions noshwordsplit + # use cd -q to avoid side effects of changing directory, e.g. chpwd hooks + builtin cd -q $1 + + # set GIT_TERMINAL_PROMPT=0 to disable auth prompting for git fetch (git 2.3+) + export GIT_TERMINAL_PROMPT=0 + # set ssh BachMode to disable all interactive ssh password prompting + export GIT_SSH_COMMAND=${GIT_SSH_COMMAND:-"ssh -o BatchMode=yes"} + + command git -c gc.auto=0 fetch &>/dev/null || return 99 + + # check arrow status after a successful git fetch + prompt_pure_async_git_arrows $1 +} + +prompt_pure_async_git_arrows() { + setopt localoptions noshwordsplit + builtin cd -q $1 + command git rev-list --left-right --count HEAD...@'{u}' +} + +prompt_pure_async_tasks() { + setopt localoptions noshwordsplit + + # initialize async worker + ((!${prompt_pure_async_init:-0})) && { + async_start_worker "prompt_pure" -u -n + async_register_callback "prompt_pure" prompt_pure_async_callback + typeset -g prompt_pure_async_init=1 + } + + typeset -gA prompt_pure_vcs_info + + local -H MATCH MBEGIN MEND + if ! [[ $PWD = ${prompt_pure_vcs_info[pwd]}* ]]; then + # stop any running async jobs + async_flush_jobs "prompt_pure" + + # reset git preprompt variables, switching working tree + unset prompt_pure_git_dirty + unset prompt_pure_git_last_dirty_check_timestamp + unset prompt_pure_git_arrows + unset prompt_pure_git_fetch_pattern + prompt_pure_vcs_info[branch]= + prompt_pure_vcs_info[top]= + fi + unset MATCH MBEGIN MEND + + async_job "prompt_pure" prompt_pure_async_vcs_info $PWD + + # # only perform tasks inside git working tree + [[ -n $prompt_pure_vcs_info[top] ]] || return + + prompt_pure_async_refresh +} + +prompt_pure_async_refresh() { + setopt localoptions noshwordsplit + + if [[ -z $prompt_pure_git_fetch_pattern ]]; then + # we set the pattern here to avoid redoing the pattern check until the + # working three has changed. pull and fetch are always valid patterns. + typeset -g prompt_pure_git_fetch_pattern="pull|fetch" + async_job "prompt_pure" prompt_pure_async_git_aliases $working_tree + fi + + async_job "prompt_pure" prompt_pure_async_git_arrows $PWD + + # do not preform git fetch if it is disabled or working_tree == HOME + if (( ${PURE_GIT_PULL:-1} )) && [[ $working_tree != $HOME ]]; then + # tell worker to do a git fetch + async_job "prompt_pure" prompt_pure_async_git_fetch $PWD + fi + + # if dirty checking is sufficiently fast, tell worker to check it again, or wait for timeout + integer time_since_last_dirty_check=$(( EPOCHSECONDS - ${prompt_pure_git_last_dirty_check_timestamp:-0} )) + if (( time_since_last_dirty_check > ${PURE_GIT_DELAY_DIRTY_CHECK:-1800} )); then + unset prompt_pure_git_last_dirty_check_timestamp + # check check if there is anything to pull + async_job "prompt_pure" prompt_pure_async_git_dirty ${PURE_GIT_UNTRACKED_DIRTY:-1} $PWD + fi +} + +prompt_pure_check_git_arrows() { + setopt localoptions noshwordsplit + local arrows left=${1:-0} right=${2:-0} + + (( right > 0 )) && arrows+=${PURE_GIT_DOWN_ARROW:-⇣} + (( left > 0 )) && arrows+=${PURE_GIT_UP_ARROW:-⇡} + + [[ -n $arrows ]] || return + typeset -g REPLY=$arrows +} + +prompt_pure_async_callback() { + setopt localoptions noshwordsplit + local job=$1 code=$2 output=$3 exec_time=$4 next_pending=$6 + local do_render=0 + + case $job in + prompt_pure_async_vcs_info) + local -A info + typeset -gA prompt_pure_vcs_info + + # parse output (z) and unquote as array (Q@) + info=("${(Q@)${(z)output}}") + local -H MATCH MBEGIN MEND + # check if git toplevel has changed + if [[ $info[top] = $prompt_pure_vcs_info[top] ]]; then + # if stored pwd is part of $PWD, $PWD is shorter and likelier + # to be toplevel, so we update pwd + if [[ $prompt_pure_vcs_info[pwd] = ${PWD}* ]]; then + prompt_pure_vcs_info[pwd]=$PWD + fi + else + # store $PWD to detect if we (maybe) left the git path + prompt_pure_vcs_info[pwd]=$PWD + fi + unset MATCH MBEGIN MEND + + # update has a git toplevel set which means we just entered a new + # git directory, run the async refresh tasks + [[ -n $info[top] ]] && [[ -z $prompt_pure_vcs_info[top] ]] && prompt_pure_async_refresh + + # always update branch and toplevel + prompt_pure_vcs_info[branch]=$info[branch] + prompt_pure_vcs_info[top]=$info[top] + + do_render=1 + ;; + prompt_pure_async_git_aliases) + if [[ -n $output ]]; then + # append custom git aliases to the predefined ones. + prompt_pure_git_fetch_pattern+="|$output" + fi + ;; + prompt_pure_async_git_dirty) + local prev_dirty=$prompt_pure_git_dirty + if (( code == 0 )); then + unset prompt_pure_git_dirty + else + typeset -g prompt_pure_git_dirty="*" + fi + + [[ $prev_dirty != $prompt_pure_git_dirty ]] && do_render=1 + + # When prompt_pure_git_last_dirty_check_timestamp is set, the git info is displayed in a different color. + # To distinguish between a "fresh" and a "cached" result, the preprompt is rendered before setting this + # variable. Thus, only upon next rendering of the preprompt will the result appear in a different color. + (( $exec_time > 5 )) && prompt_pure_git_last_dirty_check_timestamp=$EPOCHSECONDS + ;; + prompt_pure_async_git_fetch|prompt_pure_async_git_arrows) + # prompt_pure_async_git_fetch executes prompt_pure_async_git_arrows + # after a successful fetch. + if (( code == 0 )); then + local REPLY + prompt_pure_check_git_arrows ${(ps:\t:)output} + if [[ $prompt_pure_git_arrows != $REPLY ]]; then + typeset -g prompt_pure_git_arrows=$REPLY + do_render=1 + fi + elif (( code != 99 )); then + # Unless the exit code is 99, prompt_pure_async_git_arrows + # failed with a non-zero exit status, meaning there is no + # upstream configured. + if [[ -n $prompt_pure_git_arrows ]]; then + unset prompt_pure_git_arrows + do_render=1 + fi + fi + ;; + esac + + if (( next_pending )); then + (( do_render )) && typeset -g prompt_pure_async_render_requested=1 + return + fi + + [[ ${prompt_pure_async_render_requested:-$do_render} = 1 ]] && prompt_pure_preprompt_render + unset prompt_pure_async_render_requested +} + +prompt_pure_setup() { + # Prevent percentage showing up if output doesn't end with a newline. + export PROMPT_EOL_MARK='' + + prompt_opts=(subst percent) + + # borrowed from promptinit, sets the prompt options in case pure was not + # initialized via promptinit. + setopt noprompt{bang,cr,percent,subst} "prompt${^prompt_opts[@]}" + + if [[ -z $prompt_newline ]]; then + # This variable needs to be set, usually set by promptinit. + typeset -g prompt_newline=$'\n%{\r%}' + fi + + zmodload zsh/datetime + zmodload zsh/zle + zmodload zsh/parameter + + autoload -Uz add-zsh-hook + autoload -Uz vcs_info + autoload -Uz async && async + + add-zsh-hook precmd prompt_pure_precmd + add-zsh-hook preexec prompt_pure_preexec + + # show username@host if logged in through SSH + [[ "$SSH_CONNECTION" != '' ]] && prompt_pure_username='%F{242}%n@%m%f' + + # show username@host if root, with username in white + [[ $UID -eq 0 ]] && prompt_pure_username='%F{white}%n%f%F{242}@%m%f' + + # if a virtualenv is activated, display it in grey + PROMPT='%(12V.%F{242}%12v%f .)' + + # prompt turns red if the previous command didn't exit with 0 + PROMPT+='%(?.%F{magenta}.%F{red})${PURE_PROMPT_SYMBOL:-❯}%f ' +} + +prompt_pure_setup "$@" diff --git a/.zprezto/modules/prompt/functions/prompt_skwp_setup b/.zprezto/modules/prompt/functions/prompt_skwp_setup index 1c8f0a9..f69dcdd 100644 --- a/.zprezto/modules/prompt/functions/prompt_skwp_setup +++ b/.zprezto/modules/prompt/functions/prompt_skwp_setup @@ -28,7 +28,7 @@ function prompt_skwp_precmd { function prompt_skwp_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS - prompt_opts=(cr percent subst) + prompt_opts=(cr percent sp subst) # Load required functions. autoload -Uz add-zsh-hook diff --git a/.zprezto/modules/prompt/functions/prompt_smiley_setup b/.zprezto/modules/prompt/functions/prompt_smiley_setup index 3066a2d..3d41b3a 100644 --- a/.zprezto/modules/prompt/functions/prompt_smiley_setup +++ b/.zprezto/modules/prompt/functions/prompt_smiley_setup @@ -36,7 +36,7 @@ function prompt_smiley_precmd { function prompt_smiley_setup { unsetopt XTRACE KSH_ARRAYS - prompt_opts=(percent subst) + prompt_opts=(cr percent sp subst) # Add hook for calling git-info before each command. add-zsh-hook precmd prompt_smiley_precmd diff --git a/.zprezto/modules/prompt/functions/prompt_sorin_setup b/.zprezto/modules/prompt/functions/prompt_sorin_setup index e339dff..30e71a9 100644 --- a/.zprezto/modules/prompt/functions/prompt_sorin_setup +++ b/.zprezto/modules/prompt/functions/prompt_sorin_setup @@ -32,44 +32,53 @@ # Load dependencies. pmodload 'helper' -function prompt_sorin_pwd { - local pwd="${PWD/#$HOME/~}" +function prompt_sorin_async_callback { + case $1 in + prompt_sorin_async_git) + # We can safely split on ':' because it isn't allowed in ref names. + IFS=':' read _git_target _git_post_target <<<"$3" - if [[ "$pwd" == (#m)[/~] ]]; then - _prompt_sorin_pwd="$MATCH" - unset MATCH - else - _prompt_sorin_pwd="${${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}//\%/%%}/${${pwd:t}//\%/%%}" - fi + # The target actually contains 3 space separated possibilities, so we need to + # make sure we grab the first one. + _git_target=$(coalesce ${(@)${(z)_git_target}}) + + if [[ -z "$_git_target" ]]; then + # No git target detected, flush the git fragment and redisplay the prompt. + if [[ -n "$_prompt_sorin_git" ]]; then + _prompt_sorin_git='' + zle && zle reset-prompt + fi + else + # Git target detected, update the git fragment and redisplay the prompt. + _prompt_sorin_git="${_git_target}${_git_post_target}" + zle && zle reset-prompt + fi + ;; + esac } -function prompt_sorin_git_info { - if (( _prompt_sorin_precmd_async_pid > 0 )); then - # Append Git status. - if [[ -s "$_prompt_sorin_precmd_async_data" ]]; then - alias typeset='typeset -g' - source "$_prompt_sorin_precmd_async_data" - RPROMPT+='${git_info:+${(e)git_info[status]}}' - unalias typeset - fi - - # Reset PID. - _prompt_sorin_precmd_async_pid=0 - - # Redisplay prompt. - zle && zle reset-prompt - fi -} - -function prompt_sorin_precmd_async { - # Get Git repository information. +function prompt_sorin_async_git { + cd -q "$1" if (( $+functions[git-info] )); then git-info - typeset -p git_info >! "$_prompt_sorin_precmd_async_data" + print ${git_info[status]} + fi +} + +function prompt_sorin_async_tasks { + # Initialize async worker. This needs to be done here and not in + # prompt_sorin_setup so the git formatting can be overridden by other prompts. + if (( !${prompt_prezto_async_init:-0} )); then + async_start_worker prompt_sorin -n + async_register_callback prompt_sorin prompt_sorin_async_callback + typeset -g prompt_prezto_async_init=1 fi - # Signal completion to parent process. - kill -WINCH $$ + # Kill the old process of slow commands if it is still running. + async_flush_jobs prompt_sorin + + # Compute slow commands in the background. + async_job prompt_sorin prompt_sorin_async_git "$PWD" } function prompt_sorin_precmd { @@ -77,31 +86,36 @@ function prompt_sorin_precmd { unsetopt XTRACE KSH_ARRAYS # Format PWD. - prompt_sorin_pwd + _prompt_sorin_pwd=$(prompt-pwd) - # Define prompts. - RPROMPT='${editor_info[overwrite]}%(?:: %F{1}⏎%f)${VIM:+" %B%F{6}V%f%b"}' - - # Kill the old process of slow commands if it is still running. - if (( _prompt_sorin_precmd_async_pid > 0 )); then - kill -KILL "$_prompt_sorin_precmd_async_pid" &>/dev/null + # Handle updating git data. We also clear the git prompt data if we're in a + # different git root now. + if (( $+functions[git-dir] )); then + local new_git_root="$(git-dir 2> /dev/null)" + if [[ $new_git_root != $_sorin_cur_git_root ]]; then + _prompt_sorin_git='' + _sorin_cur_git_root=$new_git_root + fi fi - # Compute slow commands in the background. - trap prompt_sorin_git_info WINCH - prompt_sorin_precmd_async &! - _prompt_sorin_precmd_async_pid=$! + # Run python info (this should be fast and not require any async) + if (( $+functions[python-info] )); then + python-info + fi + + prompt_sorin_async_tasks } function prompt_sorin_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS - prompt_opts=(cr percent subst) + prompt_opts=(cr percent sp subst) _prompt_sorin_precmd_async_pid=0 - _prompt_sorin_precmd_async_data="${TMPPREFIX}-prompt_sorin_data" + _prompt_sorin_precmd_async_data=$(mktemp "${TMPDIR:-/tmp}/sorin-prompt-async-XXXXXXXXXX") # Load required functions. autoload -Uz add-zsh-hook + autoload -Uz async && async # Add hook for calling git-info before each command. add-zsh-hook precmd prompt_sorin_precmd @@ -128,11 +142,28 @@ function prompt_sorin_setup { zstyle ':prezto:module:git:info:unmerged' format ' %%B%F{3}═%f%%b' zstyle ':prezto:module:git:info:untracked' format ' %%B%F{7}◼%f%%b' zstyle ':prezto:module:git:info:keys' format \ - 'status' '$(coalesce "%b" "%p" "%c")%s%A%B%S%a%d%m%r%U%u' + 'status' '%b %p %c:%s%A%B%S%a%d%m%r%U%u' + + # Set up non-zero return value display + local show_return="✘ " + # Default is to show the return value + if zstyle -T ':prezto:module:prompt' show-return-val; then + show_return+='%? ' + fi + # Set python-info format + zstyle ':prezto:module:python:info:virtualenv' format '%f%F{3}(%v)%F{7} ' + + # Get the async worker set up + _sorin_cur_git_root='' + + _prompt_sorin_git='' + _prompt_sorin_pwd='' # Define prompts. PROMPT='${SSH_TTY:+"%F{9}%n%f%F{7}@%f%F{3}%m%f "}%F{4}${_prompt_sorin_pwd}%(!. %B%F{1}#%f%b.)${editor_info[keymap]} ' - RPROMPT='' + RPROMPT='$python_info[virtualenv]${editor_info[overwrite]}%(?:: %F{1}' + RPROMPT+=${show_return} + RPROMPT+='%f)${VIM:+" %B%F{6}V%f%b"}${_prompt_sorin_git}' SPROMPT='zsh: correct %F{1}%R%f to %F{2}%r%f [nyae]? ' } @@ -141,7 +172,7 @@ function prompt_sorin_preview { local +h RPROMPT='' local +h SPROMPT='' - editor-info 2>/dev/null + editor-info 2> /dev/null prompt_preview_theme 'sorin' } diff --git a/.zprezto/modules/prompt/functions/prompt_steeef_setup b/.zprezto/modules/prompt/functions/prompt_steeef_setup index 996331f..b241f9a 100644 --- a/.zprezto/modules/prompt/functions/prompt_steeef_setup +++ b/.zprezto/modules/prompt/functions/prompt_steeef_setup @@ -32,7 +32,7 @@ function prompt_steeef_precmd { function prompt_steeef_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS - prompt_opts=(cr percent subst) + prompt_opts=(cr percent sp subst) # Load required functions. autoload -Uz add-zsh-hook diff --git a/.zprezto/modules/python/README.md b/.zprezto/modules/python/README.md index d9497d6..e7b72c4 100644 --- a/.zprezto/modules/python/README.md +++ b/.zprezto/modules/python/README.md @@ -3,6 +3,23 @@ Python Enables local Python and local Python package installation. +Settings +-------- + +This module supports virtual environments from conda and virtualenvwrapper. By default, only virtualenvwrapper is enabled. To disable virtualenvwrapper, add the following to *zpreztorc*. + +```sh +zstyle ':prezto:module:python' skip-virtualenvwrapper-init 'on' +``` + +Conda support is enabled by adding the following to *zpreztorc*. + +```sh +zstyle ':prezto:module:python' conda-init 'on' +``` + +Caution: using conda and virtualenvwrapper at the same time may cause conflicts. + Local Python Installation ------------------------- @@ -14,7 +31,7 @@ execution of `pyenv`. ### Usage -Install Python versions with `pyenv install` into *~/.pyenv/versions*. +Install Python versions with `pyenv install` into `~/.pyenv/versions`. Local Package Installation -------------------------- @@ -28,43 +45,81 @@ documentation. ### Usage -Install packages into the per user site directory with `easy_install --user` or -`pip install --user`. +Install packages into the per user site directory with `pip install --user`. virtualenvwrapper ----------------- -[virtualenvwrapper][2] is a frontend to the popular [virtualenv][3] utility. +[`virtualenvwrapper`][2] is a frontend to the popular [`virtualenv`][3] utility. -virtualenv creates isolated Python environments and virtualenvwrapper provides +`virtualenv` creates isolated Python environments and `virtualenvwrapper` provides convenient shell functions to create, switch, and manage them. ### Usage -Install virtualenvwrapper. +Install `virtualenvwrapper`. -Virtual environments are stored in *~/.virtualenvs*. +Virtual environments are stored in `~/.virtualenvs`. There are configuration variables that have to be set to enable certain features. -If you wish to use these features, export the variables in *~/.zshenv* +If you wish to use these features, export the variables in [`zshenv`][6]. -The variable `$PROJECT_HOME` tells virtualenvwrapper where to place project +The variable `$PROJECT_HOME` tells `virtualenvwrapper` where to place project working directories. It must be set and the directory created before `mkproject` is used. Replace *Developer* with your projects directory. - export PROJECT_HOME="$HOME/Developer" +```sh +export PROJECT_HOME="$HOME/Developer" +``` -The variable `$VIRTUALENVWRAPPER_VIRTUALENV_ARGS` tells virtualenvwrapper what +The variable `VIRTUALENVWRAPPER_PYTHON` tells `virtualenvwrapper` to use the +specified full path of the `python` interpreter overriding the `$PATH` search. + +```sh +export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python +``` + +The variable `VIRTUALENVWRAPPER_VIRTUALENV` tells `virtualenvwrapper` to use the +specified full path of `virtualenv` binary overriding the `$PATH` search. + +```sh +export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv +``` + +The variable `$VIRTUALENVWRAPPER_VIRTUALENV_ARGS` tells `virtualenvwrapper` what arguments to pass to `virtualenv`. For example, set the value to -*--no-site-packages* to ensure that all new environments are isolated from the +`--system-site-packages` to ensure that all new environments have access to the system site-packages directory. - export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages' +```sh +export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--system-site-packages' +``` + +### Additional Options + +There is a hook to enable auto-switching to virtualenvs when switching into a +directory where the root of the project matches a virtualenv name. + +This can be enabled with: + +```sh +zstyle ':prezto:module:python:virtualenv' auto-switch 'yes' +``` + +`virtualenvwrapper` is automatically initialized if pre-requisites are met +(`$VIRTUALENVWRAPPER_VIRTUALENV` is explicitly set or `virtualenv` is in +`$PATH`). This can be disabled with: + +```sh +zstyle ':prezto:module:python:virtualenv' initialize 'no' +``` Aliases ------- - `py` is short for `python`. + - `py2` is short for `python2`. + - `py3` is short for `python3`. Functions --------- @@ -84,6 +139,10 @@ following style in the `prompt_name_setup` function. Then add `$python_info[virtualenv]` to `$PROMPT` or `$RPROMPT` and call `python-info` in the `prompt_name_preexec` hook function. +Similarly, you can use `:prezto:module:python:info:version:format` with `%v` for +the version and add `$python_info[version]` to your prompt for the current +python version/ + Authors ------- @@ -97,3 +156,4 @@ Authors [3]: http://pypi.python.org/pypi/virtualenv [4]: https://github.com/yyuu/pyenv [5]: https://github.com/sorin-ionescu/prezto/issues +[6]: https://github.com/sorin-ionescu/prezto/blob/master/runcoms/zshenv diff --git a/.zprezto/modules/python/functions/python-info b/.zprezto/modules/python/functions/python-info index 6a8c758..144a5b6 100644 --- a/.zprezto/modules/python/functions/python-info +++ b/.zprezto/modules/python/functions/python-info @@ -4,18 +4,50 @@ # # Authors: # Sorin Ionescu +# Patrick Bos # +# function python-info { + local virtualenv_format local virtualenv_formatted +local version_format +local version_formatted +local version # Clean up previous $python_info. unset python_info typeset -gA python_info +# Grab the styling we might have to do +zstyle -s ':prezto:module:python:info:virtualenv' format 'virtualenv_format' +zstyle -s ':prezto:module:python:info:version' format 'version_format' + # Format virtualenv. -if [[ -n "$VIRTUAL_ENV" ]]; then - zstyle -s ':prezto:module:python:info:virtualenv' format 'virtualenv_format' - zformat -f virtualenv_formatted "$virtualenv_format" "v:${VIRTUAL_ENV:t}" - python_info[virtualenv]="$virtualenv_formatted" +if [[ -n "$virtualenv_format" ]]; then + if [[ -n "$VIRTUAL_ENV" ]]; then + zformat -f virtualenv_formatted "$virtualenv_format" "v:${VIRTUAL_ENV:t}" + python_info[virtualenv]="$virtualenv_formatted" + fi + + # Do the same for Conda virtual environments + if [[ -n "$CONDA_DEFAULT_ENV" ]]; then + zformat -f virtualenv_formatted "$virtualenv_format" "v:${CONDA_DEFAULT_ENV:t}" + python_info[virtualenv]="$virtualenv_formatted" + fi fi + +if [[ -n "$version_format" ]]; then + if (( $+commands[pyenv] )); then + version="${"$(pyenv version)"%% *}" + elif (( $+commands[python] )); then + version="${$(python3 --version)#Python }" + fi + + if [[ -n "$version" && "$version" != "system" ]]; then + zformat -f version_formatted "$version_format" "v:$version" + python_info[version]="$version_formatted" + fi +fi + +# } diff --git a/.zprezto/modules/python/init.zsh b/.zprezto/modules/python/init.zsh index da78ea7..28f671e 100644 --- a/.zprezto/modules/python/init.zsh +++ b/.zprezto/modules/python/init.zsh @@ -4,19 +4,22 @@ # Authors: # Sorin Ionescu # Sebastian Wiesner +# Patrick Bos # # Load manually installed pyenv into the shell session. if [[ -s "$HOME/.pyenv/bin/pyenv" ]]; then path=("$HOME/.pyenv/bin" $path) - eval "$(pyenv init -)" + export PYENV_ROOT=$(pyenv root) + eval "$(pyenv init - --no-rehash zsh)" # Load package manager installed pyenv into the shell session. elif (( $+commands[pyenv] )); then - eval "$(pyenv init -)" + export PYENV_ROOT=$(pyenv root) + eval "$(pyenv init - --no-rehash zsh)" # Prepend PEP 370 per user site packages directory, which defaults to -# ~/Library/Python on Mac OS X and ~/.local elsewhere, to PATH. The +# ~/Library/Python on macOS and ~/.local elsewhere, to PATH. The # path can be overridden using PYTHONUSERBASE. else if [[ -n "$PYTHONUSERBASE" ]]; then @@ -34,15 +37,141 @@ if (( ! $+commands[python] && ! $+commands[pyenv] )); then return 1 fi -# Load virtualenvwrapper into the shell session. -if (( $+commands[virtualenvwrapper.sh] )); then +function _python-workon-cwd { + # Check if this is a Git repo + local GIT_REPO_ROOT="" + local GIT_TOPLEVEL="$(git rev-parse --show-toplevel 2> /dev/null)" + if [[ $? == 0 ]]; then + GIT_REPO_ROOT="$GIT_TOPLEVEL" + fi + # Get absolute path, resolving symlinks + local PROJECT_ROOT="${PWD:A}" + while [[ "$PROJECT_ROOT" != "/" && ! -e "$PROJECT_ROOT/.venv" \ + && ! -d "$PROJECT_ROOT/.git" && "$PROJECT_ROOT" != "$GIT_REPO_ROOT" ]]; do + PROJECT_ROOT="${PROJECT_ROOT:h}" + done + if [[ "$PROJECT_ROOT" == "/" ]]; then + PROJECT_ROOT="." + fi + # Check for virtualenv name override + local ENV_NAME="" + if [[ -f "$PROJECT_ROOT/.venv" ]]; then + ENV_NAME="$(cat "$PROJECT_ROOT/.venv")" + elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then + ENV_NAME="$PROJECT_ROOT/.venv" + elif [[ "$PROJECT_ROOT" != "." ]]; then + ENV_NAME="${PROJECT_ROOT:t}" + fi + if [[ -n $CD_VIRTUAL_ENV && "$ENV_NAME" != "$CD_VIRTUAL_ENV" ]]; then + # We've just left the repo, deactivate the environment + # Note: this only happens if the virtualenv was activated automatically + deactivate && unset CD_VIRTUAL_ENV + fi + if [[ "$ENV_NAME" != "" ]]; then + # Activate the environment only if it is not already active + if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then + if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then + workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME" + elif [[ -e "$ENV_NAME/bin/activate" ]]; then + source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME" + fi + fi + fi +} + +# Load auto workon cwd hook +if zstyle -t ':prezto:module:python:virtualenv' auto-switch 'yes'; then + # Auto workon when changing directory + autoload -Uz add-zsh-hook + add-zsh-hook chpwd _python-workon-cwd +fi + +# Load virtualenvwrapper into the shell session, if pre-requisites are met +# and unless explicitly requested not to +if (( $+VIRTUALENVWRAPPER_VIRTUALENV || $+commands[virtualenv] )) && \ + zstyle -T ':prezto:module:python:virtualenv' initialize ; then # Set the directory where virtual environments are stored. - export WORKON_HOME="$HOME/.virtualenvs" + export WORKON_HOME="${WORKON_HOME:-$HOME/.virtualenvs}" # Disable the virtualenv prompt. - VIRTUAL_ENV_DISABLE_PROMPT=1 + export VIRTUAL_ENV_DISABLE_PROMPT=1 - source "$commands[virtualenvwrapper.sh]" + # Create a sorted array of available virtualenv related 'pyenv' commands to + # look for plugins of interest. Scanning shell '$path' isn't enough as they + # can exist in 'pyenv' synthesized paths (e.g., '~/.pyenv/plugins') instead. + local -a pyenv_plugins + if (( $+commands[pyenv] )); then + pyenv_plugins=(${(@oM)${(f)"$(pyenv commands --no-sh 2>/dev/null)"}:#virtualenv*}) + fi + + if (( $pyenv_plugins[(i)virtualenv-init] <= $#pyenv_plugins )); then + # Enable 'virtualenv' with 'pyenv'. + eval "$(pyenv virtualenv-init - zsh)" + + # Optionally activate 'virtualenvwrapper' plugin when available. + if (( $pyenv_plugins[(i)virtualenvwrapper(_lazy|)] <= $#pyenv_plugins )); then + pyenv "$pyenv_plugins[(R)virtualenvwrapper(_lazy|)]" + fi + else + # Fallback to 'virtualenvwrapper' without 'pyenv' wrapper if available + # in '$path' or in an alternative location on a Debian based system. + # + # If homebrew is installed and the python location wasn't overridden via + # environment variable we fall back to python3 then python2 in that order. + # This is needed to fix an issue with virtualenvwrapper as homebrew no + # longer shadows the system python. + if [[ -z "$VIRTUALENVWRAPPER_PYTHON" ]] && (( $+commands[brew] )); then + if (( $+commands[python3] )); then + export VIRTUALENVWRAPPER_PYTHON=$commands[python3] + elif (( $+commands[python2] )); then + export VIRTUALENVWRAPPER_PYTHON=$commands[python2] + fi + fi + + virtenv_sources=( + ${(@Ov)commands[(I)virtualenvwrapper(_lazy|).sh]} + /usr/share/virtualenvwrapper/virtualenvwrapper(_lazy|).sh(OnN) + ) + if (( $#virtenv_sources )); then + source "${virtenv_sources[1]}" + fi + + unset virtenv_sources + fi + + unset pyenv_plugins +fi + +# Load PIP completion. +if (( $#commands[(i)pip(|[23])] )); then + cache_file="${TMPDIR:-/tmp}/prezto-python-cache.$UID.zsh" + + # Detect and use one available from among 'pip', 'pip2', 'pip3' variants + pip_command="$commands[(i)pip(|[23])]" + + if [[ "$pip_command" -nt "$cache_file" \ + || "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" \ + || ! -s "$cache_file" ]]; then + # pip is slow; cache its output. And also support 'pip2', 'pip3' variants + $pip_command completion --zsh \ + | sed -e "s|compctl -K [-_[:alnum:]]* pip|& pip2 pip3|" >! "$cache_file" 2> /dev/null + fi + + source "$cache_file" + unset cache_file pip_command +fi + +# Load conda into the shell session, if requested +zstyle -T ':prezto:module:python' conda-init +if (( $? && $+commands[conda] )); then + if (( $(conda ..changeps1) )); then + echo "To make sure Conda doesn't change your prompt (should do that in the prompt module) run:\n conda config --set changeps1 false" + # TODO: + # We could just run this ourselves. In an exit hook + # (add zsh-hook zshexit [(anonymous) function]) we could then set it back + # to the way it was before we changed it. However, I'm not sure if this is + # exception safe, so left it like this for now. + fi fi # @@ -50,3 +179,5 @@ fi # alias py='python' +alias py2='python2' +alias py3='python3' diff --git a/.zprezto/modules/rsync/README.md b/.zprezto/modules/rsync/README.md index 951e3c6..77d78ea 100644 --- a/.zprezto/modules/rsync/README.md +++ b/.zprezto/modules/rsync/README.md @@ -3,7 +3,7 @@ Rsync Defines [rsync][1] aliases. -Mac OS X users are encouraged to use [Bombich's rsync][2], which has HFS+ +macOS users are encouraged to use [Bombich's rsync][2], which has HFS+ enhancements. Aliases @@ -23,5 +23,5 @@ Authors - [Sorin Ionescu](https://github.com/sorin-ionescu) [1]: http://rsync.samba.org -[2]: http://help.bombich.com/kb/overview/credits#opensource +[2]: https://bombich.com/kb/ccc5/credits#rsync [3]: https://github.com/sorin-ionescu/prezto/issues diff --git a/.zprezto/modules/rsync/init.zsh b/.zprezto/modules/rsync/init.zsh index 3afebdb..a802222 100644 --- a/.zprezto/modules/rsync/init.zsh +++ b/.zprezto/modules/rsync/init.zsh @@ -20,7 +20,7 @@ if grep -q 'xattrs' <(rsync --help 2>&1); then _rsync_cmd="${_rsync_cmd} --acls --xattrs" fi -# Mac OS X and HFS+ Enhancements +# macOS and HFS+ Enhancements # http://help.bombich.com/kb/overview/credits#opensource if [[ "$OSTYPE" == darwin* ]] && grep -q 'file-flags' <(rsync --help 2>&1); then _rsync_cmd="${_rsync_cmd} --crtimes --fileflags --protect-decmpfs --force-change" diff --git a/.zprezto/modules/ruby/README.md b/.zprezto/modules/ruby/README.md index 1c955f5..12848d8 100644 --- a/.zprezto/modules/ruby/README.md +++ b/.zprezto/modules/ruby/README.md @@ -8,7 +8,7 @@ Local Gem Installation ---------------------- When a Ruby version manager is not detected, local gems are installed in -*~/.gems*; otherwise, they are installed according to the manager. +`~/.gems`; otherwise, they are installed according to the manager. RVM --- @@ -35,7 +35,7 @@ not known to cause conflicts with shell scripts. chruby ------ -Yet another alternative is [chruby][6], which is simpler than both RVM and +Yet another alternative is [chruby][4], which is simpler than both RVM and rbenv. ### Settings @@ -43,15 +43,17 @@ rbenv. #### Auto-Switch To enable auto switching the Ruby version on directory change based on the -.ruby-version file, add the following line to *zpreztorc*: +`.ruby-version` file, add the following line to [`zpreztorc`][5]: - zstyle ':prezto:module:ruby:chruby' auto-switch 'yes' +```sh +zstyle ':prezto:module:ruby:chruby' auto-switch 'yes' +``` Bundler ------- Manage gems that are not meant to be used as commands, such as application -dependencies, with [Bundler][4]. +dependencies, with [Bundler][6]. Aliases ------- @@ -63,15 +65,16 @@ Aliases ### Bundler - `rbb` manages ruby dependencies (`bundle`). + - `rbbc` cleans up unused gems in your bundler directory. - `rbbe` executes a script in the context of the current bundle. - - `rbbi` installs the gems specified in the *Gemfile* in *vendor/bundle*. + - `rbbi` installs the gems specified in the `Gemfile` in `vendor/bundle`. - `rbbI` installs the following: - - gems specified in the *Gemfile* in *vendor/bundle*. - - packages the gems into *vendor/cache*. - - appends bundler directories to *.gitignore*. + - gems specified in the `Gemfile` in `vendor/bundle`. + - packages the gems into `vendor/cache`. + - appends bundler directories to `.gitignore`. - `rbbl` lists all gems in the current bundle. - `rbbo` opens an installed gem in the editor. - - `rbbp` packages gem files into *vendor/cache*. + - `rbbp` packages gem files into `vendor/cache`. - `rbbu` updates gems to their latest version. Functions @@ -96,13 +99,14 @@ Then add `$ruby_info[version]` to `$PROMPT` or `$RPROMPT` and call Authors ------- -*The authors of this module should be contacted via the [issue tracker][5].* +*The authors of this module should be contacted via the [issue tracker][7].* - [Sorin Ionescu](https://github.com/sorin-ionescu) [1]: http://www.ruby-lang.org [2]: https://rvm.io [3]: https://github.com/sstephenson/rbenv -[4]: http://gembundler.com -[5]: https://github.com/sorin-ionescu/prezto/issues -[6]: https://github.com/postmodern/chruby +[4]: https://github.com/postmodern/chruby +[5]: https://github.com/sorin-ionescu/prezto/blob/master/runcoms/zpreztorc +[6]: http://gembundler.com +[7]: https://github.com/sorin-ionescu/prezto/issues diff --git a/.zprezto/modules/ruby/functions/ruby-app-root b/.zprezto/modules/ruby/functions/ruby-app-root index ea35be6..ef28c5b 100644 --- a/.zprezto/modules/ruby/functions/ruby-app-root +++ b/.zprezto/modules/ruby/functions/ruby-app-root @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function ruby-app-root { + local root_dir="$PWD" while [[ "$root_dir" != '/' ]]; do @@ -16,3 +18,5 @@ while [[ "$root_dir" != '/' ]]; do done return 1 + +# } diff --git a/.zprezto/modules/ruby/functions/ruby-info b/.zprezto/modules/ruby/functions/ruby-info index ebf0f7f..cba0188 100644 --- a/.zprezto/modules/ruby/functions/ruby-info +++ b/.zprezto/modules/ruby/functions/ruby-info @@ -6,6 +6,8 @@ # Sorin Ionescu # +# function ruby-info { + local version local version_format local version_formatted @@ -14,17 +16,23 @@ local version_formatted unset ruby_info typeset -gA ruby_info -if (( $+commands[rvm-prompt] )); then - version="$(rvm-prompt)" -elif (( $+commands[rbenv] )); then - version="$(rbenv version-name)" -elif (( $+commands[ruby] )); then - version="${${$(ruby --version)[(w)1,(w)2]}/ /-}" +# Grab formatting for anything we might have to do +zstyle -s ':prezto:module:ruby:info:version' format 'version_format' + +if [[ -n "$version_format" ]]; then + if (( $+commands[rvm-prompt] )); then + version="$(rvm-prompt)" + elif (( $+commands[rbenv] )); then + version="$(rbenv version-name)" + elif (( $+commands[ruby] )); then + version="${${$(ruby --version)[(w)1,(w)2]}/ /-}" + fi + + # Format version. + if [[ -n "$version" && "$version" != "system" ]]; then + zformat -f version_formatted "$version_format" "v:$version" + ruby_info[version]="$version_formatted" + fi fi -# Format version. -if [[ -n "$version" ]]; then - zstyle -s ':prezto:module:ruby:info:version' format 'version_format' - zformat -f version_formatted "$version_format" "v:$version" - ruby_info[version]="$version_formatted" -fi +# } diff --git a/.zprezto/modules/ruby/init.zsh b/.zprezto/modules/ruby/init.zsh index fd707d0..4ede366 100644 --- a/.zprezto/modules/ruby/init.zsh +++ b/.zprezto/modules/ruby/init.zsh @@ -25,9 +25,14 @@ elif (( $+commands[rbenv] )); then # Load package manager installed chruby into the shell session. elif (( $+commands[chruby-exec] )); then - source "${commands[chruby-exec]:h:h}/share/chruby/chruby.sh" + if (( ! $+functions[chruby] )); then + source "${commands[chruby-exec]:h:h}/share/chruby/chruby.sh" + fi + if zstyle -t ':prezto:module:ruby:chruby' auto-switch; then - source "${commands[chruby-exec]:h:h}/share/chruby/auto.sh" + if (( ! $+functions[chruby_auto] )); then + source "${commands[chruby-exec]:h:h}/share/chruby/auto.sh" + fi # If a default Ruby is set, switch to it. chruby_auto @@ -53,6 +58,7 @@ alias rb='ruby' # Bundler if (( $+commands[bundle] )); then alias rbb='bundle' + alias rbbc='bundle clean' alias rbbe='bundle exec' alias rbbi='bundle install --path vendor/bundle' alias rbbl='bundle list' diff --git a/.zprezto/modules/screen/README.md b/.zprezto/modules/screen/README.md index ef96404..0a9ff07 100644 --- a/.zprezto/modules/screen/README.md +++ b/.zprezto/modules/screen/README.md @@ -13,12 +13,16 @@ Starts a GNU Screen session automatically when Zsh is launched. To enable this feature when launching Zsh in a local terminal, add the following line to *zpreztorc*: - zstyle ':prezto:module:screen:auto-start' local 'yes' +```sh +zstyle ':prezto:module:screen:auto-start' local 'yes' +``` To enable this feature when launching Zsh in a SSH connection, add the following line to *zpreztorc*: - zstyle ':prezto:module:screen:auto-start' remote 'yes' +```sh +zstyle ':prezto:module:screen:auto-start' remote 'yes' +``` Aliases ------- diff --git a/.zprezto/modules/ssh/README.md b/.zprezto/modules/ssh/README.md index 7324ae9..a1727b9 100644 --- a/.zprezto/modules/ssh/README.md +++ b/.zprezto/modules/ssh/README.md @@ -3,10 +3,6 @@ SSH Provides for an easier use of [SSH][1] by setting up [ssh-agent][2]. -This module is disabled on Mac OS X due to custom Apple SSH support rendering it -unnecessary. Use `ssh-add -K` to store identities in Keychain; they will be -added to `ssh-agent` automatically and persist between reboots. - Settings -------- @@ -14,7 +10,9 @@ Settings To load multiple identities, add the following line to *zpreztorc*: - zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_dsa' 'id_github' +```sh +zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_dsa' 'id_github' +``` Authors ------- diff --git a/.zprezto/modules/ssh/init.zsh b/.zprezto/modules/ssh/init.zsh index efc45b5..08edce5 100644 --- a/.zprezto/modules/ssh/init.zsh +++ b/.zprezto/modules/ssh/init.zsh @@ -6,7 +6,7 @@ # # Return if requirements are not found. -if [[ "$OSTYPE" == darwin* ]] || (( ! $+commands[ssh-agent] )); then +if (( ! $+commands[ssh-agent] )); then return 1 fi @@ -14,10 +14,10 @@ fi _ssh_dir="$HOME/.ssh" # Set the path to the environment file if not set by another module. -_ssh_agent_env="${_ssh_agent_env:-${TMPDIR:-/tmp}/ssh-agent.env}" +_ssh_agent_env="${_ssh_agent_env:-${TMPDIR:-/tmp}/ssh-agent.env.$UID}" # Set the path to the persistent authentication socket. -_ssh_agent_sock="${TMPDIR:-/tmp}/ssh-agent.sock" +_ssh_agent_sock="${TMPDIR:-/tmp}/ssh-agent.sock.$UID" # Start ssh-agent if not started. if [[ ! -S "$SSH_AUTH_SOCK" ]]; then @@ -25,10 +25,8 @@ if [[ ! -S "$SSH_AUTH_SOCK" ]]; then source "$_ssh_agent_env" 2> /dev/null # Start ssh-agent if not started. - if [[ -z $SSH_CLIENT ]]; then - if ! ps -U "$LOGNAME" -o pid,ucomm | grep -q -- "${SSH_AGENT_PID:--1} ssh-agent"; then - eval "$(ssh-agent | sed '/^echo /d' | tee "$_ssh_agent_env")" - fi + if ! ps -U "$LOGNAME" -o pid,ucomm | grep -q -- "${SSH_AGENT_PID:--1} ssh-agent"; then + eval "$(ssh-agent | sed '/^echo /d' | tee "$_ssh_agent_env")" fi fi @@ -41,10 +39,20 @@ fi # Load identities. if ssh-add -l 2>&1 | grep -q 'The agent has no identities'; then zstyle -a ':prezto:module:ssh:load' identities '_ssh_identities' - if (( ${#_ssh_identities} > 0 )); then - ssh-add "$_ssh_dir/${^_ssh_identities[@]}" 2> /dev/null + # ssh-add has strange requirements for running SSH_ASKPASS, so we duplicate + # them here. Essentially, if the other requirements are met, we redirect stdin + # from /dev/null in order to meet the final requirement. + # + # From ssh-add(1): + # If ssh-add needs a passphrase, it will read the passphrase from the current + # terminal if it was run from a terminal. If ssh-add does not have a terminal + # associated with it but DISPLAY and SSH_ASKPASS are set, it will execute the + # program specified by SSH_ASKPASS and open an X11 window to read the + # passphrase. + if [[ -n "$DISPLAY" && -x "$SSH_ASKPASS" ]]; then + ssh-add ${_ssh_identities:+$_ssh_dir/${^_ssh_identities[@]}} < /dev/null 2> /dev/null else - ssh-add 2> /dev/null + ssh-add ${_ssh_identities:+$_ssh_dir/${^_ssh_identities[@]}} 2> /dev/null fi fi diff --git a/.zprezto/modules/syntax-highlighting/README.md b/.zprezto/modules/syntax-highlighting/README.md index 87f85be..7a28892 100644 --- a/.zprezto/modules/syntax-highlighting/README.md +++ b/.zprezto/modules/syntax-highlighting/README.md @@ -3,9 +3,11 @@ Syntax Highlighting Integrates [zsh-syntax-highlighting][1] into Prezto. -This module should be loaded *second to last*, where last is the *prompt* -module, unless used in conjuncture with the *history-substring-search* module -where it must be loaded **before** it. +This module should be loaded before the *prompt* module. + +Additionally, if this module is used in conjunction with the +*history-substring-search* module, this module must be loaded **before** the +*history-substring-search* module. Contributors ------------ @@ -22,7 +24,9 @@ Settings To enable highlighting for this module only, add the following line to *zpreztorc*: - zstyle ':prezto:module:syntax-highlighting' color 'yes' +```sh +zstyle ':prezto:module:syntax-highlighting' color 'yes' +``` ### Highlighters @@ -31,12 +35,15 @@ only enables the *main* highlighter by default. To enable all highlighters, add the following to *zpreztorc*: - zstyle ':prezto:module:syntax-highlighting' highlighters \ - 'main' \ - 'brackets' \ - 'pattern' \ - 'cursor' \ - 'root' +```sh +zstyle ':prezto:module:syntax-highlighting' highlighters \ + 'main' \ + 'brackets' \ + 'pattern' \ + 'line' \ + 'cursor' \ + 'root' +``` ### Highlighting Styles @@ -45,10 +52,12 @@ Each syntax highlighter defines styles used to highlight tokens. To highlight, for example, builtins, commands, and functions in blue instead of green, add the following to *zpreztorc*: - zstyle ':prezto:module:syntax-highlighting' styles \ - 'builtin' 'bg=blue' \ - 'command' 'bg=blue' \ - 'function' 'bg=blue' +```sh +zstyle ':prezto:module:syntax-highlighting' styles \ + 'builtin' 'bg=blue' \ + 'command' 'bg=blue' \ + 'function' 'bg=blue' +``` Authors ------- diff --git a/.zprezto/modules/syntax-highlighting/external/.git_backup b/.zprezto/modules/syntax-highlighting/external/.git_backup new file mode 100644 index 0000000..cd073e7 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/.git_backup @@ -0,0 +1 @@ +gitdir: ../../../.git/modules/modules/syntax-highlighting/external diff --git a/.zprezto/modules/syntax-highlighting/external/.gitattributes b/.zprezto/modules/syntax-highlighting/external/.gitattributes_backup similarity index 100% rename from .zprezto/modules/syntax-highlighting/external/.gitattributes rename to .zprezto/modules/syntax-highlighting/external/.gitattributes_backup diff --git a/.zprezto/modules/syntax-highlighting/external/.gitignore b/.zprezto/modules/syntax-highlighting/external/.gitignore_backup similarity index 50% rename from .zprezto/modules/syntax-highlighting/external/.gitignore rename to .zprezto/modules/syntax-highlighting/external/.gitignore_backup index fb2e708..18fa5ec 100644 --- a/.zprezto/modules/syntax-highlighting/external/.gitignore +++ b/.zprezto/modules/syntax-highlighting/external/.gitignore_backup @@ -1,2 +1,3 @@ *.zwc* .pc/ +docs/all.md diff --git a/.zprezto/modules/syntax-highlighting/external/.revision-hash_backup b/.zprezto/modules/syntax-highlighting/external/.revision-hash_backup new file mode 100644 index 0000000..6828f88 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/.revision-hash_backup @@ -0,0 +1 @@ +$Format:%H$ diff --git a/.zprezto/modules/syntax-highlighting/external/.travis.yml_backup b/.zprezto/modules/syntax-highlighting/external/.travis.yml_backup new file mode 100644 index 0000000..2b801bd --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/.travis.yml_backup @@ -0,0 +1,49 @@ +language: generic +sudo: required + +env: + - ZSH=master + - ZSH=5.5 + - ZSH=5.4.2 + - ZSH=5.4.1 + - ZSH=5.4 + - ZSH=5.3.1 + - ZSH=5.3 + - ZSH=5.2 + - ZSH=5.1.1 + - ZSH=5.1 + - ZSH=5.0.8 + - ZSH=5.0.7 + - ZSH=5.0.6 + - ZSH=5.0.5 + - ZSH=5.0.4 + - ZSH=5.0.3 + - ZSH=5.0.2 + - ZSH=5.0.1 + - ZSH=5.0.0 + - ZSH=4.3.17 + - ZSH=4.3.16 + - ZSH=4.3.15 + - ZSH=4.3.14 + - ZSH=4.3.13 + - ZSH=4.3.12 + - ZSH=4.3.11 + +script: docker run -v $PWD:/work -w /work zshusers/zsh-${ZSH} /bin/sh -c 'install_packages make procps && make test' + +notifications: + webhooks: + urls: + - https://webhooks.gitter.im/e/367e241cdea60cb2070b + on_success: change + on_failure: always + on_start: never + irc: + channels: + - "chat.freenode.net#zsh-syntax-highlighting" + on_success: change + on_failure: always + on_start: never + use_notice: true + template: + - "%{repository}/%{branch}#%{build_number}: %{message} Changes : %{compare_url} | Build : %{build_url}" diff --git a/.zprezto/modules/syntax-highlighting/external/.version b/.zprezto/modules/syntax-highlighting/external/.version index 746bd19..e1bde80 100644 --- a/.zprezto/modules/syntax-highlighting/external/.version +++ b/.zprezto/modules/syntax-highlighting/external/.version @@ -1 +1 @@ -0.3.1-dev +0.7.0-dev diff --git a/.zprezto/modules/syntax-highlighting/external/.version_backup b/.zprezto/modules/syntax-highlighting/external/.version_backup new file mode 100644 index 0000000..e1bde80 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/.version_backup @@ -0,0 +1 @@ +0.7.0-dev diff --git a/.zprezto/modules/syntax-highlighting/external/COPYING.md b/.zprezto/modules/syntax-highlighting/external/COPYING.md index 5512a0a..22eea4f 100644 --- a/.zprezto/modules/syntax-highlighting/external/COPYING.md +++ b/.zprezto/modules/syntax-highlighting/external/COPYING.md @@ -1,4 +1,4 @@ -Copyright (c) 2010-2015 zsh-syntax-highlighting contributors +Copyright (c) 2010-2018 zsh-syntax-highlighting contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted diff --git a/.zprezto/modules/syntax-highlighting/external/HACKING.md b/.zprezto/modules/syntax-highlighting/external/HACKING.md new file mode 100644 index 0000000..5266a33 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/HACKING.md @@ -0,0 +1,75 @@ +Hacking on zsh-syntax-highlighting itself +========================================= + +This document includes information for people working on z-sy-h itself: on the +core driver (`zsh-syntax-highlighting.zsh`), on the highlighters in the +distribution, and on the test suite. It does not target third-party +highlighter authors (although they may find it an interesting read). + +The `main` highlighter +---------------------- + +The following function `pz` is useful when working on the `main` highlighting: + + pq() { + (( $#argv )) || return 0 + print -r -l -- ${(qqqq)argv} + } + pz() { + local arg + for arg; do + pq ${(z)arg} + done + } + +It prints, for each argument, its token breakdown, similar to how the main +loop of the `main` highlighter sees it. + +Testing the `brackets` highlighter +---------------------------------- + +Since the test harness empties `ZSH_HIGHLIGHT_STYLES` and the `brackets` +highlighter interrogates `ZSH_HIGHLIGHT_STYLES` to determine how to highlight, +tests must set the `bracket-level-#` keys themselves. For example: + + ZSH_HIGHLIGHT_STYLES[bracket-level-1]= + ZSH_HIGHLIGHT_STYLES[bracket-level-2]= + + BUFFER='echo ({x})' + + expected_region_highlight=( + "6 6 bracket-level-1" # ( + "7 7 bracket-level-2" # { + "9 9 bracket-level-2" # } + "10 10 bracket-level-1" # ) + ) + +Testing the `pattern` and `regexp` highlighters +----------------------------------------------- + +Because the `pattern` and `regexp` highlighters modifies `region_highlight` +directly instead of using `_zsh_highlight_add_highlight`, the test harness +cannot get the `ZSH_HIGHLIGHT_STYLES` keys. Therefore, when writing tests, use +the style itself as third word (cf. the +[documentation for `expected_region_highlight`](docs/highlighters.md)). For example: + + ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red') + + BUFFER='rm -rf /' + + expected_region_highlight=( + "1 8 fg=white,bold,bg=red" # rm -rf / + ) + +Miscellany +---------- + +If you work on the driver (`zsh-syntax-highlighting.zsh`), you may find the following zstyle useful: + + zstyle ':completion:*:*:*:*:globbed-files' ignored-patterns {'*/',}zsh-syntax-highlighting.plugin.zsh + +IRC channel +----------- + +We're on #zsh-syntax-highlighting on freenode. + diff --git a/.zprezto/modules/syntax-highlighting/external/INSTALL.md b/.zprezto/modules/syntax-highlighting/external/INSTALL.md new file mode 100644 index 0000000..1f0d923 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/INSTALL.md @@ -0,0 +1,115 @@ +How to install +-------------- + +### Using packages + +* Arch Linux: [community/zsh-syntax-highlighting][arch-package] / [AUR/zsh-syntax-highlighting-git][AUR-package] +* Debian: `zsh-syntax-highlighting` package [in `stretch`][debian-package] (or in [OBS repository][obs-repository]) +* Fedora: [zsh-syntax-highlighting package][fedora-package-alt] in Fedora 24+ (or in [OBS repository][obs-repository]) +* FreeBSD: `pkg install zsh-syntax-highlighting` (port name: [`textproc/zsh-syntax-highlighting`][freebsd-port]) +* Gentoo: [mv overlay][gentoo-overlay] +* Mac OS X / Homebrew: [brew install zsh-syntax-highlighting][brew-package] +* Ubuntu: `zsh-syntax-highlighting` package [in Xenial][ubuntu-package] (or in [OBS repository][obs-repository]) +* RHEL / CentOS / Scientific Linux: `zsh-syntax-highlighting` package in [OBS repository][obs-repository] +* openSUSE / SLE: `zsh-syntax-highlighting` package in [OBS repository][obs-repository] +* Void Linux: `zsh-syntax-highlighting package` [in XBPS][void-package] + +[arch-package]: https://www.archlinux.org/packages/zsh-syntax-highlighting +[AUR-package]: https://aur.archlinux.org/packages/zsh-syntax-highlighting-git +[debian-package]: https://packages.debian.org/zsh-syntax-highlighting +[freebsd-port]: http://www.freshports.org/textproc/zsh-syntax-highlighting/ +[gentoo-overlay]: http://gpo.zugaina.org/app-shells/zsh-syntax-highlighting +[brew-package]: https://github.com/Homebrew/homebrew-core/blob/master/Formula/zsh-syntax-highlighting.rb +[ubuntu-package]: https://launchpad.net/ubuntu/+source/zsh-syntax-highlighting +[fedora-package]: https://apps.fedoraproject.org/packages/zsh-syntax-highlighting +[fedora-package-alt]: https://bodhi.fedoraproject.org/updates/?packages=zsh-syntax-highlighting +[obs-repository]: https://software.opensuse.org//download.html?project=shells%3Azsh-users%3Azsh-syntax-highlighting&package=zsh-syntax-highlighting +[void-package]: https://github.com/voidlinux/void-packages/tree/master/srcpkgs/zsh-syntax-highlighting + +See also [repology's cross-distro index](https://repology.org/metapackage/zsh-syntax-highlighting/versions) + + +### In your ~/.zshrc + +Simply clone this repository and source the script: + + git clone https://github.com/zsh-users/zsh-syntax-highlighting.git + echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc + + Then, enable syntax highlighting in the current interactive shell: + + source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh + + If `git` is not installed, download and extract a snapshot of the latest + development tree from: + + https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz + + Note the `source` command must be **at the end** of `~/.zshrc`. + + +### With a plugin manager + +Note that `zsh-syntax-highlighting` must be the last plugin sourced. + +The zsh-syntax-highlighting authors recommend manual installation over the use +of a framework or plugin manager. + +This list is incomplete as there are too many +[frameworks / plugin managers][framework-list] to list them all here. + +[framework-list]: https://github.com/unixorn/awesome-zsh-plugins#frameworks + +#### [Antigen](https://github.com/zsh-users/antigen) + +Add `antigen bundle zsh-users/zsh-syntax-highlighting` as the last bundle in +your `.zshrc`. + +#### [Oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) + +1. Clone this repository in oh-my-zsh's plugins directory: + + git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting + +2. Activate the plugin in `~/.zshrc`: + + plugins=( [plugins...] zsh-syntax-highlighting) + +3. Source `~/.zshrc` to take changes into account: + + source ~/.zshrc + +#### [Prezto](https://github.com/sorin-ionescu/prezto) + +Zsh-syntax-highlighting is included with Prezto. See the +[Prezto documentation][prezto-docs] to enable and configure highlighters. + +[prezto-docs]: https://github.com/sorin-ionescu/prezto/tree/master/modules/syntax-highlighting + +#### [zgen](https://github.com/tarjoilija/zgen) + +Add `zgen load zsh-users/zsh-syntax-highlighting` to the end of your `.zshrc`. + +#### [zplug](https://github.com/zplug/zplug) + +Add `zplug "zsh-users/zsh-syntax-highlighting", defer:2` to your `.zshrc`. + +#### [zplugin](https://github.com/psprint/zplugin) + +Add `zplugin load zsh-users/zsh-syntax-highlighting` to the end of your +`.zshrc`. + + +### System-wide installation + +Any of the above methods is suitable for a single-user installation, +which requires no special privileges. If, however, you desire to install +zsh-syntax-highlighting system-wide, you may do so by running + + make install + +and directing your users to add + + source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh + +to their `.zshrc`s. diff --git a/.zprezto/modules/syntax-highlighting/external/Makefile b/.zprezto/modules/syntax-highlighting/external/Makefile index e4fa163..6cc2648 100644 --- a/.zprezto/modules/syntax-highlighting/external/Makefile +++ b/.zprezto/modules/syntax-highlighting/external/Makefile @@ -2,23 +2,41 @@ NAME=zsh-syntax-highlighting INSTALL?=install -c PREFIX?=/usr/local -SHARE_DIR=$(DESTDIR)$(PREFIX)/share/$(NAME) +SHARE_DIR?=$(DESTDIR)$(PREFIX)/share/$(NAME) +DOC_DIR?=$(DESTDIR)$(PREFIX)/share/doc/$(NAME) ZSH?=zsh # zsh binary to run tests with -# Have the default target do nothing. all: - @ : + cd docs && \ + cp highlighters.md all.md && \ + printf '\n\nIndividual highlighters documentation\n=====================================' >> all.md && \ + for doc in highlighters/*.md; do printf '\n\n'; cat "$$doc"; done >> all.md -install: +install: all $(INSTALL) -d $(SHARE_DIR) - cp -r .version zsh-syntax-highlighting.zsh highlighters $(SHARE_DIR) + $(INSTALL) -d $(DOC_DIR) + cp .version zsh-syntax-highlighting.zsh $(SHARE_DIR) + cp COPYING.md README.md changelog.md $(DOC_DIR) + sed -e '1s/ .*//' -e '/^\[build-status-[a-z]*\]: /d' < README.md > $(DOC_DIR)/README.md if [ x"true" = x"`git rev-parse --is-inside-work-tree 2>/dev/null`" ]; then \ git rev-parse HEAD; \ else \ cat .revision-hash; \ fi > $(SHARE_DIR)/.revision-hash + : +# The [ -e ] check below is to because sh evaluates this with (the moral +# equivalent of) NONOMATCH in effect, and highlighters/*.zsh has no matches. + for dirname in highlighters highlighters/*/ ; do \ + $(INSTALL) -d $(SHARE_DIR)/"$$dirname"; \ + for fname in "$$dirname"/*.zsh ; do [ -e "$$fname" ] && cp "$$fname" $(SHARE_DIR)"/$$dirname"; done; \ + done + cp -R docs/* $(DOC_DIR) + +clean: + rm -f docs/all.md test: + @$(ZSH) -fc 'echo ZSH_PATCHLEVEL=$$ZSH_PATCHLEVEL' @result=0; \ for test in highlighters/*; do \ if [ -d $$test/test-data ]; then \ @@ -29,6 +47,9 @@ test: done; \ exit $$result +quiet-test: + $(MAKE) test QUIET=y + perf: @result=0; \ for test in highlighters/*; do \ @@ -40,4 +61,4 @@ perf: done; \ exit $$result -.PHONY: all install test +.PHONY: all install clean test perf diff --git a/.zprezto/modules/syntax-highlighting/external/README.md b/.zprezto/modules/syntax-highlighting/external/README.md index d7fc4ad..08af2b6 100644 --- a/.zprezto/modules/syntax-highlighting/external/README.md +++ b/.zprezto/modules/syntax-highlighting/external/README.md @@ -1,68 +1,37 @@ -zsh-syntax-highlighting +zsh-syntax-highlighting [![Build Status][build-status-image]][build-status-travis] ======================= -**[Fish shell](http://www.fishshell.com) like syntax highlighting for [Zsh](http://www.zsh.org).** +**[Fish shell][fish]-like syntax highlighting for [Zsh][zsh].** -*Requirements: zsh 4.3.17+.* +*Requirements: zsh 4.3.11+.* -This package provides syntax highlighing for the shell zsh. It enables -highlighing of commands whilst they are typed at a zsh prompt into an +[fish]: http://www.fishshell.com/ +[zsh]: http://www.zsh.org/ + +This package provides syntax highlighting for the shell zsh. It enables +highlighting of commands whilst they are typed at a zsh prompt into an interactive terminal. This helps in reviewing commands before running them, particularly in catching syntax errors. -[![Screenshot](images/preview-smaller.png)](images/preview.png) +Some examples: + +Before: [![Screenshot #1.1](images/before1-smaller.png)](images/before1.png) +
+After:  [![Screenshot #1.2](images/after1-smaller.png)](images/after1.png) + +Before: [![Screenshot #2.1](images/before2-smaller.png)](images/before2.png) +
+After:  [![Screenshot #2.2](images/after2-smaller.png)](images/after2.png) + +Before: [![Screenshot #3.1](images/before3-smaller.png)](images/before3.png) +
+After:  [![Screenshot #3.2](images/after3-smaller.png)](images/after3.png) How to install -------------- -### Using packages - -* Arch Linux: [community/zsh-syntax-highlighting](https://www.archlinux.org/packages/zsh-syntax-highlighting) / [AUR/zsh-syntax-highlighting-git](https://aur.archlinux.org/packages/zsh-syntax-highlighting-git) -* Gentoo: [mv overlay](http://gpo.zugaina.org/app-shells/zsh-syntax-highlighting) -* Mac OS X / Homebrew: [brew install zsh-syntax-highlighting](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/zsh-syntax-highlighting.rb) - -### In your ~/.zshrc - -* Clone this repository: - - git clone git://github.com/zsh-users/zsh-syntax-highlighting.git - - (or [download a snapshot](https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz)) - -* Source the script **at the end** of `~/.zshrc`: - - source /path/to/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh - -* Source `~/.zshrc` to take changes into account: - - source ~/.zshrc - - -### With oh-my-zsh - -* Download the script or clone this repository in [oh-my-zsh](http://github.com/robbyrussell/oh-my-zsh) plugins directory: - - git clone git://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting - -* Activate the plugin in `~/.zshrc`: - - plugins=( [plugins...] zsh-syntax-highlighting) - -* Source `~/.zshrc` to take changes into account: - - source ~/.zshrc - -Note that `zsh-syntax-highlighting` must be the last plugin sourced, -so make it the last element of the `$plugins` array. - -### System-wide installation - -Either of the above methods is suitable for a single-user installation, which requires -no special privileges. If, however, you desire to install zsh-syntax-highlighting -system-wide, you may do so by running `make install` and directing your users to -add `source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh` -in their `.zshrc`s. +See [INSTALL.md](INSTALL.md). FAQ @@ -75,15 +44,37 @@ custom widgets have been created (i.e., after all `zle -N` calls and after running `compinit`). Widgets created later will work, but will not update the syntax highlighting. +### Does syntax highlighting work during incremental history search? + +Highlighting the command line during an incremental history search (by default bound to +to Ctrl+R in zsh's emacs keymap) requires zsh 5.4 or newer. + +Under zsh versions older than 5.4, the zsh-default [underlining][zshzle-Character-Highlighting] +of the matched portion of the buffer remains available, but zsh-syntax-highlighting's +additional highlighting is unavailable. (Those versions of zsh do not provide +enough information to allow computing the highlighting correctly.) + +See issues [#288][i288] and [#415][i415] for details. + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting +[i288]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/288 +[i415]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/415 + ### How are new releases announced? -There is currently no "push" announcements channel. However, the following alternatives exist: +There is currently no "push" announcements channel. However, the following +alternatives exist: - GitHub's RSS feed of releases: https://github.com/zsh-users/zsh-syntax-highlighting/releases.atom - An anitya entry: https://release-monitoring.org/project/7552/ + How to tweak ------------ -Syntax highlighting is done by pluggable highlighter scripts, see the [highlighters directory](highlighters) -for documentation and configuration settings. +Syntax highlighting is done by pluggable highlighter scripts. See the +[documentation on highlighters](docs/highlighters.md) for details and +configuration settings. + +[build-status-image]: https://travis-ci.org/zsh-users/zsh-syntax-highlighting.svg?branch=master +[build-status-travis]: https://travis-ci.org/zsh-users/zsh-syntax-highlighting diff --git a/.zprezto/modules/syntax-highlighting/external/changelog.md b/.zprezto/modules/syntax-highlighting/external/changelog.md index dbffcde..f20e69d 100644 --- a/.zprezto/modules/syntax-highlighting/external/changelog.md +++ b/.zprezto/modules/syntax-highlighting/external/changelog.md @@ -1,9 +1,307 @@ -up to c0dafd1d850e582291b41d693369794d1ea31343 +# Changes in version 0.6.0 + +This is a stable release, featuring bugfixes and minor improvements. +## Performance improvements: + +(none) -# Changes in version 0.3.1 +## Added highlighting of: + +- The `isearch` and `suffix` [`$zle_highlight` settings][zshzle-Character-Highlighting]. + (79e4d3d12405, 15db71abd0cc, b56ee542d619; requires zsh 5.3 for `$ISEARCHMATCH_ACTIVE` / `$SUFFIX_ACTIVE` support) + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting + +- Possible history expansions in double-quoted strings. + (76ea9e1df316) + +- Mismatched `if`/`then`/`elif`/`else`/`fi`. + (73cb83270262) + + +## Fixed highlighting of: + +- A comment line followed by a non-comment line. + (#385, 9396ad5c5f9c) + +- An unquoted `$*` (expands to the positional parameters). + (237f89ad629f) + +- history-incremental-pattern-search-backward under zsh 5.3.1. + (#407, #415, 462779629a0c) + + +## API changes (for highlighter authors): + +(none) + + +## Developer-visible changes: + +- tests: Set the `ALIAS_FUNC_DEF` option for zsh 5.4 compatibility. + (9523d6d49cb3) + + +## Other changes: + +- docs: Added before/after screenshots. + (cd9ec14a65ec..b7e277106b49) + +- docs: Link Fedora package. + (3d74aa47e4a7, 5feed23962df) + +- docs: Link FreeBSD port. + (626c034c68d7) + +- docs: Link OpenSUSE Build Service packages + (#419, dea1fedc7358) + +- Prevent user-defined aliases from taking effect in z-sy-h's own code. + (#390, 2dce602727d7, 8d5afe47f774; and #392, #395, b8fa1b9dc954) + +- docs: Update zplug installation instructions. + (#399, 4f49c4a35f17) + +- Improve "unhandled ZLE widget 'foo'" error message. + (#409, be083d7f3710) + +- Fix printing of "failed loading highlighters" error message. + (#426, ad522a091429) + + +# Changes in version 0.5.0 + + +## Performance improvements: + +We thank Sebastian Gniazdowski and "m0viefreak" for significant contributions +in this area. + +- Optimize string operations in the `main` (default) highlighter. + (#372/3cb58fd7d7b9, 02229ebd6328, ef4bfe5bcc14, #372/c6b6513ac0d6, #374/15461e7d21c3) + +- Command word highlighting: Use the `zsh/parameter` module to avoid forks. + Memoize (cache) the results. + (#298, 3ce01076b521, 2f18ba64e397, 12b879caf7a6; #320, 3b67e656bff5) + +- Avoid forks in the driver and in the `root` highlighter. + (b9112aec798a, 38c8fbea2dd2) + + +## Added highlighting of: + +- `pkexec` (a precommand). + (#248, 4f3910cbbaa5) + +- Aliases that cannot be defined normally nor invoked normally (highlighted as an error). + (#263 (in part), 28932316cca6) + +- Path separators (`/`) — the default behaviour remains to highlight path separators + and path components the same way. + (#136, #260, 6cd39e7c70d3, 9a934d291e7c, f3d3aaa00cc4) + +- Assignments to individual positional arguments (`42=foo` to assign to `$42`). + (f4036a09cee3) + +- Linewise region (the `visual-line-mode` widget, bound to `V` in zsh's `vi` keymap). + (#267, a7a7f8b42280, ee07588cfd9b) + +- Command-lines recalled by `isearch` mode; requires zsh≥5.3. + (#261 (in part); #257; 4ad311ec0a68) + +- Command-lines whilst the `IGNORE_BRACES` or `IGNORE_CLOSE_BRACES` option is in effect. + (a8a6384356af, 02807f1826a5) + +- Mismatched parentheses and braces (in the `main` highlighter). + (51b9d79c3bb6, 2fabf7ca64b7, a4196eda5e6f, and others) + +- Mismatched `do`/`done` keywords. + (b2733a64da93) + +- Mismatched `foreach`/`end` keywords. + (#96, 2bb8f0703d8f) + +- In Bourne-style function definitions, when the `MULTI_FUNC_DEF` option is set + (which is the default), highlight the first word in the function body as + a command word: `f() { g "$@" }`. + (6f91850a01e1) + +- `always` blocks. + (#335, e5782e4ddfb6) + +- Command substitutions inside double quotes, `"$(echo foo)"`. + (#139 (in part), c3913e0d8ead) + +- Non-alphabetic parameters inside double quotes (`"$$"`, `"$#"`, `"$*"`, `"$@"`, `"$?"`, `"$-"`). + (4afe670f7a1b, 44ef6e38e5a7) + +- Command words from future versions of zsh (forward compatibly). + This also adds an `arg0` style that all other command word styles fall back to. + (b4537a972eed, bccc3dc26943) + +- Escaped history expansions inside double quotes: `: "\!"` + (28d7056a7a06, et seq) + + +## Fixed highlighting of: + +- Command separator tokens in syntactically-invalid positions. + (09c4114eb980) + +- Redirections with a file descriptor number at command word. + (#238 (in part), 73ee7c1f6c4a) + +- The `select` prompt, `$PS3`. + (#268, 451665cb2a8b) + +- Values of variables in `vared`. + (e500ca246286) + +- `!` as an argument (neither a history expansion nor a reserved word). + (4c23a2fd1b90) + +- "division by zero" error under the `brackets` highlighter when `$ZSH_HIGHLIGHT_STYLES` is empty. + (f73f3d53d3a6) + +- Process substitutions, `<(pwd)` and `>(wc -l)`. + (#302, 6889ff6bd2ad, bfabffbf975c, fc9c892a3f15) + +- The non-`SHORT_LOOPS` form of `repeat` loops: `repeat 42; do true; done`. + (#290, 4832f18c50a5, ef68f50c048f, 6362c757b6f7) + +- Broken symlinks (are now highlighted as files). + (#342, 95f7206a9373, 53083da8215e) + +- Lines accepted from `isearch` mode. + (#284; #257, #259, #288; 5bae6219008b, a8fe22d42251) + +- Work around upstream bug that triggered when the command word was a relative + path, that when interpreted relative to a $PATH directory denoted a command; + the effect of that upstream bug was that the relative path was cached as + a "valid external command name". + (#354, #355, 51614ca2c994, fdaeec45146b, 7d38d07255e4; + upstream fix slated to be released in 5.3 (workers/39104)) + +- After accepting a line with the cursor on a bracket, the matching bracket + of the bracket under the cursor no longer remains highlighted (with the + `brackets` highlighter). + (4c4baede519a) + +- The first word on a new line within an array assignment or initialization is no + longer considered a command position. + (8bf423d16d46) + +- Subshells that end at command position, `(A=42)`, `(true;)`. + (#231, 7fb6f9979121; #344, 4fc35362ee5a) + +- Command word after array assignment, `a=(lorem ipsum) pwd`. + (#330, 7fb6f9979121) + + +## API changes (for highlighter authors): + +- New interface `_zsh_highlight_add_highlight`. + (341a3ae1f015, c346f6eb6fb6) + +- tests: Specify the style key, not its value, in test expectations. + (a830613467af, fd061b5730bf, eaa4335c3441, among others) + +- Module author documentation improvements. + (#306 (in part), 217669270418, 0ff354b44b6e, 80148f6c8402, 364f206a547f, and others) + +- The driver no longer defines a `_zsh_highlight_${highlighter}_highlighter_cache` + variable, which is in the highlighters' namespace. + (3e59ab41b6b8, 80148f6c8402, f91a7b885e7d) + +- Rename highlighter entry points. The old names remain supported for + backwards compatibility. + (a3d5dfcbdae9, c793e0dceab1) + +- tests: Add the "NONE" expectation. + (4da9889d1545, 13018f3dd735, d37c55c788cd) + +- tests: consider a test that writes to stderr to have failed. + (#291, 1082067f9315) + + +## Developer-visible changes: + +- Add `make quiet-test`. + (9b64ad750f35) + +- test harness: Better quote replaceables in error messages. + (30d8f92df225) + +- test harness: Fix exit code for XPASS. + (bb8d325c0cbd) + +- Create [HACKING.md](HACKING.md). + (cef49752fd0e) + +- tests: Emit a description for PASS test points. + (6aa57d60aa64, f0bae44b76dd) + +- tests: Create a script that generates a test file. + (8013dc3b8db6, et seq; `tests/generate.zsh`) + + +## Other changes: + +- Under zsh≤5.2, widgets whose names start with a `_` are no longer excluded + from highlighting. + (ed33d2cb1388; reverts part of 186d80054a40 which was for #65) + +- Under zsh≤5.2, widgets implemented by a function named after the widget are + no longer excluded from highlighting. + (487b122c480d; reverts part of 776453cb5b69) + +- Under zsh≤5.2, shell-unsafe widget names can now be wrapped. + (#278, 6a634fac9fb9, et seq) + +- Correct some test expectations. + (78290e043bc5) + +- `zsh-syntax-highlighting.plugin.zsh`: Convert from symlink to plain file + for msys2 compatibility. + (#292, d4f8edc9f3ad) + +- Document installation under some plugin managers. + (e635f766bef9, 9cab566f539b) + +- Don't leak the `PATH_DIRS` option. + (7b82b88a7166) + +- Don't require the `FUNCTION_ARGZERO` option to be set. + (#338, 750aebc553f2) + +- Under zsh≤5.2, support binding incomplete/nonexistent widgets. + (9e569bb0fe04, part of #288) + +- Make the driver reentrant, fixing possibility of infinite recursion + under zsh≤5.2 under interaction with theoretical third-party code. + (#305, d711563fe1bf, 295d62ec888d, f3242cbd6aba) + +- Fix warnings when `WARN_CREATE_GLOBAL` is set prior to sourcing zsh-syntax-highlighting. + (z-sy-h already sets `WARN_CREATE_GLOBAL` internally.) + (da60234fb236) + +- Warn only once, rather than once per keypress, when a highlighter is unavailable. + (0a9b347483ae) + + +# Changes in version 0.4.1 + +## Fixes: + +- Arguments to widgets were not properly dash-escaped. Only matters for widgets + that take arguments (i.e., that are invoked as `zle ${widget} -- ${args}`). + (282c7134e8ac, reverts c808d2187a73) + + +# Changes in version 0.4.0 ## Added highlighting of: @@ -34,6 +332,28 @@ up to c0dafd1d850e582291b41d693369794d1ea31343 ( foo ) { foo } +- command names enabled by the `PATH_DIRS` option + (#228, 96ee5116b182) + + # When ~/bin/foo/bar exists, is executable, ~/bin is in $PATH, + # and 'setopt PATH_DIRS' is in effect + foo/bar + +- parameter expansions with braces inside double quotes + (#186, 6e3720f39d84) + + echo "${foo}" + +- parameter expansions in command word + (#101, 4fcfb15913a2) + + x=/bin/ls + $x -l + +- the command separators '|&', '&!', '&|' + + view file.pdf &! ls + ## Fixed highlighting of: @@ -60,6 +380,9 @@ up to c0dafd1d850e582291b41d693369794d1ea31343 (The semicolon used to be highlighted as a mistake) +- cursor highlighter: Remove the cursor highlighting when accepting a line. + (#109, 4f0c293fdef0) + ## Removed features: @@ -79,7 +402,7 @@ up to c0dafd1d850e582291b41d693369794d1ea31343 (57624bb9f64b) - widgets wrapping: Don't add '--' when invoking widgets. - (c808d2187a73) + (c808d2187a73) [_reverted in 0.4.1_] - Refresh highlighting upon `accept-*` widgets (`accept-line` et al). (59fbdda64c21) @@ -88,6 +411,27 @@ up to c0dafd1d850e582291b41d693369794d1ea31343 `WARN_CREATE_GLOBAL` improvements). (d3deffbf46a4) +- 'make install': Permit setting `$(SHARE_DIR)` from the environment. + (e1078a8b4cf1) + +- driver: Tolerate KSH_ARRAYS being set in the calling context. + (#162, 8f19af6b319d) + +- 'make install': Install documentation fully and properly. + (#219, b1619c001390, et seq) + +- docs: Improve 'main' highlighter's documentation. + (00de155063f5, 7d4252f5f596) + +- docs: Moved to a new docs/ tree; assorted minor updates + (c575f8f37567, 5b34c23cfad5, et seq) + +- docs: Split README.md into INSTALL.md + (0b3183f6cb9a) + +- driver: Report `$ZSH_HIGHLIGHT_REVISION` when running from git + (84734ba95026) + ## Developer-visible changes: @@ -112,6 +456,8 @@ up to c0dafd1d850e582291b41d693369794d1ea31343 - tests: Add 'make perf' target (4513eaea71d7) +- tests: Run each test in a sandbox directory + (c01533920245) # Changes in version 0.3.0 diff --git a/.zprezto/modules/syntax-highlighting/external/docs/highlighters.md b/.zprezto/modules/syntax-highlighting/external/docs/highlighters.md new file mode 100644 index 0000000..642d2bd --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/docs/highlighters.md @@ -0,0 +1,105 @@ +zsh-syntax-highlighting / highlighters +====================================== + +Syntax highlighting is done by pluggable highlighters: + +* `main` - the base highlighter, and the only one [active by default][1]. +* `brackets` - [matches brackets][2] and parenthesis. +* `pattern` - matches [user-defined patterns][3]. +* `cursor` - matches [the cursor position][4]. +* `root` - highlights the whole command line [if the current user is root][5]. +* `line` - applied to [the whole command line][6]. + +[1]: highlighters/main.md +[2]: highlighters/brackets.md +[3]: highlighters/pattern.md +[4]: highlighters/cursor.md +[5]: highlighters/root.md +[6]: highlighters/line.md + + +How to activate highlighters +---------------------------- + +To activate an highlighter, add it to the `ZSH_HIGHLIGHT_HIGHLIGHTERS` array in +`~/.zshrc`, for example: + + ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor) + +By default, `$ZSH_HIGHLIGHT_HIGHLIGHTERS` is unset and only the `main` +highlighter is active. + + +How to tweak highlighters +------------------------- + +Highlighters look up styles from the `ZSH_HIGHLIGHT_STYLES` associative array. +Navigate into the [individual highlighters' documentation](highlighters/) to +see what styles (keys) each highlighter defines; the syntax for values is the +same as the syntax of "types of highlighting" of the zsh builtin +`$zle_highlight` array, which is documented in [the `zshzle(1)` manual +page][zshzle-Character-Highlighting]. + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting + +Some highlighters support additional configuration parameters; see each +highlighter's documentation for details and examples. + + +How to implement a new highlighter +---------------------------------- + +To create your own `acme` highlighter: + +* Create your script at + `highlighters/acme/acme-highlighter.zsh`. + +* Implement the `_zsh_highlight_highlighter_acme_predicate` function. + This function must return 0 when the highlighter needs to be called and + non-zero otherwise, for example: + + _zsh_highlight_highlighter_acme_predicate() { + # Call this highlighter in SVN working copies + [[ -d .svn ]] + } + +* Implement the `_zsh_highlight_highlighter_acme_paint` function. + This function does the actual syntax highlighting, by calling + `_zsh_highlight_add_highlight` with the start and end of the region to + be highlighted and the `ZSH_HIGHLIGHT_STYLES` key to use. Define the default + style for that key in the highlighter script outside of any function with + `: ${ZSH_HIGHLIGHT_STYLES[key]:=value}`, being sure to prefix + the key with your highlighter name and a colon. For example: + + : ${ZSH_HIGHLIGHT_STYLES[acme:aurora]:=fg=green} + + _zsh_highlight_highlighter_acme_paint() { + # Colorize the whole buffer with the 'aurora' style + _zsh_highlight_add_highlight 0 $#BUFFER acme:aurora + } + + If you need to test which options the user has set, test `zsyh_user_options` + with a sensible default if the option is not present in supported zsh + versions. For example: + + [[ ${zsyh_user_options[ignoreclosebraces]:-off} == on ]] + + The option name must be all lowercase with no underscores and not an alias. + +* Name your own functions and global variables `_zsh_highlight_acme_*`. + + - In zsh-syntax-highlighting 0.4.0 and earlier, the entrypoints + `_zsh_highlight_highlighter_acme_predicate` and + `_zsh_highlight_highlighter_acme_paint` + were named + `_zsh_highlight_acme_highlighter_predicate` and + `_zsh_highlight_highlighter_acme_paint` respectively. + + These names are still supported for backwards compatibility; + however, support for them will be removed in a a future major or minor release (v0.x.0 or v1.0.0). + +* Activate your highlighter in `~/.zshrc`: + + ZSH_HIGHLIGHT_HIGHLIGHTERS+=(acme) + +* [Write tests](../tests/README.md). diff --git a/.zprezto/modules/syntax-highlighting/external/docs/highlighters/brackets.md b/.zprezto/modules/syntax-highlighting/external/docs/highlighters/brackets.md new file mode 100644 index 0000000..9001074 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/docs/highlighters/brackets.md @@ -0,0 +1,29 @@ +zsh-syntax-highlighting / highlighters / brackets +------------------------------------------------- + +This is the `brackets` highlighter, that highlights brackets and parentheses, and +matches them. + + +### How to tweak it + +This highlighter defines the following styles: + +* `bracket-error` - unmatched brackets +* `bracket-level-N` - brackets with nest level N +* `cursor-matchingbracket` - the matching bracket, if cursor is on a bracket + +To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, +for example in `~/.zshrc`: + + # To define styles for nested brackets up to level 4 + ZSH_HIGHLIGHT_STYLES[bracket-level-1]='fg=blue,bold' + ZSH_HIGHLIGHT_STYLES[bracket-level-2]='fg=red,bold' + ZSH_HIGHLIGHT_STYLES[bracket-level-3]='fg=yellow,bold' + ZSH_HIGHLIGHT_STYLES[bracket-level-4]='fg=magenta,bold' + +The syntax for values is the same as the syntax of "types of highlighting" of +the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` +manual page][zshzle-Character-Highlighting]. + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting diff --git a/.zprezto/modules/syntax-highlighting/external/docs/highlighters/cursor.md b/.zprezto/modules/syntax-highlighting/external/docs/highlighters/cursor.md new file mode 100644 index 0000000..7295fd1 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/docs/highlighters/cursor.md @@ -0,0 +1,22 @@ +zsh-syntax-highlighting / highlighters / cursor +----------------------------------------------- + +This is the `cursor` highlighter, that highlights the cursor. + + +### How to tweak it + +This highlighter defines the following styles: + +* `cursor` - the style for the current cursor position + +To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, +for example in `~/.zshrc`: + + ZSH_HIGHLIGHT_STYLES[cursor]='bg=blue' + +The syntax for values is the same as the syntax of "types of highlighting" of +the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` +manual page][zshzle-Character-Highlighting]. + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting diff --git a/.zprezto/modules/syntax-highlighting/external/docs/highlighters/line.md b/.zprezto/modules/syntax-highlighting/external/docs/highlighters/line.md new file mode 100644 index 0000000..4ba14e9 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/docs/highlighters/line.md @@ -0,0 +1,22 @@ +zsh-syntax-highlighting / highlighters / line +--------------------------------------------- + +This is the `line` highlighter, that highlights the whole line. + + +### How to tweak it + +This highlighter defines the following styles: + +* `line` - the style for the whole line + +To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, +for example in `~/.zshrc`: + + ZSH_HIGHLIGHT_STYLES[line]='bold' + +The syntax for values is the same as the syntax of "types of highlighting" of +the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` +manual page][zshzle-Character-Highlighting]. + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting diff --git a/.zprezto/modules/syntax-highlighting/external/docs/highlighters/main.md b/.zprezto/modules/syntax-highlighting/external/docs/highlighters/main.md new file mode 100644 index 0000000..c14b32f --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/docs/highlighters/main.md @@ -0,0 +1,103 @@ +zsh-syntax-highlighting / highlighters / main +--------------------------------------------- + +This is the `main` highlighter, that highlights: + +* Commands +* Options +* Arguments +* Paths +* Strings + +This highlighter is active by default. + + +### How to tweak it + +This highlighter defines the following styles: + +* `unknown-token` - unknown tokens / errors +* `reserved-word` - shell reserved words (`if`, `for`) +* `alias` - aliases +* `suffix-alias` - suffix aliases (requires zsh 5.1.1 or newer) +* `builtin` - shell builtin commands (`shift`, `pwd`, `zstyle`) +* `function` - function names +* `command` - command names +* `precommand` - precommand modifiers (e.g., `noglob`, `builtin`) +* `commandseparator` - command separation tokens (`;`, `&&`) +* `hashed-command` - hashed commands +* `path` - existing filenames +* `path_pathseparator` - path separators in filenames (`/`); if unset, `path` is used (default) +* `path_prefix` - prefixes of existing filenames +* `path_prefix_pathseparator` - path separators in prefixes of existing filenames (`/`); if unset, `path_prefix` is used (default) +* `globbing` - globbing expressions (`*.txt`) +* `history-expansion` - history expansion expressions (`!foo` and `^foo^bar`) +* `single-hyphen-option` - single-hyphen options (`-o`) +* `double-hyphen-option` - double-hyphen options (`--option`) +* `back-quoted-argument` - backtick command substitution (`` `foo` ``) +* `back-quoted-argument-unclosed` - unclosed backtick command substitution (`` `foo ``) +* `single-quoted-argument` - single-quoted arguments (`` 'foo' ``) +* `single-quoted-argument-unclosed` - unclosed single-quoted arguments (`` 'foo ``) +* `double-quoted-argument` - double-quoted arguments (`` "foo" ``) +* `double-quoted-argument-unclosed` - unclosed double-quoted arguments (`` "foo ``) +* `dollar-quoted-argument` - dollar-quoted arguments (`` $'foo' ``) +* `dollar-quoted-argument-unclosed` - unclosed dollar-quoted arguments (`` $'foo ``) +* `rc-quote` - two single quotes inside single quotes when the `RC_QUOTES` option is set (`` 'foo''bar' ``) +* `dollar-double-quoted-argument` - parameter expansion inside double quotes (`$foo` inside `""`) +* `back-double-quoted-argument` - backslash escape sequences inside double-quoted arguments (`\"` in `"foo\"bar"`) +* `back-dollar-quoted-argument` - backslash escape sequences inside dollar-quoted arguments (`\x` in `$'\x48'`) +* `assign` - parameter assignments (`x=foo` and `x=( )`) +* `redirection` - redirection operators (`<`, `>`, etc) +* `comment` - comments, when `setopt INTERACTIVE_COMMENTS` is in effect (`echo # foo`) +* `arg0` - a command word other than one of those enumerated above (other than a command, precommand, alias, function, or shell builtin command). +* `default` - everything else + +To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, +for example in `~/.zshrc`: + + # Declare the variable + typeset -A ZSH_HIGHLIGHT_STYLES + + # To differentiate aliases from other command types + ZSH_HIGHLIGHT_STYLES[alias]='fg=magenta,bold' + + # To have paths colored instead of underlined + ZSH_HIGHLIGHT_STYLES[path]='fg=cyan' + + # To disable highlighting of globbing expressions + ZSH_HIGHLIGHT_STYLES[globbing]='none' + +The syntax for values is the same as the syntax of "types of highlighting" of +the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` +manual page][zshzle-Character-Highlighting]. + +#### Parameters + +To avoid partial path lookups on a path, add the path to the `X_ZSH_HIGHLIGHT_DIRS_BLACKLIST` array. +This interface is still experimental. + + X_ZSH_HIGHLIGHT_DIRS_BLACKLIST+=(/mnt/slow_share) + +### Useless trivia + +#### Forward compatibility. + +zsh-syntax-highlighting attempts to be forward-compatible with zsh. +Specifically, we attempt to facilitate highlighting _command word_ types that +had not yet been invented when this version of zsh-syntax-highlighting was +released. + +A _command word_ is something like a function name, external command name, et +cetera. (See +[Simple Commands & Pipelines in `zshmisc(1)`][zshmisc-Simple-Commands-And-Pipelines] +for a formal definition.) + +If a new _kind_ of command word is ever added to zsh — something conceptually +different than "function" and "alias" and "external command" — then command words +of that (new) kind will be highlighted by the style `arg0_$kind`, +where `$kind` is the output of `type -w` on the new kind of command word. If that +style is not defined, then the style `arg0` will be used instead. + +[zshmisc-Simple-Commands-And-Pipelines]: http://zsh.sourceforge.net/Doc/Release/Shell-Grammar.html#Simple-Commands-_0026-Pipelines + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting diff --git a/.zprezto/modules/syntax-highlighting/external/docs/highlighters/pattern.md b/.zprezto/modules/syntax-highlighting/external/docs/highlighters/pattern.md new file mode 100644 index 0000000..3ad5f24 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/docs/highlighters/pattern.md @@ -0,0 +1,19 @@ +zsh-syntax-highlighting / highlighters / pattern +------------------------------------------------ + +This is the `pattern` highlighter, that highlights user-defined patterns. + + +### How to tweak it + +To use this highlighter, associate patterns with styles in the +`ZSH_HIGHLIGHT_PATTERNS` associative array, for example in `~/.zshrc`: + + # To have commands starting with `rm -rf` in red: + ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red') + +The syntax for values is the same as the syntax of "types of highlighting" of +the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` +manual page][zshzle-Character-Highlighting]. + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting diff --git a/.zprezto/modules/syntax-highlighting/external/docs/highlighters/regexp.md b/.zprezto/modules/syntax-highlighting/external/docs/highlighters/regexp.md new file mode 100644 index 0000000..25f1b6c --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/docs/highlighters/regexp.md @@ -0,0 +1,27 @@ +zsh-syntax-highlighting / highlighters / regexp +------------------------------------------------ + +This is the `regexp` highlighter, that highlights user-defined regular +expressions. It's similar to the `pattern` highlighter, but allows more complex +patterns. + +### How to tweak it + +To use this highlighter, associate regular expressions with styles in the +`ZSH_HIGHLIGHT_REGEXP` associative array, for example in `~/.zshrc`: + + ZSH_HIGHLIGHT_REGEXP+=('\bsudo\b' fg=123,bold) + +This will highlight "sudo" only as a complete word, i.e., "sudo cmd", but not +"sudoedit" + +The syntax for values is the same as the syntax of "types of highlighting" of +the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` +manual page][zshzle-Character-Highlighting]. + +See also: [regular expressions tutorial][perlretut], zsh regexp operator `=~` +in [the `zshmisc(1)` manual page][zshmisc-Conditional-Expressions] + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting +[perlretut]: http://perldoc.perl.org/perlretut.html +[zshmisc-Conditional-Expressions]: http://zsh.sourceforge.net/Doc/Release/Conditional-Expressions.html#Conditional-Expressions diff --git a/.zprezto/modules/syntax-highlighting/external/docs/highlighters/root.md b/.zprezto/modules/syntax-highlighting/external/docs/highlighters/root.md new file mode 100644 index 0000000..0b0d41f --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/docs/highlighters/root.md @@ -0,0 +1,23 @@ +zsh-syntax-highlighting / highlighters / root +--------------------------------------------- + +This is the `root` highlighter, that highlights the whole line if the current +user is root. + + +### How to tweak it + +This highlighter defines the following styles: + +* `root` - the style for the whole line if the current user is root. + +To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, +for example in `~/.zshrc`: + + ZSH_HIGHLIGHT_STYLES[root]='bg=red' + +The syntax for values is the same as the syntax of "types of highlighting" of +the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` +manual page][zshzle-Character-Highlighting]. + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/README.md b/.zprezto/modules/syntax-highlighting/external/highlighters/README.md index 987cc83..8490ddf 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/README.md +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/README.md @@ -1,50 +1,8 @@ zsh-syntax-highlighting / highlighters ====================================== -Syntax highlighting is done by pluggable highlighters: +Navigate into the individual highlighters' documentation to see +what styles (`$ZSH_HIGHLIGHT_STYLES` keys) each highlighter defines. -* [***main***](main) - the base highlighter, and the only one active by default. -* [***brackets***](brackets) - matches brackets and parenthesis. -* [***pattern***](pattern) - matches user-defined patterns. -* [***cursor***](cursor) - matches the cursor position. -* [***root***](root) - triggered if the current user is root. -* [***line***](line) - applied to the whole command line - - -How to activate highlighters ----------------------------- - -To activate an highlighter, add it to the `ZSH_HIGHLIGHT_HIGHLIGHTERS` array in `~/.zshrc`, for example: - - ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor) - - -How to tweak highlighters -------------------------- - -Highlighters look up styles from the `ZSH_HIGHLIGHT_STYLES` array. Navigate into each highlighter directory to see what styles it defines and how to configure it. - - -How to implement a new highlighter ----------------------------------- - -To create your own ***myhighlighter*** highlighter: - -* Create your script at **highlighters/*myhighlighter*/*myhighlighter*-highlighter.zsh**. -* Implement the `_zsh_highlight_myhighlighter_highlighter_predicate` function. This function must return 0 when the highlighter needs to be called, for example: - - _zsh_highlight_myhighlighter_highlighter_predicate() { - # Call this highlighter in SVN repositories - [[ -d .svn ]] - } - -* Implement the `_zsh_highlight_myhighlighter_highlighter` function. This function does the actual syntax highlighting, by modifying `region_highlight`, for example: - - _zsh_highlight_myhighlighter_highlighter() { - # Colorize the whole buffer with blue background - region_highlight+=(0 $#BUFFER bg=blue) - } - -* Activate your highlighter in `~/.zshrc`: - - ZSH_HIGHLIGHT_HIGHLIGHTERS+=(myhighlighter) +Refer to the [documentation on highlighters](../docs/highlighters.md) for further +information. diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/README.md b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/README.md index 9fd4f96..9001074 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/README.md +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/README.md @@ -1,25 +1,20 @@ zsh-syntax-highlighting / highlighters / brackets -================================================= +------------------------------------------------- -This is the ***brackets*** highlighter, that highlights brackets, parenthesis and matches them. +This is the `brackets` highlighter, that highlights brackets and parentheses, and +matches them. -How to activate it ------------------- -To activate it, add it to `ZSH_HIGHLIGHT_HIGHLIGHTERS`: +### How to tweak it - ZSH_HIGHLIGHT_HIGHLIGHTERS=( [...] brackets) - - -How to tweak it ---------------- This highlighter defines the following styles: * `bracket-error` - unmatched brackets * `bracket-level-N` - brackets with nest level N * `cursor-matchingbracket` - the matching bracket, if cursor is on a bracket -To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, for example in `~/.zshrc`: +To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, +for example in `~/.zshrc`: # To define styles for nested brackets up to level 4 ZSH_HIGHLIGHT_STYLES[bracket-level-1]='fg=blue,bold' @@ -27,4 +22,8 @@ To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, for ZSH_HIGHLIGHT_STYLES[bracket-level-3]='fg=yellow,bold' ZSH_HIGHLIGHT_STYLES[bracket-level-4]='fg=magenta,bold' -The syntax for declaring styles is [documented here](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135). +The syntax for values is the same as the syntax of "types of highlighting" of +the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` +manual page][zshzle-Character-Highlighting]. + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/brackets-highlighter.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/brackets-highlighter.zsh index 2b87a3e..fc71f2a 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/brackets-highlighter.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/brackets-highlighter.zsh @@ -1,5 +1,5 @@ # ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors +# Copyright (c) 2010-2017 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted @@ -38,73 +38,69 @@ : ${ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]:=standout} # Whether the brackets highlighter should be called or not. -_zsh_highlight_brackets_highlighter_predicate() +_zsh_highlight_highlighter_brackets_predicate() { - _zsh_highlight_cursor_moved || _zsh_highlight_buffer_modified + [[ $WIDGET == zle-line-finish ]] || _zsh_highlight_cursor_moved || _zsh_highlight_buffer_modified } # Brackets highlighting function. -_zsh_highlight_brackets_highlighter() +_zsh_highlight_highlighter_brackets_paint() { - local level=0 pos - local -A levelpos lastoflevel matching typepos - region_highlight=() + local char style + local -i bracket_color_size=${#ZSH_HIGHLIGHT_STYLES[(I)bracket-level-*]} buflen=${#BUFFER} level=0 matchingpos pos + local -A levelpos lastoflevel matching # Find all brackets and remember which one is matching - for (( pos = 0; $pos < ${#BUFFER}; pos++ )) ; do - local char="$BUFFER[pos+1]" + for (( pos = 1; pos <= buflen; pos++ )) ; do + char=$BUFFER[pos] case $char in ["([{"]) levelpos[$pos]=$((++level)) lastoflevel[$level]=$pos - _zsh_highlight_brackets_highlighter_brackettype "$char" ;; [")]}"]) - matching[$lastoflevel[$level]]=$pos - matching[$pos]=$lastoflevel[$level] - levelpos[$pos]=$((level--)) - _zsh_highlight_brackets_highlighter_brackettype "$char" - ;; - ['"'\']) - # Skip everything inside quotes - local quotetype=$char - while (( $pos < ${#BUFFER} )) ; do - (( pos++ )) - [[ $BUFFER[$pos+1] == $quotetype ]] && break - done + if (( level > 0 )); then + matchingpos=$lastoflevel[$level] + levelpos[$pos]=$((level--)) + if _zsh_highlight_brackets_match $matchingpos $pos; then + matching[$matchingpos]=$pos + matching[$pos]=$matchingpos + fi + else + levelpos[$pos]=-1 + fi ;; esac done # Now highlight all found brackets for pos in ${(k)levelpos}; do - if [[ -n $matching[$pos] ]] && [[ $typepos[$pos] == $typepos[$matching[$pos]] ]]; then - local bracket_color_size=${#ZSH_HIGHLIGHT_STYLES[(I)bracket-level-*]} - local bracket_color_level=bracket-level-$(( (levelpos[$pos] - 1) % bracket_color_size + 1 )) - local style=$ZSH_HIGHLIGHT_STYLES[$bracket_color_level] - region_highlight+=("$pos $((pos + 1)) $style") + if (( $+matching[$pos] )); then + if (( bracket_color_size )); then + _zsh_highlight_add_highlight $((pos - 1)) $pos bracket-level-$(( (levelpos[$pos] - 1) % bracket_color_size + 1 )) + fi else - local style=$ZSH_HIGHLIGHT_STYLES[bracket-error] - region_highlight+=("$pos $((pos + 1)) $style") + _zsh_highlight_add_highlight $((pos - 1)) $pos bracket-error fi done - # If cursor is on a bracket, then highlight corresponding bracket, if any - pos=$CURSOR - if [[ -n $levelpos[$pos] ]] && [[ -n $matching[$pos] ]]; then - local otherpos=$matching[$pos] - local style=$ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket] - region_highlight+=("$otherpos $((otherpos + 1)) $style") + # If cursor is on a bracket, then highlight corresponding bracket, if any. + if [[ $WIDGET != zle-line-finish ]]; then + pos=$((CURSOR + 1)) + if (( $+levelpos[$pos] )) && (( $+matching[$pos] )); then + local -i otherpos=$matching[$pos] + _zsh_highlight_add_highlight $((otherpos - 1)) $otherpos cursor-matchingbracket + fi fi } # Helper function to differentiate type -_zsh_highlight_brackets_highlighter_brackettype() +_zsh_highlight_brackets_match() { - case $1 in - ["()"]) typepos[$pos]=round;; - ["[]"]) typepos[$pos]=bracket;; - ["{}"]) typepos[$pos]=curly;; - *) ;; + case $BUFFER[$1] in + \() [[ $BUFFER[$2] == \) ]];; + \[) [[ $BUFFER[$2] == \] ]];; + \{) [[ $BUFFER[$2] == \} ]];; + *) false;; esac } diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/cursor-matchingbracket-line-finish.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/cursor-matchingbracket-line-finish.zsh new file mode 100644 index 0000000..b2acd31 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/cursor-matchingbracket-line-finish.zsh @@ -0,0 +1,36 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +WIDGET=zle-line-finish + +BUFFER=': $foo[bar]' +CURSOR=6 # cursor is zero-based + +expected_region_highlight=( +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/cursor-matchingbracket.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/cursor-matchingbracket.zsh new file mode 100644 index 0000000..e05b4e9 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/cursor-matchingbracket.zsh @@ -0,0 +1,47 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +unsorted=1 + +ZSH_HIGHLIGHT_STYLES[bracket-level-1]= +ZSH_HIGHLIGHT_STYLES[bracket-level-2]= +ZSH_HIGHLIGHT_STYLES[bracket-level-3]= + +BUFFER=': ((( )))' +CURSOR=2 # cursor is zero-based + +expected_region_highlight=( + "3 3 bracket-level-1" + "4 4 bracket-level-2" + "5 5 bracket-level-3" + "7 7 bracket-level-3" + "8 8 bracket-level-2" + "9 9 bracket-level-1" + "9 9 cursor-matchingbracket" +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/empty-styles.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/empty-styles.zsh new file mode 100644 index 0000000..e60657b --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/empty-styles.zsh @@ -0,0 +1,33 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=': (x)' + +expected_region_highlight=( +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/loop-styles.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/loop-styles.zsh new file mode 100644 index 0000000..e5cfcdf --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/loop-styles.zsh @@ -0,0 +1,53 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +unsorted=1 + +ZSH_HIGHLIGHT_STYLES[bracket-level-1]= +ZSH_HIGHLIGHT_STYLES[bracket-level-2]= +ZSH_HIGHLIGHT_STYLES[bracket-level-3]= + +BUFFER=': ({[({[(x)]})]})' + +expected_region_highlight=( + "3 3 bracket-level-1" + "4 4 bracket-level-2" + "5 5 bracket-level-3" + "6 6 bracket-level-1" + "7 7 bracket-level-2" + "8 8 bracket-level-3" + "9 9 bracket-level-1" + "11 11 bracket-level-1" + "12 12 bracket-level-3" + "13 13 bracket-level-2" + "14 14 bracket-level-1" + "15 15 bracket-level-3" + "16 16 bracket-level-2" + "17 17 bracket-level-1" +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/mismatch-patentheses.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/mismatch-patentheses.zsh index 5671079..5cc588f 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/mismatch-patentheses.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/mismatch-patentheses.zsh @@ -27,11 +27,16 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- +unsorted=1 + +ZSH_HIGHLIGHT_STYLES[bracket-level-1]= +ZSH_HIGHLIGHT_STYLES[bracket-level-2]= + BUFFER='echo ({x}]' expected_region_highlight=( - "6 6 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # ( - "7 7 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # { - "9 9 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # } - "10 10 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # ) + "6 6 bracket-error" # ( + "7 7 bracket-level-2" # { + "9 9 bracket-level-2" # } + "10 10 bracket-error" # ) ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/near-quotes.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/near-quotes.zsh new file mode 100644 index 0000000..49f002b --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/near-quotes.zsh @@ -0,0 +1,42 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +unsorted=1 + +ZSH_HIGHLIGHT_STYLES[bracket-level-1]= +ZSH_HIGHLIGHT_STYLES[bracket-level-2]= + +BUFFER=': {"{x}"}' + +expected_region_highlight=( + "3 3 bracket-level-1" + "5 5 bracket-level-2" + "7 7 bracket-level-2" + "9 9 bracket-level-1" +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/nested-parentheses.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/nested-parentheses.zsh index 291f8f4..21a20fb 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/nested-parentheses.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/nested-parentheses.zsh @@ -27,13 +27,19 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- +unsorted=1 + +ZSH_HIGHLIGHT_STYLES[bracket-level-1]= +ZSH_HIGHLIGHT_STYLES[bracket-level-2]= +ZSH_HIGHLIGHT_STYLES[bracket-level-3]= + BUFFER='echo $(echo ${(z)array})' expected_region_highlight=( - "7 7 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # ( - "14 14 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # { - "15 15 $ZSH_HIGHLIGHT_STYLES[bracket-level-3]" # ( - "17 17 $ZSH_HIGHLIGHT_STYLES[bracket-level-3]" # ) - "23 23 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # } - "24 24 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # ) + "7 7 bracket-level-1" # ( + "14 14 bracket-level-2" # { + "15 15 bracket-level-3" # ( + "17 17 bracket-level-3" # ) + "23 23 bracket-level-2" # } + "24 24 bracket-level-1" # ) ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/only-error.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/only-error.zsh new file mode 100644 index 0000000..00fe557 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/only-error.zsh @@ -0,0 +1,34 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2017 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=': x)' + +expected_region_highlight=( + "4 4 bracket-error" # ) +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/quoted-patentheses.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/quoted-patentheses.zsh index a2c52c4..81ee04f 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/quoted-patentheses.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/quoted-patentheses.zsh @@ -30,5 +30,5 @@ BUFFER='echo "foo ( bar"' expected_region_highlight=( -"1 16 $ZSH_HIGHLIGHT_STYLES[none]" # We expect the brackets highlighter to do nothing +"11 11 bracket-error" ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/simple-parentheses.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/simple-parentheses.zsh index 893145f..2ccfbab 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/simple-parentheses.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/simple-parentheses.zsh @@ -27,11 +27,16 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- +unsorted=1 + +ZSH_HIGHLIGHT_STYLES[bracket-level-1]= +ZSH_HIGHLIGHT_STYLES[bracket-level-2]= + BUFFER='echo ({x})' expected_region_highlight=( - "6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # ( - "7 7 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # { - "9 9 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # } - "10 10 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # ) + "6 6 bracket-level-1" # ( + "7 7 bracket-level-2" # { + "9 9 bracket-level-2" # } + "10 10 bracket-level-1" # ) ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/unclosed-patentheses.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/unclosed-patentheses.zsh index c36ba36..d3f6560 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/unclosed-patentheses.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/unclosed-patentheses.zsh @@ -27,10 +27,15 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- +unsorted=1 + +ZSH_HIGHLIGHT_STYLES[bracket-level-1]= +ZSH_HIGHLIGHT_STYLES[bracket-level-2]= + BUFFER='echo ({x}' expected_region_highlight=( - "6 6 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # ( - "7 7 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # { - "9 9 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # } + "6 6 bracket-error" # ( + "7 7 bracket-level-2" # { + "9 9 bracket-level-2" # } ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/unclosed-patentheses2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/unclosed-patentheses2.zsh index 04c246b..2c489c3 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/unclosed-patentheses2.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/brackets/test-data/unclosed-patentheses2.zsh @@ -27,10 +27,14 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- +unsorted=1 + +ZSH_HIGHLIGHT_STYLES[bracket-level-1]= + BUFFER='echo {x})' expected_region_highlight=( - "6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # { - "8 8 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # } - "9 9 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # ) + "6 6 bracket-level-1" # { + "8 8 bracket-level-1" # } + "9 9 bracket-error" # ) ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/cursor/README.md b/.zprezto/modules/syntax-highlighting/external/highlighters/cursor/README.md index d28ac19..7295fd1 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/cursor/README.md +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/cursor/README.md @@ -1,24 +1,22 @@ zsh-syntax-highlighting / highlighters / cursor -================================================= +----------------------------------------------- -This is the ***cursor*** highlighter, that highlights the cursor. +This is the `cursor` highlighter, that highlights the cursor. -How to activate it ------------------- -To activate it, add it to `ZSH_HIGHLIGHT_HIGHLIGHTERS`: +### How to tweak it - ZSH_HIGHLIGHT_HIGHLIGHTERS=( [...] cursor) - - -How to tweak it ---------------- This highlighter defines the following styles: * `cursor` - the style for the current cursor position -To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, for example in `~/.zshrc`: +To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, +for example in `~/.zshrc`: ZSH_HIGHLIGHT_STYLES[cursor]='bg=blue' -The syntax for declaring styles is [documented here](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135). +The syntax for values is the same as the syntax of "types of highlighting" of +the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` +manual page][zshzle-Character-Highlighting]. + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/cursor/cursor-highlighter.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/cursor/cursor-highlighter.zsh index d315c62..81633a3 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/cursor/cursor-highlighter.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/cursor/cursor-highlighter.zsh @@ -32,13 +32,16 @@ : ${ZSH_HIGHLIGHT_STYLES[cursor]:=standout} # Whether the cursor highlighter should be called or not. -_zsh_highlight_cursor_highlighter_predicate() +_zsh_highlight_highlighter_cursor_predicate() { - _zsh_highlight_cursor_moved + # remove cursor highlighting when the line is finished + [[ $WIDGET == zle-line-finish ]] || _zsh_highlight_cursor_moved } # Cursor highlighting function. -_zsh_highlight_cursor_highlighter() +_zsh_highlight_highlighter_cursor_paint() { - region_highlight+=("$CURSOR $(( $CURSOR + 1 )) $ZSH_HIGHLIGHT_STYLES[cursor]") + [[ $WIDGET == zle-line-finish ]] && return + + _zsh_highlight_add_highlight $CURSOR $(( $CURSOR + 1 )) cursor } diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/line/README.md b/.zprezto/modules/syntax-highlighting/external/highlighters/line/README.md index 2be32a2..4ba14e9 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/line/README.md +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/line/README.md @@ -1,24 +1,22 @@ zsh-syntax-highlighting / highlighters / line -================================================= +--------------------------------------------- -This is the ***line*** highlighter, that highlights the whole line. +This is the `line` highlighter, that highlights the whole line. -How to activate it ------------------- -To activate it, add it to `ZSH_HIGHLIGHT_HIGHLIGHTERS`: +### How to tweak it - ZSH_HIGHLIGHT_HIGHLIGHTERS=( [...] line) - - -How to tweak it ---------------- This highlighter defines the following styles: * `line` - the style for the whole line -To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, for example in `~/.zshrc`: +To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, +for example in `~/.zshrc`: ZSH_HIGHLIGHT_STYLES[line]='bold' -The syntax for declaring styles is [documented here](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135). +The syntax for values is the same as the syntax of "types of highlighting" of +the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` +manual page][zshzle-Character-Highlighting]. + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/line/line-highlighter.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/line/line-highlighter.zsh index 68308cc..f922dc9 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/line/line-highlighter.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/line/line-highlighter.zsh @@ -32,13 +32,13 @@ : ${ZSH_HIGHLIGHT_STYLES[line]:=} # Whether the root highlighter should be called or not. -_zsh_highlight_line_highlighter_predicate() +_zsh_highlight_highlighter_line_predicate() { _zsh_highlight_buffer_modified } # root highlighting function. -_zsh_highlight_line_highlighter() +_zsh_highlight_highlighter_line_paint() { - region_highlight+=("0 $#BUFFER $ZSH_HIGHLIGHT_STYLES[line]") + _zsh_highlight_add_highlight 0 $#BUFFER line } diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/README.md b/.zprezto/modules/syntax-highlighting/external/highlighters/main/README.md index c748248..c14b32f 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/README.md +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/README.md @@ -1,7 +1,7 @@ zsh-syntax-highlighting / highlighters / main -============================================= +--------------------------------------------- -This is the ***main*** highlighter, that highlights: +This is the `main` highlighter, that highlights: * Commands * Options @@ -9,48 +9,51 @@ This is the ***main*** highlighter, that highlights: * Paths * Strings -How to activate it ------------------- -To activate it, add it to `ZSH_HIGHLIGHT_HIGHLIGHTERS`: - - ZSH_HIGHLIGHT_HIGHLIGHTERS=( [...] main) - This highlighter is active by default. -How to tweak it ---------------- +### How to tweak it + This highlighter defines the following styles: * `unknown-token` - unknown tokens / errors -* `reserved-word` - shell reserved words +* `reserved-word` - shell reserved words (`if`, `for`) * `alias` - aliases * `suffix-alias` - suffix aliases (requires zsh 5.1.1 or newer) -* `builtin` - shell builtin commands -* `function` - functions -* `command` - commands -* `precommand` - precommands (i.e. exec, builtin, ...) -* `commandseparator` - command separation tokens +* `builtin` - shell builtin commands (`shift`, `pwd`, `zstyle`) +* `function` - function names +* `command` - command names +* `precommand` - precommand modifiers (e.g., `noglob`, `builtin`) +* `commandseparator` - command separation tokens (`;`, `&&`) * `hashed-command` - hashed commands -* `path` - paths -* `path_prefix` - path prefixes +* `path` - existing filenames +* `path_pathseparator` - path separators in filenames (`/`); if unset, `path` is used (default) +* `path_prefix` - prefixes of existing filenames +* `path_prefix_pathseparator` - path separators in prefixes of existing filenames (`/`); if unset, `path_prefix` is used (default) * `globbing` - globbing expressions (`*.txt`) * `history-expansion` - history expansion expressions (`!foo` and `^foo^bar`) -* `single-hyphen-option` - single hyphen options (-o) -* `double-hyphen-option` - double hyphen options (--option) -* `back-quoted-argument` - backquoted expressions (`` `foo` ``) -* `single-quoted-argument` - single quoted arguments (`` 'foo' ``) -* `double-quoted-argument` - double quoted arguments (`` "foo" ``) -* `dollar-quoted-argument` - dollar quoted arguments (`` $'foo' ``) -* `dollar-double-quoted-argument` - dollar double quoted arguments ($foo inside "") -* `back-double-quoted-argument` - back double quoted arguments (\x inside "") -* `back-dollar-quoted-argument` - back dollar quoted arguments (\x inside $'') -* `assign` - variable assignments +* `single-hyphen-option` - single-hyphen options (`-o`) +* `double-hyphen-option` - double-hyphen options (`--option`) +* `back-quoted-argument` - backtick command substitution (`` `foo` ``) +* `back-quoted-argument-unclosed` - unclosed backtick command substitution (`` `foo ``) +* `single-quoted-argument` - single-quoted arguments (`` 'foo' ``) +* `single-quoted-argument-unclosed` - unclosed single-quoted arguments (`` 'foo ``) +* `double-quoted-argument` - double-quoted arguments (`` "foo" ``) +* `double-quoted-argument-unclosed` - unclosed double-quoted arguments (`` "foo ``) +* `dollar-quoted-argument` - dollar-quoted arguments (`` $'foo' ``) +* `dollar-quoted-argument-unclosed` - unclosed dollar-quoted arguments (`` $'foo ``) +* `rc-quote` - two single quotes inside single quotes when the `RC_QUOTES` option is set (`` 'foo''bar' ``) +* `dollar-double-quoted-argument` - parameter expansion inside double quotes (`$foo` inside `""`) +* `back-double-quoted-argument` - backslash escape sequences inside double-quoted arguments (`\"` in `"foo\"bar"`) +* `back-dollar-quoted-argument` - backslash escape sequences inside dollar-quoted arguments (`\x` in `$'\x48'`) +* `assign` - parameter assignments (`x=foo` and `x=( )`) * `redirection` - redirection operators (`<`, `>`, etc) -* `comment` - interactive comments, when `setopt INTERACTIVE_COMMENTS` is in effect (`echo # foo`) -* `default` - parts of the buffer that do not match anything +* `comment` - comments, when `setopt INTERACTIVE_COMMENTS` is in effect (`echo # foo`) +* `arg0` - a command word other than one of those enumerated above (other than a command, precommand, alias, function, or shell builtin command). +* `default` - everything else -To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, for example in `~/.zshrc`: +To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, +for example in `~/.zshrc`: # Declare the variable typeset -A ZSH_HIGHLIGHT_STYLES @@ -64,5 +67,37 @@ To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, for # To disable highlighting of globbing expressions ZSH_HIGHLIGHT_STYLES[globbing]='none' -The syntax for declaring styles is documented in [the `zshzle(1)` manual -page](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135). +The syntax for values is the same as the syntax of "types of highlighting" of +the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` +manual page][zshzle-Character-Highlighting]. + +#### Parameters + +To avoid partial path lookups on a path, add the path to the `X_ZSH_HIGHLIGHT_DIRS_BLACKLIST` array. +This interface is still experimental. + + X_ZSH_HIGHLIGHT_DIRS_BLACKLIST+=(/mnt/slow_share) + +### Useless trivia + +#### Forward compatibility. + +zsh-syntax-highlighting attempts to be forward-compatible with zsh. +Specifically, we attempt to facilitate highlighting _command word_ types that +had not yet been invented when this version of zsh-syntax-highlighting was +released. + +A _command word_ is something like a function name, external command name, et +cetera. (See +[Simple Commands & Pipelines in `zshmisc(1)`][zshmisc-Simple-Commands-And-Pipelines] +for a formal definition.) + +If a new _kind_ of command word is ever added to zsh — something conceptually +different than "function" and "alias" and "external command" — then command words +of that (new) kind will be highlighted by the style `arg0_$kind`, +where `$kind` is the output of `type -w` on the new kind of command word. If that +style is not defined, then the style `arg0` will be used instead. + +[zshmisc-Simple-Commands-And-Pipelines]: http://zsh.sourceforge.net/Doc/Release/Shell-Grammar.html#Simple-Commands-_0026-Pipelines + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/main-highlighter.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/main-highlighter.zsh index 64a2032..8b373ab 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/main-highlighter.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/main-highlighter.zsh @@ -1,5 +1,5 @@ # ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2015 zsh-syntax-highlighting contributors +# Copyright (c) 2010-2017 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted @@ -32,16 +32,12 @@ : ${ZSH_HIGHLIGHT_STYLES[default]:=none} : ${ZSH_HIGHLIGHT_STYLES[unknown-token]:=fg=red,bold} : ${ZSH_HIGHLIGHT_STYLES[reserved-word]:=fg=yellow} -: ${ZSH_HIGHLIGHT_STYLES[alias]:=fg=green} : ${ZSH_HIGHLIGHT_STYLES[suffix-alias]:=fg=green,underline} -: ${ZSH_HIGHLIGHT_STYLES[builtin]:=fg=green} -: ${ZSH_HIGHLIGHT_STYLES[function]:=fg=green} -: ${ZSH_HIGHLIGHT_STYLES[command]:=fg=green} : ${ZSH_HIGHLIGHT_STYLES[precommand]:=fg=green,underline} : ${ZSH_HIGHLIGHT_STYLES[commandseparator]:=none} -: ${ZSH_HIGHLIGHT_STYLES[hashed-command]:=fg=green} : ${ZSH_HIGHLIGHT_STYLES[path]:=underline} -: ${ZSH_HIGHLIGHT_STYLES[path_prefix]:=underline} +: ${ZSH_HIGHLIGHT_STYLES[path_pathseparator]:=} +: ${ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]:=} : ${ZSH_HIGHLIGHT_STYLES[globbing]:=fg=blue} : ${ZSH_HIGHLIGHT_STYLES[history-expansion]:=fg=blue} : ${ZSH_HIGHLIGHT_STYLES[single-hyphen-option]:=none} @@ -50,56 +46,219 @@ : ${ZSH_HIGHLIGHT_STYLES[single-quoted-argument]:=fg=yellow} : ${ZSH_HIGHLIGHT_STYLES[double-quoted-argument]:=fg=yellow} : ${ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]:=fg=yellow} +: ${ZSH_HIGHLIGHT_STYLES[rc-quote]:=fg=cyan} : ${ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]:=fg=cyan} : ${ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]:=fg=cyan} : ${ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]:=fg=cyan} : ${ZSH_HIGHLIGHT_STYLES[assign]:=none} : ${ZSH_HIGHLIGHT_STYLES[redirection]:=none} : ${ZSH_HIGHLIGHT_STYLES[comment]:=fg=black,bold} +: ${ZSH_HIGHLIGHT_STYLES[arg0]:=fg=green} # Whether the highlighter should be called or not. -_zsh_highlight_main_highlighter_predicate() +_zsh_highlight_highlighter_main_predicate() { - # accept-* may trigger removal of path_prefix highlighting - [[ $WIDGET == accept-* ]] || - _zsh_highlight_buffer_modified + # may need to remove path_prefix highlighting when the line ends + [[ $WIDGET == zle-line-finish ]] || _zsh_highlight_buffer_modified } # Helper to deal with tokens crossing line boundaries. _zsh_highlight_main_add_region_highlight() { integer start=$1 end=$2 - local style=$3 + shift 2 + + if (( $+argv[2] )); then + # Caller specified inheritance explicitly. + else + # Automate inheritance. + typeset -A fallback_of; fallback_of=( + alias arg0 + suffix-alias arg0 + builtin arg0 + function arg0 + command arg0 + precommand arg0 + hashed-command arg0 + + path_prefix path + # The path separator fallback won't ever be used, due to the optimisation + # in _zsh_highlight_main_highlighter_highlight_path_separators(). + path_pathseparator path + path_prefix_pathseparator path_prefix + + single-quoted-argument{-unclosed,} + double-quoted-argument{-unclosed,} + dollar-quoted-argument{-unclosed,} + back-quoted-argument{-unclosed,} + ) + local needle=$1 value + while [[ -n ${value::=$fallback_of[$needle]} ]]; do + unset "fallback_of[$needle]" # paranoia against infinite loops + argv+=($value) + needle=$value + done + fi # The calculation was relative to $PREBUFFER$BUFFER, but region_highlight is # relative to $BUFFER. (( start -= $#PREBUFFER )) (( end -= $#PREBUFFER )) - (( end < 0 )) && return # having end<0 would be a bug + (( start >= end )) && { print -r -- >&2 "zsh-syntax-highlighting: BUG: _zsh_highlight_main_add_region_highlight: start($start) >= end($end)"; return } + (( end <= 0 )) && return (( start < 0 )) && start=0 # having start<0 is normal with e.g. multiline strings - region_highlight+=("$start $end $style") + _zsh_highlight_add_highlight $start $end "$@" +} + +_zsh_highlight_main_add_many_region_highlights() { + for 1 2 3; do + _zsh_highlight_main_add_region_highlight $1 $2 $3 + done +} + +# Get the type of a command. +# +# Uses the zsh/parameter module if available to avoid forks, and a +# wrapper around 'type -w' as fallback. +# +# Takes a single argument. +# +# The result will be stored in REPLY. +_zsh_highlight_main__type() { + if (( $+_zsh_highlight_main__command_type_cache )); then + REPLY=$_zsh_highlight_main__command_type_cache[(e)$1] + if [[ -n "$REPLY" ]]; then + return + fi + fi + if (( $#options_to_set )); then + setopt localoptions $options_to_set; + fi + unset REPLY + if zmodload -e zsh/parameter; then + if (( $+aliases[(e)$1] )); then + REPLY=alias + elif (( $+saliases[(e)${1##*.}] )); then + REPLY='suffix alias' + elif (( $reswords[(Ie)$1] )); then + REPLY=reserved + elif (( $+functions[(e)$1] )); then + REPLY=function + elif (( $+builtins[(e)$1] )); then + REPLY=builtin + elif (( $+commands[(e)$1] )); then + REPLY=command + # zsh 5.2 and older have a bug whereby running 'type -w ./sudo' implicitly + # runs 'hash ./sudo=/usr/local/bin/./sudo' (assuming /usr/local/bin/sudo + # exists and is in $PATH). Avoid triggering the bug, at the expense of + # falling through to the $() below, incurring a fork. (Issue #354.) + # + # The first disjunct mimics the isrelative() C call from the zsh bug. + elif { [[ $1 != */* ]] || is-at-least 5.3 } && + ! builtin type -w -- $1 >/dev/null 2>&1; then + REPLY=none + fi + fi + if ! (( $+REPLY )); then + # Note that 'type -w' will run 'rehash' implicitly. + REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null)##*: }" + fi + if (( $+_zsh_highlight_main__command_type_cache )); then + _zsh_highlight_main__command_type_cache[(e)$1]=$REPLY + fi +} + +# Check whether the first argument is a redirection operator token. +# Report result via the exit code. +_zsh_highlight_main__is_redirection() { + # A redirection operator token: + # - starts with an optional single-digit number; + # - then, has a '<' or '>' character; + # - is not a process substitution [<(...) or >(...)]. + # - is not a numeric glob <-> + [[ $1 == (<0-9>|)(\<|\>)* ]] && [[ $1 != (\<|\>)$'\x28'* ]] && [[ $1 != *'<'*'-'*'>'* ]] +} + +# Resolve alias. +# +# Takes a single argument. +# +# The result will be stored in REPLY. +_zsh_highlight_main__resolve_alias() { + if zmodload -e zsh/parameter; then + REPLY=${aliases[$arg]} + else + REPLY="${"$(alias -- $arg)"#*=}" + fi +} + +# Check that the top of $braces_stack has the expected value. If it does, set +# the style according to $2; otherwise, set style=unknown-token. +# +# $1: character expected to be at the top of $braces_stack +# $2: assignment to execute it if matches +_zsh_highlight_main__stack_pop() { + if [[ $braces_stack[1] == $1 ]]; then + braces_stack=${braces_stack:1} + eval "$2" + else + style=unknown-token + fi } # Main syntax highlighting function. -_zsh_highlight_main_highlighter() +_zsh_highlight_highlighter_main_paint() { - if [[ -o interactive_comments ]]; then - local interactive_comments= # set to empty + setopt localoptions extendedglob + + # At the PS3 prompt and in vared, highlight nothing. + # + # (We can't check this in _zsh_highlight_highlighter_main_predicate because + # if the predicate returns false, the previous value of region_highlight + # would be reused.) + if [[ $CONTEXT == (select|vared) ]]; then + return fi - emulate -L zsh - setopt localoptions extendedglob bareglobqual + + ## Variable declarations and initializations local start_pos=0 end_pos highlight_glob=true arg style + local in_array_assignment=false # true between 'a=(' and the matching ')' typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR typeset -a ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS typeset -a ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW + local -a options_to_set # used in callees local buf="$PREBUFFER$BUFFER" - region_highlight=() + integer len="${#buf}" + + # "R" for round + # "Q" for square + # "Y" for curly + # "D" for do/done + # "$" for 'end' (matches 'foreach' always; also used with cshjunkiequotes in repeat/while) + # "?" for 'if'/'fi'; also checked by 'elif'/'else' + # ":" for 'then' + local braces_stack + + if [[ $zsyh_user_options[ignorebraces] == on || ${zsyh_user_options[ignoreclosebraces]:-off} == on ]]; then + local right_brace_is_recognised_everywhere=false + else + local right_brace_is_recognised_everywhere=true + fi + + if [[ $zsyh_user_options[pathdirs] == on ]]; then + options_to_set+=( PATH_DIRS ) + fi ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=( '|' '||' ';' '&' '&&' + '|&' + '&!' '&|' + # ### 'case' syntax, but followed by a pattern, not by a command + # ';;' ';&' ';|' ) ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS=( 'builtin' 'command' 'exec' 'nocorrect' 'noglob' + 'pkexec' # immune to #121 because it's usually not passed --option flags ) # Tokens that, at (naively-determined) "command position", are followed by @@ -120,6 +279,8 @@ _zsh_highlight_main_highlighter() '!' # reserved word; unrelated to $histchars[1] ) + local -a match mbegin mend + # State machine # # The states are: @@ -128,8 +289,9 @@ _zsh_highlight_main_highlighter() # - :sudo_arg: The argument to a sudo leading-dash option that takes one, # when given as a separate word; i.e., "foo" in "-u foo" (two # words) but not in "-ufoo" (one word). - # - :regular: "Not a command word". + # - :regular: "Not a command word", and command delimiters are permitted. # Mainly used to detect premature termination of commands. + # - :always: The word 'always' in the «{ foo } always { bar }» syntax. # # When the kind of a word is not yet known, $this_word / $next_word may contain # multiple states. For example, after "sudo -i", the next word may be either @@ -137,7 +299,7 @@ _zsh_highlight_main_highlighter() # and :sudo_opt:. # # The tokens are always added with both leading and trailing colons to serve as - # word delimiters (an improvised array); [[ $x == *:foo:* ]] and x=${x//:foo:/} + # word delimiters (an improvised array); [[ $x == *:foo:* ]] and x=${x//:foo:/} # will DTRT regardless of how many elements or repetitions $x has.. # # Handling of redirections: upon seeing a redirection token, we must stall @@ -157,25 +319,47 @@ _zsh_highlight_main_highlighter() # local this_word=':start:' next_word integer in_redirection - for arg in ${interactive_comments-${(z)buf}} \ - ${interactive_comments+${(zZ+c+)buf}}; do + # Processing buffer + local proc_buf="$buf" + local -a args + if [[ $zsyh_user_options[interactivecomments] == on ]]; then + args=(${(zZ+c+)buf}) + else + args=(${(z)buf}) + fi + for arg in $args; do + # Initialize $next_word. if (( in_redirection )); then (( --in_redirection )) fi if (( in_redirection == 0 )); then + # Initialize $next_word to its default value. next_word=':regular:' + else + # Stall $next_word. fi + + # Initialize per-"simple command" [zshmisc(1)] variables: + # + # $already_added (see next paragraph) + # $style how to highlight $arg + # $in_array_assignment boolean flag for "between '(' and ')' of array assignment" + # $highlight_glob boolean flag for "'noglob' is in effect" + # # $already_added is set to 1 to disable adding an entry to region_highlight # for this iteration. Currently, that is done for "" and $'' strings, # which add the entry early so escape sequences within the string override # the string's color. integer already_added=0 - local style_override="" - if [[ $this_word == *':start:'* ]] && [[ $arg = 'noglob' ]]; then - highlight_glob=false + style=unknown-token + if [[ $this_word == *':start:'* ]]; then + in_array_assignment=false + if [[ $arg == 'noglob' ]]; then + highlight_glob=false + fi fi - # advance $start_pos, skipping over whitespace in $buf. + # Compute the new $start_pos and $end_pos, skipping over whitespace in $buf. if [[ $arg == ';' ]] ; then # We're looking for either a semicolon or a newline, whichever comes # first. Both of these are rendered as a ";" (SEPER) by the ${(z)..} @@ -186,25 +370,81 @@ _zsh_highlight_main_highlighter() # indistinguishable from 'echo foo echo bar' (one command with three # words for arguments). local needle=$'[;\n]' - integer offset=${${buf[start_pos+1,-1]}[(i)$needle]} - (( start_pos += offset - 1 )) + integer offset=$(( ${proc_buf[(i)$needle]} - 1 )) + (( start_pos += offset )) (( end_pos = start_pos + $#arg )) else - ((start_pos+=${#buf[$start_pos+1,-1]}-${#${buf[$start_pos+1,-1]##([[:space:]]|\\[[:space:]])#}})) + # The line was: + # + # integer offset=$(((len-start_pos)-${#${proc_buf##([[:space:]]|\\[[:space:]])#}})) + # + # - len-start_pos is length of current proc_buf; basically: initial length minus where + # we are, and proc_buf is chopped to the "where we are" (compare the "previous value + # of start_pos" below, and the len-(start_pos-offset) = len-start_pos+offset) + # - what's after main minus sign is: length of proc_buf without spaces at the beginning + # - so what the line actually did, was computing length of the spaces! + # - this can be done via (#b) flag, like below + if [[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\[[:space:]])##)* ]]; then + # The first, outer parenthesis + integer offset="${#match[1]}" + else + integer offset=0 + fi + ((start_pos+=offset)) ((end_pos=$start_pos+${#arg})) fi - if [[ -n ${interactive_comments+'set'} && $arg[1] == $histchars[3] ]]; then + # Compute the new $proc_buf. We advance it + # (chop off characters from the beginning) + # beyond what end_pos points to, by skipping + # as many characters as end_pos was advanced. + # + # end_pos was advanced by $offset (via start_pos) + # and by $#arg. Note the `start_pos=$end_pos` + # below. + # + # As for the [,len]. We could use [,len-start_pos+offset] + # here, but to make it easier on eyes, we use len and + # rely on the fact that Zsh simply handles that. The + # length of proc_buf is len-start_pos+offset because + # we're chopping it to match current start_pos, so its + # length matches the previous value of start_pos. + # + # Why [,-1] is slower than [,length] isn't clear. + proc_buf="${proc_buf[offset + $#arg + 1,len]}" + + # Handle the INTERACTIVE_COMMENTS option. + # + # We use the (Z+c+) flag so the entire comment is presented as one token in $arg. + if [[ $zsyh_user_options[interactivecomments] == on && $arg[1] == $histchars[3] ]]; then if [[ $this_word == *(':regular:'|':start:')* ]]; then - style=$ZSH_HIGHLIGHT_STYLES[comment] + style=comment else - style=$ZSH_HIGHLIGHT_STYLES[unknown-token] # prematurely terminated + style=unknown-token # prematurely terminated fi _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style already_added=1 + start_pos=$end_pos continue fi + # Analyse the current word. + if _zsh_highlight_main__is_redirection $arg ; then + if (( in_redirection )); then + _zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token + already_added=1 + else + in_redirection=2 + fi + fi + + # Special-case the first word after 'sudo'. + if (( ! in_redirection )); then + if [[ $this_word == *':sudo_opt:'* ]] && [[ $arg != -* ]]; then + this_word=${this_word//:sudo_opt:/} + fi + fi + # Parse the sudo command line if (( ! in_redirection )); then if [[ $this_word == *':sudo_opt:'* ]]; then @@ -222,50 +462,149 @@ _zsh_highlight_main_highlighter() next_word+=':sudo_opt:' next_word+=':start:' fi - fi + fi - if [[ $this_word == *':start:'* ]] && (( in_redirection == 0 )); then # $arg is the command word + # The Great Fork: is this a command word? Is this a non-command word? + if [[ $this_word == *':always:'* && $arg == 'always' ]]; then + # try-always construct + style=reserved-word # de facto a reserved word, although not de jure + next_word=':start:' + elif [[ $this_word == *':start:'* ]] && (( in_redirection == 0 )); then # $arg is the command word if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]]; then - style=$ZSH_HIGHLIGHT_STYLES[precommand] - elif [[ "$arg" = "sudo" ]]; then - style=$ZSH_HIGHLIGHT_STYLES[precommand] + style=precommand + elif [[ "$arg" = "sudo" ]] && { _zsh_highlight_main__type sudo; [[ -n $REPLY && $REPLY != "none" ]] }; then + style=precommand next_word=${next_word//:regular:/} next_word+=':sudo_opt:' next_word+=':start:' else _zsh_highlight_main_highlighter_expand_path $arg local expanded_arg="$REPLY" - local res="$(LC_ALL=C builtin type -w -- ${expanded_arg} 2>/dev/null)" + _zsh_highlight_main__type ${expanded_arg} + local res="$REPLY" + () { + # Special-case: command word is '$foo', like that, without braces or anything. + # + # That's not entirely correct --- if the parameter's value happens to be a reserved + # word, the parameter expansion will be highlighted as a reserved word --- but that + # incorrectness is outweighed by the usability improvement of permitting the use of + # parameters that refer to commands, functions, and builtins. + local -a match mbegin mend + local MATCH; integer MBEGIN MEND + if [[ $res == none ]] && (( ${+parameters} )) && + [[ ${arg[1]} == \$ ]] && [[ ${arg:1} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+)$ ]] && + (( ${+parameters[(e)${MATCH}]} )) && [[ ${parameters[(e)$MATCH]} != *special* ]] + then + _zsh_highlight_main__type ${(P)MATCH} + res=$REPLY + fi + } case $res in - *': reserved') style=$ZSH_HIGHLIGHT_STYLES[reserved-word];; - *': suffix alias') - style=$ZSH_HIGHLIGHT_STYLES[suffix-alias] + reserved) # reserved word + style=reserved-word + # + # Match braces. + case $arg in + ($'\x7b') + braces_stack='Y'"$braces_stack" + ;; + ($'\x7d') + # We're at command word, so no need to check $right_brace_is_recognised_everywhere + _zsh_highlight_main__stack_pop 'Y' style=reserved-word + if [[ $style == reserved-word ]]; then + next_word+=':always:' + fi + ;; + ('do') + braces_stack='D'"$braces_stack" + ;; + ('done') + _zsh_highlight_main__stack_pop 'D' style=reserved-word + ;; + ('if') + braces_stack=':?'"$braces_stack" + ;; + ('then') + _zsh_highlight_main__stack_pop ':' style=reserved-word + ;; + ('elif') + if [[ ${braces_stack[1]} == '?' ]]; then + braces_stack=':'"$braces_stack" + else + style=unknown-token + fi + ;; + ('else') + if [[ ${braces_stack[1]} == '?' ]]; then + : + else + style=unknown-token + fi + ;; + ('fi') + _zsh_highlight_main__stack_pop '?' "" + ;; + ('foreach') + braces_stack='$'"$braces_stack" + ;; + ('end') + _zsh_highlight_main__stack_pop '$' style=reserved-word + ;; + esac ;; - *': alias') style=$ZSH_HIGHLIGHT_STYLES[alias] - local aliased_command="${"$(alias -- $arg)"#*=}" - [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$aliased_command"} && -z ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]] && ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS+=($arg) + 'suffix alias') style=suffix-alias;; + alias) () { + integer insane_alias + case $arg in + # Issue #263: aliases with '=' on their LHS. + # + # There are three cases: + # + # - Unsupported, breaks 'alias -L' output, but invokable: + ('='*) :;; + # - Unsupported, not invokable: + (*'='*) insane_alias=1;; + # - The common case: + (*) :;; + esac + if (( insane_alias )); then + style=unknown-token + else + # The common case. + style=alias + _zsh_highlight_main__resolve_alias $arg + local alias_target="$REPLY" + [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$alias_target"} && -z ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]] && ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS+=($arg) + fi + } ;; - *': builtin') style=$ZSH_HIGHLIGHT_STYLES[builtin];; - *': function') style=$ZSH_HIGHLIGHT_STYLES[function];; - *': command') style=$ZSH_HIGHLIGHT_STYLES[command];; - *': hashed') style=$ZSH_HIGHLIGHT_STYLES[hashed-command];; - *) if _zsh_highlight_main_highlighter_check_assign; then - style=$ZSH_HIGHLIGHT_STYLES[assign] - if [[ $arg[-1] != '(' ]]; then + builtin) style=builtin;; + function) style=function;; + command) style=command;; + hashed) style=hashed-command;; + none) if _zsh_highlight_main_highlighter_check_assign; then + style=assign + if [[ $arg[-1] == '(' ]]; then + in_array_assignment=true + else # assignment to a scalar parameter. # (For array assignments, the command doesn't start until the ")" token.) next_word+=':start:' fi - elif [[ $arg[0,1] == $histchars[0,1] || $arg[0,1] == $histchars[2,2] ]]; then - style=$ZSH_HIGHLIGHT_STYLES[history-expansion] - elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]] && - [[ $this_word == *':regular:'* ]]; then - # This highlights empty commands (semicolon follows nothing) as an error. - # Zsh accepts them, though. - style=$ZSH_HIGHLIGHT_STYLES[commandseparator] - elif [[ $arg[1] == '<' || $arg[1] == '>' ]]; then - style=$ZSH_HIGHLIGHT_STYLES[redirection] - (( in_redirection=2 )) + elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then + style=history-expansion + elif [[ $arg[0,1] == $histchars[2,2] ]]; then + style=history-expansion + elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then + if [[ $this_word == *':regular:'* ]]; then + # This highlights empty commands (semicolon follows nothing) as an error. + # Zsh accepts them, though. + style=commandseparator + else + style=unknown-token + fi + elif (( in_redirection == 2 )); then + style=redirection elif [[ $arg[1,2] == '((' ]]; then # Arithmetic evaluation. # @@ -276,77 +615,97 @@ _zsh_highlight_main_highlighter() # # We highlight just the opening parentheses, as a reserved word; this # is how [[ ... ]] is highlighted, too. - style=$ZSH_HIGHLIGHT_STYLES[reserved-word] + style=reserved-word _zsh_highlight_main_add_region_highlight $start_pos $((start_pos + 2)) $style already_added=1 if [[ $arg[-2,-1] == '))' ]]; then _zsh_highlight_main_add_region_highlight $((end_pos - 2)) $end_pos $style already_added=1 fi - elif [[ $arg == '()' || $arg == $'\x28' ]]; then + elif [[ $arg == '()' ]]; then # anonymous function + style=reserved-word + elif [[ $arg == $'\x28' ]]; then # subshell - style=$ZSH_HIGHLIGHT_STYLES[reserved-word] + style=reserved-word + braces_stack='R'"$braces_stack" + elif [[ $arg == $'\x29' ]]; then + # end of subshell + _zsh_highlight_main__stack_pop 'R' style=reserved-word else if _zsh_highlight_main_highlighter_check_path; then - style=$ZSH_HIGHLIGHT_STYLES[path] + style=$REPLY else - style=$ZSH_HIGHLIGHT_STYLES[unknown-token] + style=unknown-token fi fi ;; + *) _zsh_highlight_main_add_region_highlight $start_pos $end_pos arg0_$res arg0 + already_added=1 + ;; esac fi - else # $arg is a non-command word + fi + if (( ! already_added )) && [[ $style == unknown-token ]] && # not handled by the 'command word' codepath + { (( in_redirection )) || [[ $this_word == *':regular:'* ]] || [[ $this_word == *':sudo_opt:'* ]] || [[ $this_word == *':sudo_arg:'* ]] } + then # $arg is a non-command word case $arg in - $'\x29') style=$ZSH_HIGHLIGHT_STYLES[reserved-word];; # subshell - $'\x7d') style=$ZSH_HIGHLIGHT_STYLES[reserved-word];; # block - '--'*) style=$ZSH_HIGHLIGHT_STYLES[double-hyphen-option];; - '-'*) style=$ZSH_HIGHLIGHT_STYLES[single-hyphen-option];; - "'"*) style=$ZSH_HIGHLIGHT_STYLES[single-quoted-argument];; - '"'*) style=$ZSH_HIGHLIGHT_STYLES[double-quoted-argument] - _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style - _zsh_highlight_main_highlighter_highlight_string - already_added=1 + $'\x29') # subshell or end of array assignment + if $in_array_assignment; then + style=assign + in_array_assignment=false + next_word+=':start:' + else + _zsh_highlight_main__stack_pop 'R' style=reserved-word + fi;; + $'\x28\x29') # possibly a function definition + if [[ $zsyh_user_options[multifuncdef] == on ]] || false # TODO: or if the previous word was a command word + then + next_word+=':start:' + fi + style=reserved-word ;; - \$\'*) style=$ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument] - _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style - _zsh_highlight_main_highlighter_highlight_dollar_string - already_added=1 - ;; - '`'*) style=$ZSH_HIGHLIGHT_STYLES[back-quoted-argument];; - [*?]*|*[^\\][*?]*) - $highlight_glob && style=$ZSH_HIGHLIGHT_STYLES[globbing] || style=$ZSH_HIGHLIGHT_STYLES[default];; *) if false; then - elif [[ $arg[0,1] = $histchars[0,1] ]]; then - style=$ZSH_HIGHLIGHT_STYLES[history-expansion] + elif [[ $arg = $'\x7d' ]] && $right_brace_is_recognised_everywhere; then + # Parsing rule: } + # + # Additionally, `tt(})' is recognized in any position if neither the + # tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set. + _zsh_highlight_main__stack_pop 'Y' style=reserved-word + if [[ $style == reserved-word ]]; then + next_word+=':always:' + fi + elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then + style=history-expansion elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then if [[ $this_word == *':regular:'* ]]; then - style=$ZSH_HIGHLIGHT_STYLES[commandseparator] + style=commandseparator else - style=$ZSH_HIGHLIGHT_STYLES[unknown-token] + style=unknown-token fi - elif [[ $arg[1] == '<' || $arg[1] == '>' ]]; then - style=$ZSH_HIGHLIGHT_STYLES[redirection] - (( in_redirection=2 )) + elif (( in_redirection == 2 )); then + style=redirection else - if _zsh_highlight_main_highlighter_check_path; then - style=$ZSH_HIGHLIGHT_STYLES[path] - else - style=$ZSH_HIGHLIGHT_STYLES[default] - fi + _zsh_highlight_main_highlighter_highlight_argument + already_added=1 fi ;; esac fi - # if a style_override was set (eg in _zsh_highlight_main_highlighter_check_path), use it - [[ -n $style_override ]] && style=$ZSH_HIGHLIGHT_STYLES[$style_override] - (( already_added )) || _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style + if ! (( already_added )); then + _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style + fi if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then - next_word=':start:' + if [[ $arg == ';' ]] && $in_array_assignment; then + # literal newline inside an array assignment + next_word=':regular:' + else + next_word=':start:' + highlight_glob=true + fi elif - [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} && $this_word == *':start:' ]] || - [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} && $this_word == *':start:' ]]; then + [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} && $this_word == *':start:'* ]] || + [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} && $this_word == *':start:'* ]]; then next_word=':start:' elif [[ $arg == "repeat" && $this_word == *':start:'* ]]; then # skip the repeat-count word @@ -354,12 +713,19 @@ _zsh_highlight_main_highlighter() # The redirection mechanism assumes $this_word describes the word # following the redirection. Make it so. # + # That word can be a command word with shortloops (`repeat 2 ls`) + # or a command separator (`repeat 2; ls` or `repeat 2; do ls; done`). + # # The repeat-count word will be handled like a redirection target. - this_word=':start:' + this_word=':start::regular:' fi - [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]] && highlight_glob=true start_pos=$end_pos - (( in_redirection == 0 )) && this_word=$next_word + if (( in_redirection == 0 )); then + # This is the default/common codepath. + this_word=$next_word + else + # Stall $this_word. + fi done } @@ -367,18 +733,50 @@ _zsh_highlight_main_highlighter() _zsh_highlight_main_highlighter_check_assign() { setopt localoptions extended_glob - [[ $arg == [[:alpha:]_][[:alnum:]_]#(|\[*\])(|[+])=* ]] + [[ $arg == [[:alpha:]_][[:alnum:]_]#(|\[*\])(|[+])=* ]] || + [[ $arg == [0-9]##(|[+])=* ]] +} + +_zsh_highlight_main_highlighter_highlight_path_separators() +{ + local pos style_pathsep + style_pathsep=$1_pathseparator + reply=() + [[ -z "$ZSH_HIGHLIGHT_STYLES[$style_pathsep]" || "$ZSH_HIGHLIGHT_STYLES[$1]" == "$ZSH_HIGHLIGHT_STYLES[$style_pathsep]" ]] && return 0 + for (( pos = start_pos; $pos <= end_pos; pos++ )) ; do + if [[ $BUFFER[pos] == / ]]; then + reply+=($((pos - 1)) $pos $style_pathsep) + fi + done } # Check if $arg is a path. +# If yes, return 0 and in $REPLY the style to use. +# Else, return non-zero (and the contents of $REPLY is undefined). _zsh_highlight_main_highlighter_check_path() { _zsh_highlight_main_highlighter_expand_path $arg; - local expanded_path="$REPLY" + local expanded_path="$REPLY" tmp_path + + REPLY=path [[ -z $expanded_path ]] && return 1 + [[ -L $expanded_path ]] && return 0 [[ -e $expanded_path ]] && return 0 + # Check if this is a blacklisted path + if [[ $expanded_path[1] == / ]]; then + tmp_path=$expanded_path + else + tmp_path=$PWD/$expanded_path + fi + tmp_path=$tmp_path:a + + while [[ $tmp_path != / ]]; do + [[ -n "${(M)X_ZSH_HIGHLIGHT_DIRS_BLACKLIST:#$tmp_path}" ]] && return 1 + tmp_path=$tmp_path:h + done + # Search the path in CDPATH local cdpath_dir for cdpath_dir in $cdpath ; do @@ -386,71 +784,217 @@ _zsh_highlight_main_highlighter_check_path() done # If dirname($arg) doesn't exist, neither does $arg. - [[ ! -e ${expanded_path:h} ]] && return 1 + [[ ! -d ${expanded_path:h} ]] && return 1 # If this word ends the buffer, check if it's the prefix of a valid path. - if [[ ${BUFFER[1]} != "-" && ${#BUFFER} == $end_pos ]] && - [[ $WIDGET != accept-* ]]; then + if [[ ${BUFFER[1]} != "-" && $len == $end_pos ]] && + [[ $WIDGET != zle-line-finish ]]; then local -a tmp tmp=( ${expanded_path}*(N) ) - (( $#tmp > 0 )) && style_override=path_prefix && return 0 + (( $#tmp > 0 )) && REPLY=path_prefix && return 0 fi # It's not a path. return 1 } -# Highlight special chars inside double-quoted strings -_zsh_highlight_main_highlighter_highlight_string() +# Highlight an argument and possibly special chars in quotes +# This command will at least highlight start_pos to end_pos with the default style +_zsh_highlight_main_highlighter_highlight_argument() { - setopt localoptions noksharrays + local base_style=default i path_eligible=1 style + local -a highlights reply + local -a match mbegin mend local MATCH; integer MBEGIN MEND + + if [[ $arg[1] == - ]]; then + if [[ $arg[2] == - ]]; then + base_style=double-hyphen-option + else + base_style=single-hyphen-option + fi + path_eligible=0 + fi + + for (( i = 1 ; i <= end_pos - start_pos ; i += 1 )); do + case "$arg[$i]" in + "\\") (( i += 1 )); continue;; + "'") + _zsh_highlight_main_highlighter_highlight_single_quote $i + (( i = REPLY )) + highlights+=($reply) + ;; + '"') + _zsh_highlight_main_highlighter_highlight_double_quote $i + (( i = REPLY )) + highlights+=($reply) + ;; + '`') + _zsh_highlight_main_highlighter_highlight_backtick $i + (( i = REPLY )) + highlights+=($reply) + ;; + '$') + path_eligible=0 + if [[ $arg[i+1] == "'" ]]; then + path_eligible=1 + _zsh_highlight_main_highlighter_highlight_dollar_quote $i + (( i = REPLY )) + highlights+=($reply) + continue + fi + while [[ $arg[i+1] == [\^=~#+] ]]; do + (( i += 1 )) + done + if [[ $arg[i+1] == [*@#?$!-] ]]; then + (( i += 1 )) + fi;; + *) + if $highlight_glob && [[ ${arg[$i]} =~ ^[*?] || ${arg:$i-1} =~ ^\<[0-9]*-[0-9]*\> ]]; then + highlights+=($(( start_pos + i - 1 )) $(( start_pos + i + $#MATCH - 1)) globbing) + (( i += $#MATCH - 1 )) + path_eligible=0 + else + continue + fi + ;; + esac + done + + if (( path_eligible )) && _zsh_highlight_main_highlighter_check_path; then + base_style=$REPLY + _zsh_highlight_main_highlighter_highlight_path_separators $base_style + highlights+=($reply) + fi + + highlights=($start_pos $end_pos $base_style $highlights) + _zsh_highlight_main_add_many_region_highlights $highlights +} + +# Quote Helper Functions +# +# $arg is expected to be set to the current argument +# $start_pos is expected to be set to the start of $arg in $BUFFER +# $1 is the index in $arg which starts the quote +# $REPLY is returned as the end of quote index in $arg +# $reply is returned as an array of region_highlight additions + +# Highlight single-quoted strings +_zsh_highlight_main_highlighter_highlight_single_quote() +{ + local arg1=$1 i q=\' style + i=$arg[(ib:arg1+1:)$q] + reply=() + + if [[ $zsyh_user_options[rcquotes] == on ]]; then + while [[ $arg[i+1] == "'" ]]; do + reply+=($(( start_pos + i - 1 )) $(( start_pos + i + 1 )) rc-quote) + (( i++ )) + i=$arg[(ib:i+1:)$q] + done + fi + + if [[ $arg[i] == "'" ]]; then + style=single-quoted-argument + else + # If unclosed, i points past the end + (( i-- )) + style=single-quoted-argument-unclosed + fi + reply=($(( start_pos + arg1 - 1 )) $(( start_pos + i )) $style $reply) + REPLY=$i +} + +# Highlight special chars inside double-quoted strings +_zsh_highlight_main_highlighter_highlight_double_quote() +{ + local -a match mbegin mend saved_reply + local MATCH; integer MBEGIN MEND local i j k style - # Starting quote is at 1, so start parsing at offset 2 in the string. - for (( i = 2 ; i < end_pos - start_pos ; i += 1 )) ; do + reply=() + + for (( i = $1 + 1 ; i <= end_pos - start_pos ; i += 1 )) ; do (( j = i + start_pos - 1 )) (( k = j + 1 )) case "$arg[$i]" in - '$' ) style=$ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument] + '"') break;; + '`') saved_reply=($reply) + _zsh_highlight_main_highlighter_highlight_backtick $i + (( i = REPLY )) + reply=($saved_reply $reply) + continue + ;; + '$' ) style=dollar-double-quoted-argument # Look for an alphanumeric parameter name. if [[ ${arg:$i} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+) ]] ; then (( k += $#MATCH )) # highlight the parameter name (( i += $#MATCH )) # skip past it + elif [[ ${arg:$i} =~ ^[{]([A-Za-z_][A-Za-z0-9_]*|[0-9]+)[}] ]] ; then + (( k += $#MATCH )) # highlight the parameter name and braces + (( i += $#MATCH )) # skip past it + elif [[ $arg[i+1] == '$' ]]; then + # $$ - pid + (( k += 1 )) # highlight both dollar signs + (( i += 1 )) # don't consider the second one as introducing another parameter expansion + elif [[ $arg[i+1] == [-#*@?] ]]; then + # $#, $*, $@, $?, $- - like $$ above + (( k += 1 )) # highlight both dollar signs + (( i += 1 )) # don't consider the second one as introducing another parameter expansion + elif [[ $arg[i+1] == $'\x28' ]]; then + # Highlight just the '$'. else continue fi ;; - "\\") style=$ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument] - if [[ \\\`\"\$ == *$arg[$i+1]* ]]; then + "\\") style=back-double-quoted-argument + if [[ \\\`\"\$${histchars[1]} == *$arg[$i+1]* ]]; then (( k += 1 )) # Color following char too. (( i += 1 )) # Skip parsing the escaped char. else continue fi ;; + ($histchars[1]) # ! - may be a history expansion + if [[ $arg[i+1] != ('='|$'\x28'|$'\x7b'|[[:blank:]]) ]]; then + style=history-expansion + else + continue + fi + ;; *) continue ;; esac - _zsh_highlight_main_add_region_highlight $j $k $style + reply+=($j $k $style) done + + if [[ $arg[i] == '"' ]]; then + style=double-quoted-argument + else + # If unclosed, i points past the end + (( i-- )) + style=double-quoted-argument-unclosed + fi + reply=($(( start_pos + $1 - 1)) $(( start_pos + i )) $style $reply) + REPLY=$i } # Highlight special chars inside dollar-quoted strings -_zsh_highlight_main_highlighter_highlight_dollar_string() +_zsh_highlight_main_highlighter_highlight_dollar_quote() { - setopt localoptions noksharrays local -a match mbegin mend local MATCH; integer MBEGIN MEND local i j k style local AA integer c - # Starting dollar-quote is at 1:2, so start parsing at offset 3 in the string. - for (( i = 3 ; i < end_pos - start_pos ; i += 1 )) ; do + reply=() + + for (( i = $1 + 2 ; i <= end_pos - start_pos ; i += 1 )) ; do (( j = i + start_pos - 1 )) (( k = j + 1 )) case "$arg[$i]" in - "\\") style=$ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument] + "'") break;; + "\\") style=back-dollar-quoted-argument for (( c = i + 1 ; c <= end_pos - start_pos ; c += 1 )); do [[ "$arg[$c]" != ([0-9xXuUa-fA-F]) ]] && break done @@ -466,7 +1010,7 @@ _zsh_highlight_main_highlighter_highlight_dollar_string() else if (( $#arg > $i+1 )) && [[ $arg[$i+1] == [xXuU] ]]; then # \x not followed by hex digits is probably an error - style=$ZSH_HIGHLIGHT_STYLES[unknown-token] + style=unknown-token fi (( k += 1 )) # Color following char too. (( i += 1 )) # Skip parsing the escaped char. @@ -475,8 +1019,36 @@ _zsh_highlight_main_highlighter_highlight_dollar_string() *) continue ;; esac - _zsh_highlight_main_add_region_highlight $j $k $style + reply+=($j $k $style) done + + if [[ $arg[i] == "'" ]]; then + style=dollar-quoted-argument + else + # If unclosed, i points past the end + (( i-- )) + style=dollar-quoted-argument-unclosed + fi + reply=($(( start_pos + $1 - 1 )) $(( start_pos + i )) $style $reply) + REPLY=$i +} + +# Highlight backtick subshells +_zsh_highlight_main_highlighter_highlight_backtick() +{ + local arg1=$1 i=$1 q=\` style + reply=() + while i=$arg[(ib:i+1:)$q]; [[ $arg[i-1] == '\' && $i -lt $(( end_pos - start_pos )) ]]; do done + + if [[ $arg[i] == '`' ]]; then + style=back-quoted-argument + else + # If unclosed, i points past the end + (( i-- )) + style=back-quoted-argument-unclosed + fi + reply=($(( start_pos + arg1 - 1 )) $(( start_pos + i )) $style) + REPLY=$i } # Called with a single positional argument. @@ -485,10 +1057,29 @@ _zsh_highlight_main_highlighter_highlight_dollar_string() # Does not perform filename generation (globbing). _zsh_highlight_main_highlighter_expand_path() { - (( $# == 1 )) || echo "zsh-syntax-highlighting: BUG: _zsh_highlight_main_highlighter_expand_path: called without argument" >&2 + (( $# == 1 )) || print -r -- >&2 "zsh-syntax-highlighting: BUG: _zsh_highlight_main_highlighter_expand_path: called without argument" # The $~1 syntax normally performs filename generation, but not when it's on the right-hand side of ${x:=y}. setopt localoptions nonomatch unset REPLY - : ${REPLY:=${(Q)~1}} + : ${REPLY:=${(Q)${~1}}} } + +# ------------------------------------------------------------------------------------------------- +# Main highlighter initialization +# ------------------------------------------------------------------------------------------------- + +_zsh_highlight_main__precmd_hook() { + _zsh_highlight_main__command_type_cache=() +} + +autoload -Uz add-zsh-hook +if add-zsh-hook precmd _zsh_highlight_main__precmd_hook 2>/dev/null; then + # Initialize command type cache + typeset -gA _zsh_highlight_main__command_type_cache +else + print -r -- >&2 'zsh-syntax-highlighting: Failed to load add-zsh-hook. Some speed optimizations will not be used.' + # Make sure the cache is unset + unset _zsh_highlight_main__command_type_cache +fi +typeset -ga X_ZSH_HIGHLIGHT_DIRS_BLACKLIST diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/alias-assignment1.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/alias-assignment1.zsh new file mode 100644 index 0000000..0c101c8 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/alias-assignment1.zsh @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +# Issue #263 (more-pathological case): aliases[x=y]=z works; the ${(z)} splitter considers +# that a single word; but it's not looked up as an alias. Hence, highlight it as an error. +aliases[x=y]='lorem ipsum dolor sit amet' +BUFFER='x=y ls' + +expected_region_highlight=( + "1 3 unknown-token" # x=y + "5 6 default" # ls +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/alias.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/alias.zsh index aa84a58..fd867bf 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/alias.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/alias.zsh @@ -29,9 +29,11 @@ alias alias1="unused expansion" alias -s alias2="echo" +if set -o | grep -q aliasfuncdef; then + setopt alias_func_def # 5.4+ +fi alias1() {} # to check that it's highlighted as an alias, not as a function -ZSH_HIGHLIGHT_STYLES[alias]=$unused_highlight BUFFER='x.alias2; alias1' # Set expected_region_highlight as a function of zsh version. @@ -41,11 +43,12 @@ BUFFER='x.alias2; alias1' # functionality is present, and skip verifying suffix-alias highlighting # if it isn't. expected_region_highlight=() -if [[ "$(type -w x.alias2)" == *suffix* ]]; then +if zmodload -e zsh/parameter || [[ "$(type -w x.alias2)" == *suffix* ]]; then expected_region_highlight+=( - "1 8 $ZSH_HIGHLIGHT_STYLES[suffix-alias]" # x.alias2 + "1 8 suffix-alias" # x.alias2 ) fi expected_region_highlight+=( - "11 16 $ZSH_HIGHLIGHT_STYLES[alias]" # alias1 + "9 9 commandseparator" # ; + "11 16 alias" # alias1 ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/always1.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/always1.zsh new file mode 100644 index 0000000..ae40a72 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/always1.zsh @@ -0,0 +1,41 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='{ ls } always { pwd }' + +expected_region_highlight=( + '1 1 reserved-word' # { + '3 4 command' # ls + '6 6 reserved-word' # } + '8 13 reserved-word' # always + '15 15 reserved-word' # { + '17 19 builtin' # pwd + '21 21 reserved-word' # } +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/always2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/always2.zsh new file mode 100644 index 0000000..f5852c6 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/always2.zsh @@ -0,0 +1,43 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=$'{\nls\n} always { pwd }' + +expected_region_highlight=( + '1 1 reserved-word' # { + '2 2 unknown-token' # \n + '3 4 command' # ls + '5 5 commandseparator' # \n + '6 6 reserved-word' # } + '8 13 reserved-word' # always + '15 15 reserved-word' # { + '17 19 builtin' # pwd + '21 21 reserved-word' # } +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/always3.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/always3.zsh new file mode 100644 index 0000000..d41beeb --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/always3.zsh @@ -0,0 +1,43 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +setopt ignorebraces +BUFFER='echo { foo } always { bar }' + +expected_region_highlight=( + '1 4 builtin' # echo + '6 6 default' # { + '8 10 default' # foo + '12 12 default' # } + '14 19 default' # always + '21 21 default' # { + '23 25 default' # bar + '27 27 default' # } +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/anonymous-function.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/anonymous-function.zsh index 62714ed..9d67fb1 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/anonymous-function.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/anonymous-function.zsh @@ -27,14 +27,18 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -BUFFER='() echo hello; () { echo world }' +BUFFER='() echo hello; () { echo world } "argument"' expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # () - "4 7 $ZSH_HIGHLIGHT_STYLES[command]" # echo - "9 13 $ZSH_HIGHLIGHT_STYLES[default]" # hello - "14 14 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # ; - "16 17 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # () - "19 19 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # { - "21 24 $ZSH_HIGHLIGHT_STYLES[command]" # echo + "1 2 reserved-word" # () + "4 7 builtin" # echo + "9 13 default" # hello + "14 14 commandseparator" # ; + "16 17 reserved-word" # () + "19 19 reserved-word" # { + "21 24 builtin" # echo + "26 30 default" # world + "32 32 reserved-word" # } + "34 43 default" # "argument" + "34 43 double-quoted-argument" # "argument" ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/arg0-colon.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/arg0-colon.zsh new file mode 100644 index 0000000..8955bd2 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/arg0-colon.zsh @@ -0,0 +1,35 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=''\''x: /' + +expected_region_highlight=( + '1 5 unknown-token' # \'x: / +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/arithmetic-evaluation.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/arithmetic-evaluation.zsh index 9287e91..e0eb6e7 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/arithmetic-evaluation.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/arithmetic-evaluation.zsh @@ -35,6 +35,6 @@ BUFFER='(( x == 42 ))' expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # (( - "12 13 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # )) + "1 2 reserved-word" # (( + "12 13 reserved-word" # )) ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-append.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-append.zsh index a38cd86..eb9fbbd 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-append.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-append.zsh @@ -27,9 +27,11 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -ZSH_HIGHLIGHT_STYLES[assign]=$unused_highlight BUFFER='a+=(lorem ipsum)' expected_region_highlight=( - "1 4 $ZSH_HIGHLIGHT_STYLES[assign]" # a+=( + "1 4 assign" # a+=( + "5 9 default" # lorem + "11 15 default" # ipsum + "16 16 assign" # ) ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-argv.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-argv.zsh new file mode 100644 index 0000000..fdf30aa --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-argv.zsh @@ -0,0 +1,35 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='42=foo 43+=bar' + +expected_region_highlight=( + "1 6 assign" # 42=foo + "8 14 assign" # 43+=bar +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-array.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-array.zsh new file mode 100644 index 0000000..0624f9b --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-array.zsh @@ -0,0 +1,39 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2015 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='(A=(hello world))' + +expected_region_highlight=( + "1 1 reserved-word" # ( + "2 4 assign" # A=( + "5 9 default" # hello + "11 15 default" # world + "16 16 assign" # ) + "17 17 reserved-word" # ) +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-array2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-array2.zsh new file mode 100644 index 0000000..cdc9e63 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-array2.zsh @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='A=(hello world) ls' + +expected_region_highlight=( + "1 3 assign" # A=( + "4 8 default" # hello + "10 14 default" # world + "15 15 assign" # ) + "17 18 command" # ls +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-array3.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-array3.zsh new file mode 100644 index 0000000..4e20cfc --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-array3.zsh @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='A=(hello world) b=42' + +expected_region_highlight=( + "1 3 assign" # A=( + "4 8 default" # hello + "10 14 default" # world + "15 15 assign" # ) + "17 20 assign" # b=42 +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-semicolon.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-semicolon.zsh index c3692d4..fe55b6a 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-semicolon.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-semicolon.zsh @@ -27,10 +27,12 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -ZSH_HIGHLIGHT_STYLES[commandseparator]=$unused_highlight BUFFER='A=1; echo hello world' expected_region_highlight=( - "4 4 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # ; - "6 9 $ZSH_HIGHLIGHT_STYLES[command]" # echo + "1 3 assign" # A=1 + "4 4 commandseparator" # ; + "6 9 builtin" # echo + "11 15 default" # hello + "17 21 default" # world ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-subshell.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-subshell.zsh new file mode 100644 index 0000000..fc04f6b --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign-subshell.zsh @@ -0,0 +1,36 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2015 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='(A=1)' + +expected_region_highlight=( + "1 1 reserved-word" # ( + "2 4 assign" # A=1 + "5 5 reserved-word" # ) +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign.zsh index ef38668..36fa5d1 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/assign.zsh @@ -27,10 +27,13 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -ZSH_HIGHLIGHT_STYLES[assign]=$unused_highlight BUFFER='A=1 b=("foo" bar)' expected_region_highlight=( - "1 3 $ZSH_HIGHLIGHT_STYLES[assign]" # A=1 - "8 12 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "foo" + "1 3 assign" # A=1 + "5 7 assign" # b=( + "8 12 default" # "foo" + "8 12 double-quoted-argument" # "foo" + "14 16 default" # bar + "17 17 assign" # ) ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/back-quoted-argument.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/back-quoted-argument.zsh index 6dfba71..346d9fa 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/back-quoted-argument.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/back-quoted-argument.zsh @@ -27,9 +27,16 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=$unused_highlight -BUFFER='echo `echo 42`' +# 42 is in the command position in a nested subshell. +BUFFER='echo `echo \`42\`` "is `echo equal` to" `echo 6 times 9' expected_region_highlight=( - "6 14 $ZSH_HIGHLIGHT_STYLES[back-quoted-argument]" + "1 4 builtin" # echo + "6 18 default" # `echo \`42\`` + "6 18 back-quoted-argument" # `echo \`42\`` + "20 39 default" # "is `echo equal` to" + "20 39 double-quoted-argument" # "is `echo equal` to" + "24 35 back-quoted-argument" # `echo equal` + "41 55 default" # `echo 6 times 9 + "41 55 back-quoted-argument-unclosed" # `echo 6 times 9 ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/backslash-continuation.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/backslash-continuation.zsh index 9fbd916..ebcf2e1 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/backslash-continuation.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/backslash-continuation.zsh @@ -31,5 +31,5 @@ PREBUFFER=$'echo \\\n' BUFFER='noglob' expected_region_highlight=( - "1 6 none" # 'noglob' highlighted as a string, not as a precomand + "1 6 default" # 'noglob' highlighted as a string, not as a precomand ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/braces1.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/braces1.zsh new file mode 100644 index 0000000..3c5b1f0 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/braces1.zsh @@ -0,0 +1,41 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=$'() { echo }\n}' +# no special setopts + +expected_region_highlight=( + '1 2 reserved-word' # () + '4 4 reserved-word' # { + '6 9 builtin' # echo + '11 11 reserved-word' # } + '12 12 commandseparator' # \n + '13 13 unknown-token' # } +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/braces2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/braces2.zsh new file mode 100644 index 0000000..a3ea7c9 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/braces2.zsh @@ -0,0 +1,41 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=$'() { echo }\n}' +setopt ignorebraces + +expected_region_highlight=( + '1 2 reserved-word' # () + '4 4 reserved-word' # { + '6 9 builtin' # echo + '11 11 default' # } + '12 12 commandseparator' # \n + '13 13 reserved-word' # } +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch1.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch1.zsh new file mode 100644 index 0000000..5e6e80f --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch1.zsh @@ -0,0 +1,39 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='() { echo foo )' + +expected_region_highlight=( + '1 2 reserved-word' # () + '4 4 reserved-word' # { + '6 9 builtin' # echo + '11 13 default' # foo + '15 15 unknown-token' # ) +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch10-if-negative.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch10-if-negative.zsh new file mode 100644 index 0000000..9d0b53c --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch10-if-negative.zsh @@ -0,0 +1,42 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2017 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='elif true; then echo two; fi' + +expected_region_highlight=( + '1 4 unknown-token' # elif + '6 9 builtin' # true + '10 10 commandseparator' # ; + '12 15 unknown-token' # then + '17 20 builtin' # echo + '22 24 default' # two + '25 25 commandseparator' # ; + '27 28 unknown-token' # fi +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch2.zsh new file mode 100644 index 0000000..2d98ac2 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch2.zsh @@ -0,0 +1,39 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='() ( echo foo }' + +expected_region_highlight=( + '1 2 reserved-word' # () + '4 4 reserved-word' # ( + '6 9 builtin' # echo + '11 13 default' # foo + '15 15 unknown-token' # } +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch3.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch3.zsh new file mode 100644 index 0000000..e33040a --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch3.zsh @@ -0,0 +1,36 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='echo )' + +expected_region_highlight=( + '1 4 builtin' # echo + '6 6 unknown-token' # ) +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch4.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch4.zsh new file mode 100644 index 0000000..a9b15dc --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch4.zsh @@ -0,0 +1,36 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='echo }' + +expected_region_highlight=( + '1 4 builtin' # echo + '6 6 unknown-token' # } +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch5.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch5.zsh new file mode 100644 index 0000000..21e8bb2 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch5.zsh @@ -0,0 +1,37 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='echo { }' + +expected_region_highlight=( + '1 4 builtin' # echo + '6 6 default' # { + '8 8 unknown-token' # } +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch6.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch6.zsh new file mode 100644 index 0000000..9df8388 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch6.zsh @@ -0,0 +1,40 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='(repeat 1; do)' + +expected_region_highlight=( + '1 1 reserved-word' # ( + '2 7 reserved-word' # repeat + '9 9 default' # 1 + '10 10 commandseparator' # ; + '12 13 reserved-word' # do + '14 14 unknown-token' # ) +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch7.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch7.zsh new file mode 100644 index 0000000..1caa936 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch7.zsh @@ -0,0 +1,45 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2012 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='for n in *; do echo $n; end' + +expected_region_highlight=( + '1 3 reserved-word' # for + '5 5 default' # n + '7 8 default' # in + '10 10 default' # * + '10 10 globbing' # * + '11 11 commandseparator' # ; + '13 14 reserved-word' # do + '16 19 builtin' # echo + '21 22 default' # $n + '23 23 commandseparator' # ; + '25 27 unknown-token' # end +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch8-if-positive.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch8-if-positive.zsh new file mode 100644 index 0000000..d6838f0 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch8-if-positive.zsh @@ -0,0 +1,53 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2017 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='if false; then echo one; elif true; then echo two; else echo three; fi' + +expected_region_highlight=( + '1 2 reserved-word' # if + '4 8 builtin' # false + '9 9 commandseparator' # ; + '11 14 reserved-word' # then + '16 19 builtin' # echo + '21 23 default' # one + '24 24 commandseparator' # ; + '26 29 reserved-word' # elif + '31 34 builtin' # true + '35 35 commandseparator' # ; + '37 40 reserved-word' # then + '42 45 builtin' # echo + '47 49 default' # two + '50 50 commandseparator' # ; + '52 55 reserved-word' # else + '57 60 builtin' # echo + '62 66 default' # three + '67 67 commandseparator' # ; + '69 70 reserved-word' # fi +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch8.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch8.zsh new file mode 100644 index 0000000..07a42e3 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch8.zsh @@ -0,0 +1,38 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='(ls&)' + +expected_region_highlight=( + '1 1 reserved-word' # ( + '2 3 command' # ls + '4 4 commandseparator' # & + '5 5 reserved-word' # ) +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch9-if-positive.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch9-if-positive.zsh new file mode 100644 index 0000000..87c1ba7 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/brackets-mismatch9-if-positive.zsh @@ -0,0 +1,42 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2017 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='if false; then echo one; fi' + +expected_region_highlight=( + '1 2 reserved-word' # if + '4 8 builtin' # false + '9 9 commandseparator' # ; + '11 14 reserved-word' # then + '16 19 builtin' # echo + '21 23 default' # one + '24 24 commandseparator' # ; + '26 27 reserved-word' # fi +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/commandseparator.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/commandseparator.zsh index 383bd47..f504847 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/commandseparator.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/commandseparator.zsh @@ -27,11 +27,12 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -ZSH_HIGHLIGHT_STYLES[commandseparator]=$unused_highlight - -BUFFER=':; pwd' +BUFFER=':; pwd &! ls' expected_region_highlight=( - "2 2 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # ; - "4 6 $ZSH_HIGHLIGHT_STYLES[builtin]" # pwd + "1 1 builtin" # : + "2 2 commandseparator" # ; + "4 6 builtin" # pwd + "8 9 commandseparator" # &! + "11 12 command" # ls ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/comment-followed.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/comment-followed.zsh new file mode 100644 index 0000000..8c7e42c --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/comment-followed.zsh @@ -0,0 +1,38 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +setopt interactivecomments +BUFFER=$'# foo\ntrue' + +expected_region_highlight=( + '1 5 comment' # # foo + '6 6 commandseparator "issue #501"' # \n + '7 10 builtin' # true +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/comment-leading.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/comment-leading.zsh index a30af8b..b4c9910 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/comment-leading.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/comment-leading.zsh @@ -1,6 +1,5 @@ -#!/usr/bin/env zsh # ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors +# Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted @@ -33,6 +32,5 @@ setopt interactive_comments BUFFER='# echo foo' expected_region_highlight=( - "1 1 ${(q-)ZSH_HIGHLIGHT_STYLES[comment]}" # # - "2 10 ${(q-)ZSH_HIGHLIGHT_STYLES[comment]}" # " echo foo" + "1 10 comment" # # echo foo ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/comment-off.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/comment-off.zsh index 5aa16af..0381bdb 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/comment-off.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/comment-off.zsh @@ -1,6 +1,5 @@ -#!/usr/bin/env zsh # ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors +# Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted @@ -33,7 +32,7 @@ unsetopt interactive_comments BUFFER='# echo foo' expected_region_highlight=( - "1 1 ${(q-)ZSH_HIGHLIGHT_STYLES[unknown-token]}" # # - "3 6 ${(q-)ZSH_HIGHLIGHT_STYLES[default]}" # " echo foo" - "8 10 ${(q-)ZSH_HIGHLIGHT_STYLES[default]}" # " echo foo" + "1 1 unknown-token" # # + "3 6 default" # " echo foo" + "8 10 default" # " echo foo" ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/comments.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/comments.zsh index 4b9c974..f3cc57e 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/comments.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/comments.zsh @@ -1,6 +1,5 @@ -#!/usr/bin/env zsh # ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors +# Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted @@ -33,7 +32,8 @@ setopt interactive_comments BUFFER='echo "foo #bar" #baz # quux' expected_region_highlight=( - "1 4 $ZSH_HIGHLIGHT_STYLES[command]" # echo - "6 15 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "foo #bar" - "17 27 ${(q-)ZSH_HIGHLIGHT_STYLES[comment]}" # #baz # quux + "1 4 builtin" # echo + "6 15 default" # "foo #bar" + "6 15 double-quoted-argument" # "foo #bar" + "17 27 comment" # #baz # quux ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/commmand-parameter.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/commmand-parameter.zsh new file mode 100644 index 0000000..07dfc4c --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/commmand-parameter.zsh @@ -0,0 +1,37 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2015 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +local x=/usr/bin/env +BUFFER='$x "argument"' + +expected_region_highlight=( + "1 2 command" # $x + "4 13 default" # "argument" + "4 13 double-quoted-argument" # "argument" +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/control-flow.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/control-flow.zsh index 3107f50..a610bdc 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/control-flow.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/control-flow.zsh @@ -27,25 +27,31 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -ZSH_HIGHLIGHT_STYLES[alias]=$unused_highlight BUFFER='while if echo Hello; then ls /; else ls; fi; do stat "x"; done; repeat 10 ls' expected_region_highlight+=( - "1 5 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # while - "7 8 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # if - "10 13 $ZSH_HIGHLIGHT_STYLES[builtin]" # echo - "15 19 $ZSH_HIGHLIGHT_STYLES[default]" # Hello - "22 25 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # then - "27 28 $ZSH_HIGHLIGHT_STYLES[command]" # ls - "30 30 $ZSH_HIGHLIGHT_STYLES[path]" # / - "31 31 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # ; - "33 36 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # else - "38 39 $ZSH_HIGHLIGHT_STYLES[command]" # ls - "42 43 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # fi - "46 47 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # do - "49 52 $ZSH_HIGHLIGHT_STYLES[command]" # stat - "54 56 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "x" - "59 62 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # done - "65 70 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # repeat - "75 76 $ZSH_HIGHLIGHT_STYLES[command]" # ls + "1 5 reserved-word" # while + "7 8 reserved-word" # if + "10 13 builtin" # echo + "15 19 default" # Hello + "20 20 commandseparator" # ; + "22 25 reserved-word" # then + "27 28 command" # ls + "30 30 path" # / + "31 31 commandseparator" # ; + "33 36 reserved-word" # else + "38 39 command" # ls + "40 40 commandseparator" # ; + "42 43 reserved-word" # fi + "44 44 commandseparator" # ; + "46 47 reserved-word" # do + "49 52 command" # stat + "54 56 default" # "x" + "54 56 double-quoted-argument" # "x" + "57 57 commandseparator" # ; + "59 62 reserved-word" # done + "63 63 commandseparator" # ; + "65 70 reserved-word" # repeat + "72 73 default" # 10 + "75 76 command" # ls ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/control-flow2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/control-flow2.zsh new file mode 100644 index 0000000..acf99e1 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/control-flow2.zsh @@ -0,0 +1,40 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='repeat 42; do ls; done' + +expected_region_highlight+=( + "1 6 reserved-word" # repeat + "8 9 default" # 42 + "10 10 commandseparator" # ; + "12 13 reserved-word" # do + "15 16 command" # ls + "17 17 commandseparator" # ; + "19 22 reserved-word" # done +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/control-flow3.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/control-flow3.zsh new file mode 100644 index 0000000..58f507f --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/control-flow3.zsh @@ -0,0 +1,39 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='repeat 42; ls; pwd' + +expected_region_highlight+=( + "1 6 reserved-word" # repeat + "8 9 default" # 42 + "10 10 commandseparator" # ; + "12 13 command" # ls + "14 14 commandseparator" # ; + "16 18 builtin" # pwd +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dirs_blacklist.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dirs_blacklist.zsh new file mode 100644 index 0000000..0d4d666 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dirs_blacklist.zsh @@ -0,0 +1,40 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2018 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +mkdir foo +touch foo/bar +BUFFER=": foo/bar $PWD/foo foo/b" +X_ZSH_HIGHLIGHT_DIRS_BLACKLIST=($PWD/foo) + +expected_region_highlight=( + '1 1 builtin' # : + '3 9 path' # foo/bar + "11 $(( 14 + $#PWD )) path" # $PWD/foo + "$(( 16 + $#PWD )) $(( 20 + $#PWD )) default" # foo/b +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-dollar.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-dollar.zsh new file mode 100644 index 0000000..e3f387c --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-dollar.zsh @@ -0,0 +1,39 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=': "$$ $$foo"' + +expected_region_highlight=( + '1 1 builtin' # : + '3 12 default' # "$$ $$foo" + '3 12 double-quoted-argument' # "$$ $$foo" + '4 5 dollar-double-quoted-argument' # $$ + '7 8 dollar-double-quoted-argument' # $$ +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-noise.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-noise.zsh new file mode 100644 index 0000000..9bb11bd --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-noise.zsh @@ -0,0 +1,42 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=': "$- $# $* $@ $?"' + +expected_region_highlight=( + '1 1 builtin' # : + '3 18 default' # "$- $# $* $@ $?" + '3 18 double-quoted-argument' # "$- $# $* $@ $?" + '4 5 dollar-double-quoted-argument' # $- + '7 8 dollar-double-quoted-argument' # $# + '10 11 dollar-double-quoted-argument' # $* + '13 14 dollar-double-quoted-argument' # $@ + '16 17 dollar-double-quoted-argument' # $? +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-paren.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-paren.zsh new file mode 100644 index 0000000..2a1aecd --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-paren.zsh @@ -0,0 +1,38 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=': "$(:)"' + +expected_region_highlight=( + '1 1 builtin' # : + '3 8 default' # "$(:)" + '3 8 double-quoted-argument' # "$(:)" + '4 4 dollar-double-quoted-argument' # $ +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-quoted.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-quoted.zsh index ea12f9f..081a365 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-quoted.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-quoted.zsh @@ -27,10 +27,12 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]=$unused_highlight BUFFER=": \$'*' 'foo'" expected_region_highlight=( - "3 6 $ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]" # $'*' - not a glob - "8 12 $ZSH_HIGHLIGHT_STYLES[single-quoted-argument]" # 'foo' + "1 1 builtin" # : + "3 6 default" # $'*' + "3 6 dollar-quoted-argument" # $'*' - not a glob + "8 12 default" # 'foo' + "8 12 single-quoted-argument" # 'foo' ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-quoted2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-quoted2.zsh index 1ce9bb4..ed7428b 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-quoted2.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-quoted2.zsh @@ -27,15 +27,13 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]=$unused_highlight BUFFER=": \$'foo\xbar\udeadbeef\uzzzz'" expected_region_highlight=( - "3 7 $ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]" # $'foo - "8 11 $ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]" # \xba - "12 12 $ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]" # r - "13 18 $ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]" # \dead - "19 22 $ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]" # beef - "23 24 $ZSH_HIGHLIGHT_STYLES[unknown-token]" # \u - "25 29 $ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]" # zzzz' + "1 1 builtin" # : + "3 29 default" # $'foo\xbar\udeadbeef\uzzzz' + "3 29 dollar-quoted-argument" # $'foo\xbar\udeadbeef\uzzzz' + "8 11 back-dollar-quoted-argument" # \xba + "13 18 back-dollar-quoted-argument" # \dead + "23 24 unknown-token" # \u ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-quoted3.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-quoted3.zsh index 53ee171..365f351 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-quoted3.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/dollar-quoted3.zsh @@ -28,11 +28,12 @@ # ------------------------------------------------------------------------------------------------- # Similar to double-quoted2.zsh -ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]=$unused_highlight # This test checks that the '1' gets highlighted correctly. Do not append to the BUFFER. BUFFER=": \$'\xa1" expected_region_highlight=( - "3 4 $ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]" # $' - "5 8 $ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]" # \xa1 + "1 1 builtin" # : + "3 8 default" # $'\xa1 + "3 8 dollar-quoted-argument-unclosed" # $'\xa1 + "5 8 back-dollar-quoted-argument" # \xa1 ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-hyphen-option.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-hyphen-option.zsh index b87ebe8..e5cacd3 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-hyphen-option.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-hyphen-option.zsh @@ -27,9 +27,9 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=$unused_highlight BUFFER='hello --world' expected_region_highlight=( - "7 13 $ZSH_HIGHLIGHT_STYLES[double-hyphen-option]" # --world + "1 5 unknown-token" # hello + "7 13 double-hyphen-option" # --world ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-quoted.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-quoted.zsh index 3f80f9e..0a4336c 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-quoted.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-quoted.zsh @@ -31,15 +31,12 @@ BUFFER=': "foo$bar:\`:\":\$:' BUFFER+=\\\\:\" expected_region_highlight=( - "3 6 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "foo - "7 10 $ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]" # $bar - "11 11 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # : - "12 13 $ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]" # \` - "14 14 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # : - "15 16 $ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]" # \$ - "17 17 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # : - "18 19 $ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]" # \" - "20 20 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # : - "21 22 $ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]" # \\ - "23 24 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # :" + "1 1 builtin" # : + "3 24 default" # "foo$bar:\`:\":\$:\\:" + "3 24 double-quoted-argument" # "foo$bar:\`:\":\$:\\:" + "7 10 dollar-double-quoted-argument" # $bar + "12 13 back-double-quoted-argument" # \` + "15 16 back-double-quoted-argument" # \$ + "18 19 back-double-quoted-argument" # \" + "21 22 back-double-quoted-argument" # \\ ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-quoted2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-quoted2.zsh index d3facb2..c400e54 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-quoted2.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-quoted2.zsh @@ -1,5 +1,5 @@ # ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors +# Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted @@ -32,6 +32,8 @@ BUFFER=': "foo$bar' expected_region_highlight=( - "3 6 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "foo - "7 10 $ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]" # $bar + "1 1 builtin" # : + "3 10 default" # "foo$bar + "3 10 double-quoted-argument-unclosed" # "foo$bar + "7 10 dollar-double-quoted-argument" # $bar ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-quoted3.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-quoted3.zsh index 6b9001c..86e3ced 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-quoted3.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-quoted3.zsh @@ -1,5 +1,5 @@ # ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors +# Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted @@ -31,9 +31,12 @@ BUFFER=': "$" "$42foo"' BUFFER+=\ \"\\\'\\x\" expected_region_highlight=( - "3 5 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "$" - "7 7 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # " - "8 10 $ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]" # $42 - "11 14 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # foo" - "16 21 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "\'\x" - \' and \x are not escape sequences + "1 1 builtin" # : + "3 5 default" # "$" + "3 5 double-quoted-argument" # "$" + "7 14 default" # "$42foo" + "7 14 double-quoted-argument" # "$42foo" + "8 10 dollar-double-quoted-argument" # $42 + "16 21 default" # "\'\x" + "16 21 double-quoted-argument" # "\'\x" - \' and \x are not escape sequences ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-quoted4.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-quoted4.zsh new file mode 100644 index 0000000..c59d5d8 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/double-quoted4.zsh @@ -0,0 +1,37 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2015 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=': "${foo}bar"' + +expected_region_highlight=( + "1 1 builtin" # : + "3 13 default" # "${foo}bar" + "3 13 double-quoted-argument" # "${foo}bar" + "4 9 dollar-double-quoted-argument" # ${foo} +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/empty-command.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/empty-command.zsh index 9e4b13f..5831464 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/empty-command.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/empty-command.zsh @@ -30,6 +30,7 @@ BUFFER='echo; ;' expected_region_highlight=( - "5 5 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # ; - "7 7 $ZSH_HIGHLIGHT_STYLES[unknown-token]" # ; + "1 4 builtin" # echo + "5 5 commandseparator" # ; + "7 7 unknown-token" # ; ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/empty-command2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/empty-command2.zsh new file mode 100644 index 0000000..dcb4e6f --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/empty-command2.zsh @@ -0,0 +1,39 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2015 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +# Same test data and expectations as empty-command.zsh; the only difference is: +touch ';' + +BUFFER='echo; ;' + +expected_region_highlight=( + "1 4 builtin" # echo + "5 5 commandseparator" # ; + "7 7 unknown-token" # ; +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/escaped-single-quote.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/escaped-single-quote.zsh new file mode 100644 index 0000000..4b2fe4b --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/escaped-single-quote.zsh @@ -0,0 +1,38 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2018 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=$': \'foo\'\\\'\'bar\'' # <<<: 'foo'\''bar'>>> + +expected_region_highlight=( + '1 1 builtin' # : + '3 14 default' # 'foo'\''bar' + '3 7 single-quoted-argument' # 'foo' + '10 14 single-quoted-argument' # 'bar' +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/exec-redirection1.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/exec-redirection1.zsh new file mode 100644 index 0000000..caec2f1 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/exec-redirection1.zsh @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2015 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='exec {foo}>&/tmp ls' + +expected_region_highlight=( + "1 4 precommand" # exec + "6 10 redirection 'issue #238'" # {foo} + "11 12 redirection" # >& + "13 16 path" # /tmp + "18 19 command 'issue #238'" # ls +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/function-named1.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/function-named1.zsh new file mode 100644 index 0000000..c962ddb --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/function-named1.zsh @@ -0,0 +1,44 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='f() pwd; f() { balanced braces }' + +expected_region_highlight=( + '1 1 TBD "issue #223"' # f + '2 3 reserved-word' # () + '5 7 builtin' # pwd + '8 8 commandseparator' # ; + '10 10 TBD "issue #223"' # f + '11 12 reserved-word' # () + '14 14 reserved-word' # { + '16 23 unknown-token' # balanced + '25 30 default' # braces + '32 32 reserved-word' # } +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/function-named2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/function-named2.zsh new file mode 100644 index 0000000..e12fce6 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/function-named2.zsh @@ -0,0 +1,39 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='f g h () pwd' + +expected_region_highlight=( + '1 1 TBD "issue #223"' # f + '3 3 TBD "issue #223"' # g + '5 5 TBD "issue #223"' # h + '7 8 reserved-word' # () + '10 12 builtin' # pwd +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/function.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/function.zsh index 3e579ab..b1be853 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/function.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/function.zsh @@ -27,7 +27,6 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -ZSH_HIGHLIGHT_STYLES[function]=$unused_highlight cd() { builtin cd "$@" } @@ -36,12 +35,8 @@ ls() { } BUFFER='cd;ls' -# Use $unused_highlight to see that function highlighting has precedence over command and builtin - expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[function]" # cd - "4 5 $ZSH_HIGHLIGHT_STYLES[function]" # ls + "1 2 function" # cd + "3 3 commandseparator" # ; + "4 5 function" # ls ) - -# don't 'unfunction cd ls', since cd() and ls() should still be a functions -# when _zsh_highlight runs. Leaving the wrapper functions is harmless. diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/glob.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/glob.zsh index d808e2b..2ff1022 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/glob.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/glob.zsh @@ -30,9 +30,12 @@ BUFFER=': foo* bar? *baz qux\?' expected_region_highlight=( - "1 1 $ZSH_HIGHLIGHT_STYLES[builtin]" # : - "3 6 $ZSH_HIGHLIGHT_STYLES[globbing]" # foo* - "8 11 $ZSH_HIGHLIGHT_STYLES[globbing]" # bar? - "13 16 $ZSH_HIGHLIGHT_STYLES[globbing]" # *baz - "18 22 $ZSH_HIGHLIGHT_STYLES[default]" # qux\? + "1 1 builtin" # : + "3 6 default" # foo* + "6 6 globbing" # * + "8 11 default" # bar? + "11 11 globbing" # ? + "13 16 default" # *baz + "13 13 globbing" # * + "18 22 default" # qux\? ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/globs-with-quoting.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/globs-with-quoting.zsh new file mode 100644 index 0000000..d7d74bc --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/globs-with-quoting.zsh @@ -0,0 +1,43 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2018 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=$': "foo"*\'bar\'?"baz?"<17-29>"qu*ux"' + +expected_region_highlight=( + '1 1 builtin' # : + '3 34 default' # "foo"*'bar'?"baz?"<17-29>"qu*ux" + '3 7 double-quoted-argument' # "foo" + '8 8 globbing' # * + '9 13 single-quoted-argument' # 'bar' + '14 14 globbing' # ? + '15 20 double-quoted-argument' # "baz?" + '21 27 globbing' # <17-29> + '28 34 double-quoted-argument' # "qu*ux" +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/hashed-command.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/hashed-command.zsh index ce41b45..2983ef8 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/hashed-command.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/hashed-command.zsh @@ -28,9 +28,8 @@ # ------------------------------------------------------------------------------------------------- hash zsh_syntax_highlighting_hash=/doesnotexist -ZSH_HIGHLIGHT_STYLES[hashed-command]=$unused_highlight BUFFER='zsh_syntax_highlighting_hash' expected_region_highlight=( - "1 28 $ZSH_HIGHLIGHT_STYLES[hashed-command]" + "1 28 hashed-command 'zsh/parameter cannot distinguish between hashed and command'" ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-double-quoted-escaped.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-double-quoted-escaped.zsh new file mode 100644 index 0000000..7807cc0 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-double-quoted-escaped.zsh @@ -0,0 +1,38 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='echo "Hello\!"' + +expected_region_highlight=( + '1 4 builtin' # echo + '6 14 default' # "Hello\!" + '6 14 double-quoted-argument' # "Hello\!" + '12 13 back-double-quoted-argument' # \! +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-double-quoted-no.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-double-quoted-no.zsh new file mode 100644 index 0000000..e082dbc --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-double-quoted-no.zsh @@ -0,0 +1,37 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='echo "foo != bar !{baz}"' + +expected_region_highlight=( + '1 4 builtin' # echo + '6 24 default' # "foo != bar !{baz}" + '6 24 double-quoted-argument' # "foo != bar !{baz}" - no history expansions +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-double-quoted-unescaped.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-double-quoted-unescaped.zsh new file mode 100644 index 0000000..cfe6a11 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-double-quoted-unescaped.zsh @@ -0,0 +1,38 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='echo "Hello!"' + +expected_region_highlight=( + '1 4 builtin' # echo + '6 13 default' # "Hello!" + '6 13 double-quoted-argument' # "Hello!" + '12 12 history-expansion' # ! +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-double-quoted-yes.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-double-quoted-yes.zsh new file mode 100644 index 0000000..e963c3b --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-double-quoted-yes.zsh @@ -0,0 +1,38 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='echo "foo !bar"' + +expected_region_highlight=( + '1 4 builtin' # echo + '6 15 default' # "foo !bar" + '6 15 double-quoted-argument' # "foo !bar" + '11 11 history-expansion' # ! +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-expansion.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-expansion.zsh index c670312..05e20fc 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-expansion.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-expansion.zsh @@ -27,10 +27,13 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -BUFFER='!foo bar !baz' +BUFFER='!foo bar !baz ! ; !' expected_region_highlight=( - "1 4 $ZSH_HIGHLIGHT_STYLES[history-expansion]" # !foo - "6 8 $ZSH_HIGHLIGHT_STYLES[default]" # bar - "10 13 $ZSH_HIGHLIGHT_STYLES[history-expansion]" # !baz + "1 4 history-expansion" # !foo + "6 8 default" # bar + "10 13 history-expansion" # !baz + "15 15 default" # ! + "17 17 commandseparator" # ; + "19 19 reserved-word" # ! ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-expansion2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-expansion2.zsh index 45af624..386d0df 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-expansion2.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/history-expansion2.zsh @@ -30,5 +30,5 @@ BUFFER='^foo^bar' expected_region_highlight=( - "1 8 $ZSH_HIGHLIGHT_STYLES[history-expansion]" # ^foo^bar + "1 8 history-expansion" # ^foo^bar ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/inheritance.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/inheritance.zsh new file mode 100644 index 0000000..e851ca3 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/inheritance.zsh @@ -0,0 +1,40 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +_zsh_highlight_add_highlight() +{ + region_highlight+=("$1 $2 ${(j.,.)argv[3,-1]}") +} + +BUFFER='type' + +expected_region_highlight=( + '1 4 builtin,arg0' # type +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiline-array-assignment1.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiline-array-assignment1.zsh new file mode 100644 index 0000000..3734c7a --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiline-array-assignment1.zsh @@ -0,0 +1,39 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=$'foo=(\nbar) env' + +expected_region_highlight=( + '1 5 assign' # foo=( + '6 6 commandseparator' # \n + '7 9 default' # bar + '10 10 assign' # ) + '12 14 command' # env +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiline-string.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiline-string.zsh index 987dd20..0127b4b 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiline-string.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiline-string.zsh @@ -31,6 +31,7 @@ PREBUFFER=$'echo "foo1\n' BUFFER='foo2" ./' expected_region_highlight=( - "1 5 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # 'foo2"' - "7 8 $ZSH_HIGHLIGHT_STYLES[path]" # './' + "1 5 default" # 'foo2"' + "1 5 double-quoted-argument" # 'foo2"' + "7 8 path" # './' ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiline-string2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiline-string2.zsh index 9753e5d..3a90dce 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiline-string2.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiline-string2.zsh @@ -27,9 +27,10 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=$unused_highlight -BUFFER=$'echo "foo1\n' +BUFFER=$'echo \'foo1\n' expected_region_highlight=( - "6 10 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # 'foo2"' + "1 4 builtin" # echo + "6 11 default" # 'foo1\n + "6 11 single-quoted-argument-unclosed" # 'foo1\n ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiple-quotes.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiple-quotes.zsh new file mode 100644 index 0000000..dabf70c --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiple-quotes.zsh @@ -0,0 +1,42 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2017 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=$': \'foo\'bar"baz$quux/foo\\\\bar"baz$\'quux\\nfoo\\001bar\'baz' + +expected_region_highlight=( + "1 1 builtin" # : + "3 54 default" # 'foo'bar"baz$quux/foo\\bar"baz$'quux\nfoo\001'baz + "3 7 single-quoted-argument" # 'foo' + "11 29 double-quoted-argument" #"baz + "15 19 dollar-double-quoted-argument" # $quux + "24 25 back-double-quoted-argument" # \\ + "33 51 dollar-quoted-argument" # $'quux\nfoo\001bar' + "39 40 back-dollar-quoted-argument" # \n + "44 47 back-dollar-quoted-argument" # \001 +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiple-redirections.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiple-redirections.zsh index 374de8a..778e712 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiple-redirections.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/multiple-redirections.zsh @@ -30,17 +30,17 @@ BUFFER='ps aux | grep java | sort | uniq | tail | head' expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ps - "4 6 $ZSH_HIGHLIGHT_STYLES[default]" # aux - "8 8 $ZSH_HIGHLIGHT_STYLES[default]" # | - "10 13 $ZSH_HIGHLIGHT_STYLES[command]" # grep - "15 18 $ZSH_HIGHLIGHT_STYLES[default]" # java - "20 20 $ZSH_HIGHLIGHT_STYLES[default]" # | - "22 25 $ZSH_HIGHLIGHT_STYLES[command]" # sort - "27 27 $ZSH_HIGHLIGHT_STYLES[default]" # | - "29 32 $ZSH_HIGHLIGHT_STYLES[command]" # uniq - "34 34 $ZSH_HIGHLIGHT_STYLES[default]" # | - "36 39 $ZSH_HIGHLIGHT_STYLES[command]" # tail - "41 41 $ZSH_HIGHLIGHT_STYLES[default]" # | - "43 46 $ZSH_HIGHLIGHT_STYLES[command]" # head + "1 2 command" # ps + "4 6 default" # aux + "8 8 commandseparator" # | + "10 13 command" # grep + "15 18 default" # java + "20 20 commandseparator" # | + "22 25 command" # sort + "27 27 commandseparator" # | + "29 32 command" # uniq + "34 34 commandseparator" # | + "36 39 command" # tail + "41 41 commandseparator" # | + "43 46 command" # head ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/noglob-alias.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/noglob-alias.zsh index 44d253a..2f96445 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/noglob-alias.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/noglob-alias.zsh @@ -31,5 +31,6 @@ alias x=command BUFFER='x ls' expected_region_highlight=( - "3 4 $ZSH_HIGHLIGHT_STYLES[command]" # ls + "1 1 alias" # x + "3 4 command" # ls ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/noglob1.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/noglob1.zsh index d9bc69b..1857db0 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/noglob1.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/noglob1.zsh @@ -30,5 +30,9 @@ BUFFER=':; noglob echo *' expected_region_highlight=( - "16 16 $ZSH_HIGHLIGHT_STYLES[default]" # * + "1 1 builtin" # : + "2 2 commandseparator" # ; + "4 9 precommand" # noglob + "11 14 builtin" # echo + "16 16 default" # * ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/noglob2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/noglob2.zsh index 2c19250..3b4fcd7 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/noglob2.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/noglob2.zsh @@ -30,6 +30,11 @@ BUFFER='noglob echo *; echo *' expected_region_highlight=( - "13 13 $ZSH_HIGHLIGHT_STYLES[default]" # * - "21 21 $ZSH_HIGHLIGHT_STYLES[globbing]" # * + "1 6 precommand" # noglob + "8 11 builtin" # echo + "13 13 default" # * + "14 14 commandseparator" # ; + "16 19 builtin" # echo + "21 21 default" # * + "21 21 globbing" # * ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/noglob3.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/noglob3.zsh new file mode 100644 index 0000000..c404aaa --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/noglob3.zsh @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2018 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +touch \* + +BUFFER='noglob echo *' + +expected_region_highlight=( + "1 6 precommand" # noglob + "8 11 builtin" # echo + "13 13 path" # * +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/number_range-glob.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/number_range-glob.zsh new file mode 100644 index 0000000..c840951 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/number_range-glob.zsh @@ -0,0 +1,42 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2017 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='print <-> x<->y ' + +expected_region_highlight=( + '1 5 builtin' # print + '7 9 default' # <-> + '7 9 globbing' # <-> + '11 15 default' # x<->y + '12 14 globbing' # <-> + '17 17 redirection' # < + '18 23 default' # foo2-3 (the filename) + '24 24 redirection' # > +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/off-by-one.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/off-by-one.zsh new file mode 100644 index 0000000..550c09f --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/off-by-one.zsh @@ -0,0 +1,40 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +alias a=A +f() {} + +BUFFER='a;f;' + +expected_region_highlight=( + "1 1 alias" # f + "2 2 commandseparator" # ; + "3 3 function" # g + "4 4 commandseparator" # ; +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/option-path_dirs.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/option-path_dirs.zsh new file mode 100644 index 0000000..0300c7e --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/option-path_dirs.zsh @@ -0,0 +1,44 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2015 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +if [[ $OSTYPE == msys ]]; then + skip_test='Cannot chmod +x in msys2' +else + setopt PATH_DIRS + mkdir -p foo/bar + touch foo/bar/testing-issue-228 + chmod +x foo/bar/testing-issue-228 + path+=( "$PWD"/foo ) + + BUFFER='bar/testing-issue-228' + + expected_region_highlight=( + "1 21 command" # bar/testing-issue-228 + ) +fi diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/option-with-quotes.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/option-with-quotes.zsh new file mode 100644 index 0000000..6286f03 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/option-with-quotes.zsh @@ -0,0 +1,37 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2018 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=$': --user="phy1729"' + +expected_region_highlight=( + '1 1 builtin' # : + '3 18 double-hyphen-option' # --user="phy1729" + '10 18 double-quoted-argument' # "phy1729" +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/order-path-after-dollar.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/order-path-after-dollar.zsh new file mode 100644 index 0000000..773c183 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/order-path-after-dollar.zsh @@ -0,0 +1,38 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2018 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +touch '$foo' +BUFFER=': $foo \$foo' + +expected_region_highlight=( + '1 1 builtin' # : + '3 6 default' # $foo - if we add a "unquoted parameter expansion" style then this expectation should change + '8 12 path' # \$foo +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/order-path-before-globbing.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/order-path-before-globbing.zsh new file mode 100644 index 0000000..8456b18 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/order-path-before-globbing.zsh @@ -0,0 +1,39 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2017 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +touch '*' +BUFFER=': * \*' + +expected_region_highlight=( + '1 1 builtin' # : + '3 3 default' # * + '3 3 globbing' # * + '5 6 path' # \* +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/parameter-star.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/parameter-star.zsh new file mode 100644 index 0000000..2311be0 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/parameter-star.zsh @@ -0,0 +1,40 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2017 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='() { : $* }' + +# This tests that $* isn't highlighted as a glob. +# If we ever add a "unquoted parameter" style, the expectation may change. +expected_region_highlight=( + "1 2 reserved-word" # () + "4 4 reserved-word" # { + "6 6 builtin" # : + "8 9 default" # $* + "11 11 reserved-word" # } +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-broken-symlink.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-broken-symlink.zsh new file mode 100644 index 0000000..baebee3 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-broken-symlink.zsh @@ -0,0 +1,41 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +if [[ $OSTYPE == msys ]]; then + skip_test='Cannot create symlinks in msys2' +else + ln -s /nonexistent broken-symlink + BUFFER=': broken-symlink' + CURSOR=5 # to make path_prefix ineligible + + expected_region_highlight=( + "1 1 builtin" # : + "3 16 path" # broken-symlink + ) +fi diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-dollared-word.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-dollared-word.zsh new file mode 100644 index 0000000..99055da --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-dollared-word.zsh @@ -0,0 +1,45 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +if [[ $OSTYPE == msys ]]; then + skip_test='Cannot chmod +x in msys2' # cargo culted from option-path_dirs.zsh +else + mkdir kappa + touch kappa.exe + chmod +x kappa.exe + cd kappa + + BUFFER='$PWD.exe; ${PWD}.exe' + + expected_region_highlight=( + "1 8 unknown-token" # $PWD.exe - not eval'd; issue #328 + "9 9 commandseparator" # ; + "11 20 unknown-token" # ${PWD}.exe + ) +fi diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-dollared-word2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-dollared-word2.zsh new file mode 100644 index 0000000..f404d5d --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-dollared-word2.zsh @@ -0,0 +1,37 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +local lambda="''" +touch \$lambda +BUFFER=': \$lambda' + +expected_region_highlight=( + "1 1 builtin" # : + "3 10 path" # \$lambda +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-dollared-word3.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-dollared-word3.zsh new file mode 100644 index 0000000..a9a5fa3 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-dollared-word3.zsh @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +# «/usr» at this point would be highlighted as path_prefix; so should +# a parameter that expands to an equivalent string be highlighted. +BUFFER='$PWD; ${PWD}' + +expected_region_highlight=( + "1 4 unknown-token" # $PWD - not eval'd; issue #328 + "5 5 commandseparator" # ; + "7 12 unknown-token" # ${PWD} +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-dollared-word4.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-dollared-word4.zsh new file mode 100644 index 0000000..e29182c --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-dollared-word4.zsh @@ -0,0 +1,36 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +# This tests for a regression during development of issue #328: an interim version +# of that branch failed that test with "Bail out! output on stderr". +BUFFER='${' + +expected_region_highlight=( + "1 2 unknown-token" # ${ +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-separators.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-separators.zsh new file mode 100644 index 0000000..52749b7 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-separators.zsh @@ -0,0 +1,53 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +# ZSH_HIGHLIGHT_STYLES is empty in tests. The path-separator code however compares its values. +# Make sure the relevant ones are set to something. +ZSH_HIGHLIGHT_STYLES[path_pathseparator]=set +ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]=set + +mkdir A +touch A/mu +BUFFER='ls /bin/ / A/mu A/m' + +expected_region_highlight=( + "1 2 command" # ls + "4 8 path" # /bin/ + "4 4 path_pathseparator" # / + "8 8 path_pathseparator" # / + + "10 10 path" # / + "10 10 path_pathseparator" # / + + "12 15 path" # A/mu + "13 13 path_pathseparator" # / + + "17 19 path_prefix" # A/m + "18 18 path_prefix_pathseparator" # / +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-separators2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-separators2.zsh new file mode 100644 index 0000000..bc885a0 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-separators2.zsh @@ -0,0 +1,40 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +# ZSH_HIGHLIGHT_STYLES is empty in tests. The path-separator code however compares its values. +# For this test, make sure both these styles are set and identical: +ZSH_HIGHLIGHT_STYLES[path]=value +ZSH_HIGHLIGHT_STYLES[path_pathseparator]=value + +BUFFER='ls /bin/' + +expected_region_highlight=( + "1 2 command" # ls + "4 8 path" # /bin/ +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-space- .zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-space.zsh similarity index 91% rename from .zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-space- .zsh rename to .zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-space.zsh index f6b889e..87cc22f 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-space- .zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-space.zsh @@ -27,9 +27,11 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -BUFFER='ls highlighters/main/test-data/path-space-\ .zsh' +mkdir A +touch "A/mu with spaces" +BUFFER='ls A/mu\ with\ spaces' expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls - "4 48 $ZSH_HIGHLIGHT_STYLES[path]" # highlighters/main/test-data/path-space-\ .zsh + "1 2 command" # ls + "4 21 path" # A/mu\ with\ spaces ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-tilde-home.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-tilde-home.zsh index 31ad1e9..8b1c680 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-tilde-home.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-tilde-home.zsh @@ -31,6 +31,6 @@ HOME="." BUFFER='ls ~' expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls - "4 4 $ZSH_HIGHLIGHT_STYLES[path]" # ~ + "1 2 command" # ls + "4 4 path" # ~ ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-tilde-home2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-tilde-home2.zsh index 18dd17b..3f7b820 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-tilde-home2.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-tilde-home2.zsh @@ -31,7 +31,7 @@ HOME="/nonexistent" BUFFER='ls ~' expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls - "4 4 $ZSH_HIGHLIGHT_STYLES[default]" # ~ + "1 2 command" # ls + "4 4 default" # ~ ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-tilde-home3.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-tilde-home3.zsh new file mode 100644 index 0000000..5c076e8 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-tilde-home3.zsh @@ -0,0 +1,36 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +HOME="." +BUFFER='ls \~' + +expected_region_highlight=( + "1 2 command" # ls + "4 5 default" # \~ +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-tilde-named.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-tilde-named.zsh index be5bb5a..335b3fd 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-tilde-named.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path-tilde-named.zsh @@ -27,11 +27,13 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -hash -d D=highlighters/main/test-data +mkdir mydir +touch mydir/path-tilde-named.test +hash -d D=mydir -BUFFER='ls ~D/path-tilde-named.zsh' +BUFFER='ls ~D/path-tilde-named.test' expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls - "4 26 $ZSH_HIGHLIGHT_STYLES[path]" # ~D/path-tilde-named.zsh + "1 2 command" # ls + "4 27 path" # ~D/path-tilde-named.test ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path.zsh index 3688b9b..d387eff 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path.zsh @@ -27,9 +27,11 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -BUFFER='ls highlighters/main/test-data/path.zsh' +mkdir A +touch A/mu +BUFFER='ls A/mu' expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls - "4 39 $ZSH_HIGHLIGHT_STYLES[path]" # highlighters/main/test-data/path.zsh + "1 2 command" # ls + "4 7 path" # A/mu ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path_prefix.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path_prefix.zsh index 17cd26c..3303bfb 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path_prefix.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path_prefix.zsh @@ -30,9 +30,9 @@ # Assumes that '/bin/sh' exists and '/bin/s' does not exist. # Related to path_prefix2.zsh -ZSH_HIGHLIGHT_STYLES[path_prefix]=$unused_highlight BUFFER='ls /bin/s' expected_region_highlight=( - "4 9 $ZSH_HIGHLIGHT_STYLES[path_prefix]" # /bin/s + "1 2 command" # ls + "4 9 path_prefix" # /bin/s ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path_prefix2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path_prefix2.zsh index a1974eb..4f40f7e 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path_prefix2.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path_prefix2.zsh @@ -30,10 +30,10 @@ # Assumes that '/bin/sh' exists and '/bin/s' does not exist. # Related to path_prefix.zsh -ZSH_HIGHLIGHT_STYLES[path_prefix]=$unused_highlight BUFFER='ls /bin/s' -WIDGET=accept-line +WIDGET=zle-line-finish expected_region_highlight=( - "4 9 $ZSH_HIGHLIGHT_STYLES[default]" # /bin/s + "1 2 command" # ls + "4 9 default" # /bin/s ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path_prefix3.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path_prefix3.zsh new file mode 100644 index 0000000..f4a0189 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/path_prefix3.zsh @@ -0,0 +1,38 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2015 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +# Assumes that '/bin/sh' exists and '/bin/s' does not exist. +# Related to path_prefix.zsh + +PREBUFFER='ls \' +BUFFER='/bin/s' + +expected_region_highlight=( + '1 6 path_prefix' # /bin/s +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/precommand.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/precommand.zsh index 156b72d..a03b331 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/precommand.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/precommand.zsh @@ -27,11 +27,10 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -ZSH_HIGHLIGHT_STYLES[assign]=$unused_highlight BUFFER=': command zzzzzz' expected_region_highlight=( - "1 1 $ZSH_HIGHLIGHT_STYLES[command]" # ls - "3 9 $ZSH_HIGHLIGHT_STYLES[default]" # not precommand - "11 16 $ZSH_HIGHLIGHT_STYLES[default]" # not unknown-token (since 'zzzzzz' is not a command) + "1 1 builtin" # : + "3 9 default" # not precommand + "11 16 default" # not unknown-token (since 'zzzzzz' is not a command) ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/precommand2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/precommand2.zsh new file mode 100644 index 0000000..3d8f332 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/precommand2.zsh @@ -0,0 +1,36 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='command -v ls' + +expected_region_highlight=( + "1 7 precommand" # command + "9 10 single-hyphen-option 'issue #343'" # -v + "12 13 command 'issue #343'" # ls +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/prefix-redirection.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/prefix-redirection.zsh index 0eddf0f..a0f0ed5 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/prefix-redirection.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/prefix-redirection.zsh @@ -27,13 +27,16 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -BUFFER='>/tmp >/tmp sudo echo >/tmp foo' +BUFFER='>/tmp >/tmp command echo >/tmp foo' expected_region_highlight=( - "2 5 $ZSH_HIGHLIGHT_STYLES[path]" # /tmp - "8 11 $ZSH_HIGHLIGHT_STYLES[path]" # /tmp - "13 16 $ZSH_HIGHLIGHT_STYLES[precommand]" # sudo - "18 21 $ZSH_HIGHLIGHT_STYLES[builtin]" # echo - "24 27 $ZSH_HIGHLIGHT_STYLES[path]" # /tmp - "29 31 $ZSH_HIGHLIGHT_STYLES[default]" # foo + "1 1 redirection" # > + "2 5 path" # /tmp + "7 7 redirection" # > + "8 11 path" # /tmp + "13 19 precommand" # command + "21 24 builtin" # echo + "26 26 redirection" # > + "27 30 path" # /tmp + "32 34 default" # foo ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/process-substitution-redirection-isnt-globbing.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/process-substitution-redirection-isnt-globbing.zsh new file mode 100644 index 0000000..05c11b8 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/process-substitution-redirection-isnt-globbing.zsh @@ -0,0 +1,36 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2018 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=$': =(>&! + "1 3 redirection" # <<< + "4 6 default" # foo + "8 11 builtin" # echo + "13 16 redirection" # >>&! + "17 19 default" # bar ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/redirection2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/redirection2.zsh new file mode 100644 index 0000000..1a1588d --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/redirection2.zsh @@ -0,0 +1,37 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='ls >(wc) | nl' + +expected_region_highlight=( + "1 2 command" # ls + "4 8 process-substitution 'issue #494'" # >(wc) + "10 10 commandseparator" # | + "12 13 command" # nl +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/redirection3.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/redirection3.zsh new file mode 100644 index 0000000..bf062cf --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/redirection3.zsh @@ -0,0 +1,42 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2017 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=': >>>; : <>\<<<> + "5 5 unknown-token" # > + "6 6 commandseparator" # ; + "8 8 builtin" # : + "10 11 redirection" # <> + "12 13 default" # \< + "14 16 redirection" # <<< + "17 19 default" # EOF +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/reserved-word.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/reserved-word.zsh index 2f62103..aca3796 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/reserved-word.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/reserved-word.zsh @@ -27,12 +27,12 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -ZSH_HIGHLIGHT_STYLES[reserved-word]=$unused_highlight BUFFER='repeat "1" do done' expected_region_highlight=( - "1 6 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # repeat - "8 10 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "1" - "12 13 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # do - "15 18 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # done + "1 6 reserved-word" # repeat + "8 10 default" # "1" + "8 10 double-quoted-argument" # "1" + "12 13 reserved-word" # do + "15 18 reserved-word" # done ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/simple-command.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/simple-command.zsh index 51dd9a9..8bb41fd 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/simple-command.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/simple-command.zsh @@ -30,5 +30,5 @@ BUFFER='ls' expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls + "1 2 command" # ls ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/simple-redirection.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/simple-redirection.zsh index 191c67e..e8c25e5 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/simple-redirection.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/simple-redirection.zsh @@ -30,9 +30,9 @@ BUFFER='ps aux | grep java' expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ps - "4 6 $ZSH_HIGHLIGHT_STYLES[default]" # aux - "8 8 $ZSH_HIGHLIGHT_STYLES[default]" # | - "10 13 $ZSH_HIGHLIGHT_STYLES[command]" # grep - "15 18 $ZSH_HIGHLIGHT_STYLES[default]" # java + "1 2 command" # ps + "4 6 default" # aux + "8 8 commandseparator" # | + "10 13 command" # grep + "15 18 default" # java ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/subshell.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/subshell.zsh index 3e98476..c068013 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/subshell.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/subshell.zsh @@ -30,12 +30,22 @@ BUFFER='tar cf - * | (cd /target; tar xfp -) | { cat }' expected_region_highlight=( - "1 3 $ZSH_HIGHLIGHT_STYLES[command]" # tar - "14 14 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # ( - "15 16 $ZSH_HIGHLIGHT_STYLES[command]" # cd - "27 29 $ZSH_HIGHLIGHT_STYLES[command]" # tar - "36 36 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # ) - "40 40 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # { - "42 44 $ZSH_HIGHLIGHT_STYLES[command]" # cat - "46 46 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # } + "1 3 command" # tar + "5 6 default" # cf + "8 8 single-hyphen-option" # - + "10 10 default" # * + "10 10 globbing" # * + "12 12 commandseparator" # | + "14 14 reserved-word" # ( + "15 16 builtin" # cd + "18 24 default" # /target + "25 25 commandseparator" # ; + "27 29 command" # tar + "31 33 default" # xfp + "35 35 single-hyphen-option" # - + "36 36 reserved-word" # ) + "38 38 commandseparator" # | + "40 40 reserved-word" # { + "42 44 command" # cat + "46 46 reserved-word" # } ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-command.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-command.zsh index ec1ccff..941349a 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-command.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-command.zsh @@ -27,21 +27,28 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=$unused_highlight +sudo(){} + # Tests three codepaths: # * -i (no argument) # * -C3 (pasted argument) # * -u otheruser (non-pasted argument) -BUFFER='sudo -C3 -u otheruser -i ls /; sudo ; sudo -u ;' +BUFFER='sudo -C3 -u otheruser -i ls /; sudo ; sudo -u ; sudo notacommand' expected_region_highlight=( - "1 4 $ZSH_HIGHLIGHT_STYLES[precommand]" # sudo - "6 8 $ZSH_HIGHLIGHT_STYLES[single-hyphen-option]" # -C3 - "10 11 $ZSH_HIGHLIGHT_STYLES[single-hyphen-option]" # -u - "13 21 $ZSH_HIGHLIGHT_STYLES[default]" # otheruser - "23 24 $ZSH_HIGHLIGHT_STYLES[single-hyphen-option]" # -i - "26 27 $ZSH_HIGHLIGHT_STYLES[command]" # ls - "29 29 $ZSH_HIGHLIGHT_STYLES[path]" # / - "37 37 $ZSH_HIGHLIGHT_STYLES[unknown-token]" # ;, error because empty command - "47 47 $ZSH_HIGHLIGHT_STYLES[unknown-token]" # ;, error because incomplete command + "1 4 precommand" # sudo + "6 8 single-hyphen-option" # -C3 + "10 11 single-hyphen-option" # -u + "13 21 default" # otheruser + "23 24 single-hyphen-option" # -i + "26 27 command" # ls + "29 29 path" # / + "30 30 commandseparator" # ; + "32 35 precommand" # sudo + "37 37 unknown-token" # ;, error because empty command + "39 42 precommand" # sudo + "44 45 single-hyphen-option" # -u + "47 47 unknown-token" # ;, error because incomplete command + "49 52 precommand" # sudo + "54 64 unknown-token" # notacommand - doesn't falls back to "not a command word" codepath ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-comment.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-comment.zsh index 8a70ae3..74cd905 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-comment.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-comment.zsh @@ -27,12 +27,13 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=$unused_highlight +sudo(){} + setopt interactive_comments BUFFER='sudo -u # comment' expected_region_highlight=( - "1 4 $ZSH_HIGHLIGHT_STYLES[precommand]" # sudo - "6 7 $ZSH_HIGHLIGHT_STYLES[single-hyphen-option]" # -u - "9 17 $ZSH_HIGHLIGHT_STYLES[unknown-token]" # "# comment" - error because argument missed + "1 4 precommand" # sudo + "6 7 single-hyphen-option" # -u + "9 17 unknown-token" # "# comment" - error because argument missed ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-redirection.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-redirection.zsh index e31ce6e..c675d7d 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-redirection.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-redirection.zsh @@ -27,20 +27,22 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- +sudo(){} + BUFFER='sudo -u >/tmp otheruser ls; sudo ls; sudo -i ls' expected_region_highlight=( - "1 4 $ZSH_HIGHLIGHT_STYLES[precommand]" # sudo - "6 7 $ZSH_HIGHLIGHT_STYLES[single-hyphen-option]" # -u - "9 9 $ZSH_HIGHLIGHT_STYLES[redirection]" # > - "10 13 $ZSH_HIGHLIGHT_STYLES[path]" # /tmp - "15 23 $ZSH_HIGHLIGHT_STYLES[default]" # otheruser - "25 26 $ZSH_HIGHLIGHT_STYLES[command]" # ls - "27 27 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # ; - "29 32 $ZSH_HIGHLIGHT_STYLES[precommand]" # sudo - "34 35 $ZSH_HIGHLIGHT_STYLES[command]" # ls - "36 36 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # ; - "38 41 $ZSH_HIGHLIGHT_STYLES[precommand]" # sudo - "43 44 $ZSH_HIGHLIGHT_STYLES[single-hyphen-option]" # -i - "46 47 $ZSH_HIGHLIGHT_STYLES[command]" # ls + "1 4 precommand" # sudo + "6 7 single-hyphen-option" # -u + "9 9 redirection" # > + "10 13 path" # /tmp + "15 23 default" # otheruser + "25 26 command" # ls + "27 27 commandseparator" # ; + "29 32 precommand" # sudo + "34 35 command" # ls + "36 36 commandseparator" # ; + "38 41 precommand" # sudo + "43 44 single-hyphen-option" # -i + "46 47 command" # ls ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-redirection2.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-redirection2.zsh index f806178..23ada53 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-redirection2.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-redirection2.zsh @@ -27,13 +27,15 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- +sudo(){} + BUFFER='sudo >/tmp -u otheruser ls' expected_region_highlight=( - "1 4 $ZSH_HIGHLIGHT_STYLES[precommand]" # sudo - "6 6 $ZSH_HIGHLIGHT_STYLES[redirection]" # > - "7 10 $ZSH_HIGHLIGHT_STYLES[path]" # /tmp - "12 13 $ZSH_HIGHLIGHT_STYLES[single-hyphen-option]" # -u - "15 23 $ZSH_HIGHLIGHT_STYLES[default]" # otheruser - "25 26 $ZSH_HIGHLIGHT_STYLES[command]" # ls + "1 4 precommand" # sudo + "6 6 redirection" # > + "7 10 path" # /tmp + "12 13 single-hyphen-option" # -u + "15 23 default" # otheruser + "25 26 command" # ls ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-redirection3.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-redirection3.zsh new file mode 100644 index 0000000..80e55b5 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/sudo-redirection3.zsh @@ -0,0 +1,41 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2015 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +sudo(){} + +BUFFER='sudo 2>./. -u otheruser ls' + +expected_region_highlight=( + "1 4 precommand" # sudo + "6 7 redirection" # 2> + "8 10 path" # ./. # a 3-character path, for alignment with sudo-redirection2.zsh + "12 13 single-hyphen-option" # -u + "15 23 default" # otheruser + "25 26 command" # ls +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/tilde-command-word.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/tilde-command-word.zsh index e66db8e..67c996c 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/tilde-command-word.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/tilde-command-word.zsh @@ -32,6 +32,6 @@ hash -d D=/usr/bin BUFFER='~D/env foo' expected_region_highlight=( - "1 6 $ZSH_HIGHLIGHT_STYLES[command]" # ~D/env [= /usr/bin/env] - "8 10 $ZSH_HIGHLIGHT_STYLES[default]" # foo + "1 6 command" # ~D/env [= /usr/bin/env + "8 10 default" # foo ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/unbackslash.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/unbackslash.zsh index b96c055..c8dfbd4 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/unbackslash.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/unbackslash.zsh @@ -27,9 +27,8 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -ZSH_HIGHLIGHT_STYLES[command]=$unused_highlight BUFFER='\sh' expected_region_highlight=( - "1 3 $ZSH_HIGHLIGHT_STYLES[command]" # \sh (runs 'sh', bypassing aliases) + "1 3 command" # \sh (runs 'sh', bypassing aliases) ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/unknown-command.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/unknown-command.zsh index 9b9e8d3..e71faec 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/unknown-command.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/unknown-command.zsh @@ -30,5 +30,5 @@ BUFFER='azertyuiop' expected_region_highlight=( - "1 10 $ZSH_HIGHLIGHT_STYLES[unknown-token]" # azertyuiop + "1 10 unknown-token" # azertyuiop ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/vanilla-newline.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/vanilla-newline.zsh index 7fa9ba2..bd60ad4 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/vanilla-newline.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/vanilla-newline.zsh @@ -31,9 +31,9 @@ PREBUFFER=$'echo foo; echo bar\n\n\n' BUFFER=' echo baz; echo qux' expected_region_highlight=( - "2 5 $ZSH_HIGHLIGHT_STYLES[builtin]" # echo - "7 9 $ZSH_HIGHLIGHT_STYLES[default]" # baz - "10 10 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # semicolon - "12 15 $ZSH_HIGHLIGHT_STYLES[builtin]" # echo - "17 19 $ZSH_HIGHLIGHT_STYLES[default]" # qux + "2 5 builtin" # echo + "7 9 default" # baz + "10 10 commandseparator" # semicolon + "12 15 builtin" # echo + "17 19 default" # qux ) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/vi-linewise-mode.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/vi-linewise-mode.zsh new file mode 100644 index 0000000..7003c49 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/main/test-data/vi-linewise-mode.zsh @@ -0,0 +1,43 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +# See issue #267 for the magic numbers +BUFFER=$'foo foo\nbar bar' +REGION_ACTIVE=2 +CURSOR=4 +MARK=12 + +expected_region_highlight=( + "1 3 unknown-token" # foo + "5 7 default" # foo + "8 8 commandseparator" # \n + "9 11 unknown-token" # bar + "13 15 default" # bar + "1 15 standout" # foo foo\nbar bar +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/pattern/README.md b/.zprezto/modules/syntax-highlighting/external/highlighters/pattern/README.md index 82a7c65..3ad5f24 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/pattern/README.md +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/pattern/README.md @@ -1,21 +1,19 @@ zsh-syntax-highlighting / highlighters / pattern -================================================ +------------------------------------------------ -This is the ***pattern*** highlighter, that highlights user defined patterns. +This is the `pattern` highlighter, that highlights user-defined patterns. -How to activate it ------------------- -To activate it, add it to `ZSH_HIGHLIGHT_HIGHLIGHTERS`: +### How to tweak it - ZSH_HIGHLIGHT_HIGHLIGHTERS=( [...] pattern) - - -How to tweak it ---------------- -To use this highlighter, associate patterns with styles in the `ZSH_HIGHLIGHT_PATTERNS` array, for example in `~/.zshrc`: +To use this highlighter, associate patterns with styles in the +`ZSH_HIGHLIGHT_PATTERNS` associative array, for example in `~/.zshrc`: # To have commands starting with `rm -rf` in red: ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red') -The syntax for declaring styles is [documented here](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135). +The syntax for values is the same as the syntax of "types of highlighting" of +the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` +manual page][zshzle-Character-Highlighting]. + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/pattern/pattern-highlighter.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/pattern/pattern-highlighter.zsh index 4e2eabd..054eff7 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/pattern/pattern-highlighter.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/pattern/pattern-highlighter.zsh @@ -32,13 +32,13 @@ typeset -gA ZSH_HIGHLIGHT_PATTERNS # Whether the pattern highlighter should be called or not. -_zsh_highlight_pattern_highlighter_predicate() +_zsh_highlight_highlighter_pattern_predicate() { _zsh_highlight_buffer_modified } # Pattern syntax highlighting function. -_zsh_highlight_pattern_highlighter() +_zsh_highlight_highlighter_pattern_paint() { setopt localoptions extendedglob local pattern diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/pattern/test-data/rm-rf.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/pattern/test-data/rm-rf.zsh new file mode 100644 index 0000000..2f76929 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/pattern/test-data/rm-rf.zsh @@ -0,0 +1,36 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red') + +BUFFER='rm -rf /' + +expected_region_highlight=( + "1 8 fg=white,bold,bg=red" # rm -rf / +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/regexp/README.md b/.zprezto/modules/syntax-highlighting/external/highlighters/regexp/README.md new file mode 100644 index 0000000..25f1b6c --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/regexp/README.md @@ -0,0 +1,27 @@ +zsh-syntax-highlighting / highlighters / regexp +------------------------------------------------ + +This is the `regexp` highlighter, that highlights user-defined regular +expressions. It's similar to the `pattern` highlighter, but allows more complex +patterns. + +### How to tweak it + +To use this highlighter, associate regular expressions with styles in the +`ZSH_HIGHLIGHT_REGEXP` associative array, for example in `~/.zshrc`: + + ZSH_HIGHLIGHT_REGEXP+=('\bsudo\b' fg=123,bold) + +This will highlight "sudo" only as a complete word, i.e., "sudo cmd", but not +"sudoedit" + +The syntax for values is the same as the syntax of "types of highlighting" of +the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` +manual page][zshzle-Character-Highlighting]. + +See also: [regular expressions tutorial][perlretut], zsh regexp operator `=~` +in [the `zshmisc(1)` manual page][zshmisc-Conditional-Expressions] + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting +[perlretut]: http://perldoc.perl.org/perlretut.html +[zshmisc-Conditional-Expressions]: http://zsh.sourceforge.net/Doc/Release/Conditional-Expressions.html#Conditional-Expressions diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/regexp/regexp-highlighter.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/regexp/regexp-highlighter.zsh new file mode 100644 index 0000000..26f9da3 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/regexp/regexp-highlighter.zsh @@ -0,0 +1,62 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + + +# List of keyword and color pairs. +typeset -gA ZSH_HIGHLIGHT_REGEXP + +# Whether the pattern highlighter should be called or not. +_zsh_highlight_highlighter_regexp_predicate() +{ + _zsh_highlight_buffer_modified +} + +# Pattern syntax highlighting function. +_zsh_highlight_highlighter_regexp_paint() +{ + setopt localoptions extendedglob + local pattern + for pattern in ${(k)ZSH_HIGHLIGHT_REGEXP}; do + _zsh_highlight_regexp_highlighter_loop "$BUFFER" "$pattern" + done +} + +_zsh_highlight_regexp_highlighter_loop() +{ + local buf="$1" pat="$2" + integer OFFSET=0 + local MATCH; integer MBEGIN MEND + local -a match mbegin mend + while true; do + [[ "$buf" =~ "$pat" ]] || return; + region_highlight+=("$((MBEGIN - 1 + OFFSET)) $((MEND + OFFSET)) $ZSH_HIGHLIGHT_REGEXP[$pat]") + buf="$buf[$(($MEND+1)),-1]" + OFFSET=$((MEND+OFFSET)); + done +} diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/regexp/test-data/complex.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/regexp/test-data/complex.zsh new file mode 100644 index 0000000..4e0089b --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/regexp/test-data/complex.zsh @@ -0,0 +1,37 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +ZSH_HIGHLIGHT_REGEXP+=('[0-9\+\-]+' 'fg=white,bold,bg=red') + +BUFFER='echo 1+9-3 7+2' + +expected_region_highlight=( + "6 10 fg=white,bold,bg=red" + "12 14 fg=white,bold,bg=red" +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/regexp/test-data/subexpression.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/regexp/test-data/subexpression.zsh new file mode 100644 index 0000000..308cb41 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/regexp/test-data/subexpression.zsh @@ -0,0 +1,36 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2018 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER='ls foo' +ZSH_HIGHLIGHT_REGEXP=('(^| )(ls|cd)($| )' 'fg=green') + +expected_region_highlight=( + '1 3 fg=green' # "ls " +) diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/regexp/test-data/word-boundary.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/regexp/test-data/word-boundary.zsh new file mode 100644 index 0000000..1f4f666 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/regexp/test-data/word-boundary.zsh @@ -0,0 +1,42 @@ +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +if zmodload zsh/pcre 2>/dev/null; then + setopt RE_MATCH_PCRE + + ZSH_HIGHLIGHT_REGEXP+=('\bsudo\b' 'fg=white,bold,bg=red') + + BUFFER='sudo ls' + + expected_region_highlight=( + "1 4 fg=white,bold,bg=red" + ) +else + skip_test='Test requires zsh/pcre' +fi diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/root/README.md b/.zprezto/modules/syntax-highlighting/external/highlighters/root/README.md index 53c871b..0b0d41f 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/root/README.md +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/root/README.md @@ -1,24 +1,23 @@ zsh-syntax-highlighting / highlighters / root -================================================= +--------------------------------------------- -This is the ***root*** highlighter, that highlights the whole line if the current user is root. +This is the `root` highlighter, that highlights the whole line if the current +user is root. -How to activate it ------------------- -To activate it, add it to `ZSH_HIGHLIGHT_HIGHLIGHTERS`: +### How to tweak it - ZSH_HIGHLIGHT_HIGHLIGHTERS=( [...] root) - - -How to tweak it ---------------- This highlighter defines the following styles: * `root` - the style for the whole line if the current user is root. -To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, for example in `~/.zshrc`: +To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, +for example in `~/.zshrc`: ZSH_HIGHLIGHT_STYLES[root]='bg=red' -The syntax for declaring styles is [documented here](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135). +The syntax for values is the same as the syntax of "types of highlighting" of +the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)` +manual page][zshzle-Character-Highlighting]. + +[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting diff --git a/.zprezto/modules/syntax-highlighting/external/highlighters/root/root-highlighter.zsh b/.zprezto/modules/syntax-highlighting/external/highlighters/root/root-highlighter.zsh index 4362379..3718c44 100644 --- a/.zprezto/modules/syntax-highlighting/external/highlighters/root/root-highlighter.zsh +++ b/.zprezto/modules/syntax-highlighting/external/highlighters/root/root-highlighter.zsh @@ -32,13 +32,13 @@ : ${ZSH_HIGHLIGHT_STYLES[root]:=standout} # Whether the root highlighter should be called or not. -_zsh_highlight_root_highlighter_predicate() +_zsh_highlight_highlighter_root_predicate() { _zsh_highlight_buffer_modified } # root highlighting function. -_zsh_highlight_root_highlighter() +_zsh_highlight_highlighter_root_paint() { - if [[ $(command id -u) -eq 0 ]] { region_highlight+=("0 $#BUFFER $ZSH_HIGHLIGHT_STYLES[root]") } + if (( EUID == 0 )) { _zsh_highlight_add_highlight 0 $#BUFFER root } } diff --git a/.zprezto/modules/syntax-highlighting/external/images/after1-smaller.png b/.zprezto/modules/syntax-highlighting/external/images/after1-smaller.png new file mode 100644 index 0000000..768294c Binary files /dev/null and b/.zprezto/modules/syntax-highlighting/external/images/after1-smaller.png differ diff --git a/.zprezto/modules/syntax-highlighting/external/images/after1.png b/.zprezto/modules/syntax-highlighting/external/images/after1.png new file mode 100644 index 0000000..ea378d3 Binary files /dev/null and b/.zprezto/modules/syntax-highlighting/external/images/after1.png differ diff --git a/.zprezto/modules/syntax-highlighting/external/images/after2-smaller.png b/.zprezto/modules/syntax-highlighting/external/images/after2-smaller.png new file mode 100644 index 0000000..8b5b1f8 Binary files /dev/null and b/.zprezto/modules/syntax-highlighting/external/images/after2-smaller.png differ diff --git a/.zprezto/modules/syntax-highlighting/external/images/after2.png b/.zprezto/modules/syntax-highlighting/external/images/after2.png new file mode 100644 index 0000000..ddcbfad Binary files /dev/null and b/.zprezto/modules/syntax-highlighting/external/images/after2.png differ diff --git a/.zprezto/modules/syntax-highlighting/external/images/after3-smaller.png b/.zprezto/modules/syntax-highlighting/external/images/after3-smaller.png new file mode 100644 index 0000000..d6aaa7b Binary files /dev/null and b/.zprezto/modules/syntax-highlighting/external/images/after3-smaller.png differ diff --git a/.zprezto/modules/syntax-highlighting/external/images/after3.png b/.zprezto/modules/syntax-highlighting/external/images/after3.png new file mode 100644 index 0000000..7a0af88 Binary files /dev/null and b/.zprezto/modules/syntax-highlighting/external/images/after3.png differ diff --git a/.zprezto/modules/syntax-highlighting/external/images/before1-smaller.png b/.zprezto/modules/syntax-highlighting/external/images/before1-smaller.png new file mode 100644 index 0000000..b29551e Binary files /dev/null and b/.zprezto/modules/syntax-highlighting/external/images/before1-smaller.png differ diff --git a/.zprezto/modules/syntax-highlighting/external/images/before1.png b/.zprezto/modules/syntax-highlighting/external/images/before1.png new file mode 100644 index 0000000..80c6f54 Binary files /dev/null and b/.zprezto/modules/syntax-highlighting/external/images/before1.png differ diff --git a/.zprezto/modules/syntax-highlighting/external/images/before2-smaller.png b/.zprezto/modules/syntax-highlighting/external/images/before2-smaller.png new file mode 100644 index 0000000..991a716 Binary files /dev/null and b/.zprezto/modules/syntax-highlighting/external/images/before2-smaller.png differ diff --git a/.zprezto/modules/syntax-highlighting/external/images/before2.png b/.zprezto/modules/syntax-highlighting/external/images/before2.png new file mode 100644 index 0000000..48cfc32 Binary files /dev/null and b/.zprezto/modules/syntax-highlighting/external/images/before2.png differ diff --git a/.zprezto/modules/syntax-highlighting/external/images/before3-smaller.png b/.zprezto/modules/syntax-highlighting/external/images/before3-smaller.png new file mode 100644 index 0000000..e525c6d Binary files /dev/null and b/.zprezto/modules/syntax-highlighting/external/images/before3-smaller.png differ diff --git a/.zprezto/modules/syntax-highlighting/external/images/before3.png b/.zprezto/modules/syntax-highlighting/external/images/before3.png new file mode 100644 index 0000000..40c3601 Binary files /dev/null and b/.zprezto/modules/syntax-highlighting/external/images/before3.png differ diff --git a/.zprezto/modules/syntax-highlighting/external/release.md b/.zprezto/modules/syntax-highlighting/external/release.md index a38d677..55a70f5 100644 --- a/.zprezto/modules/syntax-highlighting/external/release.md +++ b/.zprezto/modules/syntax-highlighting/external/release.md @@ -1,15 +1,18 @@ # Release procedure (for developers): +- For minor (A.B.0) releases: + - Check whether the release uses any not-yet-released zsh features - Check open issues and outstanding pull requests - Confirm `make test` passes - check with multiple zsh versions - Update changelog.md + `tig --abbrev=12 --abbrev-commit 0.4.1..upstream/master` - Remove `-dev` suffix from `./.version`; - Commit that; - Tag it using `git tag $(<.version)`; + Commit that using `git commit -m "Tag version $(<.version)." .version`; + Tag it using `git tag -m "Tag version $(<.version)"`; Increment `./.version` and restore the `-dev` suffix; - Commit that. -- Push with `git push --tags` + Commit that using `git commit -C b5c30ae52638e81a38fe5329081c5613d7bd6ca5 .version`. +- Push with `git push && git push --tags` - Notify downstreams (OS packages) - anitya should autodetect the tag - Update /topic on IRC diff --git a/.zprezto/modules/syntax-highlighting/external/tests/README.md b/.zprezto/modules/syntax-highlighting/external/tests/README.md index e82a64b..8487b3c 100644 --- a/.zprezto/modules/syntax-highlighting/external/tests/README.md +++ b/.zprezto/modules/syntax-highlighting/external/tests/README.md @@ -3,20 +3,68 @@ zsh-syntax-highlighting / tests Utility scripts for testing zsh-syntax-highlighting highlighters. -The tests expect the highlighter directory to contain a `test-data` directory with test data files. See the [main highlighter](../highlighters/main/test-data) for examples. +The tests harness expects the highlighter directory to contain a `test-data` +directory with test data files. +See the [main highlighter](../highlighters/main/test-data) for examples. -Each test should define the array parameter `$expected_region_highlight`. -The value of that parameter is a list of `"$i $j $style [$todo]"` strings. +Each test should define the string `$BUFFER` that is to be highlighted and the +array parameter `$expected_region_highlight`. +The value of that parameter is a list of strings of the form `"$i $j $style"`. +or `"$i $j $style $todo"`. Each string specifies the highlighting that `$BUFFER[$i,$j]` should have; that is, `$i` and `$j` specify a range, 1-indexed, inclusive of both endpoints. -If `$todo` exists, the test point is marked as TODO (the failure of that test point will not fail the test), and `$todo` is used as the explanation. +`$style` is a key of `$ZSH_HIGHLIGHT_STYLES`. +If `$todo` exists, the test point is marked as TODO (the failure of that test +point will not fail the test), and `$todo` is used as the explanation. +If a test sets `$skip_test` to a non-empty string, the test will be skipped +with the provided string as the reason. +If a test sets `unsorted=1` the order of highlights in `$expected_region_highlight` +need not match the order in `$region_highlight`. -_Note_: `$region_highlight` uses the same `"$i $j $style"` syntax but interprets the indexes differently. +**Note**: `$region_highlight` uses the same `"$i $j $style"` syntax but +interprets the indexes differently. + +**Note**: Tests are run with `setopt NOUNSET WARN_CREATE_GLOBAL`, so any +variables the test creates must be declared local. + +**Isolation**: Each test is run in a separate subshell, so any variables, +aliases, functions, etc., it defines will be visible to the tested code (that +computes `$region_highlight`), but will not affect subsequent tests. The +current working directory of tests is set to a newly-created empty directory, +which is automatically cleaned up after the test exits. For example: + + setopt PATH_DIRS + mkdir -p foo/bar + touch foo/bar/testing-issue-228 + chmod +x foo/bar/testing-issue-228 + path+=( "$PWD"/foo ) + + BUFFER='bar/testing-issue-228' + + expected_region_highlight=( + "1 21 command" # bar/testing-issue-228 + ) -highlighting test +Writing new tests ----------------- -[`test-highlighting.zsh`](tests/test-highlighting.zsh) tests the correctness of the highlighting. Usage: + +An experimental tool is available to generate test files: + + zsh -f tests/generate.zsh 'ls -x' acme newfile + +This generates a `highlighters/acme/test-data/newfile.zsh` test file based on +the current highlighting of the given `$BUFFER` (in this case, `ls -x`). + +_This tool is experimental._ Its interface may change. In particular it may +grow ways to set `$PREBUFFER` to inject free-form code into the generated file. + + +Highlighting test +----------------- + +[`test-highlighting.zsh`](tests/test-highlighting.zsh) tests the correctness of +the highlighting. Usage: zsh test-highlighting.zsh @@ -24,12 +72,19 @@ All tests may be run with make test -which will run all highlighting tests and report results in [TAP](http://testanything.org/) format. +which will run all highlighting tests and report results in [TAP format][TAP]. +By default, the results of all tests will be printed; to show only "interesting" +results (tests that failed but were expected to succeed, or vice-versa), run +`make quiet-test` (or `make test QUIET=y`). + +[TAP]: http://testanything.org/ -performance test +Performance test ---------------- -[`test-perfs.zsh`](tests/test-perfs.zsh) measures the time spent doing the highlighting. Usage: + +[`test-perfs.zsh`](tests/test-perfs.zsh) measures the time spent doing the +highlighting. Usage: zsh test-perfs.zsh diff --git a/.zprezto/modules/syntax-highlighting/external/tests/generate.zsh b/.zprezto/modules/syntax-highlighting/external/tests/generate.zsh new file mode 100755 index 0000000..64a1ede --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/tests/generate.zsh @@ -0,0 +1,99 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2016 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +emulate -LR zsh +setopt localoptions extendedglob + +# Argument parsing. +if (( $# != 3 )) || [[ $1 == -* ]]; then + print -r -- >&2 "$0: usage: $0 BUFFER HIGHLIGHTER BASENAME" + print -r -- >&2 "" + print -r -- >&2 "Generate highlighters/HIGHLIGHTER/test-data/BASENAME.zsh based on the" + print -r -- >&2 "current highlighting of BUFFER." + exit 1 +fi +buffer=$1 +ZSH_HIGHLIGHT_HIGHLIGHTERS=( $2 ) +fname=${0:A:h:h}/highlighters/$2/test-data/${3%.zsh}.zsh + +# Load the main script. +. ${0:A:h:h}/zsh-syntax-highlighting.zsh + +# Overwrite _zsh_highlight_add_highlight so we get the key itself instead of the style +_zsh_highlight_add_highlight() +{ + region_highlight+=("$1 $2 $3") +} + + +# Copyright block +year="`LC_ALL=C date +%Y`" +if ! read -q "?Set copyright year to $year? "; then + year="YYYY" +fi +exec >$fname +<$0 sed -n -e '1,/^$/p' | sed -e "s/2[0-9][0-9][0-9]/${year}/" +# Assumes stdout is line-buffered +git add -- $fname + +# Buffer +print -n 'BUFFER=' +if [[ $buffer != (#s)[$'\t -~']#(#e) ]]; then + print -r -- ${(qqqq)buffer} +else + print -r -- ${(qq)buffer} +fi +echo "" + +# Expectations +print 'expected_region_highlight=(' +() { + local i + local PREBUFFER + local BUFFER + + PREBUFFER="" + BUFFER="$buffer" + region_highlight=() + # TODO: use run_test() from tests/test-highlighting.zsh (to get a tempdir) + _zsh_highlight + + for ((i=1; i<=${#region_highlight}; i++)); do + local -a highlight_zone; highlight_zone=( ${(z)region_highlight[$i]} ) + integer start=$highlight_zone[1] end=$highlight_zone[2] + if (( start < end )) # region_highlight ranges are half-open + then + (( --end )) # convert to closed range, like expected_region_highlight + (( ++start, ++end )) # region_highlight is 0-indexed; expected_region_highlight is 1-indexed + fi + printf " %s # %s\n" ${(qq):-"$start $end $highlight_zone[3]"} ${${(qqqq)BUFFER[start,end]}[3,-2]} + done +} +print ')' diff --git a/.zprezto/modules/syntax-highlighting/external/tests/tap-colorizer.zsh b/.zprezto/modules/syntax-highlighting/external/tests/tap-colorizer.zsh index cb645c6..f3dc84e 100755 --- a/.zprezto/modules/syntax-highlighting/external/tests/tap-colorizer.zsh +++ b/.zprezto/modules/syntax-highlighting/external/tests/tap-colorizer.zsh @@ -1,6 +1,6 @@ #!/usr/bin/env zsh # ------------------------------------------------------------------------------------------------- -# Copyright (c) 2015 zsh-syntax-highlighting contributors +# Copyright (c) 2015, 2017 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted @@ -44,6 +44,10 @@ do (#* | <->..<->) print -nP %F{blue} ;; + # SKIP + (*# SKIP*) + print -nP %F{yellow} + ;; # XPASS (ok*# TODO*) print -nP %F{red} diff --git a/.zprezto/modules/syntax-highlighting/external/tests/tap-filter b/.zprezto/modules/syntax-highlighting/external/tests/tap-filter new file mode 100755 index 0000000..6587808 --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/tests/tap-filter @@ -0,0 +1,45 @@ +#!/usr/bin/env perl +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2015 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# vim: ft=perl sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +# This is a stdin-to-stdout filter that takes TAP output (such as 'make test') +# on stdin and deletes lines pertaining to expected results. +# +# More specifically, if any of the test points in a test file either failed but +# was expected to pass, or passed but was expected to fail, then emit that test +# file's output; else, elide that test file's output. + +use v5.10.0; +use warnings; +use strict; + +undef $/; # slurp mode +print for + grep { /^ok.*# TODO/m or /^not ok(?!.*# TODO)/m } + split /^(?=#)/m, + ; diff --git a/.zprezto/modules/syntax-highlighting/external/tests/test-highlighting.zsh b/.zprezto/modules/syntax-highlighting/external/tests/test-highlighting.zsh index 1eed974..812b1a7 100755 --- a/.zprezto/modules/syntax-highlighting/external/tests/test-highlighting.zsh +++ b/.zprezto/modules/syntax-highlighting/external/tests/test-highlighting.zsh @@ -1,6 +1,6 @@ #!/usr/bin/env zsh # ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2015 zsh-syntax-highlighting contributors +# Copyright (c) 2010-2017 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted @@ -29,6 +29,8 @@ # ------------------------------------------------------------------------------------------------- +setopt NO_UNSET WARN_CREATE_GLOBAL + # Check an highlighter was given as argument. [[ -n "$1" ]] || { echo >&2 "Bail out! You must provide the name of a valid highlighter as argument." @@ -37,81 +39,160 @@ # Check the highlighter is valid. [[ -f ${0:h:h}/highlighters/$1/$1-highlighter.zsh ]] || { - echo >&2 "Bail out! Could not find highlighter '$1'." + echo >&2 "Bail out! Could not find highlighter ${(qq)1}." exit 2 } # Check the highlighter has test data. [[ -d ${0:h:h}/highlighters/$1/test-data ]] || { - echo >&2 "Bail out! Highlighter '$1' has no test data." + echo >&2 "Bail out! Highlighter ${(qq)1} has no test data." exit 2 } +# Set up results_filter +local results_filter +if [[ ${QUIET-} == y ]]; then + if type -w perl >/dev/null; then + results_filter=${0:A:h}/tap-filter + else + echo >&2 "Bail out! quiet mode not supported: perl not found"; exit 2 + fi +else + results_filter=cat +fi +[[ -n $results_filter ]] || { echo >&2 "Bail out! BUG setting \$results_filter"; exit 2 } + # Load the main script. +# While here, test that it doesn't eat aliases. +print > >($results_filter | ${0:A:h}/tap-colorizer.zsh) -r -- "# global (driver) tests" +print > >($results_filter | ${0:A:h}/tap-colorizer.zsh) -r -- "1..1" +alias -- +plus=plus +alias -- _other=other +original_alias_dash_L_output="$(alias -L)" . ${0:h:h}/zsh-syntax-highlighting.zsh +if [[ $original_alias_dash_L_output == $(alias -L) ]]; then + print -r -- "ok 1 # 'alias -- +foo=bar' is preserved" +else + print -r -- "not ok 1 # 'alias -- +foo=bar' is preserved" + exit 1 +fi > >($results_filter | ${0:A:h}/tap-colorizer.zsh) + +# Overwrite _zsh_highlight_add_highlight so we get the key itself instead of the style +_zsh_highlight_add_highlight() +{ + region_highlight+=("$1 $2 $3") +} # Activate the highlighter. ZSH_HIGHLIGHT_HIGHLIGHTERS=($1) # Runs a highlighting test # $1: data file -run_test() { - local -a highlight_zone - local unused_highlight='bg=red,underline' # a style unused by anything else, for tests to use +run_test_internal() { + + local tests_tempdir="$1"; shift + local srcdir="$PWD" + builtin cd -q -- "$tests_tempdir" || { echo >&2 "Bail out! On ${(qq)1}: cd failed: $?"; return 1 } echo "# ${1:t:r}" # Load the data and prepare checking it. - PREBUFFER= BUFFER= ; - . "$1" + local BUFFER CURSOR MARK PENDING PREBUFFER REGION_ACTIVE WIDGET skip_test unsorted=0 + local -a expected_region_highlight region_highlight + . "$srcdir"/"$1" + + (( $#skip_test )) && { print -r -- "1..0 # SKIP $skip_test"; return; } # Check the data declares $PREBUFFER or $BUFFER. - [[ -z $PREBUFFER && -z $BUFFER ]] && { echo >&2 "Bail out! Either 'PREBUFFER' or 'BUFFER' must be declared and non-blank"; return 1; } + [[ -z $PREBUFFER && -z $BUFFER ]] && { echo >&2 "Bail out! On ${(qq)1}: Either 'PREBUFFER' or 'BUFFER' must be declared and non-blank"; return 1; } # Check the data declares $expected_region_highlight. - (( ${#expected_region_highlight} == 0 )) && { echo >&2 "Bail out! 'expected_region_highlight' is not declared or empty."; return 1; } + (( $+expected_region_highlight == 0 )) && { echo >&2 "Bail out! On ${(qq)1}: 'expected_region_highlight' is not declared."; return 1; } + + # Set sane defaults for ZLE variables + : ${CURSOR=$#BUFFER} ${PENDING=0} ${WIDGET=z-sy-h-test-harness-test-widget} # Process the data. - region_highlight=() _zsh_highlight - # Overlapping regions can be declared in region_highlight, so we first build an array of the - # observed highlighting. - local -A observed_result - for ((i=1; i<=${#region_highlight}; i++)); do - highlight_zone=${(z)region_highlight[$i]} - integer start=$highlight_zone[1] end=$highlight_zone[2] - if (( start < end )) # region_highlight ranges are half-open - then - (( --end )) # convert to closed range, like expected_region_highlight - (( ++start, ++end )) # region_highlight is 0-indexed; expected_region_highlight is 1-indexed - for j in {$start..$end}; do - observed_result[$j]=$highlight_zone[3] - done - else - # noop range; ignore. + if (( unsorted )); then + region_highlight=("${(@n)region_highlight}") + expected_region_highlight=("${(@n)expected_region_highlight}") + fi + + echo "1..$(( $#expected_region_highlight + 1))" + local i + for ((i=1; i<=$#expected_region_highlight; i++)); do + local -a expected_highlight_zone; expected_highlight_zone=( ${(z)expected_region_highlight[i]} ) + integer exp_start=$expected_highlight_zone[1] exp_end=$expected_highlight_zone[2] + local todo= + (( $+expected_highlight_zone[4] )) && todo="# TODO $expected_highlight_zone[4]" + if ! (( $+region_highlight[i] )); then + print -r -- "not ok $i - unmatched expectation ($exp_start $exp_end $expected_highlight_zone[3])" + continue fi + local -a highlight_zone; highlight_zone=( ${(z)region_highlight[i]} ) + integer start=$(( highlight_zone[1] + 1 )) end=$highlight_zone[2] + # Escape # as ♯ and newline as ↵ they are illegal in the 'description' part of TAP output + local desc="[$start,$end] «${${BUFFER[$start,$end]//'#'/♯}//$'\n'/↵}»" + if + [[ $start != $exp_start ]] || + [[ $end != $exp_end ]] || + [[ $highlight_zone[3] != $expected_highlight_zone[3] ]] + then + print -r -- "not ok $i - $desc - expected ($exp_start $exp_end ${(qqq)expected_highlight_zone[3]}), observed ($start $end ${(qqq)highlight_zone[3]}). $todo" + else + print -r -- "ok $i - $desc${todo:+ - }$todo" + fi + unset expected_highlight_zone + unset exp_start exp_end + unset todo + unset highlight_zone + unset start end + unset desc done - # Then we compare the observed result with the expected one. - echo "1..${#expected_region_highlight}" - for ((i=1; i<=${#expected_region_highlight}; i++)); do - local todo= - highlight_zone=${(z)expected_region_highlight[$i]} - [[ -n "$highlight_zone[4]" ]] && todo=" # TODO $highlight_zone[4]" - for j in {$highlight_zone[1]..$highlight_zone[2]}; do - if [[ "$observed_result[$j]" != "$highlight_zone[3]" ]]; then - echo "not ok $i '$BUFFER[$highlight_zone[1],$highlight_zone[2]]' [$highlight_zone[1],$highlight_zone[2]]: expected '$highlight_zone[3]', observed '$observed_result[$j]'.$todo" - continue 2 + if (( $#expected_region_highlight == $#region_highlight )); then + print -r -- "ok $i - cardinality check" + else + print -r -- "not ok $i - have $#expected_region_highlight expectations and $#region_highlight region_highlight entries" + fi +} + +# Run a single test file. The exit status is 1 if the test harness had +# an error and 0 otherwise. The exit status does not depend on whether +# test points succeeded or failed. +run_test() { + # Do not combine the declaration and initialization: «local x="$(false)"» does not set $?. + local __tests_tempdir + __tests_tempdir="$(mktemp -d)" && [[ -d $__tests_tempdir ]] || { + echo >&2 "Bail out! mktemp failed"; return 1 + } + typeset -r __tests_tempdir # don't allow tests to override the variable that we will 'rm -rf' later on + + { + # Use a subshell to isolate tests from each other. + # (So tests can alter global shell state using 'cd', 'hash', etc) + { + # These braces are so multios don't come into play. + { (run_test_internal "$__tests_tempdir" "$@") 3>&1 >&2 2>&3 } | grep \^ + local ret=$pipestatus[1] stderr=$pipestatus[2] + if (( ! stderr )); then + # stdout will become stderr + echo "Bail out! On ${(qq)1}: output on stderr"; return 1 + else + return $ret fi - done - echo "ok $i$todo" - done + } 3>&1 >&2 2>&3 + } always { + rm -rf -- "$__tests_tempdir" + } } # Process each test data file in test data directory. integer something_failed=0 +ZSH_HIGHLIGHT_STYLES=() for data_file in ${0:h:h}/highlighters/$1/test-data/*.zsh; do - (run_test "$data_file") | tee >(${0:A:h}/tap-colorizer.zsh) | grep -v '^not ok.*# TODO' | grep -q '^not ok\|^ok.*# TODO' && (( something_failed=1 )) + run_test "$data_file" | tee >($results_filter | ${0:A:h}/tap-colorizer.zsh) | grep -v '^not ok.*# TODO' | grep -Eq '^not ok|^ok.*# TODO' && (( something_failed=1 )) (( $pipestatus[1] )) && exit 2 done diff --git a/.zprezto/modules/syntax-highlighting/external/tests/test-perfs.zsh b/.zprezto/modules/syntax-highlighting/external/tests/test-perfs.zsh index 0d4adc3..3411754 100755 --- a/.zprezto/modules/syntax-highlighting/external/tests/test-perfs.zsh +++ b/.zprezto/modules/syntax-highlighting/external/tests/test-perfs.zsh @@ -1,6 +1,6 @@ #!/usr/bin/env zsh # ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors +# Copyright (c) 2010-2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted @@ -31,20 +31,20 @@ # Check an highlighter was given as argument. [[ -n "$1" ]] || { - echo "You must provide the name of a valid highlighter as argument." >&2 - exit 1 + echo >&2 "Bail out! You must provide the name of a valid highlighter as argument." + exit 2 } # Check the highlighter is valid. [[ -f ${0:h:h}/highlighters/$1/$1-highlighter.zsh ]] || { - echo "Could not find highlighter '$1'." >&2 - exit 1 + echo >&2 "Bail out! Could not find highlighter ${(qq)1}." + exit 2 } # Check the highlighter has test data. [[ -d ${0:h:h}/highlighters/$1/test-data ]] || { - echo "Highlighter '$1' has no test data." >&2 - exit 1 + echo >&2 "Bail out! Highlighter ${(qq)1} has no test data." + exit 2 } # Load the main script. @@ -53,23 +53,48 @@ # Activate the highlighter. ZSH_HIGHLIGHT_HIGHLIGHTERS=($1) -# Process each test data file in test data directory. -for data_file in ${0:h:h}/highlighters/$1/test-data/*; do +# Runs a highlighting test +# $1: data file +run_test_internal() { + local -a highlight_zone + + local tests_tempdir="$1"; shift + local srcdir="$PWD" + builtin cd -q -- "$tests_tempdir" || { echo >&2 "Bail out! cd failed: $?"; return 1 } + + echo -n "# ${1:t:r}: " # Load the data and prepare checking it. - BUFFER= - echo -n "* ${data_file:t:r}: " - . $data_file + PREBUFFER= BUFFER= ; + . "$srcdir"/"$1" - # Check the data declares $BUFFER. - if [[ ${#BUFFER} -eq 0 ]]; then - echo "KO\n - 'BUFFER' is not declared or blank." - else + # Check the data declares $PREBUFFER or $BUFFER. + [[ -z $PREBUFFER && -z $BUFFER ]] && { echo >&2 "Bail out! Either 'PREBUFFER' or 'BUFFER' must be declared and non-blank"; return 1; } - # Measure the time taken by _zsh_highlight. - TIMEFMT="%*Es" - time ( BUFFER="$BUFFER" && _zsh_highlight) + # Measure the time taken by _zsh_highlight. + TIMEFMT="%*Es" + time (BUFFER="$BUFFER" && _zsh_highlight) +} - fi +run_test() { + # Do not combine the declaration and initialization: «local x="$(false)"» does not set $?. + local __tests_tempdir + __tests_tempdir="$(mktemp -d)" && [[ -d $__tests_tempdir ]] || { + echo >&2 "Bail out! mktemp failed"; return 1 + } + typeset -r __tests_tempdir # don't allow tests to override the variable that we will 'rm -rf' later on + { + (run_test_internal "$__tests_tempdir" "$@") + } always { + rm -rf -- "$__tests_tempdir" + } +} + +# Process each test data file in test data directory. +for data_file in ${0:h:h}/highlighters/$1/test-data/*.zsh; do + run_test "$data_file" + (( $pipestatus[1] )) && exit 2 done + +exit 0 diff --git a/.zprezto/modules/syntax-highlighting/external/zsh-syntax-highlighting.plugin.zsh b/.zprezto/modules/syntax-highlighting/external/zsh-syntax-highlighting.plugin.zsh deleted file mode 120000 index cc95cd4..0000000 --- a/.zprezto/modules/syntax-highlighting/external/zsh-syntax-highlighting.plugin.zsh +++ /dev/null @@ -1 +0,0 @@ -zsh-syntax-highlighting.zsh \ No newline at end of file diff --git a/.zprezto/modules/syntax-highlighting/external/zsh-syntax-highlighting.plugin.zsh b/.zprezto/modules/syntax-highlighting/external/zsh-syntax-highlighting.plugin.zsh new file mode 100644 index 0000000..f2456ae --- /dev/null +++ b/.zprezto/modules/syntax-highlighting/external/zsh-syntax-highlighting.plugin.zsh @@ -0,0 +1,2 @@ +0=${(%):-%N} +source ${0:A:h}/zsh-syntax-highlighting.zsh diff --git a/.zprezto/modules/syntax-highlighting/external/zsh-syntax-highlighting.zsh b/.zprezto/modules/syntax-highlighting/external/zsh-syntax-highlighting.zsh index 1d63dbf..6838e1d 100644 --- a/.zprezto/modules/syntax-highlighting/external/zsh-syntax-highlighting.zsh +++ b/.zprezto/modules/syntax-highlighting/external/zsh-syntax-highlighting.zsh @@ -1,5 +1,5 @@ # ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2015 zsh-syntax-highlighting contributors +# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted @@ -27,29 +27,41 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- +# First of all, ensure predictable parsing. +zsh_highlight__aliases=`builtin alias -Lm '[^+]*'` +# In zsh <= 5.2, `alias -L` emits aliases that begin with a plus sign ('alias -- +foo=42') +# them without a '--' guard, so they don't round trip. +# +# Hence, we exclude them from unaliasing: +builtin unalias -m '[^+]*' -if [[ -o function_argzero ]]; then +# Set $0 to the expected value, regardless of functionargzero. +0=${(%):-%N} +if true; then # $0 is reliable - ZSH_HIGHLIGHT_VERSION=$(<"$0:A:h"/.version) - ZSH_HIGHLIGHT_REVISION=$(<"$0:A:h"/.revision-hash) + typeset -g ZSH_HIGHLIGHT_VERSION=$(<"${0:A:h}"/.version) + typeset -g ZSH_HIGHLIGHT_REVISION=$(<"${0:A:h}"/.revision-hash) if [[ $ZSH_HIGHLIGHT_REVISION == \$Format:* ]]; then # When running from a source tree without 'make install', $ZSH_HIGHLIGHT_REVISION # would be set to '$Format:%H$' literally. That's an invalid value, and obtaining # the valid value (via `git rev-parse HEAD`, as Makefile does) might be costly, so: - unset ZSH_HIGHLIGHT_REVISION + ZSH_HIGHLIGHT_REVISION=HEAD fi -else - # $0 is unreliable, so the call to _zsh_highlight_load_highlighters will fail. - # TODO: If 'zmodload zsh/parameter' is available, ${funcsourcetrace[1]%:*} might serve as a substitute? - # TODO: also check POSIX_ARGZERO, but not it's not available in older zsh - echo "zsh-syntax-highlighting: error: not compatible with FUNCTION_ARGZERO" >&2 - return 1 fi # ------------------------------------------------------------------------------------------------- # Core highlighting update system # ------------------------------------------------------------------------------------------------- +# Use workaround for bug in ZSH? +# zsh-users/zsh@48cadf4 http://www.zsh.org/mla/workers//2017/msg00034.html +autoload -Uz is-at-least +if is-at-least 5.4; then + zsh_highlight__pat_static_bug=false +else + zsh_highlight__pat_static_bug=true +fi + # Array declaring active highlighters names. typeset -ga ZSH_HIGHLIGHT_HIGHLIGHTERS @@ -62,6 +74,33 @@ _zsh_highlight() # Store the previous command return code to restore it whatever happens. local ret=$? + # Remove all highlighting in isearch, so that only the underlining done by zsh itself remains. + # For details see FAQ entry 'Why does syntax highlighting not work while searching history?'. + # This disables highlighting during isearch (for reasons explained in README.md) unless zsh is new enough + # and doesn't have the pattern matching bug + if [[ $WIDGET == zle-isearch-update ]] && { $zsh_highlight__pat_static_bug || ! (( $+ISEARCHMATCH_ACTIVE )) }; then + region_highlight=() + return $ret + fi + + # Before we 'emulate -L', save the user's options + local -A zsyh_user_options + if zmodload -e zsh/parameter; then + zsyh_user_options=("${(@kv)options}") + else + local canonical_options onoff option raw_options + raw_options=(${(f)"$(emulate -R zsh; set -o)"}) + canonical_options=(${${${(M)raw_options:#*off}%% *}#no} ${${(M)raw_options:#*on}%% *}) + for option in $canonical_options; do + [[ -o $option ]] + # This variable cannot be eliminated c.f. workers/42101. + onoff=${${=:-off on}[2-$?]} + zsyh_user_options+=($option $onoff) + done + fi + typeset -r zsyh_user_options + + emulate -L zsh setopt localoptions warncreateglobal local REPLY # don't leak $REPLY into global scope @@ -84,11 +123,15 @@ _zsh_highlight() local highlighter; for highlighter in $ZSH_HIGHLIGHT_HIGHLIGHTERS; do # eval cache place for current highlighter and prepare it - cache_place="_zsh_highlight_${highlighter}_highlighter_cache" + cache_place="_zsh_highlight__highlighter_${highlighter}_cache" typeset -ga ${cache_place} # If highlighter needs to be invoked - if "_zsh_highlight_${highlighter}_highlighter_predicate"; then + if ! type "_zsh_highlight_highlighter_${highlighter}_predicate" >&/dev/null; then + echo "zsh-syntax-highlighting: warning: disabling the ${(qq)highlighter} highlighter as it has not been loaded" >&2 + # TODO: use ${(b)} rather than ${(q)} if supported + ZSH_HIGHLIGHT_HIGHLIGHTERS=( ${ZSH_HIGHLIGHT_HIGHLIGHTERS:#${highlighter}} ) + elif "_zsh_highlight_highlighter_${highlighter}_predicate"; then # save a copy, and cleanup region_highlight region_highlight_copy=("${region_highlight[@]}") @@ -96,9 +139,9 @@ _zsh_highlight() # Execute highlighter and save result { - "_zsh_highlight_${highlighter}_highlighter" + "_zsh_highlight_highlighter_${highlighter}_paint" } always { - eval "${cache_place}=(\"\${region_highlight[@]}\")" + : ${(AP)cache_place::="${region_highlight[@]}"} } # Restore saved region_highlight @@ -107,38 +150,41 @@ _zsh_highlight() fi # Use value form cache if any cached - eval "region_highlight+=(\"\${${cache_place}[@]}\")" + region_highlight+=("${(@P)cache_place}") done # Re-apply zle_highlight settings - () { - if (( REGION_ACTIVE )) ; then - # zle_highlight[region] defaults to 'standout' if unspecified - local region="${${zle_highlight[(r)region:*]#region:}:-standout}" - integer start end + + # region + if (( REGION_ACTIVE == 1 )); then + _zsh_highlight_apply_zle_highlight region standout "$MARK" "$CURSOR" + elif (( REGION_ACTIVE == 2 )); then + () { + local needle=$'\n' + integer min max if (( MARK > CURSOR )) ; then - start=$CURSOR end=$MARK + min=$CURSOR max=$MARK else - start=$MARK end=$CURSOR + min=$MARK max=$CURSOR fi - region_highlight+=("$start $end $region") - fi - } - # YANK_ACTIVE is only available in zsh-5.1.1 and newer - (( $+YANK_ACTIVE )) && () { - if (( YANK_ACTIVE )) ; then - # zle_highlight[paste] defaults to 'standout' if unspecified - local paste="${${zle_highlight[(r)paste:*]#paste:}:-standout}" - integer start end - if (( YANK_END > YANK_START )) ; then - start=$YANK_START end=$YANK_END - else - start=$YANK_END end=$YANK_START - fi - region_highlight+=("$start $end $paste") - fi - } + # CURSOR and MARK are 0 indexed between letters like region_highlight + # Do not include the newline in the highlight + (( min = ${BUFFER[(Ib:min:)$needle]} )) + (( max = ${BUFFER[(ib:max:)$needle]} - 1 )) + _zsh_highlight_apply_zle_highlight region standout "$min" "$max" + } + fi + + # yank / paste (zsh-5.1.1 and newer) + (( $+YANK_ACTIVE )) && (( YANK_ACTIVE )) && _zsh_highlight_apply_zle_highlight paste standout "$YANK_START" "$YANK_END" + + # isearch + (( $+ISEARCHMATCH_ACTIVE )) && (( ISEARCHMATCH_ACTIVE )) && _zsh_highlight_apply_zle_highlight isearch underline "$ISEARCHMATCH_START" "$ISEARCHMATCH_END" + + # suffix + (( $+SUFFIX_ACTIVE )) && (( SUFFIX_ACTIVE )) && _zsh_highlight_apply_zle_highlight suffix bold "$SUFFIX_START" "$SUFFIX_END" + return $ret @@ -149,6 +195,46 @@ _zsh_highlight() } } +# Apply highlighting based on entries in the zle_highlight array. +# This function takes four arguments: +# 1. The exact entry (no patterns) in the zle_highlight array: +# region, paste, isearch, or suffix +# 2. The default highlighting that should be applied if the entry is unset +# 3. and 4. Two integer values describing the beginning and end of the +# range. The order does not matter. +_zsh_highlight_apply_zle_highlight() { + local entry="$1" default="$2" + integer first="$3" second="$4" + + # read the relevant entry from zle_highlight + # + # ### In zsh≥5.0.8 we'd use ${(b)entry}, but we support older zsh's, so we don't + # ### add (b). The only effect is on the failure mode for callers that violate + # ### the precondition. + local region="${zle_highlight[(r)${entry}:*]-}" + + if [[ -z "$region" ]]; then + # entry not specified at all, use default value + region=$default + else + # strip prefix + region="${region#${entry}:}" + + # no highlighting when set to the empty string or to 'none' + if [[ -z "$region" ]] || [[ "$region" == none ]]; then + return + fi + fi + + integer start end + if (( first < second )); then + start=$first end=$second + else + start=$second end=$first + fi + region_highlight+=("$start $end $region") +} + # ------------------------------------------------------------------------------------------------- # API/utility functions for highlighters @@ -173,6 +259,24 @@ _zsh_highlight_cursor_moved() [[ -n $CURSOR ]] && [[ -n ${_ZSH_HIGHLIGHT_PRIOR_CURSOR-} ]] && (($_ZSH_HIGHLIGHT_PRIOR_CURSOR != $CURSOR)) } +# Add a highlight defined by ZSH_HIGHLIGHT_STYLES. +# +# Should be used by all highlighters aside from 'pattern' (cf. ZSH_HIGHLIGHT_PATTERN). +# Overwritten in tests/test-highlighting.zsh when testing. +_zsh_highlight_add_highlight() +{ + local -i start end + local highlight + start=$1 + end=$2 + shift 2 + for highlight; do + if (( $+ZSH_HIGHLIGHT_STYLES[$highlight] )); then + region_highlight+=("$start $end $ZSH_HIGHLIGHT_STYLES[$highlight]") + break + fi + done +} # ------------------------------------------------------------------------------------------------- # Setup functions @@ -189,36 +293,66 @@ _zsh_highlight_call_widget() # Rebind all ZLE widgets to make them invoke _zsh_highlights. _zsh_highlight_bind_widgets() { + setopt localoptions noksharrays + typeset -F SECONDS + local prefix=orig-s$SECONDS-r$RANDOM # unique each time, in case we're sourced more than once + # Load ZSH module zsh/zleparameter, needed to override user defined widgets. zmodload zsh/zleparameter 2>/dev/null || { - echo 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' >&2 + print -r -- >&2 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' return 1 } # Override ZLE widgets to make them invoke _zsh_highlight. + local -U widgets_to_bind + widgets_to_bind=(${${(k)widgets}:#(.*|run-help|which-command|beep|set-local-history|yank)}) + + # Always wrap special zle-line-finish widget. This is needed to decide if the + # current line ends and special highlighting logic needs to be applied. + # E.g. remove cursor imprint, don't highlight partial paths, ... + widgets_to_bind+=(zle-line-finish) + + # Always wrap special zle-isearch-update widget to be notified of updates in isearch. + # This is needed because we need to disable highlighting in that case. + widgets_to_bind+=(zle-isearch-update) + local cur_widget - for cur_widget in ${${(f)"$(builtin zle -la)"}:#(.*|_*|orig-*|run-help|which-command|beep|set-local-history|yank)}; do - case $widgets[$cur_widget] in + for cur_widget in $widgets_to_bind; do + case ${widgets[$cur_widget]:-""} in # Already rebound event: do nothing. - user:$cur_widget|user:_zsh_highlight_widget_*);; + user:_zsh_highlight_widget_*);; + + # The "eval"'s are required to make $cur_widget a closure: the value of the parameter at function + # definition time is used. + # + # We can't use ${0/_zsh_highlight_widget_} because these widgets are always invoked with + # NO_function_argzero, regardless of the option's setting here. # User defined widget: override and rebind old one with prefix "orig-". - user:*) eval "zle -N orig-$cur_widget ${widgets[$cur_widget]#*:}; \ - _zsh_highlight_widget_$cur_widget() { _zsh_highlight_call_widget orig-$cur_widget \"\$@\" }; \ - zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; + user:*) zle -N $prefix-$cur_widget ${widgets[$cur_widget]#*:} + eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget ${(q)prefix}-${(q)cur_widget} -- \"\$@\" }" + zle -N $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;; # Completion widget: override and rebind old one with prefix "orig-". - completion:*) eval "zle -C orig-$cur_widget ${${widgets[$cur_widget]#*:}/:/ }; \ - _zsh_highlight_widget_$cur_widget() { _zsh_highlight_call_widget orig-$cur_widget \"\$@\" }; \ - zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; + completion:*) zle -C $prefix-$cur_widget ${${(s.:.)widgets[$cur_widget]}[2,3]} + eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget ${(q)prefix}-${(q)cur_widget} -- \"\$@\" }" + zle -N $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;; # Builtin widget: override and make it call the builtin ".widget". - builtin) eval "_zsh_highlight_widget_$cur_widget() { _zsh_highlight_call_widget .$cur_widget \"\$@\" }; \ - zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; + builtin) eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget .${(q)cur_widget} -- \"\$@\" }" + zle -N $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;; + # Incomplete or nonexistent widget: Bind to z-sy-h directly. + *) + if [[ $cur_widget == zle-* ]] && (( ! ${+widgets[$cur_widget]} )); then + _zsh_highlight_widget_${cur_widget}() { :; _zsh_highlight } + zle -N $cur_widget _zsh_highlight_widget_$cur_widget + else # Default: unhandled case. - *) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;; + print -r -- >&2 "zsh-syntax-highlighting: unhandled ZLE widget ${(qq)cur_widget}" + print -r -- >&2 "zsh-syntax-highlighting: (This is sometimes caused by doing \`bindkey ${(q-)cur_widget}\` without creating the ${(qq)cur_widget} widget with \`zle -N\` or \`zle -C\`.)" + fi esac done } @@ -229,23 +363,38 @@ _zsh_highlight_bind_widgets() # 1) Path to the highlighters directory. _zsh_highlight_load_highlighters() { + setopt localoptions noksharrays + # Check the directory exists. [[ -d "$1" ]] || { - echo "zsh-syntax-highlighting: highlighters directory '$1' not found." >&2 + print -r -- >&2 "zsh-syntax-highlighting: highlighters directory ${(qq)1} not found." return 1 } # Load highlighters from highlighters directory and check they define required functions. local highlighter highlighter_dir - for highlighter_dir ($1/*/); do + for highlighter_dir ($1/*/(/)); do highlighter="${highlighter_dir:t}" - [[ -f "$highlighter_dir/${highlighter}-highlighter.zsh" ]] && { - . "$highlighter_dir/${highlighter}-highlighter.zsh" - type "_zsh_highlight_${highlighter}_highlighter" &> /dev/null && - type "_zsh_highlight_${highlighter}_highlighter_predicate" &> /dev/null || { - echo "zsh-syntax-highlighting: '${highlighter}' highlighter should define both required functions '_zsh_highlight_${highlighter}_highlighter' and '_zsh_highlight_${highlighter}_highlighter_predicate' in '${highlighter_dir}/${highlighter}-highlighter.zsh'." >&2 - } - } + [[ -f "$highlighter_dir${highlighter}-highlighter.zsh" ]] && + . "$highlighter_dir${highlighter}-highlighter.zsh" + if type "_zsh_highlight_highlighter_${highlighter}_paint" &> /dev/null && + type "_zsh_highlight_highlighter_${highlighter}_predicate" &> /dev/null; + then + # New (0.5.0) function names + elif type "_zsh_highlight_${highlighter}_highlighter" &> /dev/null && + type "_zsh_highlight_${highlighter}_highlighter_predicate" &> /dev/null; + then + # Old (0.4.x) function names + if false; then + # TODO: only show this warning for plugin authors/maintainers, not for end users + print -r -- >&2 "zsh-syntax-highlighting: warning: ${(qq)highlighter} highlighter uses deprecated entry point names; please ask its maintainer to update it: https://github.com/zsh-users/zsh-syntax-highlighting/issues/329" + fi + # Make it work. + eval "_zsh_highlight_highlighter_${(q)highlighter}_paint() { _zsh_highlight_${(q)highlighter}_highlighter \"\$@\" }" + eval "_zsh_highlight_highlighter_${(q)highlighter}_predicate() { _zsh_highlight_${(q)highlighter}_highlighter_predicate \"\$@\" }" + else + print -r -- >&2 "zsh-syntax-highlighting: ${(qq)highlighter} highlighter should define both required functions '_zsh_highlight_highlighter_${highlighter}_paint' and '_zsh_highlight_highlighter_${highlighter}_predicate' in ${(qq):-"$highlighter_dir${highlighter}-highlighter.zsh"}." + fi done } @@ -256,13 +405,13 @@ _zsh_highlight_load_highlighters() # Try binding widgets. _zsh_highlight_bind_widgets || { - echo 'zsh-syntax-highlighting: failed binding ZLE widgets, exiting.' >&2 + print -r -- >&2 'zsh-syntax-highlighting: failed binding ZLE widgets, exiting.' return 1 } # Resolve highlighters directory location. _zsh_highlight_load_highlighters "${ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR:-${${0:A}:h}/highlighters}" || { - echo 'zsh-syntax-highlighting: failed loading highlighters, exiting.' >&2 + print -r -- >&2 'zsh-syntax-highlighting: failed loading highlighters, exiting.' return 1 } @@ -272,10 +421,20 @@ _zsh_highlight_preexec_hook() typeset -g _ZSH_HIGHLIGHT_PRIOR_BUFFER= typeset -gi _ZSH_HIGHLIGHT_PRIOR_CURSOR= } -autoload -U add-zsh-hook +autoload -Uz add-zsh-hook add-zsh-hook preexec _zsh_highlight_preexec_hook 2>/dev/null || { - echo 'zsh-syntax-highlighting: failed loading add-zsh-hook.' >&2 + print -r -- >&2 'zsh-syntax-highlighting: failed loading add-zsh-hook.' } +# Load zsh/parameter module if available +zmodload zsh/parameter 2>/dev/null || true + # Initialize the array of active highlighters if needed. -[[ $#ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main) || true +[[ $#ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main) + +# Restore the aliases we unned +eval "$zsh_highlight__aliases" +builtin unset zsh_highlight__aliases + +# Set $?. +true diff --git a/.zprezto/modules/syntax-highlighting/init.zsh b/.zprezto/modules/syntax-highlighting/init.zsh index 25cd96b..52cc0c3 100644 --- a/.zprezto/modules/syntax-highlighting/init.zsh +++ b/.zprezto/modules/syntax-highlighting/init.zsh @@ -26,3 +26,11 @@ for syntax_highlighting_style in "${(k)syntax_highlighting_styles[@]}"; do ZSH_HIGHLIGHT_STYLES[$syntax_highlighting_style]="$syntax_highlighting_styles[$syntax_highlighting_style]" done unset syntax_highlighting_style{s,} + +# Set pattern highlighting styles. +typeset -A syntax_pattern_styles +zstyle -a ':prezto:module:syntax-highlighting' pattern 'syntax_pattern_styles' +for syntax_pattern_style in "${(k)syntax_pattern_styles[@]}"; do + ZSH_HIGHLIGHT_PATTERNS[$syntax_pattern_style]="$syntax_pattern_styles[$syntax_pattern_style]" +done +unset syntax_pattern_style{s,} diff --git a/.zprezto/modules/terminal/README.md b/.zprezto/modules/terminal/README.md index 58f81be..41a0885 100644 --- a/.zprezto/modules/terminal/README.md +++ b/.zprezto/modules/terminal/README.md @@ -11,16 +11,27 @@ Settings To auto set the terminal window and tab titles with the current command or directory, add the following to *zpreztorc*: - zstyle ':prezto:module:terminal' auto-title 'yes' +```sh +zstyle ':prezto:module:terminal' auto-title 'yes' +``` -Auto titling is disabled inside terminal multiplexers, except inside dvtm, since -it interferes with window names defined in configuration files and profile -managers. +Auto titling is disabled inside terminal multiplexers (except inside dvtm) +since it interferes with window names defined in configuration files and +profile managers. This can be overridden by setting it to `always`. + +```sh +zstyle ':prezto:module:terminal' auto-title 'always' +``` + +### Title formats To format terminal window and tab titles, add the following to *zpreztorc*: - zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s' - zstyle ':prezto:module:terminal:tab-title' format '%m: %s' +```sh +zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s' +zstyle ':prezto:module:terminal:tab-title' format '%m: %s' +zstyle ':prezto:module:terminal:multiplexer-title' format '%s' +``` `%s` will be replaced with the current working directory path or the currently executing program name. @@ -31,7 +42,8 @@ Functions --------- - `set-tab-title` sets the terminal tab title. -- `set-window-title` sets the terminal or terminal multiplexer window title. +- `set-window-title` sets the terminal window title. +- `set-multiplexer-title` sets the terminal multiplexer title. Authors ------- @@ -39,6 +51,7 @@ Authors *The authors of this module should be contacted via the [issue tracker][2].* - [Sorin Ionescu](https://github.com/sorin-ionescu) + - [Olaf Conradi](https://github.com/oohlaf) [1]: http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Expansion-of-Prompt-Sequences [2]: https://github.com/sorin-ionescu/prezto/issues diff --git a/.zprezto/modules/terminal/init.zsh b/.zprezto/modules/terminal/init.zsh index b0be502..2a5b9be 100644 --- a/.zprezto/modules/terminal/init.zsh +++ b/.zprezto/modules/terminal/init.zsh @@ -3,6 +3,7 @@ # # Authors: # Sorin Ionescu +# Olaf Conradi # # Return if requirements are not found. @@ -10,19 +11,12 @@ if [[ "$TERM" == (dumb|linux|*bsd*|eterm*) ]]; then return 1 fi -# Sets the terminal or terminal multiplexer window title. +# Sets the terminal window title. function set-window-title { local title_format{,ted} zstyle -s ':prezto:module:terminal:window-title' format 'title_format' || title_format="%s" zformat -f title_formatted "$title_format" "s:$argv" - - if [[ "$TERM" == screen* ]]; then - title_format="\ek%s\e\\" - else - title_format="\e]2;%s\a" - fi - - printf "$title_format" "${(V%)title_formatted}" + printf '\e]2;%s\a' "${(V%)title_formatted}" } # Sets the terminal tab title. @@ -30,8 +24,15 @@ function set-tab-title { local title_format{,ted} zstyle -s ':prezto:module:terminal:tab-title' format 'title_format' || title_format="%s" zformat -f title_formatted "$title_format" "s:$argv" + printf '\e]1;%s\a' "${(V%)title_formatted}" +} - printf "\e]1;%s\a" ${(V%)title_formatted} +# Sets the terminal multiplexer tab title. +function set-multiplexer-title { + local title_format{,ted} + zstyle -s ':prezto:module:terminal:multiplexer-title' format 'title_format' || title_format="%s" + zformat -f title_formatted "$title_format" "s:$argv" + printf '\ek%s\e\\' "${(V%)title_formatted}" } # Sets the tab and window titles with a given command. @@ -48,7 +49,7 @@ function _terminal-set-titles-with-command { local -A jobtexts_from_parent_shell jobtexts_from_parent_shell=(${(kv)jobtexts}) - jobs "$job_name" 2>/dev/null > >( + jobs "$job_name" 2> /dev/null > >( read index discarded # The index is already surrounded by brackets: [1]. _terminal-set-titles-with-command "${(e):-\$jobtexts_from_parent_shell$index}" @@ -59,8 +60,11 @@ function _terminal-set-titles-with-command { local truncated_cmd="${cmd/(#m)?(#c15,)/${MATCH[1,12]}...}" unset MATCH - set-window-title "$cmd" + if [[ "$TERM" == screen* ]]; then + set-multiplexer-title "$truncated_cmd" + fi set-tab-title "$truncated_cmd" + set-window-title "$cmd" fi } @@ -74,8 +78,11 @@ function _terminal-set-titles-with-path { local truncated_path="${abbreviated_path/(#m)?(#c15,)/...${MATCH[-12,-1]}}" unset MATCH - set-window-title "$abbreviated_path" + if [[ "$TERM" == screen* ]]; then + set-multiplexer-title "$truncated_path" + fi set-tab-title "$truncated_path" + set-window-title "$abbreviated_path" } # Do not override precmd/preexec; append to the hook array. @@ -110,12 +117,13 @@ then fi # Set up non-Apple terminals. -if zstyle -t ':prezto:module:terminal' auto-title \ - && ( ! [[ -n "$STY" || -n "$TMUX" ]] ) +if zstyle -t ':prezto:module:terminal' auto-title 'always' \ + || (zstyle -t ':prezto:module:terminal' auto-title \ + && ( ! [[ -n "$STY" || -n "$TMUX" ]] )) then - # Sets the tab and window titles before the prompt is displayed. + # Sets titles before the prompt is displayed. add-zsh-hook precmd _terminal-set-titles-with-path - # Sets the tab and window titles before command execution. + # Sets titles before command execution. add-zsh-hook preexec _terminal-set-titles-with-command fi diff --git a/.zprezto/modules/tmux/README.md b/.zprezto/modules/tmux/README.md index 11c8a08..0738d7c 100644 --- a/.zprezto/modules/tmux/README.md +++ b/.zprezto/modules/tmux/README.md @@ -13,29 +13,43 @@ Starts a tmux session automatically when Zsh is launched. To enable this feature when launching Zsh in a local terminal, add the following line to *zpreztorc*: - zstyle ':prezto:module:tmux:auto-start' local 'yes' +```sh +zstyle ':prezto:module:tmux:auto-start' local 'yes' +``` To enable this feature when launching Zsh in a SSH connection, add the following line to *zpreztorc*: - zstyle ':prezto:module:tmux:auto-start' remote 'yes' +```sh +zstyle ':prezto:module:tmux:auto-start' remote 'yes' +``` In both cases, it will create a background session named _prezto_ if the tmux server is not started. +You can change the default session name with: + +```sh +zstyle ':prezto:module:tmux:session' name '' +``` + With `auto-start` enabled, you may want to control how multiple sessions are managed. The `destroy-unattached` option of tmux controls if the unattached sessions must be kept alive, making sessions available for later use, configured in *tmux.conf*: - set-option -g destroy-unattached [on | off] +```conf +set-option -g destroy-unattached [on | off] +``` #### iTerm2 Integration [iTerm2][6] offers significant integration with tmux. This can be enabled by adding the following line to *zpreztorc*: - zstyle ':prezto:module:tmux:iterm' integrate 'yes' +```sh +zstyle ':prezto:module:tmux:iterm' integrate 'yes' +``` Read [iTerm2 and tmux Integration][7] for more information. @@ -48,14 +62,16 @@ Aliases Caveats ------- -On Mac OS X, launching tmux can cause the error **launch_msg(...): Socket is not +On macOS, launching tmux can cause the error **launch_msg(...): Socket is not connected** to be displayed, which can be fixed by installing [reattach-to-user-namespace][3], available in [Homebrew][4], and adding the following to *tmux.conf*: - set-option -g default-command "reattach-to-user-namespace -l $SHELL -l" +```conf +set-option -g default-command "reattach-to-user-namespace -l $SHELL -l" +``` -Furthermore, tmux is known to cause **kernel panics** on Mac OS X. A discussion +Furthermore, tmux is known to cause **kernel panics** on macOS. A discussion about this and Prezto has already been [opened][2]. Authors diff --git a/.zprezto/modules/tmux/init.zsh b/.zprezto/modules/tmux/init.zsh index 070abca..fb56d07 100644 --- a/.zprezto/modules/tmux/init.zsh +++ b/.zprezto/modules/tmux/init.zsh @@ -23,7 +23,7 @@ if ([[ "$TERM_PROGRAM" = 'iTerm.app' ]] && \ _tmux_iterm_integration='-CC' fi -if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" ]] && ( \ +if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" && -z "$INSIDE_EMACS" && -z "$VSCODE_PID" ]] && ( \ ( [[ -n "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' remote ) || ( [[ -z "$SSH_TTY" ]] && zstyle -t ':prezto:module:tmux:auto-start' local ) \ ); then @@ -31,14 +31,14 @@ if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" ]] && ( \ # Create a 'prezto' session if no session has been defined in tmux.conf. if ! tmux has-session 2> /dev/null; then - tmux_session='prezto' + zstyle -s ':prezto:module:tmux:session' name tmux_session || tmux_session='prezto' tmux \ new-session -d -s "$tmux_session" \; \ set-option -t "$tmux_session" destroy-unattached off &> /dev/null fi - # Attach to the 'prezto' session or to the last session used. - exec tmux $_tmux_iterm_integration attach-session + # Attach to the 'prezto' session or to the last session used. (detach first) + exec tmux $_tmux_iterm_integration attach-session -d fi # diff --git a/.zprezto/modules/utility/README.md b/.zprezto/modules/utility/README.md index 5e7919e..84e81f5 100644 --- a/.zprezto/modules/utility/README.md +++ b/.zprezto/modules/utility/README.md @@ -14,19 +14,27 @@ commands. To disable `ls` color, add the following line to *zpreztorc*; when coloring is disabled, type indicators (\*, /, =>, @, =, |, %) will be appended to entries. - zstyle ':prezto:module:utility:ls' color 'no' +```sh +zstyle ':prezto:module:utility:ls' color 'no' +``` To disable `diff` highlighting, add the following line to *zpreztorc*: - zstyle ':prezto:module:utility:diff' color 'no' +```sh +zstyle ':prezto:module:utility:diff' color 'no' +``` To disable `wdiff` highlighting, add the following line to *zpreztorc*: - zstyle ':prezto:module:utility:wdiff' color 'no' +```sh +zstyle ':prezto:module:utility:wdiff' color 'no' +``` To disable `make` highlighting, add the following line to *zpreztorc*: - zstyle ':prezto:module:utility:make' color 'no' +```sh +zstyle ':prezto:module:utility:make' color 'no' +``` Aliases ------- @@ -57,24 +65,22 @@ Aliases - `history` - `locate` - `rake` - - `rsync` - - `scp` + - `rsync` (selectively enabled for local files) + - `scp` (selectively enabled for local files) - `sftp` ### General - `_` executes a command as another user (`sudo`). - `b` opens the default web browser. - - `cp` copies files and directories interactively. + - `diffu` shorthand for `diff --unified` - `e` opens the default editor. - - `ln` links files and directories interactively. - `mkdir` creates directories, including intermediary directories. - - `mv` moves files and directories interactively. - `p` opens the default pager. - `po` removes a directory from the stack and changes to it (`popd`). - `pu` changes the directory and pushes the old directory onto the stack (`pushd`). - - `rm` removes files and directories interactively. + - `sa` search aliases for a word. - `type` displays all the attribute values of a shell parameter. ### Files and Directories @@ -92,7 +98,7 @@ Aliases - `lu` lists sorted by date, most recent last, shows access time. - `sl` lists directory contents (`ls`). -### Mac OS X Everywhere +### macOS Everywhere - `o` opens files and directories (`open` or `xdg-open`). - `get` downloads files (`curl` or `wget`). @@ -103,13 +109,26 @@ Aliases ### Resource Usage - - `df` displays free disk space using human readable units. + - `df` displays free disk space using human readable units (aliases to `pydf`, if installed). - `du` displays disk usage using human readable units. - - `top` displays information about processes (aliased to `htop`, if installed). - - `topc` displays information about processes sorted by CPU usage (`htop` not - installed). - - `topm` displays information about processes sorted by RAM usage (`htop` not - installed). + - `top` displays information about processes. + - `topc` displays information about processes sorted by CPU usage. + - `topm` displays information about processes sorted by RAM usage. + +### Safe ops + +By default, `cp`,`ln`, `mv` and `rm` are aliased to their interactive variants. +If this is not desired, it can be disabled by adding the following line to +*zpreztorc*: + + zstyle ':prezto:module:utility' safe-ops 'no'. + +In addition, the following aliases have been added: + + - `cpi` copies files and directories interactively. + - `lni` links files and directories interactively. + - `mvi` moves files and directories interactively. + - `rmi` removes files and directories interactively. ### Miscellaneous @@ -130,10 +149,11 @@ Functions - `mkdcd` makes a directory and changes to it. - `popdls` pops an entry off the directory stack and lists its contents. - `pushdls` pushes an entry onto the directory stack and lists its contents. + - `noremoteglob` enable local path globbing but disable remote path globbing. ### Developer - - `diff` highlights diff output (requires `colordiff` or `Git`). + - `diff` highlights diff output (requires `colordiff`). - `make` highlights make output (requires `colormake`). - `wdiff` highlights wdiff output (requires `wdiff `or `Git`). diff --git a/.zprezto/modules/utility/functions/_noremoteglob b/.zprezto/modules/utility/functions/_noremoteglob new file mode 100644 index 0000000..de5290e --- /dev/null +++ b/.zprezto/modules/utility/functions/_noremoteglob @@ -0,0 +1,11 @@ +#compdef noremoteglob +#autoload + +# +# Completes noremoteglob. +# +# Authors: +# Indrajit Raychaudhuri +# + +_precommand diff --git a/.zprezto/modules/utility/functions/diff b/.zprezto/modules/utility/functions/diff index 8347899..d614b28 100644 --- a/.zprezto/modules/utility/functions/diff +++ b/.zprezto/modules/utility/functions/diff @@ -6,16 +6,11 @@ # function diff { - if zstyle -t ':prezto:module:utility:diff' color; then - if (( $+commands[colordiff] )); then - command diff --unified "$@" | colordiff --difftype diffu - elif (( $+commands[git] )); then - git --no-pager diff --color=auto --no-ext-diff --no-index "$@" - else - command diff --unified "$@" - fi + if zstyle -t ':prezto:module:utility:diff' color \ + && (( $+commands[colordiff] )); then + command colordiff "$@" else - command diff --unified "$@" + command diff "$@" fi } diff --git a/.zprezto/modules/utility/functions/prep b/.zprezto/modules/utility/functions/prep index 23028ec..d6448ae 100644 --- a/.zprezto/modules/utility/functions/prep +++ b/.zprezto/modules/utility/functions/prep @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function prep { + local usage pattern modifiers invert usage="$( @@ -50,3 +52,5 @@ pattern="$1" shift perl -n -l -e "print if ${invert:+not} m/${pattern//\//\\/}/${modifiers}" "$@" + +# } diff --git a/.zprezto/modules/utility/functions/psub b/.zprezto/modules/utility/functions/psub index ffc0108..af191fd 100644 --- a/.zprezto/modules/utility/functions/psub +++ b/.zprezto/modules/utility/functions/psub @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function psub { + local usage pattern replacement modifiers usage="$( @@ -51,3 +53,5 @@ replacement="$2" repeat 2 shift perl -i'.orig' -n -l -e "s/${pattern//\//\\/}/${replacement//\//\\/}/${modifiers}; print" "$@" + +# } diff --git a/.zprezto/modules/utility/functions/wdiff b/.zprezto/modules/utility/functions/wdiff index c93ead1..ebfad0b 100644 --- a/.zprezto/modules/utility/functions/wdiff +++ b/.zprezto/modules/utility/functions/wdiff @@ -17,7 +17,7 @@ function wdiff { "$@" \ | sed 's/^\(@@\( [+-][[:digit:]]*,[[:digit:]]*\)\{2\} @@\)$/;5;6m\10m/g' elif (( $+commands[git] )); then - git --no-pager diff --color=auto --no-ext-diff --no-index --color-words "$@" + command git --no-pager diff --color=auto --no-ext-diff --no-index --color-words "$@" else command wdiff "$@" fi diff --git a/.zprezto/modules/utility/functions/zsh-help b/.zprezto/modules/utility/functions/zsh-help new file mode 100644 index 0000000..f6605ea --- /dev/null +++ b/.zprezto/modules/utility/functions/zsh-help @@ -0,0 +1,102 @@ +# +# Provides a much easier way to search and access ZSH's manual. First checks for +# terms at the start of the manual, then checks if it's at start of a line allowing +# whitespace. +# +# Authors: +# Samantha McVey +# + +# function zsh-help { + +local usage="$( +cat <&2; fi + if man --pager='' ${i} | grep -E ${case} "${pattern}" > /dev/null; then + printf "%s" "${i}"; return 0; + fi + done + return 1 + } + # By default search only things at start of line + local first_prefix='^' + local prefix='^\s*' + if [[ ${1} == '--zsh-help-debug' ]]; then + shift; debug=1 + fi + if [[ ${1} == "--all" ]]; then + shift; first_prefix='' # We're searching everything, so remove the prefix + fi + if [[ $# < 1 || $1 == "--help" ]]; then + printf "%s\n" "${usage}" + unfunction _zsh-help-join; unfunction _zsh-help-try-query; # unfunction so it's not in the global scope + return 1 + fi + if [[ ${1} == "test" && $# == 1 ]]; then + case='' + pattern='^CONDITIONAL EXPRESSIONS$' + elif [[ ($1 == "-eq" || $1 == "-ne" || $1 == "-lt" || $1 == "-gt" || $1 == "-le" || $1 == "-ge") && $# == 1 ]]; then + case='' + pattern="${prefix}exp1\s+${1}\s+exp2" + elif [[ $1 == 'zstyle' ]]; then + pattern=$(_zsh-help-join '\s+' "$@") + section=ZSHMODULES + fi + # If it wasn't one of the special-cased things, check ZSHBUILTINS first. If + # not found there, we will search ZSHALL + if [[ ${pattern} == "" ]]; then + pattern="$(_zsh-help-join '\s+' "$@")" + # search for sections at the start of the man page first + section=$(_zsh-help-try-query "${case}" "${first_prefix}${pattern}") + # If it exists there, keep ZSHBUILTINS as the section + if (( $? == 0 )); then + pattern="${first_prefix}${pattern}" + elif [[ "${prefix}" ]]; then + # if not found, search for the term preceeded by whitetext + section=$(_zsh-help-try-query "${case}" "${prefix}${pattern}") + if (( $? == 0 )); then + pattern="${prefix}${pattern}" + else + pattern="" + fi + fi + if [[ ! ${pattern} ]]; then # Otherwise we use zshall + printf "Can't find term\n" 2>&1 + unfunction _zsh-help-join; unfunction _zsh-help-try-query; # unfunction so it's not in the global scope + return 1; + fi + fi + local command="man --pager=\"less ${case} -p '${pattern}'\" \"${section}\"" + if [[ ${debug} ]]; then + printf "\nFinal search term is:\n"; printf "%s\n" "${command}"; + else + eval $command + fi + local rtrn=$? + unfunction _zsh-help-join; unfunction _zsh-help-try-query; # unfunction so it's not in the global scope + return $? +#} diff --git a/.zprezto/modules/utility/init.zsh b/.zprezto/modules/utility/init.zsh index 9efd529..942090d 100644 --- a/.zprezto/modules/utility/init.zsh +++ b/.zprezto/modules/utility/init.zsh @@ -41,30 +41,48 @@ alias ftp='noglob ftp' alias history='noglob history' alias locate='noglob locate' alias rake='noglob rake' -# alias rsync='noglob rsync' +alias rsync='noglob rsync' alias scp='noglob scp' alias sftp='noglob sftp' # Define general aliases. alias _='sudo' alias b='${(z)BROWSER}' + +alias diffu="diff --unified" alias e='${(z)VISUAL:-${(z)EDITOR}}' alias mkdir="${aliases[mkdir]:-mkdir} -p" alias p='${(z)PAGER}' alias po='popd' alias pu='pushd' +alias sa='alias | grep -i' alias type='type -a' +# Safe ops. Ask the user before doing anything destructive. +alias rmi="${aliases[rm]:-rm} -i" +alias mvi="${aliases[mv]:-mv} -i" +alias cpi="${aliases[cp]:-cp} -i" +alias lni="${aliases[ln]:-ln} -i" +if zstyle -T ':prezto:module:utility' safe-ops; then + alias rm='rmi' + alias mv='mvi' + alias cp='cpi' + alias ln='lni' +fi + # ls if is-callable 'dircolors'; then # GNU Core Utilities alias ls='ls --group-directories-first' if zstyle -t ':prezto:module:utility:ls' color; then - if [[ -s "$HOME/.dir_colors" ]]; then - eval "$(dircolors --sh "$HOME/.dir_colors")" - else - eval "$(dircolors --sh)" + # Call dircolors to define colors if they're missing + if [[ -z "$LS_COLORS" ]]; then + if [[ -s "$HOME/.dir_colors" ]]; then + eval "$(dircolors --sh "$HOME/.dir_colors")" + else + eval "$(dircolors --sh)" + fi fi alias ls="${aliases[ls]:-ls} --color=auto" @@ -74,11 +92,15 @@ if is-callable 'dircolors'; then else # BSD Core Utilities if zstyle -t ':prezto:module:utility:ls' color; then - # Define colors for BSD ls. - export LSCOLORS='exfxcxdxbxGxDxabagacad' + # Define colors for BSD ls if they're not already defined + if [[ -z "$LSCOLORS" ]]; then + export LSCOLORS='exfxcxdxbxGxDxabagacad' + fi - # Define colors for the completion system. - export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:' + # Define colors for the completion system if they're not already defined + if [[ -z "$LS_COLORS" ]]; then + export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:' + fi alias ls="${aliases[ls]:-ls} -G" else @@ -86,10 +108,7 @@ else fi fi -# printf "${aliases[ls]:-ls}" -# alias lss="${aliases[ls]:-ls}" -# alias ls="${aliases[ls]:-ls} -A" -alias l='ls -lAh' # Lists in one column, hidden files. +alias l='ls -1A' # Lists in one column, hidden files. alias ll='ls -lh' # Lists human readable sizes. alias lr='ll -R' # Lists human readable sizes, recursively. alias la='ll -A' # Lists human readable sizes, hidden files. @@ -109,7 +128,7 @@ if zstyle -t ':prezto:module:utility:grep' color; then alias grep="${aliases[grep]:-grep} --color=auto" fi -# Mac OS X Everywhere +# macOS Everywhere if [[ "$OSTYPE" == darwin* ]]; then alias o='open' elif [[ "$OSTYPE" == cygwin* ]]; then @@ -142,22 +161,22 @@ fi alias df='df -kh' alias du='du -kh' -if (( $+commands[htop] )); then - alias top=htop +if [[ "$OSTYPE" == (darwin*|*bsd*) ]]; then + alias topc='top -o cpu' + alias topm='top -o vsize' else - if [[ "$OSTYPE" == (darwin*|*bsd*) ]]; then - alias topc='top -o cpu' - alias topm='top -o vsize' - else - alias topc='top -o %CPU' - alias topm='top -o %MEM' - fi + alias topc='top -o %CPU' + alias topm='top -o %MEM' fi # Miscellaneous # Serves a directory via HTTP. -alias http-serve='python -m SimpleHTTPServer' +if (( $+commands[python3] )); then + alias http-serve='python3 -m http.server' +else + alias http-serve='python -m SimpleHTTPServer' +fi # # Functions @@ -197,3 +216,27 @@ function find-exec { function psu { ps -U "${1:-$LOGNAME}" -o 'pid,%cpu,%mem,command' "${(@)argv[2,-1]}" } + +# Enables globbing selectively on path arguments. +# Globbing is enabled on local paths (starting in '/' and './') and disabled +# on remote paths (containing ':' but not starting in '/' and './'). This is +# useful for programs that have their own globbing for remote paths. +# Currently, this is used by default for 'rsync' and 'scp'. +# Example: +# - Local: '*.txt', './foo:2017*.txt', '/var/*:log.txt' +# - Remote: user@localhost:foo/ +# +# NOTE: This function is buggy and is not used anywhere until we can make sure +# it's fixed. See https://github.com/sorin-ionescu/prezto/issues/1443 and +# https://github.com/sorin-ionescu/prezto/issues/1521 for more information. +function noremoteglob { + local -a argo + local cmd="$1" + for arg in ${argv:2}; do case $arg in + ( ./* ) argo+=( ${~arg} ) ;; # local relative, glob + ( /* ) argo+=( ${~arg} ) ;; # local absolute, glob + ( *:* ) argo+=( ${arg} ) ;; # remote, noglob + ( * ) argo+=( ${~arg} ) ;; # default, glob + esac; done + command $cmd "${(@)argo}" +} diff --git a/.zprezto/modules/wakeonlan/README.md b/.zprezto/modules/wakeonlan/README.md index 9bde199..dacfa52 100644 --- a/.zprezto/modules/wakeonlan/README.md +++ b/.zprezto/modules/wakeonlan/README.md @@ -14,11 +14,15 @@ Each file should contain a line with the MAC address of the target device and the network broadcast address. For instance, there might be a file *~/.wakeonlan/leto* with the following contents: - 00:11:22:33:44:55:66 192.168.0.255 +```conf +00:11:22:33:44:55:66 192.168.0.255 +``` To wake that device, use the following command: - wake leto +```sh +$ wake leto +``` For more information on the configuration file format, read the [wakeonlan man page][2]. diff --git a/.zprezto/modules/wakeonlan/functions/wake b/.zprezto/modules/wakeonlan/functions/wake index 5259c95..6f7d6c5 100644 --- a/.zprezto/modules/wakeonlan/functions/wake +++ b/.zprezto/modules/wakeonlan/functions/wake @@ -6,6 +6,8 @@ # Sorin Ionescu # +# function wake { + local config_file="$HOME/.wakeonlan/$1" if [[ ! -s "$config_file" ]]; then print "$0: invalid device file: $1" >&2 @@ -18,3 +20,5 @@ if (( ! $+commands[wakeonlan] )); then fi wakeonlan -f "$config_file" + +# } diff --git a/.zprezto/modules/zbell/init.zsh b/.zprezto/modules/zbell/init.zsh deleted file mode 100644 index d9e6103..0000000 --- a/.zprezto/modules/zbell/init.zsh +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env zsh - -# This script prints a bell character when a command finishes -# if it has been running for longer than $zbell_duration seconds. -# If there are programs that you know run long that you don't -# want to bell after, then add them to $zbell_ignore. -# -# This script uses only zsh builtins so its fast, there's no needless -# forking, and its only dependency is zsh and its standard modules -# -# Written by Jean-Philippe Ouellet -# Made available under the ISC license. - -# only do this if we're in an interactive shell -[[ -o interactive ]] || return - -# get $EPOCHSECONDS. builtins are faster than date(1) -zmodload zsh/datetime || return - -# make sure we can register hooks -autoload -Uz add-zsh-hook || return - -# initialize zbell_duration if not set -(( ${+zbell_duration} )) || zbell_duration=15 - -# initialize zbell_ignore if not set -(( ${+zbell_ignore} )) || zbell_ignore=($EDITOR $PAGER) - -# initialize it because otherwise we compare a date and an empty string -# the first time we see the prompt. it's fine to have lastcmd empty on the -# initial run because it evaluates to an empty string, and splitting an -# empty string just results in an empty array. -zbell_timestamp=$EPOCHSECONDS - -# right before we begin to execute something, store the time it started at -zbell_begin() { - zbell_timestamp=$EPOCHSECONDS - zbell_lastcmd=$1 -} - -# when it finishes, if it's been running longer than $zbell_duration, -# and we dont have an ignored command in the line, then print a bell. -zbell_end() { - ret_code=$? - - ran_long=$(( $EPOCHSECONDS - $zbell_timestamp >= $zbell_duration )) - - has_ignored_cmd=0 - for cmd in ${(s:;:)zbell_lastcmd//|/;}; do - words=(${(z)cmd}) - util=${words[1]} - if (( ${zbell_ignore[(i)$util]} <= ${#zbell_ignore} )); then - has_ignored_cmd=1 - break - fi - done - - if (( ! $has_ignored_cmd )) && (( ran_long )); then - if [[ $ret_code != 0 ]]; then - print -n "\a" - sleep 0.3 - fi - print -n "\a" - fi -} - -# register the functions as hooks -add-zsh-hook preexec zbell_begin -add-zsh-hook precmd zbell_end \ No newline at end of file diff --git a/.zprezto/runcoms/zpreztorc b/.zprezto/runcoms/zpreztorc index fffb0f3..e8c2e27 100644 --- a/.zprezto/runcoms/zpreztorc +++ b/.zprezto/runcoms/zpreztorc @@ -15,6 +15,9 @@ # Color output (auto set to 'no' on dumb terminals). zstyle ':prezto:*:*' color 'yes' +# Add additional directories to load prezto modules from +# zstyle ':prezto:load' pmodule-dirs $HOME/.zprezto-contrib + # Set the Zsh modules to load (man zshmodules). # zstyle ':prezto:load' zmodule 'attr' 'stat' @@ -31,17 +34,14 @@ zstyle ':prezto:load' pmodule \ 'directory' \ 'spectrum' \ 'utility' \ - 'ssh' \ 'completion' \ + 'prompt' \ + 'ssh' \ 'homebrew' \ 'osx' \ - 'ruby' \ - 'rails' \ 'git' \ 'syntax-highlighting' \ - 'history-substring-search' \ - 'prompt' \ - 'zbell' + 'history-substring-search' # # Autosuggestions @@ -50,6 +50,14 @@ zstyle ':prezto:load' pmodule \ # Set the query found color. # zstyle ':prezto:module:autosuggestions:color' found '' +# +# Completions +# + +# Set the entries to ignore in static */etc/hosts* for host completion. +# zstyle ':prezto:module:completion:*:hosts' etc-host-ignores \ +# '0.0.0.0' '127.0.0.1' + # # Editor # @@ -60,6 +68,9 @@ zstyle ':prezto:module:editor' key-bindings 'emacs' # Auto convert .... to ../.. # zstyle ':prezto:module:editor' dot-expansion 'yes' +# Allow the zsh prompt context to be shown. +#zstyle ':prezto:module:editor' ps-context 'yes' + # # Git # @@ -87,6 +98,13 @@ zstyle ':prezto:module:editor' key-bindings 'emacs' # Set the search globbing flags. # zstyle ':prezto:module:history-substring-search' globbing-flags '' +# +# macOS +# + +# Set the keyword used by `mand` to open man pages in Dash.app +# zstyle ':prezto:module:osx:man' dash-keyword 'manpages' + # # Pacman # @@ -101,9 +119,17 @@ zstyle ':prezto:module:editor' key-bindings 'emacs' # Set the prompt theme to load. # Setting it to 'random' loads a random theme. # Auto set to 'off' on dumb terminals. -#zstyle ':prezto:module:prompt' theme 'sorin' zstyle ':prezto:module:prompt' theme 'abra' +# Set the working directory prompt display length. +# By default, it is set to 'short'. Set it to 'long' (without '~' expansion) +# for longer or 'full' (with '~' expansion) for even longer prompt display. +# zstyle ':prezto:module:prompt' pwd-length 'short' + +# Set the prompt to display the return code along with an indicator for non-zero +# return codes. This is not supported by all prompts. +# zstyle ':prezto:module:prompt' show-return-val 'yes' + # # Ruby # @@ -111,6 +137,16 @@ zstyle ':prezto:module:prompt' theme 'abra' # Auto switch the Ruby version on directory change. # zstyle ':prezto:module:ruby:chruby' auto-switch 'yes' +# +# Python +# + +# Auto switch the Python virtualenv on directory change. +# zstyle ':prezto:module:python:virtualenv' auto-switch 'yes' + +# Automatically initialize virtualenvwrapper if pre-requisites are met. +# zstyle ':prezto:module:python:virtualenv' initialize 'yes' + # # Screen # @@ -147,6 +183,10 @@ zstyle ':prezto:module:prompt' theme 'abra' # 'builtin' 'bg=blue' \ # 'command' 'bg=blue' \ # 'function' 'bg=blue' +# +# Set syntax pattern styles. +# zstyle ':prezto:module:syntax-highlighting' pattern \ +# 'rm*-rf*' 'fg=white,bold,bg=red' # # Terminal @@ -161,6 +201,9 @@ zstyle ':prezto:module:prompt' theme 'abra' # Set the tab title format. # zstyle ':prezto:module:terminal:tab-title' format '%m: %s' +# Set the terminal multiplexer title format. +# zstyle ':prezto:module:terminal:multiplexer-title' format '%s' + # # Tmux # @@ -174,3 +217,14 @@ zstyle ':prezto:module:prompt' theme 'abra' # Integrate with iTerm2. zstyle ':prezto:module:tmux:iterm' integrate 'yes' +# Set the default session name: +# zstyle ':prezto:module:tmux:session' name 'YOUR DEFAULT SESSION NAME' + +# +# Utility +# + +# Enabled safe options. This aliases cp, ln, mv and rm so that they prompt +# before deleting or overwriting files. Set to 'no' to disable this safer +# behavior. +# zstyle ':prezto:module:utility' safe-ops 'yes' diff --git a/.zprezto/runcoms/zprofile b/.zprezto/runcoms/zprofile index 44c2384..66a6e6e 100644 --- a/.zprezto/runcoms/zprofile +++ b/.zprezto/runcoms/zprofile @@ -36,7 +36,7 @@ fi # Ensure path arrays do not contain duplicates. typeset -gU cdpath fpath mailpath path -# Set the the list of directories that cd searches. +# Set the list of directories that cd searches. # cdpath=( # $cdpath # ) @@ -61,15 +61,3 @@ export LESS='-F -g -i -M -R -S -w -X -z-4' if (( $#commands[(i)lesspipe(|.sh)] )); then export LESSOPEN="| /usr/bin/env $commands[(i)lesspipe(|.sh)] %s 2>&-" fi - -# -# Temporary Files -# - -if [[ ! -d "$TMPDIR" ]]; then - export TMPDIR="/tmp/$LOGNAME" - mkdir -p -m 700 "$TMPDIR" -fi - -TMPPREFIX="${TMPDIR%/}/zsh" - diff --git a/.zprezto/runcoms/zshenv b/.zprezto/runcoms/zshenv index 2d97203..ae8dacf 100644 --- a/.zprezto/runcoms/zshenv +++ b/.zprezto/runcoms/zshenv @@ -6,6 +6,16 @@ # # Ensure that a non-login, non-interactive shell has a defined environment. -if [[ "$SHLVL" -eq 1 && ! -o LOGIN && -s "${ZDOTDIR:-$HOME}/.zprofile" ]]; then +if [[ ( "$SHLVL" -eq 1 && ! -o LOGIN ) && -s "${ZDOTDIR:-$HOME}/.zprofile" ]]; then source "${ZDOTDIR:-$HOME}/.zprofile" fi + +function add_to_path { + if [[ -d $1 ]]; then + export PATH="$1:$PATH" + fi +} + +add_to_path "$HOME/bin" +add_to_path "$HOME/brew/sbin" +add_to_path "$HOME/brew/bin" diff --git a/.zprezto/runcoms/zshrc b/.zprezto/runcoms/zshrc index f9219be..505dc30 100644 --- a/.zprezto/runcoms/zshrc +++ b/.zprezto/runcoms/zshrc @@ -1,34 +1,17 @@ +# +# Executes commands at the start of an interactive session. +# +# Authors: +# Sorin Ionescu +# + +function zsource_if_exists { + if [[ -s "$1" ]]; then + source "$1" + fi +} + # Source Prezto. -if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then - source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" -fi - -source ~/.zoptions - -source ~/.zalias - -source ~/.zfunc - -if [[ -s "$HOME/.iterm2_shell_integration.zsh" ]]; then - source "$HOME/.iterm2_shell_integration.zsh" -fi - -add_dir_to_path "$HOME/bin" -add_dir_to_path "$HOME/work/arcadia" - -add_dir_to_path "$HOME/brew/sbin" -add_dir_to_path "$HOME/brew/bin" - - -# export PATH="$HOME/bin/":$PATH -# export PATH="$HOME/work/arcadia/":$PATH - - -# if is_local; then -# export PATH="$HOME/brew/sbin":"$HOME/brew/bin":$PATH -# export DYLD_LIBRARY_PATH="/Developer/NVIDIA/CUDA-8.0/lib:/usr/local/cuda/lib" -# fi - -# update, background+disown -update_.g &! +zsource_if_exists "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" +zsource_if_exists "${ZDOTDIR:-$HOME}/.zprezto/abra/main.zsh" diff --git a/.zpreztorc b/.zpreztorc index fb46b62..ac8611a 120000 --- a/.zpreztorc +++ b/.zpreztorc @@ -1 +1 @@ -.zprezto/runcoms/zpreztorc \ No newline at end of file +/Users/svxf/.zprezto/runcoms/zpreztorc \ No newline at end of file diff --git a/.zprofile b/.zprofile index b085555..0d19295 120000 --- a/.zprofile +++ b/.zprofile @@ -1 +1 @@ -.zprezto/runcoms/zprofile \ No newline at end of file +/Users/svxf/.zprezto/runcoms/zprofile \ No newline at end of file diff --git a/.zprofile.pysave b/.zprofile.pysave deleted file mode 100644 index d87cb3b..0000000 --- a/.zprofile.pysave +++ /dev/null @@ -1,74 +0,0 @@ -# -# Executes commands at login pre-zshrc. -# -# Authors: -# Sorin Ionescu -# - -# -# Browser -# - -if [[ "$OSTYPE" == darwin* ]]; then - export BROWSER='open' -fi - -# -# Editors -# - -export EDITOR='nano' -export VISUAL='nano' -export PAGER='less' - -# -# Language -# - -if [[ -z "$LANG" ]]; then - export LANG='en_US.UTF-8' -fi - -# -# Paths -# - -# Ensure path arrays do not contain duplicates. -typeset -gU cdpath fpath mailpath path - -# Set the the list of directories that cd searches. -# cdpath=( -# $cdpath -# ) - -# Set the list of directories that Zsh searches for programs. -path=( - /usr/local/{bin,sbin} - $path -) - -# -# Less -# - -# Set the default Less options. -# Mouse-wheel scrolling has been disabled by -X (disable screen clearing). -# Remove -X and -F (exit if the content fits on one screen) to enable it. -export LESS='-F -g -i -M -R -S -w -X -z-4' - -# Set the Less input preprocessor. -# Try both `lesspipe` and `lesspipe.sh` as either might exist on a system. -if (( $#commands[(i)lesspipe(|.sh)] )); then - export LESSOPEN="| /usr/bin/env $commands[(i)lesspipe(|.sh)] %s 2>&-" -fi - -# -# Temporary Files -# - -if [[ ! -d "$TMPDIR" ]]; then - export TMPDIR="/tmp/$LOGNAME" - mkdir -p -m 700 "$TMPDIR" -fi - -TMPPREFIX="${TMPDIR%/}/zsh" diff --git a/.zshenv b/.zshenv index 2ffffef..e2f4643 120000 --- a/.zshenv +++ b/.zshenv @@ -1 +1 @@ -.zprezto/runcoms/zshenv \ No newline at end of file +/Users/svxf/.zprezto/runcoms/zshenv \ No newline at end of file diff --git a/.zshrc b/.zshrc index ff7ceae..8d25eea 120000 --- a/.zshrc +++ b/.zshrc @@ -1 +1 @@ -.zprezto/runcoms/zshrc \ No newline at end of file +/Users/svxf/.zprezto/runcoms/zshrc \ No newline at end of file