diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2018-05-20 13:00:53 -0600 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2018-05-20 13:00:53 -0600 |
commit | db38c7c3b2921783d955912262f87ee7dd8cd31b (patch) | |
tree | 19711b0495e8472fdfb85643c2c7ec7c5a5229c3 /plugins | |
parent | 1481f7aa67df42bdf45953231637194ac200d240 (diff) | |
parent | a600ab4b8578ca0a8e6c6dae0373033b9d8c201c (diff) | |
download | zsh-db38c7c3b2921783d955912262f87ee7dd8cd31b.tar.gz zsh-db38c7c3b2921783d955912262f87ee7dd8cd31b.tar.bz2 zsh-db38c7c3b2921783d955912262f87ee7dd8cd31b.zip |
Merge branch 'master' of https://github.com/robbyrussell/oh-my-zsh
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/aws/aws.plugin.zsh | 11 | ||||
-rw-r--r-- | plugins/copydir/README.md | 10 | ||||
-rw-r--r-- | plugins/copyfile/README.md | 10 | ||||
-rw-r--r-- | plugins/dirhistory/dirhistory.plugin.zsh | 58 | ||||
-rw-r--r-- | plugins/docker/_docker | 10 | ||||
-rw-r--r-- | plugins/fasd/fasd.plugin.zsh | 2 | ||||
-rw-r--r-- | plugins/fedora/README.md | 3 | ||||
l---------[-rw-r--r--] | plugins/fedora/fedora.plugin.zsh | 17 | ||||
-rw-r--r-- | plugins/git-prompt/gitstatus.py | 2 | ||||
-rw-r--r-- | plugins/gpg-agent/gpg-agent.plugin.zsh | 14 | ||||
-rw-r--r-- | plugins/gradle/gradle.plugin.zsh | 6 | ||||
-rw-r--r-- | plugins/heroku/_heroku | 48 | ||||
-rw-r--r-- | plugins/kubectl/kubectl.plugin.zsh | 6 | ||||
-rw-r--r-- | plugins/last-working-dir/last-working-dir.plugin.zsh | 6 | ||||
-rw-r--r-- | plugins/minikube/minikube.plugin.zsh | 6 | ||||
-rw-r--r-- | plugins/pyenv/pyenv.plugin.zsh | 26 | ||||
-rw-r--r-- | plugins/rust/_rust | 4 | ||||
-rw-r--r-- | plugins/shrink-path/shrink-path.plugin.zsh | 5 | ||||
-rw-r--r-- | plugins/terraform/README.md | 8 | ||||
-rw-r--r-- | plugins/terraform/_terraform | 192 | ||||
-rw-r--r-- | plugins/ubuntu/ubuntu.plugin.zsh | 67 | ||||
-rw-r--r-- | plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh | 7 |
22 files changed, 386 insertions, 132 deletions
diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 6a0e04add..183b0f226 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -37,16 +37,15 @@ function asp { } function aws_profiles { - reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/')) + reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/')) } - compctl -K aws_profiles asp -if _homebrew-installed && _awscli-homebrew-installed ; then +if which aws_zsh_completer.sh &>/dev/null; then + _aws_zsh_completer_path=$(which aws_zsh_completer.sh 2>/dev/null) +elif _homebrew-installed && _awscli-homebrew-installed; then _aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh -else - _aws_zsh_completer_path=$(which aws_zsh_completer.sh) fi -[ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path +[ -n "$_aws_zsh_completer_path" ] && [ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path unset _aws_zsh_completer_path diff --git a/plugins/copydir/README.md b/plugins/copydir/README.md new file mode 100644 index 000000000..594bf1065 --- /dev/null +++ b/plugins/copydir/README.md @@ -0,0 +1,10 @@ +# copydir plugin + +Copies the path of your current folder to the system clipboard. + +To use, add `copydir` to your plugins array: +``` +plugins=(... copydir) +``` + +Then use the command `copydir` to copy the $PWD. diff --git a/plugins/copyfile/README.md b/plugins/copyfile/README.md new file mode 100644 index 000000000..53138ad06 --- /dev/null +++ b/plugins/copyfile/README.md @@ -0,0 +1,10 @@ +# copyfile plugin + +Puts the contents of a file in your system clipboard so you can paste it anywhere. + +To use, add `copyfile` to your plugins array: +``` +plugins=(... copyfile) +``` + +Then you can run the command `copyfile <filename>` to copy the file named `filename`. diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh index 8138872bc..239915e48 100644 --- a/plugins/dirhistory/dirhistory.plugin.zsh +++ b/plugins/dirhistory/dirhistory.plugin.zsh @@ -2,6 +2,10 @@ # Navigate directory history using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories # that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT. # +# Navigate directory hierarchy using ALT-UP and ALT-DOWN. (mac keybindings not yet implemented) +# ALT-UP moves to higher hierarchy (cd ..) +# ALT-DOWN moves into the first directory found in alphabetical order +# dirhistory_past=($PWD) dirhistory_future=() @@ -120,7 +124,9 @@ zle -N dirhistory_zle_dirhistory_back bindkey "\e[3D" dirhistory_zle_dirhistory_back bindkey "\e[1;3D" dirhistory_zle_dirhistory_back # Mac teminal (alt+left/right) -bindkey "^[b" dirhistory_zle_dirhistory_back +if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then + bindkey "^[b" dirhistory_zle_dirhistory_back +fi # Putty: bindkey "\e\e[D" dirhistory_zle_dirhistory_back # GNU screen: @@ -129,8 +135,56 @@ bindkey "\eO3D" dirhistory_zle_dirhistory_back zle -N dirhistory_zle_dirhistory_future bindkey "\e[3C" dirhistory_zle_dirhistory_future bindkey "\e[1;3C" dirhistory_zle_dirhistory_future -bindkey "^[f" dirhistory_zle_dirhistory_future +if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then + bindkey "^[f" dirhistory_zle_dirhistory_future +fi bindkey "\e\e[C" dirhistory_zle_dirhistory_future bindkey "\eO3C" dirhistory_zle_dirhistory_future +# +# HIERARCHY Implemented in this section, in case someone wants to split it to another plugin if it clashes bindings +# + +# Move up in hierarchy +function dirhistory_up() { + cd .. || return 1 +} + +# Move down in hierarchy +function dirhistory_down() { + cd "$(find . -mindepth 1 -maxdepth 1 -type d | sort -n | head -n 1)" || return 1 +} + + +# Bind keys to hierarchy navigation +function dirhistory_zle_dirhistory_up() { + zle kill-buffer # Erase current line in buffer + dirhistory_up + zle accept-line +} + +function dirhistory_zle_dirhistory_down() { + zle kill-buffer # Erase current line in buffer + dirhistory_down + zle accept-line +} + +zle -N dirhistory_zle_dirhistory_up +# xterm in normal mode +bindkey "\e[3A" dirhistory_zle_dirhistory_up +bindkey "\e[1;3A" dirhistory_zle_dirhistory_up +# Mac teminal (alt+up) + #bindkey "^[?" dirhistory_zle_dirhistory_up #dont know it +# Putty: +bindkey "\e\e[A" dirhistory_zle_dirhistory_up +# GNU screen: +bindkey "\eO3A" dirhistory_zle_dirhistory_up + +zle -N dirhistory_zle_dirhistory_down +bindkey "\e[3B" dirhistory_zle_dirhistory_down +bindkey "\e[1;3B" dirhistory_zle_dirhistory_down +# Mac teminal (alt+down) + #bindkey "^[?" dirhistory_zle_dirhistory_down #dont know it +bindkey "\e\e[B" dirhistory_zle_dirhistory_down +bindkey "\eO3B" dirhistory_zle_dirhistory_down diff --git a/plugins/docker/_docker b/plugins/docker/_docker index 0c20cf28e..32ad4848a 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -450,9 +450,9 @@ __docker_complete_events_filter() { ;; (event) local -a event_opts - event_opts=('attach' 'commit' 'connect' 'copy' 'create' 'delete' 'destroy' 'detach' 'die' 'disconnect' 'exec_create' 'exec_detach' - 'exec_start' 'export' 'health_status' 'import' 'kill' 'load' 'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'rename' 'resize' 'restart' 'save' 'start' - 'stop' 'tag' 'top' 'unmount' 'unpause' 'untag' 'update') + event_opts=('attach' 'commit' 'connect' 'copy' 'create' 'delete' 'destroy' 'detach' 'die' 'disable' 'disconnect' 'enable' 'exec_create' 'exec_detach' + 'exec_start' 'export' 'health_status' 'import' 'install' 'kill' 'load' 'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'remove' 'rename' 'resize' + 'restart' 'save' 'start' 'stop' 'tag' 'top' 'unmount' 'unpause' 'untag' 'update') _describe -t event-filter-opts "event filter options" event_opts && ret=0 ;; (image) @@ -889,7 +889,7 @@ __docker_container_subcommand() { $opts_help \ $opts_attach_exec_run_start \ "($help -a --attach)"{-a,--attach}"[Attach container's stdout/stderr and forward all signals]" \ - "($help -i --interactive)"{-i,--interactive}"[Attach container's stding]" \ + "($help -i --interactive)"{-i,--interactive}"[Attach container's stdin]" \ "($help -)*:containers:__docker_complete_stopped_containers" && ret=0 ;; (stats) @@ -3024,4 +3024,4 @@ _docker "$@" # indent-tabs-mode: nil # sh-basic-offset: 4 # End: -# vim: ft=zsh sw=4 ts=4 et
\ No newline at end of file +# vim: ft=zsh sw=4 ts=4 et diff --git a/plugins/fasd/fasd.plugin.zsh b/plugins/fasd/fasd.plugin.zsh index 2c302f74d..45d10858f 100644 --- a/plugins/fasd/fasd.plugin.zsh +++ b/plugins/fasd/fasd.plugin.zsh @@ -6,6 +6,6 @@ if [ $commands[fasd] ]; then # check if fasd is installed source "$fasd_cache" unset fasd_cache - alias v="f -e $EDITOR" + alias v="f -e \"$EDITOR\"" alias o='a -e open_command' fi diff --git a/plugins/fedora/README.md b/plugins/fedora/README.md deleted file mode 100644 index f384b0ffd..000000000 --- a/plugins/fedora/README.md +++ /dev/null @@ -1,3 +0,0 @@ -This is a plugin based on yum plugin, but using dnf as main frontend -(from Fedora 22 onwards, yum is deprecated in favor of dnf). - diff --git a/plugins/fedora/fedora.plugin.zsh b/plugins/fedora/fedora.plugin.zsh index eddc3627b..16a214313 100644..120000 --- a/plugins/fedora/fedora.plugin.zsh +++ b/plugins/fedora/fedora.plugin.zsh @@ -1,16 +1 @@ -## Aliases - -alias dnfs="dnf search" # search package -alias dnfp="dnf info" # show package info -alias dnfl="dnf list" # list packages -alias dnfgl="dnf grouplist" # list package groups -alias dnfli="dnf list installed" # print all installed packages -alias dnfmc="dnf makecache" # rebuilds the dnf package list - -alias dnfu="sudo dnf upgrade" # upgrade packages -alias dnfi="sudo dnf install" # install package -alias dnfgi="sudo dnf groupinstall" # install package group -alias dnfr="sudo dnf remove" # remove package -alias dnfgr="sudo dnf groupremove" # remove pagage group -alias dnfrl="sudo dnf remove --remove-leaves" # remove package and leaves -alias dnfc="sudo dnf clean all" # clean cache +../dnf/dnf.plugin.zsh
\ No newline at end of file diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index a8eb8284b..14d875973 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -41,7 +41,7 @@ ahead, behind = 0, 0 status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()] for st in status: if st[0] == '#' and st[1] == '#': - if re.search('Initial commit on', st[2]): + if re.search('Initial commit on', st[2]) or re.search('No commits yet on', st[2]): branch = st[2].split(' ')[-1] elif re.search('no branch', st[2]): # detached status branch = get_tagname_or_hash() diff --git a/plugins/gpg-agent/gpg-agent.plugin.zsh b/plugins/gpg-agent/gpg-agent.plugin.zsh index 6a94f598f..3e24c2527 100644 --- a/plugins/gpg-agent/gpg-agent.plugin.zsh +++ b/plugins/gpg-agent/gpg-agent.plugin.zsh @@ -1,16 +1,16 @@ # Enable gpg-agent if it is not running- # --use-standard-socket will work from version 2 upwards -AGENT_SOCK=`gpgconf --list-dirs | grep agent-socket | cut -d : -f 2` +AGENT_SOCK=$(gpgconf --list-dirs | grep agent-socket | cut -d : -f 2) -if [ ! -S ${AGENT_SOCK} ]; then - gpg-agent --daemon --use-standard-socket >/dev/null 2>&1 +if [[ ! -S $AGENT_SOCK ]]; then + gpg-agent --daemon --use-standard-socket &>/dev/null fi -export GPG_TTY=$(tty) +export GPG_TTY=$TTY # Set SSH to use gpg-agent if it's enabled -if [ -S "${AGENT_SOCK}.ssh" ]; then - export SSH_AUTH_SOCK="${AGENT_SOCK}.ssh" +GNUPGCONFIG="${GNUPGHOME:-"$HOME/.gnupg"}/gpg-agent.conf" +if [[ -r $GNUPGCONFIG ]] && command grep -q enable-ssh-support "$GNUPGCONFIG"; then + export SSH_AUTH_SOCK="$AGENT_SOCK.ssh" unset SSH_AGENT_PID fi - diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh index 0adc04a13..c7047552d 100644 --- a/plugins/gradle/gradle.plugin.zsh +++ b/plugins/gradle/gradle.plugin.zsh @@ -88,7 +88,7 @@ function _gradle_arguments() { # and if so, regenerate the .gradle_tasks cache file ############################################################################ _gradle_does_task_list_need_generating () { - [[ ! -f .gradletasknamecache ]] || [[ build.gradle -nt .gradletasknamecache ]] + [[ ! -f .gradletasknamecache ]] || [[ build.gradle -nt .gradletasknamecache || build.gradle.kts -nt .gradletasknamecache ]] } ############## @@ -144,7 +144,7 @@ _gradle_parse_and_extract_tasks () { # Discover the gradle tasks by running "gradle tasks --all" ############################################################################ _gradle_tasks () { - if [[ -f build.gradle ]]; then + if [[ -f build.gradle || -f build.gradle.kts ]]; then _gradle_arguments if _gradle_does_task_list_need_generating; then _gradle_parse_and_extract_tasks "$(gradle tasks --all)" > .gradletasknamecache @@ -154,7 +154,7 @@ _gradle_tasks () { } _gradlew_tasks () { - if [[ -f build.gradle ]]; then + if [[ -f build.gradle || -f build.gradle.kts ]]; then _gradle_arguments if _gradle_does_task_list_need_generating; then _gradle_parse_and_extract_tasks "$(./gradlew tasks --all)" > .gradletasknamecache diff --git a/plugins/heroku/_heroku b/plugins/heroku/_heroku index 878d3ce1b..4122de237 100644 --- a/plugins/heroku/_heroku +++ b/plugins/heroku/_heroku @@ -45,6 +45,18 @@ _1st_arguments=( "logs\:drains":"manage syslog drains" "maintenance\:on":"put the app into maintenance mode" "maintenance\:off":"take the app out of maintenance mode" + "pipelines":"list pipelines you have access to" + "pipelines\:add":"add this app to a pipeline" + "pipelines\:create":"create a new pipeline" + "pipelines\:destroy":"destroy a pipeline" + "pipelines\:diff":"compares the latest release of this app to its downstream app(s)" + "pipelines\:info":"show list of apps in a pipeline" + "pipelines\:list":"list pipelines you have access to" + "pipelines\:open":"open a pipeline in dashboard" + "pipelines\:promote":"promote the latest release of this app to its downstream app(s)" + "pipelines\:remove":"remove this app from its pipeline" + "pipelines\:rename":"rename a pipeline" + "pipelines\:update":"update this app's stage in a pipeline" "pg\:credentials":"display the DATABASE credentials" "pg\:diagnose":"run diagnostics report on DATABASE" "pg\:info":"display database information" @@ -60,6 +72,7 @@ _1st_arguments=( "pg\:unfollow":"stop a replica from following and make it a read/write database" "pg\:upgrade":"unfollow a database and upgrade it to the latest PostgreSQL version" "pg\:wait":"monitor database creation, exit when complete" + "pg\:backups":"Interact with built-in backups" "pgbackups":"list captured backups" "pgbackups\:url":"get a temporary URL for a backup" "pgbackups\:capture":"capture a backup from a database id" @@ -131,6 +144,41 @@ case "$words[1]" in '(-t|--tail)'{-t,--tail}'[continually stream logs]' \ ) ;; + pipelines) + _command_args=( + '(--json)'--json'[output in json format]' \ + ) + ;; + pipelines:add) + _command_args=( + '(-s|--stage)'{-s,--stage}'[stage of first app in pipeline]' \ + ) + ;; + pipelines:create) + _command_args=( + '(-s|--stage)'{-s,--stage}'[stage of first app in pipeline]' \ + ) + ;; + pipelines:info) + _command_args=( + '(--json)'--json'[output in json format]' \ + ) + ;; + pipelines:list) + _command_args=( + '(--json)'--json'[output in json format]' \ + ) + ;; + pipelines:promote) + _command_args=( + '(-t|--to)'{-t,--to}'[comma separated list of apps to promote to]' \ + ) + ;; + pipelines:update) + _command_args=( + '(-s|--stage)'{-s,--stage}'[stage of first app in pipeline]' \ + ) + ;; pgbackups:capture) _command_args=( '(-e|--expire)'{-e,--expire}'[if no slots are available to capture, delete the oldest backup to make room]' \ diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index 97e429aac..ec1321d8b 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -33,6 +33,12 @@ alias kes='k edit svc' alias kds='k describe svc' alias kdels='k delete svc' +# Ingress management +alias kgi='k get ingress' +alias kei='k edit ingress' +alias kdi='k describe ingress' +alias kdeli='k delete ingress' + # Secret management alias kgsec='k get secret' alias kdsec='k describe secret' diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh index e882b288f..53bb19e46 100644 --- a/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -4,8 +4,10 @@ typeset -g ZSH_LAST_WORKING_DIRECTORY # Updates the last directory once directory is changed chpwd_functions+=(chpwd_last_working_dir) chpwd_last_working_dir() { - local cache_file="$ZSH_CACHE_DIR/last-working-dir" - pwd >| "$cache_file" + if [ "$ZSH_SUBSHELL" = 0 ]; then + local cache_file="$ZSH_CACHE_DIR/last-working-dir" + pwd >| "$cache_file" + fi } # Changes directory to the last working directory diff --git a/plugins/minikube/minikube.plugin.zsh b/plugins/minikube/minikube.plugin.zsh new file mode 100644 index 000000000..d8ebe79af --- /dev/null +++ b/plugins/minikube/minikube.plugin.zsh @@ -0,0 +1,6 @@ +# Autocompletion for Minikube. +# + +if [ $commands[minikube] ]; then + source <(minikube completion zsh) +fi diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh index 76880e415..dbc7da472 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -1,7 +1,29 @@ # This plugin loads pyenv into the current shell and provides prompt info via # the 'pyenv_prompt_info' function. Also loads pyenv-virtualenv if available. -if (( $+commands[pyenv] )); then +FOUND_PYENV=$+commands[pyenv] + +if [[ $FOUND_PYENV -ne 1 ]]; then + pyenvdirs=("$HOME/.pyenv" "/usr/local/pyenv" "/opt/pyenv") + for dir in $pyenvdirs; do + if [[ -d $dir/bin ]]; then + export PATH="$PATH:$dir/bin" + FOUND_PYENV=1 + break + fi + done +fi + +if [[ $FOUND_PYENV -ne 1 ]]; then + if (( $+commands[brew] )) && dir=$(brew --prefix pyenv 2>/dev/null); then + if [[ -d $dir/bin ]]; then + export PATH="$PATH:$dir/bin" + FOUND_PYENV=1 + fi + fi +fi + +if [[ $FOUND_PYENV -eq 1 ]]; then eval "$(pyenv init - zsh)" if (( $+commands[pyenv-virtualenv-init] )); then eval "$(pyenv virtualenv-init - zsh)" @@ -15,3 +37,5 @@ else echo "system: $(python -V 2>&1 | cut -f 2 -d ' ')" } fi + +unset FOUND_PYENV dir diff --git a/plugins/rust/_rust b/plugins/rust/_rust index ac6aee160..6e3f344cd 100644 --- a/plugins/rust/_rust +++ b/plugins/rust/_rust @@ -88,14 +88,14 @@ _rustc_opts_vals=( --pretty='[Pretty-print the input instead of compiling]::TYPE:_values "TYPES" "$_rustc_pretty_types[@]"' --unpretty='[Present the input source, unstable (and less-pretty)]::TYPE:_values "TYPES" "$_rustc_unpretty_types[@]"' --color='[Configure coloring of output]:CONF:_values "COLORS" "$_rustc_color_types[@]"' - {-v,--version}'[Print version info and exit]::VERBOSE:(verbose)' ) _rustc_opts_switches=( -g'[Equivalent to --debuginfo=2]' -O'[Equivalent to --opt-level=2]' --test'[Build a test harness]' - --verbose'[Use verbose output]' + {-v,--verbose}'[Use verbose output]' + {-V,--version}'[Print version info and exit]' {-h,--help}'[Display this message]' --no-analysis'[Parse and expand the output, but run no analysis or produce output]' --no-trans'[Run all passes except translation; no output]' diff --git a/plugins/shrink-path/shrink-path.plugin.zsh b/plugins/shrink-path/shrink-path.plugin.zsh index f111962a5..6dd6a930f 100644 --- a/plugins/shrink-path/shrink-path.plugin.zsh +++ b/plugins/shrink-path/shrink-path.plugin.zsh @@ -94,6 +94,11 @@ shrink_path () { (( tilde )) && dir=${dir/$HOME/\~} tree=(${(s:/:)dir}) ( + # unset chpwd_functions since we'll be calling `cd` and don't + # want any side-effects (eg., if the user was using auto-ls) + chpwd_functions=() + # unset chpwd since even if chpwd_functions is (), zsh will + # attempt to execute chpwd unfunction chpwd 2> /dev/null if [[ $tree[1] == \~* ]] { cd ${~tree[1]} diff --git a/plugins/terraform/README.md b/plugins/terraform/README.md index 46855e417..e5d9e47b6 100644 --- a/plugins/terraform/README.md +++ b/plugins/terraform/README.md @@ -1,7 +1,9 @@ -## atom +## Terraform oh-my-zsh plugin Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently. +Current as of Terraform v0.11.7 + ### Requirements * [Terraform](https://terraform.io/) @@ -12,8 +14,8 @@ Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely a ### Expanding ZSH prompt with current Terraform workspace name -If you want to get current Terraform workspace name in your ZSH prompt open -your .zsh-theme file and in a choosen place insert: +If you want to get current Terraform workspace name in your ZSH prompt open +your .zsh-theme file and in a chosen place insert: ``` $FG[045]\ diff --git a/plugins/terraform/_terraform b/plugins/terraform/_terraform index 285d83ec7..1d1315a8a 100644 --- a/plugins/terraform/_terraform +++ b/plugins/terraform/_terraform @@ -3,91 +3,151 @@ local -a _terraform_cmds _terraform_cmds=( 'apply:Builds or changes infrastructure' + 'console:Interactive console for Terraform interpolations' 'destroy:Destroy Terraform-managed infrastructure' + 'fmt:Rewrites config files to canonical format' 'get:Download and install modules for the configuration' 'graph:Create a visual graph of Terraform resources' - 'init:Initializes Terraform configuration from a module' + 'import:Import existing infrastructure into Terraform' + 'init:Initialize a Terraform working directory' 'output:Read an output from a state file' 'plan:Generate and show an execution plan' - 'pull:Refreshes the local state copy from the remote server' - 'push:Uploads the local state to the remote server' + 'providers:Prints a tree of the providers used in the configuration' + 'push:Upload this Terraform module to Atlas to run' 'refresh:Update local state file against real resources' - 'remote:Configures remote state management' 'show:Inspect Terraform state or plan' - 'taint:Manually forcing a destroy and recreate on the next plan/apply' + 'taint:Manually mark a resource for recreation' + 'untaint:Manually unmark a resource as tainted' + 'validate:Validates the Terraform files' 'version:Prints the Terraform version' + 'workspace:Workspace management' ) __apply() { _arguments \ - '-auto-approve[Skip interactive approval of plan before applying.]' \ '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \ + '-auto-approve[Skip interactive approval of plan before applying.]' \ + '-lock=[(true) Lock the state file when locking is supported.]' \ + '-lock-timeout=[(0s) Duration to retry a state lock.]' \ '-input=[(true) Ask for input for variables if not directly set.]' \ - '-no-color[If specified, output will not contain any color.]' \ + '-no-color[If specified, output wil be colorless.]' \ + '-parallelism=[(10) Limit the number of parallel resource operations.]' \ '-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \ - '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \ + '-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]' \ '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \ - '-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \ + '-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \ '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ - '-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]' + '-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]' +} + +__console() { + _arguments \ + '-state=[(terraform.tfstate) Path to read state.]' \ + '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ + '-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]' } __destroy() { _arguments \ '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \ - '-force[If set, then the destroy confirmation will not be shown.]' \ - '-input=[(true) Ask for input for variables if not directly set.]' \ - '-no-color[If specified, output will not contain any color.]' \ + '-auto-approve[Skip interactive approval before destroying.]' \ + '-force[Deprecated: same as auto-approve.]' \ + '-lock=[(true) Lock the state file when locking is supported.]' \ + '-lock-timeout=[(0s) Duration to retry a state lock.]' \ + '-no-color[If specified, output will contain no color.]' \ + '-parallelism=[(10) Limit the number of concurrent operations.]' \ '-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \ - '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \ + '-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]' \ '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \ - '-target=[(resource) Instead of affecting "dependencies" will instead also destroy any resources that depend on the target(s) specified.]' \ + '-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \ '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ - '-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]' + '-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]' +} + +__fmt() { + _arguments \ + '-list=[(true) List files whose formatting differs (always false if using STDIN)]' \ + '-write=[(true) Write result to source file instead of STDOUT (always false if using STDIN or -check)]' \ + '-diff=[(false) Display diffs of formatting changes]' \ + '-check=[(false) Check if the input is formatted. Exit status will be 0 if all input is properly formatted and non-zero otherwise.]' } __get() { _arguments \ - '-update=[(false) If true, modules already downloaded will be checked for updates and updated if necessary.]' + '-update=[(false) If true, modules already downloaded will be checked for updates and updated if necessary.]' \ + '-no-color[If specified, output will contain no color.]' } __graph() { _arguments \ '-draw-cycles[Highlight any cycles in the graph with colored edges. This helps when diagnosing cycle errors.]' \ - '-module-depth=[(n) The maximum depth to expand modules. By default this is zero, which will not expand modules at all.]' \ - '-verbose[Generate a verbose, "worst-case" graph, with all nodes for potential operations in place.]' + '-no-color[If specified, output will contain no color.]' \ + '-type=[(plan) Type of graph to output. Can be: plan, plan-destroy, apply, validate, input, refresh.]' +} + +__import() { + _arguments \ + '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \ + '-config=[(path) Path to a directory of Terraform configuration files to use to configure the provider. Defaults to pwd. If no config files are present, they must be provided via the input prompts or env vars.]' \ + '-allow-missing-config[Allow import when no resource configuration block exists.]' \ + '-input=[(true) Ask for input for variables if not directly set.]' \ + '-lock=[(true) Lock the state file when locking is supported.]' \ + '-lock-timeout=[(0s) Duration to retry a state lock.]' \ + '-no-color[If specified, output will contain no color.]' \ + '-provider=[(provider) Specific provider to use for import. This is used for specifying aliases, such as "aws.eu". Defaults to the normal provider prefix of the resource being imported.]' \ + '-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]' \ + '-state-out=[(PATH) Path to the destination state file to write to. If this is not specified, the source state file will be used. This can be a new or existing path.]' \ + '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times. This is only useful with the "-config" flag.]' \ + '-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]' } __init() { _arguments \ - '-address=[(url) URL of the remote storage server. Required for HTTP backend, optional for Atlas and Consul.]' \ - '-access-token=[(token) Authentication token for state storage server. Required for Atlas backend, optional for Consul.]' \ - '-backend=[(atlas) Specifies the type of remote backend. Must be one of Atlas, Consul, or HTTP. Defaults to atlas.]' \ - '-backend-config=[(path) Specifies the path to remote backend config file.]' \ - '-name=[(name) Name of the state file in the state storage server. Required for Atlas backend.]' \ - '-path=[(path) Path of the remote state in Consul. Required for the Consul backend.]' + '-backend=[(true) Configure the backend for this configuration.]' \ + '-backend-config=[This can be either a path to an HCL file with key/value assignments (same format as terraform.tfvars) or a 'key=value' format. This is merged with what is in the configuration file. This can be specified multiple times. The backend type must be in the configuration itself.]' \ + '-force-copy[Suppress prompts about copying state data. This is equivalent to providing a "yes" to all confirmation prompts.]' \ + '-from-module=[Copy the contents of the given module into the target directory before initialization.]' \ + '-get=[(true) Download any modules for this configuration.]' \ + '-get-plugins=[(true) Download any missing plugins for this configuration.]' \ + '-input=[(true) Ask for input if necessary. If false, will error if input was required.]' \ + '-lock=[(true) Lock the state file when locking is supported.]' \ + '-lock-timeout=[(0s) Duration to retry a state lock.]' \ + '-no-color[If specified, output will contain no color.]' \ + '-plugin-dir[Directory containing plugin binaries. This overrides all default search paths for plugins, and prevents the automatic installation of plugins. This flag can be used multiple times.]' \ + '-reconfigure[Reconfigure the backend, ignoring any saved configuration.]' \ + '-upgrade=[(false) If installing modules (-get) or plugins (-get-plugins), ignore previously-downloaded objects and install the latest version allowed within configured constraints.]' \ + '-verify-plugins=[(true) Verify the authenticity and integrity of automatically downloaded plugins.]' } __output() { _arguments \ '-state=[(path) Path to the state file to read. Defaults to "terraform.tfstate".]' \ - '-module=[(module_name) The module path which has needed output. By default this is the root path. Other modules can be specified by a period-separated list.]' + '-no-color[ If specified, output will contain no color.]' \ + '-module=[(name) If specified, returns the outputs for a specific module]' \ + '-json[If specified, machine readable output will be printed in JSON format]' } __plan() { _arguments \ - '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with" .backup" extension. Set to "-" to disable backup.]' \ - '-destroy[If set, a plan will be generated to destroy all resources managed by the given configuration and state.]' \ - '-detailed-exitcode[Return a detailed exit code when the command exits. When provided, this argument changes the exit codes and their meanings to provide more granular information about what the resulting plan contains]' \ + '-destroy[() If set, a plan will be generated to destroy all resources managed by the given configuration and state.]' \ + '-detailed-exitcode[() Return detailed exit codes when the command exits. This will change the meaning of exit codes to: 0 - Succeeded, diff is empty (no changes); 1 - Errored, 2 - Succeeded; there is a diff]' \ '-input=[(true) Ask for input for variables if not directly set.]' \ - '-module-depth=[(n) Specifies the depth of modules to show in the output. This does not affect the plan itself, only the output shown. By default, this is zero. -1 will expand all.]' \ - '-no-color[If specified, output will not contain any color.]' \ + '-lock=[(true) Lock the state file when locking is supported.]' \ + '-lock-timeout=[(0s) Duration to retry a state lock.]' \ + '-module-depth=[(n) Specifies the depth of modules to show in the output. This does not affect the plan itself, only the output shown. By default, this is -1, which will expand all.]' \ + '-no-color[() If specified, output will contain no color.]' \ '-out=[(path) Write a plan file to the given path. This can be used as input to the "apply" command.]' \ + '-parallelism=[(10) Limit the number of concurrent operations.]' \ '-refresh=[(true) Update state prior to checking for differences.]' \ '-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]' \ - '-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \ + '-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \ '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ - '-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]' + '-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]' \ +} + +__providers() { + _arguments \ + } __push() { @@ -106,6 +166,9 @@ __push() { __refresh() { _arguments \ '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \ + '-input=[(true) Ask for input for variables if not directly set.]' \ + '-lock=[(true) Lock the state file when locking is supported.]' \ + '-lock-timeout=[(0s) Duration to retry a state lock.]' \ '-no-color[If specified, output will not contain any color.]' \ '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \ '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \ @@ -114,19 +177,6 @@ __refresh() { '-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]' } -__remote() { - _arguments \ - '-address=[(url) URL of the remote storage server. Required for HTTP backend, optional for Atlas and Consul.]' \ - '-access-token=[(token) Authentication token for state storage server. Required for Atlas backend, optional for Consul.]' \ - '-backend=[(atlas) Specifies the type of remote backend. Must be one of Atlas, Consul, or HTTP. Defaults to atlas.]' \ - '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \ - '-disable[Disables remote state management and migrates the state to the -state path.]' \ - '-name=[(name) Name of the state file in the state storage server. Required for Atlas backend.]' \ - '-path=[(path) Path of the remote state in Consul. Required for the Consul backend.]' \ - '-pull=[(true) Controls if the remote state is pulled before disabling. This defaults to true to ensure the latest state is cached before disabling.]' \ - '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' -} - __show() { _arguments \ '-module-depth=[(n) The maximum depth to expand modules. By default this is zero, which will not expand modules at all.]' \ @@ -137,12 +187,46 @@ __taint() { _arguments \ '-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \ '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \ + '-lock=[(true) Lock the state file when locking is supported.]' \ + '-lock-timeout=[(0s) Duration to retry a state lock.]' \ '-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \ '-no-color[If specified, output will not contain any color.]' \ '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \ '-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]' } +__untaint() { + _arguments \ + '-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \ + '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \ + '-lock=[(true) Lock the state file when locking is supported.]' \ + '-lock-timeout=[(0s) Duration to retry a state lock.]' \ + '-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \ + '-no-color[If specified, output will not contain any color.]' \ + '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \ + '-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]' +} + +__validate() { + _arguments \ + '-check-variables=[(true) If set to true (default), the command will check whether all required variables have been specified.]' \ + '-no-color[If specified, output will not contain any color.]' \ + '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ + '-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]' +} + +__workspace() { + local -a __workspace_cmds + __workspace_cmds=( + 'delete:Delete a workspace' + 'list:List Workspaces' + 'new:Create a new workspace' + 'select:Select a workspace' + 'show:Show the name of the current workspace' + ) + _describe -t workspace "workspace commands" __workspace_cmds +} + _arguments '*:: :->command' if (( CURRENT == 1 )); then @@ -154,26 +238,38 @@ local -a _command_args case "$words[1]" in apply) __apply ;; + console) + __console;; destroy) __destroy ;; + fmt) + __fmt;; get) __get ;; graph) __graph ;; + import) + __import;; init) __init ;; output) __output ;; plan) __plan ;; + providers) + __providers ;; push) __push ;; refresh) __refresh ;; - remote) - __remote ;; show) __show ;; taint) __taint ;; + untaint) + __untaint ;; + validate) + __validate ;; + workspace) + test $CURRENT -lt 3 && __workspace ;; esac diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh index 082481466..f7363feb8 100644 --- a/plugins/ubuntu/ubuntu.plugin.zsh +++ b/plugins/ubuntu/ubuntu.plugin.zsh @@ -5,18 +5,21 @@ # https://github.com/trinaldi # Nicolas Jonas nextgenthemes.com # https://github.com/loctauxphilippe +# https://github.com/HaraldNordgren # # Debian, Ubuntu and friends related zsh aliases and functions for zsh +(( $+commands[apt] )) && APT=apt || APT=apt-get + alias acs='apt-cache search' compdef _acs acs='apt-cache search' alias afs='apt-file search --regexp' compdef _afs afs='apt-file search --regexp' -# These are apt-get only -alias ags='apt-get source' # asrc -compdef _ags ags='apt-get source' +# These are apt/apt-get only +alias ags="$APT source" # asrc +compdef _ags ags="$APT source" alias acp='apt-cache policy' # app compdef _acp acp='apt-cache policy' @@ -37,33 +40,33 @@ compdef _afu afu='sudo apt-file update' alias ppap='sudo ppa-purge' compdef _ppap ppap='sudo ppa-purge' -alias apg='sudo apt-get' # age - but without sudo -alias aga='sudo apt-get autoclean' # aac -alias agb='sudo apt-get build-dep' # abd -alias agc='sudo apt-get clean' # adc -alias agd='sudo apt-get dselect-upgrade' # ads -alias agi='sudo apt-get install' # ai -alias agp='sudo apt-get purge' # ap -alias agr='sudo apt-get remove' # ar -alias agu='sudo apt-get update' # ad -alias agud='sudo apt-get update && sudo apt-get full-upgrade' #adu -alias agug='sudo apt-get upgrade' # ag -alias aguu='sudo apt-get update && sudo apt-get upgrade' #adg -alias agar='sudo apt-get autoremove' - -compdef _ag apg='sudo apt-get' -compdef _aga aga='sudo apt-get autoclean' -compdef _agb agb='sudo apt-get build-dep' -compdef _agc agc='sudo apt-get clean' -compdef _agd agd='sudo apt-get dselect-upgrade' -compdef _agi agi='sudo apt-get install' -compdef _agp agp='sudo apt-get purge' -compdef _agr agr='sudo apt-get remove' -compdef _agu agu='sudo apt-get update' -compdef _agud agud='sudo apt-get update && sudo apt-get full-upgrade' -compdef _agug agug='sudo apt-get upgrade' -compdef _aguu aguu='sudo apt-get update && sudo apt-get upgrade' -compdef _agar agar='sudo apt-get autoremove' +alias ag="sudo $APT" # age - but without sudo +alias aga="sudo $APT autoclean" # aac +alias agb="sudo $APT build-dep" # abd +alias agc="sudo $APT clean" # adc +alias agd="sudo $APT dselect-upgrade" # ads +alias agi="sudo $APT install" # ai +alias agp="sudo $APT purge" # ap +alias agr="sudo $APT remove" # ar +alias agu="sudo $APT update" # ad +alias agud="sudo $APT update && sudo $APT dist-upgrade" #adu +alias agug="sudo $APT upgrade" # ag +alias aguu="sudo $APT update && sudo $APT upgrade" #adg +alias agar="sudo $APT autoremove" + +compdef _ag ag="sudo $APT" +compdef _aga aga="sudo $APT autoclean" +compdef _agb agb="sudo $APT build-dep" +compdef _agc agc="sudo $APT clean" +compdef _agd agd="sudo $APT dselect-upgrade" +compdef _agi agi="sudo $APT install" +compdef _agp agp="sudo $APT purge" +compdef _agr agr="sudo $APT remove" +compdef _agu agu="sudo $APT update" +compdef _agud agud="sudo $APT update && sudo $APT dist-upgrade" +compdef _agug agug="sudo $APT upgrade" +compdef _aguu aguu="sudo $APT update && sudo $APT upgrade" +compdef _agar agar="sudo $APT autoremove" # Remove ALL kernel images and headers EXCEPT the one in use alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \ @@ -91,8 +94,8 @@ aar() { PACKAGE=${1##*/} fi - sudo apt-add-repository $1 && sudo apt-get update - sudo apt-get install $PACKAGE + sudo apt-add-repository $1 && sudo $APT update + sudo $APT install $PACKAGE } # Prints apt history diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index 6cd30732e..484f18c91 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -6,6 +6,13 @@ if (( $+commands[$virtualenvwrapper] )); then unsetopt equals source ${${virtualenvwrapper}:c} } +elif [[ -f "/usr/local/bin/virtualenvwrapper.sh" ]]; then + function { + setopt local_options + unsetopt equals + virtualenvwrapper="/usr/local/bin/virtualenvwrapper.sh" + source "/usr/local/bin/virtualenvwrapper.sh" + } elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then function { setopt local_options |