diff options
28 files changed, 1100 insertions, 215 deletions
diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 5c5bb0e6d..a3bb24677 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -1,36 +1,37 @@ # ls colors autoload -U colors && colors -export LSCOLORS="Gxfxcxdxbxegedabagacad" # Enable ls colors -if [ "$DISABLE_LS_COLORS" != "true" ] -then - # Find the option for using colors in ls, depending on the version: Linux or BSD +export LSCOLORS="Gxfxcxdxbxegedabagacad" + +if [[ "$DISABLE_LS_COLORS" != "true" ]]; then + # Find the option for using colors in ls, depending on the version if [[ "$(uname -s)" == "NetBSD" ]]; then # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); # otherwise, leave ls as is, because NetBSD's ls doesn't support -G - gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' + gls --color -d . &>/dev/null && alias ls='gls --color=tty' elif [[ "$(uname -s)" == "OpenBSD" ]]; then # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base, # with color and multibyte support) are available from ports. "colorls" # will be installed on purpose and can't be pulled in by installing # coreutils, so prefer it to "gls". - gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' - colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G' + gls --color -d . &>/dev/null && alias ls='gls --color=tty' + colorls -G -d . &>/dev/null && alias ls='colorls -G' else - ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' + # For GNU ls, we use the default ls color theme. They can later be overwritten by themes. + if [[ -z "$LS_COLORS" ]]; then + (( $+commands[dircolors] )) && eval "$(dircolors -b)" + fi + + ls --color -d . &>/dev/null && alias ls='ls --color=tty' || alias ls='ls -G' fi fi setopt auto_cd setopt multios +setopt prompt_subst -if [[ x$WINDOW != x ]] -then - SCREEN_NO="%B$WINDOW%b " -else - SCREEN_NO="" -fi +[[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO="" # Apply theming defaults PS1="%n@%m:%~%# " @@ -40,6 +41,3 @@ ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of th ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean - -# Setup the prompt with pretty colors -setopt prompt_subst diff --git a/plugins/archlinux/README.md b/plugins/archlinux/README.md index 785538a56..16f099415 100644 --- a/plugins/archlinux/README.md +++ b/plugins/archlinux/README.md @@ -27,6 +27,30 @@ | yasu | yaourt -Syua --no-confirm | Same as `yaupg`, but without confirmation | | upgrade | yaourt -Syu | Sync with repositories before upgrading packages | +### PACAUR + +| Alias | Command | Description | +|---------|------------------------------------|---------------------------------------------------------------------| +| pain | pacaur -S | Install packages from the repositories | +| pains | pacaur -U | Install a package from a local file | +| painsd | pacaur -S --asdeps | Install packages as dependencies of another package | +| paloc | pacaur -Qi | Display information about a package in the local database | +| palocs | pacaur -Qs | Search for packages in the local database | +| palst | pacaur -Qe | List installed packages including from AUR (tagged as "local") | +| pamir | pacaur -Syy | Force refresh of all package lists after updating mirrorlist | +| paorph | pacaur -Qtd | Remove orphans using pacaur | +| pare | pacaur -R | Remove packages, keeping its settings and dependencies | +| parem | pacaur -Rns | Remove packages, including its settings and unneeded dependencies | +| parep | pacaur -Si | Display information about a package in the repositories | +| pareps | pacaur -Ss | Search for packages in the repositories | +| paupd | pacaur -Sy && sudo abs && sudo aur | Update and refresh local package, ABS and AUR databases | +| paupd | pacaur -Sy && sudo abs | Update and refresh the local package and ABS databases | +| paupd | pacaur -Sy && sudo aur | Update and refresh the local package and AUR databases | +| paupd | pacaur -Sy | Update and refresh the local package database | +| paupg | pacaur -Syua | Sync with repositories before upgrading all packages (from AUR too) | +| pasu | pacaur -Syua --no-confirm | Same as `paupg`, but without confirmation | +| upgrade | pacaur -Syu | Sync with repositories before upgrading packages | + #### PACMAN | Alias | Command | Description | @@ -67,3 +91,5 @@ - Martin Putniorz - mputniorz@gmail.com - MatthR3D - matthr3d@gmail.com - ornicar - thibault.duplessis@gmail.com +- Juraj Fiala - doctorjellyface@riseup.net +- Majora320 (Moses Miller) - Majora320@gmail.com diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh index 1637e8561..3156e949a 100644 --- a/plugins/archlinux/archlinux.plugin.zsh +++ b/plugins/archlinux/archlinux.plugin.zsh @@ -1,12 +1,4 @@ -if ! (( $+commands[yaourt] )); then - upgrade() { - sudo pacman -Syu - } -else - upgrade () { - yaourt -Syu - } - +if (( $+commands[yaourt] )); then alias yaconf='yaourt -C' alias yaupg='yaourt -Syua' alias yasu='yaourt -Syua --noconfirm' @@ -35,6 +27,47 @@ else fi fi +if (( $+commands[pacaur] )); then + alias paupg='pacaur -Syua' + alias pasu='pacaur -Syua --noconfirm' + alias pain='pacaur -S' + alias pains='pacaur -U' + alias pare='pacaur -R' + alias parem='pacaur -Rns' + alias parep='pacaur -Si' + alias pareps='pacaur -Ss' + alias paloc='pacaur -Qi' + alias palocs='pacaur -Qs' + alias palst='pacaur -Qe' + alias paorph='pacaur -Qtd' + alias painsd='pacaur -S --asdeps' + alias pamir='pacaur -Syy' + + if (( $+commands[abs] && $+commands[aur] )); then + alias paupd='pacaur -Sy && sudo abs && sudo aur' + elif (( $+commands[abs] )); then + alias paupd='pacaur -Sy && sudo abs' + elif (( $+commands[aur] )); then + alias paupd='pacaur -Sy && sudo aur' + else + alias paupd='pacaur -Sy' + fi +fi + +if (( $+commands[pacaur] )); then + upgrade() { + pacaur -Syu + } +elif (( $+commands[yaourt] )); then + upgrade() { + yaourt -Syu + } +else + upgrade() { + sudo pacman -Syu + } +fi + # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips alias pacupg='sudo pacman -Syu' alias pacin='sudo pacman -S' diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh index ea2e56dd6..af58ee77b 100644 --- a/plugins/autoenv/autoenv.plugin.zsh +++ b/plugins/autoenv/autoenv.plugin.zsh @@ -1,7 +1,7 @@ # Activates autoenv or reports its failure () { if ! type autoenv_init >/dev/null; then - for d (~/.autoenv /usr/local/opt/autoenv); do + for d (~/.autoenv /usr/local/opt/autoenv /usr/local/bin); do if [[ -e $d/activate.sh ]]; then autoenv_dir=$d break diff --git a/plugins/cargo/README.md b/plugins/cargo/README.md new file mode 100644 index 000000000..5fa688d21 --- /dev/null +++ b/plugins/cargo/README.md @@ -0,0 +1,11 @@ +# cargo + +This plugin adds completion for the Rust build tool [`cargo`](https://github.com/rust-lang/cargo). + +To use it, add `cargo` to the plugins array in your zshrc file: + +```zsh +plugins=(... cargo) +``` + +Updated on October 4th, 2016. diff --git a/plugins/cargo/_cargo b/plugins/cargo/_cargo new file mode 100644 index 000000000..175859202 --- /dev/null +++ b/plugins/cargo/_cargo @@ -0,0 +1,497 @@ +#compdef cargo + +typeset -A opt_args +autoload -U regexp-replace + +_cargo() { + +_arguments \ + '(- 1 *)'{-h,--help}'[show help message]' \ + '(- 1 *)'--list'[list installed commands]' \ + '(- 1 *)'{-v,--verbose}'[use verbose output]' \ + '(- 1 *)'--color'[colorization option]' \ + '(- 1 *)'{-V,--version}'[show version information]' \ + '1: :_cargo_cmds' \ + '*:: :->args' + +case $state in + args) + case $words[1] in + bench) + _arguments \ + '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ + "${command_scope_spec[@]}" \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--no-default-features[do not build the default features]' \ + '--no-run[compile but do not run]' \ + '(-p,--package)'{-p=,--package=}'[package to run benchmarks for]:packages:_get_package_names' \ + '--target=[target triple]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + build) + _arguments \ + '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ + "${command_scope_spec[@]}" \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--no-default-features[do not build the default features]' \ + '(-p,--package)'{-p=,--package=}'[package to build]:packages:_get_package_names' \ + '--release=[build in release mode]' \ + '--target=[target triple]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + clean) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '(-p,--package)'{-p=,--package=}'[package to clean]:packages:_get_package_names' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--release[whether or not to clean release artifacts]' \ + '--target=[target triple(default:all)]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + doc) + _arguments \ + '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--no-deps[do not build docs for dependencies]' \ + '--no-default-features[do not build the default features]' \ + '--open[open docs in browser after the build]' \ + '(-p, --package)'{-p,--package}'=[package to document]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--release[build artifacts in release mode, with optimizations]' \ + '--target=[build for the target triple]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + fetch) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + generate-lockfile) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + git-checkout) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + 'q(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--reference=[REF]' \ + '--url=[URL]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + help) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '*: :_cargo_cmds' \ + ;; + + init) + _arguments \ + '--bin[use binary template]' \ + '--vcs:initialize a new repo with a given VCS:(git hg none)' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--name=[set the resulting package name]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + install) + _arguments \ + '--bin=[only install the specified binary]' \ + '--branch=[branch to use when installing from git]' \ + '--color=:colorization option:(auto always never)' \ + '--debug[build in debug mode instead of release mode]' \ + '--example[install the specified example instead of binaries]' \ + '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ + '--git=[URL from which to install the crate]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ + '--no-default-features[do not build the default features]' \ + '--path=[local filesystem path to crate to install]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--rev=[specific commit to use when installing from git]' \ + '--root=[directory to install packages into]' \ + '--tag=[tag to use when installing from git]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--vers=[version to install from crates.io]' \ + ;; + + locate-project) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + ;; + + login) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--host=[Host to set the token for]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + metadata) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + "--no-deps[output information only about the root package and don't fetch dependencies]" \ + '--no-default-features[do not include the default feature]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ + '--format-version=[format version(default: 1)]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + new) + _arguments \ + '--bin[use binary template]' \ + '--vcs:initialize a new repo with a given VCS:(git hg none)' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--name=[set the resulting package name]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + owner) + _arguments \ + '(-a, --add)'{-a,--add}'[add owner LOGIN]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--index[registry index]' \ + '(-l, --list)'{-l,--list}'[list owners of a crate]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-r, --remove)'{-r,--remove}'[remove owner LOGIN]' \ + '--token[API token to use when authenticating]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + package) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-l, --list)'{-l,--list}'[print files included in a package without making one]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--no-metadata[ignore warnings about a lack of human-usable metadata]' \ + '--no-verify[do not build to verify contents]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + pkgid) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + publish) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--host=[Host to set the token for]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--no-verify[Do not verify tarball until before publish]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--token[token to use when uploading]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + read-manifest) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + run) + _arguments \ + '--example=[name of the bin target]' \ + '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--bin=[name of the bin target]' \ + '--no-default-features[do not build the default features]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--release=[build in release mode]' \ + '--target=[target triple]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + '*: :_normal' \ + ;; + + rustc) + _arguments \ + '--color=:colorization option:(auto always never)' \ + '--features=[features to compile for the package]' \ + '--all-features[enable all available features]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \ + '--manifest-path=[path to the manifest to fetch dependencies for]' \ + '--no-default-features[do not compile default features for the package]' \ + '(-p, --package)'{-p,--package}'=[profile to compile for]' \ + '--profile=[profile to build the selected target for]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--release[build artifacts in release mode, with optimizations]' \ + '--target=[target triple which compiles will be for]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + "${command_scope_spec[@]}" \ + ;; + + rustdoc) + _arguments \ + '--color=:colorization option:(auto always never)' \ + '--features=[space-separated list of features to also build]' \ + '--all-features[enable all available features]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \ + '--manifest-path=[path to the manifest to document]' \ + '--no-default-features[do not build the `default` feature]' \ + '--open[open the docs in a browser after the operation]' \ + '(-p, --package)'{-p,--package}'=[package to document]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--release[build artifacts in release mode, with optimizations]' \ + '--target=[build for the target triple]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + "${command_scope_spec[@]}" \ + ;; + + search) + _arguments \ + '--color=:colorization option:(auto always never)' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--host=[host of a registry to search in]' \ + '--limit=[limit the number of results]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + ;; + + test) + _arguments \ + '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--test=[test name]: :_test_names' \ + '--no-default-features[do not build the default features]' \ + '--no-fail-fast[run all tests regardless of failure]' \ + '--no-run[compile but do not run]' \ + '(-p,--package)'{-p=,--package=}'[package to run tests for]:packages:_get_package_names' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--release[build artifacts in release mode, with optimizations]' \ + '--target=[target triple]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + '1: :_test_names' \ + ;; + + uninstall) + _arguments \ + '--bin=[only uninstall the binary NAME]' \ + '--color=:colorization option:(auto always never)' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-q, --quiet)'{-q,--quiet}'[less output printed to stdout]' \ + '--root=[directory to uninstall packages from]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + ;; + + update) + _arguments \ + '--aggressive=[force dependency update]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '(-p,--package)'{-p=,--package=}'[package to update]:packages:__get_package_names' \ + '--precise=[update single dependency to PRECISE]: :' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + verify-project) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--manifest-path=[path to manifest]: :_files -/' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + version) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + ;; + + yank) + _arguments \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '--index[registry index]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--token[API token to use when authenticating]' \ + '--undo[undo a yank, putting a version back into the index]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '--color=:colorization option:(auto always never)' \ + '--vers[yank version]' \ + ;; + esac + ;; +esac +} + +_cargo_cmds(){ +local -a commands;commands=( +'bench:execute all benchmarks of a local package' +'build:compile the current project' +'clean:remove generated artifacts' +'doc:build package documentation' +'fetch:fetch package dependencies' +'generate-lockfile:create lockfile' +'git-checkout:git checkout' +'help:get help for commands' +'init:create new project in current directory' +'install:install a Rust binary' +'locate-project:print "Cargo.toml" location' +'login:login to remote server' +'metadata:the metadata for a project in json' +'new:create a new project' +'owner:manage the owners of a crate on the registry' +'package:assemble local package into a distributable tarball' +'pkgid:print a fully qualified package specification' +'publish:upload package to the registry' +'read-manifest:print manifest in JSON format' +'run:run the main binary of the local package' +'rustc:compile a package and all of its dependencies' +'rustdoc:build documentation for a package' +'search:search packages on crates.io' +'test:execute all unit and tests of a local package' +'uninstall:remove a Rust binary' +'update:update dependencies' +'verify-project:check Cargo.toml' +'version:show version information' +'yank:remove pushed file from index' +) +_describe 'command' commands + +} + + +#FIXME: Disabled until fixed +#gets package names from the manifest file +_get_package_names() +{ +} + +#TODO:see if it makes sense to have 'locate-project' to have non-json output. +#strips package name from json stuff +_locate_manifest(){ +local manifest=`cargo locate-project 2>/dev/null` +regexp-replace manifest '\{"root":"|"\}' '' +echo $manifest +} + +# Extracts the values of "name" from the array given in $1 and shows them as +# command line options for completion +_get_names_from_array() +{ + local -a filelist; + local manifest=$(_locate_manifest) + if [[ -z $manifest ]]; then + return 0 + fi + + local last_line + local -a names; + local in_block=false + local block_name=$1 + names=() + while read line + do + if [[ $last_line == "[[$block_name]]" ]]; then + in_block=true + else + if [[ $last_line =~ '.*\[\[.*' ]]; then + in_block=false + fi + fi + + if [[ $in_block == true ]]; then + if [[ $line =~ '.*name.*=' ]]; then + regexp-replace line '^.*name *= *|"' "" + names+=$line + fi + fi + + last_line=$line + done < $manifest + _describe $block_name names + +} + +#Gets the test names from the manifest file +_test_names() +{ + _get_names_from_array "test" +} + +#Gets the bench names from the manifest file +_benchmark_names() +{ + _get_names_from_array "bench" +} + +# These flags are mutally exclusive specifiers for the scope of a command; as +# they are used in multiple places without change, they are expanded into the +# appropriate command's `_arguments` where appropriate. +set command_scope_spec +command_scope_spec=( + '(--bin --example --test --lib)--bench=[benchmark name]: :_benchmark_names' + '(--bench --bin --test --lib)--example=[example name]' + '(--bench --example --test --lib)--bin=[binary name]' + '(--bench --bin --example --test)--lib=[library name]' + '(--bench --bin --example --lib)--test=[test name]' +) + + +_cargo diff --git a/plugins/cp/README.md b/plugins/cp/README.md new file mode 100644 index 000000000..e8a9b6ccc --- /dev/null +++ b/plugins/cp/README.md @@ -0,0 +1,32 @@ +# cp plugin + +This plugin defines a `cpv` function that uses `rsync` so that you +get the features and security of this command. + +To enable, add `cp` to your `plugins` array in your zshrc file: + +```zsh +plugins=(... cp) +``` + +## Description + +The enabled options for rsync are: + +- `-p`: preserves permissions. + +- `-o`: preserves owner. + +* `-g`: preserves group. + +* `-b`: make a backup of the original file instead of overwriting it, if it exists. + +* `-r`: recurse directories. + +* `-hhh`: outputs numbers in human-readable format, in units of 1024 (K, M, G, T). + +* `--backup-dir=/tmp/rsync`: move backup copies to "/tmp/rsync". + +* `-e /dev/null`: only work on local files (disable remote shells). + +* `--progress`: display progress. diff --git a/plugins/cp/cp.plugin.zsh b/plugins/cp/cp.plugin.zsh index 7355a9990..fe6ea87a8 100644 --- a/plugins/cp/cp.plugin.zsh +++ b/plugins/cp/cp.plugin.zsh @@ -1,14 +1,4 @@ -#Show progress while file is copying - -# Rsync options are: -# -p - preserve permissions -# -o - preserve owner -# -g - preserve group -# -h - output in human-readable format -# --progress - display progress -# -b - instead of just overwriting an existing file, save the original -# --backup-dir=/tmp/rsync - move backup copies to "/tmp/rsync" -# -e /dev/null - only work on local files -# -- - everything after this is an argument, even if it looks like an option - -alias cpv="rsync -poghb --backup-dir=/tmp/rsync -e /dev/null --progress --" +cpv() { + rsync -pogbr -hhh --backup-dir=/tmp/rsync -e /dev/null --progress "$@" +} +compdef _files cpv diff --git a/plugins/docker-compose/docker-compose.plugin.zsh b/plugins/docker-compose/docker-compose.plugin.zsh index 351e77824..7e3307017 100644 --- a/plugins/docker-compose/docker-compose.plugin.zsh +++ b/plugins/docker-compose/docker-compose.plugin.zsh @@ -5,9 +5,18 @@ # Aliases ################################################################### -alias dcup='docker-compose up' +# Use dco as alias for docker-compose, since dc on *nix is 'dc - an arbitrary precision calculator' +# https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html + +alias dco='docker-compose' + alias dcb='docker-compose build' -alias dcrm='docker-compose rm' +alias dce='docker-compose exec' alias dcps='docker-compose ps' -alias dcstop='docker-compose stop' alias dcrestart='docker-compose restart' +alias dcrm='docker-compose rm' +alias dcr='docker-compose run' +alias dcstop='docker-compose stop' +alias dcup='docker-compose up' +alias dcl='docker-compose logs' +alias dclf='docker-compose logs -f' diff --git a/plugins/extract/README.md b/plugins/extract/README.md new file mode 100644 index 000000000..c6bdd36dd --- /dev/null +++ b/plugins/extract/README.md @@ -0,0 +1,46 @@ +# extract plugin + +This plugin defines a function called `extract` that extracts the archive file +you pass it, and it supports a wide variety of archive filetypes. + +This way you don't have to know what specific command extracts a file, you just +do `extract <filename>` and the function takes care of the rest. + +To use it, add `extract` to the plugins array in your zshrc file: + +```zsh +plugins=(... extract) +``` + +## Supported file extensions + +| Extension | Description | +|:------------------|:-------------------------------------| +| `7z` | 7zip file | +| `Z` | Z archive (LZW) | +| `apk` | Android app file | +| `bz2` | Bzip2 file | +| `deb` | Debian package | +| `gz` | Gzip file | +| `ipsw` | iOS firmware file | +| `jar` | Java Archive | +| `lzma` | LZMA archive | +| `rar` | WinRAR archive | +| `sublime-package` | Sublime Text package | +| `tar` | Tarball | +| `tar.bz2` | Tarball with bzip2 compression | +| `tar.gz` | Tarball with gzip compression | +| `tar.xz` | Tarball with lzma2 compression | +| `tar.zma` | Tarball with lzma compression | +| `tbz` | Tarball with bzip compression | +| `tbz2` | Tarball with bzip2 compression | +| `tgz` | Tarball with gzip compression | +| `tlz` | Tarball with lzma compression | +| `txz` | Tarball with lzma2 compression | +| `war` | Web Application archive (Java-based) | +| `xpi` | Mozilla XPI module file | +| `xz` | LZMA2 archive | +| `zip` | Zip archive | + +See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for +more information regarding archive formats. diff --git a/plugins/extract/_extract b/plugins/extract/_extract index 387b344bc..172425d2c 100644 --- a/plugins/extract/_extract +++ b/plugins/extract/_extract @@ -3,6 +3,5 @@ _arguments \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \ - "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|ipsw|rar|7z|deb)(-.)'" && return 0 - - + "*::archive file:_files -g '(#i)*.(7z|Z|apk|bz2|deb|gz|ipsw|jar|lzma|rar|sublime-package|tar|tar.bz2|tar.gz|tar.xz|tar.zma|tbz|tbz2|tgz|tlz|txz|war|xpi|xz|zip)(-.)'" \ + && return 0 diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 5d0809e9a..c524bf8f5 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -1,80 +1,71 @@ -# ------------------------------------------------------------------------------ -# FILE: extract.plugin.zsh -# DESCRIPTION: oh-my-zsh plugin file. -# AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com) -# VERSION: 1.0.1 -# ------------------------------------------------------------------------------ +alias x=extract +extract() { + local remove_archive + local success + local extract_dir -function extract() { - local remove_archive - local success - local file_name - local extract_dir + if (( $# == 0 )); then + cat <<-'EOF' >&2 + Usage: extract [-option] [file ...] - if (( $# == 0 )); then - echo "Usage: extract [-option] [file ...]" - echo - echo Options: - echo " -r, --remove Remove archive." - echo - echo "Report bugs to <sorin.ionescu@gmail.com>." - fi + Options: + -r, --remove Remove archive. + EOF + fi - remove_archive=1 - if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then - remove_archive=0 - shift - fi + remove_archive=1 + if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then + remove_archive=0 + shift + fi - while (( $# > 0 )); do - if [[ ! -f "$1" ]]; then - echo "extract: '$1' is not a valid file" 1>&2 - shift - continue - fi + while (( $# > 0 )); do + if [[ ! -f "$1" ]]; then + echo "extract: '$1' is not a valid file" >&2 + shift + continue + fi - success=0 - file_name="$( basename "$1" )" - extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )" - case "$1" in - (*.tar.gz|*.tgz) [ -z $commands[pigz] ] && tar zxvf "$1" || pigz -dc "$1" | tar xv ;; - (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; - (*.tar.xz|*.txz) tar --xz --help &> /dev/null \ - && tar --xz -xvf "$1" \ - || xzcat "$1" | tar xvf - ;; - (*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \ - && tar --lzma -xvf "$1" \ - || lzcat "$1" | tar xvf - ;; - (*.tar) tar xvf "$1" ;; - (*.gz) [ -z $commands[pigz] ] && gunzip "$1" || pigz -d "$1" ;; - (*.bz2) bunzip2 "$1" ;; - (*.xz) unxz "$1" ;; - (*.lzma) unlzma "$1" ;; - (*.Z) uncompress "$1" ;; - (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;; - (*.rar) unrar x -ad "$1" ;; - (*.7z) 7za x "$1" ;; - (*.deb) - mkdir -p "$extract_dir/control" - mkdir -p "$extract_dir/data" - cd "$extract_dir"; ar vx "../${1}" > /dev/null - cd control; tar xzvf ../control.tar.gz - cd ../data; tar xzvf ../data.tar.gz - cd ..; rm *.tar.gz debian-binary - cd .. - ;; - (*) - echo "extract: '$1' cannot be extracted" 1>&2 - success=1 - ;; - esac + success=0 + extract_dir="${1:t:r}" + case "$1" in + (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;; + (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; + (*.tar.xz|*.txz) + tar --xz --help &> /dev/null \ + && tar --xz -xvf "$1" \ + || xzcat "$1" | tar xvf - ;; + (*.tar.zma|*.tlz) + tar --lzma --help &> /dev/null \ + && tar --lzma -xvf "$1" \ + || lzcat "$1" | tar xvf - ;; + (*.tar) tar xvf "$1" ;; + (*.gz) (( $+commands[pigz] )) && pigz -d "$1" || gunzip "$1" ;; + (*.bz2) bunzip2 "$1" ;; + (*.xz) unxz "$1" ;; + (*.lzma) unlzma "$1" ;; + (*.Z) uncompress "$1" ;; + (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;; + (*.rar) unrar x -ad "$1" ;; + (*.7z) 7za x "$1" ;; + (*.deb) + mkdir -p "$extract_dir/control" + mkdir -p "$extract_dir/data" + cd "$extract_dir"; ar vx "../${1}" > /dev/null + cd control; tar xzvf ../control.tar.gz + cd ../data; extract ../data.tar.* + cd ..; rm *.tar.* debian-binary + cd .. + ;; + (*) + echo "extract: '$1' cannot be extracted" >&2 + success=1 + ;; + esac - (( success = $success > 0 ? $success : $? )) - (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" - shift - done + (( success = $success > 0 ? $success : $? )) + (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" + shift + done } - -alias x=extract - diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 25da03509..28fb253dd 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -65,6 +65,7 @@ alias gca!='git commit -v -a --amend' alias gcan!='git commit -v -a --no-edit --amend' alias gcans!='git commit -v -a -s --no-edit --amend' alias gcam='git commit -a -m' +alias gcsm='git commit -s -m' alias gcb='git checkout -b' alias gcf='git config --list' alias gcl='git clone --recursive' @@ -236,4 +237,4 @@ alias gupv='git pull --rebase -v' alias glum='git pull upstream master' 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 --no-verify -m "--wip--"' diff --git a/plugins/last-working-dir/README.md b/plugins/last-working-dir/README.md new file mode 100644 index 000000000..4cc4acab6 --- /dev/null +++ b/plugins/last-working-dir/README.md @@ -0,0 +1,9 @@ +# last-working-dir plugin + +Keeps track of the last used working directory and automatically jumps into it +for new shells, unless: + +- The plugin is already loaded. +- The current `$PWD` is not `$HOME`. + +Adds `lwd` function to jump to the last working directory. diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh index c458464ce..e882b288f 100644 --- a/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -1,26 +1,23 @@ -#!/usr/bin/env zsh -# Keeps track of the last used working directory and automatically jumps -# into it for new shells. - -# Flag indicating if we've previously jumped to last directory. +# Flag indicating if we've previously jumped to last directory typeset -g ZSH_LAST_WORKING_DIRECTORY -mkdir -p $ZSH_CACHE_DIR -cache_file="$ZSH_CACHE_DIR/last-working-dir" -# Updates the last directory once directory is changed. +# Updates the last directory once directory is changed chpwd_functions+=(chpwd_last_working_dir) -function chpwd_last_working_dir() { - # Use >| in case noclobber is set to avoid "file exists" error +chpwd_last_working_dir() { + local cache_file="$ZSH_CACHE_DIR/last-working-dir" pwd >| "$cache_file" } -# Changes directory to the last working directory. -function lwd() { - [[ ! -r "$cache_file" ]] || cd "`cat "$cache_file"`" +# Changes directory to the last working directory +lwd() { + local cache_file="$ZSH_CACHE_DIR/last-working-dir" + [[ -r "$cache_file" ]] && cd "$(cat "$cache_file")" } -# Automatically jump to last working directory unless this isn't the first time -# this plugin has been loaded. -if [[ -z "$ZSH_LAST_WORKING_DIRECTORY" ]]; then - lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true -fi +# Jump to last directory automatically unless: +# - this isn't the first time the plugin is loaded +# - it's not in $HOME directory +[[ -n "$ZSH_LAST_WORKING_DIRECTORY" ]] && return +[[ "$PWD" != "$HOME" ]] && return + +lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh index 625aad949..04bd186af 100644 --- a/plugins/mvn/mvn.plugin.zsh +++ b/plugins/mvn/mvn.plugin.zsh @@ -110,6 +110,8 @@ function listMavenCompletions { help:active-profiles help:all-profiles help:describe help:effective-pom help:effective-settings help:evaluate help:expressions help:system # release release:clean release:prepare release:rollback release:perform release:stage release:branch release:update-versions + # jgitflow + jgitflow:feature-start jgitflow:feature-finish jgitflow:release-start jgitflow:release-finish jgitflow:hotfix-start jgitflow:hotfix-finish jgitflow:build-number # repository repository:bundle-create repository:bundle-pack # source diff --git a/plugins/nomad/README.md b/plugins/nomad/README.md new file mode 100644 index 000000000..04b361683 --- /dev/null +++ b/plugins/nomad/README.md @@ -0,0 +1,15 @@ +# Nomad + +The `nomad` plugin provides a simple autocompletion for [Nomad](https://nomadproject.io/), a tool from Hashicorp for easily deploy applications at any scale. + +## Usage + +1. Enable the `nomad` plugin: + + ```zsh + plugins=(... nomad) + ``` + +2. Install [Nomad](https://nomadproject.io/) + +3. Type `nomad` into your prompt and hit `TAB` to see available completion options. diff --git a/plugins/nomad/_nomad b/plugins/nomad/_nomad new file mode 100644 index 000000000..1c935a02e --- /dev/null +++ b/plugins/nomad/_nomad @@ -0,0 +1,153 @@ +#compdef nomad + +local -a _nomad_cmds +_nomad_cmds=( + 'agent:Runs a Nomad agent' + 'agent-info:Display status information about the local agent' + 'alloc-status:Display allocation status information and metadata' + 'client-config:View or modify client configuration details' + 'eval-status:Display evaluation status and placement failure reasons' + 'fs:Inspect the contents of an allocation directory' + 'init:Create an example job file' + 'inspect:Inspect a submitted job' + 'logs:Streams the logs of a task.' + 'node-drain:Toggle drain mode on a given node' + 'node-status:Display status information about nodes' + 'plan:Dry-run a job update to determine its effects' + 'run:Run a new job or update an existing' + 'server-force-leave:Force a server into the left state' + 'server-join:Join server nodes together' + 'server-members:Display a list of known servers and their' + 'status:Display status information about jobs' + 'stop:Stop a running job' + 'validate:Checks if a given job specification is valid' + 'version:Prints the Nomad version' +) + +__allocstatus() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-short[Display short output. Shows only the most recent task event.]' \ + '-stats[Display detailed resource usage statistics.]' \ + '-verbose[Show full information.]' \ + '-json[Output the allocation in its JSON format.]' \ + '-t[Format and display allocation using a Go template.]' +} + +__evalstatus() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-monitor[Monitor an outstanding evaluation.]' \ + '-verbose[Show full information.]' \ + '-json[Output the allocation in its JSON format.]' \ + '-t[Format and display allocation using a Go template.]' +} + +__inspect() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-json[Output the allocation in its JSON format.]' \ + '-t[Format and display allocation using a Go template.]' +} + +__logs() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-stderr[ Display stderr logs.]' \ + '-job[<job-id> Use a random allocation from the specified job ID.]' \ + '-verbose[Show full information.]' \ + '-f[Causes the output to not stop when the end of the logs are reached, but rather to wait for additional output.]' \ + '-tail[Show the logs contents with offsets relative to the end of the logs. If no offset is given, -n is defaulted to 10.]' \ + '-n[Sets the tail location in best-efforted number of lines relative to the end of the logs.]' \ + '-c[Sets the tail location in number of bytes relative to the end of the logs.]' +} + +__nodestatus() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-self[Query the status of the local node.]' \ + '-allocs[ Display a count of running allocations for each node.]' \ + '-short[Display short output. Shows only the most recent task event.]' \ + '-stats[Display detailed resource usage statistics.]' \ + '-verbose[Show full information.]' \ + '-json[Output the allocation in its JSON format.]' \ + '-t[Format and display allocation using a Go template.]' +} + +__plan() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-diff[Determines whether the diff between the remote job and planned job is shown. Defaults to true.]' +} + +__run() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-check-index[If set, the job is only registered or updated if the the passed job modify index matches the server side version. If a check-index value of zero is passed, the job is only registered if it does not yet exist. If a non-zero value is passed, it ensures that the job is being updated from a known state. The use of this flag is most common in conjunction with plan command.]' \ + '-detach[Return immediately instead of entering monitor mode. After job submission, the evaluation ID will be printed to the screen, which can be used to examine the evaluation using the eval-status command.]' \ + '-output[Output the JSON that would be submitted to the HTTP API without submitting the job.]' \ + '-verbose[Show full information.]' +} + +__status() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-short[Display short output. Shows only the most recent task event.]' \ + '-evals[Display the evaluations associated with the job.]' \ + '-verbose[Show full information.]' +} + +__stop() { + _arguments \ + '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \ + '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \ + '-no-color[Disables colored command output.]' \ + '-detach[Return immediately instead of entering monitor mode. After the deregister command is submitted, a new evaluation ID is printed to the screen, which can be used to examine the evaluation using the eval-status command.]' \ + '-yes[Automatic yes to prompts.]' \ + '-verbose[Show full information.]' +} + +_arguments '*:: :->command' + +if (( CURRENT == 1 )); then + _describe -t commands "nomad command" _nomad_cmds + return +fi + +local -a _command_args +case "$words[1]" in + alloc-status) + __allocstatus ;; + eval-status) + __evalstatus ;; + inspect) + __inspect ;; + logs) + __logs ;; + node-status) + __nodestatus ;; + plan) + __plan ;; + run) + __run ;; + status) + __status ;; + stop) + __stop ;; +esac diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index aa6a256c1..d7baa1191 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -314,7 +314,7 @@ function spotify() { position=$(osascript -e 'tell application "Spotify" to player position as string' | tr ',' '.'); position=$(echo "scale=2; $position / 60" | bc | awk '{printf "%0.2f", $0}'); - printf "$reset""Artist: %s\nAlbum: %s\nTrack: %s \nPosition: %s / %s" "$artist" "$album" "$track" "$position" "$duration"; + printf "$reset""Artist: %s\nAlbum: %s\nTrack: %s \nPosition: %s / %s\n" "$artist" "$album" "$track" "$position" "$duration"; fi } @@ -412,17 +412,17 @@ function spotify() { osascript -e 'tell application "Spotify" to playpause'; break ;; - "quit" ) + "quit" ) cecho "Quitting Spotify."; osascript -e 'tell application "Spotify" to quit'; exit 1 ;; - "next" ) + "next" ) cecho "Going to next track." ; osascript -e 'tell application "Spotify" to next track'; break ;; - "prev" ) + "prev" ) cecho "Going to previous track."; osascript -e 'tell application "Spotify" to previous track'; break ;; diff --git a/plugins/per-directory-history/README.md b/plugins/per-directory-history/README.md index d8ff93dc0..196f74e6c 100644 --- a/plugins/per-directory-history/README.md +++ b/plugins/per-directory-history/README.md @@ -27,9 +27,8 @@ Usage 2. The default mode if per directory history, interact with your history as normal. 3. Press ^G (the Control and G keys simultaneously) to toggle between local - and global histories. - - + and global histories. If you would prefer a different shortcut to toggle + set the PER_DIRECTORY_HISTORY_TOGGLE environment variable. ------------------------------------------------------------------------------- Configuration diff --git a/plugins/per-directory-history/per-directory-history.zsh b/plugins/per-directory-history/per-directory-history.zsh index bdee341bd..1242dc420 100644 --- a/plugins/per-directory-history/per-directory-history.zsh +++ b/plugins/per-directory-history/per-directory-history.zsh @@ -30,7 +30,7 @@ # ################################################################################ # -# Copyright (c) 2012 Jim Hester +# Copyright (c) 2014 Jim Hester # # This software is provided 'as-is', without any express or implied warranty. # In no event will the authors be held liable for any damages arising from the @@ -57,6 +57,7 @@ #------------------------------------------------------------------------------- [[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history" +[[ -z $PER_DIRECTORY_HISTORY_TOGGLE ]] && PER_DIRECTORY_HISTORY_TOGGLE='^G' #------------------------------------------------------------------------------- # toggle global/directory history used for searching - ctrl-G by default @@ -76,7 +77,7 @@ function per-directory-history-toggle-history() { autoload per-directory-history-toggle-history zle -N per-directory-history-toggle-history -bindkey '^G' per-directory-history-toggle-history +bindkey $PER_DIRECTORY_HISTORY_TOGGLE per-directory-history-toggle-history #------------------------------------------------------------------------------- # implementation details @@ -108,7 +109,7 @@ function _per-directory-history-change-directory() { } function _per-directory-history-addhistory() { - print -Sr -- ${1%%$'\n'} + print -Sr -- "${1%%$'\n'}" fc -p $_per_directory_history_directory } @@ -140,8 +141,9 @@ function _per-directory-history-set-global-history() { #add functions to the exec list for chpwd and zshaddhistory -chpwd_functions=(${chpwd_functions[@]} "_per-directory-history-change-directory") -zshaddhistory_functions=(${zshaddhistory_functions[@]} "_per-directory-history-addhistory") +autoload -U add-zsh-hook +add-zsh-hook chpwd _per-directory-history-change-directory +add-zsh-hook zshaddhistory _per-directory-history-addhistory #start in directory mode mkdir -p ${_per_directory_history_directory:h} diff --git a/plugins/pip/_pip b/plugins/pip/_pip index cb155e5f4..732ffabea 100644 --- a/plugins/pip/_pip +++ b/plugins/pip/_pip @@ -1,7 +1,8 @@ #compdef pip pip2 pip-2.7 pip3 pip-3.2 pip-3.3 pip-3.4 #autoload -# pip zsh completion, based on homebrew completion +# pip zsh completion, based on last stable release (pip8) +# homebrew completion and backwards compatibility _pip_all() { # we cache the list of packages (originally from the macports plugin) @@ -17,30 +18,43 @@ _pip_installed() { local -a _1st_arguments _1st_arguments=( - 'bundle:create pybundles (archives containing multiple packages)' + 'install:install packages' + 'download:download packages' + 'uninstall:uninstall packages' 'freeze:output all currently installed packages (exact versions) to stdout' - 'help:show available commands' + 'list:list installed packages' 'show:show information about installed packages' - 'install:install packages' 'search:search PyPI' - 'uninstall:uninstall packages' - 'unzip:unzip individual packages' - 'zip:zip individual packages' + 'wheel:build individual wheel archives for your requirements and dependencies' + 'hash:compute a hash of a local package archive' + 'help:show available commands' + 'bundle:create pybundles (archives containing multiple packages)(deprecated)' + 'unzip:unzip individual packages(deprecated)' + 'zip:zip individual packages(deprecated)' ) local expl local -a all_pkgs installed_pkgs _arguments \ - '(--version)--version[show version number of program and exit]' \ '(-h --help)'{-h,--help}'[show help]' \ - '(-E --environment)'{-E,--environment}'[virtualenv environment to run pip in]' \ - '(-s --enable-site-packages)'{-s,--enable-site-packages}'[include site-packages in virtualenv]' \ + '(--isolated)--isolated[run pip in isolated mode, ignores environment variables and user configuration]' \ '(-v --verbose)'{-v,--verbose}'[give more output]' \ + '(-V --version)'{-V,--version}'[show version number of program and exit]' \ '(-q --quiet)'{-q,--quiet}'[give less output]' \ '(--log)--log[log file location]' \ '(--proxy)--proxy[proxy in form user:passwd@proxy.server:port]' \ + '(--retries)--retries[max number of retries per connection (default 5 times)]' \ '(--timeout)--timeout[socket timeout (default 15s)]' \ + '(--exists-action)--exists-action[default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup]' \ + '(--trusted-host)--trusted-host[mark this host as trusted]' \ + '(--cert)--cert[path to alternate CA bundle]' \ + '(--client-cert)--client-cert[path to SSL client certificate]' \ + '(--cache-dir)--cache-dir[store the cache data in specified directory]' \ + '(--no-cache-dir)--no-cache-dir[disable de cache]' \ + '(--disable-pip-version-check)--disable-pip-version-check[do not check periodically for new pip version downloads]' \ + '(-E --environment)'{-E,--environment}'[virtualenv environment to run pip in (deprecated)]' \ + '(-s --enable-site-packages)'{-s,--enable-site-packages}'[include site-packages in virtualenv (deprecated)]' \ '*:: :->subcmds' && return 0 if (( CURRENT == 1 )); then @@ -56,7 +70,7 @@ case "$words[1]" in _arguments \ '(-l --local)'{-l,--local}'[report only virtualenv packages]' ;; install) - _arguments \ + _arguments \ '(-U --upgrade)'{-U,--upgrade}'[upgrade all packages to the newest available version]' \ '(-f --find-links)'{-f,--find-links}'[URL for finding packages]' \ '(-r --requirement)'{-r,--requirement}'[Requirements file for packages to install]:File:_files' \ diff --git a/plugins/react-native/react-native.plugin.zsh b/plugins/react-native/react-native.plugin.zsh index 7323f1d2e..9463a98b3 100644 --- a/plugins/react-native/react-native.plugin.zsh +++ b/plugins/react-native/react-native.plugin.zsh @@ -3,4 +3,5 @@ alias rnios4s='react-native run-ios --simulator "iPhone 4s"' alias rnios5='react-native run-ios --simulator "iPhone 5"' alias rnios5s='react-native run-ios --simulator "iPhone 5s"' alias rnios='react-native run-ios' +alias rnlink='react-native link' diff --git a/plugins/svn/README.md b/plugins/svn/README.md new file mode 100644 index 000000000..1f7b70c86 --- /dev/null +++ b/plugins/svn/README.md @@ -0,0 +1,67 @@ +# `svn` plugin + +This plugin adds some utility functions to display additional information regarding your current +svn repository. See http://subversion.apache.org/ for the full svn documentation. + +To use it, add `svn` to your plugins array: + +```zsh +plugins=(... svn) +``` + +## Functions + +| Command | Description | +|:----------------------|:--------------------------------------------| +| `svn_prompt_info` | Shows svn prompt in themes | +| `in_svn` | Checks if we're in an svn repository | +| `svn_get_repo_name` | Get repository name | +| `svn_get_branch_name` | Get branch name (see [caveats](#caveats)) | +| `svn_get_rev_nr` | Get revision number | +| `svn_dirty` | Checks if there are changes in the svn repo | + +## Caveats + +The plugin expects the first directory to be the current branch / tag / trunk. So it returns +the first path element if you don't use branches. + +## Usage on themes + +To use this in the `agnoster` theme follow these instructions: + +1. Enable the svn plugin + +2. Add the following lines to your `zshrc` file: + + ```shell + prompt_svn() { + local rev branch + if in_svn; then + rev=$(svn_get_rev_nr) + branch=$(svn_get_branch_name) + if [[ $(svn_dirty_choose_pwd 1 0) -eq 1 ]]; then + prompt_segment yellow black + echo -n "$rev@$branch" + echo -n "±" + else + prompt_segment green black + echo -n "$rev@$branch" + fi + fi + } + ``` + +3. Override the agnoster `build_prompt()` function: + + ```zsh + build_prompt() { + RETVAL=$? + prompt_status + prompt_context + prompt_dir + prompt_git + prompt_svn + prompt_end + } + ``` + diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index 816055afe..fbc9ee538 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -1,9 +1,7 @@ -# vim:ft=zsh ts=2 sw=2 sts=2 -# -function svn_prompt_info() { +svn_prompt_info() { local _DISPLAY if in_svn; then - if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then + if [[ "$SVN_SHOW_BRANCH" = true ]]; then unset SVN_SHOW_BRANCH _DISPLAY=$(svn_get_branch_name) else @@ -16,23 +14,20 @@ $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_S } -function in_svn() { - if $(svn info >/dev/null 2>&1); then - return 0 - fi - return 1 +in_svn() { + svn info >/dev/null 2>&1 } -function svn_get_repo_name() { +svn_get_repo_name() { if in_svn; then - svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT - svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p" + LANG=C svn info | sed -n 's/^Repository\ Root:\ .*\///p' | read SVN_ROOT + LANG=C svn info | sed -n "s/^URL:\ .*$SVN_ROOT\///p" fi } -function svn_get_branch_name() { +svn_get_branch_name() { local _DISPLAY=$( - svn info 2> /dev/null | \ + LANG=C svn info 2> /dev/null | \ awk -F/ \ '/^URL:/ { \ for (i=0; i<=NF; i++) { \ @@ -44,24 +39,28 @@ function svn_get_branch_name() { } \ }' ) - - if [ "x$_DISPLAY" = "x" ]; then + + if [[ -z "$_DISPLAY" ]]; then svn_get_repo_name else echo $_DISPLAY fi } -function svn_get_rev_nr() { +svn_get_rev_nr() { if in_svn; then - svn info 2> /dev/null | sed -n 's/Revision:\ //p' + LANG=C svn info 2> /dev/null | sed -n 's/Revision:\ //p' fi } -function svn_dirty_choose() { +svn_dirty() { + svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN +} + +svn_dirty_choose() { if in_svn; then - local root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'` - if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then + local root=$(LANG=C svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p') + if svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then # Grep exits with 0 when "One or more lines were selected", return "dirty". echo $1 else @@ -71,14 +70,13 @@ function svn_dirty_choose() { fi } -function svn_dirty() { - svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN +svn_dirty_pwd () { + svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD } -function svn_dirty_choose_pwd () { +svn_dirty_choose_pwd () { if in_svn; then - local root=$PWD - if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then + if svn status "$PWD" 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then # Grep exits with 0 when "One or more lines were selected", return "dirty". echo $1 else @@ -87,9 +85,3 @@ function svn_dirty_choose_pwd () { fi fi } - -function svn_dirty_pwd () { - svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD -} - - diff --git a/themes/xiong-chiamiov-plus.zsh-theme b/themes/xiong-chiamiov-plus.zsh-theme index 095dae290..5fb4fe6f4 100644 --- a/themes/xiong-chiamiov-plus.zsh-theme +++ b/themes/xiong-chiamiov-plus.zsh-theme @@ -1,6 +1,6 @@ # user, host, full path, and time/date # on two lines for easier vgrepping # entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888 -PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %I:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} +PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %H:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} %{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B] <$(git_prompt_info)>%{\e[0m%}%b ' PS2=$' \e[0;34m%}%B>%{\e[0m%}%b ' diff --git a/themes/xiong-chiamiov.zsh-theme b/themes/xiong-chiamiov.zsh-theme index 7c4c2e4f8..0ed335fb5 100644 --- a/themes/xiong-chiamiov.zsh-theme +++ b/themes/xiong-chiamiov.zsh-theme @@ -1,6 +1,6 @@ # user, host, full path, and time/date # on two lines for easier vgrepping # entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888 -PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %I:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} +PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%a %b %d, %H:%M"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} %{\e[0;34m%}%B└─%B[%{\e[1;35m%}$%{\e[0;34m%}%B]>%{\e[0m%}%b ' PS2=$' \e[0;34m%}%B>%{\e[0m%}%b ' diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index bd9aba8be..a57f6da0f 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -29,31 +29,32 @@ fi # Cancel upgrade if git is unavailable on the system whence git >/dev/null || return 0 -if [ -f ~/.zsh-update ] -then - . ~/.zsh-update +if mkdir "$ZSH/log/update.lock" 2>/dev/null; then + if [ -f ~/.zsh-update ]; then + . ~/.zsh-update - if [[ -z "$LAST_EPOCH" ]]; then - _update_zsh_update && return 0; - fi + if [[ -z "$LAST_EPOCH" ]]; then + _update_zsh_update && return 0; + fi - epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) - if [ $epoch_diff -gt $epoch_target ] - then - if [ "$DISABLE_UPDATE_PROMPT" = "true" ] - then - _upgrade_zsh - else - echo "[Oh My Zsh] Would you like to check for updates? [Y/n]: \c" - read line - if [[ "$line" == Y* ]] || [[ "$line" == y* ]] || [ -z "$line" ]; then + epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) + if [ $epoch_diff -gt $epoch_target ]; then + if [ "$DISABLE_UPDATE_PROMPT" = "true" ]; then _upgrade_zsh else - _update_zsh_update + echo "[Oh My Zsh] Would you like to check for updates? [Y/n]: \c" + read line + if [[ "$line" == Y* ]] || [[ "$line" == y* ]] || [ -z "$line" ]; then + _upgrade_zsh + else + _update_zsh_update + fi fi fi + else + # create the zsh file + _update_zsh_update fi -else - # create the zsh file - _update_zsh_update + + rmdir $ZSH/log/update.lock fi |