Merge remote-tracking branch 'upstream/master'

Conflicts:
	lib/git.zsh
This commit is contained in:
Gaetan Semet 2016-02-04 01:18:13 +01:00
commit 6000880f2d
38 changed files with 844 additions and 144 deletions

View file

@ -2,7 +2,7 @@
# Usage is also described at https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins
# Look for yaourt, and add some useful functions if we have it.
if [[ -x `command -v yaourt` ]]; then
if (( $+commands[yaourt] )); then
upgrade () {
yaourt -Syu
}
@ -21,11 +21,11 @@ if [[ -x `command -v yaourt` ]]; then
alias yalst='yaourt -Qe' # List installed packages, even those installed from AUR (they're tagged as "local")
alias yaorph='yaourt -Qtd' # Remove orphans using yaourt
# Additional yaourt alias examples
if [[ -x `command -v abs` && -x `command -v aur` ]]; then
if (( $+commands[abs] && $+commands[aur] )); then
alias yaupd='yaourt -Sy && sudo abs && sudo aur' # Update and refresh the local package, ABS and AUR databases against repositories
elif [[ -x `command -v abs` ]]; then
elif (( $+commands[abs] )); then
alias yaupd='yaourt -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories
elif [[ -x `command -v aur` ]]; then
elif (( $+commands[aur] )); then
alias yaupd='yaourt -Sy && sudo aur' # Update and refresh the local package and AUR databases against repositories
else
alias yaupd='yaourt -Sy' # Update and refresh the local package database against repositories
@ -49,11 +49,11 @@ alias pacreps='pacman -Ss' # Search for package(s) in the repositori
alias pacloc='pacman -Qi' # Display information about a given package in the local database
alias paclocs='pacman -Qs' # Search for package(s) in the local database
# Additional pacman alias examples
if [[ -x `command -v abs` && -x `command -v aur` ]]; then
if (( $+commands[abs] && $+commands[aur] )); then
alias pacupd='sudo pacman -Sy && sudo abs && sudo aur' # Update and refresh the local package, ABS and AUR databases against repositories
elif [[ -x `command -v abs` ]]; then
elif (( $+commands[abs] )); then
alias pacupd='sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories
elif [[ -x `command -v aur` ]]; then
elif (( $+commands[aur] )); then
alias pacupd='sudo pacman -Sy && sudo aur' # Update and refresh the local package and AUR databases against repositories
else
alias pacupd='sudo pacman -Sy' # Update and refresh the local package database against repositories

33
plugins/branch/README.md Normal file
View file

@ -0,0 +1,33 @@
# Branch
Displays the current Git or Mercurial branch fast.
## Speed test
### Mercurial
```shell
$ time hg branch
0.11s user 0.14s system 70% cpu 0.355 total
```
### Branch plugin
```shell
$ time zsh /tmp/branch_prompt_info_test.zsh
0.00s user 0.01s system 78% cpu 0.014 total
```
## Usage
Edit your theme file (eg.: `~/.oh-my-zsh/theme/robbyrussell.zsh-theme`)
adding `$(branch_prompt_info)` in your prompt like this:
```diff
- PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
+ PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(branch_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
```
## Maintainer
Victor Torres (<vpaivatorres@gmail.com>)

View file

@ -0,0 +1,26 @@
# Branch: displays the current Git or Mercurial branch fast.
# Victor Torres <vpaivatorres@gmail.com>
# Oct 2, 2015
function branch_prompt_info() {
# Defines path as current directory
local current_dir=$PWD
# While current path is not root path
while [[ $current_dir != '/' ]]
do
# Git repository
if [[ -d "${current_dir}/.git" ]]
then
echo '±' ${"$(<"$current_dir/.git/HEAD")"##*/}
return;
fi
# Mercurial repository
if [[ -d "${current_dir}/.hg" ]]
then
echo '☿' $(<"$current_dir/.hg/branch")
return;
fi
# Defines path as parent directory and keeps looking for :)
current_dir="${current_dir:h}"
done
}

View file

@ -16,9 +16,6 @@
# rvm and rbenv plugins also provide this alias
alias rubies='chruby'
local _chruby_path
local _chruby_auto
_homebrew-installed() {
whence brew &> /dev/null
}
@ -42,6 +39,9 @@ if _ruby-build_installed; then
fi
_source_from_omz_settings() {
local _chruby_path
local _chruby_auto
zstyle -s :omz:plugins:chruby path _chruby_path
zstyle -s :omz:plugins:chruby auto _chruby_auto

View file

@ -1,32 +1,32 @@
if [ "$OSTYPE[0,7]" = "solaris" ]
if [[ "$OSTYPE" = solaris* ]]
then
if [ ! -x ${HOME}/bin/nroff ]
if [[ ! -x "$HOME/bin/nroff" ]]
then
mkdir -p ${HOME}/bin
cat > ${HOME}/bin/nroff <<EOF
mkdir -p "$HOME/bin"
cat > "$HOME/bin/nroff" <<EOF
#!/bin/sh
if [ -n "\$_NROFF_U" -a "\$1,\$2,\$3" = "-u0,-Tlp,-man" ]; then
shift
exec /usr/bin/nroff -u\${_NROFF_U} "\$@"
exec /usr/bin/nroff -u\$_NROFF_U "\$@"
fi
#-- Some other invocation of nroff
exec /usr/bin/nroff "\$@"
EOF
chmod +x ${HOME}/bin/nroff
chmod +x "$HOME/bin/nroff"
fi
fi
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
PAGER=/usr/bin/less \
_NROFF_U=1 \
PATH=${HOME}/bin:${PATH} \
man "$@"
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
PAGER="${commands[less]:-$PAGER}" \
_NROFF_U=1 \
PATH="$HOME/bin:$PATH" \
man "$@"
}

View file

@ -23,3 +23,11 @@ if [ -f /usr/libexec/pk-command-not-found ]; then
return $retval
}
fi
# OSX command-not-found support
# https://github.com/Homebrew/homebrew-command-not-found
if type brew &> /dev/null; then
if brew command command-not-found-init > /dev/null 2>&1; then
eval "$(brew command-not-found-init)";
fi
fi

View file

@ -6,14 +6,16 @@ Ember CLI (http://www.ember-cli.com/)
### List of Aliases
alias es='ember serve'
alias ea='ember addon'
alias eb='ember build'
alias ed='ember destroy'
alias eg='ember generate'
alias eh='ember help'
alias ein='ember init'
alias ei='ember install'
alias et='ember test'
alias eu='ember update'
alias ev='ember version'
Alias | Ember-CLI command
----- | -----------------
**es** | *ember serve*
**ea** | *ember addon*
**eb** | *ember build*
**ed** | *ember destroy*
**eg** | *ember generate*
**eh** | *ember help*
**ein** | *ember init*
**ei** | *ember install*
**et** | *ember test*
**eu** | *ember update*
**ev** | *ember version*

View file

@ -1,4 +1,17 @@
encode64(){ printf '%s' $1 | base64 }
decode64(){ printf '%s' $1 | base64 --decode }
encode64() {
if [[ $# -eq 0 ]]; then
cat | base64
else
printf '%s' $1 | base64
fi
}
decode64() {
if [[ $# -eq 0 ]]; then
cat | base64 --decode
else
printf '%s' $1 | base64 --decode
fi
}
alias e64=encode64
alias d64=decode64

View file

@ -4,10 +4,12 @@ Plugin for ForkLift, an FTP application for OS X.
### Requirements
* [ForkLift](http://forkliftapp.com/forklift/)
* [ForkLift](http://www.binarynights.com/forklift/)
### Usage
* If `fl` is called without arguments then the current folder is opened in ForkLift. Is equivalent to `fl .`
<code>fl [*file_or_folder*]</code>
* If `fl` is called with a directory as the argument, then that directory is opened in ForkLift
* If `fl` is called without arguments then the current folder is opened in ForkLift. This is equivalent to `fl .`.
* If `fl` is called with a directory as the argument, then that directory is opened in ForkLift. If called with a non-directory file as the argument, then the file's parent directory is opened.

View file

@ -4,7 +4,7 @@
#
# Completion script for git-extras (http://github.com/tj/git-extras).
#
# This depends on and reueses some of the internals of the _git completion
# This depends on and reuses some of the internals of the _git completion
# function that ships with zsh itself. It will not work with the _git that ships
# with git.
#

View file

@ -6,19 +6,12 @@ zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd
# Functions
#
# The current branch name
# Usage example: git pull origin $(current_branch)
# Using '--quiet' with 'symbolic-ref' will not cause a fatal error (128) if
# it's not a symbolic ref, but in a Git repo.
# The name of the current branch
# Back-compatibility wrapper for when this function was defined here in
# the plugin, before being pulled in to core lib/git.zsh as git_current_branch()
# to fix the core -> git plugin dependency.
function current_branch() {
local ref
ref=$($_omz_git_git_cmd symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]]; then
[[ $ret == 128 ]] && return # no git repo.
ref=$($_omz_git_git_cmd rev-parse --short HEAD 2> /dev/null) || return
fi
echo ${ref#refs/heads/}
git_current_branch
}
# The list of remotes
function current_repository() {
@ -99,7 +92,7 @@ alias gfo='git fetch origin'
alias gg='git gui citool'
alias gga='git gui citool --amend'
ggf() {
[[ "$#" != 1 ]] && local b="$(current_branch)"
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
git push --force origin "${b:=$1}"
}
compdef _git ggf=git-checkout
@ -107,23 +100,23 @@ ggl() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git pull origin "${*}"
else
[[ "$#" == 0 ]] && local b="$(current_branch)"
[[ "$#" == 0 ]] && local b="$(git_current_branch)"
git pull origin "${b:=$1}"
fi
}
compdef _git ggl=git-checkout
alias ggpull='git pull origin $(current_branch)'
alias ggpull='git pull origin $(git_current_branch)'
compdef _git ggpull=git-checkout
ggp() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git push origin "${*}"
else
[[ "$#" == 0 ]] && local b="$(current_branch)"
[[ "$#" == 0 ]] && local b="$(git_current_branch)"
git push origin "${b:=$1}"
fi
}
compdef _git ggp=git-checkout
alias ggpush='git push origin $(current_branch)'
alias ggpush='git push origin $(git_current_branch)'
compdef _git ggpush=git-checkout
ggpnp() {
if [[ "$#" == 0 ]]; then
@ -133,9 +126,9 @@ ggl "${*}" && ggp "${*}"
fi
}
compdef _git ggpnp=git-checkout
alias ggsup='git branch --set-upstream-to=origin/$(current_branch)'
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
ggu() {
[[ "$#" != 1 ]] && local b="$(current_branch)"
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
git pull --rebase origin "${b:=$1}"
}
compdef _git ggu=git-checkout
@ -223,4 +216,4 @@ alias glum='git pull upstream master'
alias gvt='git verify-tag'
alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit -m "--wip--"'
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit -m "--wip--"'

163
plugins/github/_hub Normal file
View file

@ -0,0 +1,163 @@
#compdef hub
# Zsh will source this file when attempting to autoload the "_hub" function,
# typically on the first attempt to complete the hub command. We define two new
# setup helper routines (one for the zsh-distributed version, one for the
# git-distributed, bash-based version). Then we redefine the "_hub" function to
# call "_git" after some other interception.
#
# This is pretty fragile, if you think about it. Any number of implementation
# changes in the "_git" scripts could cause problems down the road. It would be
# better if the stock git completions were just a bit more permissive about how
# it allowed third-party commands to be added.
(( $+functions[__hub_setup_zsh_fns] )) ||
__hub_setup_zsh_fns () {
(( $+functions[_git-alias] )) ||
_git-alias () {
_arguments \
'-s[output shell script suitable for eval]' \
'1::shell:(zsh bash csh)'
}
(( $+functions[_git-browse] )) ||
_git-browse () {
_arguments \
'-u[output the URL]' \
'2::subpage:(wiki commits issues)'
}
(( $+functions[_git-compare] )) ||
_git-compare () {
_arguments \
'-u[output the URL]' \
':[start...]end range:'
}
(( $+functions[_git-create] )) ||
_git-create () {
_arguments \
'::name (REPOSITORY or ORGANIZATION/REPOSITORY):' \
'-p[make repository private]' \
'-d[description]:description' \
'-h[home page]:repository home page URL:_urls'
}
(( $+functions[_git-fork] )) ||
_git-fork () {
_arguments \
'--no-remote[do not add a remote for the new fork]'
}
(( $+functions[_git-pull-request] )) ||
_git-pull-request () {
_arguments \
'-f[force (skip check for local commits)]' \
'-b[base]:base ("branch", "owner\:branch", "owner/repo\:branch"):' \
'-h[head]:head ("branch", "owner\:branch", "owner/repo\:branch"):' \
- set1 \
'-m[message]' \
'-F[file]' \
'-a[user]' \
'-M[milestone]' \
'-l[labels]' \
- set2 \
'-i[issue]:issue number:' \
- set3 \
'::issue-url:_urls'
}
# stash the "real" command for later
functions[_hub_orig_git_commands]=$functions[_git_commands]
# Replace it with our own wrapper.
declare -f _git_commands >& /dev/null && unfunction _git_commands
_git_commands () {
local ret=1
# call the original routine
_call_function ret _hub_orig_git_commands
# Effectively "append" our hub commands to the behavior of the original
# _git_commands function. Using this wrapper function approach ensures
# that we only offer the user the hub subcommands when the user is
# actually trying to complete subcommands.
hub_commands=(
alias:'show shell instructions for wrapping git'
pull-request:'open a pull request on GitHub'
fork:'fork origin repo on GitHub'
create:'create new repo on GitHub for the current project'
browse:'browse the project on GitHub'
compare:'open GitHub compare view'
ci-status:'lookup commit in GitHub Status API'
)
_describe -t hub-commands 'hub command' hub_commands && ret=0
return ret
}
}
(( $+functions[__hub_setup_bash_fns] )) ||
__hub_setup_bash_fns () {
# TODO more bash-style fns needed here to complete subcommand args. They take
# the form "_git_CMD" where "CMD" is something like "pull-request".
# Duplicate and rename the 'list_all_commands' function
eval "$(declare -f __git_list_all_commands | \
sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')"
# Wrap the 'list_all_commands' function with extra hub commands
__git_list_all_commands() {
cat <<-EOF
alias
pull-request
fork
create
browse
compare
ci-status
EOF
__git_list_all_commands_without_hub
}
# Ensure cached commands are cleared
__git_all_commands=""
}
# redefine _hub to a much smaller function in the steady state
_hub () {
# only attempt to intercept the normal "_git" helper functions once
(( $+__hub_func_replacement_done )) ||
() {
# At this stage in the shell's execution the "_git" function has not yet
# been autoloaded, so the "_git_commands" or "__git_list_all_commands"
# functions will not be defined. Call it now (with a bogus no-op service
# to prevent premature completion) so that we can wrap them.
if declare -f _git >& /dev/null ; then
_hub_noop () { __hub_zsh_provided=1 } # zsh-provided will call this one
__hub_noop_main () { __hub_git_provided=1 } # git-provided will call this one
local service=hub_noop
_git
unfunction _hub_noop
unfunction __hub_noop_main
service=git
fi
if (( $__hub_zsh_provided )) ; then
__hub_setup_zsh_fns
elif (( $__hub_git_provided )) ; then
__hub_setup_bash_fns
fi
__hub_func_replacement_done=1
}
# Now perform the actual completion, allowing the "_git" function to call our
# replacement "_git_commands" function as needed. Both versions expect
# service=git or they will call nonexistent routines or end up in an infinite
# loop.
service=git
declare -f _git >& /dev/null && _git
}
# make sure we actually attempt to complete on the first "tab" from the user
_hub

View file

@ -1,4 +1,4 @@
function gi() { curl -sL https://www.gitignore.io/api/$@ ;}
function gi() { curl -sL https://www.gitignore.io/api/${(j:,:)@} }
_gitignoreio_get_command_list() {
curl -sL https://www.gitignore.io/api/list | tr "," "\n"

View file

@ -2,12 +2,12 @@
#
# gulp-autocompletion-zsh
#
#
# Autocompletion for your gulp.js tasks
#
# Copyright(c) 2014 André König <andre.koenig@posteo.de>
# MIT Licensed
#
#
#
# André König
@ -20,7 +20,7 @@
# in the current directory.
#
function $$gulp_completion {
compls="$(grep -Eo "gulp.task\((['\"](([a-zA-Z0-9]|-)*)['\"],)" gulpfile.js 2>/dev/null | grep -Eo "['\"](([a-zA-Z0-9]|-)*)['\"]" | sed s/"['\"]"//g | sort)"
compls=$(gulp --tasks-simple 2>/dev/null)
completions=(${=compls})
compadd -- $completions

View file

@ -61,6 +61,7 @@ alias rr='rake routes'
alias rrg='rake routes | grep'
alias rt='rake test'
alias rmd='rake middleware'
alias rsts='rake stats'
# legacy stuff
alias sstat='thin --stats "/thin/stats" start'

18
plugins/vault/README.md Normal file
View file

@ -0,0 +1,18 @@
## Vault (https://www.vaultproject.io) autocomplete plugin
- Adds autocomplete options for all vault commands.
####Show help for all commands
![General Help](http://i.imgur.com/yv5Db1r.png "Help for all commands")
####Create new Vault token
![Create token](http://i.imgur.com/xMegNgh.png "Create token")
####Enable audit backends
![Audit backends](http://i.imgur.com/fKLeiSF.png "Audit backends")
Crafted with <3 by Valentin Bud ([@valentinbud](https://twitter.com/valentinbud))

400
plugins/vault/_vault Normal file
View file

@ -0,0 +1,400 @@
#compdef vault
typeset -a main_args
main_args=(
'(-version)-version[Prints the Vault version]'
'(-help)-help[Prints Vault Help]'
)
typeset -a general_args
general_args=(
'(-help)-help[Prints Help]'
'(-address)-address=-[The address of the Vault server. Overrides the VAULT_ADDR environment variable if set.]:address:'
'(-ca-cert)-ca-cert=-[Path to a PEM encoded CA cert file to use to verify the Vault server SSL certificate. Overrides the VAULT_CACERT environment variable if set.]:file:_files -g "*.pem"'
'(-ca-path)-ca-path=-[Path to a directory of PEM encoded CA cert files to verify the Vault server SSL certificate. If both -ca-cert and -ca-path are specified, -ca-path is used.Overrides the VAULT_CAPATH environment variable if set.]:directory:_directories'
'(-client-cert)-client-cert=-[Path to a PEM encoded client certificate for TLS authentication to the Vault server. Must also specify -client-key. Overrides the VAULT_CLIENT_CERT environment variable if set.]:file:_files -g "*.pem"'
'(-client-key)-client-key=-[Path to an unencrypted PEM encoded private key matching the client certificate from -client-cert. Overrides the VAULT_CLIENT_KEY environment variable if set.]:file:_files -g "*.pem"'
'(-tls-skip-verify)-tls-skip-verify[Do not verify TLS certificate. This is highly not recommended. Verification will also be skipped if VAULT_SKIP_VERIFY is set.]'
)
typeset -a audit_enable_args
audit_enable_args=(
'(-description)-description=-[A human-friendly description for the backend. This shows up only when querying the enabled backends.]:description:'
'(-id)-id=-[Specify a unique ID for this audit backend. This is purely for referencing this audit backend. By default this will be the backend type.]:id:'
)
typeset -a auth_args
auth_args=(
'(-method)-method=-[Outputs help for the authentication method with the given name for the remote server. If this authentication method is not available, exit with code 1.]:method:(cert ldap github userpass app-id)'
'(-method-help)-method-help[If set, the help for the selected method will be shown.]'
'(-methods)-methods[List the available auth methods.]'
'(-no-verify)-no-verify[Do not verify the token after creation; avoids a use count]'
)
typeset -a auth_enable_args
auth_enable_args=(
'(-description)-description=-[Human-friendly description of the purpose for the auth provider. This shows up in the auth-list command.]:description:'
'(-path)-path=-[Mount point for the auth provider. This defaults to the type of the mount. This will make the auth provider available at "/auth/<path>"]:path:'
)
typeset -a init_args
init_args=(
'(-key-shares)-key-shares=-[(default: 5) The number of key shares to split the master key into.]:keyshares:'
'(-key-threshold)-key-threshold=-[(default: 3) The number of key shares required to reconstruct the master key.]:keythreshold:'
'(-pgp-keys)-pgp-keys[If provided, must be a comma-separated list of files on disk containing binary- or base64-format public PGP keys. The number of files must match "key-shares". The output unseal keys will encrypted and hex-encoded, in order, with the given public keys. If you want to use them with the "vault unseal" command, you will need to hex decode and decrypt; this will be the plaintext unseal key.]:pgpkeys:_files'
)
typeset -a mount_tune_args
mount_tune_args=(
'(-default-lease-ttl)-default-lease-ttl=-[Default lease time-to-live for this backend. If not specified, uses the system default, or the previously set value. Set to "system" to explicitly set it to use the system default.]:defaultleasettl:'
'(-max-lease-ttl)-max-lease-ttl=-[Max lease time-to-live for this backend. If not specified, uses the system default, or the previously set value. Set to "system" to explicitly set it to use the system default.]:maxleasettl:'
)
typeset -a mount_args
mount_args=(
$mount_tune_args
'(-path)-path=-[Mount point for the logical backend. This defauls to the type of the mount.]:path:'
'(-description)-description=-[Human-friendly description of the purpose for the mount. This shows up in the mounts command.]:description:'
)
typeset -a rekey_args
rekey_args=(
$init_args
'(-init)-init[Initialize the rekey operation by setting the desired number of shares and the key threshold. This can only be done if no rekey is already initiated.]:init:'
'(-cancel)-cancel[Reset the rekey process by throwing away prior keys and the rekey configuration.]:cancel:'
'(-status)-status[Prints the status of the current rekey operation. This can be used to see the status without attempting to provide an unseal key.]:status:'
)
typeset -a ssh_args
ssh_args=(
'(-role)-role[Role to be used to create the key. ]:role:'
'(-no-exec)-no-exec[Shows the credentials but does not establish connection.]:noexec:'
'(-mount-point)-mount-point[Mount point of SSH backend. If the backend is mounted at "ssh", which is the default as well, this parameter can be skipped.]:mountpoint:'
'(-format)-format[If no-exec option is enabled, then the credentials will be printed out and SSH connection will not be established. The format of the output can be "json" or "table". JSON output is useful when writing scripts. Default is "table".]:format:(json table)'
)
typeset -a token_create_args
token_create_args=(
'(-id)-id=-[The token value that clients will use to authenticate with vault. If not provided this defaults to a 36 character UUID. A root token is required to specify the ID of a token.]:id:'
'(-display-name)-display-name=-[A display name to associate with this token. This is a non-security sensitive value used to help identify created secrets, i.e. prefixes.]:displayname:'
'(-ttl)-ttl=-[TTL to associate with the token. This option enables the tokens to be renewable.]:ttl:'
'*-metadata=-[Metadata to associate with the token. This shows up in the audit log. This can be specified multiple times.]:metadata:'
'(-orphan)-orphan[If specified, the token will have no parent. Only root tokens can create orphan tokens. This prevents the new token from being revoked with your token.]:orphan:'
'(-no-default-policy)-no-default-policy[If specified, the token will not have the "default" policy included in its policy set.]:nodefaultpolicy:'
'*-policy=-[Policy to associate with this token. This can be specified multiple times.]:policy:__vault_policies'
'(-use-limit)-use-limit=-[The number of times this token can be used until it is automatically revoked.]:uselimit:'
'(-format)-format=-[The format for output. By default it is a whitespace-delimited table. This can also be json.]:format:(json table)'
)
typeset -a server_args
server_args=(
'*-config=-[Path to the configuration file or directory. This can be specified multiple times. If it is a directory, all files with a ".hcl" or ".json" suffix will be loaded.]:config:_files'
'-dev[Enables Dev mode. In this mode, Vault is completely in-memory and unsealed. Do not run the Dev server in production!]:dev:'
'-log-level=-[Log verbosity. Defaults to "info", will be outputtedto stderr. Supported values: "trace", "debug", "info", "warn", "err"]:loglevel:(trace debug info warn err)'
)
_vault_audit-list() {
_arguments : \
${general_args[@]} && ret=0
}
_vault_audit-disable() {
# vault audit-list doesn't print the backend id so for now
# no *smart* autocompletion for this subcommand.
_arguments : \
${general_args[@]} \
':::(file syslog)' && ret=0
}
_vault_audit-enable() {
_arguments : \
${general_args[@]} \
${audit_enable_args[@]} \
': :->backends' \
'*:: :->backendconfig' && ret=0
case $state in
backends)
local -a backends
backends=(
'file:The "file" audit backend writes audit logs to a file.'
'syslog:The "syslog" audit backend writes audit logs to syslog.'
)
_describe -t backends 'vault audit backends' backends && ret=0
;;
backendconfig)
case ${line[1]} in
file)
_values -w "Audit Backend File" \
'path[(required) - The path to where the file will be written. If this path exists, the audit backend will append to it.]:file:_files' \
'log_raw[(optional) Should security sensitive information be logged raw. Defaults to "false".]:log_raw:(true false)' && ret=0
;;
syslog)
_values -w "Audit Backend Syslog" \
'facility[(optional) - The syslog facility to use. Defaults to "AUTH".]:facility:(kern user mail daemon auth syslog lpr news uucp authpriv ftp cron local0 local1 local2 local3 local4 local5 local6 local7)' \
'tag[(optional) - The syslog tag to use. Defaults to "vault".]:tag:' \
'log_raw[(optional) Should security sensitive information be logged raw.]:log_raw:(true false)' && ret=0
;;
esac
;;
esac
}
_vault_auth() {
_arguments : \
${general_args[@]} \
${auth_args[@]} && ret=0
}
_vault_auth-enable() {
_arguments : \
${general_args[@]} \
${auth_enable_args[@]} \
':::(cert ldap github userpass app-id)' && ret=0
}
__vault_auth_methods() {
local -a authmethods
authmethods=($(vault auth -methods | awk 'NR>1{split ($1,a,"/"); print a[1]":["$2"]"}'))
_describe -t authmethods 'authmethods' authmethods && ret=0
}
_vault_auth-disable() {
_arguments : \
${general_args[@]} \
':::__vault_auth_methods' && ret=0
}
_vault_init() {
_arguments : \
${general_args[@]} \
${init_args[@]} && ret=0
}
_vault_key-status() {
_arguments : \
${general_args[@]} && ret=0
}
__vault_mounts() {
local -a mounts
mounts=($(vault mounts | awk 'NR>1{split ($1,a,"/"); print a[1]":["$2"]"}'))
_describe -t mounts 'mounts' mounts && ret=0
}
_vault_mounts() {
_arguments : \
${general_args[@]} && ret=0
}
_vault_mount() {
# to find out how many types of backens are there
_arguments : \
${general_args[@]} \
${mount_args[@]} \
':::(generic ssh)' && ret=0
}
_vault_mount-tune() {
_arguments : \
${general_args[@]} \
${mount_tune_args[@]} \
':::__vault_mounts' && ret=0
}
_vault_unmount() {
_arguments : \
${general_args[@]} \
':::__vault_mounts' && ret=0
}
_vault_remount() {
_arguments : \
${general_args[@]} \
':::__vault_mounts' \
':::' && ret=0
}
__vault_policies() {
local -a policies
policies=($(vault policies | awk '{print $1":["$1"]"}'))
_describe -t policies 'policies' policies && ret=0
}
_vault_policies() {
_arguments : \
${general_args[@]} \
':::__vault_policies' && ret=0
}
_vault_policy-delete() {
_arguments : \
${general_args[@]} \
':::__vault_policies' && ret=0
}
_vault_policy-write() {
_arguments : \
${general_args[@]} \
': ::' \
'::policy:_files' && ret=0
}
_vault_status() {
_arguments : \
${general_args[@]} && ret=0
}
_vault_rekey() {
_arguments : \
${general_args[@]} \
${rekey_args[@]} \
': ::' && ret=0
}
_vault_rotate() {
_arguments : \
${general_args[@]} && ret=0
}
_vault_seal() {
_arguments : \
${general_args[@]} && ret=0
}
_vault_ssh() {
_arguments : \
${general_args[@]} \
${ssh_args[@]} \
': ::' && ret=0
}
_vault_token-create() {
_arguments : \
${general_args[@]} \
${token_create_args[@]} && ret=0
}
_vault_token-renew() {
_arguments : \
${general_args[@]} \
'(-format)-format=-[The format for output. By default it is a whitespace-delimited table. This can also be json.]:format:(json table)' \
': ::' \
': ::' && ret=0
}
_vault_token-revoke() {
_arguments : \
${general_args[@]} \
'(-mode)-mode=-[The type of revocation to do. See the documentation above for more information.]:mode:( orphan path)' \
': ::' && ret=0
}
_vault_unseal() {
_arguments : \
${general_args[@]} \
'(-reset)-reset[Reset the unsealing process by throwing away prior keys in process to unseal the vault.]:reset:' \
': ::' && ret=0
}
_vault_version() {
# no args
}
_vault_delete() {
_arguments : \
${general_args[@]} \
': ::' && ret=0
}
_vault_path-help() {
_arguments : \
${general_args[@]} \
': ::' && ret=0
}
_vault_revoke() {
_arguments : \
${general_args[@]} \
'(-format)-format=-[The format for output. By default it is a whitespace-delimited table. This can also be json.]:format:(json table)' \
': ::' \
': ::' && ret=0
}
_vault_server() {
_arguments : \
${server_args[@]} && ret=0
}
_vault_write() {
_arguments : \
${general_args[@]} \
'(-f -force)'{-f,-force}'[Force the write to continue without any data values specified. This allows writing to keys that do not need or expect any fields to be specified.]:force:' \
': ::' \
': ::' && ret=0
}
_vault_read() {
_arguments : \
${general_args[@]} \
'(-format)-format=-[The format for output. By default it is a whitespace-delimited table. This can also be json.]:format:(json table)' \
'(-field)-field=-[If included, the raw value of the specified field will be output raw to stdout.]:field:' \
': ::' && ret=0
}
_vault_commands() {
local -a commands
commands=(
"delete":"Delete operation on secrets in Vault"
"path-help":"Look up the help for a path"
"read":"Read data or secrets from Vault"
"renew":"Renew the lease of a secret"
"revoke":"Revoke a secret"
"server":"Start a Vault server"
"status":"Outputs status of whether Vault is sealed and if HA mode is enabled"
"write":"Write secrets or configuration into Vault"
"audit-disable":"Disable an audit backend"
"audit-enable":"Enable an audit backend"
"audit-list":"Lists enabled audit backends in Vault"
"auth":"Prints information about how to authenticate with Vault"
"auth-disable":"Disable an auth provider"
"auth-enable":"Enable a new auth provider"
"init":"Initialize a new Vault server"
"key-status":"Provides information about the active encryption key"
"mount":"Mount a logical backend"
"mount-tune":"Tune mount configuration parameters"
"mounts":"Lists mounted backends in Vault"
"policies":"List the policies on the server"
"policy-delete":"Delete a policy from the server"
"policy-write":"Write a policy to the server"
"rekey":"Rekeys Vault to generate new unseal keys"
"remount":"Remount a secret backend to a new path"
"rotate":"Rotates the backend encryption key used to persist data"
"seal":"Seals the vault server"
"ssh":"Initiate a SSH session"
"token-create":"Create a new auth token"
"token-renew":"Renew an auth token if there is an associated lease"
"token-revoke":"Revoke one or more auth tokens"
"unmount":"Unmount a secret backend"
"unseal":"Unseals the vault server"
"version":"Prints the Vault version"
)
_describe -t commands 'vault command' commands && ret=0
}
local curcontext=$curcontext ret=1
_arguments : \
${main_args[@]} \
'*:: :->subcommands' && ret=0
if ((CURRENT == 1 )); then
_vault_commands && ret=0
fi
if [[ $state == subcommands ]]; then
# (( CURRENT -- ))
curcontext="${curcontext%:*:*}:vault-$words[1]:"
_call_function ret _vault_$words[1]
fi

View file

@ -1,4 +1,5 @@
# Hotlist
# Try to use $ZSH_VERSION, e.g. /usr/share/zsh/$ZSH_VERSION/functions
local hotlist
hotlist=(
~/.config/znt
@ -7,7 +8,6 @@ hotlist=(
/usr/local/share/zsh/site-functions
/usr/local/share/zsh
/usr/local/bin
/usr/lib
)
# Suppress adding (to directory stack) directories visited by n-cd

View file

@ -25,7 +25,7 @@ widgets exist, znt-cd-widget and znt-kill-widget, they can be too assigned
to key combinations (no need for autoload when using Oh My Zsh):
zle -N znt-cd-widget
bindkey "^T" znt-cd-widget
bindkey "^A" znt-cd-widget
zle -N znt-kill-widget
bindkey "^Y" znt-kill-widget
@ -105,7 +105,7 @@ colorize output of the tools, via their config files (check out e.g. n-cd.conf,
it uses this).
## Performance
ZNT are fastest with Zsh before 5.0.8 and starting from 5.2
ZNT are fastest with Zsh before 5.0.6 and starting from 5.2
vim:filetype=conf

View file

@ -42,7 +42,7 @@ if [ "$REPLY" -gt 0 ]; then
# ZLE?
if [ "${(t)CURSOR}" = "integer-local-special" ]; then
zle redisplay
zle kill-whole-line
zle kill-buffer
zle -U "$selected"
else
print -zr "$selected"

View file

@ -1,6 +1,7 @@
# $1, $2, ... - elements of the list
# $NLIST_NONSELECTABLE_ELEMENTS - array of indexes (1-based) that cannot be selected
# $REPLY is the output variable - contains index (1-based) or -1 when no selection
# $reply (array) is the second part of the output - use the index (REPLY) to get selected element
#
# Copy this file into /usr/share/zsh/site-functions/
# and add 'autoload n-list` to .zshrc
@ -164,6 +165,7 @@ integer current_difference=0
local prev_search_buffer=""
integer prev_uniq_mode=0
integer prev_start_idx=-1
local MBEGIN MEND MATCH mbegin mend match
# Ability to remember the list between calls
if [[ -z "$NLIST_REMEMBER_STATE" || "$NLIST_REMEMBER_STATE" -eq 0 || "$NLIST_REMEMBER_STATE" -eq 2 ]]; then
@ -243,7 +245,9 @@ while (( 1 )); do
# Take all elements, including duplicates and non-selectables
typeset +U list
list=( "$@" )
repeat 1; do
list=( "$@" )
done
# Remove non-selectable elements
[ "$#NLIST_NONSELECTABLE_ELEMENTS" -gt 0 ] && for i in "${(nO)NLIST_NONSELECTABLE_ELEMENTS[@]}"; do
@ -262,11 +266,15 @@ while (( 1 )); do
local search_pattern=""
local colsearch_pattern=""
if [ -n "$search_buffer" ]; then
# Patterns will be *foo*~^*bar* and foo|bar)
# Patterns will be *foo*~^*bar* and (foo|bar)
search_pattern="${search_buffer// ##/*~^*}"
colsearch_pattern="${search_buffer// ##/|}"
list=( "${(@M)list:#(#i)*$~search_pattern*}" )
# The repeat will make the matching work on a fresh heap
repeat 1; do
list=( "${(@M)list:#(#i)*$~search_pattern*}" )
done
last_element="$#list"
fi
@ -285,7 +293,10 @@ while (( 1 )); do
if [ -n "$colsearch_pattern" ]; then
local red=$'\x1b[00;31m' reset=$'\x1b[00;00m'
disp_list=( "${(@)disp_list//(#mi)($~colsearch_pattern)/$red${MATCH}$reset}" )
# The repeat will make the matching work on a fresh heap
repeat 1; do
disp_list=( "${(@)disp_list//(#mi)($~colsearch_pattern)/$red${MATCH}$reset}" )
done
fi
# We have display list, lets replace newlines with "\n" when needed (1/2)
@ -309,7 +320,9 @@ while (( 1 )); do
# Take all elements, including duplicates and non-selectables
typeset +U list
list=( "$@" )
repeat 1; do
list=( "$@" )
done
# Remove non-selectable elements only when in uniq mode
[ "$NLIST_IS_UNIQ_MODE" -eq 1 ] && [ "$#NLIST_NONSELECTABLE_ELEMENTS" -gt 0 ] &&
@ -376,7 +389,7 @@ while (( 1 )); do
# Get the special (i.e. "keypad") key or regular key
if [ -n "$key" ]; then
final_key="$key"
final_key="$key"
elif [ -n "$keypad" ]; then
final_key="$keypad"
else

View file

@ -98,7 +98,7 @@ shift 7
integer max_text_len=page_width-x_offset
[ "$bold" = "0" ] && bold="" || bold="+bold"
[[ "$active_text" = "underline" || "$active_text" = "reverse" ]] || active_text="reverse"
[[ "$active_text" = "underline" || "$active_text" = "reverse" ]] || local active_text="reverse"
# With Linux terminal underline won't work properly
[ "$TERM" = "linux" ] && active_text="reverse"

View file

@ -44,7 +44,7 @@ case "$key" in
[ "$current_idx" -lt "$last_element" ] && current_idx=current_idx+1;
_nlist_compute_first_to_show_idx
;;
(PPAGE)
(PPAGE|$'\b'|$'\C-?'|BACKSPACE)
current_idx=current_idx-page_height
[ "$current_idx" -lt 1 ] && current_idx=1;
_nlist_compute_first_to_show_idx
@ -72,7 +72,7 @@ case "$key" in
current_idx=last_element
_nlist_compute_first_to_show_idx
;;
($'\n')
($'\n'|ENTER)
# Is that element selectable?
# Check for this only when there is no search
if [[ "$NLIST_SEARCH_BUFFER" != "" || "$NLIST_IS_UNIQ_MODE" -eq 1 ||
@ -137,7 +137,7 @@ esac
else
case "$key" in
($'\n')
($'\n'|ENTER)
search=0
_nlist_cursor_visibility 0
;;

View file

@ -1,7 +1,11 @@
autoload znt-usetty-wrapper n-history
local NLIST_START_IN_SEARCH_MODE=1
local NLIST_START_IN_UNIQ_MODE=1
local NLIST_SET_SEARCH_TO="$BUFFER"
# Only if current $BUFFER doesn't come from history
if [ "$HISTCMD" = "$HISTNO" ]; then
local NLIST_SET_SEARCH_TO="$BUFFER"
fi
znt-usetty-wrapper n-history "$@"