diff options
Diffstat (limited to 'plugins')
24 files changed, 754 insertions, 77 deletions
diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh index b83c24560..99de5b936 100644 --- a/plugins/archlinux/archlinux.plugin.zsh +++ b/plugins/archlinux/archlinux.plugin.zsh @@ -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 diff --git a/plugins/branch/README.md b/plugins/branch/README.md new file mode 100644 index 000000000..56ab8da4b --- /dev/null +++ b/plugins/branch/README.md @@ -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>) diff --git a/plugins/branch/branch.plugin.zsh b/plugins/branch/branch.plugin.zsh new file mode 100644 index 000000000..a1e9ca31b --- /dev/null +++ b/plugins/branch/branch.plugin.zsh @@ -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 +} diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh index 164b4319f..758b4a56c 100644 --- a/plugins/chruby/chruby.plugin.zsh +++ b/plugins/chruby/chruby.plugin.zsh @@ -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 diff --git a/plugins/colored-man-pages/colored-man-pages.plugin.zsh b/plugins/colored-man-pages/colored-man-pages.plugin.zsh index 5c613f49d..54f0bdda9 100644 --- a/plugins/colored-man-pages/colored-man-pages.plugin.zsh +++ b/plugins/colored-man-pages/colored-man-pages.plugin.zsh @@ -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 "$@" } diff --git a/plugins/command-not-found/command-not-found.plugin.zsh b/plugins/command-not-found/command-not-found.plugin.zsh index 797554a13..0e2f2133f 100644 --- a/plugins/command-not-found/command-not-found.plugin.zsh +++ b/plugins/command-not-found/command-not-found.plugin.zsh @@ -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 diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index fc19d73c3..c7aafd8b8 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -52,7 +52,7 @@ alias mv='mv -i' # zsh is able to auto-do some kungfoo # depends on the SUFFIX :) -if [ ${ZSH_VERSION//\./} -ge 420 ]; then +if is-at-least 4.2.0; then # open browser on urls _browser_fts=(htm html de org net com at cx nl se dk dk php) for ft in $_browser_fts ; do alias -s $ft=$BROWSER ; done diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index 86f5be3d0..07eb1de88 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -7,11 +7,11 @@ # Composer basic command completion _composer_get_command_list () { - $_comp_command1 --no-ansi | sed "1,/Available commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }' + $_comp_command1 --no-ansi 2>/dev/null | sed "1,/Available commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }' } _composer_get_required_list () { - $_comp_command1 show -s --no-ansi | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }' + $_comp_command1 show -s --no-ansi 2>/dev/null | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }' } _composer () { diff --git a/plugins/ember-cli/README.md b/plugins/ember-cli/README.md index 482c347d2..1f92bba32 100644 --- a/plugins/ember-cli/README.md +++ b/plugins/ember-cli/README.md @@ -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* diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 690126ba6..5d0809e9a 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -52,7 +52,7 @@ function extract() { (*.xz) unxz "$1" ;; (*.lzma) unlzma "$1" ;; (*.Z) uncompress "$1" ;; - (*.zip|*.war|*.jar|*.sublime-package|*.ipsw) unzip "$1" -d $extract_dir ;; + (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;; (*.rar) unrar x -ad "$1" ;; (*.7z) 7za x "$1" ;; (*.deb) diff --git a/plugins/forklift/README.md b/plugins/forklift/README.md index b452a357c..6c5cbab23 100644 --- a/plugins/forklift/README.md +++ b/plugins/forklift/README.md @@ -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
\ No newline at end of file +* 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. diff --git a/plugins/git-extras/git-extras.plugin.zsh b/plugins/git-extras/git-extras.plugin.zsh index 507bf1b25..0dcd630e8 100644 --- a/plugins/git-extras/git-extras.plugin.zsh +++ b/plugins/git-extras/git-extras.plugin.zsh @@ -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. # diff --git a/plugins/git-flow/git-flow.plugin.zsh b/plugins/git-flow/git-flow.plugin.zsh index 444440bcb..a8386cb19 100644 --- a/plugins/git-flow/git-flow.plugin.zsh +++ b/plugins/git-flow/git-flow.plugin.zsh @@ -6,7 +6,7 @@ # To achieve git-flow completion nirvana: # # 0. Update your zsh's git-completion module to the newest version. -# From here. http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=blob_plain;f=Completion/Unix/Command/_git;hb=HEAD +# From here. https://raw.githubusercontent.com/zsh-users/zsh/master/Completion/Unix/Command/_git # # 1. Install this file. Either: # diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index d78b82df3..b851fb97d 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -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 diff --git a/plugins/github/_hub b/plugins/github/_hub new file mode 100644 index 000000000..3a6493878 --- /dev/null +++ b/plugins/github/_hub @@ -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 diff --git a/plugins/gulp/gulp.plugin.zsh b/plugins/gulp/gulp.plugin.zsh index f7eaefa85..2b3105135 100644 --- a/plugins/gulp/gulp.plugin.zsh +++ b/plugins/gulp/gulp.plugin.zsh @@ -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 diff --git a/plugins/history-substring-search/history-substring-search.plugin.zsh b/plugins/history-substring-search/history-substring-search.plugin.zsh index 25fd3a2da..7883a65f3 100644 --- a/plugins/history-substring-search/history-substring-search.plugin.zsh +++ b/plugins/history-substring-search/history-substring-search.plugin.zsh @@ -13,11 +13,14 @@ fi # Bind terminal-specific up and down keys - +# Bind in both emacs and vi modes so it works in both, and is not +# sensitive to whether this is loaded before or after the vi-mode plugin if [[ -n "$terminfo[kcuu1]" ]]; then - bindkey "$terminfo[kcuu1]" history-substring-search-up + bindkey -M emacs "$terminfo[kcuu1]" history-substring-search-up + bindkey -M viins "$terminfo[kcuu1]" history-substring-search-up fi if [[ -n "$terminfo[kcud1]" ]]; then - bindkey "$terminfo[kcud1]" history-substring-search-down + bindkey -M emacs "$terminfo[kcud1]" history-substring-search-down + bindkey -M viins "$terminfo[kcud1]" history-substring-search-down fi diff --git a/plugins/history-substring-search/update-from-upstream.zsh b/plugins/history-substring-search/update-from-upstream.zsh index 6e6cca5d5..81e1942a5 100755 --- a/plugins/history-substring-search/update-from-upstream.zsh +++ b/plugins/history-substring-search/update-from-upstream.zsh @@ -76,10 +76,12 @@ cat >> $plugin_basename.plugin.zsh <<EOF # Bind terminal-specific up and down keys if [[ -n "\$terminfo[kcuu1]" ]]; then - bindkey "\$terminfo[kcuu1]" history-substring-search-up + bindkey -M emacs "\$terminfo[kcuu1]" history-substring-search-up + bindkey -M viins "\$terminfo[kcuu1]" history-substring-search-up fi if [[ -n "\$terminfo[kcud1]" ]]; then - bindkey "\$terminfo[kcud1]" history-substring-search-down + bindkey -M emacs "\$terminfo[kcud1]" history-substring-search-down + bindkey -M viins "\$terminfo[kcud1]" history-substring-search-down fi EOF diff --git a/plugins/mercurial/mercurial.plugin.zsh b/plugins/mercurial/mercurial.plugin.zsh index 86200ccf6..3ae59496e 100644 --- a/plugins/mercurial/mercurial.plugin.zsh +++ b/plugins/mercurial/mercurial.plugin.zsh @@ -14,8 +14,7 @@ alias hgo='hg outgoing' alias hgp='hg push' alias hgs='hg status' alias hgsl='hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n" ' -# this is the 'git commit --amend' equivalent -alias hgca='hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip' +alias hgca='hg commit --amend' # list unresolved files (since hg does not list unmerged files in the status command) alias hgun='hg resolve --list' diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index a390c919c..8af1d6301 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -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' diff --git a/plugins/tmux-cssh/_tmux-cssh b/plugins/tmux-cssh/_tmux-cssh new file mode 100644 index 000000000..604e2e478 --- /dev/null +++ b/plugins/tmux-cssh/_tmux-cssh @@ -0,0 +1,25 @@ +#compdef tmux-cssh + +# tmux-cssh autocompletion for oh-my-zsh +# Requires: tmux-cssh installed +# Author: Manfred Touron (@moul) + +_arguments \ +'(-h --help)'{-h,--help}'[This help.]' \ +'(-u --user)'{-u,--user}'[User to use.]' \ +'(-c --certificate)'{-c,--certificate}'[Path to ssh-certificate to use.]' \ +'(-sc --ssh)'{-sc,--ssh}'[SSH-connection-string, multiple.]' \ +'(-sa --ssh)'{-sa,--ssh}'[SSH connection arguments, used on every session.]' \ +'(-ts --tmux)'{-ts,--tmux}'[Alternative tmux-session-name, default: tmux-cssh]' \ +'(-ns --new)'{-ns,--new}'[Initializes a new session, like -ts \[name\].]' \ +'(-q --quiet)'{-q,--quiet}'[Quiet-mode.]' \ +'(-f --filename)'{-f,--filename}'[Filename of textfile to get -sc connection-strings from, line separated.]' \ +'(-cs --config)'{-cs,--config}'[Name of config-settings which should be get from config-file "$HOME/.tmux-cssh". Which can be a grep-regular expression to find the name(s).]' \ + ':hosts:_hosts' \ + '*:: :->subcmds' \ + && return 0 + +if (( CURRENT == 1 )); then + _describe -t commands "tmux-cssh command" + return +fi diff --git a/plugins/vault/README.md b/plugins/vault/README.md new file mode 100644 index 000000000..0f61c9410 --- /dev/null +++ b/plugins/vault/README.md @@ -0,0 +1,18 @@ +## Vault (https://www.vaultproject.io) autocomplete plugin + +- Adds autocomplete options for all vault commands. + +####Show help for all commands + + + +####Create new Vault token + + + +####Enable audit backends + + + + +Crafted with <3 by Valentin Bud ([@valentinbud](https://twitter.com/valentinbud))
\ No newline at end of file diff --git a/plugins/vault/_vault b/plugins/vault/_vault new file mode 100644 index 000000000..c5338dffa --- /dev/null +++ b/plugins/vault/_vault @@ -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 diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 369a0e680..d3bf97d75 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -13,6 +13,7 @@ function web_search() { yandex "https://yandex.ru/yandsearch?text=" github "https://github.com/search?q=" baidu "https://www.baidu.com/s?wd=" + ecosia "https://www.ecosia.org/search?q=" ) # check whether the search engine is supported @@ -43,6 +44,7 @@ alias ddg='web_search duckduckgo' alias yandex='web_search yandex' alias github='web_search github' alias baidu='web_search baidu' +alias ecosia='web_search ecosia' #add your own !bang searches here alias wiki='web_search duckduckgo \!w' |