summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2023-03-18 16:23:39 -0700
committerTuowen Zhao <ztuowen@gmail.com>2023-03-18 16:23:39 -0700
commit4b0bbc0b263a150eb9a9b59f196914629be06a9b (patch)
tree619723cfa449f93149b766ee397f85ce2acef5f7
parentdb7efd2336e4dbe6abf321b00dbc11bc5afb1355 (diff)
parent72732a224e886933df6b64a49ec6f5e94c884612 (diff)
downloadzsh-4b0bbc0b263a150eb9a9b59f196914629be06a9b.tar.gz
zsh-4b0bbc0b263a150eb9a9b59f196914629be06a9b.tar.bz2
zsh-4b0bbc0b263a150eb9a9b59f196914629be06a9b.zip
Merge remote-tracking branch 'github/master'
-rw-r--r--.gitignore3
-rw-r--r--.prettierrc4
-rw-r--r--README.md12
-rw-r--r--lib/completion.zsh4
-rw-r--r--lib/correction.zsh5
-rw-r--r--lib/directories.zsh8
-rw-r--r--lib/functions.zsh9
-rw-r--r--lib/misc.zsh8
-rw-r--r--lib/prompt_info_functions.zsh1
-rw-r--r--lib/theme-and-appearance.zsh122
-rw-r--r--lib/vcs_info.zsh2
-rw-r--r--oh-my-zsh.sh7
-rw-r--r--plugins/aliases/README.md2
-rw-r--r--plugins/aliases/cheatsheet.py5
-rw-r--r--plugins/argocd/README.md20
-rw-r--r--plugins/argocd/argocd.plugin.zsh14
-rw-r--r--plugins/aws/README.md22
-rw-r--r--plugins/aws/aws.plugin.zsh41
-rw-r--r--plugins/azure/README.md49
-rw-r--r--plugins/azure/azure.plugin.zsh62
-rw-r--r--plugins/brew/README.md27
-rw-r--r--plugins/brew/brew.plugin.zsh2
-rw-r--r--plugins/dotnet/README.md1
-rw-r--r--plugins/dotnet/dotnet.plugin.zsh1
-rw-r--r--plugins/extract/README.md16
-rw-r--r--plugins/extract/_extract2
-rw-r--r--plugins/extract/extract.plugin.zsh3
-rw-r--r--plugins/fasd/README.md2
-rw-r--r--plugins/fzf/fzf.plugin.zsh14
-rw-r--r--plugins/gcloud/gcloud.plugin.zsh1
-rw-r--r--plugins/git/README.md9
-rw-r--r--plugins/git/git.plugin.zsh15
-rw-r--r--plugins/gnu-utils/gnu-utils.plugin.zsh11
-rw-r--r--plugins/gradle/_gradle22
-rw-r--r--plugins/iterm2/README.md12
-rw-r--r--plugins/iterm2/iterm2.plugin.zsh11
-rw-r--r--plugins/iterm2/iterm2_shell_integration.zsh178
-rwxr-xr-xplugins/iterm2/update4
-rw-r--r--plugins/lando/README.md1
-rw-r--r--plugins/macos/README.md2
-rw-r--r--plugins/macos/macos.plugin.zsh7
-rw-r--r--plugins/marked2/marked2.plugin.zsh7
-rw-r--r--plugins/marktext/README.md17
-rw-r--r--plugins/marktext/marktext.plugin.zsh7
-rw-r--r--plugins/nats/README.md14
-rw-r--r--plugins/nats/nats.plugin.zsh23
-rw-r--r--plugins/nodenv/README.md20
-rw-r--r--plugins/nodenv/nodenv.plugin.zsh43
-rw-r--r--plugins/nsc/README.md11
-rw-r--r--plugins/nsc/nsc.plugin.zsh13
-rw-r--r--plugins/rails/README.md1
-rw-r--r--plugins/rails/rails.plugin.zsh1
-rw-r--r--plugins/rvm/README.md1
-rw-r--r--plugins/rvm/rvm.plugin.zsh1
-rw-r--r--plugins/sudo/sudo.plugin.zsh2
-rw-r--r--plugins/systemadmin/systemadmin.plugin.zsh8
-rw-r--r--plugins/terraform/README.md1
-rw-r--r--plugins/terraform/_terraform411
-rw-r--r--plugins/terraform/terraform.plugin.zsh6
-rw-r--r--plugins/vi-mode/README.md40
-rw-r--r--plugins/vi-mode/vi-mode.plugin.zsh23
-rw-r--r--plugins/zsh-interactive-cd/LICENSE375
-rw-r--r--plugins/zsh-interactive-cd/README.md22
-rw-r--r--plugins/zsh-interactive-cd/demo.gifbin0 -> 1497944 bytes
-rw-r--r--plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh54
-rw-r--r--themes/af-magic.zsh-theme5
-rw-r--r--themes/amuse.zsh-theme8
-rw-r--r--themes/mlh.zsh-theme10
-rw-r--r--tools/check_for_upgrade.sh2
-rwxr-xr-xtools/install.sh52
70 files changed, 1709 insertions, 210 deletions
diff --git a/.gitignore b/.gitignore
index 71ae444e5..10bd4bebc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,4 +8,5 @@ log/
.DS_Store
# editor configs
-.vscode \ No newline at end of file
+.vscode
+.idea
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 000000000..a8f5a14b0
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,4 @@
+{
+ "printWidth": 110,
+ "proseWrap": "always"
+}
diff --git a/README.md b/README.md
index 1e4b7ff70..4042c8c26 100644
--- a/README.md
+++ b/README.md
@@ -276,6 +276,16 @@ If you have many functions that go well together, you can put them as a `XYZ.plu
If you would like to override the functionality of a plugin distributed with Oh My Zsh, create a plugin of the same name in the `custom/plugins/` directory and it will be loaded instead of the one in `plugins/`.
+### Remove directories aliases
+
+If you want to skip ohmyzsh default
+[directories aliases](https://github.com/ohmyzsh/ohmyzsh/blob/master/lib/directories.zsh) you can add the
+following snippet to your `zshrc`, before loading `oh-my-zsh.sh` script:
+
+```zsh
+zstyle ':omz:directories' aliases no
+```
+
## Getting Updates
By default, you will be prompted to check for updates every 2 weeks. You can choose other update modes by adding a line to your `~/.zshrc` file, **before Oh My Zsh is loaded**:
@@ -364,4 +374,4 @@ Oh My Zsh is released under the [MIT license](LICENSE.txt).
![Planet Argon](https://pa-github-assets.s3.amazonaws.com/PARGON_logo_digital_COL-small.jpg)
-Oh My Zsh was started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a [Ruby on Rails development agency](https://www.planetargon.com/skills/ruby-on-rails-development?utm_source=github). Check out our [other open source projects](https://www.planetargon.com/open-source?utm_source=github).
+Oh My Zsh was started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a [Ruby on Rails development agency](http://www.planetargon.com/services/ruby-on-rails-development?utm_source=github). Check out our [other open source projects](https://www.planetargon.com/open-source?utm_source=github).
diff --git a/lib/completion.zsh b/lib/completion.zsh
index 2c5695487..63379b53f 100644
--- a/lib/completion.zsh
+++ b/lib/completion.zsh
@@ -18,9 +18,9 @@ if [[ "$CASE_SENSITIVE" = true ]]; then
zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*'
else
if [[ "$HYPHEN_INSENSITIVE" = true ]]; then
- zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*'
+ zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]-_}={[:upper:][:lower:]_-}' 'r:|=*' 'l:|=* r:|=*'
else
- zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
+ zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|=*' 'l:|=* r:|=*'
fi
fi
unset CASE_SENSITIVE HYPHEN_INSENSITIVE
diff --git a/lib/correction.zsh b/lib/correction.zsh
index 4259d3418..ba9664fcb 100644
--- a/lib/correction.zsh
+++ b/lib/correction.zsh
@@ -1,13 +1,8 @@
if [[ "$ENABLE_CORRECTION" == "true" ]]; then
alias cp='nocorrect cp'
- alias ebuild='nocorrect ebuild'
- alias gist='nocorrect gist'
- alias heroku='nocorrect heroku'
- alias hpodder='nocorrect hpodder'
alias man='nocorrect man'
alias mkdir='nocorrect mkdir'
alias mv='nocorrect mv'
- alias mysql='nocorrect mysql'
alias sudo='nocorrect sudo'
alias su='nocorrect su'
diff --git a/lib/directories.zsh b/lib/directories.zsh
index c62f56468..13b680c19 100644
--- a/lib/directories.zsh
+++ b/lib/directories.zsh
@@ -1,8 +1,16 @@
# Changing/making/removing directory
+setopt auto_cd
setopt auto_pushd
setopt pushd_ignore_dups
setopt pushdminus
+# add (uncommented):
+# zstyle ':omz:directories' aliases no
+# to your `zshrc` before loading `oh-my-zsh.sh`
+# to disable the following aliases and functions
+
+zstyle -T ':omz:directories' aliases || return 0
+
alias -g ...='../..'
alias -g ....='../../..'
alias -g .....='../../../..'
diff --git a/lib/functions.zsh b/lib/functions.zsh
index dfcc4d961..1d85ea38a 100644
--- a/lib/functions.zsh
+++ b/lib/functions.zsh
@@ -30,6 +30,13 @@ function open_command() {
;;
esac
+ # If a URL is passed, $BROWSER might be set to a local browser within SSH.
+ # See https://github.com/ohmyzsh/ohmyzsh/issues/11098
+ if [[ -n "$BROWSER" && "$1" = (http|https)://* ]]; then
+ "$BROWSER" "$@"
+ return
+ fi
+
${=open_cmd} "$@" &>/dev/null
}
@@ -56,7 +63,7 @@ function takegit() {
}
function take() {
- if [[ $1 =~ ^(https?|ftp).*\.tar\.(gz|bz2|xz)$ ]]; then
+ if [[ $1 =~ ^(https?|ftp).*\.(tar\.(gz|bz2|xz)|tgz)$ ]]; then
takeurl "$1"
elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then
takegit "$1"
diff --git a/lib/misc.zsh b/lib/misc.zsh
index 1f637083a..132f33551 100644
--- a/lib/misc.zsh
+++ b/lib/misc.zsh
@@ -15,8 +15,9 @@ if [[ $DISABLE_MAGIC_FUNCTIONS != true ]]; then
done
fi
-## jobs
-setopt long_list_jobs
+setopt multios # enable redirect to multiple streams: echo >file1 >file2
+setopt long_list_jobs # show long list format job notifications
+setopt interactivecomments # recognize comments
env_default 'PAGER' 'less'
env_default 'LESS' '-R'
@@ -30,6 +31,3 @@ if (( $+commands[ack-grep] )); then
elif (( $+commands[ack] )); then
alias afind='ack -il'
fi
-
-# recognize comments
-setopt interactivecomments
diff --git a/lib/prompt_info_functions.zsh b/lib/prompt_info_functions.zsh
index e5535848b..3dc9b6d10 100644
--- a/lib/prompt_info_functions.zsh
+++ b/lib/prompt_info_functions.zsh
@@ -18,6 +18,7 @@ function chruby_prompt_info \
vi_mode_prompt_info \
virtualenv_prompt_info \
jenv_prompt_info \
+ azure_prompt_info \
tf_prompt_info \
{
return 1
diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh
index 00947f72d..d8859b04c 100644
--- a/lib/theme-and-appearance.zsh
+++ b/lib/theme-and-appearance.zsh
@@ -1,59 +1,83 @@
-# ls colors
+# Sets color variable such as $fg, $bg, $color and $reset_color
autoload -U colors && colors
-# Enable ls colors
-export LSCOLORS="Gxfxcxdxbxegedabagacad"
-
-# TODO organise this chaotic logic
+# Expand variables and commands in PROMPT variables
+setopt prompt_subst
-if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
- # Find the option for using colors in ls, depending on the version
- if [[ "$OSTYPE" == 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 && alias ls='gls --color=tty'
- elif [[ "$OSTYPE" == 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 && alias ls='gls --color=tty'
- colorls -G -d . &>/dev/null && alias ls='colorls -G'
- elif [[ "$OSTYPE" == (darwin|freebsd)* ]]; then
- # this is a good alias, it works by default just using $LSCOLORS
- ls -G . &>/dev/null && alias ls='ls -G'
-
- # only use coreutils ls if there is a dircolors customization present ($LS_COLORS or .dircolors file)
- # otherwise, gls will use the default color scheme which is ugly af
- [[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] && gls --color -d . &>/dev/null && alias ls='gls --color=tty'
- else
- # 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
+# Prompt function theming defaults
+ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Beginning of the git prompt, before the branch name
+ZSH_THEME_GIT_PROMPT_SUFFIX=")" # End of the git 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
+ZSH_THEME_RUBY_PROMPT_PREFIX="("
+ZSH_THEME_RUBY_PROMPT_SUFFIX=")"
- ls --color -d . &>/dev/null && alias ls='ls --color=tty' || { ls -G . &>/dev/null && alias ls='ls -G' }
- # Take advantage of $LS_COLORS for completion as well.
- zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
- fi
+# Use diff --color if available
+if command diff --color /dev/null{,} &>/dev/null; then
+ function diff {
+ command diff --color "$@"
+ }
fi
-# enable diff color if possible.
-if command diff --color /dev/null /dev/null &>/dev/null; then
- alias diff='diff --color'
-fi
-setopt auto_cd
-setopt multios
-setopt prompt_subst
+# Don't set ls coloring if disabled
+[[ "$DISABLE_LS_COLORS" != true ]] || return 0
-[[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO=""
+function test-ls-args {
+ local cmd="$1" # ls, gls, colorls, ...
+ local args="${@[2,-1]}" # arguments except the first one
+ command "$cmd" "$args" /dev/null &>/dev/null
+}
-# git theming default: Variables for theming the git info prompt
-ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of the prompt, before the branch name
-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
-ZSH_THEME_RUBY_PROMPT_PREFIX="("
-ZSH_THEME_RUBY_PROMPT_SUFFIX=")"
+# Find the option for using colors in ls, depending on the version
+case "$OSTYPE" in
+ netbsd*)
+ # 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
+ test-ls-args gls --color && alias ls='gls --color=tty'
+ ;;
+ openbsd*)
+ # 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 (which might be installed for ), so prefer it to `gls`.
+ test-ls-args gls --color && alias ls='gls --color=tty'
+ test-ls-args colorls -G && alias ls='colorls -G'
+ ;;
+ (darwin|freebsd)*)
+ # This alias works by default just using $LSCOLORS
+ test-ls-args ls -G && alias ls='ls -G'
+ # Only use GNU ls if installed and there are user defaults for $LS_COLORS,
+ # as the default coloring scheme is not very pretty
+ [[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] \
+ && test-ls-args gls --color \
+ && alias ls='gls --color=tty'
+ ;;
+ *)
+ if test-ls-args ls --color; then
+ alias ls='ls --color=tty'
+ elif test-ls-args ls -G; then
+ alias ls='ls -G'
+ fi
+ ;;
+esac
+
+unfunction test-ls-args
+
+
+# Default coloring for BSD-based ls
+export LSCOLORS="Gxfxcxdxbxegedabagacad"
+
+# Default coloring for GNU-based ls
+if [[ -z "$LS_COLORS" ]]; then
+ # Define LS_COLORS via dircolors if available. Otherwise, set a default
+ # equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
+ if (( $+commands[dircolors] )); then
+ [[ -f "$HOME/.dircolors" ]] \
+ && source <(dircolors -b "$HOME/.dircolors") \
+ || source <(dircolors -b)
+ else
+ export LS_COLORS="di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"
+ fi
+fi
diff --git a/lib/vcs_info.zsh b/lib/vcs_info.zsh
index e60938c14..be6d32ee9 100644
--- a/lib/vcs_info.zsh
+++ b/lib/vcs_info.zsh
@@ -38,7 +38,7 @@
# due to malicious input as a consequence of CVE-2021-45444, which affects
# zsh versions from 5.0.3 to 5.8.
#
-autoload -Uz +X regexp-replace VCS_INFO_formats 2>/dev/null || return
+autoload -Uz +X regexp-replace VCS_INFO_formats 2>/dev/null || return 0
# We use $tmp here because it's already a local variable in VCS_INFO_formats
typeset PATCH='for tmp (base base-name branch misc revision subdir) hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"'
diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
index e94c2f417..363cfca8b 100644
--- a/oh-my-zsh.sh
+++ b/oh-my-zsh.sh
@@ -57,9 +57,7 @@ mkdir -p "$ZSH_CACHE_DIR/completions"
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
# Check for updates on initial load...
-if [[ "$DISABLE_AUTO_UPDATE" != true ]]; then
- source "$ZSH/tools/check_for_upgrade.sh"
-fi
+source "$ZSH/tools/check_for_upgrade.sh"
# Initializes Oh My Zsh
@@ -191,3 +189,6 @@ if [[ -n "$ZSH_THEME" ]]; then
echo "[oh-my-zsh] theme '$ZSH_THEME' not found"
fi
fi
+
+# set completion colors to be the same as `ls`, after theme has been loaded
+[[ -z "$LS_COLORS" ]] || zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
diff --git a/plugins/aliases/README.md b/plugins/aliases/README.md
index 4e77f67b3..6a2da3d74 100644
--- a/plugins/aliases/README.md
+++ b/plugins/aliases/README.md
@@ -19,7 +19,7 @@ Requirements: Python needs to be installed.
- `acs -h/--help`: print help mesage
-- `acs <keyword>`: filter aliases by `<keyword>` and highlight
+- `acs <keyword(s)>`: filter and highlight aliases by `<keyword>`
- `acs -g <group>/--group <group>`: show only aliases for group `<group>`. Multiple uses of the flag show all groups
diff --git a/plugins/aliases/cheatsheet.py b/plugins/aliases/cheatsheet.py
index 3362a6ab6..f742fba9e 100644
--- a/plugins/aliases/cheatsheet.py
+++ b/plugins/aliases/cheatsheet.py
@@ -15,6 +15,7 @@ def parse(line):
def cheatsheet(lines):
exps = [ parse(line) for line in lines ]
+ exps.sort(key=lambda exp:exp[2])
cheatsheet = {'_default': []}
for key, group in itertools.groupby(exps, lambda exp:exp[2]):
group_list = [ item for item in group ]
@@ -56,8 +57,8 @@ def pretty_print(cheatsheet, wfilter, group_list=None, groups_only=False):
pretty_print_group(key, [ alias for alias in aliases if alias[0].find(wfilter)>-1 or alias[1].find(wfilter)>-1], wfilter)
if __name__ == '__main__':
- parser = argparse.ArgumentParser(description="Pretty print aliases.")
- parser.add_argument('filter', nargs="*", help="search aliases matching string")
+ parser = argparse.ArgumentParser(description="Pretty print aliases.", prog="acs")
+ parser.add_argument('filter', nargs="*", metavar="<keyword>", help="search aliases matching keywords")
parser.add_argument('-g', '--group', dest="group_list", action='append', help="only print aliases in given groups")
parser.add_argument('--groups', dest='groups_only', action='store_true', help="only print alias groups")
args = parser.parse_args()
diff --git a/plugins/argocd/README.md b/plugins/argocd/README.md
new file mode 100644
index 000000000..0f900ff22
--- /dev/null
+++ b/plugins/argocd/README.md
@@ -0,0 +1,20 @@
+# Argo CD plugin
+
+This plugin adds completion for the [Argo CD](https://argoproj.github.io/cd/) CLI.
+
+To use it, add `argocd` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... argocd)
+```
+
+This plugin does not add any aliases.
+
+## Cache
+
+This plugin caches the completion script and is automatically updated asynchronously when the plugin is
+loaded, which is usually when you start up a new terminal emulator.
+
+The cache is stored at:
+
+- `$ZSH_CACHE/completions/_argocd` completions script
diff --git a/plugins/argocd/argocd.plugin.zsh b/plugins/argocd/argocd.plugin.zsh
new file mode 100644
index 000000000..8de7b0238
--- /dev/null
+++ b/plugins/argocd/argocd.plugin.zsh
@@ -0,0 +1,14 @@
+# Autocompletion for argocd.
+if (( ! $+commands[argocd] )); then
+ return
+fi
+
+# If the completion file doesn't exist yet, we need to autoload it and
+# bind it to `argocd`. Otherwise, compinit will have already done that.
+if [[ ! -f "$ZSH_CACHE_DIR/completions/_argocd" ]]; then
+ typeset -g -A _comps
+ autoload -Uz _argocd
+ _comps[argocd]=_argocd
+fi
+
+argocd completion zsh >| "$ZSH_CACHE_DIR/completions/_argocd" &|
diff --git a/plugins/aws/README.md b/plugins/aws/README.md
index d6f4f4600..e1e355741 100644
--- a/plugins/aws/README.md
+++ b/plugins/aws/README.md
@@ -1,7 +1,7 @@
# aws
This plugin provides completion support for [awscli](https://docs.aws.amazon.com/cli/latest/reference/index.html)
-and a few utilities to manage AWS profiles and display them in the prompt.
+and a few utilities to manage AWS profiles/regions and display them in the prompt.
To use it, add `aws` to the plugins array in your zshrc file.
@@ -16,6 +16,9 @@ plugins=(... aws)
Run `asp` without arguments to clear the profile.
* `asp [<profile>] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection.
+* `asr [<region>]`: sets `$AWS_REGION` and `$AWS_DEFAULT_REGION` (legacy) to `<region>`.
+ Run `asr` without arguments to clear the profile.
+
* `acp [<profile>] [<mfa_token>]`: in addition to `asp` functionality, it actually changes
the profile by assuming the role specified in the `<profile>` configuration. It supports
MFA and sets `$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if
@@ -25,25 +28,34 @@ plugins=(... aws)
* `agp`: gets the current value of `$AWS_PROFILE`.
+* `agr`: gets the current value of `$AWS_REGION`.
+
* `aws_change_access_key`: changes the AWS access key of a profile.
* `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`).
Used to provide completion for the `asp` function.
+* `aws_regions`: lists the available regions.
+ Used to provide completion for the `asr` function.
+
## Plugin options
* Set `SHOW_AWS_PROMPT=false` in your zshrc file if you want to prevent the plugin from modifying your RPROMPT.
Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to
- see the AWS profile prompt.
+ see the AWS profile/region prompt.
## Theme
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
-the current `$AWS_PROFILE`. It uses two variables to control how that is shown:
+the current `$AWS_PROFILE` and `$AWS_REGION`. It uses four variables to control how that is shown:
+
+* ZSH_THEME_AWS_PROFILE_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
+
+* ZSH_THEME_AWS_PROFILE_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
-* ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
+* ZSH_THEME_AWS_REGION_PREFIX: sets the prefix of the AWS_REGION. Defaults to `<region:`.
-* ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
+* ZSH_THEME_AWS_REGION_SUFFIX: sets the suffix of the AWS_REGION. Defaults to `>`.
## Configuration
diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh
index 865e82f19..1c386a3e1 100644
--- a/plugins/aws/aws.plugin.zsh
+++ b/plugins/aws/aws.plugin.zsh
@@ -2,6 +2,10 @@ function agp() {
echo $AWS_PROFILE
}
+function agr() {
+ echo $AWS_REGION
+}
+
# AWS profile selection
function asp() {
if [[ -z "$1" ]]; then
@@ -27,6 +31,25 @@ function asp() {
fi
}
+# AWS region selection
+function asr() {
+ if [[ -z "$1" ]]; then
+ unset AWS_DEFAULT_REGION AWS_REGION
+ echo AWS region cleared.
+ return
+ fi
+
+ local -a available_regions
+ available_regions=($(aws_regions))
+ if [[ -z "${available_regions[(r)$1]}" ]]; then
+ echo "${fg[red]}Available regions: \n$(aws_regions)"
+ return 1
+ fi
+
+ export AWS_REGION=$1
+ export AWS_DEFAULT_REGION=$1
+}
+
# AWS profile switch
function acp() {
if [[ -z "$1" ]]; then
@@ -145,12 +168,25 @@ function aws_change_access_key() {
AWS_PAGER="" aws iam list-access-keys
}
+function aws_regions() {
+ if [[ $AWS_DEFAULT_PROFILE || $AWS_PROFILE ]];then
+ aws ec2 describe-regions |grep RegionName | awk -F ':' '{gsub(/"/, "", $2);gsub(/,/, "", $2);gsub(/ /, "", $2); print $2}'
+ else
+ echo "You must specify a AWS profile."
+ fi
+}
+
function aws_profiles() {
aws --no-cli-pager configure list-profiles 2> /dev/null && return
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([^[:space:]]+)\][[:space:]]*$/\2/g'
}
+function _aws_regions() {
+ reply=($(aws_regions))
+}
+compctl -K _aws_regions asr
+
function _aws_profiles() {
reply=($(aws_profiles))
}
@@ -158,8 +194,8 @@ compctl -K _aws_profiles asp acp aws_change_access_key
# AWS prompt
function aws_prompt_info() {
- [[ -n "$AWS_PROFILE" ]] || return
- echo "${ZSH_THEME_AWS_PREFIX=<aws:}${AWS_PROFILE:gs/%/%%}${ZSH_THEME_AWS_SUFFIX=>}"
+ if [[ -z $AWS_REGION && -z $AWS_PROFILE ]];then return; fi
+ echo "${ZSH_THEME_AWS_PROFILE_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_PROFILE_SUFFIX:=>} ${ZSH_THEME_AWS_REGION_PREFIX:=<region:}${AWS_REGION}${ZSH_THEME_AWS_REGION_SUFFIX:=>}"
}
if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then
@@ -211,3 +247,4 @@ else
[[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path
unset _aws_zsh_completer_path _brew_prefix
fi
+
diff --git a/plugins/azure/README.md b/plugins/azure/README.md
new file mode 100644
index 000000000..f39930851
--- /dev/null
+++ b/plugins/azure/README.md
@@ -0,0 +1,49 @@
+# azure
+
+This plugin provides completion support for [azure cli](https://docs.microsoft.com/en-us/cli/azure/)
+and a few utilities to manage azure subscriptions and display them in the prompt.
+
+To use it, add `azure` to the plugins array in your zshrc file.
+
+```zsh
+plugins=(... azure)
+```
+
+## Plugin commands
+
+
+* `az_subscriptions`: lists the available subscriptions in the `AZURE_CONFIG_DIR` (default: `~/.azure/`).
+ Used to provide completion for the `azss` function.
+
+* `azgs`: gets the current value of `$azure_subscription`.
+
+* `azss [<subscription>]`: sets the `$azure_subscription`.
+
+
+NOTE : because azure keeps the state of active subscription in ${AZURE_CONFIG_DIR:-$HOME/.azure/azureProfile.json}, the prompt command requires `jq` to be enabled to parse the file. If jq is not in the path the prompt will show nothing
+
+## Theme
+
+The plugin creates an `azure_prompt_info` function that you can use in your theme, which displays
+the current `$azure_subscription`. It uses two variables to control how that is shown:
+
+- ZSH_THEME_AZURE_PREFIX: sets the prefix of the azure_subscription. Defaults to `<az:`.
+
+- ZSH_THEME_azure_SUFFIX: sets the suffix of the azure_subscription. Defaults to `>`.
+
+
+```
+RPROMPT='$(azure_prompt_info)'
+```
+
+## Develop
+
+On ubuntu get a working environment with :
+
+` docker run -it -v $(pwd):/mnt -w /mnt ubuntu bash`
+
+```
+apt install -y curl jq zsh git vim
+sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
+curl -sL https://aka.ms/InstallAzureCLIDeb | bash
+``` \ No newline at end of file
diff --git a/plugins/azure/azure.plugin.zsh b/plugins/azure/azure.plugin.zsh
new file mode 100644
index 000000000..51b54dbc1
--- /dev/null
+++ b/plugins/azure/azure.plugin.zsh
@@ -0,0 +1,62 @@
+# AZ Get Subscritions
+function azgs() {
+ az account show --output tsv --query 'name' 2>/dev/null
+}
+
+# AZ Subscription Selection
+alias azss="az account set --subscription"
+
+
+function az_subscriptions() {
+ az account list --all --output tsv --query '[*].name' 2> /dev/null
+}
+
+function _az_subscriptions() {
+ reply=($(az_subscriptions))
+}
+compctl -K _az_subscriptions azss
+
+# Azure prompt
+function azure_prompt_info() {
+ [[ ! -f "${AZURE_CONFIG_DIR:-$HOME/.azure/azureProfile.json}" ]] && return
+ # azgs is too expensive, if we have jq, we enable the prompt
+ (( $+commands[jq] )) || return 1
+ azgs=$(jq -r '.subscriptions[] | select(.isDefault==true) .name' ${AZURE_CONFIG_DIR:-$HOME/.azure/azureProfile.json})
+ echo "${ZSH_THEME_AZURE_PREFIX:=<az:}${azgs}${ZSH_THEME_AZURE_SUFFIX:=>}"
+}
+
+
+# Load az completions
+function _az-homebrew-installed() {
+ # check if Homebrew is installed
+ (( $+commands[brew] )) || return 1
+
+ # speculatively check default brew prefix
+ if [[ -d /usr/local ]]; then
+ _brew_prefix=/usr/local
+ elif [[ -d /opt/homebrew ]]; then
+ _brew_prefix=/opt/homebrew
+ else
+ # ok, it is not in the default prefix
+ # this call to brew is expensive (about 400 ms), so at least let's make it only once
+ _brew_prefix=$(brew --prefix)
+ fi
+}
+
+
+# get az.completion.sh location from $PATH
+_az_zsh_completer_path="$commands[az_zsh_completer.sh]"
+
+# otherwise check common locations
+if [[ -z $_az_zsh_completer_path ]]; then
+ # Homebrew
+ if _az-homebrew-installed; then
+ _az_zsh_completer_path=$_brew_prefix/etc/bash_completion.d/az
+ # Linux
+ else
+ _az_zsh_completer_path=/etc/bash_completion.d/azure-cli
+ fi
+fi
+
+[[ -r $_az_zsh_completer_path ]] && autoload -U +X bashcompinit && bashcompinit && source $_az_zsh_completer_path
+unset _az_zsh_completer_path _brew_prefix
diff --git a/plugins/brew/README.md b/plugins/brew/README.md
index 4a42b3d74..412daae63 100644
--- a/plugins/brew/README.md
+++ b/plugins/brew/README.md
@@ -17,20 +17,19 @@ defined for convenience.
## Aliases
-| Alias | Command | Description |
-| -------- | ------------------------------------- | ------------------------------------------------------------------- |
-| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. |
-| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. |
-| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. |
-| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
-| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
-| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
-| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. |
-| `bugbc` | `brew upgrade --greedy && brew cleanup` | Upgrade outdated formulae and casks (greedy), then run cleanup. |
-| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
-| `bubu` | `bubo && bubc` | Do the last two operations above. |
-| `buf` | `brew upgrade --formula` | Upgrade only formulas (not casks). |
-| `buz` | `brew uninstall --zap` | Remove all files associated with a cask. |
+| Alias | Command | Description |
+| -------- | --------------------------------------- | ------------------------------------------------------------------- |
+| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. |
+| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. |
+| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
+| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
+| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
+| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. |
+| `bugbc` | `brew upgrade --greedy && brew cleanup` | Upgrade outdated formulae and casks (greedy), then run cleanup. |
+| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
+| `bubu` | `bubo && bubc` | Do the last two operations above. |
+| `bfu` | `brew upgrade --formula` | Upgrade only formulas (not casks). |
+| `buz` | `brew uninstall --zap` | Remove all files associated with a cask. |
## Completion
diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh
index 8275454a4..f6abe0875 100644
--- a/plugins/brew/brew.plugin.zsh
+++ b/plugins/brew/brew.plugin.zsh
@@ -35,7 +35,7 @@ alias bugbc='brew upgrade --greedy && brew cleanup'
alias bubo='brew update && brew outdated'
alias bubu='bubo && bubc'
alias bubug='bubo && bugbc'
-alias buf='brew upgrade --formula'
+alias bfu='brew upgrade --formula'
alias buz='brew uninstall --zap'
function brews() {
diff --git a/plugins/dotnet/README.md b/plugins/dotnet/README.md
index 87dfd8f8d..a15e80577 100644
--- a/plugins/dotnet/README.md
+++ b/plugins/dotnet/README.md
@@ -17,6 +17,7 @@ plugins=(... dotnet)
| dt | dotnet test | Run unit tests using the test runner specified in a .NET project. |
| dw | dotnet watch | Watch for source file changes and restart the dotnet command. |
| dwr | dotnet watch run | Watch for source file changes and restart the `run` command. |
+| dwt | dotnet watch test| Watch for source file changes and restart the `test` command. |
| ds | dotnet sln | Modify Visual Studio solution files. |
| da | dotnet add | Add a package or reference to a .NET project. |
| dp | dotnet pack | Create a NuGet package. |
diff --git a/plugins/dotnet/dotnet.plugin.zsh b/plugins/dotnet/dotnet.plugin.zsh
index 8ea31cdbd..89d464670 100644
--- a/plugins/dotnet/dotnet.plugin.zsh
+++ b/plugins/dotnet/dotnet.plugin.zsh
@@ -26,6 +26,7 @@ alias dr='dotnet run'
alias dt='dotnet test'
alias dw='dotnet watch'
alias dwr='dotnet watch run'
+alias dwt='dotnet watch test'
alias ds='dotnet sln'
alias da='dotnet add'
alias dp='dotnet pack'
diff --git a/plugins/extract/README.md b/plugins/extract/README.md
index 44f0b05a1..ac4a8e197 100644
--- a/plugins/extract/README.md
+++ b/plugins/extract/README.md
@@ -1,10 +1,10 @@
# 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 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.
+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:
@@ -15,7 +15,7 @@ plugins=(... extract)
## Supported file extensions
| Extension | Description |
-|:------------------|:-------------------------------------|
+| :---------------- | :----------------------------------- |
| `7z` | 7zip file |
| `Z` | Z archive (LZW) |
| `apk` | Android app file |
@@ -32,6 +32,7 @@ plugins=(... extract)
| `lrz` | LRZ archive |
| `lz4` | LZ4 archive |
| `lzma` | LZMA archive |
+| `obscpio` | cpio archive used on OBS |
| `rar` | WinRAR archive |
| `rpm` | RPM package |
| `sublime-package` | Sublime Text package |
@@ -55,6 +56,7 @@ plugins=(... extract)
| `xz` | LZMA2 archive |
| `zip` | Zip archive |
| `zst` | Zstandard file (zstd) |
+| `zpaq` | Zpaq file |
-See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for
-more information regarding archive formats.
+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 27b099c9e..56b17058f 100644
--- a/plugins/extract/_extract
+++ b/plugins/extract/_extract
@@ -3,5 +3,5 @@
_arguments \
'(-r --remove)'{-r,--remove}'[Remove archive.]' \
- "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \
+ "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|obscpio|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst|zpaq)(-.)'" \
&& return 0
diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh
index 563d88c72..7b7a2fa4f 100644
--- a/plugins/extract/extract.plugin.zsh
+++ b/plugins/extract/extract.plugin.zsh
@@ -72,7 +72,8 @@ EOF
builtin cd -q ..; command rm *.tar.* debian-binary ;;
(*.zst) unzstd "$file" ;;
(*.cab) cabextract -d "$extract_dir" "$file" ;;
- (*.cpio) cpio -idmvF "$file" ;;
+ (*.cpio|*.obscpio) cpio -idmvF "$file" ;;
+ (*.zpaq) zpaq x "$file" ;;
(*)
echo "extract: '$file' cannot be extracted" >&2
success=1 ;;
diff --git a/plugins/fasd/README.md b/plugins/fasd/README.md
index a5c74e5b8..7c44ac84d 100644
--- a/plugins/fasd/README.md
+++ b/plugins/fasd/README.md
@@ -10,7 +10,7 @@ plugins=(... fasd)
## Installation
-Please find detailed installation guide [`here`](https://github.com/clvv/fasd#install)
+Please find detailed installation guide [`here`](https://github.com/whjvenyl/fasd#install)
## Aliases
diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh
index 9c8dd8648..b253a23d2 100644
--- a/plugins/fzf/fzf.plugin.zsh
+++ b/plugins/fzf/fzf.plugin.zsh
@@ -9,7 +9,7 @@ function fzf_setup_using_base_dir() {
"${HOME}/.nix-profile/share/fzf"
"${XDG_DATA_HOME:-$HOME/.local/share}/fzf"
"/usr/local/opt/fzf"
- "/opt/homebrew/bin/fzf"
+ "/opt/homebrew/opt/fzf"
"/usr/share/fzf"
"/usr/local/share/examples/fzf"
)
@@ -60,8 +60,8 @@ function fzf_setup_using_base_dir() {
function fzf_setup_using_debian() {
- if (( ! $+commands[dpkg] )) || ! dpkg -s fzf &>/dev/null; then
- # Either not a debian based distro, or no fzf installed
+ if (( ! $+commands[apt] && ! $+commands[apt-get] )); then
+ # Not a debian based distro
return 1
fi
@@ -72,11 +72,19 @@ function fzf_setup_using_debian() {
case $PREFIX in
*com.termux*)
+ if [[ ! -f "${PREFIX}/bin/fzf" ]]; then
+ # fzf not installed
+ return 1
+ fi
# Support Termux package
completions="${PREFIX}/share/fzf/completion.zsh"
key_bindings="${PREFIX}/share/fzf/key-bindings.zsh"
;;
*)
+ if [[ ! -d /usr/share/doc/fzf/examples ]]; then
+ # fzf not installed
+ return 1
+ fi
# Determine completion file path: first bullseye/sid, then buster/stretch
completions="/usr/share/doc/fzf/examples/completion.zsh"
[[ -f "$completions" ]] || completions="/usr/share/zsh/vendor-completions/_fzf"
diff --git a/plugins/gcloud/gcloud.plugin.zsh b/plugins/gcloud/gcloud.plugin.zsh
index 9be9d68aa..30f1dba8f 100644
--- a/plugins/gcloud/gcloud.plugin.zsh
+++ b/plugins/gcloud/gcloud.plugin.zsh
@@ -10,6 +10,7 @@ if [[ -z "${CLOUDSDK_HOME}" ]]; then
"/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
"/usr/share/google-cloud-sdk"
"/snap/google-cloud-sdk/current"
+ "/snap/google-cloud-cli/current"
"/usr/lib/google-cloud-sdk"
"/usr/lib64/google-cloud-sdk"
"/opt/google-cloud-sdk"
diff --git a/plugins/git/README.md b/plugins/git/README.md
index d455e0eff..0895ce39c 100644
--- a/plugins/git/README.md
+++ b/plugins/git/README.md
@@ -25,6 +25,9 @@ plugins=(... git)
| gbd | git branch --delete |
| gbda | git branch --no-color --merged \| grep -vE "^([+*]\|\s*(<span>$</span>(git_main_branch)\|<span>$</span>(git_develop_branch))\s*<span>$</span>)" \| xargs git branch --delete 2>/dev/null |
| gbD | git branch --delete --force |
+| gbg | git branch -vv | grep ": gone\]" |
+| gbgd | local res=$(git branch -vv | grep ": gone\]" | awk '{print $1}') && [[ $res ]] && echo $res | xargs git branch -d |
+| gbgD | local res=$(git branch -vv | grep ": gone\]" | awk '{print $1}') && [[ $res ]] && echo $res | xargs git branch -D |
| gbl | git blame -b -w |
| gbnm | git branch --no-merged |
| gbr | git branch --remote |
@@ -89,6 +92,8 @@ plugins=(... git)
| ggsup | git branch --set-upstream-to=origin/$(git_current_branch) |
| ggu | git pull --rebase origin $(current_branch) |
| gpsup | git push --set-upstream origin $(git_current_branch) |
+| gpsupf | git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes (git version >= 2.30) |
+| gpsupf | git push --set-upstream origin $(git_current_branch) --force-with-lease (git version < 2.30) |
| ghh | git help |
| gignore | git update-index --assume-unchanged |
| gignored | git ls-files -v \| grep "^[[:lower:]]" |
@@ -118,9 +123,11 @@ plugins=(... git)
| gma | git merge --abort |
| gp | git push |
| gpd | git push --dry-run |
-| gpf | git push --force-with-lease |
+| gpf | git push --force-with-lease --force-if-includes (git version >= 2.30) |
+| gpf | git push --force-with-lease (git version < 2.30) |
| gpf! | git push --force |
| gpoat | git push origin --all && git push origin --tags |
+| gpod | git push origin --delete |
| gpr | git pull --rebase |
| gpu | git push upstream |
| gpv | git push --verbose |
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
index 7544ca440..ed17436e8 100644
--- a/plugins/git/git.plugin.zsh
+++ b/plugins/git/git.plugin.zsh
@@ -73,6 +73,9 @@ alias gba='git branch --all'
alias gbd='git branch --delete'
alias gbda='git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null'
alias gbD='git branch --delete --force'
+alias gbg='git branch -vv | grep ": gone\]"'
+alias gbgd='local res=$(gbg | awk '"'"'{print $1}'"'"') && [[ $res ]] && echo $res | xargs git branch -d'
+alias gbgD='local res=$(gbg | awk '"'"'{print $1}'"'"') && [[ $res ]] && echo $res | xargs git branch -D'
alias gbl='git blame -b -w'
alias gbnm='git branch --no-merged'
alias gbr='git branch --remote'
@@ -104,7 +107,7 @@ compdef _git gccd=git-clone
alias gcl='git clone --recurse-submodules'
alias gclean='git clean --interactive -d'
-alias gpristine='git reset --hard && git clean --force -dx'
+alias gpristine='git reset --hard && git clean --force -dfx'
alias gcm='git checkout $(git_main_branch)'
alias gcd='git checkout $(git_develop_branch)'
alias gcmsg='git commit --message'
@@ -199,6 +202,9 @@ alias ggpush='git push origin "$(git_current_branch)"'
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
alias gpsup='git push --set-upstream origin $(git_current_branch)'
+is-at-least 2.30 "$git_version" \
+ && alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes' \
+ || alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease'
alias ghh='git help'
@@ -234,9 +240,12 @@ alias gma='git merge --abort'
alias gp='git push'
alias gpd='git push --dry-run'
-alias gpf='git push --force-with-lease'
+is-at-least 2.30 "$git_version" \
+ && alias gpf='git push --force-with-lease --force-if-includes' \
+ || alias gpf='git push --force-with-lease'
alias gpf!='git push --force'
alias gpoat='git push origin --all && git push origin --tags'
+alias gpod='git push origin --delete'
alias gpr='git pull --rebase'
alias gpu='git push upstream'
alias gpv='git push --verbose'
@@ -341,4 +350,4 @@ function grename() {
fi
}
-unset git_version \ No newline at end of file
+unset git_version
diff --git a/plugins/gnu-utils/gnu-utils.plugin.zsh b/plugins/gnu-utils/gnu-utils.plugin.zsh
index 9419127d8..6bd3e8463 100644
--- a/plugins/gnu-utils/gnu-utils.plugin.zsh
+++ b/plugins/gnu-utils/gnu-utils.plugin.zsh
@@ -61,3 +61,14 @@ __gnu_utils_preexec() {
autoload -Uz add-zsh-hook
add-zsh-hook preexec __gnu_utils_preexec
+
+# lib/theme-and-appearance.zsh sets the alias for ls not knowing that
+# we'll be using GNU ls. We'll reset this to use GNU ls --color.
+# See https://github.com/ohmyzsh/ohmyzsh/issues/11503
+#
+# The ls alias might look like:
+# - ls='ls -G'
+# - ls='gls --color=tty'
+if [[ -x "${commands[gls]}" && "${aliases[ls]}" = (*-G*|gls*) ]]; then
+ alias ls='ls --color=tty'
+fi
diff --git a/plugins/gradle/_gradle b/plugins/gradle/_gradle
index 770723d85..f8df928b4 100644
--- a/plugins/gradle/_gradle
+++ b/plugins/gradle/_gradle
@@ -1,4 +1,6 @@
#compdef gradle gradlew gw
+# THE LINE ABOVE MUST BE THE FIRST LINE OF THIS FILE IN ORDER FOR COMPLETION TO WORK
+
#
# Taken from https://github.com/gradle/gradle-completion
# Copyright (c) 2017 Eric Wendelin
@@ -96,7 +98,7 @@ __gradle-generate-script-cache() {
zle -R "Generating Gradle build script cache"
# Cache all Gradle scripts
local -a gradle_build_scripts
- gradle_build_scripts=( $(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | grep -E -v "$script_exclude_pattern") )
+ gradle_build_scripts=( $(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | egrep -v "$script_exclude_pattern") )
printf "%s\n" "${gradle_build_scripts[@]}" >| $cache_dir/$cache_name
fi
}
@@ -116,9 +118,9 @@ __gradle-generate-tasks-cache() {
# Reuse Gradle Daemon if IDLE but don't start a new one.
local gradle_tasks_output
if [[ ! -z "$($gradle_cmd --status 2>/dev/null | grep IDLE)" ]]; then
- gradle_tasks_output="$($gradle_cmd --daemon --build-file $gradle_build_file --console plain -q tasks --all 2>/dev/null)"
+ gradle_tasks_output="$($gradle_cmd --daemon --no-scan --build-file $gradle_build_file --console=plain -q tasks --all 2>/dev/null)"
else
- gradle_tasks_output="$($gradle_cmd --no-daemon --build-file $gradle_build_file --console plain -q tasks --all 2>/dev/null)"
+ gradle_tasks_output="$($gradle_cmd --no-daemon --no-scan --build-file $gradle_build_file --console=plain -q tasks --all 2>/dev/null)"
fi
local gradle_all_tasks="" root_tasks="" subproject_tasks="" output_line
local -a match
@@ -180,7 +182,7 @@ __gradle_tasks() {
local cached_checksum="$(cat $cache_dir/$cache_name.md5)"
local -a cached_tasks
if [[ -z $cur ]]; then
- cached_tasks=(${(f)"$(cat $cache_dir/$cached_checksum)"})
+ cached_tasks=(${(f)"$(grep -v "^\\\:" $cache_dir/$cached_checksum)"})
else
cached_tasks=(${(f)"$(grep "^${cur//:/\\\\:}" $cache_dir/$cached_checksum)"})
fi
@@ -191,7 +193,7 @@ __gradle_tasks() {
# Regenerate tasks cache in the background
if [[ $gradle_files_checksum != "$(cat $cache_dir/$cache_name.md5)" || ! -f $cache_dir/$gradle_files_checksum || $(wc -c < $cache_dir/$gradle_files_checksum) -le 1 ]]; then
- $(__gradle-generate-tasks-cache 1>&2 2>/dev/null &)
+ $(__gradle-generate-tasks-cache &> /dev/null &)
fi
else
_describe 'built-in tasks' '(
@@ -262,7 +264,10 @@ __gradle_subcommand() {
{-b,--build-file}'[Specifies the build file.]:build script:_files -g \*.gradle' \
{-C,--cache}'[Specifies how compiled build scripts should be cached.]:cache policy:(on rebuild)' \
{-c,--settings-file}'[Specifies the settings file.]:settings file:_files -g \*.gradle' \
+ '(--configuration-cache)--no-configuration-cache[Disables the configuration cache. Gradle will not reuse the build configuration from previous builds.]' \
+ '--configuration-cache-problems=[Configures how the configuration cache handles problems]:problem handling:(fail warn)' \
'(--no-configure-on-demand)--configure-on-demand[Only relevant projects are configured in this build run.]' \
+ '(--no-configuration-cache)--configuration-cache[Enables the configuration cache. Gradle will try to reuse the build configuration from previous builds.]' \
'--console=[Specifies which type of console output to generate.]:console output type:(plain auto rich verbose)' \
'--continue[Continues task execution after a task failure.]' \
'-Dorg.gradle.cache.reserved.mb=[Reserve Gradle Daemon memory for operations.]' \
@@ -276,6 +281,7 @@ __gradle_subcommand() {
'-Dorg.gradle.logging.level=[Set default Gradle log level.]:log level:(quiet warn lifecycle info debug)' \
'-Dorg.gradle.parallel=[Set true to enable parallel project builds.]:enable parallel build:(true false)' \
'-Dorg.gradle.priority=[Set priority for Gradle worker processes.]:priority:(low normal)' \
+ '-Dorg.gradle.unsafe.watch-fs=[Set true to enable Gradle file watcher.]:enable watcher:(true false)' \
'-Dorg.gradle.warning.mode=[Set types of warnings to log.]:warning level:(all summary none)' \
'-Dorg.gradle.workers.max=[Set the number of workers Gradle is allowed to use.]' \
'(-i --info -w --warn -q --quiet)'{-d,--debug}'[Log in debug mode (includes normal stacktrace).]' \
@@ -314,6 +320,7 @@ __gradle_subcommand() {
'(--write-locks)--update-locks[Perform a partial update of the dependency lock.]' \
'(-d --debug -q --quiet -i --info)'{-w,--warn}'[Log warnings and errors only.]' \
'--warning-mode=[Set types of warnings to log.]:warning mode:(all summary none)' \
+ '(--no-watch-fs)--watch-fs[Gradle watches filesystem for incremental builds.]' \
'(--update-locks)--write-locks[Persists dependency resolution for locked configurations.]' \
{-x,--exclude-task}'[Specify a task to be excluded from execution.]' && ret=0
;;
@@ -347,6 +354,9 @@ _gradle() {
{-b,--build-file}'[Specifies the build file.]:build script:_files -g \*.gradle' \
{-C,--cache}'[Specifies how compiled build scripts should be cached.]:cache policy:(on rebuild)' \
{-c,--settings-file}'[Specifies the settings file.]:settings file:_files -g \*.gradle:->argument-expected' \
+ '(--no-configuration-cache)--configuration-cache[Enables the configuration cache. Gradle will try to reuse the build configuration from previous builds.]' \
+ '(--configuration-cache)--no-configuration-cache[Disables the configuration cache. Gradle will not reuse the build configuration from previous builds.]' \
+ '--configuration-cache-problems=[Configures how the configuration cache handles problems]:problem handling:(fail warn)' \
'(--no-configure-on-demand)--configure-on-demand[Only relevant projects are configured in this build run.]' \
'--console=[Specifies which type of console output to generate.]:console output type:(plain auto rich verbose)' \
'--continue[Continues task execution after a task failure.]' \
@@ -361,6 +371,7 @@ _gradle() {
'-Dorg.gradle.logging.level=[Set default Gradle log level.]:log level:(quiet warn lifecycle info debug)' \
'-Dorg.gradle.parallel=[Set true to enable parallel project builds.]:(true false)' \
'-Dorg.gradle.priority=[Set priority for Gradle worker processes.]:priority:(low normal)' \
+ '-Dorg.gradle.unsafe.watch-fs=[Set true to enable Gradle file watcher.]:enable watcher:(true false)' \
'-Dorg.gradle.warning.mode=[Set types of warnings to log.]:warning level:(all summary none)' \
'-Dorg.gradle.workers.max=[Set the number of workers Gradle is allowed to use.]' \
'(-i --info -w --warn -q --quiet)'{-d,--debug}'[Log in debug mode (includes normal stacktrace).]' \
@@ -404,6 +415,7 @@ _gradle() {
'(-d --debug -q --quiet -i --info)'{-w,--warn}'[Log warnings and errors only.]' \
'--warning-mode=[Set types of warnings to log.]:warning mode:(all summary none)' \
'(--update-locks)--write-locks[Persists dependency resolution for locked configurations.]' \
+ '(--no-watch-fs)--watch-fs[Gradle watches filesystem for incremental builds.]' \
{-x,--exclude-task}'[Specify a task to be excluded from execution.]' \
'(-)*:: :->task-or-option' && ret=0
diff --git a/plugins/iterm2/README.md b/plugins/iterm2/README.md
index 50cdebf5e..3d11622df 100644
--- a/plugins/iterm2/README.md
+++ b/plugins/iterm2/README.md
@@ -2,11 +2,20 @@
This plugin adds a few functions that are useful when using [iTerm2](https://www.iterm2.com/).
+
To use it, add _iterm2_ to the plugins array of your zshrc file:
```
plugins=(... iterm2)
```
+Optionally, the plugin also applies the [Shell Integration Script for iTerm2](https://iterm2.com/documentation-shell-integration.html).
+You can enable the integration with zstyle. It's important to add this line
+before the line sourcing oh-my-zsh:
+
+```
+zstyle :omz:plugins:iterm2 shell-integration yes
+```
+
## Plugin commands
* `_iterm2_command <iterm2-command>`
@@ -24,6 +33,9 @@ plugins=(... iterm2)
* `iterm2_tab_color_reset`
resets the color of iTerm2's current tab back to default.
+
+For shell integration features see the [official documentation](https://iterm2.com/documentation-shell-integration.html).
+
## Contributors
- [Aviv Rosenberg](https://github.com/avivrosenberg)
diff --git a/plugins/iterm2/iterm2.plugin.zsh b/plugins/iterm2/iterm2.plugin.zsh
index 9d8e40bf6..d00232a30 100644
--- a/plugins/iterm2/iterm2.plugin.zsh
+++ b/plugins/iterm2/iterm2.plugin.zsh
@@ -7,6 +7,17 @@
# This plugin is only relevant if the terminal is iTerm2 on OSX.
if [[ "$OSTYPE" == darwin* ]] && [[ -n "$ITERM_SESSION_ID" ]] ; then
+ # maybe make it the default in the future and allow opting out?
+ if zstyle -t ':omz:plugins:iterm2' shell-integration; then
+ # Handle $0 according to the standard:
+ # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+ 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+ 0="${${(M)0:#/*}:-$PWD/$0}"
+
+ # See official docs: https://iterm2.com/documentation-shell-integration.html
+ source "${0:A:h}/iterm2_shell_integration.zsh"
+ fi
+
###
# Executes an arbitrary iTerm2 command via an escape code sequence.
# See https://iterm2.com/documentation-escape-codes.html for all supported commands.
diff --git a/plugins/iterm2/iterm2_shell_integration.zsh b/plugins/iterm2/iterm2_shell_integration.zsh
new file mode 100644
index 000000000..7871ddded
--- /dev/null
+++ b/plugins/iterm2/iterm2_shell_integration.zsh
@@ -0,0 +1,178 @@
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+if [[ -o interactive ]]; then
+ if [ "${ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX-}""$TERM" != "tmux-256color" -a "${ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX-}""$TERM" != "screen" -a "${ITERM_SHELL_INTEGRATION_INSTALLED-}" = "" -a "$TERM" != linux -a "$TERM" != dumb ]; then
+ ITERM_SHELL_INTEGRATION_INSTALLED=Yes
+ ITERM2_SHOULD_DECORATE_PROMPT="1"
+ # Indicates start of command output. Runs just before command executes.
+ iterm2_before_cmd_executes() {
+ if [ "$TERM_PROGRAM" = "iTerm.app" ]; then
+ printf "\033]133;C;\r\007"
+ else
+ printf "\033]133;C;\007"
+ fi
+ }
+
+ iterm2_set_user_var() {
+ printf "\033]1337;SetUserVar=%s=%s\007" "$1" $(printf "%s" "$2" | base64 | tr -d '\n')
+ }
+
+ # Users can write their own version of this method. It should call
+ # iterm2_set_user_var but not produce any other output.
+ # e.g., iterm2_set_user_var currentDirectory $PWD
+ # Accessible in iTerm2 (in a badge now, elsewhere in the future) as
+ # \(user.currentDirectory).
+ whence -v iterm2_print_user_vars > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ iterm2_print_user_vars() {
+ true
+ }
+ fi
+
+ iterm2_print_state_data() {
+ local _iterm2_hostname="${iterm2_hostname-}"
+ if [ -z "${iterm2_hostname:-}" ]; then
+ _iterm2_hostname=$(hostname -f 2>/dev/null)
+ fi
+ printf "\033]1337;RemoteHost=%s@%s\007" "$USER" "${_iterm2_hostname-}"
+ printf "\033]1337;CurrentDir=%s\007" "$PWD"
+ iterm2_print_user_vars
+ }
+
+ # Report return code of command; runs after command finishes but before prompt
+ iterm2_after_cmd_executes() {
+ printf "\033]133;D;%s\007" "$STATUS"
+ iterm2_print_state_data
+ }
+
+ # Mark start of prompt
+ iterm2_prompt_mark() {
+ printf "\033]133;A\007"
+ }
+
+ # Mark end of prompt
+ iterm2_prompt_end() {
+ printf "\033]133;B\007"
+ }
+
+ # There are three possible paths in life.
+ #
+ # 1) A command is entered at the prompt and you press return.
+ # The following steps happen:
+ # * iterm2_preexec is invoked
+ # * PS1 is set to ITERM2_PRECMD_PS1
+ # * ITERM2_SHOULD_DECORATE_PROMPT is set to 1
+ # * The command executes (possibly reading or modifying PS1)
+ # * iterm2_precmd is invoked
+ # * ITERM2_PRECMD_PS1 is set to PS1 (as modified by command execution)
+ # * PS1 gets our escape sequences added to it
+ # * zsh displays your prompt
+ # * You start entering a command
+ #
+ # 2) You press ^C while entering a command at the prompt.
+ # The following steps happen:
+ # * (iterm2_preexec is NOT invoked)
+ # * iterm2_precmd is invoked
+ # * iterm2_before_cmd_executes is called since we detected that iterm2_preexec was not run
+ # * (ITERM2_PRECMD_PS1 and PS1 are not messed with, since PS1 already has our escape
+ # sequences and ITERM2_PRECMD_PS1 already has PS1's original value)
+ # * zsh displays your prompt
+ # * You start entering a command
+ #
+ # 3) A new shell is born.
+ # * PS1 has some initial value, either zsh's default or a value set before this script is sourced.
+ # * iterm2_precmd is invoked
+ # * ITERM2_SHOULD_DECORATE_PROMPT is initialized to 1
+ # * ITERM2_PRECMD_PS1 is set to the initial value of PS1
+ # * PS1 gets our escape sequences added to it
+ # * Your prompt is shown and you may begin entering a command.
+ #
+ # Invariants:
+ # * ITERM2_SHOULD_DECORATE_PROMPT is 1 during and just after command execution, and "" while the prompt is
+ # shown and until you enter a command and press return.
+ # * PS1 does not have our escape sequences during command execution
+ # * After the command executes but before a new one begins, PS1 has escape sequences and
+ # ITERM2_PRECMD_PS1 has PS1's original value.
+ iterm2_decorate_prompt() {
+ # This should be a raw PS1 without iTerm2's stuff. It could be changed during command
+ # execution.
+ ITERM2_PRECMD_PS1="$PS1"
+ ITERM2_SHOULD_DECORATE_PROMPT=""
+
+ # Add our escape sequences just before the prompt is shown.
+ # Use ITERM2_SQUELCH_MARK for people who can't mdoify PS1 directly, like powerlevel9k users.
+ # This is gross but I had a heck of a time writing a correct if statetment for zsh 5.0.2.
+ local PREFIX=""
+ if [[ $PS1 == *"$(iterm2_prompt_mark)"* ]]; then
+ PREFIX=""
+ elif [[ "${ITERM2_SQUELCH_MARK-}" != "" ]]; then
+ PREFIX=""
+ else
+ PREFIX="%{$(iterm2_prompt_mark)%}"
+ fi
+ PS1="$PREFIX$PS1%{$(iterm2_prompt_end)%}"
+ ITERM2_DECORATED_PS1="$PS1"
+ }
+
+ iterm2_precmd() {
+ local STATUS="$?"
+ if [ -z "${ITERM2_SHOULD_DECORATE_PROMPT-}" ]; then
+ # You pressed ^C while entering a command (iterm2_preexec did not run)
+ iterm2_before_cmd_executes
+ if [ "$PS1" != "${ITERM2_DECORATED_PS1-}" ]; then
+ # PS1 changed, perhaps in another precmd. See issue 9938.
+ ITERM2_SHOULD_DECORATE_PROMPT="1"
+ fi
+ fi
+
+ iterm2_after_cmd_executes "$STATUS"
+
+ if [ -n "$ITERM2_SHOULD_DECORATE_PROMPT" ]; then
+ iterm2_decorate_prompt
+ fi
+ }
+
+ # This is not run if you press ^C while entering a command.
+ iterm2_preexec() {
+ # Set PS1 back to its raw value prior to executing the command.
+ PS1="$ITERM2_PRECMD_PS1"
+ ITERM2_SHOULD_DECORATE_PROMPT="1"
+ iterm2_before_cmd_executes
+ }
+
+ # If hostname -f is slow on your system set iterm2_hostname prior to
+ # sourcing this script. We know it is fast on macOS so we don't cache
+ # it. That lets us handle the hostname changing like when you attach
+ # to a VPN.
+ if [ -z "${iterm2_hostname-}" ]; then
+ if [ "$(uname)" != "Darwin" ]; then
+ iterm2_hostname=`hostname -f 2>/dev/null`
+ # Some flavors of BSD (i.e. NetBSD and OpenBSD) don't have the -f option.
+ if [ $? -ne 0 ]; then
+ iterm2_hostname=`hostname`
+ fi
+ fi
+ fi
+
+ [[ -z ${precmd_functions-} ]] && precmd_functions=()
+ precmd_functions=($precmd_functions iterm2_precmd)
+
+ [[ -z ${preexec_functions-} ]] && preexec_functions=()
+ preexec_functions=($preexec_functions iterm2_preexec)
+
+ iterm2_print_state_data
+ printf "\033]1337;ShellIntegrationVersion=14;shell=zsh\007"
+ fi
+fi
diff --git a/plugins/iterm2/update b/plugins/iterm2/update
new file mode 100755
index 000000000..da8dae690
--- /dev/null
+++ b/plugins/iterm2/update
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+curl -s -L https://iterm2.com/shell_integration/zsh \
+ -o iterm2_shell_integration.zsh
diff --git a/plugins/lando/README.md b/plugins/lando/README.md
index 928a42bca..6daeae4e4 100644
--- a/plugins/lando/README.md
+++ b/plugins/lando/README.md
@@ -17,6 +17,7 @@ plugins=(... lando)
| `drush` | `lando drush` |
| `gulp` | `lando gulp` |
| `npm` | `lando npm` |
+| `php` | `lando php` |
| `wp` | `lando wp` |
| `yarn` | `lando yarn` |
diff --git a/plugins/macos/README.md b/plugins/macos/README.md
index 1bc4244a4..1cb9b395d 100644
--- a/plugins/macos/README.md
+++ b/plugins/macos/README.md
@@ -25,7 +25,7 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
| `pxd` | Return the current Xcode project directory |
| `cdx` | `cd` to the current Xcode project directory |
| `quick-look` | Quick-Look a specified file |
-| `man-preview` | Open a specified man page in Preview app |
+| `man-preview` | Open man pages in Preview app |
| `showfiles` | Show hidden files in Finder |
| `hidefiles` | Hide the hidden files in Finder |
| `itunes` | _DEPRECATED_. Use `music` from macOS Catalina on |
diff --git a/plugins/macos/macos.plugin.zsh b/plugins/macos/macos.plugin.zsh
index e4d759dcf..e27d412c8 100644
--- a/plugins/macos/macos.plugin.zsh
+++ b/plugins/macos/macos.plugin.zsh
@@ -224,9 +224,10 @@ function quick-look() {
}
function man-preview() {
- local location
- # Don't let Preview.app steal focus if the man page doesn't exist
- location=$(man -w "$@") && mandoc -Tpdf $location | open -f -a Preview
+ local page
+ for page in "${(@f)"$(man -w $@)"}"; do
+ command mandoc -Tpdf $page | open -f -a Preview
+ done
}
compdef _man man-preview
diff --git a/plugins/marked2/marked2.plugin.zsh b/plugins/marked2/marked2.plugin.zsh
index 56863ade5..45f4b65c1 100644
--- a/plugins/marked2/marked2.plugin.zsh
+++ b/plugins/marked2/marked2.plugin.zsh
@@ -3,10 +3,5 @@
# If marked is passed a file, open it in Marked
#
function marked() {
- if [ "$1" ]
- then
- open -a "marked 2.app" "$1"
- else
- open -a "marked 2.app"
- fi
+ open -a "marked 2.app" "$1"
}
diff --git a/plugins/marktext/README.md b/plugins/marktext/README.md
new file mode 100644
index 000000000..71d287451
--- /dev/null
+++ b/plugins/marktext/README.md
@@ -0,0 +1,17 @@
+## marktext
+
+Plugin for MarkText, a previewer for Markdown files on Mac OS X
+
+### Requirements
+
+ * [MarkText](https://github.com/marktext/marktext)
+
+### Usage
+
+ * If `marktext` is called without an argument, open MarkText
+
+ * If `marktext` is passed a file, open it in MarkText
+
+### Credits
+
+ * just copied from plugins/marked2, all credits to marked2 plugin author
diff --git a/plugins/marktext/marktext.plugin.zsh b/plugins/marktext/marktext.plugin.zsh
new file mode 100644
index 000000000..1da85bcca
--- /dev/null
+++ b/plugins/marktext/marktext.plugin.zsh
@@ -0,0 +1,7 @@
+#
+# If marktext is called without an argument, open MarkText
+# If marktext is passed a file, open it in MarkText
+#
+function marktext() {
+ open -a "MarkText.app" "$1"
+}
diff --git a/plugins/nats/README.md b/plugins/nats/README.md
new file mode 100644
index 000000000..0ea26fca1
--- /dev/null
+++ b/plugins/nats/README.md
@@ -0,0 +1,14 @@
+# NATS plugin
+
+This plugin adds completion for several tools from [NATS](https://nats.io/).
+
+- [`nsc`](https://github.com/nats-io/nsc)
+- [`natscli`](https://github.com/nats-io/natscli)
+
+To use it, add `nats` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... nats)
+```
+
+This plugin does not add any aliases.
diff --git a/plugins/nats/nats.plugin.zsh b/plugins/nats/nats.plugin.zsh
new file mode 100644
index 000000000..8b95b07c6
--- /dev/null
+++ b/plugins/nats/nats.plugin.zsh
@@ -0,0 +1,23 @@
+if (( $+commands[nsc] )); then
+ # If the completion file doesn't exist yet, we need to autoload it and
+ # bind it to `nsc`. Otherwise, compinit will have already done that.
+ if [[ ! -f "$ZSH_CACHE_DIR/completions/_nsc" ]]; then
+ typeset -g -A _comps
+ autoload -Uz _nsc
+ _comps[nsc]=_nsc
+ fi
+
+ nsc completion zsh >| "$ZSH_CACHE_DIR/completions/_nsc" &|
+fi
+
+if (( $+commands[nats] )); then
+ # If the completion file doesn't exist yet, we need to autoload it and
+ # bind it to `nats`. Otherwise, compinit will have already done that.
+ if [[ ! -f "$ZSH_CACHE_DIR/completions/_nats" ]]; then
+ typeset -g -A _comps
+ autoload -Uz _nats
+ _comps[nats]=_nats
+ fi
+
+ nats --completion-script-zsh >| "$ZSH_CACHE_DIR/completions/_nats" &|
+fi
diff --git a/plugins/nodenv/README.md b/plugins/nodenv/README.md
new file mode 100644
index 000000000..550597025
--- /dev/null
+++ b/plugins/nodenv/README.md
@@ -0,0 +1,20 @@
+# nodenv plugin
+
+The primary job of this plugin is to provide `nodenv_prompt_info` which can be added to your theme to include Node
+version information into your prompt.
+
+To use it, add `nodenv` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... nodenv)
+```
+
+## Functions
+
+* `nodenv_prompt_info`: displays the Node version in use by nodenv; or the global Node
+ version, if nodenv wasn't found. You can use this function in your prompt by adding
+ `$(nodenv_prompt_info)` to PROMPT or RPROMPT:
+
+ ```zsh
+ RPROMPT='$(nodenv_prompt_info)'
+ ```
diff --git a/plugins/nodenv/nodenv.plugin.zsh b/plugins/nodenv/nodenv.plugin.zsh
new file mode 100644
index 000000000..79a4ffbb5
--- /dev/null
+++ b/plugins/nodenv/nodenv.plugin.zsh
@@ -0,0 +1,43 @@
+# This plugin loads nodenv into the current shell and provides prompt info via
+# the 'nodenv_prompt_info' function.
+
+FOUND_NODENV=${+commands[nodenv]}
+
+if [[ $FOUND_NODENV -ne 1 ]]; then
+ nodenvdirs=(
+ "$HOME/.nodenv"
+ "/usr/local/nodenv"
+ "/opt/nodenv"
+ "/usr/local/opt/nodenv"
+ )
+ for dir in $nodenvdirs; do
+ if [[ -d "${dir}/bin" ]]; then
+ export PATH="$PATH:${dir}/bin"
+ FOUND_NODENV=1
+ break
+ fi
+ done
+
+ if [[ $FOUND_NODENV -ne 1 ]]; then
+ if (( $+commands[brew] )) && dir=$(brew --prefix nodenv 2>/dev/null); then
+ if [[ -d "${dir}/bin" ]]; then
+ export PATH="$PATH:${dir}/bin"
+ FOUND_NODENV=1
+ fi
+ fi
+ fi
+fi
+
+if [[ $FOUND_NODENV -eq 1 ]]; then
+ eval "$(nodenv init --no-rehash - zsh)"
+ function nodenv_prompt_info() {
+ nodenv version-name 2>/dev/null
+ }
+else
+ # fallback to system node
+ function nodenv_prompt_info() {
+ echo "system: $(node -v 2>&1 | cut -c 2-)"
+ }
+fi
+
+unset FOUND_NODENV nodenvdirs dir
diff --git a/plugins/nsc/README.md b/plugins/nsc/README.md
deleted file mode 100644
index ce0d2c15c..000000000
--- a/plugins/nsc/README.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# NSC plugin
-
-This plugin adds completion for the [NSC](https://github.com/nats-io/nsc).
-
-To use it, add `nsc` to the plugins array in your zshrc file:
-
-```zsh
-plugins=(... nsc)
-```
-
-This plugin does not add any aliases.
diff --git a/plugins/nsc/nsc.plugin.zsh b/plugins/nsc/nsc.plugin.zsh
deleted file mode 100644
index daa599e8f..000000000
--- a/plugins/nsc/nsc.plugin.zsh
+++ /dev/null
@@ -1,13 +0,0 @@
-if (( ! $+commands[nsc] )); then
- return
-fi
-
-# If the completion file doesn't exist yet, we need to autoload it and
-# bind it to `nsc`. Otherwise, compinit will have already done that.
-if [[ ! -f "$ZSH_CACHE_DIR/completions/_nsc" ]]; then
- typeset -g -A _comps
- autoload -Uz _nsc
- _comps[nsc]=_nsc
-fi
-
-nsc completion zsh >| "$ZSH_CACHE_DIR/completions/_nsc" &|
diff --git a/plugins/rails/README.md b/plugins/rails/README.md
index fa66750f0..b2425aabc 100644
--- a/plugins/rails/README.md
+++ b/plugins/rails/README.md
@@ -47,6 +47,7 @@ plugins=(... rails)
| `rsp` | `rails server --port` | Launch a web server and specify the listening port |
| `rsts` | `rails stats` | Print code statistics |
| `rt` | `rails test` | Run Rails tests |
+| `rta` | `rails test:all` | Runs all Rails tests, including system tests |
| `ru` | `rails runner` | Run Ruby code in the context of Rails |
### Foreman
diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh
index b11cbb5c7..015dc9ecb 100644
--- a/plugins/rails/rails.plugin.zsh
+++ b/plugins/rails/rails.plugin.zsh
@@ -75,6 +75,7 @@ alias rsd='rails server --debugger'
alias rsp='rails server --port'
alias rsts='rails stats'
alias rt='rails test'
+alias rta='rails test:all'
alias ru='rails runner'
# Foreman aliases
diff --git a/plugins/rvm/README.md b/plugins/rvm/README.md
index 576b037b0..410bd60c0 100644
--- a/plugins/rvm/README.md
+++ b/plugins/rvm/README.md
@@ -24,6 +24,7 @@ plugins=(... rvm)
| `rb27` | `rvm use ruby-2.7` |
| `rb30` | `rvm use ruby-3.0` |
| `rb31` | `rvm use ruby-3.1` |
+| `rb32` | `rvm use ruby-3.2` |
| `rvm-update` | `rvm get head` |
| `gems` | `gem list` |
| `rvms` | `rvm gemset` |
diff --git a/plugins/rvm/rvm.plugin.zsh b/plugins/rvm/rvm.plugin.zsh
index 2a091d019..3ddf04176 100644
--- a/plugins/rvm/rvm.plugin.zsh
+++ b/plugins/rvm/rvm.plugin.zsh
@@ -27,6 +27,7 @@ rubies=(
27 'ruby-2.7'
30 'ruby-3.0'
31 'ruby-3.1'
+ 32 'ruby-3.2'
)
for v in ${(k)rubies}; do
diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh
index 2a0b3bfc4..66b253fe7 100644
--- a/plugins/sudo/sudo.plugin.zsh
+++ b/plugins/sudo/sudo.plugin.zsh
@@ -96,7 +96,7 @@ sudo-command-line() {
LBUFFER="${WHITESPACE}${LBUFFER}"
# Redisplay edit buffer (compatibility with zsh-syntax-highlighting)
- zle redisplay
+ zle && zle redisplay # only run redisplay if zle is enabled
}
}
diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh
index 9b5159ff1..7ce62bac1 100644
--- a/plugins/systemadmin/systemadmin.plugin.zsh
+++ b/plugins/systemadmin/systemadmin.plugin.zsh
@@ -140,7 +140,13 @@ function d0() {
# gather external ip address
function geteip() {
curl -s -S -4 https://icanhazip.com
- curl -s -S -6 https://icanhazip.com
+
+ # handle case when there is no IPv6 external IP, which shows error
+ # curl: (7) Couldn't connect to server
+ curl -s -S -6 https://icanhazip.com 2>/dev/null
+ local ret=$?
+ (( ret == 7 )) && print -P -u2 "%F{red}error: no IPv6 route to host%f"
+ return $ret
}
# determine local IP address(es)
diff --git a/plugins/terraform/README.md b/plugins/terraform/README.md
index 59c6e7f2a..c19f2ad1c 100644
--- a/plugins/terraform/README.md
+++ b/plugins/terraform/README.md
@@ -19,6 +19,7 @@ plugins=(... terraform)
| ----- | -------------------- |
| `tf` | `terraform` |
| `tfa` | `terraform apply` |
+| `tfc` | `terraform console` |
| `tfd` | `terraform destroy` |
| `tff` | `terraform fmt` |
| `tfi` | `terraform init` |
diff --git a/plugins/terraform/_terraform b/plugins/terraform/_terraform
new file mode 100644
index 000000000..625834563
--- /dev/null
+++ b/plugins/terraform/_terraform
@@ -0,0 +1,411 @@
+#compdef terraform
+
+local -a _terraform_cmds opt_args
+_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'
+ 'force-unlock:Manually unlock the terraform state'
+ 'get:Download and install modules for the configuration'
+ 'graph:Create a visual graph of Terraform resources'
+ 'import:Import existing infrastructure into Terraform'
+ 'init:Initialize a Terraform working directory'
+ 'login:Obtain and save credentials for a remote host'
+ 'logout:Remove locally-stored credentials for a remote host'
+ 'output:Read an output from a state file'
+ 'plan:Generate and show an execution plan'
+ 'providers:Prints a tree of the providers used in the configuration'
+ 'refresh:Update local state file against real resources'
+ 'show:Inspect Terraform state or plan'
+ 'state:Advanced state management'
+ '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'
+ '0.12upgrade:Rewrites pre-0.12 module source code for v0.12'
+ '0.13upgrade:Rewrites pre-0.13 module source code for v0.13'
+)
+
+__012upgrade() {
+ _arguments \
+ '-yes[Skip the initial introduction messages and interactive confirmation. This can be used to run this command in batch from a script.]' \
+ '-force[ Override the heuristic that attempts to detect if a configuration is already written for v0.12 or later. Some of the transformations made by this command are not idempotent, so re-running against the same module may change the meanings expressions in the module.]'
+}
+
+__013upgrade() {
+ _arguments \
+ '-yes[Skip the initial introduction messages and interactive confirmation. This can be used to run this command in batch from a script.]'
+}
+
+__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.]:backupfile:_files -g "*.backup"' \
+ '-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
+ '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
+ '-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 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=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -g "*.tfstate"' \
+ '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
+ '*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
+ '*-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.]:file:_files -g "*.tfvars{,.json}"'
+}
+
+__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.]:file:_files -g "*.tfvars{,.json}"'
+}
+
+__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.]:backupfile:_files -g "*.backup"' \
+ '-auto-approve[Skip interactive approval before destroying.]' \
+ '-force[Deprecated: same as auto-approve.]' \
+ '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
+ '-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=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -g "*.tfstate"' \
+ '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
+ '*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
+ '*-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.]:file:_files -g "*.tfvars{,.json}"'
+}
+
+__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.]' \
+ '-recursive=[(false) Also process files in subdirectories. By default, only the given directory (or current directory) is processed.]'
+}
+
+__force_unlock() {
+ _arguments \
+ "-force[Don't ask for input for unlock confirmation.]"
+}
+
+__get() {
+ _arguments \
+ '-update=[(false) If true, modules already downloaded will be checked for updates and updated if necessary.]' \
+ '-no-color[Disable text coloring in the output.]'
+}
+
+__graph() {
+ _arguments \
+ '-draw-cycles[Highlight any cycles in the graph with colored edges. This helps when diagnosing cycle errors.]' \
+ '-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.]:backupfile:_files -g "*.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:(true false)' \
+ '-lock-timeout=[(0s) Duration to retry a state lock.]' \
+ '-no-color[If specified, output will contain no color.]' \
+ '-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.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.]:statefile:_files -g "*.tfstate"' \
+ '*-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.]:file:_files -g "*.tfvars{,.json}"'
+}
+
+__init() {
+ _arguments \
+ '-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=[(SOURCE) 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:(true false)' \
+ '-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.]:plugin_dir:_files -/' \
+ '-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.]'
+}
+
+__login() {
+ _arguments \
+
+}
+
+__logout() {
+ _arguments \
+
+}
+
+__output() {
+ _arguments \
+ '-state=[(path) Path to the state file to read. Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
+ '-no-color[If specified, output will contain no color.]' \
+ '-json[If specified, machine readable output will be printed in JSON format]'
+}
+
+__plan() {
+ _arguments \
+ '-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
+ '-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.]' \
+ '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
+ '-lock-timeout=[(0s) Duration to retry a state lock.]' \
+ '-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.]:statefile:_files -g "*.tfstate"' \
+ '*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
+ '*-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.]:file:_files -g "*.tfvars{,.json}"'
+}
+
+__providers() {
+ local -a __providers_cmds
+ __providers_cmds=(
+ 'mirror:Mirrors the provider plugins needed for the current configuration'
+ 'schema:Prints the schemas of the providers used in the configuration'
+ )
+ _describe -t providers "providers commands" __providers_cmds
+
+}
+
+__providers_mirror() {
+ _arguments \
+ '-platform=[(os_arch) Choose which target platform to build a mirror for.]' \
+ "*:target_dir:_files -/"
+}
+
+__providers_schema() {
+ _arguments \
+ '-json[]' \
+ '::'
+}
+
+__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.]::backupfile:_files -g "*.backup"' \
+ '-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
+ '-input=[(true) Ask for input for variables if not directly set.]' \
+ '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
+ '-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".]:statefile:_files -g "*.tfstate"' \
+ '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
+ '*-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:__statelist' \
+ '*-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.]:file:_files -g "*.tfvars{,.json}"'
+}
+
+__show() {
+ _arguments \
+ '-json[If specified, output the Terraform plan or state in a machine-readable form.]' \
+ '-no-color[If specified, output will not contain any color.]'
+}
+
+__state() {
+ local -a __state_cmds
+ __state_cmds=(
+ 'list:List resources in the state'
+ 'mv:Move an item in the state'
+ 'pull:Pull current state and output to stdout'
+ 'push:Update remote state from a local state file'
+ 'replace-provider:Replace provider for resources in the Terraform state'
+ 'rm:Remove instances from the state'
+ 'show:Show a resource in the state'
+ )
+ _describe -t state "state commands" __state_cmds
+}
+
+__state_list() {
+ _arguments \
+ '-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default, Terraform will consult the state of the currently-selected workspace.]' \
+ '-id=[(id) Filters the results to include only instances whose resource types have an attribute named id whose value equals the given id string.]' \
+ "*:address:__statelist"
+}
+
+__state_mv() {
+ _arguments \
+ "-dry-run[If set, prints out what would've been moved but doesn't actually move anything.]" \
+ '-backup=[(PATH) Path where Terraform should write the backup for the original state. This can"t be disabled. If not set, Terraform will write it to the same path as the statefile with a ".backup" extension.]:backupfile:_files -g "*.backup"' \
+ '-backup-out=[(PATH) Path where Terraform should write the backup for the destination state. This can"t be disabled. If not set, Terraform will write it to the same path as the destination state file with a backup extension. This only needs to be specified if -state-out is set to a different path than -state.]:backupfile:_files -g "*.backup"' \
+ "-lock=[(true) Lock the state files when locking is supported.]:lock:(true false)" \
+ "-lock-timeout=[(0s) Duration to retry a state lock.]" \
+ '-state=[(path) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
+ '-state-out=[(path) Path to the destination state file to write to. If this isn"t specified, the source state file will be used. This can be a new or existing path.]:statefile:_files -g "*.tfstate"' \
+ "::" \
+ ":source:__statelist" \
+ ":destination: "
+}
+
+__state_push() {
+ _arguments \
+ "-force[Write the state even if lineages don't match or the remote serial is higher.]" \
+ '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
+ "-lock-timeout=[(0s) Duration to retry a state lock.]" \
+ "::" \
+ ":destination:_files"
+}
+
+__state_replace_provider() {
+ _arguments \
+ '-auto-approve[Skip interactive approval.]' \
+ '-backup=[(PATH) Path where Terraform should write the backup for the state file. This can"t be disabled. If not set, Terraform will write it to the same path as the state file with a ".backup" extension.]:backupfile:_files -g "*.backup"' \
+ "-lock=[(true) Lock the state files when locking is supported.]:lock:(true false)" \
+ "-lock-timeout=[(0s) Duration to retry a state lock.]" \
+ '-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
+ ":from_provider_fqn:" \
+ ":to_provider_fqn:"
+}
+
+__state_rm() {
+ _arguments \
+ "-dry-run[If set, prints out what would've been removed but doesn't actually remove anything.]" \
+ '-backup=[(PATH) Path where Terraform should write the backup for the original state.]::backupfile:_files -g "*.backup"' \
+ "-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)" \
+ "-lock-timeout=[(0s) Duration to retry a state lock.]" \
+ '-state=[(PATH) Path to the state file to update. Defaults to the current workspace state.]:statefile:_files -g "*.tfstate"' \
+ "*:address:__statelist"
+}
+
+
+__state_show() {
+ _arguments \
+ '-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.]:statefile:_files -g "*.tfstate"' \
+ "*:address:__statelist"
+}
+
+__statelist() {
+ compadd $(terraform state list $opt_args[-state])
+}
+
+__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.]:backupfile:_files -g "*.backup"' \
+ '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
+ '-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).]' \
+ '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
+ '-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -g "*.tfstate"' \
+ "*:address:__statelist"
+}
+
+__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.]:backupfile:_files -g "*.backup"' \
+ '-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
+ '-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).]' \
+ '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
+ '-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -g "*.tfstate"'
+}
+
+__validate() {
+ _arguments \
+ '-no-color[If specified, output will not contain any color.]' \
+ '-json[Produce output in a machine-readable JSON format, suitable for use in text editor integrations and other automated systems.]' \
+ ':dir:_files -/'
+}
+
+__version() {
+ _arguments \
+ '-json[Output the version information as a JSON object.]'
+}
+
+__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
+ _describe -t commands "terraform command" _terraform_cmds
+ return
+fi
+
+local -a _command_args
+case "$words[1]" in
+ 0.12upgrade)
+ __012upgrade ;;
+ 0.13upgrade)
+ __013upgrade ;;
+ apply)
+ __apply ;;
+ console)
+ __console;;
+ destroy)
+ __destroy ;;
+ fmt)
+ __fmt;;
+ force-unlock)
+ __force_unlock;;
+ get)
+ __get ;;
+ graph)
+ __graph ;;
+ import)
+ __import;;
+ init)
+ __init ;;
+ login)
+ __login ;;
+ logout)
+ __logout ;;
+ output)
+ __output ;;
+ plan)
+ __plan ;;
+ providers)
+ test $CURRENT -lt 3 && __providers
+ [[ $words[2] = "mirror" ]] && __providers_mirror
+ [[ $words[2] = "schema" ]] && __providers_schema
+ ;;
+ refresh)
+ __refresh ;;
+ show)
+ __show ;;
+ state)
+ test $CURRENT -lt 3 && __state
+ [[ $words[2] = "list" ]] && __state_list
+ [[ $words[2] = "mv" ]] && __state_mv
+ [[ $words[2] = "push" ]] && __state_push
+ [[ $words[2] = "replace-provider" ]] && __state_replace_provider
+ [[ $words[2] = "rm" ]] && __state_rm
+ [[ $words[2] = "show" ]] && __state_show
+ ;;
+ taint)
+ __taint ;;
+ untaint)
+ __untaint ;;
+ validate)
+ __validate ;;
+ version)
+ __version ;;
+ workspace)
+ test $CURRENT -lt 3 && __workspace ;;
+esac
diff --git a/plugins/terraform/terraform.plugin.zsh b/plugins/terraform/terraform.plugin.zsh
index eaa1e2e81..7006f204b 100644
--- a/plugins/terraform/terraform.plugin.zsh
+++ b/plugins/terraform/terraform.plugin.zsh
@@ -10,14 +10,10 @@ function tf_prompt_info() {
alias tf='terraform'
alias tfa='terraform apply'
+alias tfc='terraform console'
alias tfd='terraform destroy'
alias tff='terraform fmt'
alias tfi='terraform init'
alias tfo='terraform output'
alias tfp='terraform plan'
alias tfv='terraform validate'
-
-if (( $+commands[terraform] )); then
- autoload -U +X bashcompinit && bashcompinit
- complete -o nospace -C terraform terraform
-fi
diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md
index 476666bf6..0cb516751 100644
--- a/plugins/vi-mode/README.md
+++ b/plugins/vi-mode/README.md
@@ -29,6 +29,8 @@ plugins=(... vi-mode)
VI_MODE_SET_CURSOR=true
```
+ See [Cursor Styles](#cursor-styles) for controlling how the cursor looks in different modes
+
- `MODE_INDICATOR`: controls the string displayed when the shell is in normal mode.
See [Mode indicators](#mode-indicators) for details.
@@ -49,8 +51,42 @@ MODE_INDICATOR="%F{white}+%f"
INSERT_MODE_INDICATOR="%F{yellow}+%f"
```
-You can also use the `vi_mode_prompt_info` function in your prompt, which will display
-this mode indicator.
+### Adding mode indicators to your prompt
+
+`Vi-mode` by default will add mode indicators to `RPROMPT` **unless** that is defined by
+a preceding plugin.
+
+If `PROMPT` or `RPROMPT` is not defined to your liking, you can add mode info manually. The `vi_mode_prompt_info` function is available to insert mode indicator information.
+
+Here are some examples:
+
+```bash
+source $ZSH/oh-my-zsh.sh
+
+PROMPT="$PROMPT\$(vi_mode_prompt_info)"
+RPROMPT="\$(vi_mode_prompt_info)$RPROMPT"
+```
+
+Note the `\$` here, which importantly prevents interpolation at the time of defining, but allows it to be executed for each prompt update event.
+
+## Cursor Styles
+
+You can control the cursor style used in each active vim mode by changing the values of the following variables.
+
+```zsh
+# defaults
+VI_MODE_CURSOR_NORMAL=2
+VI_MODE_CURSOR_VISUAL=6
+VI_MODE_CURSOR_INSERT=6
+VI_MODE_CURSOR_OPPEND=0
+```
+
+- 0, 1 - Blinking block
+- 2 - Solid block
+- 3 - Blinking underline
+- 4 - Solid underline
+- 5 - Blinking line
+- 6 - Solid line
## Key bindings
diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh
index 149d6bbd5..9a410c1fb 100644
--- a/plugins/vi-mode/vi-mode.plugin.zsh
+++ b/plugins/vi-mode/vi-mode.plugin.zsh
@@ -14,6 +14,15 @@ typeset -g VI_MODE_RESET_PROMPT_ON_MODE_CHANGE
# Unset or set to any other value to do the opposite.
typeset -g VI_MODE_SET_CURSOR
+# Control how the cursor appears in the various vim modes. This only applies
+# if $VI_MODE_SET_CURSOR=true.
+#
+# See https://vt100.net/docs/vt510-rm/DECSCUSR for cursor styles
+typeset -g VI_MODE_CURSOR_NORMAL=2
+typeset -g VI_MODE_CURSOR_VISUAL=6
+typeset -g VI_MODE_CURSOR_INSERT=6
+typeset -g VI_MODE_CURSOR_OPPEND=0
+
typeset -g VI_KEYMAP=main
function _vi-mode-set-cursor-shape-for-keymap() {
@@ -22,13 +31,13 @@ function _vi-mode-set-cursor-shape-for-keymap() {
# https://vt100.net/docs/vt510-rm/DECSCUSR
local _shape=0
case "${1:-${VI_KEYMAP:-main}}" in
- main) _shape=6 ;; # vi insert: line
- viins) _shape=6 ;; # vi insert: line
- isearch) _shape=6 ;; # inc search: line
- command) _shape=6 ;; # read a command name
- vicmd) _shape=2 ;; # vi cmd: block
- visual) _shape=2 ;; # vi visual mode: block
- viopp) _shape=0 ;; # vi operation pending: blinking block
+ main) _shape=$VI_MODE_CURSOR_INSERT ;; # vi insert: line
+ viins) _shape=$VI_MODE_CURSOR_INSERT ;; # vi insert: line
+ isearch) _shape=$VI_MODE_CURSOR_INSERT ;; # inc search: line
+ command) _shape=$VI_MODE_CURSOR_INSERT ;; # read a command name
+ vicmd) _shape=$VI_MODE_CURSOR_NORMAL ;; # vi cmd: block
+ visual) _shape=$VI_MODE_CURSOR_VISUAL ;; # vi visual mode: block
+ viopp) _shape=$VI_MODE_CURSOR_OPPEND ;; # vi operation pending: blinking block
*) _shape=0 ;;
esac
printf $'\e[%d q' "${_shape}"
diff --git a/plugins/zsh-interactive-cd/LICENSE b/plugins/zsh-interactive-cd/LICENSE
new file mode 100644
index 000000000..40b3f8d7a
--- /dev/null
+++ b/plugins/zsh-interactive-cd/LICENSE
@@ -0,0 +1,375 @@
+Copyright 2017-2018 Henry Chang
+
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+ means each individual or legal entity that creates, contributes to
+ the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+ means the combination of the Contributions of others (if any) used
+ by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+ means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+ means Source Code Form to which the initial Contributor has attached
+ the notice in Exhibit A, the Executable Form of such Source Code
+ Form, and Modifications of such Source Code Form, in each case
+ including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+ means
+
+ (a) that the initial Contributor has attached the notice described
+ in Exhibit B to the Covered Software; or
+
+ (b) that the Covered Software was made available under the terms of
+ version 1.1 or earlier of the License, but not also under the
+ terms of a Secondary License.
+
+1.6. "Executable Form"
+ means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+ means a work that combines Covered Software with other material, in
+ a separate file or files, that is not Covered Software.
+
+1.8. "License"
+ means this document.
+
+1.9. "Licensable"
+ means having the right to grant, to the maximum extent possible,
+ whether at the time of the initial grant or subsequently, any and
+ all of the rights conveyed by this License.
+
+1.10. "Modifications"
+ means any of the following:
+
+ (a) any file in Source Code Form that results from an addition to,
+ deletion from, or modification of the contents of Covered
+ Software; or
+
+ (b) any new file in Source Code Form that contains any Covered
+ Software.
+
+1.11. "Patent Claims" of a Contributor
+ means any patent claim(s), including without limitation, method,
+ process, and apparatus claims, in any patent Licensable by such
+ Contributor that would be infringed, but for the grant of the
+ License, by the making, using, selling, offering for sale, having
+ made, import, or transfer of either its Contributions or its
+ Contributor Version.
+
+1.12. "Secondary License"
+ means either the GNU General Public License, Version 2.0, the GNU
+ Lesser General Public License, Version 2.1, the GNU Affero General
+ Public License, Version 3.0, or any later versions of those
+ licenses.
+
+1.13. "Source Code Form"
+ means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+ means an individual or a legal entity exercising rights under this
+ License. For legal entities, "You" includes any entity that
+ controls, is controlled by, or is under common control with You. For
+ purposes of this definition, "control" means (a) the power, direct
+ or indirect, to cause the direction or management of such entity,
+ whether by contract or otherwise, or (b) ownership of more than
+ fifty percent (50%) of the outstanding shares or beneficial
+ ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+ Licensable by such Contributor to use, reproduce, make available,
+ modify, display, perform, distribute, and otherwise exploit its
+ Contributions, either on an unmodified basis, with Modifications, or
+ as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+ for sale, have made, import, and otherwise transfer either its
+ Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+ or
+
+(b) for infringements caused by: (i) Your and any other third party's
+ modifications of Covered Software, or (ii) the combination of its
+ Contributions with other software (except as part of its Contributor
+ Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+ its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+ Form, as described in Section 3.1, and You must inform recipients of
+ the Executable Form how they can obtain a copy of such Source Code
+ Form by reasonable means in a timely manner, at a charge no more
+ than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+ License, or sublicense it under different terms, provided that the
+ license for the Executable Form does not attempt to limit or alter
+ the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+* *
+* 6. Disclaimer of Warranty *
+* ------------------------- *
+* *
+* Covered Software is provided under this License on an "as is" *
+* basis, without warranty of any kind, either expressed, implied, or *
+* statutory, including, without limitation, warranties that the *
+* Covered Software is free of defects, merchantable, fit for a *
+* particular purpose or non-infringing. The entire risk as to the *
+* quality and performance of the Covered Software is with You. *
+* Should any Covered Software prove defective in any respect, You *
+* (not any Contributor) assume the cost of any necessary servicing, *
+* repair, or correction. This disclaimer of warranty constitutes an *
+* essential part of this License. No use of any Covered Software is *
+* authorized under this License except under this disclaimer. *
+* *
+************************************************************************
+
+************************************************************************
+* *
+* 7. Limitation of Liability *
+* -------------------------- *
+* *
+* Under no circumstances and under no legal theory, whether tort *
+* (including negligence), contract, or otherwise, shall any *
+* Contributor, or anyone who distributes Covered Software as *
+* permitted above, be liable to You for any direct, indirect, *
+* special, incidental, or consequential damages of any character *
+* including, without limitation, damages for lost profits, loss of *
+* goodwill, work stoppage, computer failure or malfunction, or any *
+* and all other commercial damages or losses, even if such party *
+* shall have been informed of the possibility of such damages. This *
+* limitation of liability shall not apply to liability for death or *
+* personal injury resulting from such party's negligence to the *
+* extent applicable law prohibits such limitation. Some *
+* jurisdictions do not allow the exclusion or limitation of *
+* incidental or consequential damages, so this exclusion and *
+* limitation may not apply to You. *
+* *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0. If a copy of the MPL was not distributed with this
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+ This Source Code Form is "Incompatible With Secondary Licenses", as
+ defined by the Mozilla Public License, v. 2.0.
diff --git a/plugins/zsh-interactive-cd/README.md b/plugins/zsh-interactive-cd/README.md
index c8337fbc8..4bffbf04a 100644
--- a/plugins/zsh-interactive-cd/README.md
+++ b/plugins/zsh-interactive-cd/README.md
@@ -1,23 +1,15 @@
# zsh-interactive-cd
-This plugin adds a fish-like interactive tab completion for the `cd` command.
+## Demo
-To use it, add `zsh-interactive-cd` to the plugins array of your zshrc file:
-```zsh
-plugins=(... zsh-interactive-cd)
-```
+![demo](demo.gif)
-![demo](https://user-images.githubusercontent.com/1441704/74360670-cb202900-4dc5-11ea-9734-f60caf726e85.gif)
+## Installation
-## Usage
-
-Press tab for completion as usual, it'll launch fzf automatically. Check fzf’s [readme](https://github.com/junegunn/fzf#search-syntax) for more search syntax usage.
+1. Install [fzf](https://github.com/junegunn/fzf) by following its [installation instruction](https://github.com/junegunn/fzf#installation).
-## Requirements
+2. Source `zsh-interactive-cd.plugin.zsh` in `.zshrc`.
-This plugin requires [fzf](https://github.com/junegunn/fzf). Install it by following
-its [installation instructions](https://github.com/junegunn/fzf#installation).
-
-## Author
+## Usage
-[Henry Chang](https://github.com/changyuheng)
+Press tab for completion as usual, it'll launch fzf automatically. Check fzf’s [readme](https://github.com/junegunn/fzf#search-syntax) for more search syntax usage.
diff --git a/plugins/zsh-interactive-cd/demo.gif b/plugins/zsh-interactive-cd/demo.gif
new file mode 100644
index 000000000..3568ecf95
--- /dev/null
+++ b/plugins/zsh-interactive-cd/demo.gif
Binary files differ
diff --git a/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh b/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh
index b0520c239..0ae9d50a7 100644
--- a/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh
+++ b/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh
@@ -1,4 +1,10 @@
-# Copyright (c) 2017 Henry Chang
+#!/usr/bin/env zsh
+#
+# Copyright 2017-2018 Henry Chang
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
__zic_fzf_prog() {
[ -n "$TMUX_PANE" ] && [ "${FZF_TMUX:-0}" != 0 ] && [ ${LINES:-40} -gt 15 ] \
@@ -17,7 +23,7 @@ __zic_matched_subdir_list() {
length=0
fi
find -L "$dir" -mindepth 1 -maxdepth 1 -type d 2>/dev/null \
- | cut -b $(( ${length} + 2 ))- | sed '/^$/d' | while read -r line; do
+ | cut -b $(( ${length} + 2 ))- | command sed '/^$/d' | while read -r line; do
if [[ "${line[1]}" == "." ]]; then
continue
fi
@@ -32,13 +38,19 @@ __zic_matched_subdir_list() {
seg=$(basename -- "$1")
starts_with_dir=$( \
find -L "$dir" -mindepth 1 -maxdepth 1 -type d \
- 2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \
+ 2>/dev/null | cut -b $(( ${length} + 2 ))- | command sed '/^$/d' \
| while read -r line; do
if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then
continue
fi
- if [[ "$line" == "$seg"* ]]; then
- echo "$line"
+ if [ "$zic_case_insensitive" = "true" ]; then
+ if [[ "$line:u" == "$seg:u"* ]]; then
+ echo "$line"
+ fi
+ else
+ if [[ "$line" == "$seg"* ]]; then
+ echo "$line"
+ fi
fi
done
)
@@ -46,19 +58,36 @@ __zic_matched_subdir_list() {
echo "$starts_with_dir"
else
find -L "$dir" -mindepth 1 -maxdepth 1 -type d \
- 2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \
+ 2>/dev/null | cut -b $(( ${length} + 2 ))- | command sed '/^$/d' \
| while read -r line; do
if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then
continue
fi
- if [[ "$line" == *"$seg"* ]]; then
- echo "$line"
+ if [ "$zic_case_insensitive" = "true" ]; then
+ if [[ "$line:u" == *"$seg:u"* ]]; then
+ echo "$line"
+ fi
+ else
+ if [[ "$line" == *"$seg"* ]]; then
+ echo "$line"
+ fi
fi
done
fi
fi
}
+__zic_fzf_bindings() {
+ autoload is-at-least
+ fzf=$(__zic_fzf_prog)
+
+ if $(is-at-least '0.21.0' $(${=fzf} --version)); then
+ echo 'shift-tab:up,tab:down,bspace:backward-delete-char/eof'
+ else
+ echo 'shift-tab:up,tab:down'
+ fi
+}
+
_zic_list_generator() {
__zic_matched_subdir_list "${(Q)@[-1]}" | sort
}
@@ -75,6 +104,7 @@ _zic_complete() {
fi
fzf=$(__zic_fzf_prog)
+ fzf_bindings=$(__zic_fzf_bindings)
if [ $(echo $l | wc -l) -eq 1 ]; then
matches=${(q)l}
@@ -82,7 +112,7 @@ _zic_complete() {
matches=$(echo $l \
| FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} \
--reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS \
- --bind 'shift-tab:up,tab:down'" ${=fzf} \
+ --bind '${fzf_bindings}'" ${=fzf} \
| while read -r item; do
echo -n "${(q)item} "
done)
@@ -144,5 +174,7 @@ zic-completion() {
}
zle -N zic-completion
-bindkey -M emacs '^I' zic-completion
-bindkey -M viins '^I' zic-completion
+if [ -z $zic_custom_binding ]; then
+ zic_custom_binding='^I'
+fi
+bindkey "${zic_custom_binding}" zic-completion
diff --git a/themes/af-magic.zsh-theme b/themes/af-magic.zsh-theme
index 2ef9b02d7..70549d01f 100644
--- a/themes/af-magic.zsh-theme
+++ b/themes/af-magic.zsh-theme
@@ -6,11 +6,12 @@
# dashed separator size
function afmagic_dashes {
# check either virtualenv or condaenv variables
- local python_env="${VIRTUAL_ENV:-$CONDA_DEFAULT_ENV}"
+ local python_env_dir="${VIRTUAL_ENV:-$CONDA_DEFAULT_ENV}"
+ local python_env="${python_env_dir##*/}"
# if there is a python virtual environment and it is displayed in
# the prompt, account for it when returning the number of dashes
- if [[ -n "$python_env" && "$PS1" = \(* ]]; then
+ if [[ -n "$python_env" && "$PS1" = *\(${python_env}\)* ]]; then
echo $(( COLUMNS - ${#python_env} - 3 ))
else
echo $COLUMNS
diff --git a/themes/amuse.zsh-theme b/themes/amuse.zsh-theme
index 3f7ec0bc5..d787fdaa4 100644
--- a/themes/amuse.zsh-theme
+++ b/themes/amuse.zsh-theme
@@ -11,8 +11,14 @@ ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg_bold[red]%}‹"
ZSH_THEME_RUBY_PROMPT_SUFFIX="›%{$reset_color%}"
PROMPT='
-%{$fg_bold[green]%}%~%{$reset_color%}$(git_prompt_info) ⌚ %{$fg_bold[red]%}%*%{$reset_color%}
+%{$fg_bold[green]%}%~%{$reset_color%}$(git_prompt_info)$(virtualenv_prompt_info) ⌚ %{$fg_bold[red]%}%*%{$reset_color%}
$ '
RPROMPT='$(ruby_prompt_info)'
+VIRTUAL_ENV_DISABLE_PROMPT=0
+ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX=" %{$fg[green]%}🐍"
+ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX="%{$reset_color%}"
+ZSH_THEME_VIRTUALENV_PREFIX=$ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX
+ZSH_THEME_VIRTUALENV_SUFFIX=$ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX
+
diff --git a/themes/mlh.zsh-theme b/themes/mlh.zsh-theme
index baff3fb63..c059bf850 100644
--- a/themes/mlh.zsh-theme
+++ b/themes/mlh.zsh-theme
@@ -47,6 +47,10 @@ if [ -z "$MLH_SHELL_SYMBOL" ]; then
MLH_SHELL_SYMBOL="$ "
fi
+if [ -z "$MLH_SHELL_SYMBOL_ROOT" ]; then
+ MLH_SHELL_SYMBOL_ROOT="# "
+fi
+
# colors
USER_COLOR="%F{001}"
DEVICE_COLOR="%F{033}"
@@ -83,7 +87,11 @@ exit_code() {
}
prompt_end() {
- printf "\n$MLH_SHELL_SYMBOL"
+ if [ "$UID" -eq 0 ]; then
+ printf "\n$MLH_SHELL_SYMBOL_ROOT"
+ else
+ printf "\n$MLH_SHELL_SYMBOL"
+ fi
}
# Set git_prompt_info text
diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
index 3a6bb6555..734714c94 100644
--- a/tools/check_for_upgrade.sh
+++ b/tools/check_for_upgrade.sh
@@ -21,9 +21,11 @@ zstyle -s ':omz:update' mode update_mode || {
# Cancel update if:
# - the automatic update is disabled.
# - the current user doesn't have write permissions nor owns the $ZSH directory.
+# - is not run from a tty
# - git is unavailable on the system.
if [[ "$update_mode" = disabled ]] \
|| [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \
+ || [[ ! -t 1 ]] \
|| ! command git --version 2>&1 >/dev/null; then
unset update_mode
return
diff --git a/tools/install.sh b/tools/install.sh
index a6538f9d7..f4ef16a0c 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -16,6 +16,9 @@
# ZSH=~/.zsh sh install.sh
#
# Respects the following environment variables:
+# ZDOTDIR - path to Zsh dotfiles directory (default: unset). See [1][2]
+# [1] https://zsh.sourceforge.io/Doc/Release/Parameters.html#index-ZDOTDIR
+# [2] https://zsh.sourceforge.io/Doc/Release/Files.html#index-ZDOTDIR_002c-use-of
# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)
# REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh)
# REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)
@@ -53,8 +56,17 @@ HOME="${HOME:-$(eval echo ~$USER)}"
# Track if $ZSH was provided
custom_zsh=${ZSH:+yes}
-# Default settings
+# Use $zdot to keep track of where the directory is for zsh dotfiles
+# To check if $ZDOTDIR was provided, explicitly check for $ZDOTDIR
+zdot="${ZDOTDIR:-$HOME}"
+
+# Default value for $ZSH
+# a) if $ZDOTDIR is supplied and not $HOME: $ZDOTDIR/ohmyzsh
+# b) otherwise, $HOME/.oh-my-zsh
+[ "$ZDOTDIR" = "$HOME" ] || ZSH="${ZSH:-${ZDOTDIR:+$ZDOTDIR/ohmyzsh}}"
ZSH="${ZSH:-$HOME/.oh-my-zsh}"
+
+# Default settings
REPO=${REPO:-ohmyzsh/ohmyzsh}
REMOTE=${REMOTE:-https://github.com/${REPO}.git}
BRANCH=${BRANCH:-master}
@@ -311,11 +323,11 @@ setup_zshrc() {
echo "${FMT_BLUE}Looking for an existing zsh config...${FMT_RESET}"
# Must use this exact name so uninstall.sh can find it
- OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh
- if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
+ OLD_ZSHRC="$zdot/.zshrc.pre-oh-my-zsh"
+ if [ -f "$zdot/.zshrc" ] || [ -h "$zdot/.zshrc" ]; then
# Skip this if the user doesn't want to replace an existing .zshrc
if [ "$KEEP_ZSHRC" = yes ]; then
- echo "${FMT_YELLOW}Found ~/.zshrc.${FMT_RESET} ${FMT_GREEN}Keeping...${FMT_RESET}"
+ echo "${FMT_YELLOW}Found ${zdot}/.zshrc.${FMT_RESET} ${FMT_GREEN}Keeping...${FMT_RESET}"
return
fi
if [ -e "$OLD_ZSHRC" ]; then
@@ -327,19 +339,24 @@ setup_zshrc() {
fi
mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"
- echo "${FMT_YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \
+ echo "${FMT_YELLOW}Found old .zshrc.pre-oh-my-zsh." \
"${FMT_GREEN}Backing up to ${OLD_OLD_ZSHRC}${FMT_RESET}"
fi
- echo "${FMT_YELLOW}Found ~/.zshrc.${FMT_RESET} ${FMT_GREEN}Backing up to ${OLD_ZSHRC}${FMT_RESET}"
- mv ~/.zshrc "$OLD_ZSHRC"
+ echo "${FMT_YELLOW}Found ${zdot}/.zshrc.${FMT_RESET} ${FMT_GREEN}Backing up to ${OLD_ZSHRC}${FMT_RESET}"
+ mv "$zdot/.zshrc" "$OLD_ZSHRC"
fi
- echo "${FMT_GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${FMT_RESET}"
+ echo "${FMT_GREEN}Using the Oh My Zsh template file and adding it to $zdot/.zshrc.${FMT_RESET}"
- # Replace $HOME path with '$HOME' in $ZSH variable in .zshrc file
- omz=$(echo "$ZSH" | sed "s|^$HOME/|\$HOME/|")
- sed "s|^export ZSH=.*$|export ZSH=\"${omz}\"|" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp
- mv -f ~/.zshrc-omztemp ~/.zshrc
+ # Modify $ZSH variable in .zshrc directory to use the literal $ZDOTDIR or $HOME
+ omz="$ZSH"
+ if [ -n "$ZDOTDIR" ] && [ "$ZDOTDIR" != "$HOME" ]; then
+ omz=$(echo "$omz" | sed "s|^$ZDOTDIR/|\$ZDOTDIR/|")
+ fi
+ omz=$(echo "$omz" | sed "s|^$HOME/|\$HOME/|")
+
+ sed "s|^export ZSH=.*$|export ZSH=\"${omz}\"|" "$ZSH/templates/zshrc.zsh-template" > "$zdot/.zshrc-omztemp"
+ mv -f "$zdot/.zshrc-omztemp" "$zdot/.zshrc"
echo
}
@@ -407,9 +424,9 @@ EOF
# We're going to change the default shell, so back up the current one
if [ -n "$SHELL" ]; then
- echo "$SHELL" > ~/.shell.pre-oh-my-zsh
+ echo "$SHELL" > "$zdot/.shell.pre-oh-my-zsh"
else
- grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh
+ grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > "$zdot/.shell.pre-oh-my-zsh"
fi
echo "Changing your shell to $zsh..."
@@ -451,7 +468,7 @@ print_success() {
printf '\n'
printf '\n'
printf "%s %s %s\n" "Before you scream ${FMT_BOLD}${FMT_YELLOW}Oh My Zsh!${FMT_RESET} look over the" \
- "$(fmt_code "$(fmt_link ".zshrc" "file://$HOME/.zshrc" --text)")" \
+ "$(fmt_code "$(fmt_link ".zshrc" "file://$zdot/.zshrc" --text)")" \
"file to select plugins, themes, and options."
printf '\n'
printf '%s\n' "• Follow us on Twitter: $(fmt_link @ohmyzsh https://twitter.com/ohmyzsh)"
@@ -506,6 +523,11 @@ EOF
exit 1
fi
+ # Create ZDOTDIR folder structure if it doesn't exist
+ if [ -n "$ZDOTDIR" ]; then
+ mkdir -p "$ZDOTDIR"
+ fi
+
setup_ohmyzsh
setup_zshrc
setup_shell