summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ansible/ansible.plugin.zsh4
-rw-r--r--plugins/archlinux/archlinux.plugin.zsh18
-rw-r--r--plugins/aws/README.md41
-rw-r--r--plugins/aws/aws.plugin.zsh112
-rw-r--r--plugins/battery/battery.plugin.zsh5
-rw-r--r--plugins/bgnotify/bgnotify.plugin.zsh2
-rw-r--r--plugins/brew/README.md21
-rw-r--r--plugins/brew/brew.plugin.zsh5
-rw-r--r--plugins/bundler/README.md79
-rw-r--r--plugins/bundler/bundler.plugin.zsh116
-rw-r--r--plugins/cargo/_cargo4
-rw-r--r--plugins/chucknorris/fortunes/chucknorris286
-rw-r--r--plugins/colored-man-pages/README.md14
-rw-r--r--plugins/colored-man-pages/colored-man-pages.plugin.zsh73
-rwxr-xr-xplugins/colored-man-pages/nroff12
-rw-r--r--plugins/colorize/colorize.plugin.zsh3
-rw-r--r--plugins/command-not-found/command-not-found.plugin.zsh24
-rw-r--r--plugins/common-aliases/common-aliases.plugin.zsh6
-rw-r--r--plugins/composer/composer.plugin.zsh2
-rw-r--r--plugins/docker/README.md22
-rw-r--r--plugins/emacs/emacs.plugin.zsh10
-rw-r--r--plugins/fzf/README.md53
-rw-r--r--plugins/fzf/fzf.plugin.zsh137
-rw-r--r--plugins/git-auto-fetch/README.md43
-rw-r--r--plugins/git-auto-fetch/git-auto-fetch.plugin.zsh81
-rw-r--r--plugins/git-lfs/README.md24
-rw-r--r--plugins/git-lfs/git-lfs.plugin.zsh17
-rw-r--r--plugins/git-prompt/README.md3
-rw-r--r--plugins/git-prompt/gitstatus.py4
-rw-r--r--plugins/git/git.plugin.zsh28
-rw-r--r--plugins/gitfast/_git200
-rw-r--r--plugins/gitfast/git-completion.bash2279
-rw-r--r--plugins/gitfast/git-prompt.sh72
-rwxr-xr-xplugins/gitfast/update11
-rw-r--r--plugins/gitfast/updates.patch56
-rw-r--r--plugins/globalias/README.md19
-rw-r--r--plugins/globalias/globalias.plugin.zsh10
-rw-r--r--plugins/golang/golang.plugin.zsh2
-rw-r--r--plugins/grc/README.md37
-rw-r--r--plugins/grc/grc.plugin.zsh44
-rw-r--r--plugins/ipfs/LICENSE22
-rw-r--r--plugins/ipfs/README.md17
-rw-r--r--plugins/ipfs/_ipfs717
-rw-r--r--plugins/kube-ps1/README.md8
-rw-r--r--plugins/kubectl/README.md31
-rw-r--r--plugins/kubectl/kubectl.plugin.zsh30
-rw-r--r--plugins/lando/LICENSE21
-rw-r--r--plugins/lando/README.md37
-rw-r--r--plugins/lando/lando.plugin.zsh40
-rw-r--r--plugins/laravel5/laravel5.plugin.zsh19
-rw-r--r--plugins/magic-enter/magic-enter.plugin.zsh53
-rw-r--r--plugins/minikube/minikube.plugin.zsh10
-rw-r--r--plugins/mvn/README.md1
-rw-r--r--plugins/mvn/mvn.plugin.zsh13
-rw-r--r--plugins/npx/README.md28
-rw-r--r--plugins/nvm/README.md19
-rw-r--r--plugins/nvm/nvm.plugin.zsh81
-rw-r--r--plugins/pip/pip.plugin.zsh6
-rw-r--r--plugins/pyenv/pyenv.plugin.zsh2
-rw-r--r--plugins/safe-paste/safe-paste.plugin.zsh128
-rw-r--r--plugins/scd/README.md54
-rw-r--r--plugins/scd/_scd60
-rwxr-xr-x[-rw-r--r--]plugins/scd/scd343
-rw-r--r--plugins/scd/scd.plugin.zsh16
-rwxr-xr-xplugins/shell-proxy/proxy.py2
-rwxr-xr-xplugins/shell-proxy/ssh-agent.py2
-rw-r--r--plugins/sublime-merge/README.md17
-rw-r--r--plugins/sublime-merge/sublime-merge.plugin.zsh55
-rw-r--r--plugins/sublime/sublime.plugin.zsh2
-rw-r--r--plugins/sudo/sudo.plugin.zsh61
-rw-r--r--plugins/systemadmin/README.md4
-rw-r--r--plugins/systemadmin/systemadmin.plugin.zsh4
-rw-r--r--plugins/terraform/README.md3
-rw-r--r--plugins/terraform/_terraform228
-rw-r--r--plugins/terraform/terraform.plugin.zsh2
-rw-r--r--plugins/thefuck/README.md4
-rw-r--r--plugins/timer/timer.plugin.zsh5
-rw-r--r--plugins/vagrant-prompt/vagrant-prompt.plugin.zsh25
-rw-r--r--plugins/wd/README.md186
-rw-r--r--plugins/wd/wd.sh163
-rw-r--r--plugins/wp-cli/README.md202
-rw-r--r--plugins/wp-cli/wp-cli.plugin.zsh51
-rw-r--r--plugins/z/README8
-rw-r--r--plugins/z/z.13
-rw-r--r--plugins/z/z.sh44
-rw-r--r--plugins/zsh_reload/zsh_reload.plugin.zsh14
86 files changed, 4556 insertions, 2264 deletions
diff --git a/plugins/ansible/ansible.plugin.zsh b/plugins/ansible/ansible.plugin.zsh
index f68ff23a5..75393b704 100644
--- a/plugins/ansible/ansible.plugin.zsh
+++ b/plugins/ansible/ansible.plugin.zsh
@@ -4,7 +4,7 @@ function ansible-version(){
}
function ansible-role-init(){
- if ! [ -z $1] ; then
+ if ! [ -z $1 ] ; then
echo "Ansible Role : $1 Creating...."
ansible-galaxy init $1
tree $1
@@ -25,4 +25,4 @@ alias ainv='ansible-inventory '
alias adoc='ansible-doc '
alias agal='ansible-galaxy '
alias apull='ansible-pull '
-alias aval='ansible-vault' \ No newline at end of file
+alias aval='ansible-vault'
diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh
index 4d39bd86b..c72e06dc2 100644
--- a/plugins/archlinux/archlinux.plugin.zsh
+++ b/plugins/archlinux/archlinux.plugin.zsh
@@ -171,14 +171,13 @@ function paclist() {
}
function pacdisowned() {
- emulate -L zsh
-
+ local tmp db fs
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
db=$tmp/db
fs=$tmp/fs
mkdir "$tmp"
- trap 'rm -rf "$tmp"' EXIT
+ trap 'rm -rf "$tmp"' EXIT
pacman -Qlq | sort -u > "$db"
@@ -189,15 +188,14 @@ function pacdisowned() {
}
function pacmanallkeys() {
- emulate -L zsh
curl -s https://www.archlinux.org/people/{developers,trustedusers}/ | \
awk -F\" '(/pgp.mit.edu/) { sub(/.*search=0x/,""); print $1}' | \
xargs sudo pacman-key --recv-keys
}
function pacmansignkeys() {
- emulate -L zsh
- for key in $*; do
+ local key
+ for key in $@; do
sudo pacman-key --recv-keys $key
sudo pacman-key --lsign-key $key
printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \
@@ -207,13 +205,13 @@ function pacmansignkeys() {
if (( $+commands[xdg-open] )); then
function pacweb() {
- pkg="$1"
- infos="$(LANG=C pacman -Si "$pkg")"
+ local pkg="$1"
+ local infos="$(LANG=C pacman -Si "$pkg")"
if [[ -z "$infos" ]]; then
return
fi
- repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
- arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
+ local repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
+ local arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null
}
fi
diff --git a/plugins/aws/README.md b/plugins/aws/README.md
index 57c3b54ac..011bbd8b4 100644
--- a/plugins/aws/README.md
+++ b/plugins/aws/README.md
@@ -15,6 +15,13 @@ plugins=(... aws)
It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI.
Run `asp` without arguments to clear the profile.
+* `acp [<profile>]`: 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 obtained. It
+ requires the roles to be configured as per the
+ [official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html).
+ Run `acp` without arguments to clear the profile.
+
* `agp`: gets the current value of `$AWS_PROFILE`.
* `aws_change_access_key`: changes the AWS access key of a profile.
@@ -33,6 +40,36 @@ plugins=(... aws)
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:
-- ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
+* ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
+
+* ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
+
+## Configuration
+
+[Configuration and credential file settings](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) by AWS
-- ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
+### Scenario: IAM roles with a source profile and MFA authentication
+
+Source profile credentials in `~/.aws/credentials`:
+
+```
+[source-profile-name]
+aws_access_key_id = ...
+aws_secret_access_key = ...
+```
+
+Role configuration in `~/.aws/config`:
+
+```
+[profile source-profile-name]
+mfa_serial = arn:aws:iam::111111111111:mfa/myuser
+region = us-east-1
+output = json
+
+[profile profile-with-role]
+role_arn = arn:aws:iam::9999999999999:role/myrole
+mfa_serial = arn:aws:iam::111111111111:mfa/myuser
+source_profile = source-profile-name
+region = us-east-1
+output = json
+```
diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh
index 7994963c3..e1566b113 100644
--- a/plugins/aws/aws.plugin.zsh
+++ b/plugins/aws/aws.plugin.zsh
@@ -23,31 +23,131 @@ function asp() {
export AWS_EB_PROFILE=$1
}
+# AWS profile switch
+function acp() {
+ if [[ -z "$1" ]]; then
+ unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE
+ unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
+ echo AWS profile cleared.
+ return
+ fi
+
+ local -a available_profiles
+ available_profiles=($(aws_profiles))
+ if [[ -z "${available_profiles[(r)$1]}" ]]; then
+ echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2
+ echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2
+ return 1
+ fi
+
+ local profile="$1"
+
+ # Get fallback credentials for if the aws command fails or no command is run
+ local aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
+ local aws_secret_access_key="$(aws configure get aws_secret_access_key --profile $profile)"
+ local aws_session_token="$(aws configure get aws_session_token --profile $profile)"
+
+
+ # First, if the profile has MFA configured, lets get the token and session duration
+ local mfa_serial="$(aws configure get mfa_serial --profile $profile)"
+ local sess_duration="$(aws configure get duration_seconds --profile $profile)"
+
+ if [[ -n "$mfa_serial" ]]; then
+ local -a mfa_opt
+ local mfa_token
+ echo -n "Please enter your MFA token for $mfa_serial: "
+ read -r mfa_token
+ if [[ -z "$sess_duration" ]]; then
+ echo -n "Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role): "
+ read -r sess_duration
+ fi
+ mfa_opt=(--serial-number "$mfa_serial" --token-code "$mfa_token" --duration-seconds "${sess_duration:-3600}")
+
+ # Now see whether we need to just MFA for the current role, or assume a different one
+ local role_arn="$(aws configure get role_arn --profile $profile)"
+ local sess_name="$(aws configure get role_session_name --profile $profile)"
+
+ if [[ -n "$role_arn" ]]; then
+ # Means we need to assume a specified role
+ aws_command=(aws sts assume-role --role-arn "$role_arn" "${mfa_opt[@]}")
+
+ # Check whether external_id is configured to use while assuming the role
+ local external_id="$(aws configure get external_id --profile $profile)"
+ if [[ -n "$external_id" ]]; then
+ aws_command+=(--external-id "$external_id")
+ fi
+
+ # Get source profile to use to assume role
+ local source_profile="$(aws configure get source_profile --profile $profile)"
+ if [[ -z "$sess_name" ]]; then
+ sess_name="${source_profile:-profile}"
+ fi
+ aws_command+=(--profile="${source_profile:-profile}" --role-session-name "${sess_name}")
+
+ echo "Assuming role $role_arn using profile ${source_profile:-profile}"
+ else
+ # Means we only need to do MFA
+ aws_command=(aws sts get-session-token --profile="$profile" "${mfa_opt[@]}")
+ echo "Obtaining session token for profile $profile"
+ fi
+
+ # Format output of aws command for easier processing
+ aws_command+=(--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' --output text)
+
+ # Run the aws command to obtain credentials
+ local -a credentials
+ credentials=(${(ps:\t:)"$(${aws_command[@]})"})
+
+ if [[ -n "$credentials" ]]; then
+ aws_access_key_id="${credentials[1]}"
+ aws_secret_access_key="${credentials[2]}"
+ aws_session_token="${credentials[3]}"
+ fi
+ fi
+
+ # Switch to AWS profile
+ if [[ -n "${aws_access_key_id}" && -n "$aws_secret_access_key" ]]; then
+ export AWS_DEFAULT_PROFILE="$profile"
+ export AWS_PROFILE="$profile"
+ export AWS_EB_PROFILE="$profile"
+ export AWS_ACCESS_KEY_ID="$aws_access_key_id"
+ export AWS_SECRET_ACCESS_KEY="$aws_secret_access_key"
+
+ if [[ -n "$aws_session_token" ]]; then
+ export AWS_SESSION_TOKEN="$aws_session_token"
+ else
+ unset AWS_SESSION_TOKEN
+ fi
+
+ echo "Switched to AWS Profile: $profile"
+ fi
+}
+
function aws_change_access_key() {
if [[ -z "$1" ]]; then
echo "usage: $0 <profile>"
return 1
fi
- echo Insert the credentials when asked.
+ echo "Insert the credentials when asked."
asp "$1" || return 1
AWS_PAGER="" aws iam create-access-key
AWS_PAGER="" aws configure --profile "$1"
- echo You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\`
- echo Your current keys are:
+ echo "You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\`"
+ echo "Your current keys are:"
AWS_PAGER="" aws iam list-access-keys
}
function aws_profiles() {
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
- grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9@_\.-]*\).*/\1/'
+ grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([-_[:alnum:]\.@]+)\][[:space:]]*$/\2/g'
}
function _aws_profiles() {
reply=($(aws_profiles))
}
-compctl -K _aws_profiles asp aws_change_access_key
+compctl -K _aws_profiles asp acp aws_change_access_key
# AWS prompt
function aws_prompt_info() {
@@ -55,7 +155,7 @@ function aws_prompt_info() {
echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}"
}
-if [ "$SHOW_AWS_PROMPT" != false ]; then
+if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then
RPROMPT='$(aws_prompt_info)'"$RPROMPT"
fi
diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
index 755ec8d64..a525fd7da 100644
--- a/plugins/battery/battery.plugin.zsh
+++ b/plugins/battery/battery.plugin.zsh
@@ -18,10 +18,7 @@ if [[ "$OSTYPE" = darwin* ]]; then
}
function battery_pct() {
- local battery_status="$(ioreg -rc AppleSmartBattery)"
- local -i capacity=$(sed -n -e '/MaxCapacity/s/^.*"MaxCapacity"\ =\ //p' <<< $battery_status)
- local -i current=$(sed -n -e '/CurrentCapacity/s/^.*"CurrentCapacity"\ =\ //p' <<< $battery_status)
- echo $(( current * 100 / capacity ))
+ pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
}
function battery_pct_remaining() {
diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh
index b3a6890b8..aecde20ea 100644
--- a/plugins/bgnotify/bgnotify.plugin.zsh
+++ b/plugins/bgnotify/bgnotify.plugin.zsh
@@ -53,7 +53,7 @@ bgnotify () { ## args: (title, subtitle)
bgnotify_begin() {
bgnotify_timestamp=$EPOCHSECONDS
- bgnotify_lastcmd="$1"
+ bgnotify_lastcmd="${1:-$2}"
bgnotify_windowid=$(currentWindowId)
}
diff --git a/plugins/brew/README.md b/plugins/brew/README.md
index 44af05225..b714b7ac0 100644
--- a/plugins/brew/README.md
+++ b/plugins/brew/README.md
@@ -10,16 +10,17 @@ plugins=(... brew)
## Aliases
-| Alias | Command | Description |
-|----------|-------------------------------------------------------------|---------------------------------------------------------------------|
-| `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. |
-| `bubo` | `brew update && brew outdated` | Update Homebrew and all formulae, then list outdated formulae. |
-| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae, then run cleanup. |
-| `bubu` | `bubo && bubc` | Do the last two operations above. |
-| `bcubo` | `brew update && brew cask outdated` | Update Homebrew and alll formulae, then list outdated casks. |
-| `bcubc` | `brew cask reinstall $(brew cask outdated) && brew cleanup` | Update outdated casks, then run cleanup. |
+| Alias | Command | Description |
+|----------|------------------------------------------------------------- |---------------------------------------------------------------------|
+| `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. |
+| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
+| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. |
+| `bubu` | `bubo && bubc` | Do the last two operations above. |
+| `buf` | `brew upgrade --formula` | Upgrade only formulas (not casks). |
+| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. |
+| `bcubc` | `brew cask reinstall $(brew outdated --cask) && brew cleanup` | Update outdated casks, then run cleanup. |
## Completion
diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh
index fdea76c74..30eb135bb 100644
--- a/plugins/brew/brew.plugin.zsh
+++ b/plugins/brew/brew.plugin.zsh
@@ -4,5 +4,6 @@ alias brewsp='brew list --pinned'
alias bubo='brew update && brew outdated'
alias bubc='brew upgrade && brew cleanup'
alias bubu='bubo && bubc'
-alias bcubo='brew update && brew cask outdated'
-alias bcubc='brew cask reinstall $(brew cask outdated) && brew cleanup'
+alias buf='brew upgrade --formula'
+alias bcubo='brew update && brew outdated --cask'
+alias bcubc='brew cask reinstall $(brew outdated --cask) && brew cleanup'
diff --git a/plugins/bundler/README.md b/plugins/bundler/README.md
index a3bceb0ae..7b79cbcdc 100644
--- a/plugins/bundler/README.md
+++ b/plugins/bundler/README.md
@@ -1,34 +1,48 @@
# Bundler
-- Adds completion for basic bundler commands
-
-- Adds short aliases for common bundler commands
- - `ba` aliased to `bundle add`
- - `be` aliased to `bundle exec`.
- It also supports aliases (if `rs` is `rails server`, `be rs` will bundle-exec `rails server`).
- - `bl` aliased to `bundle list`
- - `bp` aliased to `bundle package`
- - `bo` aliased to `bundle open`
- - `bout` aliased to `bundle outdated`
- - `bu` aliased to `bundle update`
- - `bi` aliased to `bundle install --jobs=<cpu core count>` (only for bundler `>= 1.4.0`)
- - `bcn` aliased to `bundle clean`
- - `bck` aliased to `bundle check`
-
-- Adds a wrapper for common gems:
- - Looks for a binstub under `./bin/` and executes it (if present)
- - Calls `bundle exec <gem executable>` otherwise
+This plugin adds completion for basic bundler commands, as well as aliases and helper functions for
+an easier experience with bundler.
+
+To use it, add `bundler` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... bundler)
+```
+
+## Aliases
+
+| Alias | Command | Description |
+|--------|--------------------------------------|------------------------------------------------------------------------------------------|
+| `ba` | `bundle add` | Add gem to the Gemfile and run bundle install |
+| `bck` | `bundle check` | Verifies if dependencies are satisfied by installed gems |
+| `bcn` | `bundle clean` | Cleans up unused gems in your bundler directory |
+| `be` | `bundle exec` | Execute a command in the context of the bundle |
+| `bi` | `bundle install --jobs=<core_count>` | Install the dependencies specified in your Gemfile (using all cores in bundler >= 1.4.0) |
+| `bl` | `bundle list` | List all the gems in the bundle |
+| `bo` | `bundle open` | Opens the source directory for a gem in your bundle |
+| `bout` | `bundle outdated` | List installed gems with newer versions available |
+| `bp` | `bundle package` | Package your needed .gem files into your application |
+| `bu` | `bundle update` | Update your gems to the latest available versions |
+
+## Gem wrapper
+
+The plugin adds a wrapper for common gems, which:
+
+- Looks for a binstub under `./bin/` and executes it if present.
+- Calls `bundle exec <gem>` otherwise.
Common gems wrapped by default (by name of the executable):
+
`annotate`, `cap`, `capify`, `cucumber`, `foodcritic`, `guard`, `hanami`, `irb`, `jekyll`, `kitchen`, `knife`, `middleman`, `nanoc`, `pry`, `puma`, `rackup`, `rainbows`, `rake`, `rspec`, `rubocop`, `shotgun`, `sidekiq`, `spec`, `spork`, `spring`, `strainer`, `tailor`, `taps`, `thin`, `thor`, `unicorn` and `unicorn_rails`.
-## Configuration
+### Settings
-Please use the exact name of the executable and not the gem name.
+You can add or remove gems from the list of wrapped commands.
+Please **use the exact name of the executable** and not the gem name.
-### Add additional gems to be wrapped
+#### Include gems to be wrapped (`BUNDLED_COMMANDS`)
-Add this before the plugin-list in your `.zshrc`:
+Add this before the plugin list in your `.zshrc`:
```sh
BUNDLED_COMMANDS=(rubocop)
@@ -37,10 +51,9 @@ plugins=(... bundler ...)
This will add the wrapper for the `rubocop` gem (i.e. the executable).
+#### Exclude gems from being wrapped (`UNBUNDLED_COMMANDS`)
-### Exclude gems from being wrapped
-
-Add this before the plugin-list in your `.zshrc`:
+Add this before the plugin list in your `.zshrc`:
```sh
UNBUNDLED_COMMANDS=(foreman spin)
@@ -49,13 +62,13 @@ plugins=(... bundler ...)
This will exclude the `foreman` and `spin` gems (i.e. their executable) from being wrapped.
-## Excluded gems
+### Excluded gems
-These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/ohmyzsh/ohmyzsh/pull/2923) on GitHub for clarification.
+These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/ohmyzsh/ohmyzsh/pull/2923) on GitHub for clarification:
-`berks`
-`foreman`
-`mailcatcher`
-`rails`
-`ruby`
-`spin`
+- `berks`
+- `foreman`
+- `mailcatcher`
+- `rails`
+- `ruby`
+- `spin`
diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh
index 65b0ffa6e..6293dc28a 100644
--- a/plugins/bundler/bundler.plugin.zsh
+++ b/plugins/bundler/bundler.plugin.zsh
@@ -1,13 +1,49 @@
+## Aliases
+
alias ba="bundle add"
+alias bck="bundle check"
+alias bcn="bundle clean"
alias be="bundle exec"
+alias bi="bundle_install"
alias bl="bundle list"
-alias bp="bundle package"
alias bo="bundle open"
alias bout="bundle outdated"
+alias bp="bundle package"
alias bu="bundle update"
-alias bi="bundle_install"
-alias bcn="bundle clean"
-alias bck="bundle check"
+
+## Functions
+
+bundle_install() {
+ # Bail out if bundler is not installed
+ if (( ! $+commands[bundle] )); then
+ echo "Bundler is not installed"
+ return 1
+ fi
+
+ # Bail out if not in a bundled project
+ if ! _within-bundled-project; then
+ echo "Can't 'bundle install' outside a bundled project"
+ return 1
+ fi
+
+ # Check the bundler version is at least 1.4.0
+ autoload -Uz is-at-least
+ local bundler_version=$(bundle version | cut -d' ' -f3)
+ if ! is-at-least 1.4.0 "$bundler_version"; then
+ bundle install "$@"
+ return $?
+ fi
+
+ # If bundler is at least 1.4.0, use all the CPU cores to bundle install
+ if [[ "$OSTYPE" = (darwin|freebsd)* ]]; then
+ local cores_num="$(sysctl -n hw.ncpu)"
+ else
+ local cores_num="$(nproc)"
+ fi
+ bundle install --jobs="$cores_num" "$@"
+}
+
+## Gem wrapper
bundled_commands=(
annotate
@@ -54,65 +90,41 @@ for cmd in $BUNDLED_COMMANDS; do
bundled_commands+=($cmd);
done
-## Functions
-
-bundle_install() {
- if ! _bundler-installed; then
- echo "Bundler is not installed"
- elif ! _within-bundled-project; then
- echo "Can't 'bundle install' outside a bundled project"
- else
- local bundler_version=`bundle version | cut -d' ' -f3`
- if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then
- if [[ "$OSTYPE" = (darwin|freebsd)* ]]
- then
- local cores_num="$(sysctl -n hw.ncpu)"
- else
- local cores_num="$(nproc)"
- fi
- bundle install --jobs=$cores_num $@
- else
- bundle install $@
- fi
- fi
-}
-
-_bundler-installed() {
- which bundle > /dev/null 2>&1
-}
-
+# Check if in the root or a subdirectory of a bundled project
_within-bundled-project() {
local check_dir="$PWD"
- while [ "$check_dir" != "/" ]; do
- [ -f "$check_dir/Gemfile" -o -f "$check_dir/gems.rb" ] && return
- check_dir="$(dirname $check_dir)"
+ while [[ "$check_dir" != "/" ]]; do
+ if [[ -f "$check_dir/Gemfile" || -f "$check_dir/gems.rb" ]]; then
+ return 0
+ fi
+ check_dir="${check_dir:h}"
done
- false
-}
-
-_binstubbed() {
- [ -f "./bin/${1}" ]
+ return 1
}
_run-with-bundler() {
- if _bundler-installed && _within-bundled-project; then
- if _binstubbed $1; then
- ./bin/${^^@}
- else
- bundle exec $@
- fi
+ if (( ! $+commands[bundle] )) || ! _within-bundled-project; then
+ "$@"
+ return $?
+ fi
+
+ if [[ -f "./bin/${1}" ]]; then
+ ./bin/${^^@}
else
- $@
+ bundle exec "$@"
fi
}
-## Main program
for cmd in $bundled_commands; do
- eval "function unbundled_$cmd () { $cmd \$@ }"
- eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}"
- alias $cmd=bundled_$cmd
+ # Create wrappers for bundled and unbundled execution
+ eval "function unbundled_$cmd () { \"$cmd\" \"\$@\"; }"
+ eval "function bundled_$cmd () { _run-with-bundler \"$cmd\" \"\$@\"; }"
+ alias "$cmd"="bundled_$cmd"
- if which _$cmd > /dev/null 2>&1; then
- compdef _$cmd bundled_$cmd=$cmd
+ # Bind completion function to wrapped gem if available
+ if (( $+functions[_$cmd] )); then
+ compdef "_$cmd" "bundled_$cmd"="$cmd"
fi
done
+
+unset cmd bundled_commands
diff --git a/plugins/cargo/_cargo b/plugins/cargo/_cargo
index 12694901e..ffc9fcdc8 100644
--- a/plugins/cargo/_cargo
+++ b/plugins/cargo/_cargo
@@ -12,8 +12,8 @@ _cargo() {
'(-q --quiet)*'{-v,--verbose}'[use verbose output]'
'(-q --quiet -v --verbose)'{-q,--quiet}'[no output printed to stdout]'
'-Z+[pass unstable (nightly-only) flags to cargo]: :_cargo_unstable_flags'
- '--frozen[require that Cargo.lock and cache are up-to-date]'
- '--locked[require that Cargo.lock is up-to-date]'
+ '--frozen[require that Cargo.lock and cache are up to date]'
+ '--locked[require that Cargo.lock is up to date]'
'--color=[specify colorization option]:coloring:(auto always never)'
'(- 1 *)'{-h,--help}'[show help message]'
)
diff --git a/plugins/chucknorris/fortunes/chucknorris b/plugins/chucknorris/fortunes/chucknorris
index 1f4ca7a60..0eb6e2e99 100644
--- a/plugins/chucknorris/fortunes/chucknorris
+++ b/plugins/chucknorris/fortunes/chucknorris
@@ -20,7 +20,7 @@ Aliens fear that Chuck Norris might abduct them.
%
An angry glare from Chuck Norris is known to kill on the spot.
%
-Behind every successful man is Chuck Norris
+Behind every successful man is Chuck Norris.
%
Beware of dogs... Dogs, beware of Chuck Norris.
%
@@ -34,25 +34,25 @@ Chuck Norris - the new standard.
%
Chuck Norris CAN balance the light-switch between ON and OFF.
%
-Chuck Norris CAN believe it's not butter
+Chuck Norris CAN believe it's not butter.
%
Chuck Norris CAN spell with an I before E even after C.
%
-Chuck Norris Can Play the Theme from the Twilight Zone with His Beard
+Chuck Norris can play the theme from the Twilight Zone with his beard.
%
-Chuck Norris Can Power Solar Panels. At Night.
+Chuck Norris can power solar panels. At night.
%
-Chuck Norris Watches "the Nat.Geo. Specials" on Discovery Channel
+Chuck Norris watches "the Nat.Geo. Specials" on Discovery Channel.
%
-Chuck Norris bowled a 301 after constructing another pin out of his beard hair
+Chuck Norris bowled a 301 after constructing another pin out of his beard hair.
%
Chuck Norris burnt a fire proof vest, UNDERWATER!
%
Chuck Norris can French kiss his elbow.
%
-Chuck Norris can bake in a Freezer.
+Chuck Norris can bake in a freezer.
%
-Chuck Norris can defuse bomb even if he cut the wrong wire
+Chuck Norris can defuse a bomb by cutting the wrong wire.
%
Chuck Norris can dig a hole in air.
%
@@ -60,19 +60,19 @@ Chuck Norris can divide by zero.
%
Chuck Norris can do a regime change with a roundhouse kick.
%
-Chuck Norris can fit 10 gallons of water in a 5 gallon water bucket
+Chuck Norris can fit 10 gallons of water in a 5 gallon bucket.
%
-Chuck Norris can grill a popsicle
+Chuck Norris can grill a popsicle.
%
Chuck Norris can lead a horse to water AND make it drink.
%
-Chuck Norris can make his own megazord "The Chuck Norris Roundhouse Kickers Ultimate Super Awesome Megazord"
+Chuck Norris can make his own megazord "The Chuck Norris Roundhouse Kickers Ultimate Super Awesome Megazord".
%
-Chuck Norris can milk an alligator
+Chuck Norris can milk an alligator.
%
Chuck Norris can play the death waltz with his chin.
%
-Chuck Norris can roundhouse kick someone through a window without breaking the glass
+Chuck Norris can roundhouse kick someone through a window without breaking the glass.
%
Chuck Norris can roundhouse-kick round houses into squares.
%
@@ -80,36 +80,30 @@ Chuck Norris can rub two fires together and make a stick!
%
Chuck Norris can see in 3D with just one eye.
%
-Chuck Norris can shoot a person 28 times with an unloaded gun.
-%
Chuck Norris can slam a revolving door.
%
Chuck Norris can terminate a repeating decimal.
%
-Chuck Norris can turn toast back into bread
+Chuck Norris can turn toast back into bread.
%
Chuck Norris can win a game of Connect Four in only three moves.
%
-Chuck Norris can win in a top spinning tournament with a cube
-%
-Chuck Norris can't get fired by Donald Trump
+Chuck Norris can win in a top spinning tournament with a cube.
%
-Chuck Norris can't perform Hadoukens, he IS a Hadouken
+Chuck Norris can't perform Hadoukens, he IS a Hadouken.
%
Chuck Norris checks under his bed for Fedor Emelianenko because he takes Fedor to the vet regularly.
%
Chuck Norris counted to infinity - twice.
%
-Chuck Norris created Heavy Metal when he was upset
+Chuck Norris created Heavy Metal when he was upset.
%
Chuck Norris does not get frostbite. Chuck Norris bites frost.
%
-Chuck Norris does not have a cell phone because he hears everything
+Chuck Norris does not have a cell phone because he hears everything.
%
Chuck Norris does not sleep. He waits.
%
-Chuck Norris does not teabag the ladies. He potato-sacks them.
-%
Chuck Norris doesn't bowl strikes, he just knocks down one pin and the other nine faint.
%
Chuck Norris doesn't call the wrong number, you just answer the wrong phone.
@@ -118,39 +112,31 @@ Chuck Norris doesn't cheat death, he beats it fair and square.
%
Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
%
-Chuck Norris doesn't eat, he just sucks the energy out of food by staring at it
+Chuck Norris doesn't eat, he just sucks the energy out of food by staring at it.
%
Chuck Norris doesn't exhale. The air runs desperately scared out of his lungs.
%
-Chuck Norris doesn't fight. He gives motivational seminars to die on their own to avoid a roundhouse kick to the face.
-%
Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
%
Chuck Norris doesn't let it go.
%
-Chuck Norris doesn't like Mudkipz
+Chuck Norris doesn't like Mudkipz.
%
Chuck Norris doesn't look for fun. The fun looks for Chuck Norris.
%
-Chuck Norris doesn't need a bulletproof vest to be bulletproof
-%
Chuck Norris doesn't need a bulletproof vest. He catches them with his bare hands.
%
-Chuck Norris doesn't need air, he is air
+Chuck Norris doesn't need air, he is air.
%
-Chuck Norris doesn't need sunglasses, the sun needs Chuck Norris glasses
+Chuck Norris doesn't need sunglasses, the sun needs Chuck Norris glasses.
%
Chuck Norris doesn't need to brush his teeth, his spit acts as a bleach.
%
Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
%
-Chuck Norris doesn't read. He just stares at the book until he gets the information he wants.
-%
Chuck Norris doesn't throw up if he drinks too much. Chuck Norris throws down!
%
-Chuck Norris doesn't brew up tea. He sucks the bag.
-%
-Chuck Norris doesn't eat salad, he eats vegetarians
+Chuck Norris doesn't eat salad, he eats vegetarians.
%
Chuck Norris doesn't wash his clothes, he disembowels them.
%
@@ -162,26 +148,22 @@ Chuck Norris drives an ice cream truck covered in human skulls.
%
Chuck Norris drowned a man ON LAND.
%
-Chuck Norris fed the Hunger Games
+Chuck Norris fed the Hunger Games.
%
Chuck Norris found the hay in the needle stack.
%
-Chuck Norris found the last digit of pie
+Chuck Norris found the last digit of pi.
%
-Chuck Norris had a knife thrown at him............ the knife didn't impale him, he impaled the knife
+Chuck Norris had a knife thrown at him. The knife didn't impale him; he impaled the knife.
%
Chuck Norris has a battle cruiser AND a car.
%
-Chuck Norris has killed the Dead Sea
-%
-Chuck Norris has made a 148 break a snooker.
+Chuck Norris has killed the Dead Sea.
%
-Chuck Norris has two speeds. Walk, and Kill.
+Chuck Norris has made a 148 break at snooker.
%
Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
%
-Chuck Norris is Chuck Norris
-%
Chuck Norris is allowed two carry-ons.
%
Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
@@ -192,13 +174,11 @@ Chuck Norris is entitled to his own facts.
%
Chuck Norris is my Homeboy.
%
-Chuck Norris is overra...
-%
Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
%
Chuck Norris is so hard, he uses diamonds as stress balls.
%
-Chuck Norris is so scary he makes Sharks swim backwards away from him
+Chuck Norris is so scary, he makes sharks swim backwards away from him.
%
Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
%
@@ -212,101 +192,81 @@ Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
%
Chuck Norris is the only one who can tear a facebook page!
%
-Chuck Norris is the reason that the world will end in 2012. He was getting bored with the Earth
+Chuck Norris is the reason that the world will end in 2012. He was getting bored with the Earth.
%
-Chuck Norris is the reason tumbleweeds tumble
+Chuck Norris is the reason tumbleweeds tumble.
%
Chuck Norris is the reason why Waldo is hiding.
%
Chuck Norris is waiting for Mt. St. Helens to erupt again. He's hoping the lava is hot enough to soften his beard so he can shave for the first time.
%
-Chuck Norris isn't allowed at the zoo because when he's there the animals are terriefied to come out their cages
-%
-Chuck Norris isn't appropriate...appropriate isn't Chuck Norris
-%
-Chuck Norris killed Kemper
-%
-Chuck Norris likes everyone on the earth, cause everyone he didn't like... Is dead...
+Chuck Norris isn't allowed at the zoo, because when he's there the animals are too terrified to come out of their cages.
%
Chuck Norris made a statue bleed.
%
-Chuck Norris made the big bang just by clicking his fingers
+Chuck Norris made the big bang just by clicking his fingers.
%
Chuck Norris never trains, because he's Chuck Norris.
%
-Chuck Norris once asked a man to turn down his music, he refused, that man's baby was born deaf.
-%
Chuck Norris once cried just to see what it was like. The end result was the creation of life.
%
Chuck Norris once cut a knife with a stick of butter.
%
-Chuck Norris once got a 200 yard punt return
+Chuck Norris once got a 200 yard punt return.
%
-Chuck Norris once had a pet monkey........his name was KING KONG
+Chuck Norris once had a pet monkey named KING KONG.
%
-Chuck Norris once had a street named after him. But the name removed at once, because nobody crosses Chuck Norris, and lives
+Chuck Norris once had a street named after him. The name removed at once, because nobody crosses Chuck Norris, and lives.
%
Chuck Norris once had a weak moment, just to know what it felt like.
%
-Chuck Norris once played Duck Duck Goose with a group of Kindergarteners. Only one kid made it to first grade
+Chuck Norris once played Duck Duck Goose with a group of Kindergarteners. Only one kid made it to first grade.
%
Chuck Norris once proved p^~p by induction on his beard hairs.
%
-Chuck Norris once punched the ground to stop an earthquake. The resulting aftershock caused the BP oil spill
+Chuck Norris once punched the ground to stop an earthquake. The resulting aftershock caused the BP oil spill.
%
Chuck Norris once round-house kicked a salesman. Over the phone.
%
-Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean.
-%
-Chuck Norris once rounhouse kicked a football ...... it is now considered as a planet
-%
-Chuck Norris once taught a class of martial arts.Unfortunately Chuck had forgiven to take elephant tranquilizers and killed every one just by saluting
+Chuck Norris once rounhouse kicked a football. The astronomical society now considers it a planet.
%
Chuck Norris once thought he was wrong. He was, however, mistaken.
%
-Chuck Norris once tried to teach a fat, stupid kid Martial Arts. Unsuccessfully. The kid grew up to be Steven Seagal.
-%
Chuck Norris once walked down a street with his fists in his pockets. He was then arrested for concealing two deadly weapons.
%
-Chuck Norris once won the tour de france riding a " big wheel"
+Chuck Norris once won the Tour de France riding a "big wheel".
%
Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch."
%
Chuck Norris owns all number 1 pencils.
%
-Chuck Norris pees Adamantium
+Chuck Norris pees Adamantium.
%
-Chuck Norris play's Texas hold em with Zeus, every second Wednesday of the month
+Chuck Norris plays Texas Hold'Em with Zeus, every second Wednesday of the month.
%
Chuck Norris played "Got your Nose" with Voldemort and won.
%
-Chuck Norris played the game of thrones and won
+Chuck Norris played the game of thrones and won.
%
-Chuck Norris protects his body guards.
+Chuck Norris protects his bodyguards.
%
Chuck Norris rolled a 20 on a 6 sided die.
%
Chuck Norris roundhouse kicks people in the face first and asks questions later.
%
-Chuck Norris sent a BBM to an iphone.
-%
-Chuck Norris shops at Sam's Club, but leaves without having his receipt checked
+Chuck Norris sent a BBM to an iPhone.
%
-Chuck Norris shot a man with a knife
+Chuck Norris shops at Sam's Club, but leaves without having his receipt checked.
%
-Chuck Norris sleeps in Seattle.
-%
-Chuck Norris splattered tiger blood and Adonis' dna on Charlie Sheen with 1 roundhouse kick!
+Chuck Norris splattered tiger blood and Adonis' DNA on Charlie Sheen with 1 roundhouse kick!
%
Chuck Norris started Chuck Norris.
%
-Chuck Norris starts his day with 6 live chickens two cows, three pigs and a boiling hot cup of pure fury
-%
-Chuck Norris thretened to kill Michael Jackson, MJ got so scared to turned white.
+Chuck Norris starts his day with 6 live chickens, two cows, three pigs, and a boiling hot cup of pure fury.
%
Chuck Norris told me to put this here.
%
-Chuck Norris uses a real mouse to move the cursor, type on the keyboard, write e-mails, code entire websites, use photoshop, bring coffee.
+Chuck Norris uses a real mouse to move the cursor, type on the keyboard, write e-mails, code entire websites, and make coffee.
%
Chuck Norris uses pepper spray to spice up his steaks.
%
@@ -322,21 +282,21 @@ Chuck Norris was the reason why the Great Wall of China was constructed. It fail
%
Chuck Norris was what Willis was talking about.
%
-Chuck Norris wasn't born on his birthday
+Chuck Norris wasn't born on his birthday.
%
-Chuck Norris watched the first steps on the moon... From his summer home on Mars
+Chuck Norris watched the first steps on the moon... from his summer home on Mars.
%
-Chuck Norris went up the creek without a paddle... or a canoe
+Chuck Norris went up the creek without a paddle... or a canoe.
%
Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
%
Chuck Norris wins NASCAR races with all right turns.
%
-Chuck Norris won a stepdance contest by standing on his hands
+Chuck Norris won a stepdance contest by standing on his hands.
%
-Chuck Norris yells at Drill Sergeants
+Chuck Norris yells at drill Sergeants.
%
-Chuck Norris' dog pick up after him.
+Chuck Norris' dog picks up after him.
%
Chuck Norris' films are factual documentaries.
%
@@ -346,55 +306,47 @@ Chuck Norris' glass is never half full or half empty. It stays full even after h
%
Chuck Norris' hand is the only hand that can beat a Royal Flush.
%
-Chuck Norris' personal airplane is called Air Force Chuck
+Chuck Norris' personal airplane is called Air Force Chuck.
%
Chuck Norris. Enough said.
%
-Chuck Norris: even Naruto can't believe it
+Chuck Norris: even Naruto can't believe it.
%
-Chunk Norris can make sour milk turn fresh
+Chunk Norris can make sour milk turn fresh.
%
-Contrary to popular beleif, Rome WAS built in a day, by Chuck Norris.
+Contrary to popular belief, Rome WAS built in a day, by Chuck Norris.
%
Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
%
-Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
+Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on Earth.
%
-Cops don't need a badges in their wallets but only a picture of Chuck Norris.
+Cops don't need badges in their wallets, but only a picture of Chuck Norris.
%
Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
%
-Dead bodies were found of people that are still alive. These people will cross Chuck Norris in the future and will be round-house kicked back in time.
-%
-Did you here about the boy who cried Chuck Norris?
-%
-Do you know why Chuck Norris didn't star in The Expandebles? Because all the others guys would have surrended at the beginning.
+Did you hear about the boy who cried Chuck Norris?
%
Dog the Bounty Hunter can't track Chuck Norris down.
%
-Don't get Chuck Norris angry, last time somebody did that Chuck Norris made the Grand Canyon.
-%
-During the Civil War Chuck Norris was a slave, his master would often beg him for mercy
+Don't get Chuck Norris angry. Last time somebody did that, Chuck Norris made the Grand Canyon.
%
Earth's rotation is purely governed by the direction that Chuck Norris is walking.
%
-Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming
+Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming.
%
-Every line in a Chuck Norris haiku is "A roundhouse kick to the face." And they all have the correct number of syllables.
+Every line in a Chuck Norris haiku is "A roundhouse kick to the face." And they all have the correct number of syllables.
%
-Every phobia known to man has a phobia of Chuck Norris
+Every phobia known to man has a phobia of Chuck Norris.
%
Every time there's an earthquake, you know Chuck Norris is hungry. The earthquake is caused by his stomach growling.
%
-Everyone is so scared of Chuck Norris that they kiss his arse by writing these facts, too right they should
-%
Evolution's driving mechanism is nature's desperate attempt to escape Chuck Norris.
%
-Fear of spiders is aracnaphobia, fear of tight spaces is chlaustraphobia, fear of Chuck Norris is called Logic
+Fear of spiders is arachnaphobia. Fear of tight spaces is claustrophobia. Fear of Chuck Norris is called Logic.
%
Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
%
-Ghosts can see Chuck Norris
+Ghosts can see Chuck Norris.
%
Guns don't kill people. Chuck Norris kills people.
%
@@ -404,55 +356,47 @@ If Chuck Norris were a calendar, every month would be named Chucktober, and ever
%
If Chuck Norris were to get into a fight with another Chuck Norris, Chuck Norris would win.
%
-If Chuck was ever captured, he could win a game of Russian Roulette with six bullets in the revolver, he would shoot everyone else!
-%
-If God doesn't know, Chuck does
+If God doesn't know, Chuck does.
%
-If Goliath listened to Chuck Norris he would have won.
+If Goliath listened to Chuck Norris, he would have won.
%
If at first you don't succeed, you're not Chuck Norris.
%
If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face.
%
-If you put in the correct cheat code in Halo 2, you can have Master Cheif play without his helmet; revealing to be Chuck Norris.
+If you put in the correct cheat code in Halo 2, you can have Master Chief play without his helmet, revealing himself to be Chuck Norris.
%
If you see a man in the street who looks like Chuck Norris, but isn't, run: you don't want to be caught in the resulting roundhouse kick to his face.
%
If you spell Chuck Norris in Scrabble, you win. Forever.
%
-In 1945 The US army asked if they could clone Chuck Norris. instead he said he could sort out the Japanese.
+In 1945 The US army asked if they could clone Chuck Norris. Instead he said he could sort out the Japanese.
%
-In Texas, there are five sizes for fountain drinks: small, medium, large, Texas sized, and Chuck Norris Sized. It is a cup made of a human skull.
+In Texas, there are five sizes for fountain drinks: small, medium, large, Texas sized, and Chuck Norris sized. It is a cup made of a human skull.
%
In a rain storm Chuck Norris stays dry. Rain drops are scared to hit him.
%
-In fine print on the last page of the Guinness Book of World Records it notes that all world records are held by Chuck Norris, and those listed in the book are simply the closest anyone else has ever gotten.
-%
In the back of the book of world records, it says "All records are held by Chuck Norris. The ones listed are in second place."
%
James Bond has a license to kill. He got it from Chuck Norris.
%
-Jedis are now taught to use the "Chuck"
+Jedis are now taught to use the "Chuck".
%
MacGyver immediately tried to make a bomb out of some Q-Tips and Gatorade, but Chuck Norris roundhouse-kicked him in the solar plexus. MacGyver promptly threw up his own heart.
%
Machiavelli said it is better to be feared than loved because he was inspired by Chuck Norris.
%
-May the Force be with Chuck Norris... for it's own good.
+May the Force be with Chuck Norris... for its own good.
%
Merlin was Chuck Norris' assistant.
%
-More of a question than a fact: in a fight between Chuck Norris and Gordan Freeman who would win?
-%
Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
%
-Note to everyone: Please do not give beans to Chuck Norris or do you want another atombomb on hiroshima?
-%
-Note to self: Don't be the cashier to tell Chuck Norris his coupons have expired.
+Note to self: Don't be the cashier to tell Chuck Norris his coupons have expired.
%
-On the keyboard there is no control button because Chuck Norris is always in control.
+Chuck Norris' keyboard has no control key. Chuck Norris is always in control.
%
-Once upon a time, Chuck Norris found himself in a town called Shit Creek.....He opened a Paddle Store.
+Once upon a time, Chuck Norris found himself in a town called Shit Creek. He opened a Paddle Store.
%
One glance from Chuck Norris and snow turns itself yellow.
%
@@ -472,11 +416,9 @@ Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
%
Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
%
-Simon doesn't say...Chuck Norris says.
+Simon doesn't say... Chuck Norris says.
%
-Since 1940, the year Chuck Norris was born, roundhouse-kick related deaths have increased 13,000 percent.?
-%
-Some boots were made for walking. Some boots may walk all over you, but Chuck Norris' boot walk THROUGH you.
+Some boots were made for walking. Some boots may walk all over you, but Chuck Norris' boots walk THROUGH you.
%
Some kids pee their name in snow. Chuck Norris pees his name in concrete.
%
@@ -486,9 +428,9 @@ Someone once videotaped Chuck Norris getting pissed off. It was called Walker: T
%
Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindess, and possibly foot sized brusies on the face.
%
-Taking Karate Lessons = $100, Buying MMA DVD's= $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS
+Taking Karate Lessons = $100, Buying MMA DVD's = $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS.
%
-That's not an eclipse....that's the sun hiding from Chuck Norris.
+That's not an eclipse. That's the sun hiding from Chuck Norris.
%
The Beatles are on iTunes because Chuck Norris bought a Mac.
%
@@ -498,29 +440,25 @@ The Earth was almost destroyed by a 50 km wide asteroid in 1984, but Chuck Norri
%
The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
%
-The Jone's are trying to keep up with Chuck Norris
+The Joneses are trying to keep up with Chuck Norris.
%
-The Matrix Trilogy would have ended on the first movie if Keanu Reeves said, “I know Chuck Norris.”
+The Matrix Trilogy would have ended on the first movie had Keanu Reeves said, “I know Chuck Norris.”
%
-The answer to life, the universe and everything isnt 42. It's Chuck Norris.
+The answer to life, the universe and everything isn't 42. It's Chuck Norris.
%
-The apple falls far from the tree, when a roundhouse kick is taken to the trunk.
+The apple falls far from the tree, when Chuck's roundhouse kick is taken to the trunk.
%
-The best part of waking up is not Folgers in your cup, it's knowing that Chuck Norris let you live.
+The best part of waking up is not Folgers in your cup. it's knowing that Chuck Norris let you live.
%
-The chief export of Chuck Norris is Pain.
+The chief export of Chuck Norris is pain.
%
The dictionary references Chuck Norris several times, he is metioned under Fear, Law, Order and Chucktatorship.
%
-The kids said when Chuck was eating Trix cereal ´´silly Chuck, Trix are for kids´´...what happened next?..............................Darfur happened.
-%
The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
%
The letters in Chuck Norris cannot be unscrambled.
%
-The meaning of life is Chuck Norris
-%
-The only place where the Starship Enterprise refuses to boldly go is Chuck Norris' planet...which is all of them.
+The only place where the Starship Enterprise refuses to boldly go is Chuck Norris' planet... which is all of them.
%
The only reason that USA lost the 2011 world cup to Japan is because Chuck Norris wasn't there.
%
@@ -528,21 +466,19 @@ The only sure things are Death and Taxes, and when Chuck Norris goes to work for
%
The only way sharks will come near CN underwater is when CN is inside of a cage.
%
-The only word that rhymes with orange is Chuck Norris
-%
-The planes in 9/11 were not hijacked. Chuck Norris was just playing with his old radio controller.
+The only word that rhymes with orange is Chuck Norris.
%
The producers of the movie "The Last Airbender" are now in talks with Chuck Norris in Order to star him in their next sequal "The Last Skull Bender".
%
The quickest way to a man's heart is with Chuck Norris' fist.
%
-The reason why batman only comes out at night is because he's afraid he might encounter Chuck Norris in the Morning and afternoon.
+The reason why Batman only comes out at night is because he's afraid he might encounter Chuck Norris in the morning and afternoon.
%
-The red phone in the oval office...Rings directly to Chuck Norris Cell Phone
+The red phone in the oval office rings directly to Chuck Norris' cell phone.
%
The show Survivor had the original premise of putting people on an island with Chuck Norris. There were no survivors, and nobody is brave enough to go to the island to retrieve the footage.
%
-The square root of Chuck Norris is pain. Do not try to square Chuck Norris. The result is death
+The square root of Chuck Norris is pain. Do not try to square Chuck Norris. The result is death.
%
The sun only rises every morning because Chuck Norris allows it to.
%
@@ -550,25 +486,17 @@ The truth hurts, doesn't it? Chuck Norris' truth kills.
%
There is no chin behind Chuck Norris' beard. There is only another fist.
%
-There is no chin behind Chuck Norris' beard. There is only another fist.
-%
-There is no limbo, only a world that doesn't know of Chuck Norris
-%
-There is no such thing as being hard its called the Chuck Norris factor.
+There is no limbo, only a world that doesn't know of Chuck Norris.
%
There is no such thing as global warming. Chuck Norris was cold, so he turned the sun up.
%
-There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
-%
-There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
-%
-They say death by a 1000 lashes was the most painful way to die, that was before they got roundhouse kicked in the face by Chuck Norris
+There is no theory of evolution, just a list of creatures Chuck Norris has allowed to live.
%
This one time at band camp... BAM! Chuck Norris.
%
Those who ignore history, are doomed by Chuck Norris.
%
-Trick me once, shame on you, trick Chuck Norris.....rest in peace.
+Trick me once, shame on you, trick Chuck Norris.. rest in peace.
%
Unlike Jack Bauer, Chuck Norris doesn't need bullets. A quick roundhouse to the face kills twice as fast.
%
@@ -580,7 +508,7 @@ Whatever Chuck Norris wants, it will instantly appear.
%
When Betty White gets angry, she turns into the Hulk. When Valerie Bertinelli gets mad, she turns into Chuck Norris.
%
-When Chuck Norris creates a login, it tells him "password not strong enough", he types in his name and it tells him "password too strong."
+When Chuck Norris creates a login, it tells him "password not strong enough." He types in his name and it tells him "password too strong."
%
When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
%
@@ -590,7 +518,7 @@ When Chuck Norris goes to Vegas, he doesn't have to gamble. The casinos just giv
%
When Chuck Norris goes to rodeos, bulls ride him.
%
-When Chuck Norris goes to the library, he looks for the guinness book of records in the comedy section.
+When Chuck Norris goes to the library, he looks for the Guinness book of records in the comedy section.
%
When Chuck Norris inhales helium, his voice doesn't change.
%
@@ -600,36 +528,32 @@ When Chuck Norris played the card game War with a friend, France surrendered.
%
When Chuck Norris pokes the Pillsbury Doughboy, it's not a laughing matter.
%
-When Chuck Norris roundhouse-kicks you HE decides when you will feel the impact .
+When Chuck Norris roundhouse-kicks you, he decides when you will feel the impact.
%
When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever.
%
-When Chuck Norris tosses a coin, it lands on both head and tail.
+When Chuck Norris tosses a coin, it lands on both heads and tails.
%
-When God said "Let there be light!", Chuck Norris said "Only for half the day
+When God said "Let there be light!", Chuck Norris said "Only for half the day."
%
-When President Roosevelt dropped the atomic bomb on Hiroshima, he did so only because it was more human then sending Chuck Norris.
-%
-When Presidents speak, their nation listens. When Chuck Norris blinks, the whole World listens.
+When Presidents speak, their nation listens. When Chuck Norris blinks, the whole world listens.
%
When Steven Seagal kills a ninja, he only takes its hide. When Chuck Norris kills a ninja, he uses every part.
%
When chuck Norris was in school, he made his PE teacher run laps.
%
-When does Chuck Norris run out of shotgun bullets?.....whenever he wants to.
+When does Chuck Norris run out of shotgun bullets? whenever he wants to.
%
When taking the SAT, write "Chuck Norris" for every answer. You will score over 8000.
%
When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
%
-When things go bump in the night.... it's Chuck Norris
+When things go bump in the night, it's Chuck Norris
%
-While visiting the hexagon, Chuck Norris was asked to demonstrate his famous roundhouse kick. Henceforth, it has been known as the Pentagon.
+While visiting the Hexagon, Chuck Norris was asked to demonstrate his famous roundhouse kick. Henceforth, it has been known as the Pentagon.
%
Why didn't the chicken cross the road? Because Chuck Norris got to it first.
%
-World War II began because Chuck Norris took a nap. When he woke up, Hitler found out and killed himself out of fear Chuck Norris would kill him.
-%
You know Chuck Norris' pet lizard, right? Last I heard, he was in the movie "Godzilla". Oh, and his pet turtle starred in "Gamera" as well.
%
http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one.
diff --git a/plugins/colored-man-pages/README.md b/plugins/colored-man-pages/README.md
index f34941e73..4cbf64d3e 100644
--- a/plugins/colored-man-pages/README.md
+++ b/plugins/colored-man-pages/README.md
@@ -16,3 +16,17 @@ You can also try to color other pages by prefixing the respective command with `
```zsh
colored git help clone
```
+
+## Customization
+
+The plugin declares global associative array `less_termcap`, which maps termcap capabilities to escape
+sequences for the `less` pager. This mapping can be further customized by the user after the plugin is
+loaded. Check out sources for more.
+
+For example: `less_termcap[md]` maps to `LESS_TERMCAP_md` which is the escape sequence that tells `less`
+how to print something in bold. It's currently shown in bold red, but if you want to change it, you
+can redefine `less_termcap[md]` in your zshrc file, after OMZ is sourced:
+
+```zsh
+less_termcap[md]="${fg_bold[blue]}" # this tells less to print bold text in bold blue
+```
diff --git a/plugins/colored-man-pages/colored-man-pages.plugin.zsh b/plugins/colored-man-pages/colored-man-pages.plugin.zsh
index ec518472c..37faed672 100644
--- a/plugins/colored-man-pages/colored-man-pages.plugin.zsh
+++ b/plugins/colored-man-pages/colored-man-pages.plugin.zsh
@@ -1,39 +1,48 @@
-if [[ "$OSTYPE" = solaris* ]]
-then
- if [[ ! -x "$HOME/bin/nroff" ]]
- then
- mkdir -p "$HOME/bin"
- cat > "$HOME/bin/nroff" <<EOF
-#!/bin/sh
-if [ -n "\$_NROFF_U" -a "\$1,\$2,\$3" = "-u0,-Tlp,-man" ]; then
- shift
- exec /usr/bin/nroff -u\$_NROFF_U "\$@"
-fi
-#-- Some other invocation of nroff
-exec /usr/bin/nroff "\$@"
-EOF
- chmod +x "$HOME/bin/nroff"
- fi
-fi
+# Requires colors autoload.
+# See termcap(5).
+
+# Set up once, and then reuse. This way it supports user overrides after the
+# plugin is loaded.
+typeset -AHg less_termcap
+
+# bold & blinking mode
+less_termcap[mb]="${fg_bold[red]}"
+less_termcap[md]="${fg_bold[red]}"
+less_termcap[me]="${reset_color}"
+# standout mode
+less_termcap[so]="${fg_bold[yellow]}${bg[blue]}"
+less_termcap[se]="${reset_color}"
+# underlining
+less_termcap[us]="${fg_bold[green]}"
+less_termcap[ue]="${reset_color}"
+
+# Absolute path to this file's directory.
+typeset __colored_man_pages_dir="${0:A:h}"
function colored() {
- command env \
- LESS_TERMCAP_mb=$(printf "\e[1;31m") \
- LESS_TERMCAP_md=$(printf "\e[1;31m") \
- LESS_TERMCAP_me=$(printf "\e[0m") \
- LESS_TERMCAP_se=$(printf "\e[0m") \
- LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
- LESS_TERMCAP_ue=$(printf "\e[0m") \
- LESS_TERMCAP_us=$(printf "\e[1;32m") \
- PAGER="${commands[less]:-$PAGER}" \
- _NROFF_U=1 \
- PATH="$HOME/bin:$PATH" \
- "$@"
+ local -a environment
+
+ # Convert associative array to plain array of NAME=VALUE items.
+ local k v
+ for k v in "${(@kv)less_termcap}"; do
+ environment+=( "LESS_TERMCAP_${k}=${v}" )
+ done
+
+ # Prefer `less` whenever available, since we specifically configured
+ # environment for it.
+ environment+=( PAGER="${commands[less]:-$PAGER}" )
+
+ # See ./nroff script.
+ if [[ "$OSTYPE" = solaris* ]]; then
+ environment+=( PATH="${__colored_man_pages_dir}:$PATH" )
+ fi
+
+ command env $environment "$@"
}
# Colorize man and dman/debman (from debian-goodies)
function man \
- dman \
- debman {
- colored $0 "$@"
+ dman \
+ debman {
+ colored $0 "$@"
}
diff --git a/plugins/colored-man-pages/nroff b/plugins/colored-man-pages/nroff
new file mode 100755
index 000000000..4ae155d29
--- /dev/null
+++ b/plugins/colored-man-pages/nroff
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# The whole point of this wrapper is to replace emboldening factor -u0 with
+# -u1 under certain circumstances on Solaris.
+
+if [ "$1,$2,$3" = "-u0,-Tlp,-man" ]; then
+ shift
+ exec /usr/bin/nroff -u1 "$@"
+else
+ # Some other invocation of nroff
+ exec /usr/bin/nroff "$@"
+fi
diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh
index 80b69190f..cb5ac36f5 100644
--- a/plugins/colorize/colorize.plugin.zsh
+++ b/plugins/colorize/colorize.plugin.zsh
@@ -6,7 +6,8 @@ alias cless="colorize_less"
ZSH_COLORIZE_PLUGIN_PATH=$0:A
colorize_check_requirements() {
- local available_tools=("chroma" "pygmentize")
+ local -a available_tools
+ available_tools=("chroma" "pygmentize")
if [ -z "$ZSH_COLORIZE_TOOL" ]; then
if (( $+commands[pygmentize] )); then
diff --git a/plugins/command-not-found/command-not-found.plugin.zsh b/plugins/command-not-found/command-not-found.plugin.zsh
index 81d76e638..aea1e1b4c 100644
--- a/plugins/command-not-found/command-not-found.plugin.zsh
+++ b/plugins/command-not-found/command-not-found.plugin.zsh
@@ -2,7 +2,22 @@
# as seen in https://www.porcheron.info/command-not-found-for-zsh/
# this is installed in Ubuntu
-[[ -e /etc/zsh_command_not_found ]] && source /etc/zsh_command_not_found
+if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
+ function command_not_found_handler {
+ # check because c-n-f could've been removed in the meantime
+ if [ -x /usr/lib/command-not-found ]; then
+ /usr/lib/command-not-found -- "$1"
+ return $?
+ elif [ -x /usr/share/command-not-found/command-not-found ]; then
+ /usr/share/command-not-found/command-not-found -- "$1"
+ return $?
+ else
+ printf "zsh: command not found: %s\n" "$1" >&2
+ return 127
+ fi
+ return 0
+ }
+fi
# Arch Linux command-not-found support, you must have package pkgfile installed
# https://wiki.archlinux.org/index.php/Pkgfile#.22Command_not_found.22_hook
@@ -10,13 +25,12 @@
# Fedora command-not-found support
if [ -f /usr/libexec/pk-command-not-found ]; then
- command_not_found_handler () {
+ command_not_found_handler() {
runcnf=1
retval=127
[ ! -S /var/run/dbus/system_bus_socket ] && runcnf=0
[ ! -x /usr/libexec/packagekitd ] && runcnf=0
- if [ $runcnf -eq 1 ]
- then
+ if [ $runcnf -eq 1 ]; then
/usr/libexec/pk-command-not-found $@
retval=$?
fi
@@ -32,7 +46,7 @@ fi
# NixOS command-not-found support
if [ -x /run/current-system/sw/bin/command-not-found ]; then
- command_not_found_handler () {
+ command_not_found_handler() {
/run/current-system/sw/bin/command-not-found $@
}
fi
diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh
index 231037a92..4e5ff848f 100644
--- a/plugins/common-aliases/common-aliases.plugin.zsh
+++ b/plugins/common-aliases/common-aliases.plugin.zsh
@@ -55,15 +55,15 @@ if is-at-least 4.2.0; then
# open browser on urls
if [[ -n "$BROWSER" ]]; then
_browser_fts=(htm html de org net com at cx nl se dk)
- for ft in $_browser_fts; do alias -s $ft=$BROWSER; done
+ for ft in $_browser_fts; do alias -s $ft='$BROWSER'; done
fi
_editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex)
- for ft in $_editor_fts; do alias -s $ft=$EDITOR; done
+ for ft in $_editor_fts; do alias -s $ft='$EDITOR'; done
if [[ -n "$XIVIEWER" ]]; then
_image_fts=(jpg jpeg png gif mng tiff tif xpm)
- for ft in $_image_fts; do alias -s $ft=$XIVIEWER; done
+ for ft in $_image_fts; do alias -s $ft='$XIVIEWER'; done
fi
_media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm)
diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh
index 330360cdd..75b03ffe7 100644
--- a/plugins/composer/composer.plugin.zsh
+++ b/plugins/composer/composer.plugin.zsh
@@ -51,6 +51,8 @@ alias cget='curl -s https://getcomposer.org/installer | php'
# Add Composer's global binaries to PATH, using Composer if available.
if (( $+commands[composer] )); then
+ autoload -Uz _store_cache _retrieve_cache
+
_retrieve_cache composer
if [[ -z $__composer_bin_dir ]]; then
diff --git a/plugins/docker/README.md b/plugins/docker/README.md
index 241a6a448..fab7aa8f1 100644
--- a/plugins/docker/README.md
+++ b/plugins/docker/README.md
@@ -10,3 +10,25 @@ plugins=(... docker)
A copy of the completion script from the docker/cli git repo:
https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker
+
+## Settings
+
+By default, the completion doesn't allow option-stacking, meaning if you try to
+complete `docker run -it <TAB>` it won't work, because you're _stacking_ the
+`-i` and `-t` options.
+
+[You can enable it](https://github.com/docker/cli/commit/b10fb43048) by **adding
+the lines below to your zshrc file**, but be aware of the side effects:
+
+> This enables Zsh to understand commands like `docker run -it
+> ubuntu`. However, by enabling this, this also makes Zsh complete
+> `docker run -u<tab>` with `docker run -uapprox` which is not valid. The
+> users have to put the space or the equal sign themselves before trying
+> to complete.
+>
+> Therefore, this behavior is disabled by default. To enable it:
+>
+> ```
+> zstyle ':completion:*:*:docker:*' option-stacking yes
+> zstyle ':completion:*:*:docker-*:*' option-stacking yes
+> ```
diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh
index db0ab13af..0b602d12a 100644
--- a/plugins/emacs/emacs.plugin.zsh
+++ b/plugins/emacs/emacs.plugin.zsh
@@ -26,6 +26,16 @@ if "$ZSH/tools/require_tool.sh" emacsclient 24 2>/dev/null ; then
# create a new X frame
alias eframe='emacsclient --alternate-editor "" --create-frame'
+ # Emacs ANSI Term tracking
+ if [[ -n "$INSIDE_EMACS" ]]; then
+ chpwd_emacs() { print -P "\033AnSiTc %d"; }
+ print -P "\033AnSiTc %d" # Track current working directory
+ print -P "\033AnSiTu %n" # Track username
+
+ # add chpwd hook
+ autoload -Uz add-zsh-hook
+ add-zsh-hook chpwd chpwd_emacs
+ fi
# Write to standard output the path to the file
# opened in the current buffer.
diff --git a/plugins/fzf/README.md b/plugins/fzf/README.md
index b3a434347..791a3eb6f 100644
--- a/plugins/fzf/README.md
+++ b/plugins/fzf/README.md
@@ -1,19 +1,52 @@
# fzf
-This plugin enables [junegunn's fzf](https://github.com/junegunn/fzf) fuzzy auto-completion and key bindings
+This plugin tries to find [junegunn's fzf](https://github.com/junegunn/fzf) based on where
+it's been installed, and enables its fuzzy auto-completion and key bindings.
+
+To use it, add `fzf` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... fzf)
+```
+
+## Settings
+
+All these settings should go in your zshrc file, before Oh My Zsh is sourced.
+
+### `FZF_BASE`
+
+Set to fzf installation directory path:
```zsh
-# Set fzf installation directory path
export FZF_BASE=/path/to/fzf/install/dir
+```
+
+### `FZF_DEFAULT_COMMAND`
+
+Set default command to use when input is tty:
-# Uncomment the following line to disable fuzzy completion
-# export DISABLE_FZF_AUTO_COMPLETION="true"
+```zsh
+export FZF_DEFAULT_COMMAND='<your fzf default commmand>'
+```
+
+If not set, the plugin will try to set it to these, in the order in which they're found:
-# Uncomment the following line to disable key bindings (CTRL-T, CTRL-R, ALT-C)
-# export DISABLE_FZF_KEY_BINDINGS="true"
+- [`rg`](https://github.com/BurntSushi/ripgrep)
+- [`fd`](https://github.com/sharkdp/fd)
+- [`ag`](https://github.com/ggreer/the_silver_searcher)
-plugins=(
- ...
- fzf
-)
+### `DISABLE_FZF_AUTO_COMPLETION`
+
+Set whether to load fzf auto-completion:
+
+```zsh
+DISABLE_FZF_AUTO_COMPLETION="true"
+```
+
+### `DISABLE_FZF_KEY_BINDINGS`
+
+Set whether to disable key bindings (CTRL-T, CTRL-R, ALT-C):
+
+```zsh
+DISABLE_FZF_KEY_BINDINGS="true"
```
diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh
index 53bdcbc97..524089983 100644
--- a/plugins/fzf/fzf.plugin.zsh
+++ b/plugins/fzf/fzf.plugin.zsh
@@ -1,9 +1,5 @@
function setup_using_base_dir() {
- # Declare all variables local not no mess with outside env in any way
- local fzf_base
- local fzf_shell
- local fzfdirs
- local dir
+ local fzf_base fzf_shell fzfdirs dir
test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
@@ -31,38 +27,37 @@ function setup_using_base_dir() {
fi
fi
- if [[ -d "${fzf_base}" ]]; then
- # Fix fzf shell directory for Arch Linux, NixOS or Void Linux packages
- if [[ ! -d "${fzf_base}/shell" ]]; then
- fzf_shell="${fzf_base}"
- else
- fzf_shell="${fzf_base}/shell"
- fi
+ if [[ ! -d "${fzf_base}" ]]; then
+ return 1
+ fi
- # Setup fzf binary path
- if ! (( ${+commands[fzf]} )) && [[ ! "$PATH" == *$fzf_base/bin* ]]; then
- export PATH="$PATH:$fzf_base/bin"
- fi
+ # Fix fzf shell directory for Arch Linux, NixOS or Void Linux packages
+ if [[ ! -d "${fzf_base}/shell" ]]; then
+ fzf_shell="${fzf_base}"
+ else
+ fzf_shell="${fzf_base}/shell"
+ fi
- # Auto-completion
- if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
- [[ $- == *i* ]] && source "${fzf_shell}/completion.zsh" 2> /dev/null
- fi
+ # Setup fzf binary path
+ if (( ! ${+commands[fzf]} )) && [[ "$PATH" != *$fzf_base/bin* ]]; then
+ export PATH="$PATH:$fzf_base/bin"
+ fi
- # Key bindings
- if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then
- source "${fzf_shell}/key-bindings.zsh"
- fi
- else
- return 1
+ # Auto-completion
+ if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
+ source "${fzf_shell}/completion.zsh" 2> /dev/null
+ fi
+
+ # Key bindings
+ if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then
+ source "${fzf_shell}/key-bindings.zsh"
fi
}
function setup_using_debian_package() {
- (( $+commands[dpkg] )) && dpkg -s fzf &> /dev/null
- if (( $? )); then
- # Either not a debian based distro, or no fzf installed. In any case skip ahead
+ if (( ! $+commands[dpkg] )) || ! dpkg -s fzf &>/dev/null; then
+ # Either not a debian based distro, or no fzf installed
return 1
fi
@@ -76,8 +71,8 @@ function setup_using_debian_package() {
local key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh"
# Auto-completion
- if [[ $- == *i* ]] && [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
- source $completions 2> /dev/null
+ if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
+ source $completions 2> /dev/null
fi
# Key bindings
@@ -88,13 +83,81 @@ function setup_using_debian_package() {
return 0
}
+function setup_using_opensuse_package() {
+ # OpenSUSE installs fzf in /usr/bin/fzf
+ # If the command is not found, the package isn't installed
+ (( $+commands[fzf] )) || return 1
+
+ # The fzf-zsh-completion package installs the auto-completion in
+ local completions="/usr/share/zsh/site-functions/_fzf"
+ # The fzf-zsh-completion package installs the key-bindings file in
+ local key_bindings="/etc/zsh_completion.d/fzf-key-bindings"
+
+ # If these are not found: (1) maybe we're not on OpenSUSE, or
+ # (2) maybe the fzf-zsh-completion package isn't installed.
+ if [[ ! -f "$completions" || ! -f "$key_bindings" ]]; then
+ return 1
+ fi
+
+ # Auto-completion
+ if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
+ source "$completions" 2>/dev/null
+ fi
+
+ # Key bindings
+ if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then
+ source "$key_bindings" 2>/dev/null
+ fi
+
+ return 0
+}
+
+function setup_using_openbsd_package() {
+ # openBSD installs fzf in /usr/local/bin/fzf
+ if [[ "$OSTYPE" != openbsd* ]] || (( ! $+commands[fzf] )); then
+ return 1
+ fi
+
+ # The fzf package installs the auto-completion in
+ local completions="/usr/local/share/zsh/site-functions/_fzf_completion"
+ # The fzf package installs the key-bindings file in
+ local key_bindings="/usr/local/share/zsh/site-functions/_fzf_key_bindings"
+
+ # Auto-completion
+ if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
+ source "$completions" 2>/dev/null
+ fi
+
+ # Key bindings
+ if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then
+ source "$key_bindings" 2>/dev/null
+ fi
+
+ return 0
+}
+
function indicate_error() {
- print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\
- "Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2
+ cat >&2 <<EOF
+[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.
+Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc
+EOF
}
-# Check for debian package first, because it easy to short cut
# Indicate to user that fzf installation not found if nothing worked
-setup_using_debian_package || setup_using_base_dir || indicate_error
-
-unset -f setup_using_debian_package setup_using_base_dir indicate_error
+setup_using_openbsd_package \
+ || setup_using_debian_package \
+ || setup_using_opensuse_package \
+ || setup_using_base_dir \
+ || indicate_error
+
+unset -f setup_using_opensuse_package setup_using_debian_package setup_using_base_dir indicate_error
+
+if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
+ if (( $+commands[rg] )); then
+ export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"'
+ elif (( $+commands[fd] )); then
+ export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
+ elif (( $+commands[ag] )); then
+ export FZF_DEFAULT_COMMAND='ag -l --hidden -g "" --ignore .git'
+ fi
+fi
diff --git a/plugins/git-auto-fetch/README.md b/plugins/git-auto-fetch/README.md
index 35f3c2f71..e96ab42a3 100644
--- a/plugins/git-auto-fetch/README.md
+++ b/plugins/git-auto-fetch/README.md
@@ -1,26 +1,29 @@
# Git auto-fetch
-Automatically fetches all changes from all remotes while you are working in git-initialized directory.
+Automatically fetches all changes from all remotes while you are working in a git-initialized directory.
-#### Usage
-
-Add `git-auto-fetch` to the plugins array in your zshrc file:
+To use it, add `git-auto-fetch` to the plugins array in your zshrc file:
```shell
plugins=(... git-auto-fetch)
```
-Every time you launch a command in your shell all remotes will be fetched in background.
-By default autofetch will be triggered only if last fetch was done at least 60 seconds ago.
-You can change fetch interval in your .zshrc:
-```
-GIT_AUTO_FETCH_INTERVAL=1200 #in seconds
+## Usage
+
+Every time the command prompt is shown all remotes will be fetched in the background. By default,
+`git-auto-fetch` will be triggered only if the last auto-fetch was done at least 60 seconds ago.
+You can change the fetch interval in your .zshrc:
+
+```sh
+GIT_AUTO_FETCH_INTERVAL=1200 # in seconds
```
-Log of `git fetch --all` will be saved into `.git/FETCH_LOG`
+A log of `git fetch --all` will be saved in `.git/FETCH_LOG`.
+
+## Toggle auto-fetch per folder
-#### Toggle auto fetch per folder
-If you are using mobile connection or for any other reason you can disable git-auto-fetch for any folder:
+If you are using a mobile connection or for any other reason you can disable git-auto-fetch
+for any folder:
```shell
$ cd to/your/project
@@ -29,3 +32,19 @@ disabled
$ git-auto-fetch
enabled
```
+
+## Caveats
+
+Automatically fetching all changes defeats the purpose of `git push --force-with-lease`,
+and makes it behave like `git push --force` in some cases. For example:
+
+Consider that you made some changes and possibly rebased some stuff, which means you'll
+need to use `--force-with-lease` to overwrite the remote history of a branch. Between the
+time when you make the changes (maybe do a `git log`) and the time when you `git push`,
+it's possible that someone else updates the branch you're working on.
+
+If `git-auto-fetch` triggers then, you'll have fetched the remote changes without knowing
+it, and even though you're running the push with `--force-with-lease`, git will overwrite
+the recent changes because you already have them in your local repository. The
+[`git push --force-with-lease` docs](https://git-scm.com/docs/git-push) talk about possible
+solutions to this problem.
diff --git a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
index 5c42c21a7..0da84f2f5 100644
--- a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
+++ b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
@@ -1,36 +1,61 @@
-GIT_AUTO_FETCH_INTERVAL=${GIT_AUTO_FETCH_INTERVAL:=60}
+# Default auto-fetch interval: 60 seconds
+: ${GIT_AUTO_FETCH_INTERVAL:=60}
+
+# Necessary for the git-fetch-all function
+zmodload zsh/datetime zsh/stat
function git-fetch-all {
- (`command git rev-parse --is-inside-work-tree 2>/dev/null` &&
- dir=`command git rev-parse --git-dir` &&
- [[ ! -f $dir/NO_AUTO_FETCH ]] &&
- (( `date +%s` - `date -r $dir/FETCH_LOG +%s 2>/dev/null || echo 0` > $GIT_AUTO_FETCH_INTERVAL )) &&
- GIT_SSH_COMMAND="command ssh -o BatchMode=yes" \
- command git fetch --all 2>/dev/null &>! $dir/FETCH_LOG &)
+ (
+ # Get git root directory
+ if ! gitdir="$(command git rev-parse --git-dir 2>/dev/null)"; then
+ return 0
+ fi
+
+ # Do nothing if auto-fetch disabled
+ if [[ -z "$gitdir" || -f "$gitdir/NO_AUTO_FETCH" ]]; then
+ return 0
+ fi
+
+ # Get time (seconds) when auto-fetch was last run
+ lastrun="$(zstat +mtime "$gitdir/FETCH_LOG" 2>/dev/null || echo 0)"
+ # Do nothing if not enough time has passed since last auto-fetch
+ if (( EPOCHSECONDS - lastrun < $GIT_AUTO_FETCH_INTERVAL )); then
+ return 0
+ fi
+
+ # Fetch all remotes (avoid ssh passphrase prompt)
+ GIT_SSH_COMMAND="command ssh -o BatchMode=yes" \
+ command git fetch --all 2>/dev/null &>! "$gitdir/FETCH_LOG"
+ ) &|
}
function git-auto-fetch {
- `command git rev-parse --is-inside-work-tree 2>/dev/null` || return
- guard="`command git rev-parse --git-dir`/NO_AUTO_FETCH"
+ # Do nothing if not in a git repository
+ command git rev-parse --is-inside-work-tree &>/dev/null || return 0
- (rm $guard 2>/dev/null &&
- echo "${fg_bold[green]}enabled${reset_color}") ||
- (touch $guard &&
- echo "${fg_bold[red]}disabled${reset_color}")
+ # Remove or create guard file depending on its existence
+ local guard="$(command git rev-parse --git-dir)/NO_AUTO_FETCH"
+ if [[ -f "$guard" ]]; then
+ command rm "$guard" && echo "${fg_bold[green]}enabled${reset_color}"
+ else
+ command touch "$guard" && echo "${fg_bold[red]}disabled${reset_color}"
+ fi
}
-# Override zle-line-init if it exists
-if (( $+functions[zle-line-init] )); then
- eval "override-git-auto-fetch-$(declare -f zle-line-init)"
-
- function zle-line-init () {
- git-fetch-all
- override-git-auto-fetch-zle-line-init
- }
-else
- function zle-line-init () {
- git-fetch-all
- }
-fi
-
-zle -N zle-line-init
+# zle-line-init widget (don't redefine if already defined)
+(( ! ${+functions[_git-auto-fetch_zle-line-init]} )) || return 0
+
+case "$widgets[zle-line-init]" in
+ # Simply define the function if zle-line-init doesn't yet exist
+ builtin|"") function _git-auto-fetch_zle-line-init() {
+ git-fetch-all
+ } ;;
+ # Override the current zle-line-init widget, calling the old one
+ user:*) zle -N _git-auto-fetch_orig_zle-line-init "${widgets[zle-line-init]#user:}"
+ function _git-auto-fetch_zle-line-init() {
+ git-fetch-all
+ zle _git-auto-fetch_orig_zle-line-init -- "$@"
+ } ;;
+esac
+
+zle -N zle-line-init _git-auto-fetch_zle-line-init
diff --git a/plugins/git-lfs/README.md b/plugins/git-lfs/README.md
new file mode 100644
index 000000000..1222b2767
--- /dev/null
+++ b/plugins/git-lfs/README.md
@@ -0,0 +1,24 @@
+# git lfs plugin
+
+The git lfs plugin provides [aliases](#aliases) and [functions](#functions) for [git-lfs](https://github.com/git-lfs/git-lfs).
+
+To use it, add `git-lfs` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... git-lfs)
+```
+
+## Aliases
+
+| Alias | Command |
+| :------- | :---------------------------------- |
+| `glfsi` | `git lfs install` |
+| `glfst` | `git lfs track` |
+| `glfsls` | `git lfs ls-files` |
+| `glfsmi` | `git lfs migrate import --include=` |
+
+## Functions
+
+| Function | Command |
+| :------- | :---------------------------------------------- |
+| `gplfs` | `git lfs push origin "$(current_branch)" --all` |
diff --git a/plugins/git-lfs/git-lfs.plugin.zsh b/plugins/git-lfs/git-lfs.plugin.zsh
new file mode 100644
index 000000000..e7bb67603
--- /dev/null
+++ b/plugins/git-lfs/git-lfs.plugin.zsh
@@ -0,0 +1,17 @@
+#
+# Aliases
+#
+
+alias glfsi='git lfs install'
+alias glfst='git lfs track'
+alias glfsls='git lfs ls-files'
+alias glfsmi='git lfs migrate import --include='
+
+#
+# Functions
+#
+
+function gplfs() {
+ local b="$(git_current_branch)"
+ git lfs push origin "$b" --all
+}
diff --git a/plugins/git-prompt/README.md b/plugins/git-prompt/README.md
index e3b2d623a..83948f536 100644
--- a/plugins/git-prompt/README.md
+++ b/plugins/git-prompt/README.md
@@ -11,6 +11,9 @@ plugins=(... git-prompt)
See the [original repository](https://github.com/olivierverdier/zsh-git-prompt).
+## Prerequisites
+This plugin uses `python`, so your host needs to have it installed
+
## Examples
The prompt may look like the following:
diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py
index 300365d71..bf3173614 100644
--- a/plugins/git-prompt/gitstatus.py
+++ b/plugins/git-prompt/gitstatus.py
@@ -11,11 +11,11 @@ def get_tagname_or_hash():
"""return tagname if exists else hash"""
# get hash
hash_cmd = ['git', 'rev-parse', '--short', 'HEAD']
- hash_ = check_output(hash_cmd).strip()
+ hash_ = check_output(hash_cmd).decode('utf-8').strip()
# get tagname
tags_cmd = ['git', 'for-each-ref', '--points-at=HEAD', '--count=2', '--sort=-version:refname', '--format=%(refname:short)', 'refs/tags']
- tags = check_output(tags_cmd).split()
+ tags = check_output(tags_cmd).decode('utf-8').split()
if tags:
return tags[0] + ('+' if len(tags) > 1 else '')
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
index 5a9ccff5c..e32136f15 100644
--- a/plugins/git/git.plugin.zsh
+++ b/plugins/git/git.plugin.zsh
@@ -1,3 +1,7 @@
+# Git version checking
+autoload -Uz is-at-least
+git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
+
#
# Functions
#
@@ -27,11 +31,15 @@ function work_in_progress() {
# Check if main exists and use instead of master
function git_main_branch() {
- if [[ -n "$(git branch --list main)" ]]; then
- echo main
- else
- echo master
- fi
+ command git rev-parse --git-dir &>/dev/null || return
+ local branch
+ for branch in main trunk; do
+ if command git show-ref -q --verify refs/heads/$branch; then
+ echo $branch
+ return
+ fi
+ done
+ echo master
}
#
@@ -104,7 +112,10 @@ function gdv() { git diff -w "$@" | view - }
compdef _git gdv=git-diff
alias gf='git fetch'
-alias gfa='git fetch --all --prune'
+# --jobs=<n> was added in git 2.8
+is-at-least 2.8 "$git_version" \
+ && alias gfa='git fetch --all --prune --jobs=10' \
+ || alias gfa='git fetch --all --prune'
alias gfo='git fetch origin'
alias gfg='git ls-files | grep'
@@ -240,8 +251,7 @@ alias gss='git status -s'
alias gst='git status'
# use the default stash push on git 2.13 and newer
-autoload -Uz is-at-least
-is-at-least 2.13 "$(git --version 2>/dev/null | awk '{print $3}')" \
+is-at-least 2.13 "$git_version" \
&& alias gsta='git stash push' \
|| alias gsta='git stash save'
@@ -291,3 +301,5 @@ function grename() {
git push --set-upstream origin "$2"
fi
}
+
+unset git_version
diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git
index 78a6dbb3d..988f5b1c6 100644
--- a/plugins/gitfast/_git
+++ b/plugins/gitfast/_git
@@ -2,25 +2,24 @@
# zsh completion wrapper for git
#
-# Copyright (c) 2012-2013 Felipe Contreras <felipe.contreras@gmail.com>
+# Copyright (c) 2012-2020 Felipe Contreras <felipe.contreras@gmail.com>
#
-# You need git's bash completion script installed somewhere, by default it
-# would be the location bash-completion uses.
+# The recommended way to install this script is to make a copy of it as a
+# file named '_git' inside any directory in your fpath.
#
-# If your script is somewhere else, you can configure it on your ~/.zshrc:
+# For example, create a directory '~/.zsh/', copy this file to '~/.zsh/_git',
+# and then add the following to your ~/.zshrc file:
#
-# zstyle ':completion:*:*:git:*' script ~/.git-completion.zsh
+# fpath=(~/.zsh $fpath)
#
-# The recommended way to install this script is to copy to '~/.zsh/_git', and
-# then add the following to your ~/.zshrc file:
+# You need git's bash completion script installed. By default bash-completion's
+# location will be used (e.g. pkg-config --variable=completionsdir bash-completion).
+#
+# If your bash completion script is somewhere else, you can specify the
+# location in your ~/.zshrc:
+#
+# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
#
-# fpath=(~/.zsh $fpath)
-
-complete ()
-{
- # do nothing
- return 0
-}
zstyle -T ':completion:*:*:git:*' tag-order && \
zstyle ':completion:*:*:git:*' tag-order 'common-commands'
@@ -28,18 +27,32 @@ zstyle -T ':completion:*:*:git:*' tag-order && \
zstyle -s ":completion:*:*:git:*" script script
if [ -z "$script" ]; then
local -a locations
- local e
+ local e bash_completion
+
+ bash_completion=$(pkg-config --variable=completionsdir bash-completion 2>/dev/null) ||
+ bash_completion='/usr/share/bash-completion/completions/'
+
locations=(
- "$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash"
- '/etc/bash_completion.d/git' # fedora, old debian
- '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
- '/usr/share/bash-completion/git' # gentoo
+ "$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
+ "$HOME/.local/share/bash-completion/completions/git"
+ "$bash_completion/git"
+ '/etc/bash_completion.d/git' # old debian
)
for e in $locations; do
test -f $e && script="$e" && break
done
fi
-ZSH_VERSION='' . "$script"
+
+local old_complete="$functions[complete]"
+functions[complete]=:
+COMP_WORDBREAKS=':'
+GIT_SOURCING_ZSH_COMPLETION=y . "$script"
+functions[complete]="$old_complete"
+
+__gitcompadd ()
+{
+ compadd -Q -p "${2-}" -S "${3- }" ${@[4,-1]} -- ${=1} && _ret=0
+}
__gitcomp ()
{
@@ -47,59 +60,85 @@ __gitcomp ()
local cur_="${3-$cur}"
- case "$cur_" in
- --*=)
- ;;
- *)
- local c IFS=$' \t\n'
- local -a array
- for c in ${=1}; do
- c="$c${4-}"
+ [[ "$cur_" == *= ]] && return
+
+ local c IFS=$' \t\n' sfx
+ for c in ${=1}; do
+ if [[ $c == "--" ]]; then
+ [[ "$cur_" == --no-* ]] && continue
+ __gitcompadd "--no-..."
+ break
+ fi
+
+ if [[ -z "${4-}" ]]; then
case $c in
- --*=*|*.) ;;
- *) c="$c " ;;
+ *=) c="${c%=}"; sfx="=" ;;
+ *.) sfx="" ;;
+ *) sfx=" " ;;
esac
- array+=("$c")
- done
- compset -P '*[=:]'
- compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
- ;;
- esac
+ else
+ sfx="$4"
+ fi
+ __gitcompadd "$c" "${2-}" "$sfx" -q
+ done
}
-__gitcomp_direct ()
+__gitcomp_nl ()
{
emulate -L zsh
- local IFS=$'\n'
- compset -P '*[=:]'
- compadd -Q -- ${=1} && _ret=0
+ IFS=$'\n' __gitcompadd "$1" "${2-}" "${4- }"
}
-__gitcomp_nl ()
+__gitcomp_file ()
{
emulate -L zsh
- local IFS=$'\n'
- compset -P '*[=:]'
- compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
+ compadd -f -p "${2-}" -- ${(f)1} && _ret=0
+}
+
+__gitcomp_direct ()
+{
+ __gitcomp_nl "$1" "" "" ""
+}
+
+__gitcomp_file_direct ()
+{
+ __gitcomp_file "$1" ""
}
__gitcomp_nl_append ()
{
- emulate -L zsh
+ __gitcomp_nl "$@"
+}
+
+__gitcomp_direct_append ()
+{
+ __gitcomp_direct "$@"
+}
- local IFS=$'\n'
- compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
+_git_zsh ()
+{
+ __gitcomp "v1.2"
}
-__gitcomp_file ()
+__git_complete_command ()
{
emulate -L zsh
- local IFS=$'\n'
compset -P '*[=:]'
- compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
+
+ local command="$1"
+ local completion_func="_git_${command//-/_}"
+ if (( $+functions[$completion_func] )); then
+ emulate ksh -c $completion_func
+ return 0
+ elif emulate ksh -c "__git_support_parseopt_helper $command"; then
+ emulate ksh -c "__git_complete_common $command"
+ return 0
+ else
+ return 1
+ fi
}
__git_zsh_bash_func ()
@@ -108,14 +147,12 @@ __git_zsh_bash_func ()
local command=$1
- local completion_func="_git_${command//-/_}"
- declare -f $completion_func >/dev/null && $completion_func && return
+ __git_complete_command "$command" && return
local expansion=$(__git_aliased_command "$command")
if [ -n "$expansion" ]; then
words[1]=$expansion
- completion_func="_git_${expansion//-/_}"
- declare -f $completion_func >/dev/null && $completion_func
+ __git_complete_command "$expansion"
fi
}
@@ -140,9 +177,11 @@ __git_zsh_cmd_common ()
push:'update remote refs along with associated objects'
rebase:'forward-port local commits to the updated upstream head'
reset:'reset current HEAD to the specified state'
+ restore:'restore working tree files'
rm:'remove files from the working tree and from the index'
show:'show various types of objects'
status:'show the working tree status'
+ switch:'switch branches'
tag:'create, list, delete or verify a tag object signed with GPG')
_describe -t common-commands 'common commands' list && _ret=0
}
@@ -150,8 +189,9 @@ __git_zsh_cmd_common ()
__git_zsh_cmd_alias ()
{
local -a list
- list=(${${${(0)"$(git config -z --get-regexp '^alias\.')"}#alias.}%$'\n'*})
- _describe -t alias-commands 'aliases' list $* && _ret=0
+ list=(${${(0)"$(git config -z --get-regexp '^alias\.*')"}#alias.})
+ list=(${(f)"$(printf "%s:alias for '%s'\n" ${(f@)list})"})
+ _describe -t alias-commands 'aliases' list && _ret=0
}
__git_zsh_cmd_all ()
@@ -166,33 +206,43 @@ __git_zsh_main ()
{
local curcontext="$curcontext" state state_descr line
typeset -A opt_args
- local -a orig_words
+ local -a orig_words __git_C_args
orig_words=( ${words[@]} )
_arguments -C \
- '(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
- '(-p --paginate)--no-pager[do not pipe git output into a pager]' \
- '--git-dir=-[set the path to the repository]: :_directories' \
- '--bare[treat the repository as a bare repository]' \
+ '(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
+ '(-p --paginate -P --no-pager)'{-P,--no-pager}'[do not pipe git output into a pager]' \
+ '(--bare)--git-dir=[set the path to the repository]: :_directories' \
+ '(--git-dir)--bare[treat the repository as a bare repository]' \
'(- :)--version[prints the git suite version]' \
- '--exec-path=-[path to where your core git programs are installed]:: :_directories' \
- '--html-path[print the path where git''s HTML documentation is installed]' \
- '--info-path[print the path where the Info files are installed]' \
- '--man-path[print the manpath (see `man(1)`) for the man pages]' \
- '--work-tree=-[set the path to the working tree]: :_directories' \
- '--namespace=-[set the git namespace]' \
+ '--exec-path=[path to where your core git programs are installed]: :_directories' \
+ '(- :)--exec-path[print the path where your core git programs are installed]' \
+ '(- :)--html-path[print the path where git''s HTML documentation is installed]' \
+ '(- :)--info-path[print the path where the Info files are installed]' \
+ '(- :)--man-path[print the manpath (see `man(1)`) for the man pages]' \
+ '--work-tree=[set the path to the working tree]: :_directories' \
+ '--namespace=[set the git namespace]:' \
'--no-replace-objects[do not use replacement refs to replace git objects]' \
'(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \
+ '*-C[run as if git was started in the given path]: :_directories' \
+ '*-c[pass a configuration parameter to the command]: :->config' \
'(-): :->command' \
'(-)*:: :->arg' && return
case $state in
(command)
- _alternative \
- 'alias-commands:alias:__git_zsh_cmd_alias' \
- 'common-commands:common:__git_zsh_cmd_common' \
- 'all-commands:all:__git_zsh_cmd_all' && _ret=0
+ _tags common-commands alias-commands all-commands
+ while _tags; do
+ _requested common-commands && __git_zsh_cmd_common
+ _requested alias-commands && __git_zsh_cmd_alias
+ _requested all-commands && __git_zsh_cmd_all
+ let _ret || break
+ done
+ ;;
+ (config)
+ compset -P '*[=:]'
+ emulate ksh -c __git_complete_config_variable_name_and_value
;;
(arg)
local command="${words[1]}" __git_dir
@@ -200,9 +250,13 @@ __git_zsh_main ()
if (( $+opt_args[--bare] )); then
__git_dir='.'
else
- __git_dir=${opt_args[--git-dir]}
+ __git_dir=${~opt_args[--git-dir]}
fi
+ for x in ${(s.:.)opt_args[-C]}; do
+ __git_C_args+=('-C' ${~x})
+ done
+
(( $+opt_args[--help] )) && command='help'
words=( ${orig_words[@]} )
@@ -227,6 +281,8 @@ _git ()
emulate ksh -c __${service}_main
elif (( $+functions[_${service}] )); then
emulate ksh -c _${service}
+ elif (( $+functions[_${service//-/_}] )); then
+ emulate ksh -c _${service//-/_}
fi
let _ret && _default && _ret=0
diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash
index b6ff5dc08..4497a294f 100644
--- a/plugins/gitfast/git-completion.bash
+++ b/plugins/gitfast/git-completion.bash
@@ -29,25 +29,28 @@
# tell the completion to use commit completion. This also works with aliases
# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '".
#
+# Compatible with bash 3.2.57.
+#
# You can set the following environment variables to influence the behavior of
# the completion routines:
#
# GIT_COMPLETION_CHECKOUT_NO_GUESS
#
# When set to "1", do not include "DWIM" suggestions in git-checkout
-# completion (e.g., completing "foo" when "origin/foo" exists).
-
-case "$COMP_WORDBREAKS" in
-*:*) : great ;;
-*) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
-esac
+# and git-switch completion (e.g., completing "foo" when "origin/foo"
+# exists).
+#
+# GIT_COMPLETION_SHOW_ALL
+#
+# When set to "1" suggest all options, including options which are
+# typically hidden (e.g. '--allow-empty' for 'git commit').
# Discovers the path to the git repository taking any '--git-dir=<path>' and
# '-C <path>' options into account and stores it in the $__git_repo_path
# variable.
__git_find_repo_path ()
{
- if [ -n "$__git_repo_path" ]; then
+ if [ -n "${__git_repo_path-}" ]; then
# we already know where it is
return
fi
@@ -92,6 +95,70 @@ __git ()
${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null
}
+# Removes backslash escaping, single quotes and double quotes from a word,
+# stores the result in the variable $dequoted_word.
+# 1: The word to dequote.
+__git_dequote ()
+{
+ local rest="$1" len ch
+
+ dequoted_word=""
+
+ while test -n "$rest"; do
+ len=${#dequoted_word}
+ dequoted_word="$dequoted_word${rest%%[\\\'\"]*}"
+ rest="${rest:$((${#dequoted_word}-$len))}"
+
+ case "${rest:0:1}" in
+ \\)
+ ch="${rest:1:1}"
+ case "$ch" in
+ $'\n')
+ ;;
+ *)
+ dequoted_word="$dequoted_word$ch"
+ ;;
+ esac
+ rest="${rest:2}"
+ ;;
+ \')
+ rest="${rest:1}"
+ len=${#dequoted_word}
+ dequoted_word="$dequoted_word${rest%%\'*}"
+ rest="${rest:$((${#dequoted_word}-$len+1))}"
+ ;;
+ \")
+ rest="${rest:1}"
+ while test -n "$rest" ; do
+ len=${#dequoted_word}
+ dequoted_word="$dequoted_word${rest%%[\\\"]*}"
+ rest="${rest:$((${#dequoted_word}-$len))}"
+ case "${rest:0:1}" in
+ \\)
+ ch="${rest:1:1}"
+ case "$ch" in
+ \"|\\|\$|\`)
+ dequoted_word="$dequoted_word$ch"
+ ;;
+ $'\n')
+ ;;
+ *)
+ dequoted_word="$dequoted_word\\$ch"
+ ;;
+ esac
+ rest="${rest:2}"
+ ;;
+ \")
+ rest="${rest:1}"
+ break
+ ;;
+ esac
+ done
+ ;;
+ esac
+ done
+}
+
# The following function is based on code from:
#
# bash_completion - programmable completion functions for bash 3.2+
@@ -234,6 +301,19 @@ __gitcomp_direct ()
COMPREPLY=($1)
}
+# Similar to __gitcomp_direct, but appends to COMPREPLY instead.
+# Callers must take care of providing only words that match the current word
+# to be completed and adding any prefix and/or suffix (trailing space!), if
+# necessary.
+# 1: List of newline-separated matching completion words, complete with
+# prefix and suffix.
+__gitcomp_direct_append ()
+{
+ local IFS=$'\n'
+
+ COMPREPLY+=($1)
+}
+
__gitcompappend ()
{
local x i=${#COMPREPLY[@]}
@@ -262,15 +342,38 @@ __gitcomp ()
local cur_="${3-$cur}"
case "$cur_" in
- --*=)
+ *=)
+ ;;
+ --no-*)
+ local c i=0 IFS=$' \t\n'
+ for c in $1; do
+ if [[ $c == "--" ]]; then
+ continue
+ fi
+ c="$c${4-}"
+ if [[ $c == "$cur_"* ]]; then
+ case $c in
+ --*=|*.) ;;
+ *) c="$c " ;;
+ esac
+ COMPREPLY[i++]="${2-}$c"
+ fi
+ done
;;
*)
local c i=0 IFS=$' \t\n'
for c in $1; do
+ if [[ $c == "--" ]]; then
+ c="--no-...${4-}"
+ if [[ $c == "$cur_"* ]]; then
+ COMPREPLY[i++]="${2-}$c "
+ fi
+ break
+ fi
c="$c${4-}"
if [[ $c == "$cur_"* ]]; then
case $c in
- --*=*|*.) ;;
+ *=|*.) ;;
*) c="$c " ;;
esac
COMPREPLY[i++]="${2-}$c"
@@ -280,6 +383,163 @@ __gitcomp ()
esac
}
+# Clear the variables caching builtins' options when (re-)sourcing
+# the completion script.
+if [[ -n ${ZSH_VERSION-} ]]; then
+ unset ${(M)${(k)parameters[@]}:#__gitcomp_builtin_*} 2>/dev/null
+else
+ unset $(compgen -v __gitcomp_builtin_)
+fi
+
+__gitcomp_builtin_add_default=" --dry-run --verbose --interactive --patch --edit --force --update --renormalize --intent-to-add --all --ignore-removal --refresh --ignore-errors --ignore-missing --chmod= --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-verbose --no-interactive --no-patch --no-edit --no-force --no-update --no-renormalize --no-intent-to-add --no-all --no-ignore-removal --no-refresh --no-ignore-errors --no-ignore-missing --no-chmod --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_am_default=" --interactive --3way --quiet --signoff --utf8 --keep --keep-non-patch --message-id --keep-cr --no-keep-cr --scissors --whitespace= --ignore-space-change --ignore-whitespace --directory= --exclude= --include= --patch-format= --reject --resolvemsg= --continue --resolved --skip --abort --quit --show-current-patch --committer-date-is-author-date --ignore-date --rerere-autoupdate --gpg-sign -- --no-interactive --no-3way --no-quiet --no-signoff --no-utf8 --no-keep --no-keep-non-patch --no-message-id --no-scissors --no-whitespace --no-ignore-space-change --no-ignore-whitespace --no-directory --no-exclude --no-include --no-patch-format --no-reject --no-resolvemsg --no-committer-date-is-author-date --no-ignore-date --no-rerere-autoupdate --no-gpg-sign"
+__gitcomp_builtin_apply_default=" --exclude= --include= --no-add --stat --numstat --summary --check --index --intent-to-add --cached --apply --3way --build-fake-ancestor= --whitespace= --ignore-space-change --ignore-whitespace --reverse --unidiff-zero --reject --allow-overlap --verbose --inaccurate-eof --recount --directory= --add -- --no-stat --no-numstat --no-summary --no-check --no-index --no-intent-to-add --no-cached --no-apply --no-3way --no-build-fake-ancestor --no-whitespace --no-ignore-space-change --no-ignore-whitespace --no-reverse --no-unidiff-zero --no-reject --no-allow-overlap --no-verbose --no-inaccurate-eof --no-recount --no-directory"
+__gitcomp_builtin_archive_default=" --output= --remote= --exec= --no-output -- --no-remote --no-exec"
+__gitcomp_builtin_bisect__helper_default=" --next-all --write-terms --bisect-clean-state --check-expected-revs --bisect-reset --bisect-write --check-and-set-terms --bisect-next-check --bisect-terms --bisect-start --bisect-next --bisect-auto-next --bisect-autostart --no-log --log"
+__gitcomp_builtin_blame_default=" --incremental --root --show-stats --progress --score-debug --show-name --show-number --porcelain --line-porcelain --show-email --ignore-rev= --ignore-revs-file= --color-lines --color-by-age --minimal --contents= --abbrev --no-incremental -- --no-root --no-show-stats --no-progress --no-score-debug --no-show-name --no-show-number --no-porcelain --no-line-porcelain --no-show-email --no-ignore-rev --no-ignore-revs-file --no-color-lines --no-color-by-age --no-minimal --no-contents --no-abbrev"
+__gitcomp_builtin_branch_default=" --verbose --quiet --track --set-upstream-to= --unset-upstream --color --remotes --contains --no-contains --abbrev --all --delete --move --copy --list --show-current --create-reflog --edit-description --merged --no-merged --column --sort= --points-at= --ignore-case --format= -- --no-verbose --no-quiet --no-track --no-set-upstream-to --no-unset-upstream --no-color --no-remotes --no-abbrev --no-all --no-delete --no-move --no-copy --no-list --no-show-current --no-create-reflog --no-edit-description --no-column --no-points-at --no-ignore-case --no-format"
+__gitcomp_builtin_bugreport_default=" --output-directory= --suffix= --no-output-directory -- --no-suffix"
+__gitcomp_builtin_cat_file_default=" --textconv --filters --path= --allow-unknown-type --buffer --batch --batch-check --follow-symlinks --batch-all-objects --unordered --no-path -- --no-allow-unknown-type --no-buffer --no-follow-symlinks --no-batch-all-objects --no-unordered"
+__gitcomp_builtin_check_attr_default=" --all --cached --stdin --no-all -- --no-cached --no-stdin"
+__gitcomp_builtin_check_ignore_default=" --quiet --verbose --stdin --non-matching --no-index --index -- --no-quiet --no-verbose --no-stdin --no-non-matching"
+__gitcomp_builtin_check_mailmap_default=" --stdin --no-stdin"
+__gitcomp_builtin_checkout_default=" --guess --overlay --quiet --recurse-submodules --progress --merge --conflict= --detach --track --orphan= --ignore-other-worktrees --ours --theirs --patch --ignore-skip-worktree-bits --pathspec-from-file= --pathspec-file-nul --no-guess -- --no-overlay --no-quiet --no-recurse-submodules --no-progress --no-merge --no-conflict --no-detach --no-track --no-orphan --no-ignore-other-worktrees --no-patch --no-ignore-skip-worktree-bits --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_checkout_index_default=" --all --force --quiet --no-create --index --stdin --temp --prefix= --stage= --create -- --no-all --no-force --no-quiet --no-index --no-stdin --no-temp --no-prefix"
+__gitcomp_builtin_cherry_default=" --abbrev --verbose --no-abbrev -- --no-verbose"
+__gitcomp_builtin_cherry_pick_default=" --quit --continue --abort --skip --cleanup= --no-commit --edit --signoff --mainline= --rerere-autoupdate --strategy= --strategy-option= --gpg-sign --ff --allow-empty --allow-empty-message --keep-redundant-commits --commit -- --no-cleanup --no-edit --no-signoff --no-mainline --no-rerere-autoupdate --no-strategy --no-strategy-option --no-gpg-sign --no-ff --no-allow-empty --no-allow-empty-message --no-keep-redundant-commits"
+__gitcomp_builtin_clean_default=" --quiet --dry-run --interactive --exclude= --no-quiet -- --no-dry-run --no-interactive"
+__gitcomp_builtin_clone_default=" --verbose --quiet --progress --no-checkout --bare --mirror --local --no-hardlinks --shared --recurse-submodules --recursive --jobs= --template= --reference= --reference-if-able= --dissociate --origin= --branch= --upload-pack= --depth= --shallow-since= --shallow-exclude= --single-branch --no-tags --shallow-submodules --separate-git-dir= --config= --server-option= --ipv4 --ipv6 --filter= --remote-submodules --sparse --checkout --hardlinks --tags -- --no-verbose --no-quiet --no-progress --no-bare --no-mirror --no-local --no-shared --no-recurse-submodules --no-recursive --no-jobs --no-template --no-reference --no-reference-if-able --no-dissociate --no-origin --no-branch --no-upload-pack --no-depth --no-shallow-since --no-shallow-exclude --no-single-branch --no-shallow-submodules --no-separate-git-dir --no-config --no-server-option --no-ipv4 --no-ipv6 --no-filter --no-remote-submodules --no-sparse"
+__gitcomp_builtin_column_default=" --command= --mode --raw-mode= --width= --indent= --nl= --padding= --no-command -- --no-mode --no-raw-mode --no-width --no-indent --no-nl --no-padding"
+__gitcomp_builtin_commit_default=" --quiet --verbose --file= --author= --date= --message= --reedit-message= --reuse-message= --fixup= --squash= --reset-author --signoff --template= --edit --cleanup= --status --gpg-sign --all --include --interactive --patch --only --no-verify --dry-run --short --branch --ahead-behind --porcelain --long --null --amend --no-post-rewrite --untracked-files --pathspec-from-file= --pathspec-file-nul --verify --post-rewrite -- --no-quiet --no-verbose --no-file --no-author --no-date --no-message --no-reedit-message --no-reuse-message --no-fixup --no-squash --no-reset-author --no-signoff --no-template --no-edit --no-cleanup --no-status --no-gpg-sign --no-all --no-include --no-interactive --no-patch --no-only --no-dry-run --no-short --no-branch --no-ahead-behind --no-porcelain --no-long --no-null --no-amend --no-untracked-files --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_commit_graph_default=" --object-dir= --no-object-dir"
+__gitcomp_builtin_config_default=" --global --system --local --worktree --file= --blob= --get --get-all --get-regexp --get-urlmatch --replace-all --add --unset --unset-all --rename-section --remove-section --list --edit --get-color --get-colorbool --type= --bool --int --bool-or-int --bool-or-str --path --expiry-date --null --name-only --includes --show-origin --show-scope --default= --no-global -- --no-system --no-local --no-worktree --no-file --no-blob --no-get --no-get-all --no-get-regexp --no-get-urlmatch --no-replace-all --no-add --no-unset --no-unset-all --no-rename-section --no-remove-section --no-list --no-edit --no-get-color --no-get-colorbool --no-type --no-null --no-name-only --no-includes --no-show-origin --no-show-scope --no-default"
+__gitcomp_builtin_count_objects_default=" --verbose --human-readable --no-verbose -- --no-human-readable"
+__gitcomp_builtin_credential_cache_default=" --timeout= --socket= --no-timeout -- --no-socket"
+__gitcomp_builtin_credential_cache__daemon_default=" --debug --no-debug"
+__gitcomp_builtin_credential_store_default=" --file= --no-file"
+__gitcomp_builtin_describe_default=" --contains --debug --all --tags --long --first-parent --abbrev --exact-match --candidates= --match= --exclude= --always --dirty --broken --no-contains -- --no-debug --no-all --no-tags --no-long --no-first-parent --no-abbrev --no-exact-match --no-candidates --no-match --no-exclude --no-always --no-dirty --no-broken"
+__gitcomp_builtin_difftool_default=" --gui --dir-diff --no-prompt --symlinks --tool= --tool-help --trust-exit-code --extcmd= --no-index -- --no-gui --no-dir-diff --no-symlinks --no-tool --no-tool-help --no-trust-exit-code --no-extcmd"
+__gitcomp_builtin_env__helper_default=" --type= --default= --exit-code --no-default -- --no-exit-code"
+__gitcomp_builtin_fast_export_default=" --progress= --signed-tags= --tag-of-filtered-object= --reencode= --export-marks= --import-marks= --import-marks-if-exists= --fake-missing-tagger --full-tree --use-done-feature --no-data --refspec= --anonymize --anonymize-map= --reference-excluded-parents --show-original-ids --mark-tags --data -- --no-progress --no-signed-tags --no-tag-of-filtered-object --no-reencode --no-export-marks --no-import-marks --no-import-marks-if-exists --no-fake-missing-tagger --no-full-tree --no-use-done-feature --no-refspec --no-anonymize --no-reference-excluded-parents --no-show-original-ids --no-mark-tags"
+__gitcomp_builtin_fetch_default=" --verbose --quiet --all --set-upstream --append --upload-pack= --force --multiple --tags --jobs= --prune --prune-tags --recurse-submodules --dry-run --write-fetch-head --keep --update-head-ok --progress --depth= --shallow-since= --shallow-exclude= --deepen= --unshallow --update-shallow --refmap= --server-option= --ipv4 --ipv6 --negotiation-tip= --filter= --auto-maintenance --auto-gc --show-forced-updates --write-commit-graph --stdin --no-verbose -- --no-quiet --no-all --no-set-upstream --no-append --no-upload-pack --no-force --no-multiple --no-tags --no-jobs --no-prune --no-prune-tags --no-recurse-submodules --no-dry-run --no-write-fetch-head --no-keep --no-update-head-ok --no-progress --no-depth --no-shallow-since --no-shallow-exclude --no-deepen --no-update-shallow --no-server-option --no-ipv4 --no-ipv6 --no-negotiation-tip --no-filter --no-auto-maintenance --no-auto-gc --no-show-forced-updates --no-write-commit-graph --no-stdin"
+__gitcomp_builtin_fmt_merge_msg_default=" --log --message= --file= --no-log -- --no-message --no-file"
+__gitcomp_builtin_for_each_ref_default=" --shell --perl --python --tcl --count= --format= --color --sort= --points-at= --merged --no-merged --contains --no-contains --ignore-case -- --no-shell --no-perl --no-python --no-tcl --no-count --no-format --no-color --no-points-at --no-ignore-case"
+__gitcomp_builtin_format_patch_default=" --numbered --no-numbered --signoff --stdout --cover-letter --numbered-files --suffix= --start-number= --reroll-count= --rfc --cover-from-description= --subject-prefix= --output-directory= --keep-subject --no-binary --zero-commit --ignore-if-in-upstream --no-stat --add-header= --to= --cc= --from --in-reply-to= --attach --inline --thread --signature= --base= --signature-file= --quiet --progress --interdiff= --range-diff= --creation-factor= --binary -- --no-numbered --no-signoff --no-stdout --no-cover-letter --no-numbered-files --no-suffix --no-start-number --no-reroll-count --no-cover-from-description --no-zero-commit --no-ignore-if-in-upstream --no-add-header --no-to --no-cc --no-from --no-in-reply-to --no-attach --no-thread --no-signature --no-base --no-signature-file --no-quiet --no-progress --no-interdiff --no-range-diff --no-creation-factor"
+__gitcomp_builtin_fsck_default=" --verbose --unreachable --dangling --tags --root --cache --reflogs --full --connectivity-only --strict --lost-found --progress --name-objects --no-verbose -- --no-unreachable --no-dangling --no-tags --no-root --no-cache --no-reflogs --no-full --no-connectivity-only --no-strict --no-lost-found --no-progress --no-name-objects"
+__gitcomp_builtin_fsck_objects_default=" --verbose --unreachable --dangling --tags --root --cache --reflogs --full --connectivity-only --strict --lost-found --progress --name-objects --no-verbose -- --no-unreachable --no-dangling --no-tags --no-root --no-cache --no-reflogs --no-full --no-connectivity-only --no-strict --no-lost-found --no-progress --no-name-objects"
+__gitcomp_builtin_gc_default=" --quiet --prune --aggressive --keep-largest-pack --no-quiet -- --no-prune --no-aggressive --no-keep-largest-pack"
+__gitcomp_builtin_grep_default=" --cached --no-index --untracked --exclude-standard --recurse-submodules --invert-match --ignore-case --word-regexp --text --textconv --recursive --max-depth= --extended-regexp --basic-regexp --fixed-strings --perl-regexp --line-number --column --full-name --files-with-matches --name-only --files-without-match --only-matching --count --color --break --heading --context= --before-context= --after-context= --threads= --show-function --function-context --and --or --not --quiet --all-match --index -- --no-cached --no-untracked --no-exclude-standard --no-recurse-submodules --no-invert-match --no-ignore-case --no-word-regexp --no-text --no-textconv --no-recursive --no-extended-regexp --no-basic-regexp --no-fixed-strings --no-perl-regexp --no-line-number --no-column --no-full-name --no-files-with-matches --no-name-only --no-files-without-match --no-only-matching --no-count --no-color --no-break --no-heading --no-context --no-before-context --no-after-context --no-threads --no-show-function --no-function-context --no-or --no-quiet --no-all-match"
+__gitcomp_builtin_hash_object_default=" --stdin --stdin-paths --no-filters --literally --path= --filters -- --no-stdin --no-stdin-paths --no-literally --no-path"
+__gitcomp_builtin_help_default=" --all --guides --config --man --web --info --verbose --no-all -- --no-guides --no-config --no-man --no-web --no-info --no-verbose"
+__gitcomp_builtin_init_default=" --template= --bare --shared --quiet --separate-git-dir= --initial-branch= --object-format= --no-template -- --no-bare --no-quiet --no-separate-git-dir --no-initial-branch --no-object-format"
+__gitcomp_builtin_init_db_default=" --template= --bare --shared --quiet --separate-git-dir= --initial-branch= --object-format= --no-template -- --no-bare --no-quiet --no-separate-git-dir --no-initial-branch --no-object-format"
+__gitcomp_builtin_interpret_trailers_default=" --in-place --trim-empty --where= --if-exists= --if-missing= --only-trailers --only-input --unfold --parse --no-divider --trailer= --divider -- --no-in-place --no-trim-empty --no-where --no-if-exists --no-if-missing --no-only-trailers --no-only-input --no-unfold --no-trailer"
+__gitcomp_builtin_log_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
+__gitcomp_builtin_ls_files_default=" --cached --deleted --modified --others --ignored --stage --killed --directory --eol --empty-directory --unmerged --resolve-undo --exclude= --exclude-from= --exclude-per-directory= --exclude-standard --full-name --recurse-submodules --error-unmatch --with-tree= --abbrev --debug --no-cached -- --no-deleted --no-modified --no-others --no-ignored --no-stage --no-killed --no-directory --no-eol --no-empty-directory --no-unmerged --no-resolve-undo --no-exclude-per-directory --no-recurse-submodules --no-error-unmatch --no-with-tree --no-abbrev --no-debug"
+__gitcomp_builtin_ls_remote_default=" --quiet --upload-pack= --tags --heads --refs --get-url --sort= --symref --server-option= --no-quiet -- --no-upload-pack --no-tags --no-heads --no-refs --no-get-url --no-symref --no-server-option"
+__gitcomp_builtin_ls_tree_default=" --long --name-only --name-status --full-name --full-tree --abbrev --no-long -- --no-name-only --no-name-status --no-full-name --no-full-tree --no-abbrev"
+__gitcomp_builtin_merge_default=" --stat --summary --log --squash --commit --edit --cleanup= --ff --ff-only --rerere-autoupdate --verify-signatures --strategy= --strategy-option= --message= --file --verbose --quiet --abort --quit --continue --allow-unrelated-histories --progress --gpg-sign --autostash --overwrite-ignore --signoff --no-verify --verify -- --no-stat --no-summary --no-log --no-squash --no-commit --no-edit --no-cleanup --no-ff --no-rerere-autoupdate --no-verify-signatures --no-strategy --no-strategy-option --no-message --no-verbose --no-quiet --no-abort --no-quit --no-continue --no-allow-unrelated-histories --no-progress --no-gpg-sign --no-autostash --no-overwrite-ignore --no-signoff"
+__gitcomp_builtin_merge_base_default=" --all --octopus --independent --is-ancestor --fork-point --no-all"
+__gitcomp_builtin_merge_file_default=" --stdout --diff3 --ours --theirs --union --marker-size= --quiet --no-stdout -- --no-diff3 --no-ours --no-theirs --no-union --no-marker-size --no-quiet"
+__gitcomp_builtin_mktree_default=" --missing --batch --no-missing -- --no-batch"
+__gitcomp_builtin_multi_pack_index_default=" --object-dir= --progress --batch-size= --no-object-dir -- --no-progress"
+__gitcomp_builtin_mv_default=" --verbose --dry-run --no-verbose -- --no-dry-run"
+__gitcomp_builtin_name_rev_default=" --name-only --tags --refs= --exclude= --all --stdin --undefined --always --no-name-only -- --no-tags --no-refs --no-exclude --no-all --no-stdin --no-undefined --no-always"
+__gitcomp_builtin_notes_default=" --ref= --no-ref"
+__gitcomp_builtin_pack_objects_default=" --quiet --progress --all-progress --all-progress-implied --index-version= --max-pack-size= --local --incremental --window= --window-memory= --depth= --reuse-delta --reuse-object --delta-base-offset --threads= --non-empty --revs --unpacked --all --reflog --indexed-objects --stdout --include-tag --keep-unreachable --pack-loose-unreachable --unpack-unreachable --sparse --thin --shallow --honor-pack-keep --keep-pack= --compression= --keep-true-parents --use-bitmap-index --write-bitmap-index --filter= --missing= --exclude-promisor-objects --delta-islands --uri-protocol= --no-quiet -- --no-progress --no-all-progress --no-all-progress-implied --no-local --no-incremental --no-window --no-depth --no-reuse-delta --no-reuse-object --no-delta-base-offset --no-threads --no-non-empty --no-revs --no-stdout --no-include-tag --no-keep-unreachable --no-pack-loose-unreachable --no-unpack-unreachable --no-sparse --no-thin --no-shallow --no-honor-pack-keep --no-keep-pack --no-compression --no-keep-true-parents --no-use-bitmap-index --no-write-bitmap-index --no-filter --no-exclude-promisor-objects --no-delta-islands --no-uri-protocol"
+__gitcomp_builtin_pack_refs_default=" --all --prune --no-all -- --no-prune"
+__gitcomp_builtin_pickaxe_default=" --incremental --root --show-stats --progress --score-debug --show-name --show-number --porcelain --line-porcelain --show-email --ignore-rev= --ignore-revs-file= --color-lines --color-by-age --minimal --contents= --abbrev --no-incremental -- --no-root --no-show-stats --no-progress --no-score-debug --no-show-name --no-show-number --no-porcelain --no-line-porcelain --no-show-email --no-ignore-rev --no-ignore-revs-file --no-color-lines --no-color-by-age --no-minimal --no-contents --no-abbrev"
+__gitcomp_builtin_prune_default=" --dry-run --verbose --progress --expire= --exclude-promisor-objects --no-dry-run -- --no-verbose --no-progress --no-expire --no-exclude-promisor-objects"
+__gitcomp_builtin_prune_packed_default=" --dry-run --quiet --no-dry-run -- --no-quiet"
+__gitcomp_builtin_pull_default=" --verbose --quiet --progress --recurse-submodules --rebase --stat --log --signoff --squash --commit --edit --cleanup= --ff --ff-only --verify-signatures --autostash --strategy= --strategy-option= --gpg-sign --allow-unrelated-histories --all --append --upload-pack= --force --tags --prune --jobs --dry-run --keep --depth= --shallow-since= --shallow-exclude= --deepen= --unshallow --update-shallow --refmap= --server-option= --ipv4 --ipv6 --negotiation-tip= --show-forced-updates --set-upstream --no-verbose -- --no-quiet --no-progress --no-recurse-submodules --no-rebase --no-stat --no-log --no-signoff --no-squash --no-commit --no-edit --no-cleanup --no-ff --no-verify-signatures --no-autostash --no-strategy --no-strategy-option --no-gpg-sign --no-allow-unrelated-histories --no-all --no-append --no-upload-pack --no-force --no-tags --no-prune --no-jobs --no-dry-run --no-keep --no-depth --no-shallow-since --no-shallow-exclude --no-deepen --no-update-shallow --no-server-option --no-ipv4 --no-ipv6 --no-negotiation-tip --no-show-forced-updates --no-set-upstream"
+__gitcomp_builtin_push_default=" --verbose --quiet --repo= --all --mirror --delete --tags --dry-run --porcelain --force --force-with-lease --recurse-submodules= --receive-pack= --exec= --set-upstream --progress --prune --no-verify --follow-tags --signed --atomic --push-option= --ipv4 --ipv6 --verify -- --no-verbose --no-quiet --no-repo --no-all --no-mirror --no-delete --no-tags --no-dry-run --no-porcelain --no-force --no-force-with-lease --no-recurse-submodules --no-receive-pack --no-exec --no-set-upstream --no-progress --no-prune --no-follow-tags --no-signed --no-atomic --no-push-option --no-ipv4 --no-ipv6"
+__gitcomp_builtin_range_diff_default=" --creation-factor= --no-dual-color --notes --patch --no-patch --unified --function-context --raw --patch-with-raw --patch-with-stat --numstat --shortstat --dirstat --cumulative --dirstat-by-file --check --summary --name-only --name-status --stat --stat-width= --stat-name-width= --stat-graph-width= --stat-count= --compact-summary --binary --full-index --color --ws-error-highlight= --abbrev --src-prefix= --dst-prefix= --line-prefix= --no-prefix --inter-hunk-context= --output-indicator-new= --output-indicator-old= --output-indicator-context= --break-rewrites --find-renames --irreversible-delete --find-copies --find-copies-harder --no-renames --rename-empty --follow --minimal --ignore-all-space --ignore-space-change --ignore-space-at-eol --ignore-cr-at-eol --ignore-blank-lines --indent-heuristic --patience --histogram --diff-algorithm= --anchored= --word-diff --word-diff-regex= --color-words --color-moved --color-moved-ws= --relative --text --exit-code --quiet --ext-diff --textconv --ignore-submodules --submodule --ita-invisible-in-index --ita-visible-in-index --pickaxe-all --pickaxe-regex --find-object= --diff-filter= --output= --dual-color -- --no-creation-factor --no-notes --no-function-context --no-compact-summary --no-full-index --no-color --no-abbrev --no-find-copies-harder --no-rename-empty --no-follow --no-minimal --no-indent-heuristic --no-color-moved --no-color-moved-ws --no-relative --no-text --no-exit-code --no-quiet --no-ext-diff --no-textconv"
+__gitcomp_builtin_read_tree_default=" --index-output= --empty --verbose --trivial --aggressive --reset --prefix= --exclude-per-directory= --dry-run --no-sparse-checkout --debug-unpack --recurse-submodules --quiet --sparse-checkout -- --no-empty --no-verbose --no-trivial --no-aggressive --no-reset --no-dry-run --no-debug-unpack --no-recurse-submodules --no-quiet"
+__gitcomp_builtin_rebase_default=" --onto= --keep-base --no-verify --quiet --verbose --no-stat --signoff --committer-date-is-author-date --reset-author-date --ignore-whitespace --whitespace= --force-rebase --no-ff --continue --skip --abort --quit --edit-todo --show-current-patch --apply --merge --interactive --rerere-autoupdate --empty= --autosquash --gpg-sign --autostash --exec= --rebase-merges --fork-point --strategy= --strategy-option= --root --reschedule-failed-exec --reapply-cherry-picks --verify --stat --ff -- --no-onto --no-keep-base --no-quiet --no-verbose --no-signoff --no-committer-date-is-author-date --no-reset-author-date --no-ignore-whitespace --no-whitespace --no-force-rebase --no-rerere-autoupdate --no-autosquash --no-gpg-sign --no-autostash --no-exec --no-rebase-merges --no-fork-point --no-strategy --no-strategy-option --no-root --no-reschedule-failed-exec --no-reapply-cherry-picks"
+__gitcomp_builtin_rebase__interactive_default=" --ff --rebase-merges --rebase-cousins --autosquash --signoff --verbose --continue --skip --edit-todo --show-current-patch --shorten-ids --expand-ids --check-todo-list --rearrange-squash --add-exec-commands --onto= --restrict-revision= --squash-onto= --upstream= --head-name= --gpg-sign --strategy= --strategy-opts= --switch-to= --onto-name= --cmd= --rerere-autoupdate --reschedule-failed-exec --no-ff -- --no-rebase-merges --no-rebase-cousins --no-autosquash --no-signoff --no-verbose --no-head-name --no-gpg-sign --no-strategy --no-strategy-opts --no-switch-to --no-onto-name --no-cmd --no-rerere-autoupdate --no-reschedule-failed-exec"
+__gitcomp_builtin_receive_pack_default=" --quiet --no-quiet"
+__gitcomp_builtin_reflog_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
+__gitcomp_builtin_remote_default=" --verbose --no-verbose"
+__gitcomp_builtin_repack_default=" --quiet --local --write-bitmap-index --delta-islands --unpack-unreachable= --keep-unreachable --window= --window-memory= --depth= --threads= --max-pack-size= --pack-kept-objects --keep-pack= --no-quiet -- --no-local --no-write-bitmap-index --no-delta-islands --no-unpack-unreachable --no-keep-unreachable --no-window --no-window-memory --no-depth --no-threads --no-max-pack-size --no-pack-kept-objects --no-keep-pack"
+__gitcomp_builtin_replace_default=" --list --delete --edit --graft --convert-graft-file --raw --format= --no-raw -- --no-format"
+__gitcomp_builtin_rerere_default=" --rerere-autoupdate --no-rerere-autoupdate"
+__gitcomp_builtin_reset_default=" --quiet --mixed --soft --hard --merge --keep --recurse-submodules --patch --intent-to-add --pathspec-from-file= --pathspec-file-nul --no-quiet -- --no-mixed --no-soft --no-hard --no-merge --no-keep --no-recurse-submodules --no-patch --no-intent-to-add --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_restore_default=" --source= --staged --worktree --ignore-unmerged --overlay --quiet --recurse-submodules --progress --merge --conflict= --ours --theirs --patch --ignore-skip-worktree-bits --pathspec-from-file= --pathspec-file-nul --no-source -- --no-staged --no-worktree --no-ignore-unmerged --no-overlay --no-quiet --no-recurse-submodules --no-progress --no-merge --no-conflict --no-patch --no-ignore-skip-worktree-bits --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_revert_default=" --quit --continue --abort --skip --cleanup= --no-commit --edit --signoff --mainline= --rerere-autoupdate --strategy= --strategy-option= --gpg-sign --commit -- --no-cleanup --no-edit --no-signoff --no-mainline --no-rerere-autoupdate --no-strategy --no-strategy-option --no-gpg-sign"
+__gitcomp_builtin_rm_default=" --dry-run --quiet --cached --ignore-unmatch --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-quiet --no-cached --no-ignore-unmatch --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_send_pack_default=" --verbose --quiet --receive-pack= --exec= --remote= --all --dry-run --mirror --force --signed --push-option= --progress --thin --atomic --stateless-rpc --stdin --helper-status --force-with-lease --no-verbose -- --no-quiet --no-receive-pack --no-exec --no-remote --no-all --no-dry-run --no-mirror --no-force --no-signed --no-push-option --no-progress --no-thin --no-atomic --no-stateless-rpc --no-stdin --no-helper-status --no-force-with-lease"
+__gitcomp_builtin_shortlog_default=" --committer --numbered --summary --email --group= --no-committer -- --no-numbered --no-summary --no-email --no-group"
+__gitcomp_builtin_show_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
+__gitcomp_builtin_show_branch_default=" --all --remotes --color --more --list --no-name --current --sha1-name --merge-base --independent --topo-order --topics --sparse --date-order --reflog --name -- --no-all --no-remotes --no-color --no-more --no-list --no-current --no-sha1-name --no-merge-base --no-independent --no-topo-order --no-topics --no-sparse --no-date-order"
+__gitcomp_builtin_show_index_default=" --object-format= --no-object-format"
+__gitcomp_builtin_show_ref_default=" --tags --heads --verify --head --dereference --hash --abbrev --quiet --exclude-existing --no-tags -- --no-heads --no-verify --no-head --no-dereference --no-hash --no-abbrev --no-quiet"
+__gitcomp_builtin_sparse_checkout_default=""
+__gitcomp_builtin_stage_default=" --dry-run --verbose --interactive --patch --edit --force --update --renormalize --intent-to-add --all --ignore-removal --refresh --ignore-errors --ignore-missing --chmod= --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-verbose --no-interactive --no-patch --no-edit --no-force --no-update --no-renormalize --no-intent-to-add --no-all --no-ignore-removal --no-refresh --no-ignore-errors --no-ignore-missing --no-chmod --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_stash_default=""
+__gitcomp_builtin_status_default=" --verbose --short --branch --show-stash --ahead-behind --porcelain --long --null --untracked-files --ignored --ignore-submodules --column --no-renames --find-renames --renames -- --no-verbose --no-short --no-branch --no-show-stash --no-ahead-behind --no-porcelain --no-long --no-null --no-untracked-files --no-ignored --no-ignore-submodules --no-column"
+__gitcomp_builtin_stripspace_default=" --strip-comments --comment-lines"
+__gitcomp_builtin_switch_default=" --create= --force-create= --guess --discard-changes --quiet --recurse-submodules --progress --merge --conflict= --detach --track --orphan= --ignore-other-worktrees --no-create -- --no-force-create --no-guess --no-discard-changes --no-quiet --no-recurse-submodules --no-progress --no-merge --no-conflict --no-detach --no-track --no-orphan --no-ignore-other-worktrees"
+__gitcomp_builtin_symbolic_ref_default=" --quiet --delete --short --no-quiet -- --no-delete --no-short"
+__gitcomp_builtin_tag_default=" --list --delete --verify --annotate --message= --file= --edit --sign --cleanup= --local-user= --force --create-reflog --column --contains --no-contains --merged --no-merged --sort= --points-at --format= --color --ignore-case -- --no-annotate --no-file --no-edit --no-sign --no-cleanup --no-local-user --no-force --no-create-reflog --no-column --no-points-at --no-format --no-color --no-ignore-case"
+__gitcomp_builtin_update_index_default=" --ignore-submodules --add --replace --remove --unmerged --refresh --really-refresh --cacheinfo --chmod= --assume-unchanged --no-assume-unchanged --skip-worktree --no-skip-worktree --ignore-skip-worktree-entries --info-only --force-remove --stdin --index-info --unresolve --again --ignore-missing --verbose --clear-resolve-undo --index-version= --split-index --untracked-cache --test-untracked-cache --force-untracked-cache --force-write-index --fsmonitor --fsmonitor-valid --no-fsmonitor-valid -- --no-ignore-submodules --no-add --no-replace --no-remove --no-unmerged --no-ignore-skip-worktree-entries --no-info-only --no-force-remove --no-ignore-missing --no-verbose --no-index-version --no-split-index --no-untracked-cache --no-test-untracked-cache --no-force-untracked-cache --no-force-write-index --no-fsmonitor"
+__gitcomp_builtin_update_ref_default=" --no-deref --stdin --create-reflog --deref -- --no-stdin --no-create-reflog"
+__gitcomp_builtin_update_server_info_default=" --force --no-force"
+__gitcomp_builtin_upload_pack_default=" --stateless-rpc --advertise-refs --strict --timeout= --no-stateless-rpc -- --no-advertise-refs --no-strict --no-timeout"
+__gitcomp_builtin_verify_commit_default=" --verbose --raw --no-verbose -- --no-raw"
+__gitcomp_builtin_verify_pack_default=" --verbose --stat-only --object-format= --no-verbose -- --no-stat-only --no-object-format"
+__gitcomp_builtin_verify_tag_default=" --verbose --raw --format= --no-verbose -- --no-raw --no-format"
+__gitcomp_builtin_version_default=" --build-options --no-build-options"
+__gitcomp_builtin_whatchanged_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
+__gitcomp_builtin_write_tree_default=" --missing-ok --prefix= --no-missing-ok -- --no-prefix"
+__gitcomp_builtin_send_email_default=" --numbered --no-numbered --signoff --stdout --cover-letter --numbered-files --suffix= --start-number= --reroll-count= --rfc --cover-from-description= --subject-prefix= --output-directory= --keep-subject --no-binary --zero-commit --ignore-if-in-upstream --no-stat --add-header= --to= --cc= --from --in-reply-to= --attach --inline --thread --signature= --base= --signature-file= --quiet --progress --interdiff= --range-diff= --creation-factor= --binary -- --no-numbered --no-signoff --no-stdout --no-cover-letter --no-numbered-files --no-suffix --no-start-number --no-reroll-count --no-cover-from-description --no-zero-commit --no-ignore-if-in-upstream --no-add-header --no-to --no-cc --no-from --no-in-reply-to --no-attach --no-thread --no-signature --no-base --no-signature-file --no-quiet --no-progress --no-interdiff --no-range-diff --no-creation-factor"
+
+__gitcomp_builtin_get_default ()
+{
+ eval "test -n \"\$${1}_default\" && echo \"\$${1}_default\""
+}
+
+# This function is equivalent to
+#
+# __gitcomp "$(git xxx --git-completion-helper) ..."
+#
+# except that the output is cached. Accept 1-3 arguments:
+# 1: the git command to execute, this is also the cache key
+# 2: extra options to be added on top (e.g. negative forms)
+# 3: options to be excluded
+__gitcomp_builtin ()
+{
+ # spaces must be replaced with underscore for multi-word
+ # commands, e.g. "git remote add" becomes remote_add.
+ local cmd="$1"
+ local incl="${2-}"
+ local excl="${3-}"
+
+ local var=__gitcomp_builtin_"${cmd//-/_}"
+ local options
+ eval "options=\${$var-}"
+
+ if [ -z "$options" ]; then
+ local completion_helper
+ if [ "$GIT_COMPLETION_SHOW_ALL" = "1" ]; then
+ completion_helper="--git-completion-helper-all"
+ else
+ completion_helper="--git-completion-helper"
+ fi
+ completion="$(__git ${cmd/_/ } $completion_helper ||
+ __gitcomp_builtin_get_default $var)" || return
+ # leading and trailing spaces are significant to make
+ # option removal work correctly.
+ options=" $incl $completion "
+
+ for i in $excl; do
+ options="${options/ $i / }"
+ done
+ eval "$var=\"$options\""
+ fi
+
+ __gitcomp "$options"
+}
+
# Variation of __gitcomp_nl () that appends to the existing list of
# completion candidates, COMPREPLY.
__gitcomp_nl_append ()
@@ -303,6 +563,24 @@ __gitcomp_nl ()
__gitcomp_nl_append "$@"
}
+# Fills the COMPREPLY array with prefiltered paths without any additional
+# processing.
+# Callers must take care of providing only paths that match the current path
+# to be completed and adding any prefix path components, if necessary.
+# 1: List of newline-separated matching paths, complete with all prefix
+# path components.
+__gitcomp_file_direct ()
+{
+ local IFS=$'\n'
+
+ COMPREPLY=($1)
+
+ # use a hack to enable file mode in bash < 4
+ compopt -o filenames +o nospace 2>/dev/null ||
+ compgen -f /non-existing-dir/ >/dev/null ||
+ true
+}
+
# Generates completion reply with compgen from newline-separated possible
# completion filenames.
# It accepts 1 to 3 arguments:
@@ -322,7 +600,8 @@ __gitcomp_file ()
# use a hack to enable file mode in bash < 4
compopt -o filenames +o nospace 2>/dev/null ||
- compgen -f /non-existing-dir/ > /dev/null
+ compgen -f /non-existing-dir/ >/dev/null ||
+ true
}
# Execute 'git ls-files', unless the --committable option is specified, in
@@ -332,10 +611,12 @@ __gitcomp_file ()
__git_ls_files_helper ()
{
if [ "$2" == "--committable" ]; then
- __git -C "$1" diff-index --name-only --relative HEAD
+ __git -C "$1" -c core.quotePath=false diff-index \
+ --name-only --relative HEAD -- "${3//\\/\\\\}*"
else
# NOTE: $2 is not quoted in order to support multiple options
- __git -C "$1" ls-files --exclude-standard $2
+ __git -C "$1" -c core.quotePath=false ls-files \
+ --exclude-standard $2 -- "${3//\\/\\\\}*"
fi
}
@@ -346,17 +627,103 @@ __git_ls_files_helper ()
# If provided, only files within the specified directory are listed.
# Sub directories are never recursed. Path must have a trailing
# slash.
+# 3: List only paths matching this path component (optional).
__git_index_files ()
{
- local root="${2-.}" file
+ local root="$2" match="$3"
- __git_ls_files_helper "$root" "$1" |
- while read -r file; do
- case "$file" in
- ?*/*) echo "${file%%/*}" ;;
- *) echo "$file" ;;
- esac
- done | sort | uniq
+ __git_ls_files_helper "$root" "$1" "${match:-?}" |
+ awk -F / -v pfx="${2//\\/\\\\}" '{
+ paths[$1] = 1
+ }
+ END {
+ for (p in paths) {
+ if (substr(p, 1, 1) != "\"") {
+ # No special characters, easy!
+ print pfx p
+ continue
+ }
+
+ # The path is quoted.
+ p = dequote(p)
+ if (p == "")
+ continue
+
+ # Even when a directory name itself does not contain
+ # any special characters, it will still be quoted if
+ # any of its (stripped) trailing path components do.
+ # Because of this we may have seen the same directory
+ # both quoted and unquoted.
+ if (p in paths)
+ # We have seen the same directory unquoted,
+ # skip it.
+ continue
+ else
+ print pfx p
+ }
+ }
+ function dequote(p, bs_idx, out, esc, esc_idx, dec) {
+ # Skip opening double quote.
+ p = substr(p, 2)
+
+ # Interpret backslash escape sequences.
+ while ((bs_idx = index(p, "\\")) != 0) {
+ out = out substr(p, 1, bs_idx - 1)
+ esc = substr(p, bs_idx + 1, 1)
+ p = substr(p, bs_idx + 2)
+
+ if ((esc_idx = index("abtvfr\"\\", esc)) != 0) {
+ # C-style one-character escape sequence.
+ out = out substr("\a\b\t\v\f\r\"\\",
+ esc_idx, 1)
+ } else if (esc == "n") {
+ # Uh-oh, a newline character.
+ # We cannot reliably put a pathname
+ # containing a newline into COMPREPLY,
+ # and the newline would create a mess.
+ # Skip this path.
+ return ""
+ } else {
+ # Must be a \nnn octal value, then.
+ dec = esc * 64 + \
+ substr(p, 1, 1) * 8 + \
+ substr(p, 2, 1)
+ out = out sprintf("%c", dec)
+ p = substr(p, 3)
+ }
+ }
+ # Drop closing double quote, if there is one.
+ # (There is not any if this is a directory, as it was
+ # already stripped with the trailing path components.)
+ if (substr(p, length(p), 1) == "\"")
+ out = out substr(p, 1, length(p) - 1)
+ else
+ out = out p
+
+ return out
+ }'
+}
+
+# __git_complete_index_file requires 1 argument:
+# 1: the options to pass to ls-file
+#
+# The exception is --committable, which finds the files appropriate commit.
+__git_complete_index_file ()
+{
+ local dequoted_word pfx="" cur_
+
+ __git_dequote "$cur"
+
+ case "$dequoted_word" in
+ ?*/*)
+ pfx="${dequoted_word%/*}/"
+ cur_="${dequoted_word##*/}"
+ ;;
+ *)
+ cur_="$dequoted_word"
+ esac
+
+ __gitcomp_file_direct "$(__git_index_files "$1" "$pfx" "$cur_")"
}
# Lists branches from the local repository.
@@ -372,6 +739,19 @@ __git_heads ()
"refs/heads/$cur_*" "refs/heads/$cur_*/**"
}
+# Lists branches from remote repositories.
+# 1: A prefix to be added to each listed branch (optional).
+# 2: List only branches matching this word (optional; list all branches if
+# unset or empty).
+# 3: A suffix to be appended to each listed branch (optional).
+__git_remote_heads ()
+{
+ local pfx="${1-}" cur_="${2-}" sfx="${3-}"
+
+ __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \
+ "refs/remotes/$cur_*" "refs/remotes/$cur_*/**"
+}
+
# Lists tags from the local repository.
# Accepts the same positional parameters as __git_heads() above.
__git_tags ()
@@ -382,6 +762,26 @@ __git_tags ()
"refs/tags/$cur_*" "refs/tags/$cur_*/**"
}
+# List unique branches from refs/remotes used for 'git checkout' and 'git
+# switch' tracking DWIMery.
+# 1: A prefix to be added to each listed branch (optional)
+# 2: List only branches matching this word (optional; list all branches if
+# unset or empty).
+# 3: A suffix to be appended to each listed branch (optional).
+__git_dwim_remote_heads ()
+{
+ local pfx="${1-}" cur_="${2-}" sfx="${3-}"
+ local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers
+
+ # employ the heuristic used by git checkout and git switch
+ # Try to find a remote branch that cur_es the completion word
+ # but only output if the branch name is unique
+ __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \
+ --sort="refname:strip=3" \
+ "refs/remotes/*/$cur_*" "refs/remotes/*/$cur_*/**" | \
+ uniq -u
+}
+
# Lists refs from the local (by default) or from a remote repository.
# It accepts 0, 1 or 2 arguments:
# 1: The remote to list refs from (optional; ignored, if set but empty).
@@ -439,7 +839,7 @@ __git_refs ()
track=""
;;
*)
- for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
+ for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do
case "$i" in
$match*)
if [ -e "$dir/$i" ]; then
@@ -457,13 +857,7 @@ __git_refs ()
__git_dir="$dir" __git for-each-ref --format="$fer_pfx%($format)$sfx" \
"${refs[@]}"
if [ -n "$track" ]; then
- # employ the heuristic used by git checkout
- # Try to find a remote branch that matches the completion word
- # but only output if the branch name is unique
- __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \
- --sort="refname:strip=3" \
- "refs/remotes/*/$match*" "refs/remotes/*/$match*/**" | \
- uniq -u
+ __git_dwim_remote_heads "$pfx" "$match" "$sfx"
fi
return
fi
@@ -510,29 +904,51 @@ __git_refs ()
# Usage: __git_complete_refs [<option>]...
# --remote=<remote>: The remote to list refs from, can be the name of a
# configured remote, a path, or a URL.
-# --track: List unique remote branches for 'git checkout's tracking DWIMery.
+# --dwim: List unique remote branches for 'git switch's tracking DWIMery.
# --pfx=<prefix>: A prefix to be added to each ref.
# --cur=<word>: The current ref to be completed. Defaults to the current
# word to be completed.
# --sfx=<suffix>: A suffix to be appended to each ref instead of the default
# space.
+# --mode=<mode>: What set of refs to complete, one of 'refs' (the default) to
+# complete all refs, 'heads' to complete only branches, or
+# 'remote-heads' to complete only remote branches. Note that
+# --remote is only compatible with --mode=refs.
__git_complete_refs ()
{
- local remote track pfx cur_="$cur" sfx=" "
+ local remote= dwim= pfx= cur_="$cur" sfx=" " mode="refs"
while test $# != 0; do
case "$1" in
--remote=*) remote="${1##--remote=}" ;;
- --track) track="yes" ;;
+ --dwim) dwim="yes" ;;
+ # --track is an old spelling of --dwim
+ --track) dwim="yes" ;;
--pfx=*) pfx="${1##--pfx=}" ;;
--cur=*) cur_="${1##--cur=}" ;;
--sfx=*) sfx="${1##--sfx=}" ;;
+ --mode=*) mode="${1##--mode=}" ;;
*) return 1 ;;
esac
shift
done
- __gitcomp_direct "$(__git_refs "$remote" "$track" "$pfx" "$cur_" "$sfx")"
+ # complete references based on the specified mode
+ case "$mode" in
+ refs)
+ __gitcomp_direct "$(__git_refs "$remote" "" "$pfx" "$cur_" "$sfx")" ;;
+ heads)
+ __gitcomp_direct "$(__git_heads "$pfx" "$cur_" "$sfx")" ;;
+ remote-heads)
+ __gitcomp_direct "$(__git_remote_heads "$pfx" "$cur_" "$sfx")" ;;
+ *)
+ return 1 ;;
+ esac
+
+ # Append DWIM remote branch names if requested
+ if [ "$dwim" = "yes" ]; then
+ __gitcomp_direct_append "$(__git_dwim_remote_heads "$pfx" "$cur_" "$sfx")"
+ fi
}
# __git_refs2 requires 1 argument (to pass to __git_refs)
@@ -594,7 +1010,7 @@ __git_is_configured_remote ()
__git_list_merge_strategies ()
{
- git merge -s help 2>&1 |
+ LANG=C LC_ALL=C git merge -s help 2>&1 |
sed -n -e '/[Aa]vailable strategies are: /,/^$/{
s/\.$//
s/.*://
@@ -604,6 +1020,7 @@ __git_list_merge_strategies ()
}'
}
+__git_merge_strategies_default='octopus ours recursive resolve subtree'
__git_merge_strategies=
# 'git merge -s help' (and thus detection of the merge strategy
# list) fails, unfortunately, if run outside of any git working
@@ -613,12 +1030,18 @@ __git_merge_strategies=
__git_compute_merge_strategies ()
{
test -n "$__git_merge_strategies" ||
- __git_merge_strategies=$(__git_list_merge_strategies)
+ { __git_merge_strategies=$(__git_list_merge_strategies);
+ __git_merge_strategies="${__git_merge_strategies:-__git_merge_strategies_default}"; }
}
+__git_merge_strategy_options="ours theirs subtree subtree= patience
+ histogram diff-algorithm= ignore-space-change ignore-all-space
+ ignore-space-at-eol renormalize no-renormalize no-renames
+ find-renames find-renames= rename-threshold="
+
__git_complete_revlist_file ()
{
- local pfx ls ref cur_="$cur"
+ local dequoted_word pfx ls ref cur_="$cur"
case "$cur_" in
*..?*:*)
return
@@ -626,14 +1049,18 @@ __git_complete_revlist_file ()
?*:*)
ref="${cur_%%:*}"
cur_="${cur_#*:}"
- case "$cur_" in
+
+ __git_dequote "$cur_"
+
+ case "$dequoted_word" in
?*/*)
- pfx="${cur_%/*}"
- cur_="${cur_##*/}"
+ pfx="${dequoted_word%/*}"
+ cur_="${dequoted_word##*/}"
ls="$ref:$pfx"
pfx="$pfx/"
;;
*)
+ cur_="$dequoted_word"
ls="$ref"
;;
esac
@@ -643,21 +1070,10 @@ __git_complete_revlist_file ()
*) pfx="$ref:$pfx" ;;
esac
- __gitcomp_nl "$(__git ls-tree "$ls" \
- | sed '/^100... blob /{
- s,^.* ,,
- s,$, ,
- }
- /^120000 blob /{
- s,^.* ,,
- s,$, ,
- }
- /^040000 tree /{
- s,^.* ,,
- s,$,/,
- }
- s/^.* //')" \
- "$pfx" "$cur_" ""
+ __gitcomp_file "$(__git ls-tree "$ls" \
+ | sed 's/^.* //
+ s/$//')" \
+ "$pfx" "$cur_"
;;
*...*)
pfx="${cur_%...*}..."
@@ -675,26 +1091,6 @@ __git_complete_revlist_file ()
esac
}
-
-# __git_complete_index_file requires 1 argument:
-# 1: the options to pass to ls-file
-#
-# The exception is --committable, which finds the files appropriate commit.
-__git_complete_index_file ()
-{
- local pfx="" cur_="$cur"
-
- case "$cur_" in
- ?*/*)
- pfx="${cur_%/*}"
- cur_="${cur_##*/}"
- pfx="${pfx}/"
- ;;
- esac
-
- __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
-}
-
__git_complete_file ()
{
__git_complete_revlist_file
@@ -726,6 +1122,7 @@ __git_complete_remote_or_refspec ()
*) ;;
esac
;;
+ --multiple) no_complete_refspec=1; break ;;
-*) ;;
*) remote="$i"; break ;;
esac
@@ -785,136 +1182,30 @@ __git_complete_strategy ()
-s|--strategy)
__gitcomp "$__git_merge_strategies"
return 0
+ ;;
+ -X)
+ __gitcomp "$__git_merge_strategy_options"
+ return 0
+ ;;
esac
case "$cur" in
--strategy=*)
__gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
return 0
;;
+ --strategy-option=*)
+ __gitcomp "$__git_merge_strategy_options" "" "${cur##--strategy-option=}"
+ return 0
+ ;;
esac
return 1
}
-__git_commands () {
- if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"
- then
- printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
- else
- git help -a|egrep '^ [a-zA-Z0-9]'
- fi
-}
-
-__git_list_all_commands ()
-{
- local i IFS=" "$'\n'
- for i in $(__git_commands)
- do
- case $i in
- *--*) : helper pattern;;
- *) echo $i;;
- esac
- done
-}
-
__git_all_commands=
__git_compute_all_commands ()
{
test -n "$__git_all_commands" ||
- __git_all_commands=$(__git_list_all_commands)
-}
-
-__git_list_porcelain_commands ()
-{
- local i IFS=" "$'\n'
- __git_compute_all_commands
- for i in $__git_all_commands
- do
- case $i in
- *--*) : helper pattern;;
- applymbox) : ask gittus;;
- applypatch) : ask gittus;;
- archimport) : import;;
- cat-file) : plumbing;;
- check-attr) : plumbing;;
- check-ignore) : plumbing;;
- check-mailmap) : plumbing;;
- check-ref-format) : plumbing;;
- checkout-index) : plumbing;;
- column) : internal helper;;
- commit-tree) : plumbing;;
- count-objects) : infrequent;;
- credential) : credentials;;
- credential-*) : credentials helper;;
- cvsexportcommit) : export;;
- cvsimport) : import;;
- cvsserver) : daemon;;
- daemon) : daemon;;
- diff-files) : plumbing;;
- diff-index) : plumbing;;
- diff-tree) : plumbing;;
- fast-import) : import;;
- fast-export) : export;;
- fsck-objects) : plumbing;;
- fetch-pack) : plumbing;;
- fmt-merge-msg) : plumbing;;
- for-each-ref) : plumbing;;
- hash-object) : plumbing;;
- http-*) : transport;;
- index-pack) : plumbing;;
- init-db) : deprecated;;
- local-fetch) : plumbing;;
- ls-files) : plumbing;;
- ls-remote) : plumbing;;
- ls-tree) : plumbing;;
- mailinfo) : plumbing;;
- mailsplit) : plumbing;;
- merge-*) : plumbing;;
- mktree) : plumbing;;
- mktag) : plumbing;;
- pack-objects) : plumbing;;
- pack-redundant) : plumbing;;
- pack-refs) : plumbing;;
- parse-remote) : plumbing;;
- patch-id) : plumbing;;
- prune) : plumbing;;
- prune-packed) : plumbing;;
- quiltimport) : import;;
- read-tree) : plumbing;;
- receive-pack) : plumbing;;
- remote-*) : transport;;
- rerere) : plumbing;;
- rev-list) : plumbing;;
- rev-parse) : plumbing;;
- runstatus) : plumbing;;
- sh-setup) : internal;;
- shell) : daemon;;
- show-ref) : plumbing;;
- send-pack) : plumbing;;
- show-index) : plumbing;;
- ssh-*) : transport;;
- stripspace) : plumbing;;
- symbolic-ref) : plumbing;;
- unpack-file) : plumbing;;
- unpack-objects) : plumbing;;
- update-index) : plumbing;;
- update-ref) : plumbing;;
- update-server-info) : daemon;;
- upload-archive) : plumbing;;
- upload-pack) : plumbing;;
- write-tree) : plumbing;;
- var) : infrequent;;
- verify-pack) : infrequent;;
- verify-tag) : plumbing;;
- *) echo $i;;
- esac
- done
-}
-
-__git_porcelain_commands=
-__git_compute_porcelain_commands ()
-{
- test -n "$__git_porcelain_commands" ||
- __git_porcelain_commands=$(__git_list_porcelain_commands)
+ __git_all_commands=$(__git --list-cmds=main,others,alias,nohelpers)
}
# Lists all set config variables starting with the given section prefix,
@@ -932,45 +1223,75 @@ __git_pretty_aliases ()
__git_get_config_variables "pretty"
}
-__git_aliases ()
-{
- __git_get_config_variables "alias"
-}
-
# __git_aliased_command requires 1 argument
__git_aliased_command ()
{
- local word cmdline=$(__git config --get "alias.$1")
- for word in $cmdline; do
- case "$word" in
- \!gitk|gitk)
- echo "gitk"
- return
- ;;
- \!*) : shell command alias ;;
- -*) : option ;;
- *=*) : setting env ;;
- git) : git itself ;;
- \(\)) : skip parens of shell function definition ;;
- {) : skip start of shell helper function ;;
- :) : skip null command ;;
- \'*) : skip opening quote after sh -c ;;
- *)
- echo "$word"
+ local cur=$1 last list word cmdline
+
+ while [[ -n "$cur" ]]; do
+ if [[ "$list" == *" $cur "* ]]; then
+ # loop detected
return
- esac
+ fi
+
+ cmdline=$(__git config --get "alias.$cur")
+ list=" $cur $list"
+ last=$cur
+ cur=
+
+ for word in $cmdline; do
+ case "$word" in
+ \!gitk|gitk)
+ cur="gitk"
+ break
+ ;;
+ \!*) : shell command alias ;;
+ -*) : option ;;
+ *=*) : setting env ;;
+ git) : git itself ;;
+ \(\)) : skip parens of shell function definition ;;
+ {) : skip start of shell helper function ;;
+ :) : skip null command ;;
+ \'*) : skip opening quote after sh -c ;;
+ *)
+ cur="$word"
+ break
+ esac
+ done
done
+
+ cur=$last
+ if [[ "$cur" != "$1" ]]; then
+ echo "$cur"
+ fi
}
-# __git_find_on_cmdline requires 1 argument
+# Check whether one of the given words is present on the command line,
+# and print the first word found.
+#
+# Usage: __git_find_on_cmdline [<option>]... "<wordlist>"
+# --show-idx: Optionally show the index of the found word in the $words array.
__git_find_on_cmdline ()
{
- local word subcommand c=1
+ local word c=1 show_idx
+
+ while test $# -gt 1; do
+ case "$1" in
+ --show-idx) show_idx=y ;;
+ *) return 1 ;;
+ esac
+ shift
+ done
+ local wordlist="$1"
+
while [ $c -lt $cword ]; do
- word="${words[c]}"
- for subcommand in $1; do
- if [ "$subcommand" = "$word" ]; then
- echo "$subcommand"
+ for word in $wordlist; do
+ if [ "$word" = "${words[c]}" ]; then
+ if [ -n "${show_idx-}" ]; then
+ echo "$c $word"
+ else
+ echo "$word"
+ fi
return
fi
done
@@ -978,6 +1299,40 @@ __git_find_on_cmdline ()
done
}
+# Similar to __git_find_on_cmdline, except that it loops backwards and thus
+# prints the *last* word found. Useful for finding which of two options that
+# supersede each other came last, such as "--guess" and "--no-guess".
+#
+# Usage: __git_find_last_on_cmdline [<option>]... "<wordlist>"
+# --show-idx: Optionally show the index of the found word in the $words array.
+__git_find_last_on_cmdline ()
+{
+ local word c=$cword show_idx
+
+ while test $# -gt 1; do
+ case "$1" in
+ --show-idx) show_idx=y ;;
+ *) return 1 ;;
+ esac
+ shift
+ done
+ local wordlist="$1"
+
+ while [ $c -gt 1 ]; do
+ ((c--))
+ for word in $wordlist; do
+ if [ "$word" = "${words[c]}" ]; then
+ if [ -n "$show_idx" ]; then
+ echo "$c $word"
+ else
+ echo "$word"
+ fi
+ return
+ fi
+ done
+ done
+}
+
# Echo the value of an option set on the command line or config
#
# $1: short option name
@@ -1072,12 +1427,15 @@ __git_count_arguments ()
}
__git_whitespacelist="nowarn warn error error-all fix"
+__git_patchformat="mbox stgit stgit-series hg mboxrd"
+__git_showcurrentpatch="diff raw"
+__git_am_inprogress_options="--skip --continue --resolved --abort --quit --show-current-patch"
_git_am ()
{
__git_find_repo_path
if [ -d "$__git_repo_path"/rebase-apply ]; then
- __gitcomp "--skip --continue --resolved --abort"
+ __gitcomp "$__git_am_inprogress_options"
return
fi
case "$cur" in
@@ -1085,13 +1443,17 @@ _git_am ()
__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
return
;;
+ --patch-format=*)
+ __gitcomp "$__git_patchformat" "" "${cur##--patch-format=}"
+ return
+ ;;
+ --show-current-patch=*)
+ __gitcomp "$__git_showcurrentpatch" "" "${cur##--show-current-patch=}"
+ return
+ ;;
--*)
- __gitcomp "
- --3way --committer-date-is-author-date --ignore-date
- --ignore-whitespace --ignore-space-change
- --interactive --keep --no-utf8 --signoff --utf8
- --whitespace= --scissors
- "
+ __gitcomp_builtin am "" \
+ "$__git_am_inprogress_options"
return
esac
}
@@ -1104,14 +1466,7 @@ _git_apply ()
return
;;
--*)
- __gitcomp "
- --stat --numstat --summary --check --index
- --cached --index-info --reverse --reject --unidiff-zero
- --apply --no-add --exclude=
- --ignore-whitespace --ignore-space-change
- --whitespace= --inaccurate-eof --verbose
- --recount --directory=
- "
+ __gitcomp_builtin apply
return
esac
}
@@ -1119,11 +1474,12 @@ _git_apply ()
_git_add ()
{
case "$cur" in
+ --chmod=*)
+ __gitcomp "+x -x" "" "${cur##--chmod=}"
+ return
+ ;;
--*)
- __gitcomp "
- --interactive --refresh --patch --update --dry-run
- --ignore-errors --intent-to-add --force --edit --chmod=
- "
+ __gitcomp_builtin add
return
esac
@@ -1147,10 +1503,7 @@ _git_archive ()
return
;;
--*)
- __gitcomp "
- --format= --list --verbose
- --prefix= --remote= --exec= --output
- "
+ __gitcomp_builtin archive "--format= --list --verbose --prefix= --worktree-attributes"
return
;;
esac
@@ -1182,6 +1535,8 @@ _git_bisect ()
esac
}
+__git_ref_fieldlist="refname objecttype objectsize objectname upstream push HEAD symref"
+
_git_branch ()
{
local i c=1 only_local_ref="n" has_r="n"
@@ -1200,13 +1555,7 @@ _git_branch ()
__git_complete_refs --cur="${cur##--set-upstream-to=}"
;;
--*)
- __gitcomp "
- --color --no-color --verbose --abbrev= --no-abbrev
- --track --no-track --contains --no-contains --merged --no-merged
- --set-upstream-to= --edit-description --list
- --unset-upstream --delete --move --copy --remotes
- --column --no-column --sort= --points-at
- "
+ __gitcomp_builtin branch
;;
*)
if [ $only_local_ref = "y" -a $has_r = "n" ]; then
@@ -1238,49 +1587,111 @@ _git_bundle ()
esac
}
+# Helper function to decide whether or not we should enable DWIM logic for
+# git-switch and git-checkout.
+#
+# To decide between the following rules in priority order
+# 1) the last provided of "--guess" or "--no-guess" explicitly enable or
+# disable completion of DWIM logic respectively.
+# 2) If the --no-track option is provided, take this as a hint to disable the
+# DWIM completion logic
+# 3) If GIT_COMPLETION_CHECKOUT_NO_GUESS is set, disable the DWIM completion
+# logic, as requested by the user.
+# 4) Enable DWIM logic otherwise.
+#
+__git_checkout_default_dwim_mode ()
+{
+ local last_option dwim_opt="--dwim"
+
+ if [ "${GIT_COMPLETION_CHECKOUT_NO_GUESS-}" = "1" ]; then
+ dwim_opt=""
+ fi
+
+ # --no-track disables DWIM, but with lower priority than
+ # --guess/--no-guess
+ if [ -n "$(__git_find_on_cmdline "--no-track")" ]; then
+ dwim_opt=""
+ fi
+
+ # Find the last provided --guess or --no-guess
+ last_option="$(__git_find_last_on_cmdline "--guess --no-guess")"
+ case "$last_option" in
+ --guess)
+ dwim_opt="--dwim"
+ ;;
+ --no-guess)
+ dwim_opt=""
+ ;;
+ esac
+
+ echo "$dwim_opt"
+}
+
_git_checkout ()
{
__git_has_doubledash && return
+ local dwim_opt="$(__git_checkout_default_dwim_mode)"
+
+ case "$prev" in
+ -b|-B|--orphan)
+ # Complete local branches (and DWIM branch
+ # remote branch names) for an option argument
+ # specifying a new branch name. This is for
+ # convenience, assuming new branches are
+ # possibly based on pre-existing branch names.
+ __git_complete_refs $dwim_opt --mode="heads"
+ return
+ ;;
+ *)
+ ;;
+ esac
+
case "$cur" in
--conflict=*)
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
;;
--*)
- __gitcomp "
- --quiet --ours --theirs --track --no-track --merge
- --conflict= --orphan --patch --detach --ignore-skip-worktree-bits
- --recurse-submodules --no-recurse-submodules
- "
+ __gitcomp_builtin checkout
;;
*)
- # check if --track, --no-track, or --no-guess was specified
- # if so, disable DWIM mode
- local flags="--track --no-track --no-guess" track_opt="--track"
- if [ "$GIT_COMPLETION_CHECKOUT_NO_GUESS" = "1" ] ||
- [ -n "$(__git_find_on_cmdline "$flags")" ]; then
- track_opt=''
+ # At this point, we've already handled special completion for
+ # the arguments to -b/-B, and --orphan. There are 3 main
+ # things left we can possibly complete:
+ # 1) a start-point for -b/-B, -d/--detach, or --orphan
+ # 2) a remote head, for --track
+ # 3) an arbitrary reference, possibly including DWIM names
+ #
+
+ if [ -n "$(__git_find_on_cmdline "-b -B -d --detach --orphan")" ]; then
+ __git_complete_refs --mode="refs"
+ elif [ -n "$(__git_find_on_cmdline "--track")" ]; then
+ __git_complete_refs --mode="remote-heads"
+ else
+ __git_complete_refs $dwim_opt --mode="refs"
fi
- __git_complete_refs $track_opt
;;
esac
}
-_git_cherry ()
-{
- __git_complete_refs
-}
+__git_sequencer_inprogress_options="--continue --quit --abort --skip"
+
+__git_cherry_pick_inprogress_options=$__git_sequencer_inprogress_options
_git_cherry_pick ()
{
__git_find_repo_path
if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD ]; then
- __gitcomp "--continue --quit --abort"
+ __gitcomp "$__git_cherry_pick_inprogress_options"
return
fi
+
+ __git_complete_strategy && return
+
case "$cur" in
--*)
- __gitcomp "--edit --no-commit --signoff --strategy= --mainline"
+ __gitcomp_builtin cherry-pick "" \
+ "$__git_cherry_pick_inprogress_options"
;;
*)
__git_complete_refs
@@ -1292,7 +1703,7 @@ _git_clean ()
{
case "$cur" in
--*)
- __gitcomp "--dry-run --quiet"
+ __gitcomp_builtin clean
return
;;
esac
@@ -1303,28 +1714,20 @@ _git_clean ()
_git_clone ()
{
+ case "$prev" in
+ -c|--config)
+ __git_complete_config_variable_name_and_value
+ return
+ ;;
+ esac
case "$cur" in
+ --config=*)
+ __git_complete_config_variable_name_and_value \
+ --cur="${cur##--config=}"
+ return
+ ;;
--*)
- __gitcomp "
- --local
- --no-hardlinks
- --shared
- --reference
- --quiet
- --no-checkout
- --bare
- --mirror
- --origin
- --upload-pack
- --template=
- --depth
- --single-branch
- --no-tags
- --branch
- --recurse-submodules
- --no-single-branch
- --shallow-submodules
- "
+ __gitcomp_builtin clone
return
;;
esac
@@ -1357,16 +1760,7 @@ _git_commit ()
return
;;
--*)
- __gitcomp "
- --all --author= --signoff --verify --no-verify
- --edit --no-edit
- --amend --include --only --interactive
- --dry-run --reuse-message= --reedit-message=
- --reset-author --file= --message= --template=
- --cleanup= --untracked-files --untracked-files=
- --verbose --quiet --fixup= --squash=
- --patch --short --date --allow-empty
- "
+ __gitcomp_builtin commit
return
esac
@@ -1382,11 +1776,7 @@ _git_describe ()
{
case "$cur" in
--*)
- __gitcomp "
- --all --tags --contains --abbrev= --candidates=
- --exact-match --debug --long --match --always --first-parent
- --exclude --dirty --broken
- "
+ __gitcomp_builtin describe
return
esac
__git_complete_refs
@@ -1396,9 +1786,16 @@ __git_diff_algorithms="myers minimal patience histogram"
__git_diff_submodule_formats="diff log short"
+__git_color_moved_opts="no default plain blocks zebra dimmed-zebra"
+
+__git_color_moved_ws_opts="no ignore-space-at-eol ignore-space-change
+ ignore-all-space allow-indentation-change"
+
__git_diff_common_options="--stat --numstat --shortstat --summary
--patch-with-stat --name-only --name-status --color
--no-color --color-words --no-renames --check
+ --color-moved --color-moved= --no-color-moved
+ --color-moved-ws= --no-color-moved-ws
--full-index --binary --abbrev --diff-filter=
--find-copies-harder --ignore-cr-at-eol
--text --ignore-space-at-eol --ignore-space-change
@@ -1411,7 +1808,9 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
--dirstat --dirstat= --dirstat-by-file
--dirstat-by-file= --cumulative
--diff-algorithm=
- --submodule --submodule=
+ --submodule --submodule= --ignore-submodules
+ --indent-heuristic --no-indent-heuristic
+ --textconv --no-textconv
"
_git_diff ()
@@ -1427,6 +1826,14 @@ _git_diff ()
__gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
return
;;
+ --color-moved=*)
+ __gitcomp "$__git_color_moved_opts" "" "${cur##--color-moved=}"
+ return
+ ;;
+ --color-moved-ws=*)
+ __gitcomp "$__git_color_moved_ws_opts" "" "${cur##--color-moved-ws=}"
+ return
+ ;;
--*)
__gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
--base --ours --theirs --no-index
@@ -1439,7 +1846,8 @@ _git_diff ()
}
__git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
- tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
+ tkdiff vimdiff nvimdiff gvimdiff xxdiff araxis p4merge
+ bc codecompare smerge
"
_git_difftool ()
@@ -1452,11 +1860,11 @@ _git_difftool ()
return
;;
--*)
- __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
- --base --ours --theirs
- --no-renames --diff-filter= --find-copies-harder
- --relative --ignore-submodules
- --tool="
+ __gitcomp_builtin difftool "$__git_diff_common_options
+ --base --cached --ours --theirs
+ --pickaxe-all --pickaxe-regex
+ --relative --staged
+ "
return
;;
esac
@@ -1465,12 +1873,6 @@ _git_difftool ()
__git_fetch_recurse_submodules="yes on-demand no"
-__git_fetch_options="
- --quiet --verbose --append --upload-pack --force --keep --depth=
- --tags --no-tags --all --prune --dry-run --recurse-submodules=
- --unshallow --update-shallow
-"
-
_git_fetch ()
{
case "$cur" in
@@ -1478,21 +1880,21 @@ _git_fetch ()
__gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
return
;;
+ --filter=*)
+ __gitcomp "blob:none blob:limit= sparse:oid=" "" "${cur##--filter=}"
+ return
+ ;;
--*)
- __gitcomp "$__git_fetch_options"
+ __gitcomp_builtin fetch
return
;;
esac
__git_complete_remote_or_refspec
}
-__git_format_patch_options="
- --stdout --attach --no-attach --thread --thread= --no-thread
- --numbered --start-number --numbered-files --keep-subject --signoff
- --signature --no-signature --in-reply-to= --cc= --full-index --binary
- --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
- --inline --suffix= --ignore-if-in-upstream --subject-prefix=
- --output-directory --reroll-count --to= --quiet --notes
+__git_format_patch_extra_options="
+ --full-index --not --all --no-prefix --src-prefix=
+ --dst-prefix= --notes
"
_git_format_patch ()
@@ -1504,32 +1906,23 @@ _git_format_patch ()
" "" "${cur##--thread=}"
return
;;
- --*)
- __gitcomp "$__git_format_patch_options"
+ --base=*|--interdiff=*|--range-diff=*)
+ __git_complete_refs --cur="${cur#--*=}"
return
;;
- esac
- __git_complete_revlist
-}
-
-_git_fsck ()
-{
- case "$cur" in
--*)
- __gitcomp "
- --tags --root --unreachable --cache --no-reflogs --full
- --strict --verbose --lost-found --name-objects
- "
+ __gitcomp_builtin format-patch "$__git_format_patch_extra_options"
return
;;
esac
+ __git_complete_revlist
}
-_git_gc ()
+_git_fsck ()
{
case "$cur" in
--*)
- __gitcomp "--prune --aggressive"
+ __gitcomp_builtin fsck
return
;;
esac
@@ -1585,21 +1978,7 @@ _git_grep ()
case "$cur" in
--*)
- __gitcomp "
- --cached
- --text --ignore-case --word-regexp --invert-match
- --full-name --line-number
- --extended-regexp --basic-regexp --fixed-strings
- --perl-regexp
- --threads
- --files-with-matches --name-only
- --files-without-match
- --max-depth
- --count
- --and --or --not --all-match
- --break --heading --show-function --function-context
- --untracked --no-index
- "
+ __gitcomp_builtin grep
return
;;
esac
@@ -1617,17 +1996,16 @@ _git_help ()
{
case "$cur" in
--*)
- __gitcomp "--all --guides --info --man --web"
+ __gitcomp_builtin help
return
;;
esac
- __git_compute_all_commands
- __gitcomp "$__git_all_commands $(__git_aliases)
- attributes cli core-tutorial cvs-migration
- diffcore everyday gitk glossary hooks ignore modules
- namespaces repository-layout revisions tutorial tutorial-2
- workflows
- "
+ if test -n "$GIT_TESTING_ALL_COMMAND_LIST"
+ then
+ __gitcomp "$GIT_TESTING_ALL_COMMAND_LIST $(__git --list-cmds=alias,list-guide) gitk"
+ else
+ __gitcomp "$(__git --list-cmds=main,nohelpers,alias,list-guide) gitk"
+ fi
}
_git_init ()
@@ -1640,7 +2018,7 @@ _git_init ()
return
;;
--*)
- __gitcomp "--quiet --bare --template= --shared --shared="
+ __gitcomp_builtin init
return
;;
esac
@@ -1650,13 +2028,7 @@ _git_ls_files ()
{
case "$cur" in
--*)
- __gitcomp "--cached --deleted --modified --others --ignored
- --stage --directory --no-empty-directory --unmerged
- --killed --exclude= --exclude-from=
- --exclude-per-directory= --exclude-standard
- --error-unmatch --with-tree= --full-name
- --abbrev --ignored --exclude-per-directory
- "
+ __gitcomp_builtin ls-files
return
;;
esac
@@ -1670,7 +2042,7 @@ _git_ls_remote ()
{
case "$cur" in
--*)
- __gitcomp "--heads --tags --refs --get-url --symref"
+ __gitcomp_builtin ls-remote
return
;;
esac
@@ -1679,6 +2051,13 @@ _git_ls_remote ()
_git_ls_tree ()
{
+ case "$cur" in
+ --*)
+ __gitcomp_builtin ls-tree
+ return
+ ;;
+ esac
+
__git_complete_file
}
@@ -1705,8 +2084,8 @@ __git_log_shortlog_options="
--all-match --invert-grep
"
-__git_log_pretty_formats="oneline short medium full fuller email raw format:"
-__git_log_date_formats="relative iso8601 rfc2822 short local default raw"
+__git_log_pretty_formats="oneline short medium full fuller reference email raw format: tformat: mboxrd"
+__git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default raw unix format:"
_git_log ()
{
@@ -1752,6 +2131,10 @@ _git_log ()
__gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
return
;;
+ --no-walk=*)
+ __gitcomp "sorted unsorted" "" "${cur##--no-walk=}"
+ return
+ ;;
--*)
__gitcomp "
$__git_log_common_options
@@ -1759,19 +2142,23 @@ _git_log ()
$__git_log_gitk_options
--root --topo-order --date-order --reverse
--follow --full-diff
- --abbrev-commit --abbrev=
+ --abbrev-commit --no-abbrev-commit --abbrev=
--relative-date --date=
--pretty= --format= --oneline
--show-signature
--cherry-mark
--cherry-pick
--graph
- --decorate --decorate=
+ --decorate --decorate= --no-decorate
--walk-reflogs
+ --no-walk --no-walk= --do-walk
--parents --children
+ --expand-tabs --expand-tabs= --no-expand-tabs
+ --patch
$merge
$__git_diff_common_options
--pickaxe-all --pickaxe-regex
+ --patch --no-patch
"
return
;;
@@ -1794,22 +2181,13 @@ _git_log ()
__git_complete_revlist
}
-# Common merge options shared by git-merge(1) and git-pull(1).
-__git_merge_options="
- --no-commit --no-stat --log --no-log --squash --strategy
- --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
- --verify-signatures --no-verify-signatures --gpg-sign
- --quiet --verbose --progress --no-progress
-"
-
_git_merge ()
{
__git_complete_strategy && return
case "$cur" in
--*)
- __gitcomp "$__git_merge_options
- --rerere-autoupdate --no-rerere-autoupdate --abort --continue"
+ __gitcomp_builtin merge
return
esac
__git_complete_refs
@@ -1823,7 +2201,7 @@ _git_mergetool ()
return
;;
--*)
- __gitcomp "--tool= --prompt --no-prompt"
+ __gitcomp "--tool= --prompt --no-prompt --gui --no-gui"
return
;;
esac
@@ -1833,7 +2211,7 @@ _git_merge_base ()
{
case "$cur" in
--*)
- __gitcomp "--octopus --independent --is-ancestor --fork-point"
+ __gitcomp_builtin merge-base
return
;;
esac
@@ -1844,7 +2222,7 @@ _git_mv ()
{
case "$cur" in
--*)
- __gitcomp "--dry-run"
+ __gitcomp_builtin mv
return
;;
esac
@@ -1858,19 +2236,14 @@ _git_mv ()
fi
}
-_git_name_rev ()
-{
- __gitcomp "--tags --all --stdin"
-}
-
_git_notes ()
{
- local subcommands='add append copy edit list prune remove show'
+ local subcommands='add append copy edit get-ref list merge prune remove show'
local subcommand="$(__git_find_on_cmdline "$subcommands")"
case "$subcommand,$cur" in
,--*)
- __gitcomp '--ref'
+ __gitcomp_builtin notes
;;
,*)
case "$prev" in
@@ -1882,21 +2255,14 @@ _git_notes ()
;;
esac
;;
- add,--reuse-message=*|append,--reuse-message=*|\
- add,--reedit-message=*|append,--reedit-message=*)
+ *,--reuse-message=*|*,--reedit-message=*)
__git_complete_refs --cur="${cur#*=}"
;;
- add,--*|append,--*)
- __gitcomp '--file= --message= --reedit-message=
- --reuse-message='
- ;;
- copy,--*)
- __gitcomp '--stdin'
+ *,--*)
+ __gitcomp_builtin notes_$subcommand
;;
- prune,--*)
- __gitcomp '--dry-run --verbose'
- ;;
- prune,*)
+ prune,*|get-ref,*)
+ # this command does not take a ref, do not complete it
;;
*)
case "$prev" in
@@ -1920,12 +2286,8 @@ _git_pull ()
return
;;
--*)
- __gitcomp "
- --rebase --no-rebase
- --autostash --no-autostash
- $__git_merge_options
- $__git_fetch_options
- "
+ __gitcomp_builtin pull
+
return
;;
esac
@@ -1976,27 +2338,39 @@ _git_push ()
return
;;
--*)
+ __gitcomp_builtin push
+ return
+ ;;
+ esac
+ __git_complete_remote_or_refspec
+}
+
+_git_range_diff ()
+{
+ case "$cur" in
+ --*)
__gitcomp "
- --all --mirror --tags --dry-run --force --verbose
- --quiet --prune --delete --follow-tags
- --receive-pack= --repo= --set-upstream
- --force-with-lease --force-with-lease= --recurse-submodules=
+ --creation-factor= --no-dual-color
+ $__git_diff_common_options
"
return
;;
esac
- __git_complete_remote_or_refspec
+ __git_complete_revlist
}
+__git_rebase_inprogress_options="--continue --skip --abort --quit --show-current-patch"
+__git_rebase_interactive_inprogress_options="$__git_rebase_inprogress_options --edit-todo"
+
_git_rebase ()
{
__git_find_repo_path
if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then
- __gitcomp "--continue --skip --abort --quit --edit-todo"
+ __gitcomp "$__git_rebase_interactive_inprogress_options"
return
elif [ -d "$__git_repo_path"/rebase-apply ] || \
[ -d "$__git_repo_path"/rebase-merge ]; then
- __gitcomp "--continue --skip --abort --quit"
+ __gitcomp "$__git_rebase_inprogress_options"
return
fi
__git_complete_strategy && return
@@ -2005,19 +2379,13 @@ _git_rebase ()
__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
return
;;
+ --onto=*)
+ __git_complete_refs --cur="${cur##--onto=}"
+ return
+ ;;
--*)
- __gitcomp "
- --onto --merge --strategy --interactive
- --preserve-merges --stat --no-stat
- --committer-date-is-author-date --ignore-date
- --ignore-whitespace --whitespace=
- --autosquash --no-autosquash
- --fork-point --no-fork-point
- --autostash --no-autostash
- --verify --no-verify
- --keep-empty --root --force-rebase --no-ff
- --exec
- "
+ __gitcomp_builtin rebase "" \
+ "$__git_rebase_interactive_inprogress_options"
return
esac
@@ -2077,16 +2445,16 @@ _git_send_email ()
return
;;
--*)
- __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
+ __gitcomp_builtin send-email "--annotate --bcc --cc --cc-cmd --chain-reply-to
--compose --confirm= --dry-run --envelope-sender
--from --identity
--in-reply-to --no-chain-reply-to --no-signed-off-by-cc
- --no-suppress-from --no-thread --quiet
+ --no-suppress-from --no-thread --quiet --reply-to
--signed-off-by-cc --smtp-pass --smtp-server
--smtp-server-port --smtp-encryption= --smtp-user
--subject --suppress-cc= --suppress-from --thread --to
--validate --no-validate
- $__git_format_patch_options"
+ $__git_format_patch_extra_options"
return
;;
esac
@@ -2119,11 +2487,7 @@ _git_status ()
return
;;
--*)
- __gitcomp "
- --short --branch --porcelain --long --verbose
- --untracked-files= --ignore-submodules= --ignored
- --column= --no-column
- "
+ __gitcomp_builtin status
return
;;
esac
@@ -2148,6 +2512,57 @@ _git_status ()
__git_complete_index_file "$complete_opt"
}
+_git_switch ()
+{
+ local dwim_opt="$(__git_checkout_default_dwim_mode)"
+
+ case "$prev" in
+ -c|-C|--orphan)
+ # Complete local branches (and DWIM branch
+ # remote branch names) for an option argument
+ # specifying a new branch name. This is for
+ # convenience, assuming new branches are
+ # possibly based on pre-existing branch names.
+ __git_complete_refs $dwim_opt --mode="heads"
+ return
+ ;;
+ *)
+ ;;
+ esac
+
+ case "$cur" in
+ --conflict=*)
+ __gitcomp "diff3 merge" "" "${cur##--conflict=}"
+ ;;
+ --*)
+ __gitcomp_builtin switch
+ ;;
+ *)
+ # Unlike in git checkout, git switch --orphan does not take
+ # a start point. Thus we really have nothing to complete after
+ # the branch name.
+ if [ -n "$(__git_find_on_cmdline "--orphan")" ]; then
+ return
+ fi
+
+ # At this point, we've already handled special completion for
+ # -c/-C, and --orphan. There are 3 main things left to
+ # complete:
+ # 1) a start-point for -c/-C or -d/--detach
+ # 2) a remote head, for --track
+ # 3) a branch name, possibly including DWIM remote branches
+
+ if [ -n "$(__git_find_on_cmdline "-c -C -d --detach")" ]; then
+ __git_complete_refs --mode="refs"
+ elif [ -n "$(__git_find_on_cmdline "--track")" ]; then
+ __git_complete_refs --mode="remote-heads"
+ else
+ __git_complete_refs $dwim_opt --mode="heads"
+ fi
+ ;;
+ esac
+}
+
__git_config_get_set_variables ()
{
local prevword word config_file= c=$cword
@@ -2170,496 +2585,287 @@ __git_config_get_set_variables ()
__git config $config_file --name-only --list
}
-_git_config ()
+__git_config_vars=
+__git_compute_config_vars ()
{
- case "$prev" in
+ test -n "$__git_config_vars" ||
+ __git_config_vars="$(git help --config-for-completion | sort -u)"
+}
+
+# Completes possible values of various configuration variables.
+#
+# Usage: __git_complete_config_variable_value [<option>]...
+# --varname=<word>: The name of the configuration variable whose value is
+# to be completed. Defaults to the previous word on the
+# command line.
+# --cur=<word>: The current value to be completed. Defaults to the current
+# word to be completed.
+__git_complete_config_variable_value ()
+{
+ local varname="$prev" cur_="$cur"
+
+ while test $# != 0; do
+ case "$1" in
+ --varname=*) varname="${1##--varname=}" ;;
+ --cur=*) cur_="${1##--cur=}" ;;
+ *) return 1 ;;
+ esac
+ shift
+ done
+
+ if [ "${BASH_VERSINFO[0]:-0}" -ge 4 ]; then
+ varname="${varname,,}"
+ else
+ varname="$(echo "$varname" |tr A-Z a-z)"
+ fi
+
+ case "$varname" in
branch.*.remote|branch.*.pushremote)
- __gitcomp_nl "$(__git_remotes)"
+ __gitcomp_nl "$(__git_remotes)" "" "$cur_"
return
;;
branch.*.merge)
- __git_complete_refs
+ __git_complete_refs --cur="$cur_"
return
;;
branch.*.rebase)
- __gitcomp "false true preserve interactive"
+ __gitcomp "false true merges preserve interactive" "" "$cur_"
return
;;
remote.pushdefault)
- __gitcomp_nl "$(__git_remotes)"
+ __gitcomp_nl "$(__git_remotes)" "" "$cur_"
return
;;
remote.*.fetch)
- local remote="${prev#remote.}"
+ local remote="${varname#remote.}"
remote="${remote%.fetch}"
- if [ -z "$cur" ]; then
+ if [ -z "$cur_" ]; then
__gitcomp_nl "refs/heads/" "" "" ""
return
fi
- __gitcomp_nl "$(__git_refs_remotes "$remote")"
+ __gitcomp_nl "$(__git_refs_remotes "$remote")" "" "$cur_"
return
;;
remote.*.push)
- local remote="${prev#remote.}"
+ local remote="${varname#remote.}"
remote="${remote%.push}"
__gitcomp_nl "$(__git for-each-ref \
- --format='%(refname):%(refname)' refs/heads)"
+ --format='%(refname):%(refname)' refs/heads)" "" "$cur_"
return
;;
pull.twohead|pull.octopus)
__git_compute_merge_strategies
- __gitcomp "$__git_merge_strategies"
- return
- ;;
- color.branch|color.diff|color.interactive|\
- color.showbranch|color.status|color.ui)
- __gitcomp "always never auto"
+ __gitcomp "$__git_merge_strategies" "" "$cur_"
return
;;
color.pager)
- __gitcomp "false true"
+ __gitcomp "false true" "" "$cur_"
return
;;
color.*.*)
__gitcomp "
normal black red green yellow blue magenta cyan white
bold dim ul blink reverse
- "
+ " "" "$cur_"
+ return
+ ;;
+ color.*)
+ __gitcomp "false true always never auto" "" "$cur_"
return
;;
diff.submodule)
- __gitcomp "log short"
+ __gitcomp "$__git_diff_submodule_formats" "" "$cur_"
return
;;
help.format)
- __gitcomp "man info web html"
+ __gitcomp "man info web html" "" "$cur_"
return
;;
log.date)
- __gitcomp "$__git_log_date_formats"
+ __gitcomp "$__git_log_date_formats" "" "$cur_"
return
;;
- sendemail.aliasesfiletype)
- __gitcomp "mutt mailrc pine elm gnus"
+ sendemail.aliasfiletype)
+ __gitcomp "mutt mailrc pine elm gnus" "" "$cur_"
return
;;
sendemail.confirm)
- __gitcomp "$__git_send_email_confirm_options"
+ __gitcomp "$__git_send_email_confirm_options" "" "$cur_"
return
;;
sendemail.suppresscc)
- __gitcomp "$__git_send_email_suppresscc_options"
+ __gitcomp "$__git_send_email_suppresscc_options" "" "$cur_"
return
;;
sendemail.transferencoding)
- __gitcomp "7bit 8bit quoted-printable base64"
- return
- ;;
- --get|--get-all|--unset|--unset-all)
- __gitcomp_nl "$(__git_config_get_set_variables)"
+ __gitcomp "7bit 8bit quoted-printable base64" "" "$cur_"
return
;;
*.*)
return
;;
esac
- case "$cur" in
- --*)
- __gitcomp "
- --system --global --local --file=
- --list --replace-all
- --get --get-all --get-regexp
- --add --unset --unset-all
- --remove-section --rename-section
- --name-only
- "
- return
- ;;
+}
+
+# Completes configuration sections, subsections, variable names.
+#
+# Usage: __git_complete_config_variable_name [<option>]...
+# --cur=<word>: The current configuration section/variable name to be
+# completed. Defaults to the current word to be completed.
+# --sfx=<suffix>: A suffix to be appended to each fully completed
+# configuration variable name (but not to sections or
+# subsections) instead of the default space.
+__git_complete_config_variable_name ()
+{
+ local cur_="$cur" sfx
+
+ while test $# != 0; do
+ case "$1" in
+ --cur=*) cur_="${1##--cur=}" ;;
+ --sfx=*) sfx="${1##--sfx=}" ;;
+ *) return 1 ;;
+ esac
+ shift
+ done
+
+ case "$cur_" in
branch.*.*)
- local pfx="${cur%.*}." cur_="${cur##*.}"
- __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"
+ local pfx="${cur_%.*}."
+ cur_="${cur_##*.}"
+ __gitcomp "remote pushRemote merge mergeOptions rebase" "$pfx" "$cur_" "$sfx"
return
;;
branch.*)
- local pfx="${cur%.*}." cur_="${cur#*.}"
+ local pfx="${cur_%.*}."
+ cur_="${cur_#*.}"
__gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
- __gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
+ __gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx:- }"
return
;;
guitool.*.*)
- local pfx="${cur%.*}." cur_="${cur##*.}"
+ local pfx="${cur_%.*}."
+ cur_="${cur_##*.}"
__gitcomp "
- argprompt cmd confirm needsfile noconsole norescan
- prompt revprompt revunmerged title
- " "$pfx" "$cur_"
+ argPrompt cmd confirm needsFile noConsole noRescan
+ prompt revPrompt revUnmerged title
+ " "$pfx" "$cur_" "$sfx"
return
;;
difftool.*.*)
- local pfx="${cur%.*}." cur_="${cur##*.}"
- __gitcomp "cmd path" "$pfx" "$cur_"
+ local pfx="${cur_%.*}."
+ cur_="${cur_##*.}"
+ __gitcomp "cmd path" "$pfx" "$cur_" "$sfx"
return
;;
man.*.*)
- local pfx="${cur%.*}." cur_="${cur##*.}"
- __gitcomp "cmd path" "$pfx" "$cur_"
+ local pfx="${cur_%.*}."
+ cur_="${cur_##*.}"
+ __gitcomp "cmd path" "$pfx" "$cur_" "$sfx"
return
;;
mergetool.*.*)
- local pfx="${cur%.*}." cur_="${cur##*.}"
- __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
+ local pfx="${cur_%.*}."
+ cur_="${cur_##*.}"
+ __gitcomp "cmd path trustExitCode" "$pfx" "$cur_" "$sfx"
return
;;
pager.*)
- local pfx="${cur%.*}." cur_="${cur#*.}"
+ local pfx="${cur_%.*}."
+ cur_="${cur_#*.}"
__git_compute_all_commands
- __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"
+ __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx:- }"
return
;;
remote.*.*)
- local pfx="${cur%.*}." cur_="${cur##*.}"
+ local pfx="${cur_%.*}."
+ cur_="${cur_##*.}"
__gitcomp "
url proxy fetch push mirror skipDefaultUpdate
- receivepack uploadpack tagopt pushurl
- " "$pfx" "$cur_"
+ receivepack uploadpack tagOpt pushurl
+ " "$pfx" "$cur_" "$sfx"
return
;;
remote.*)
- local pfx="${cur%.*}." cur_="${cur#*.}"
+ local pfx="${cur_%.*}."
+ cur_="${cur_#*.}"
__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
- __gitcomp_nl_append "pushdefault" "$pfx" "$cur_"
+ __gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx:- }"
return
;;
url.*.*)
- local pfx="${cur%.*}." cur_="${cur##*.}"
- __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
- return
- ;;
- esac
- __gitcomp "
- add.ignoreErrors
- advice.amWorkDir
- advice.commitBeforeMerge
- advice.detachedHead
- advice.implicitIdentity
- advice.pushAlreadyExists
- advice.pushFetchFirst
- advice.pushNeedsForce
- advice.pushNonFFCurrent
- advice.pushNonFFMatching
- advice.pushUpdateRejected
- advice.resolveConflict
- advice.rmHints
- advice.statusHints
- advice.statusUoption
- advice.ignoredHook
- alias.
- am.keepcr
- am.threeWay
- apply.ignorewhitespace
- apply.whitespace
- branch.autosetupmerge
- branch.autosetuprebase
- browser.
- clean.requireForce
- color.branch
- color.branch.current
- color.branch.local
- color.branch.plain
- color.branch.remote
- color.decorate.HEAD
- color.decorate.branch
- color.decorate.remoteBranch
- color.decorate.stash
- color.decorate.tag
- color.diff
- color.diff.commit
- color.diff.frag
- color.diff.func
- color.diff.meta
- color.diff.new
- color.diff.old
- color.diff.plain
- color.diff.whitespace
- color.grep
- color.grep.context
- color.grep.filename
- color.grep.function
- color.grep.linenumber
- color.grep.match
- color.grep.selected
- color.grep.separator
- color.interactive
- color.interactive.error
- color.interactive.header
- color.interactive.help
- color.interactive.prompt
- color.pager
- color.showbranch
- color.status
- color.status.added
- color.status.changed
- color.status.header
- color.status.localBranch
- color.status.nobranch
- color.status.remoteBranch
- color.status.unmerged
- color.status.untracked
- color.status.updated
- color.ui
- commit.cleanup
- commit.gpgSign
- commit.status
- commit.template
- commit.verbose
- core.abbrev
- core.askpass
- core.attributesfile
- core.autocrlf
- core.bare
- core.bigFileThreshold
- core.checkStat
- core.commentChar
- core.compression
- core.createObject
- core.deltaBaseCacheLimit
- core.editor
- core.eol
- core.excludesfile
- core.fileMode
- core.fsyncobjectfiles
- core.gitProxy
- core.hideDotFiles
- core.hooksPath
- core.ignoreStat
- core.ignorecase
- core.logAllRefUpdates
- core.loosecompression
- core.notesRef
- core.packedGitLimit
- core.packedGitWindowSize
- core.packedRefsTimeout
- core.pager
- core.precomposeUnicode
- core.preferSymlinkRefs
- core.preloadindex
- core.protectHFS
- core.protectNTFS
- core.quotepath
- core.repositoryFormatVersion
- core.safecrlf
- core.sharedRepository
- core.sparseCheckout
- core.splitIndex
- core.sshCommand
- core.symlinks
- core.trustctime
- core.untrackedCache
- core.warnAmbiguousRefs
- core.whitespace
- core.worktree
- credential.helper
- credential.useHttpPath
- credential.username
- credentialCache.ignoreSIGHUP
- diff.autorefreshindex
- diff.external
- diff.ignoreSubmodules
- diff.mnemonicprefix
- diff.noprefix
- diff.renameLimit
- diff.renames
- diff.statGraphWidth
- diff.submodule
- diff.suppressBlankEmpty
- diff.tool
- diff.wordRegex
- diff.algorithm
- difftool.
- difftool.prompt
- fetch.recurseSubmodules
- fetch.unpackLimit
- format.attach
- format.cc
- format.coverLetter
- format.from
- format.headers
- format.numbered
- format.pretty
- format.signature
- format.signoff
- format.subjectprefix
- format.suffix
- format.thread
- format.to
- gc.
- gc.aggressiveDepth
- gc.aggressiveWindow
- gc.auto
- gc.autoDetach
- gc.autopacklimit
- gc.logExpiry
- gc.packrefs
- gc.pruneexpire
- gc.reflogexpire
- gc.reflogexpireunreachable
- gc.rerereresolved
- gc.rerereunresolved
- gc.worktreePruneExpire
- gitcvs.allbinary
- gitcvs.commitmsgannotation
- gitcvs.dbTableNamePrefix
- gitcvs.dbdriver
- gitcvs.dbname
- gitcvs.dbpass
- gitcvs.dbuser
- gitcvs.enabled
- gitcvs.logfile
- gitcvs.usecrlfattr
- guitool.
- gui.blamehistoryctx
- gui.commitmsgwidth
- gui.copyblamethreshold
- gui.diffcontext
- gui.encoding
- gui.fastcopyblame
- gui.matchtrackingbranch
- gui.newbranchtemplate
- gui.pruneduringfetch
- gui.spellingdictionary
- gui.trustmtime
- help.autocorrect
- help.browser
- help.format
- http.lowSpeedLimit
- http.lowSpeedTime
- http.maxRequests
- http.minSessions
- http.noEPSV
- http.postBuffer
- http.proxy
- http.sslCipherList
- http.sslVersion
- http.sslCAInfo
- http.sslCAPath
- http.sslCert
- http.sslCertPasswordProtected
- http.sslKey
- http.sslVerify
- http.useragent
- i18n.commitEncoding
- i18n.logOutputEncoding
- imap.authMethod
- imap.folder
- imap.host
- imap.pass
- imap.port
- imap.preformattedHTML
- imap.sslverify
- imap.tunnel
- imap.user
- init.templatedir
- instaweb.browser
- instaweb.httpd
- instaweb.local
- instaweb.modulepath
- instaweb.port
- interactive.singlekey
- log.date
- log.decorate
- log.showroot
- mailmap.file
- man.
- man.viewer
- merge.
- merge.conflictstyle
- merge.log
- merge.renameLimit
- merge.renormalize
- merge.stat
- merge.tool
- merge.verbosity
- mergetool.
- mergetool.keepBackup
- mergetool.keepTemporaries
- mergetool.prompt
- notes.displayRef
- notes.rewrite.
- notes.rewrite.amend
- notes.rewrite.rebase
- notes.rewriteMode
- notes.rewriteRef
- pack.compression
- pack.deltaCacheLimit
- pack.deltaCacheSize
- pack.depth
- pack.indexVersion
- pack.packSizeLimit
- pack.threads
- pack.window
- pack.windowMemory
- pager.
- pretty.
- pull.octopus
- pull.twohead
- push.default
- push.followTags
- rebase.autosquash
- rebase.stat
- receive.autogc
- receive.denyCurrentBranch
- receive.denyDeleteCurrent
- receive.denyDeletes
- receive.denyNonFastForwards
- receive.fsckObjects
- receive.unpackLimit
- receive.updateserverinfo
- remote.pushdefault
- remotes.
- repack.usedeltabaseoffset
- rerere.autoupdate
- rerere.enabled
- sendemail.
- sendemail.aliasesfile
- sendemail.aliasfiletype
- sendemail.bcc
- sendemail.cc
- sendemail.cccmd
- sendemail.chainreplyto
- sendemail.confirm
- sendemail.envelopesender
- sendemail.from
- sendemail.identity
- sendemail.multiedit
- sendemail.signedoffbycc
- sendemail.smtpdomain
- sendemail.smtpencryption
- sendemail.smtppass
- sendemail.smtpserver
- sendemail.smtpserveroption
- sendemail.smtpserverport
- sendemail.smtpuser
- sendemail.suppresscc
- sendemail.suppressfrom
- sendemail.thread
- sendemail.to
- sendemail.tocmd
- sendemail.validate
- sendemail.smtpbatchsize
- sendemail.smtprelogindelay
- showbranch.default
- status.relativePaths
- status.showUntrackedFiles
- status.submodulesummary
- submodule.
- tar.umask
- transfer.unpackLimit
- url.
- user.email
- user.name
- user.signingkey
- web.browser
- branch. remote.
- "
+ local pfx="${cur_%.*}."
+ cur_="${cur_##*.}"
+ __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_" "$sfx"
+ return
+ ;;
+ *.*)
+ __git_compute_config_vars
+ __gitcomp "$__git_config_vars" "" "$cur_" "$sfx"
+ ;;
+ *)
+ __git_compute_config_vars
+ __gitcomp "$(echo "$__git_config_vars" |
+ awk -F . '{
+ sections[$1] = 1
+ }
+ END {
+ for (s in sections)
+ print s "."
+ }
+ ')" "" "$cur_"
+ ;;
+ esac
+}
+
+# Completes '='-separated configuration sections/variable names and values
+# for 'git -c section.name=value'.
+#
+# Usage: __git_complete_config_variable_name_and_value [<option>]...
+# --cur=<word>: The current configuration section/variable name/value to be
+# completed. Defaults to the current word to be completed.
+__git_complete_config_variable_name_and_value ()
+{
+ local cur_="$cur"
+
+ while test $# != 0; do
+ case "$1" in
+ --cur=*) cur_="${1##--cur=}" ;;
+ *) return 1 ;;
+ esac
+ shift
+ done
+
+ case "$cur_" in
+ *=*)
+ __git_complete_config_variable_value \
+ --varname="${cur_%%=*}" --cur="${cur_#*=}"
+ ;;
+ *)
+ __git_complete_config_variable_name --cur="$cur_" --sfx='='
+ ;;
+ esac
+}
+
+_git_config ()
+{
+ case "$prev" in
+ --get|--get-all|--unset|--unset-all)
+ __gitcomp_nl "$(__git_config_get_set_variables)"
+ return
+ ;;
+ *.*)
+ __git_complete_config_variable_value
+ return
+ ;;
+ esac
+ case "$cur" in
+ --*)
+ __gitcomp_builtin config
+ ;;
+ *)
+ __git_complete_config_variable_name
+ ;;
+ esac
}
_git_remote ()
@@ -2672,7 +2878,7 @@ _git_remote ()
if [ -z "$subcommand" ]; then
case "$cur" in
--*)
- __gitcomp "--verbose"
+ __gitcomp_builtin remote
;;
*)
__gitcomp "$subcommands"
@@ -2683,33 +2889,33 @@ _git_remote ()
case "$subcommand,$cur" in
add,--*)
- __gitcomp "--track --master --fetch --tags --no-tags --mirror="
+ __gitcomp_builtin remote_add
;;
add,*)
;;
set-head,--*)
- __gitcomp "--auto --delete"
+ __gitcomp_builtin remote_set-head
;;
set-branches,--*)
- __gitcomp "--add"
+ __gitcomp_builtin remote_set-branches
;;
set-head,*|set-branches,*)
__git_complete_remote_or_refspec
;;
update,--*)
- __gitcomp "--prune"
+ __gitcomp_builtin remote_update
;;
update,*)
- __gitcomp "$(__git_get_config_variables "remotes")"
+ __gitcomp "$(__git_remotes) $(__git_get_config_variables "remotes")"
;;
set-url,--*)
- __gitcomp "--push --add --delete"
+ __gitcomp_builtin remote_set-url
;;
get-url,--*)
- __gitcomp "--push --all"
+ __gitcomp_builtin remote_get-url
;;
prune,--*)
- __gitcomp "--dry-run"
+ __gitcomp_builtin remote_prune
;;
*)
__gitcomp_nl "$(__git_remotes)"
@@ -2720,8 +2926,12 @@ _git_remote ()
_git_replace ()
{
case "$cur" in
+ --format=*)
+ __gitcomp "short medium long" "" "${cur##--format=}"
+ return
+ ;;
--*)
- __gitcomp "--edit --graft --format= --list --delete"
+ __gitcomp_builtin replace
return
;;
esac
@@ -2745,26 +2955,49 @@ _git_reset ()
case "$cur" in
--*)
- __gitcomp "--merge --mixed --hard --soft --patch --keep"
+ __gitcomp_builtin reset
return
;;
esac
__git_complete_refs
}
+_git_restore ()
+{
+ case "$prev" in
+ -s)
+ __git_complete_refs
+ return
+ ;;
+ esac
+
+ case "$cur" in
+ --conflict=*)
+ __gitcomp "diff3 merge" "" "${cur##--conflict=}"
+ ;;
+ --source=*)
+ __git_complete_refs --cur="${cur##--source=}"
+ ;;
+ --*)
+ __gitcomp_builtin restore
+ ;;
+ esac
+}
+
+__git_revert_inprogress_options=$__git_sequencer_inprogress_options
+
_git_revert ()
{
__git_find_repo_path
if [ -f "$__git_repo_path"/REVERT_HEAD ]; then
- __gitcomp "--continue --quit --abort"
+ __gitcomp "$__git_revert_inprogress_options"
return
fi
+ __git_complete_strategy && return
case "$cur" in
--*)
- __gitcomp "
- --edit --mainline --no-edit --no-commit --signoff
- --strategy= --strategy-option=
- "
+ __gitcomp_builtin revert "" \
+ "$__git_revert_inprogress_options"
return
;;
esac
@@ -2775,7 +3008,7 @@ _git_rm ()
{
case "$cur" in
--*)
- __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
+ __gitcomp_builtin rm
return
;;
esac
@@ -2818,9 +3051,18 @@ _git_show ()
__gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
return
;;
+ --color-moved=*)
+ __gitcomp "$__git_color_moved_opts" "" "${cur##--color-moved=}"
+ return
+ ;;
+ --color-moved-ws=*)
+ __gitcomp "$__git_color_moved_ws_opts" "" "${cur##--color-moved-ws=}"
+ return
+ ;;
--*)
- __gitcomp "--pretty= --format= --abbrev-commit --oneline
- --show-signature
+ __gitcomp "--pretty= --format= --abbrev-commit --no-abbrev-commit
+ --oneline --show-signature --patch
+ --expand-tabs --expand-tabs= --no-expand-tabs
$__git_diff_common_options
"
return
@@ -2833,28 +3075,52 @@ _git_show_branch ()
{
case "$cur" in
--*)
- __gitcomp "
- --all --remotes --topo-order --date-order --current --more=
- --list --independent --merge-base --no-name
- --color --no-color
- --sha1-name --sparse --topics --reflog
- "
+ __gitcomp_builtin show-branch
return
;;
esac
__git_complete_revlist
}
+_git_sparse_checkout ()
+{
+ local subcommands="list init set disable"
+ local subcommand="$(__git_find_on_cmdline "$subcommands")"
+ if [ -z "$subcommand" ]; then
+ __gitcomp "$subcommands"
+ return
+ fi
+
+ case "$subcommand,$cur" in
+ init,--*)
+ __gitcomp "--cone"
+ ;;
+ set,--*)
+ __gitcomp "--stdin"
+ ;;
+ *)
+ ;;
+ esac
+}
+
_git_stash ()
{
local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
- local subcommands='push save list show apply clear drop pop create branch'
- local subcommand="$(__git_find_on_cmdline "$subcommands")"
+ local subcommands='push list show apply clear drop pop create branch'
+ local subcommand="$(__git_find_on_cmdline "$subcommands save")"
+ if [ -z "$subcommand" -a -n "$(__git_find_on_cmdline "-p")" ]; then
+ subcommand="push"
+ fi
if [ -z "$subcommand" ]; then
case "$cur" in
--*)
__gitcomp "$save_opts"
;;
+ sa*)
+ if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
+ __gitcomp "save"
+ fi
+ ;;
*)
if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
__gitcomp "$subcommands"
@@ -2875,6 +3141,9 @@ _git_stash ()
drop,--*)
__gitcomp "--quiet"
;;
+ list,--*)
+ __gitcomp "--name-status --oneline --patch-with-stat"
+ ;;
show,--*|branch,--*)
;;
branch,*)
@@ -2899,7 +3168,7 @@ _git_submodule ()
{
__git_has_doubledash && return
- local subcommands="add status init deinit update summary foreach sync"
+ local subcommands="add status init deinit update set-branch set-url summary foreach sync absorbgitdirs"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
case "$cur" in
@@ -2930,6 +3199,9 @@ _git_submodule ()
--force --rebase --merge --reference --depth --recursive --jobs
"
;;
+ set-branch,--*)
+ __gitcomp "--default --branch"
+ ;;
summary,--*)
__gitcomp "--cached --files --summary-limit"
;;
@@ -2960,6 +3232,7 @@ _git_svn ()
--log-window-size= --no-checkout --quiet
--repack-flags --use-log-author --localtime
--add-author-from
+ --recursive
--ignore-paths= --include-paths= $remote_opts
"
local init_opts="
@@ -3045,7 +3318,7 @@ _git_tag ()
while [ $c -lt $cword ]; do
i="${words[c]}"
case "$i" in
- -d|-v)
+ -d|--delete|-v|--verify)
__gitcomp_direct "$(__git_tags "" "$cur" " ")"
return
;;
@@ -3071,11 +3344,7 @@ _git_tag ()
case "$cur" in
--*)
- __gitcomp "
- --list --delete --verify --annotate --message --file
- --sign --cleanup --local-user --force --column --sort=
- --contains --no-contains --points-at --merged --no-merged --create-reflog
- "
+ __gitcomp_builtin tag
;;
esac
}
@@ -3085,29 +3354,128 @@ _git_whatchanged ()
_git_log
}
+__git_complete_worktree_paths ()
+{
+ local IFS=$'\n'
+ __gitcomp_nl "$(git worktree list --porcelain |
+ # Skip the first entry: it's the path of the main worktree,
+ # which can't be moved, removed, locked, etc.
+ sed -n -e '2,$ s/^worktree //p')"
+}
+
_git_worktree ()
{
- local subcommands="add list lock prune unlock"
- local subcommand="$(__git_find_on_cmdline "$subcommands")"
- if [ -z "$subcommand" ]; then
+ local subcommands="add list lock move prune remove unlock"
+ local subcommand subcommand_idx
+
+ subcommand="$(__git_find_on_cmdline --show-idx "$subcommands")"
+ subcommand_idx="${subcommand% *}"
+ subcommand="${subcommand#* }"
+
+ case "$subcommand,$cur" in
+ ,*)
__gitcomp "$subcommands"
- else
- case "$subcommand,$cur" in
- add,--*)
- __gitcomp "--detach"
- ;;
- list,--*)
- __gitcomp "--porcelain"
- ;;
- lock,--*)
- __gitcomp "--reason"
+ ;;
+ *,--*)
+ __gitcomp_builtin worktree_$subcommand
+ ;;
+ add,*) # usage: git worktree add [<options>] <path> [<commit-ish>]
+ # Here we are not completing an --option, it's either the
+ # path or a ref.
+ case "$prev" in
+ -b|-B) # Complete refs for branch to be created/reseted.
+ __git_complete_refs
;;
- prune,--*)
- __gitcomp "--dry-run --expire --verbose"
+ -*) # The previous word is an -o|--option without an
+ # unstuck argument: have to complete the path for
+ # the new worktree, so don't list anything, but let
+ # Bash fall back to filename completion.
;;
- *)
+ *) # The previous word is not an --option, so it must
+ # be either the 'add' subcommand, the unstuck
+ # argument of an option (e.g. branch for -b|-B), or
+ # the path for the new worktree.
+ if [ $cword -eq $((subcommand_idx+1)) ]; then
+ # Right after the 'add' subcommand: have to
+ # complete the path, so fall back to Bash
+ # filename completion.
+ :
+ else
+ case "${words[cword-2]}" in
+ -b|-B) # After '-b <branch>': have to
+ # complete the path, so fall back
+ # to Bash filename completion.
+ ;;
+ *) # After the path: have to complete
+ # the ref to be checked out.
+ __git_complete_refs
+ ;;
+ esac
+ fi
;;
esac
+ ;;
+ lock,*|remove,*|unlock,*)
+ __git_complete_worktree_paths
+ ;;
+ move,*)
+ if [ $cword -eq $((subcommand_idx+1)) ]; then
+ # The first parameter must be an existing working
+ # tree to be moved.
+ __git_complete_worktree_paths
+ else
+ # The second parameter is the destination: it could
+ # be any path, so don't list anything, but let Bash
+ # fall back to filename completion.
+ :
+ fi
+ ;;
+ esac
+}
+
+__git_complete_common () {
+ local command="$1"
+
+ case "$cur" in
+ --*)
+ __gitcomp_builtin "$command"
+ ;;
+ esac
+}
+
+__git_cmds_with_parseopt_helper=
+__git_support_parseopt_helper () {
+ test -n "$__git_cmds_with_parseopt_helper" ||
+ __git_cmds_with_parseopt_helper="$(__git --list-cmds=parseopt)"
+
+ case " $__git_cmds_with_parseopt_helper " in
+ *" $1 "*)
+ return 0
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+}
+
+__git_complete_command () {
+ local command="$1"
+ local completion_func="_git_${command//-/_}"
+ if ! declare -f $completion_func >/dev/null 2>/dev/null &&
+ declare -f _completion_loader >/dev/null 2>/dev/null
+ then
+ _completion_loader "git-$command"
+ fi
+ if declare -f $completion_func >/dev/null 2>/dev/null
+ then
+ $completion_func
+ return 0
+ elif __git_support_parseopt_helper "$command"
+ then
+ __git_complete_common "$command"
+ return 0
+ else
+ return 1
fi
}
@@ -3134,14 +3502,18 @@ __git_main ()
((c++))
done
- if [ -z "$command" ]; then
+ if [ -z "${command-}" ]; then
case "$prev" in
--git-dir|-C|--work-tree)
# these need a path argument, let's fall back to
# Bash filename completion
return
;;
- -c|--namespace)
+ -c)
+ __git_complete_config_variable_name_and_value
+ return
+ ;;
+ --namespace)
# we don't support completing these options' arguments
return
;;
@@ -3164,20 +3536,24 @@ __git_main ()
--help
"
;;
- *) __git_compute_porcelain_commands
- __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
+ *)
+ if test -n "${GIT_TESTING_PORCELAIN_COMMAND_LIST-}"
+ then
+ __gitcomp "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
+ else
+ __gitcomp "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)"
+ fi
+ ;;
esac
return
fi
- local completion_func="_git_${command//-/_}"
- declare -f $completion_func >/dev/null 2>/dev/null && $completion_func && return
+ __git_complete_command "$command" && return
local expansion=$(__git_aliased_command "$command")
if [ -n "$expansion" ]; then
words[1]=$expansion
- completion_func="_git_${expansion//-/_}"
- declare -f $completion_func >/dev/null 2>/dev/null && $completion_func
+ __git_complete_command "$expansion"
fi
}
@@ -3205,76 +3581,8 @@ __gitk_main ()
__git_complete_revlist
}
-if [[ -n ${ZSH_VERSION-} ]]; then
- echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
-
- autoload -U +X compinit && compinit
-
- __gitcomp ()
- {
- emulate -L zsh
-
- local cur_="${3-$cur}"
-
- case "$cur_" in
- --*=)
- ;;
- *)
- local c IFS=$' \t\n'
- local -a array
- for c in ${=1}; do
- c="$c${4-}"
- case $c in
- --*=*|*.) ;;
- *) c="$c " ;;
- esac
- array[${#array[@]}+1]="$c"
- done
- compset -P '*[=:]'
- compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
- ;;
- esac
- }
-
- __gitcomp_direct ()
- {
- emulate -L zsh
-
- local IFS=$'\n'
- compset -P '*[=:]'
- compadd -Q -- ${=1} && _ret=0
- }
-
- __gitcomp_nl ()
- {
- emulate -L zsh
-
- local IFS=$'\n'
- compset -P '*[=:]'
- compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
- }
-
- __gitcomp_file ()
- {
- emulate -L zsh
-
- local IFS=$'\n'
- compset -P '*[=:]'
- compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
- }
-
- _git ()
- {
- local _ret=1 cur cword prev
- cur=${words[CURRENT]}
- prev=${words[CURRENT-1]}
- let cword=CURRENT-1
- emulate ksh -c __${service}_main
- let _ret && _default && _ret=0
- return _ret
- }
-
- compdef _git git gitk
+if [[ -n ${ZSH_VERSION-} && -z ${GIT_SOURCING_ZSH_COMPLETION-} ]]; then
+ echo "ERROR: this script is obsolete, please see git-completion.zsh" 1>&2
return
fi
@@ -3296,17 +3604,42 @@ __git_complete ()
|| complete -o default -o nospace -F $wrapper $1
}
-# wrapper for backwards compatibility
-_git ()
-{
- __git_wrap__git_main
-}
+if ! git --list-cmds=main >/dev/null 2>&1; then
-# wrapper for backwards compatibility
-_gitk ()
-{
- __git_wrap__gitk_main
-}
+ declare -A __git_cmds
+ __git_cmds[list-complete]="apply blame cherry config difftool fsck help instaweb mergetool prune reflog remote repack replace request-pull send-email show-branch stage whatchanged"
+ __git_cmds[list-guide]="attributes cli core-tutorial credentials cvs-migration diffcore everyday faq glossary hooks ignore modules namespaces remote-helpers repository-layout revisions submodules tutorial-2 tutorial workflows"
+ __git_cmds[list-mainporcelain]="add am archive bisect branch bundle checkout cherry-pick citool clean clone commit describe diff fetch format-patch gc grep gui init gitk log maintenance merge mv notes pull push range-diff rebase reset restore revert rm shortlog show sparse-checkout stash status submodule switch tag worktree"
+ __git_cmds[main]="add add--interactive am annotate apply archimport archive bisect bisect--helper blame branch bugreport bundle cat-file check-attr check-ignore check-mailmap check-ref-format checkout checkout-index cherry cherry-pick citool clean clone column commit commit-graph commit-tree config count-objects credential credential-cache credential-cache--daemon credential-gnome-keyring credential-libsecret credential-store cvsexportcommit cvsimport cvsserver daemon describe diff diff-files diff-index diff-tree difftool difftool--helper env--helper fast-export fast-import fetch fetch-pack filter-branch fmt-merge-msg for-each-ref format-patch fsck fsck-objects gc get-tar-commit-id grep gui gui--askpass hash-object help http-backend http-fetch http-push imap-send index-pack init init-db instaweb interpret-trailers log ls-files ls-remote ls-tree mailinfo mailsplit maintenance merge merge-base merge-file merge-index merge-octopus merge-one-file merge-ours merge-recursive merge-recursive-ours merge-recursive-theirs merge-resolve merge-subtree merge-tree mergetool mktag mktree multi-pack-index mv mw name-rev notes p4 pack-objects pack-redundant pack-refs patch-id pickaxe prune prune-packed pull push quiltimport range-diff read-tree rebase rebase--interactive receive-pack reflog remote remote-ext remote-fd remote-ftp remote-ftps remote-http remote-https remote-mediawiki repack replace request-pull rerere reset restore rev-list rev-parse revert rm send-email send-pack sh-i18n--envsubst shell shortlog show show-branch show-index show-ref sparse-checkout stage stash status stripspace submodule submodule--helper subtree svn switch symbolic-ref tag unpack-file unpack-objects update-index update-ref update-server-info upload-archive upload-archive--writer upload-pack var verify-commit verify-pack verify-tag version web--browse whatchanged worktree write-tree"
+ __git_cmds[others]="compare reintegrate related remote-hg remote-sync send-series smartlist"
+ __git_cmds[parseopt]="add am apply archive bisect--helper blame branch bugreport cat-file check-attr check-ignore check-mailmap checkout checkout-index cherry cherry-pick clean clone column commit commit-graph config count-objects credential-cache credential-cache--daemon credential-store describe difftool env--helper fast-export fetch fmt-merge-msg for-each-ref format-patch fsck fsck-objects gc grep hash-object help init init-db interpret-trailers log ls-files ls-remote ls-tree merge merge-base merge-file mktree multi-pack-index mv name-rev notes pack-objects pack-refs pickaxe prune prune-packed pull push range-diff read-tree rebase rebase--interactive receive-pack reflog remote repack replace rerere reset restore revert rm send-pack shortlog show show-branch show-index show-ref sparse-checkout stage stash status stripspace switch symbolic-ref tag update-index update-ref update-server-info upload-pack verify-commit verify-pack verify-tag version whatchanged write-tree "
+
+ # Override __git
+ __git ()
+ {
+ case "$1" in
+ --list-cmds=*)
+ while read -r -d ',' x; do
+ case "$x" in
+ nohelpers)
+ ;;
+ alias)
+ ;;
+ config)
+ ;;
+ *)
+ echo ${__git_cmds[$x]}
+ ;;
+ esac
+ done <<< "${1##--list-cmds=},"
+ return
+ ;;
+ esac
+ git ${__git_C_args:+"${__git_C_args[@]}"} \
+ ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null
+ }
+
+fi
__git_complete git __git_main
__git_complete gitk __gitk_main
@@ -3315,6 +3648,6 @@ __git_complete gitk __gitk_main
# when the user has tab-completed the executable name and consequently
# included the '.exe' suffix.
#
-if [[ "$OSTYPE" = cygwin* ]]; then
-__git_complete git.exe __git_main
+if [ "$OSTYPE" = cygwin ]; then
+ __git_complete git.exe __git_main
fi
diff --git a/plugins/gitfast/git-prompt.sh b/plugins/gitfast/git-prompt.sh
index fd2b049db..54e123d63 100644
--- a/plugins/gitfast/git-prompt.sh
+++ b/plugins/gitfast/git-prompt.sh
@@ -70,6 +70,15 @@
# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator
# is SP.
#
+# When there is an in-progress operation such as a merge, rebase,
+# revert, cherry-pick, or bisect, the prompt will include information
+# related to the operation, often in the form "|<OPERATION-NAME>".
+#
+# When the repository has a sparse-checkout, a notification of the form
+# "|SPARSE" will be included in the prompt. This can be shortened to a
+# single '?' character by setting GIT_PS1_COMPRESSSPARSESTATE, or omitted
+# by setting GIT_PS1_OMITSPARSESTATE.
+#
# By default, __git_ps1 will compare HEAD to your SVN upstream if it can
# find one, or @{upstream} otherwise. Once you have set
# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by
@@ -88,7 +97,8 @@
# If you would like a colored hint about the current dirty state, set
# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
# the colored output of "git status -sb" and are available only when
-# using __git_ps1 for PROMPT_COMMAND or precmd.
+# using __git_ps1 for PROMPT_COMMAND or precmd in Bash,
+# but always available in Zsh.
#
# If you would like __git_ps1 to do nothing in the case when the current
# directory is set up to be ignored by git, then set
@@ -286,6 +296,37 @@ __git_eread ()
test -r "$1" && IFS=$'\r\n' read "$2" <"$1"
}
+# see if a cherry-pick or revert is in progress, if the user has committed a
+# conflict resolution with 'git commit' in the middle of a sequence of picks or
+# reverts then CHERRY_PICK_HEAD/REVERT_HEAD will not exist so we have to read
+# the todo file.
+__git_sequencer_status ()
+{
+ local todo
+ if test -f "$g/CHERRY_PICK_HEAD"
+ then
+ r="|CHERRY-PICKING"
+ return 0;
+ elif test -f "$g/REVERT_HEAD"
+ then
+ r="|REVERTING"
+ return 0;
+ elif __git_eread "$g/sequencer/todo" todo
+ then
+ case "$todo" in
+ p[\ \ ]|pick[\ \ ]*)
+ r="|CHERRY-PICKING"
+ return 0
+ ;;
+ revert[\ \ ]*)
+ r="|REVERTING"
+ return 0
+ ;;
+ esac
+ fi
+ return 1
+}
+
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
# when called from PS1 using command substitution
# in this mode it prints text to add to bash PS1 prompt (includes branch name)
@@ -390,6 +431,13 @@ __git_ps1 ()
return $exit
fi
+ local sparse=""
+ if [ -z "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
+ [ -z "${GIT_PS1_OMITSPARSESTATE}" ] &&
+ [ "$(git config --bool core.sparseCheckout)" = "true" ]; then
+ sparse="|SPARSE"
+ fi
+
local r=""
local b=""
local step=""
@@ -398,11 +446,7 @@ __git_ps1 ()
__git_eread "$g/rebase-merge/head-name" b
__git_eread "$g/rebase-merge/msgnum" step
__git_eread "$g/rebase-merge/end" total
- if [ -f "$g/rebase-merge/interactive" ]; then
- r="|REBASE-i"
- else
- r="|REBASE-m"
- fi
+ r="|REBASE"
else
if [ -d "$g/rebase-apply" ]; then
__git_eread "$g/rebase-apply/next" step
@@ -417,10 +461,8 @@ __git_ps1 ()
fi
elif [ -f "$g/MERGE_HEAD" ]; then
r="|MERGING"
- elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
- r="|CHERRY-PICKING"
- elif [ -f "$g/REVERT_HEAD" ]; then
- r="|REVERTING"
+ elif __git_sequencer_status; then
+ :
elif [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING"
fi
@@ -467,6 +509,7 @@ __git_ps1 ()
local i=""
local s=""
local u=""
+ local h=""
local c=""
local p=""
@@ -499,6 +542,11 @@ __git_ps1 ()
u="%${ZSH_VERSION+%}"
fi
+ if [ -n "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
+ [ "$(git config --bool core.sparseCheckout)" = "true" ]; then
+ h="?"
+ fi
+
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
__git_ps1_show_upstream
fi
@@ -519,8 +567,8 @@ __git_ps1 ()
b="\${__git_ps1_branch_name}"
fi
- local f="$w$i$s$u"
- local gitstring="$c$b${f:+$z$f}$r$p"
+ local f="$h$w$i$s$u"
+ local gitstring="$c$b${f:+$z$f}${sparse}$r$p"
if [ $pcmode = yes ]; then
if [ "${__git_printf_supports_v-}" != yes ]; then
diff --git a/plugins/gitfast/update b/plugins/gitfast/update
index 05054245f..5311065a1 100755
--- a/plugins/gitfast/update
+++ b/plugins/gitfast/update
@@ -1,9 +1,8 @@
#!/bin/sh
-url="https://git.kernel.org/pub/scm/git/git.git/plain/contrib/completion"
-version="2.16.0"
+url="https://raw.githubusercontent.com/felipec/git-completion"
+version="1.2"
-curl -s -o _git "${url}/git-completion.zsh?h=v${version}" &&
-curl -s -o git-completion.bash "${url}/git-completion.bash?h=v${version}" &&
-curl -s -o git-prompt.sh "${url}/git-prompt.sh?h=v${version}" &&
-git apply updates.patch
+curl -s -o _git "${url}/v${version}/git-completion.zsh" &&
+curl -s -o git-completion.bash "${url}/v${version}/git-completion.bash" &&
+curl -s -o git-prompt.sh "${url}/v${version}/git-prompt.sh"
diff --git a/plugins/gitfast/updates.patch b/plugins/gitfast/updates.patch
deleted file mode 100644
index 28a31f859..000000000
--- a/plugins/gitfast/updates.patch
+++ /dev/null
@@ -1,56 +0,0 @@
-diff --git b/plugins/gitfast/_git a/plugins/gitfast/_git
-index e2554130..a2e3bef5 100644
---- b/plugins/gitfast/_git
-+++ a/plugins/gitfast/_git
-@@ -30,7 +30,7 @@ if [ -z "$script" ]; then
- local -a locations
- local e
- locations=(
-- $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
-+ "$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash"
- '/etc/bash_completion.d/git' # fedora, old debian
- '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
- '/usr/share/bash-completion/git' # gentoo
-@@ -214,8 +214,10 @@ _git ()
-
- if (( $+functions[__${service}_zsh_main] )); then
- __${service}_zsh_main
-- else
-+ elif (( $+functions[__${service}_main] )); then
- emulate ksh -c __${service}_main
-+ elif (( $+functions[_${service}] )); then
-+ emulate ksh -c _${service}
- fi
-
- let _ret && _default && _ret=0
-diff --git b/plugins/gitfast/git-completion.bash a/plugins/gitfast/git-completion.bash
-index 9c8f7380..14012cab 100644
---- b/plugins/gitfast/git-completion.bash
-+++ a/plugins/gitfast/git-completion.bash
-@@ -2915,6 +2915,6 @@ __git_complete gitk __gitk_main
- # when the user has tab-completed the executable name and consequently
- # included the '.exe' suffix.
- #
--if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
-+if [[ "$OSTYPE" = cygwin* ]]; then
- __git_complete git.exe __git_main
- fi
-diff --git b/plugins/gitfast/git-prompt.sh a/plugins/gitfast/git-prompt.sh
-index 97eacd78..c1de34eb 100644
---- b/plugins/gitfast/git-prompt.sh
-+++ a/plugins/gitfast/git-prompt.sh
-@@ -502,9 +502,11 @@ __git_ps1 ()
-
- local z="${GIT_PS1_STATESEPARATOR-" "}"
-
-- # NO color option unless in PROMPT_COMMAND mode
-- if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
-- __git_ps1_colorize_gitstring
-+ # NO color option unless in PROMPT_COMMAND mode or it's Zsh
-+ if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
-+ if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
-+ __git_ps1_colorize_gitstring
-+ fi
- fi
-
- b=${b##refs/heads/}
diff --git a/plugins/globalias/README.md b/plugins/globalias/README.md
index 0b064105d..cd7fc3cb2 100644
--- a/plugins/globalias/README.md
+++ b/plugins/globalias/README.md
@@ -17,6 +17,9 @@ Then just press `SPACE` to trigger the expansion of a command you've written.
If you only want to insert a space without expanding the command line, press
`CTRL`+`SPACE`.
+if you would like to filter out any values from expanding set `GLOBALIAS_FILTER_VALUES` to
+an array of said values. See [Filtered values](#filtered-values).
+
## Examples
#### Glob expressions
@@ -37,7 +40,6 @@ $ ls folder/file.json anotherfolder/another.json
$ mkdir "`date -R`"
# expands to
$ mkdir Tue,\ 04\ Oct\ 2016\ 13:54:03\ +0300
-
```
#### Aliases
@@ -60,3 +62,18 @@ $ S<space>
# expands to:
$ sudo systemctl
```
+
+#### Filtered values
+
+```
+# .zshrc
+alias l='ls -lh'
+alias la='ls --color=auto -lah'
+GLOBALIAS_FILTER_VALUES=(l)
+
+$ l<space>
+# does not expand
+$ la<space>
+# expands to:
+$ ls --color=auto -lah
+```
diff --git a/plugins/globalias/globalias.plugin.zsh b/plugins/globalias/globalias.plugin.zsh
index 9602a9606..bd27d589d 100644
--- a/plugins/globalias/globalias.plugin.zsh
+++ b/plugins/globalias/globalias.plugin.zsh
@@ -1,6 +1,12 @@
globalias() {
- zle _expand_alias
- zle expand-word
+ # Get last word to the left of the cursor:
+ # (z) splits into words using shell parsing
+ # (A) makes it an array even if there's only one element
+ local word=${${(Az)LBUFFER}[-1]}
+ if [[ $GLOBALIAS_FILTER_VALUES[(Ie)$word] -eq 0 ]]; then
+ zle _expand_alias
+ zle expand-word
+ fi
zle self-insert
}
zle -N globalias
diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh
index 47b10988e..398bd966f 100644
--- a/plugins/golang/golang.plugin.zsh
+++ b/plugins/golang/golang.plugin.zsh
@@ -41,7 +41,7 @@ __go_tool_complete() {
return
fi
build_flags=(
- '-a[force reinstallation of packages that are already up-to-date]'
+ '-a[force reinstallation of packages that are already up to date]'
'-n[print the commands but do not run them]'
'-p[number of parallel builds]:number'
'-race[enable data race detection]'
diff --git a/plugins/grc/README.md b/plugins/grc/README.md
new file mode 100644
index 000000000..dfda41466
--- /dev/null
+++ b/plugins/grc/README.md
@@ -0,0 +1,37 @@
+# Generic Colouriser plugin
+
+This plugin adds wrappers for commands supported by [Generic Colouriser](https://github.com/garabik/grc):
+
+To use it, add `grc` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... grc)
+```
+
+## Commands
+
+The following commands are wrapped by `grc` so that their output is automatically colored:
+
+- `cc`
+- `configure`
+- `cvs`
+- `df`
+- `diff`
+- `dig`
+- `gcc`
+- `gmake`
+- `ifconfig`
+- `iwconfig`
+- `last`
+- `ldap`
+- `make`
+- `mount`
+- `mtr`
+- `netstat`
+- `ping`
+- `ping6`
+- `ps`
+- `traceroute`
+- `traceroute6`
+- `wdiff`
+- `whois`
diff --git a/plugins/grc/grc.plugin.zsh b/plugins/grc/grc.plugin.zsh
new file mode 100644
index 000000000..6a52ec568
--- /dev/null
+++ b/plugins/grc/grc.plugin.zsh
@@ -0,0 +1,44 @@
+# Adapted from: https://github.com/garabik/grc/blob/master/grc.zsh
+
+if [[ "$TERM" = dumb ]] || (( ! $+commands[grc] )); then
+ return
+fi
+
+# Supported commands
+cmds=(
+ cc
+ configure
+ cvs
+ df
+ diff
+ dig
+ gcc
+ gmake
+ ifconfig
+ iwconfig
+ last
+ ldap
+ make
+ mount
+ mtr
+ netstat
+ ping
+ ping6
+ ps
+ traceroute
+ traceroute6
+ wdiff
+ whois
+)
+
+# Set alias for supported commands
+for cmd in $cmds; do
+ if (( $+commands[$cmd] )); then
+ eval "function $cmd {
+ grc --colour=auto \"${commands[$cmd]}\" \"\$@\"
+ }"
+ fi
+done
+
+# Clean up variables
+unset cmds cmd
diff --git a/plugins/ipfs/LICENSE b/plugins/ipfs/LICENSE
new file mode 100644
index 000000000..cf84491bb
--- /dev/null
+++ b/plugins/ipfs/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Angel Ramboi
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
diff --git a/plugins/ipfs/README.md b/plugins/ipfs/README.md
new file mode 100644
index 000000000..0808a26c1
--- /dev/null
+++ b/plugins/ipfs/README.md
@@ -0,0 +1,17 @@
+# zsh-ipfs
+
+zsh completion plugin for [The InterPlanetary File System (IPFS)][1]
+
+Please submit issues and pull requests to the [main zsh-ipfs repo][2].
+
+### About
+
+[IPFS (InterPlanetary File System)][1] is a peer-to-peer hypermedia protocol
+designed to make the web faster, safer, and more open.
+
+### License
+
+See: https://github.com/hellounicorn/zsh-ipfs/blob/master/LICENSE
+
+[1]: http://ipfs.io/
+[2]: https://github.com/hellounicorn/zsh-ipfs
diff --git a/plugins/ipfs/_ipfs b/plugins/ipfs/_ipfs
new file mode 100644
index 000000000..9ee8bd79c
--- /dev/null
+++ b/plugins/ipfs/_ipfs
@@ -0,0 +1,717 @@
+#compdef ipfs
+#autoload
+
+local -a _1st_arguments
+_1st_arguments=(
+ 'add:Add a file or directory to ipfs.'
+ 'bitswap:Interact with the bitswap agent.'
+ 'block:Interact with raw IPFS blocks.'
+ 'bootstrap:Show or edit the list of bootstrap peers.'
+ 'cat:Show IPFS object data.'
+ 'cid:Convert and discover properties of CIDs'
+ 'commands:List all available commands.'
+ 'config:Get and set ipfs config values.'
+ 'daemon:Run a network-connected IPFS node.'
+ 'dag:Interact with ipld dag objects. (experimental)'
+ 'dht:Issue commands directly through the DHT.'
+ 'diag:Generate diagnostic reports.'
+ 'dns:Resolve DNS links.'
+ 'files:Interact with unixfs files.'
+ 'filestore:Interact with filestore objects. (experimental)'
+ 'get:Download IPFS objects.'
+ 'id:Show ipfs node id info.'
+ 'init:Initializes ipfs config file.'
+ 'key:Create and list IPNS name keypairs.'
+ 'log:Interact with the daemon log output.'
+ 'ls:List directory contents for Unix filesystem objects.'
+ 'mount:Mounts IPFS to the filesystem (read-only).'
+ 'name:Publish and resolve IPNS names.'
+ 'object:Interact with IPFS objects.'
+ 'p2p:Libp2p stream mounting.'
+ 'pin:Pin (and unpin) objects to local storage.'
+ 'ping:Send echo request packets to IPFS hosts.'
+ 'refs:List links (references) from an object.'
+ 'repo:Manipulate the IPFS repo.'
+ 'resolve:Resolve the value of names to IPFS.'
+ 'stats:Query IPFS statistics.'
+ 'swarm:Interact with the swarm.'
+ 'tar:Utility functions for tar files in ipfs.'
+ 'update:Download and apply go-ipfs updates'
+ 'version:Show ipfs version information.'
+)
+
+_ipfs_subcommand(){
+ local curcontext="$curcontext" state line
+ typeset -A opt_args
+ _arguments -C ':command:->command' '*::options:->options'
+ case $state in
+ (command)
+ _describe -t commands "ipfs subcommand" $1
+ return
+ ;;
+ (options)
+ case $line[1] in
+ (wantlist)
+ case $MAIN_SUBCOMMAND in
+ (bitswap)
+ _arguments '(-p --peer)'{-p,--peer}'[Specify which peer to show wantlist for. Default: self.]'
+ ;;
+ esac
+ ;;
+ (add)
+ case $MAIN_SUBCOMMAND in
+ (pin)
+ _arguments \
+ '(-r --recursive)'{-r,--recursive}'[Recursively pin the object linked to by the specified object(s). Default: true.]' \
+ '--progress[Show progress.]'
+ ;;
+ (bootstrap)
+ local -a _bootstrap_rm_arguments
+ _bootstrap_rm_arguments=(
+ 'default:Add default peers to the bootstrap list.'
+ )
+ _ipfs_subcommand _bootstrap_rm_arguments
+ ;;
+ esac
+ ;;
+ (rm)
+ case $MAIN_SUBCOMMAND in
+ (pin)
+ _arguments '(-r --recursive)'{-r,--recursive}'[Recursively unpin the object linked to by the specified object(s). Default: true.]'
+ ;;
+ (bootstrap)
+ local -a _bootstrap_rm_arguments
+ _bootstrap_rm_arguments=(
+ 'all:Remove all peers from the bootstrap list.'
+ )
+ _ipfs_subcommand _bootstrap_rm_arguments
+ ;;
+ esac
+ ;;
+ (ls)
+ case $MAIN_SUBCOMMAND in
+ (pin)
+ _arguments \
+ '(-t --type)'{-t,--type}'[The type of pinned keys to list. Can be "direct", "indirect", "recursive", or "all". Default: all.]' \
+ '(-q --quiet)'{-q,--quiet}'[Write just hashes of objects.]'
+ ;;
+ (p2p)
+ _arguments '(-v --headers)'{-v,--headers}'[Print table headers (Protocol, Listen, Target).]'
+ ;;
+ esac
+ ;;
+ (update)
+ case $MAIN_SUBCOMMAND in
+ (pin)
+ _arguments '--unpin[Remove the old pin. Default: true.]'
+ ;;
+ esac
+ ;;
+ (verify)
+ case $MAIN_SUBCOMMAND in
+ (pin)
+ _arguments \
+ '--verbose[Also write the hashes of non-broken pins.]' \
+ '(-q --quiet)'{-q,--quiet}'[Write just hashes of broken pins.]'
+ ;;
+ esac
+ ;;
+ (get|query|findpeer)
+ case $MAIN_SUBCOMMAND in
+ (dht)
+ _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
+ ;;
+ (object)
+ _arguments '--data-encoding[Encoding type of the data field, either "text" or "base64". Default: text.]'
+ ;;
+ esac
+ ;;
+ (put)
+ case $MAIN_SUBCOMMAND in
+ (dht)
+ _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
+ ;;
+ (object)
+ _arguments \
+ '--inputenc[Encoding type of input data. One of: {"protobuf", "json"}. Default: json.]' \
+ '--datafieldenc[Encoding type of the data field, either "text" or "base64". Default: text.]' \
+ '--pin[Pin this object when adding.]' \
+ '(-q --quiet)'{-q,--quiet}'[Write minimal output]'
+ ;;
+ esac
+ ;;
+ (findprovs)
+ case $MAIN_SUBCOMMAND in
+ (dht)
+ _arguments \
+ '(-v --verbose)'{-v,--verbose}'[Print extra information.]' \
+ '(-n --num-providers)'{-n,--num-providers}'[The number of providers to find. Default: 20.]'
+ ;;
+ esac
+ ;;
+ (provide)
+ case $MAIN_SUBCOMMAND in
+ (dht)
+ _arguments \
+ '(-v --verbose)'{-v,--verbose}'[Print extra information.]' \
+ '(-r --recursive)'{-r,--recursive}'[Recursively provide entire graph.]'
+ ;;
+ esac
+ ;;
+ (cmds|diff)
+ case $MAIN_SUBCOMMAND in
+ (diag|object)
+ _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
+ ;;
+ esac
+ ;;
+ (stat)
+ case $MAIN_SUBCOMMAND in
+ (object)
+ _arguments '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
+ ;;
+ (repo)
+ _arguments \
+ '--size-only[Only report RepoSize and StorageMax.]' \
+ '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
+ ;;
+ esac
+ ;;
+ (publish)
+ case $MAIN_SUBCOMMAND in
+ (name)
+ _arguments \
+ '--resolve[Check if the given path can be resolved before publishing. Default: true.]' \
+ '(-t --lifetime)'{-t,--lifetime}'[Time duration that the record will be valid for. Default: 24h.]' \
+ '--allow-offline[When offline, save the IPNS record to the the local datastore without broadcasting to the network instead of simply failing.]' \
+ '--ttl[Time duration this record should be cached for. Uses the same syntax as the lifetime option. (caution: experimental).]' \
+ '(-k --key)'{-k,--key}"[Name of the key to be used or a valid PeerID, as listed by 'ipfs key list -l'. Default: self.]" \
+ '(-Q --quieter)'{-Q,--quieter}'[Write only final hash.]'
+ ;;
+ esac
+ ;;
+ (pubsub)
+ case $MAIN_SUBCOMMAND in
+ (name)
+ local -a _name_pubsub_arguments
+ _name_pubsub_arguments=(
+ 'cancel:Cancel a name subscription'
+ 'state:Query the state of IPNS pubsub'
+ 'subs:Show current name subscriptions'
+ )
+ _ipfs_subcommand _name_pubsub_arguments
+ ;;
+ esac
+ ;;
+ (resolve)
+ case $MAIN_SUBCOMMAND in
+ (name)
+ _arguments \
+ '(-r --recursive)'{-r,--recursive}'[Resolve until the result is not an IPNS name. Default: true.]' \
+ '(-n --nocache)'{-n,--nocache}'[Do not use cached entries.]' \
+ '(--dhtrc --dht-record-count)'{--dhtrc,--dht-record-count}'[Number of records to request for DHT resolution.]' \
+ '(--dhtt --dht-timeout)'{--dhtt,--dht-timeout}'[Max time to collect values during DHT resolution eg "30s". Pass 0 for no timeout.]' \
+ '(-s --stream)'{-s,--stream}'[Stream entries as they are found.]'
+ ;;
+ esac
+ ;;
+ (patch)
+ case $MAIN_SUBCOMMAND in
+ (object)
+ local -a _object_patch_arguments
+ _object_patch_arguments=(
+ 'add-link:Add a link to a given object.'
+ 'append-data:Append data to the data segment of a dag node.'
+ 'rm-link:Remove a link from a given object.'
+ 'set-data:Set the data field of an IPFS object.'
+ )
+ _ipfs_subcommand _object_patch_arguments
+ ;;
+ esac
+ ;;
+ (gc)
+ case $MAIN_SUBCOMMAND in
+ (repo)
+ _arguments \
+ '--stream-errors[Stream errors.]' \
+ '(-q --quiet)'{-q,--quiet}'[Write minimal output.]'
+ ;;
+ esac
+ ;;
+ (bitswap)
+ case $MAIN_SUBCOMMAND in
+ (stats)
+ _arguments \
+ '(-v --verbose)'{-v,--verbose}'[Print extra information.]' \
+ '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
+ ;;
+ esac
+ ;;
+ (bw)
+ case $MAIN_SUBCOMMAND in
+ (stats)
+ _arguments \
+ '(-p --peer)'{-p,--peer}'[Specify a peer to print bandwidth for.]' \
+ '(-t --proto)'{-t,--proto}'[Specify a protocol to print bandwidth for.]' \
+ '--poll[Print bandwidth at an interval.]' \
+ '(-i --interval)'{-i,--interval}'[Time interval to wait between updating output, if 'poll' is true.]'
+ ;;
+ esac
+ ;;
+ (repo)
+ case $MAIN_SUBCOMMAND in
+ (stats)
+ _arguments \
+ '--size-only[Only report RepoSize and StorageMax.]' \
+ '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
+ ;;
+ esac
+ ;;
+ (bases)
+ case $MAIN_SUBCOMMAND in
+ (cid)
+ _arguments \
+ '--prefix[also include the single leter prefixes in addition to the code.]' \
+ '--numeric[also include numeric codes.]'
+ ;;
+ esac
+ ;;
+ (codecs|hashes)
+ case $MAIN_SUBCOMMAND in
+ (cid)
+ _arguments '--numeric[also include numeric codes.]'
+ ;;
+ esac
+ ;;
+ (format)
+ case $MAIN_SUBCOMMAND in
+ (cid)
+ _arguments \
+ '-f[Printf style format string. Default: %s.]' \
+ '-v[CID version to convert to.]' \
+ '-b[Multibase to display CID in.]'
+ ;;
+ esac
+ ;;
+ (close)
+ case $MAIN_SUBCOMMAND in
+ (p2p)
+ _arguments \
+ '(-a --all)'{-a,--all}'[Close all listeners.]' \
+ '(-p --protocol)'{-p,--protocol}'[Match protocol name.]' \
+ '(-l --listen-address)'{-l,--listen-address}'[Match listen address.]' \
+ '(-t --target-address)'{-t,--target-address}'[Match target address.]'
+ ;;
+ esac
+ ;;
+ (forward)
+ case $MAIN_SUBCOMMAND in
+ (p2p)
+ _arguments "--allow-custom-protocol[Don't require /x/ prefix.]"
+ ;;
+ esac
+ ;;
+ (listen)
+ case $MAIN_SUBCOMMAND in
+ (p2p)
+ _arguments \
+ "--allow-custom-protocol[Don't require /x/ prefix.]" \
+ '(-r --report-peer-id)'{-r,--report-peer-id}'[Send remote base58 peerid to target when a new connection is established.]'
+ ;;
+ esac
+ ;;
+ (stream)
+ case $MAIN_SUBCOMMAND in
+ (p2p)
+ local -a _p2p_stream_arguments
+ _p2p_stream_arguments=(
+ 'close:Close active p2p stream.'
+ 'ls:List active p2p streams.'
+ )
+ _ipfs_subcommand _p2p_stream_arguments
+ ;;
+ esac
+ ;;
+ (addrs)
+ case $MAIN_SUBCOMMAND in
+ (swarm)
+ local -a _swarm_addrs_arguments
+ _swarm_addrs_arguments=(
+ 'listen:List interface listening addresses.'
+ 'local:List local addresses.'
+ )
+ _ipfs_subcommand _swarm_addrs_arguments
+ ;;
+ esac
+ ;;
+ (filters)
+ case $MAIN_SUBCOMMAND in
+ (swarm)
+ local -a _swarm_filters_arguments
+ _swarm_filters_arguments=(
+ 'add:Add an address filter.'
+ 'rm:Remove an address filter.'
+ )
+ _ipfs_subcommand _swarm_filters_arguments
+ ;;
+ esac
+ ;;
+ (peers)
+ case $MAIN_SUBCOMMAND in
+ (swarm)
+ _arguments \
+ '(-v --verbose)'{-v,--verbose}'[display all extra information.]' \
+ '--streams[Also list information about open streams for each peer.]' \
+ '--latency[Also list information about latency to each peer.]' \
+ '--direction[Also list information about the direction of connection.]'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+}
+
+local expl
+
+_arguments \
+ '(-c --config)'{-c,--config}'[Path to the configuration file to use.]' \
+ '(-D --debug)'{-D,--debug}'[Operate in debug mode.]' \
+ '(--help)--help[Show the full command help text.]' \
+ '(--h)-h[Show a short version of the command help text.]' \
+ '(-L --local)'{-L,--local}'[Run the command locally, instead of using the daemon. DEPRECATED: use --offline.]' \
+ '(--offline)--offline[Run the command offline.]' \
+ '(--api)--api[Use a specific API instance (defaults to /ip4/127.0.0.1/tcp/5001).]' \
+ '(--cid-base)--cid-base[Multibase encoding used for version 1 CIDs in output.]' \
+ '(--upgrade-cidv0-in-output)--upgrade-cidv0-in-output[Upgrade version 0 to version 1 CIDs in output.]' \
+ '(--enc --encoding)'{--enc,--encoding}'[The encoding type the output should be encoded with (json, xml, or text). Default: text.]' \
+ '(--stream-channels)--stream-channels[Stream channel output.]' \
+ '(--timeout)--timeout[Set a global timeout on the command.]' \
+ '*:: :->subcmds' && return 0
+
+if (( CURRENT == 1 )); then
+ _describe -t commands "ipfs subcommand" _1st_arguments
+ return
+fi
+
+MAIN_SUBCOMMAND="$words[1]"
+case $MAIN_SUBCOMMAND in
+ (add)
+ _arguments \
+ '(-r --recursive)'{-r,--recursive}'[Add directory paths recursively.]' \
+ '(--dereference-args)--dereference-args[Symlinks supplied in arguments are dereferenced.]' \
+ '(--stdin-name)--stdin-name[Assign a name if the file source is stdin.]' \
+ '(-H --hidden)'{-H,--hidden}'[Include files that are hidden. Only takes effect on recursive add.]' \
+ '(-q --quiet)'{-q,--quiet}'[Write minimal output.]' \
+ '(-Q --quieter)'{-Q,--quieter}'[Write only final hash.]' \
+ '(--silent)--silent[Write no output.]' \
+ '(-p --progress)'{-p,--progress}'[Stream progress data.]' \
+ '(-t --trickle)'{-t,--trickle}'[Use trickle-dag format for dag generation.]' \
+ '(-n --only-hash)'{-n,--only-hash}'[Only chunk and hash - do not write to disk.]' \
+ '(-w --wrap-with-directory)'{-w,--wrap-with-directory}'[Wrap files with a directory object.]' \
+ '(-s --chunker)'{-s,--chunker}'[Chunking algorithm, size-(bytes) or rabin-(min)-(avg)-(max). Default: size-262144.]' \
+ '(--pin)--pin[Pin this object when adding. Default: true.]' \
+ '(--raw-leaves)--raw-leaves[Use raw blocks for leaf nodes. (experimental).]' \
+ '(--nocopy)--nocopy[Add the file using filestore. Implies raw-leaves. (experimental).]' \
+ '(--fscache)--fscache[Check the filestore for pre-existing blocks. (experimental).]' \
+ '(--cid-version)--cid-version[CID version. Defaults to 0 unless an option that depends on CIDv1 is passed. (experimental).]' \
+ '(--hash)--hash[Hash function to use. Implies CIDv1 if not sha2-256. (experimental). Default: sha2-256.]' \
+ '(--inline)--inline[Inline small blocks into CIDs. (experimental).]' \
+ '(--inline-limit)--inline-limit[Maximum block size to inline. (experimental). Default: 32.]'
+ ;;
+ (bitswap)
+ local -a _bitswap_arguments
+ _bitswap_arguments=(
+ 'ledger:Show the current ledger for a peer.'
+ 'reprovide:Trigger reprovider.'
+ 'stat:Show some diagnostic information on the bitswap agent.'
+ 'wantlist:Show blocks currently on the wantlist.'
+ )
+ _ipfs_subcommand _bitswap_arguments
+ ;;
+ (block)
+ local -a _block_arguments
+ _block_arguments=(
+ 'get:Get a raw IPFS block.'
+ 'put:Store input as an IPFS block.'
+ 'rm:Remove IPFS block(s).'
+ 'stat:Print information of a raw IPFS block.'
+ )
+ _ipfs_subcommand _block_arguments
+ ;;
+ (bootstrap)
+ local -a _bootstrap_arguments
+ _bootstrap_arguments=(
+ 'add:Add peers to the bootstrap list.'
+ 'list:Show peers in the bootstrap list.'
+ 'rm:Remove peers from the bootstrap list.'
+ )
+ _ipfs_subcommand _bootstrap_arguments
+ ;;
+ (cat)
+ _arguments \
+ '(-o --offset)'{-o,--offset}'[Byte offset to begin reading from.]' \
+ '(-l --length)'{-l,--length}'[Maximum number of bytes to read.]'
+ ;;
+ (cid)
+ local -a _cid_arguments
+ _cid_arguments=(
+ 'base32:Convert CIDs to Base32 CID version 1.'
+ 'bases:List available multibase encodings.'
+ 'codecs:List available CID codecs.'
+ 'format:Format and convert a CID in various useful ways.'
+ 'hashes:List available multihashes.'
+ )
+ _ipfs_subcommand _cid_arguments
+ ;;
+ (commands)
+ _arguments '(-f --flags)'{-f,--flags}'[Show command flags.]'
+ ;;
+ (config)
+ _arguments \
+ '--bool[Set a boolean value.]' \
+ '--json[Parse stringified JSON.]'
+ local -a _config_arguments
+ _config_arguments=(
+ 'edit:Open the config file for editing in $EDITOR.'
+ 'profile:Apply profiles to config.'
+ 'replace:Replace the config with <file>.'
+ 'show:Output config file contents.'
+ )
+ _ipfs_subcommand _config_arguments
+ ;;
+ (daemon)
+ _arguments \
+ '--init[Initialize ipfs with default settings if not already initialized.]' \
+ '--init-profile[Configuration profiles to apply for --init. See ipfs init --help for more.]' \
+ '--routing[Overrides the routing option. Default: default.]' \
+ '--mount[Mounts IPFS to the filesystem.]' \
+ '--writable[Enable writing objects (with POST, PUT and DELETE).]' \
+ '--mount-ipfs[Path to the mountpoint for IPFS (if using --mount). Defaults to config setting.]' \
+ '--mount-ipns[Path to the mountpoint for IPNS (if using --mount). Defaults to config setting.]' \
+ '--unrestricted-api[Allow API access to unlisted hashes.]' \
+ '--disable-transport-encryption[Disable transport encryption (for debugging protocols).]' \
+ '--enable-gc[Enable automatic periodic repo garbage collection.]' \
+ '--manage-fdlimit[Check and raise file descriptor limits if needed. Default: true.]' \
+ '--migrate[If true, assume yes at the migrate prompt. If false, assume no.]' \
+ '--enable-pubsub-experiment[Instantiate the ipfs daemon with the experimental pubsub feature enabled.]' \
+ '--enable-namesys-pubsub[Enable IPNS record distribution through pubsub; enables pubsub.]' \
+ '--enable-mplex-experiment[Add the experimental 'go-multiplex' stream muxer to libp2p on construction. Default: true.]'
+ ;;
+ (dag)
+ local -a _dag_arguments
+ _dag_arguments=(
+ 'get:Get a dag node from ipfs.'
+ 'put:Add a dag node to ipfs.'
+ 'resolve:Resolve ipld block.'
+ )
+ _ipfs_subcommand _dag_arguments
+ ;;
+ (dht)
+ local -a _dht_arguments
+ _dht_arguments=(
+ 'findpeer:Find the multiaddresses associated with a Peer ID.'
+ 'findprovs:Find peers that can provide a specific value, given a key.'
+ 'get:Given a key, query the routing system for its best value.'
+ 'provide:Announce to the network that you are providing given values.'
+ 'put:Write a key/value pair to the routing system.'
+ 'query:Find the closest Peer IDs to a given Peer ID by querying the DHT.'
+ )
+ _ipfs_subcommand _dht_arguments
+ ;;
+ (diag)
+ local -a _diag_arguments
+ _diag_arguments=(
+ 'cmds:List commands run on this IPFS node.'
+ 'sys:Print system diagnostic information.'
+ )
+ _ipfs_subcommand _diag_arguments
+ ;;
+ (dns)
+ _arguments '(-r --recursive)'{-r,--recursive}'[Resolve until the result is not a DNS link. Default: true.]'
+ ;;
+ (files)
+ _arguments '(-f --flush)'{-f,--flush}'[Flush target and ancestors after write. Default: true.]'
+ local -a _files_arguments
+ _files_arguments=(
+ 'chcid:Change the cid version or hash function of the root node of a given path.'
+ 'cp:Copy files into mfs.'
+ "flush:Flush a given path's data to disk."
+ 'ls:List directories in the local mutable namespace.'
+ 'mkdir:Make directories.'
+ 'mv:Move files.'
+ 'read:Read a file in a given mfs.'
+ 'rm:Remove a file.'
+ 'stat:Display file status.'
+ 'write:Write to a mutable file in a given filesystem.'
+ )
+ _ipfs_subcommand _files_arguments
+ ;;
+ (filestore)
+ local -a _filestore_arguments
+ _filestore_arguments=(
+ 'dups:List blocks that are both in the filestore and standard block storage.'
+ 'ls:List objects in filestore.'
+ 'verify:Verify objects in filestore.'
+ )
+ _ipfs_subcommand _filestore_arguments
+ ;;
+ (get)
+ _arguments \
+ '(-o --output)'{-o,--output}'[The path where the output should be stored.]'\
+ '(-a --archive)'{-a,--archive}'[Output a TAR archive.]' \
+ '(-C --compress)'{-C,--compress}'[Compress the output with GZIP compression.]' \
+ '(-l --compression-level)'{-l,--compression-level}'[The level of compression (1-9).]'
+ ;;
+ (id)
+ _arguments '(-f --format)'{-f,--format}'[Optional output format.]'
+ ;;
+ (init)
+ _arguments \
+ '(-b --bits)'{-b,--bits}'[Number of bits to use in the generated RSA private key. Default: 2048.]' \
+ '(-e --empty-repo)'{-e,--empty-repo}"[Don't add and pin help files to the local storage.]" \
+ '(-p --profile)'{-p,--profile}"[Apply profile settings to config. Multiple profiles can be separated by ','.]"
+ ;;
+ (key)
+ local -a _key_arguments
+ _key_arguments=(
+ 'gen:Create a new keypair'
+ 'list:List all local keypairs'
+ 'rename:Rename a keypair'
+ 'rm:Remove a keypair'
+ )
+ _ipfs_subcommand _key_arguments
+ ;;
+ (log)
+ local -a _log_arguments
+ _log_arguments=(
+ 'level:Change the logging level.'
+ 'ls:List the logging subsystems.'
+ 'tail:Read the event log.'
+ )
+ _ipfs_subcommand _log_arguments
+ ;;
+ (ls)
+ _arguments \
+ '(-v --headers)'{-v,--headers}'[Print table headers (Hash, Size, Name).]' \
+ '--resolve-type[Resolve linked objects to find out their types. Default: true.]' \
+ '--size[Resolve linked objects to find out their file size. Default: true.]' \
+ '(-s --stream)'{-s,--stream}'[Enable exprimental streaming of directory entries as they are traversed.]' \
+ ;;
+ (mount)
+ _arguments \
+ '(-f --ipfs-path)'{-f,--ipfs-path}'[The path where IPFS should be mounted.]' \
+ '(-n --ipns-path)'{-n,--ipns-path}'[The path where IPNS should be mounted.]'
+ ;;
+ (name)
+ local -a _name_arguments
+ _name_arguments=(
+ 'publish:Publish IPNS names.'
+ 'pubsub:IPNS pubsub management.'
+ 'resolve:Resolve IPNS names.'
+ )
+ _ipfs_subcommand _name_arguments
+ ;;
+ (object)
+ local -a _object_arguments
+ _object_arguments=(
+ 'data:Output the raw bytes of an IPFS object.'
+ 'diff:Display the diff between two ipfs objects.'
+ 'get:Get and serialize the DAG node named by <key>.'
+ 'links:Output the links pointed to by the specified object.'
+ 'new:Create a new object from an ipfs template.'
+ 'patch:Create a new merkledag object based on an existing one.'
+ 'put:Store input as a DAG object, print its key.'
+ 'stat:Get stats for the DAG node named by <key>.'
+ )
+ _ipfs_subcommand _object_arguments
+ ;;
+ (p2p)
+ local -a _p2p_arguments
+ _p2p_arguments=(
+ 'close:Stop listening for new connections to forward.'
+ 'forward:Forward connections to libp2p service'
+ 'listen:Create libp2p service'
+ 'ls:List active p2p listeners.'
+ 'stream:P2P stream management.'
+ )
+ _ipfs_subcommand _p2p_arguments
+ ;;
+ (pin)
+ local -a _pin_arguments
+ _pin_arguments=(
+ 'add:Pin objects to local storage.'
+ 'ls:List objects pinned to local storage.'
+ 'rm:Remove pinned objects from local storage.'
+ 'update:Update a recursive pin'
+ 'verify:Verify that recursive pins are complete.'
+ )
+ _ipfs_subcommand _pin_arguments
+ ;;
+ (ping)
+ _arguments '(-n --count)'{-n,--count}'[Number of ping messages to send. Default: 10.]'
+ ;;
+ (refs)
+ _arguments \
+ '--format[Emit edges with given format. Available tokens: <src> <dst> <linkname>. Default: <dst>.]' \
+ '(-e --edges)'{-e,--edges}'[Emit edge format: `<from> -> <to>`.]' \
+ '(-u --unique)'{-u,--unique}'[Omit duplicate refs from output.]' \
+ '(-r --recursive)'{-r,--recursive}'[Recursively list links of child nodes.]' \
+ '--max-depth[Only for recursive refs, limits fetch and listing to the given depth. Default: -1.]'
+ local -a _refs_arguments
+ _refs_arguments='local:List all local references.'
+ _ipfs_subcommand _refs_arguments
+ ;;
+ (repo)
+ local -a _repo_arguments
+ _repo_arguments=(
+ 'fsck:Remove repo lockfiles.'
+ 'gc:Perform a garbage collection sweep on the repo.'
+ 'stat:Get stats for the currently used repo.'
+ 'verify:Verify all blocks in repo are not corrupted.'
+ 'version:Show the repo version.'
+ )
+ _ipfs_subcommand _repo_arguments
+ ;;
+ (resolve)
+ _arguments \
+ '(-r --recursive)'{-r,--recursive}'[Resolve until the result is an IPFS name. Default: true.]' \
+ '(--dhtrc --dht-record-count)'{--dhtrc,--dht-record-count}'[Number of records to request for DHT resolution.]' \
+ '(--dhtt --dht-timeout)'{--dhtt,--dht-timeout}'[Max time to collect values during DHT resolution eg "30s". Pass 0 for no timeout.]'
+ ;;
+ (stats)
+ local -a _stats_arguments
+ _stats_arguments=(
+ 'bitswap:Show some diagnostic information on the bitswap agent.'
+ 'bw:Print ipfs bandwidth information.'
+ 'repo:Get stats for the currently used repo.'
+ )
+ _ipfs_subcommand _stats_arguments
+ ;;
+ (swarm)
+ local -a _swarm_arguments
+ _swarm_arguments=(
+ 'addrs:List known addresses. Useful for debugging.'
+ 'connect:Open connection to a given address.'
+ 'disconnect:Close connection to a given address.'
+ 'filters:Manipulate address filters.'
+ 'peers:List peers with open connections.'
+ )
+ _ipfs_subcommand _swarm_arguments
+ ;;
+ (tar)
+ local -a _tar_arguments
+ _tar_arguments=(
+ 'add:Import a tar file into ipfs.'
+ 'cat:Export a tar file from IPFS.'
+ )
+ _ipfs_subcommand _tar_arguments
+ ;;
+ (version)
+ _arguments \
+ '(-n --number)'{-n,--number}'[Only show the version number.]' \
+ '--commit[Show the commit hash.]' \
+ '--repo[Show repo version.]' \
+ '--all[Show all version information.]'
+ ;;
+esac
diff --git a/plugins/kube-ps1/README.md b/plugins/kube-ps1/README.md
index a14337278..b08997b0f 100644
--- a/plugins/kube-ps1/README.md
+++ b/plugins/kube-ps1/README.md
@@ -6,14 +6,6 @@ configured on `kubectl` to your Bash/Zsh prompt strings (i.e. the `$PS1`).
Inspired by several tools used to simplify usage of `kubectl`.
-![prompt](img/screenshot2.png)
-
-![prompt_sol_light](img/screenshot-sol-light.png)
-
-![prompt_img](img/screenshot-img.png)
-
-![prompt demo](img/kube-ps1.gif)
-
## Installing
### MacOS
diff --git a/plugins/kubectl/README.md b/plugins/kubectl/README.md
index ee05a8af1..7a6cdaa59 100644
--- a/plugins/kubectl/README.md
+++ b/plugins/kubectl/README.md
@@ -22,7 +22,7 @@ plugins=(... kubectl)
| kcsc | `kubectl config set-context` | Set a context entry in kubeconfig |
| kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig |
| kccc | `kubectl config current-context` | Display the current-context |
-| kcgc | `kubectl config get-contexts` | List of contexts available
+| kcgc | `kubectl config get-contexts` | List of contexts available
| | | **General aliases** |
| kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector |
| kdelf | `kubectl delete -f` | Delete a pod using the type and name specified in -f argument |
@@ -91,13 +91,13 @@ plugins=(... kubectl)
| keno | `kubectl edit node` | Edit nodes resource from the default editor |
| kdno | `kubectl describe node` | Describe node resource in detail |
| kdelno | `kubectl delete node` | Delete the node |
-| | | **Persistent Volume Claim management** |
+| | | **Persistent Volume Claim management** |
| kgpvc | `kubectl get pvc` | List all PVCs |
| kgpvcw | `kgpvc --watch` | After listing/getting the requested object, watch for changes |
| kepvc | `kubectl edit pvc` | Edit pvcs from the default editor |
-| kdpvc | `kubectl describe pvc` | Descirbe all pvcs |
+| kdpvc | `kubectl describe pvc` | Describe all pvcs |
| kdelpvc | `kubectl delete pvc` | Delete all pvcs matching passed arguments |
-| | | |
+| | | **StatefulSets management** |
| kgss | `kubectl get statefulset` | List the statefulsets in ps format |
| kgssw | `kgss --watch` | After getting the list of statefulsets, watch for changes |
| kgsswide| `kgss -o wide` | After getting the statefulsets, output in plain-text format with any additional information |
@@ -106,3 +106,26 @@ plugins=(... kubectl)
| kdelss | `kubectl delete statefulset` | Delete the statefulset |
| ksss | `kubectl scale statefulset` | Scale a statefulset |
| krsss | `kubectl rollout status statefulset`| Check the rollout status of a deployment |
+| | | **Service Accounts management** |
+| kgsa | `kubectl get sa` | List all service accounts |
+| kdsa | `kubectl describe sa` | Describe a service account in details |
+| kdelsa | `kubectl delete sa` | Delete the service account |
+| | | **DaemonSet management** |
+| kgds | `kubectl get daemonset` | List all DaemonSets in ps output format |
+| kgdsw | `kgds --watch` | After listing all DaemonSets, watch for changes |
+| keds | `kubectl edit daemonset` | Edit DaemonSets from the default editor |
+| kdds | `kubectl describe daemonset` | Describe all DaemonSets in detail |
+| kdelds | `kubectl delete daemonset` | Delete all DaemonSets matching passed argument |
+| | | **CronJob management** |
+| kgcj | `kubectl get cronjob` | List all CronJobs in ps output format |
+| kecj | `kubectl edit cronjob` | Edit CronJob from the default editor |
+| kdcj | `kubectl describe cronjob` | Describe a CronJob in details |
+| kdelcj | `kubectl delete cronjob` | Delete the CronJob |
+
+## Wrappers
+
+This plugin provides 3 wrappers to colorize kubectl output in JSON and YAML using various tools (which must be installed):
+
+- `kj`: JSON, colorized with [`jq`](https://stedolan.github.io/jq/).
+- `kjx`: JSON, colorized with [`fx`](https://github.com/antonmedv/fx).
+- `ky`: YAML, colorized with [`yh`](https://github.com/andreazorzetto/yh).
diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh
index 647d029c1..d509d8795 100644
--- a/plugins/kubectl/kubectl.plugin.zsh
+++ b/plugins/kubectl/kubectl.plugin.zsh
@@ -1,7 +1,7 @@
if (( $+commands[kubectl] )); then
__KUBECTL_COMPLETION_FILE="${ZSH_CACHE_DIR}/kubectl_completion"
- if [[ ! -f $__KUBECTL_COMPLETION_FILE ]]; then
+ if [[ ! -f $__KUBECTL_COMPLETION_FILE || ! -s $__KUBECTL_COMPLETION_FILE ]]; then
kubectl completion zsh >! $__KUBECTL_COMPLETION_FILE
fi
@@ -150,3 +150,31 @@ alias kepvc='kubectl edit pvc'
alias kdpvc='kubectl describe pvc'
alias kdelpvc='kubectl delete pvc'
+# Service account management.
+alias kgsa="kubectl get sa"
+alias kdsa="kubectl describe sa"
+alias kdelsa="kubectl delete sa"
+
+# DaemonSet management.
+alias kgds='kubectl get daemonset'
+alias kgdsw='kgds --watch'
+alias keds='kubectl edit daemonset'
+alias kdds='kubectl describe daemonset'
+alias kdelds='kubectl delete daemonset'
+
+# CronJob management.
+alias kgcj='kubectl get cronjob'
+alias kecj='kubectl edit cronjob'
+alias kdcj='kubectl describe cronjob'
+alias kdelcj='kubectl delete cronjob'
+
+# Only run if the user actually has kubectl installed
+if (( ${+_comps[kubectl]} )); then
+ kj() { kubectl "$@" -o json | jq; }
+ kjx() { kubectl "$@" -o json | fx; }
+ ky() { kubectl "$@" -o yaml | yh; }
+
+ compdef kj=kubectl
+ compdef kjx=kubectl
+ compdef ky=kubectl
+fi
diff --git a/plugins/lando/LICENSE b/plugins/lando/LICENSE
new file mode 100644
index 000000000..1d4983163
--- /dev/null
+++ b/plugins/lando/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2019 Joshua Bedford
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE. \ No newline at end of file
diff --git a/plugins/lando/README.md b/plugins/lando/README.md
new file mode 100644
index 000000000..928a42bca
--- /dev/null
+++ b/plugins/lando/README.md
@@ -0,0 +1,37 @@
+# Lando ZSH (lando-zsh)
+
+This plugin adds aliases for using various languages and frameworks with [Lando](https://docs.lando.dev/basics/) for Docker. It will only run within lando-driven project directories.
+
+To use it, add `lando` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... lando)
+```
+
+## ALIASES:
+
+| Alias | Description |
+|:----------:|:----------------:|
+| `artisan` | `lando artisan` |
+| `composer` | `lando composer` |
+| `drush` | `lando drush` |
+| `gulp` | `lando gulp` |
+| `npm` | `lando npm` |
+| `wp` | `lando wp` |
+| `yarn` | `lando yarn` |
+
+## How It Works:
+
+This plugin removes the requirement to type `lando` before a command. It utilizes the lando version of supported commands run within directories with the following criteria:
+- The `.lando.yml` file is found in the current directory or any parent directory within `$LANDO_ZSH_SITES_DIRECTORY`.
+- The current directory is within `$LANDO_ZSH_SITES_DIRECTORY` but is not `$LANDO_ZSH_SITES_DIRECTORY` itself.
+
+## Settings:
+
+- `LANDO_ZSH_SITES_DIRECTORY`: The plugin will stop searching through parents for `CONFIG_FILE` once it hits this directory.
+- `LANDO_ZSH_CONFIG_FILE`: The plugin will check to see if this provided file exists to check for presence of Lando.
+
+## Author:
+
+- Author: Joshua Bedford
+- URL: [https://github.com/joshuabedford/lando-zsh](https://github.com/joshuabedford/lando-zsh)
diff --git a/plugins/lando/lando.plugin.zsh b/plugins/lando/lando.plugin.zsh
new file mode 100644
index 000000000..aa74c9924
--- /dev/null
+++ b/plugins/lando/lando.plugin.zsh
@@ -0,0 +1,40 @@
+# Settings
+: ${LANDO_ZSH_SITES_DIRECTORY:="$HOME/Sites"}
+: ${LANDO_ZSH_CONFIG_FILE:=.lando.yml}
+
+# Enable multiple commands with lando.
+function artisan \
+ composer \
+ drush \
+ gulp \
+ npm \
+ wp \
+ yarn {
+ if checkForLandoFile; then
+ lando "$0" "$@"
+ else
+ command "$0" "$@"
+ fi
+}
+
+# Check for the file in the current and parent directories.
+checkForLandoFile() {
+ # Only bother checking for lando within the Sites directory.
+ if [[ "$PWD/" != "$LANDO_ZSH_SITES_DIRECTORY"/* ]]; then
+ # Not within $LANDO_ZSH_SITES_DIRECTORY
+ return 1
+ fi
+
+ local curr_dir="$PWD"
+ # Checking for file: $LANDO_ZSH_CONFIG_FILE within $LANDO_ZSH_SITES_DIRECTORY...
+ while [[ "$curr_dir" != "$LANDO_ZSH_SITES_DIRECTORY" ]]; do
+ if [[ -f "$curr_dir/$LANDO_ZSH_CONFIG_FILE" ]]; then
+ return 0
+ fi
+ curr_dir="${curr_dir:h}"
+ done
+
+ # Could not find $LANDO_ZSH_CONFIG_FILE in the current directory
+ # or in any of its parents up to $LANDO_ZSH_SITES_DIRECTORY.
+ return 1
+} \ No newline at end of file
diff --git a/plugins/laravel5/laravel5.plugin.zsh b/plugins/laravel5/laravel5.plugin.zsh
index 487a0742b..70dc4ed02 100644
--- a/plugins/laravel5/laravel5.plugin.zsh
+++ b/plugins/laravel5/laravel5.plugin.zsh
@@ -1,20 +1,19 @@
+# Alias
+alias la5='php artisan'
+alias la5cache='php artisan cache:clear'
+alias la5routes='php artisan route:list'
+alias la5vendor='php artisan vendor:publish'
+
# Laravel5 basic command completion
_laravel5_get_command_list () {
- php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g"
+ php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g"
}
_laravel5 () {
- if [ -f artisan ]; then
- compadd `_laravel5_get_command_list`
+ if [[ -f artisan ]]; then
+ compadd $(_laravel5_get_command_list)
fi
}
compdef _laravel5 artisan
compdef _laravel5 la5
-
-#Alias
-alias la5='php artisan'
-
-alias la5cache='php artisan cache:clear'
-alias la5routes='php artisan route:list'
-alias la5vendor='php artisan vendor:publish'
diff --git a/plugins/magic-enter/magic-enter.plugin.zsh b/plugins/magic-enter/magic-enter.plugin.zsh
index 2d4d578b6..55b893535 100644
--- a/plugins/magic-enter/magic-enter.plugin.zsh
+++ b/plugins/magic-enter/magic-enter.plugin.zsh
@@ -1,27 +1,38 @@
-# Bind quick stuff to enter!
-#
-# Pressing enter in a git directory runs `git status`
-# in other directories `ls`
-magic-enter () {
- # If commands are not already set, use the defaults
- [ -z "$MAGIC_ENTER_GIT_COMMAND" ] && MAGIC_ENTER_GIT_COMMAND="git status -u ."
- [ -z "$MAGIC_ENTER_OTHER_COMMAND" ] && MAGIC_ENTER_OTHER_COMMAND="ls -lh ."
+# Default commands
+: ${MAGIC_ENTER_GIT_COMMAND:="git status -u ."} # run when in a git repository
+: ${MAGIC_ENTER_OTHER_COMMAND:="ls -lh ."} # run anywhere else
- if [[ -z $BUFFER ]]; then
- echo ""
- if git rev-parse --is-inside-work-tree &>/dev/null; then
- eval "$MAGIC_ENTER_GIT_COMMAND"
- else
- eval "$MAGIC_ENTER_OTHER_COMMAND"
- fi
- zle redisplay
+magic-enter() {
+ # Only run MAGIC_ENTER commands when in PS1 and command line is empty
+ # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#User_002dDefined-Widgets
+ if [[ -n "$BUFFER" || "$CONTEXT" != start ]]; then
+ return
+ fi
+
+ if command git rev-parse --is-inside-work-tree &>/dev/null; then
+ BUFFER="$MAGIC_ENTER_GIT_COMMAND"
else
- zle accept-line
+ BUFFER="$MAGIC_ENTER_OTHER_COMMAND"
fi
}
-zle -N magic-enter
+# Wrapper for the accept-line zle widget (run when pressing Enter)
+
+# If the wrapper already exists don't redefine it
+(( ! ${+functions[_magic-enter_accept-line]} )) || return 0
+
+case "$widgets[accept-line]" in
+ # Override the current accept-line widget, calling the old one
+ user:*) zle -N _magic-enter_orig_accept-line "${widgets[accept-line]#user:}"
+ function _magic-enter_accept-line() {
+ magic-enter
+ zle _magic-enter_orig_accept-line -- "$@"
+ } ;;
+ # If no user widget defined, call the original accept-line widget
+ builtin) function _magic-enter_accept-line() {
+ magic-enter
+ zle .accept-line
+ } ;;
+esac
-bindkey -M emacs "^M" magic-enter
-bindkey -M vicmd "^M" magic-enter
-bindkey -M viins "^M" magic-enter
+zle -N accept-line _magic-enter_accept-line
diff --git a/plugins/minikube/minikube.plugin.zsh b/plugins/minikube/minikube.plugin.zsh
index f7b365c7f..e87abceaf 100644
--- a/plugins/minikube/minikube.plugin.zsh
+++ b/plugins/minikube/minikube.plugin.zsh
@@ -1,13 +1,13 @@
# Autocompletion for Minikube.
#
if (( $+commands[minikube] )); then
- __MINICUBE_COMPLETION_FILE="${ZSH_CACHE_DIR}/minicube_completion"
+ __MINIKUBE_COMPLETION_FILE="${ZSH_CACHE_DIR}/minikube_completion"
- if [[ ! -f $__MINICUBE_COMPLETION_FILE ]]; then
- minikube completion zsh >! $__MINICUBE_COMPLETION_FILE
+ if [[ ! -f $__MINIKUBE_COMPLETION_FILE ]]; then
+ minikube completion zsh >! $__MINIKUBE_COMPLETION_FILE
fi
- [[ -f $__MINICUBE_COMPLETION_FILE ]] && source $__MINICUBE_COMPLETION_FILE
+ [[ -f $__MINIKUBE_COMPLETION_FILE ]] && source $__MINIKUBE_COMPLETION_FILE
- unset __MINICUBE_COMPLETION_FILE
+ unset __MINIKUBE_COMPLETION_FILE
fi
diff --git a/plugins/mvn/README.md b/plugins/mvn/README.md
index cbe7f30fa..815dfd57c 100644
--- a/plugins/mvn/README.md
+++ b/plugins/mvn/README.md
@@ -19,6 +19,7 @@ if it's found, or the mvn command otherwise.
| `mvn!` | `mvn -f <root>/pom.xml` |
| `mvnag` | `mvn archetype:generate` |
| `mvnboot` | `mvn spring-boot:run` |
+| `mvnqdev` | `mvn quarkus:dev` |
| `mvnc` | `mvn clean` |
| `mvncd` | `mvn clean deploy` |
| `mvnce` | `mvn clean eclipse:clean eclipse:eclipse` |
diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh
index 7cb94b42f..27d63a6f9 100644
--- a/plugins/mvn/mvn.plugin.zsh
+++ b/plugins/mvn/mvn.plugin.zsh
@@ -62,6 +62,7 @@ alias mvne='mvn eclipse:eclipse'
alias mvnfmt='mvn fmt:format'
alias mvnjetty='mvn jetty:run'
alias mvnp='mvn package'
+alias mvnqdev='mvn quarkus:dev'
alias mvns='mvn site'
alias mvnsrc='mvn dependency:sources'
alias mvnt='mvn test'
@@ -72,7 +73,7 @@ alias mvn-updates='mvn versions:display-dependency-updates'
function listMavenCompletions {
local file new_file
- local -a profiles POM_FILES
+ local -a profiles POM_FILES modules
# Root POM
POM_FILES=(~/.m2/settings.xml)
@@ -108,6 +109,9 @@ function listMavenCompletions {
profiles+=($(sed 's/<!--.*-->//' "$file" | sed '/<!--/,/-->/d' | grep -e "<profile>" -A 1 | grep -e "<id>.*</id>" | sed 's?.*<id>\(.*\)<\/id>.*?-P\1?'))
done
+ # List modules
+ modules=($(find **/pom.xml -type f | grep -v '/target/classes/META-INF/' | grep '/pom.xml' |sed 's|\(.*\)/pom\.xml|\1|'))
+
reply=(
# common lifecycle
clean initialize process-resources compile process-test-resources test-compile test package verify install deploy site
@@ -184,6 +188,8 @@ function listMavenCompletions {
tomee:run tomee:run-war tomee:run-war-only tomee:stop tomee:deploy tomee:undeploy
# spring-boot
spring-boot:run spring-boot:repackage
+ # quarkus
+ quarkus:dev quarkus:list-extensions quarkus:add-extension quarkus:add-extensions quarkus:generate-config quarkus:help
# exec
exec:exec exec:java
# versions
@@ -268,8 +274,8 @@ function listMavenCompletions {
stage:copy
# toolchain
toolchain:toolchain
- #liberty
- liberty:clean-server liberty:compile-jsp liberty:configure-arquillian liberty:create-server liberty:debug liberty:debug-server liberty:deploy liberty:dev liberty:display-url liberty:dump-server liberty:install-apps liberty:install-feature liberty:install-server liberty:java-dump-server liberty:package-server liberty:run liberty:run-server liberty:server-status liberty:start liberty:start-server liberty:status liberty:stop liberty:stop-server liberty:test-start-server liberty:test-stop-server liberty:undeploy liberty:uninstall-feature
+ #liberty
+ liberty:clean-server liberty:compile-jsp liberty:configure-arquillian liberty:create-server liberty:debug liberty:debug-server liberty:deploy liberty:dev liberty:display-url liberty:dump-server liberty:install-apps liberty:install-feature liberty:install-server liberty:java-dump-server liberty:package-server liberty:run liberty:run-server liberty:server-status liberty:start liberty:start-server liberty:status liberty:stop liberty:stop-server liberty:test-start-server liberty:test-stop-server liberty:undeploy liberty:uninstall-feature
# options
"-Dmaven.test.skip=true" -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile "-Dpmd.skip=true" "-Dcheckstyle.skip=true" "-Dtycho.mode=maven" "-Dmaven.test.failure.ignore=true" "-DgroupId=" "-DartifactId=" "-Dversion=" "-Dpackaging=jar" "-Dfile="
@@ -320,6 +326,7 @@ function listMavenCompletions {
-Dit.test=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dit.test=\1?' ; fi)
$profiles
+ $modules
)
}
diff --git a/plugins/npx/README.md b/plugins/npx/README.md
index 1c052930b..41e4c1352 100644
--- a/plugins/npx/README.md
+++ b/plugins/npx/README.md
@@ -1,21 +1,15 @@
# NPX Plugin
-> npx(1) -- execute npm package binaries. ([more info](https://github.com/zkat/npx))
-This plugin automatically registers npx command-not-found handler if `npx` exists in your `$PATH`.
+> npx(1) -- execute npm package binaries. ([more info](https://github.com/npm/npx))
-## Setup
+This plugin automatically registers npx command-not-found handler if `npx` exists in your `$PATH`.
-- Add plugin to `~/.zshrc`
+To use it, add `npx` to the plugins array in your zshrc file:
-```bash
+```zsh
plugins=(.... npx)
```
-- Globally install npx binary (npx will be auto installed with recent versions of Node.js)
-```bash
-sudo npm install -g npx
-```
-
## Note
The shell auto-fallback doesn't auto-install plain packages. In order to get it to install something, you need to add `@`:
@@ -29,3 +23,17 @@ Started
It does it this way so folks using the fallback don't accidentally try to install regular typoes.
+## Deprecation
+
+Since npm v7, `npx` has been moved to `npm exec`. With the move, [the `--shell-auto-fallback` argument
+for `npx` has been removed](https://github.com/npm/cli/blob/v7.0.0/docs/content/cli-commands/npm-exec.md#compatibility-with-older-npx-versions):
+
+> Shell fallback functionality is removed, as it is not advisable.
+
+When using npm v7, you'll get this error:
+
+> npx: the --shell-auto-fallback argument has been removed
+
+If you get this error, just disable the plugin by removing it from the plugins array in your zshrc file.
+This plugin will no longer be maintained and will be removed in the future, when the older `npx` versions
+are no longer available.
diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md
index 079cf0009..749a43403 100644
--- a/plugins/nvm/README.md
+++ b/plugins/nvm/README.md
@@ -1,9 +1,26 @@
# nvm plugin
-This plugin adds autocompletions for [nvm](https://github.com/creationix/nvm) — a Node.js version manager.
+This plugin adds autocompletions for [nvm](https://github.com/nvm-sh/nvm) — a Node.js version manager.
It also automatically sources nvm, so you don't need to do it manually in your `.zshrc`.
To use it, add `nvm` to the plugins array of your zshrc file:
+
```zsh
plugins=(... nvm)
```
+
+## Settings
+
+- **`NVM_DIR`**: if you have installed nvm in a directory other than `$HOME/.nvm`, set and export `NVM_DIR`
+ to be the directory where you installed nvm.
+
+- **`NVM_HOMEBREW`**: if you installed nvm via Homebrew, in a directory other than `/usr/local/opt/nvm`, you
+ can set `NVM_HOMEBREW` to be the directory where you installed it.
+
+- **`NVM_LAZY`**: if you want the plugin to defer the load of nvm to speed-up the start of your zsh session,
+ set `NVM_LAZY` to `1`. This will use the `--no-use` parameter when loading nvm, and will create a function
+ for `node`, `npm` and `yarn`, so when you call either of these three, nvm will load with `nvm use default`.
+
+- **`NVM_AUTOLOAD`**: if `NVM_AUTOLOAD` is set to `1`, the plugin will automatically load a node version when
+ if finds a [`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating
+ which node version to load.
diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh
index 4bab8e9d7..1e9b26e7a 100644
--- a/plugins/nvm/nvm.plugin.zsh
+++ b/plugins/nvm/nvm.plugin.zsh
@@ -1,8 +1,77 @@
-# Set NVM_DIR if it isn't already defined
-[[ -z "$NVM_DIR" ]] && export NVM_DIR="$HOME/.nvm"
+# See https://github.com/nvm-sh/nvm#installation-and-update
+if [[ -z "$NVM_DIR" ]]; then
+ if [[ -d "$HOME/.nvm" ]]; then
+ export NVM_DIR="$HOME/.nvm"
+ elif [[ -d "${XDG_CONFIG_HOME:-$HOME/.config}/nvm" ]]; then
+ export NVM_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/nvm"
+ fi
+fi
+
+# Don't try to load nvm if command already available
+which nvm &> /dev/null && return
+
+if [[ -f "$NVM_DIR/nvm.sh" ]]; then
+ # Load nvm if it exists in $NVM_DIR
+ source "$NVM_DIR/nvm.sh" ${NVM_LAZY+"--no-use"}
+else
+ # Otherwise try to load nvm installed via Homebrew
+ # User can set this if they have an unusual Homebrew setup
+ NVM_HOMEBREW="${NVM_HOMEBREW:-/usr/local/opt/nvm}"
+ # Load nvm from Homebrew location if it exists
+ if [[ -f "$NVM_HOMEBREW/nvm.sh" ]]; then
+ source "$NVM_HOMEBREW/nvm.sh" ${NVM_LAZY+"--no-use"}
+ else
+ # Exit the plugin if we couldn't find nvm
+ return
+ fi
+fi
+
+# Call nvm when first using node, npm or yarn
+if (( $+NVM_LAZY )); then
+ function node npm yarn {
+ unfunction node npm yarn
+ nvm use default
+ command "$0" "$@"
+ }
+fi
-# Try to load nvm only if command not already available
-if ! type "nvm" &> /dev/null; then
- # Load nvm if it exists
- [[ -f "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
+# Autoload nvm when finding a .nvmrc file in the current directory
+# Adapted from: https://github.com/nvm-sh/nvm#zsh
+if (( $+NVM_AUTOLOAD )); then
+ load-nvmrc() {
+ local node_version="$(nvm version)"
+ local nvmrc_path="$(nvm_find_nvmrc)"
+
+ if [[ -n "$nvmrc_path" ]]; then
+ local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
+
+ if [[ "$nvmrc_node_version" = "N/A" ]]; then
+ nvm install
+ elif [[ "$nvmrc_node_version" != "$node_version" ]]; then
+ nvm use
+ fi
+ elif [[ "$node_version" != "$(nvm version default)" ]]; then
+ echo "Reverting to nvm default version"
+ nvm use default
+ fi
+ }
+
+ autoload -U add-zsh-hook
+ add-zsh-hook chpwd load-nvmrc
+
+ load-nvmrc
fi
+
+# Load nvm bash completion
+for nvm_completion in "$NVM_DIR/bash_completion" "$NVM_HOMEBREW/etc/bash_completion.d/nvm"; do
+ if [[ -f "$nvm_completion" ]]; then
+ # Load bashcompinit
+ autoload -U +X bashcompinit && bashcompinit
+ # Bypass compinit call in nvm bash completion script. See:
+ # https://github.com/nvm-sh/nvm/blob/4436638/bash_completion#L86-L93
+ ZSH_VERSION= source "$nvm_completion"
+ break
+ fi
+done
+
+unset NVM_HOMEBREW NVM_LAZY NVM_AUTOLOAD nvm_completion
diff --git a/plugins/pip/pip.plugin.zsh b/plugins/pip/pip.plugin.zsh
index aaae90185..a46e7658c 100644
--- a/plugins/pip/pip.plugin.zsh
+++ b/plugins/pip/pip.plugin.zsh
@@ -9,7 +9,11 @@
# If you would like to clear your cache, go ahead and do a
# "zsh-pip-clear-cache".
-ZSH_PIP_CACHE_FILE=~/.pip/zsh-cache
+if [[ -d "${XDG_CACHE_HOME:-$HOME/.cache}/pip" ]]; then
+ ZSH_PIP_CACHE_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/pip/zsh-cache"
+else
+ ZSH_PIP_CACHE_FILE=~/.pip/zsh-cache
+fi
ZSH_PIP_INDEXES=(https://pypi.org/simple/)
zsh-pip-clear-cache() {
diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh
index b7ae2046f..82ba6ff8c 100644
--- a/plugins/pyenv/pyenv.plugin.zsh
+++ b/plugins/pyenv/pyenv.plugin.zsh
@@ -29,7 +29,7 @@ if [[ $FOUND_PYENV -ne 1 ]]; then
fi
if [[ $FOUND_PYENV -eq 1 ]]; then
- eval "$(pyenv init - zsh)"
+ eval "$(pyenv init - --no-rehash zsh)"
if (( $+commands[pyenv-virtualenv-init] )); then
eval "$(pyenv virtualenv-init - zsh)"
fi
diff --git a/plugins/safe-paste/safe-paste.plugin.zsh b/plugins/safe-paste/safe-paste.plugin.zsh
index 75f1791d7..d443ae8a2 100644
--- a/plugins/safe-paste/safe-paste.plugin.zsh
+++ b/plugins/safe-paste/safe-paste.plugin.zsh
@@ -1,54 +1,100 @@
+# A good summary of the zsh 5.1 Bracketed Paste Mode changes is at:
+# https://archive.zhimingwang.org/blog/2015-09-21-zsh-51-and-bracketed-paste.html
+
+# zsh 5.1 (September 2015) introduced built-in support for Bracketed Paste Mode
+# https://github.com/zsh-users/zsh/blob/68405f31a043bdd5bf338eb06688ed3e1f740937/README#L38-L45
+#
+# zsh 5.1 breaks url-quote-magic and other widgets replacing self-insert
+# zsh-users' bracketed-paste-magic resolves these issues:
+# https://github.com/zsh-users/zsh/blob/f702e17b14d75aa21bff014168fa9048124db286/Functions/Zle/bracketed-paste-magic#L9-L12
+
+# Load bracketed-paste-magic if zsh version is >= 5.1
+if [[ ${ZSH_VERSION:0:3} -ge 5.1 ]]; then
+ set zle_bracketed_paste # Explicitly restore this zsh default
+ autoload -Uz bracketed-paste-magic
+ zle -N bracketed-paste bracketed-paste-magic
+ return ### The rest of this file is NOT executed on zsh version >= 5.1 ###
+fi
+
+######################################################################
+# The rest of this file is ONLY executed if zsh version < 5.1
+######################################################################
+
# Code from Mikael Magnusson: https://www.zsh.org/mla/users/2011/msg00367.html
#
-# Requires xterm, urxvt, iTerm2 or any other terminal that supports bracketed
-# paste mode as documented: https://www.xfree86.org/current/ctlseqs.html
-
-# create a new keymap to use while pasting
-bindkey -N paste
-# make everything in this keymap call our custom widget
-bindkey -R -M paste "^@"-"\M-^?" paste-insert
-# these are the codes sent around the pasted text in bracketed
-# paste mode.
-# do the first one with both -M viins and -M vicmd in vi mode
-bindkey '^[[200~' _start_paste
-bindkey -M paste '^[[201~' _end_paste
-# insert newlines rather than carriage returns when pasting newlines
-bindkey -M paste -s '^M' '^J'
-
-zle -N _start_paste
-zle -N _end_paste
-zle -N zle-line-init _zle_line_init
-zle -N zle-line-finish _zle_line_finish
-zle -N paste-insert _paste_insert
-
-# switch the active keymap to paste mode
-function _start_paste() {
- bindkey -A paste main
+# Requires xterm, urxvt, iTerm2 or any other terminal that supports
+# Bracketed Paste Mode as documented:
+# https://www.xfree86.org/current/ctlseqs.html#Bracketed%20Paste%20Mode
+#
+# For tmux, use: bind ] paste-buffer -p
+#
+# Additional technical details: https://cirw.in/blog/bracketed-paste
+
+# Create a new keymap to use while pasting
+bindkey -N bracketed-paste
+# Make everything in this new keymap enqueue characters for pasting
+bindkey -RM bracketed-paste '\x00-\xFF' bracketed-paste-enqueue
+# These are the codes sent around the pasted text in bracketed paste mode
+bindkey -M main '^[[200~' _bracketed_paste_begin
+bindkey -M bracketed-paste '^[[201~' _bracketed_paste_end
+# Insert newlines rather than carriage returns when pasting newlines
+bindkey -M bracketed-paste -s '^M' '^J'
+
+zle -N _bracketed_paste_begin
+zle -N _bracketed_paste_end
+zle -N bracketed-paste-enqueue _bracketed_paste_enqueue
+
+# Attempt to not clobber zle_line_{init,finish}
+# Use https://github.com/willghatch/zsh-hooks if available
+if typeset -f hooks-add-hook > /dev/null; then
+ hooks-add-hook zle_line_init_hook _bracketed_paste_zle_init
+ hooks-add-hook zle_line_finish_hook _bracketed_paste_zle_finish
+else
+ zle -N zle-line-init _bracketed_paste_zle_init
+ zle -N zle-line-finish _bracketed_paste_zle_finish
+fi
+
+# Switch the active keymap to paste mode
+_bracketed_paste_begin() {
+ # Save the bindkey command to restore the active ("main") keymap
+ # Tokenise the restorative bindkey command into an array
+ _bracketed_paste_restore_keymap=( ${(z)"$(bindkey -lL main)"} )
+ bindkey -A bracketed-paste main
}
-# go back to our normal keymap, and insert all the pasted text in the
-# command line. this has the nice effect of making the whole paste be
+# Go back to our normal keymap, and insert all the pasted text in the
+# command line. This has the nice effect of making the whole paste be
# a single undo/redo event.
-function _end_paste() {
-#use bindkey -v here with vi mode probably. maybe you want to track
-#if you were in ins or cmd mode and restore the right one.
- bindkey -e
- LBUFFER+=$_paste_content
- unset _paste_content
+_bracketed_paste_end() {
+ # Only execute the restore command if it starts with 'bindkey'
+ # Allow for option KSH_ARRAYS being set (indexing starts at 0)
+ if [ ${_bracketed_paste_restore_keymap[@]:0:1} = 'bindkey' ]; then
+ $_bracketed_paste_restore_keymap
+ fi
+ LBUFFER+=$_bracketed_paste_content
+ unset _bracketed_paste_content _bracketed_paste_restore_keymap
}
-function _paste_insert() {
- _paste_content+=$KEYS
+# Append a pasted character to the content which is later inserted as a whole
+_bracketed_paste_enqueue() {
+ _bracketed_paste_content+=$KEYS
}
-function _zle_line_init() {
- # Tell terminal to send escape codes around pastes.
- [[ $TERM == rxvt-unicode || $TERM == xterm || $TERM = xterm-256color || $TERM = screen || $TERM = screen-256color ]] && printf '\e[?2004h'
+# Run at zle-line-init
+_bracketed_paste_zle_init() {
+ _bracketed_paste_content=''
+ # Tell terminal to send escape codes around pastes
+ if [[ $TERM =~ '^(rxvt-unicode|xterm(-256color)?|screen(-256color)?)$' ]]; then
+ printf '\e[?2004h'
+ fi
}
-function _zle_line_finish() {
- # Tell it to stop when we leave zle, so pasting in other programs
- # doesn't get the ^[[200~ codes around the pasted text.
- [[ $TERM == rxvt-unicode || $TERM == xterm || $TERM = xterm-256color || $TERM = screen || $TERM = screen-256color ]] && printf '\e[?2004l'
+# Run at zle-line-finish
+_bracketed_paste_zle_finish() {
+ # Turn off bracketed paste when we leave ZLE, so pasting in other programs
+ # doesn't get the ^[[200~ codes around the pasted text
+ if [[ $TERM =~ '^(rxvt-unicode|xterm(-256color)?|screen(-256color)?)$' ]]; then
+ printf '\e[?2004l'
+ fi
}
diff --git a/plugins/scd/README.md b/plugins/scd/README.md
index 8c156da1f..d8535f9f2 100644
--- a/plugins/scd/README.md
+++ b/plugins/scd/README.md
@@ -14,8 +14,9 @@ directory aliases, which appear as named directories in zsh session.
## INSTALLATION NOTES
Besides oh-my-zsh, `scd` can be used with *bash*, *dash* or *tcsh*
-shells and is also available as [Vim](https://www.vim.org/) plugin and
-[IPython](https://ipython.org/) extension. For installation details, see
+shells and is also available as Vim plugin
+[scd.vim](https://github.com/pavoljuhas/scd.vim) and
+[IPython](https://ipython.org) extension. For installation details, see
https://github.com/pavoljuhas/smart-change-directory.
## SYNOPSIS
@@ -24,11 +25,31 @@ https://github.com/pavoljuhas/smart-change-directory.
scd [options] [pattern1 pattern2 ...]
```
+## PATTERNS
+
+Patterns may use all zsh [glob operators](
+http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators)
+available with *extendedglob* option. Specified patterns must match
+the absolute path and at least one of them must match in the tail.
+Several special patterns are also recognized as follows:
+
+<dl><dt>
+^PAT</dt><dd>
+ PAT must match at the beginning of the path, for example, "^/home"</dd><dt>
+PAT$</dt><dd>
+ require PAT to match the end of the path, "man$"</dd><dt>
+./</dt><dd>
+ match only subdirectories of the current directory</dd><dt>
+:PAT</dt><dd>
+ require PAT to match over the tail component, ":doc", ":re/doc"</dd>
+</dl>
+
+
## OPTIONS
<dl><dt>
-a, --add</dt><dd>
- add specified directories to the directory index.</dd><dt>
+ add current or specified directories to the directory index.</dd><dt>
--unindex</dt><dd>
remove current or specified directories from the index.</dd><dt>
@@ -42,11 +63,16 @@ scd [options] [pattern1 pattern2 ...]
--unalias</dt><dd>
remove ALIAS definition for the current or specified directory from
- <em>~/.scdalias.zsh</em>.</dd><dt>
+ <em>~/.scdalias.zsh</em>. Use "OLD" to purge aliases to non-existent
+ directories.</dd><dt>
-A, --all</dt><dd>
- include all matching directories. Disregard matching by directory
- alias and filtering of less likely paths.</dd><dt>
+ display all directories even those excluded by patterns in
+ <em>~/.scdignore</em>. Disregard the unique matching for a
+ directory alias and filtering of less likely paths.</dd><dt>
+
+-p, --push</dt><dd>
+ use "pushd" to change to the target directory.</dd><dt>
--list</dt><dd>
show matching directories and exit.</dd><dt>
@@ -58,6 +84,7 @@ scd [options] [pattern1 pattern2 ...]
display this options summary and exit.</dd>
</dl>
+
## Examples
```sh
@@ -83,17 +110,26 @@ scd --alias=xray
scd xray
```
-# FILES
+## FILES
<dl><dt>
~/.scdhistory</dt><dd>
time-stamped index of visited directories.</dd><dt>
~/.scdalias.zsh</dt><dd>
- scd-generated definitions of directory aliases.</dd>
+ scd-generated definitions of directory aliases.</dd><dt>
+
+~/.scdignore</dt><dd>
+ <a href="http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators">
+ glob patterns</a> for paths to be ignored in the scd search, for example,
+ <code>/mnt/backup/*</code>. The patterns are specified one per line
+ and are matched assuming the <em>extendedglob</em> zsh option. Lines
+ starting with "#" are skipped as comments. The .scdignore patterns
+ are not applied in the <em>--all</em> mode.</dd>
</dl>
-# ENVIRONMENT
+
+## ENVIRONMENT
<dl><dt>
SCD_HISTFILE</dt><dd>
diff --git a/plugins/scd/_scd b/plugins/scd/_scd
new file mode 100644
index 000000000..39c7fa463
--- /dev/null
+++ b/plugins/scd/_scd
@@ -0,0 +1,60 @@
+#compdef scd
+#description smart change directory
+
+local curcontext="$curcontext" state line expl ret=1
+typeset -A opt_args
+
+local -a indexopts myargs
+indexopts=( --add -a --unindex )
+
+myargs=(
+ # common options
+ "(--help -h)"{--help,-h}"[print help and exit]"
+
+ # options for manipulating directory index
+ - index
+ "(--recursive -r)"{--recursive,-r}"[use recursive --add or --unindex]"
+ "($indexopts)"{--add,-a}"[add specified directories to the index]"
+ "($indexopts)--unindex[remove specified directories from the index]"
+ "*:directory:{ (( ${words[(I)-a|--add|--unindex]} )) && _path_files -/ }"
+
+ # define new directory alias
+ - alias
+ "--alias=[create alias for this or given directory]:directory-alias:()"
+ '1:directory:{ (( words[(I)--alias*] )) && _path_files -/ }'
+
+ # remove definition of directory alias
+ - unalias
+ "--unalias[remove definition of directory alias]"
+ "*::directory alias:->scd-alias-target"
+
+ # act on the directory change
+ - scd
+ "(--all -A)"{--all,-A}"[include less likely and ignored paths]"
+ "--list[print matching directories and exit]"
+ "(--verbose -v)"{--verbose,-v}"[show directory ranking and full paths]"
+ "(--push -p)"{--push,-p}"[change directory with 'pushd']"
+ "1::directory alias:->scd-alias-target"
+ "*:patterns:()"
+)
+
+_arguments -S -C $myargs && ret=0
+
+
+if [[ "$state" == scd-alias-target && -s ~/.scdalias.zsh ]]; then
+ local -a scdaliases
+ scdaliases=( )
+ eval "$(setopt extendedglob
+ phome="(#b)(#s)${HOME}(/*)#(#e)"
+ builtin hash -dr
+ source ~/.scdalias.zsh &&
+ for k v in ${(kv)nameddirs}; do
+ scdaliases+=( $k:${v/${~phome}/"~"${match[1]}} )
+ done
+ complete_unalias=${+opt_args[unalias---unalias]}
+ if (( complete_unalias && ! ${+nameddirs[OLD]} )); then
+ scdaliases+=( 'OLD:all aliases to non-existent paths' )
+ fi
+ typeset -p scdaliases )"
+ _describe -t scdaliases scdalias scdaliases
+fi
diff --git a/plugins/scd/scd b/plugins/scd/scd
index 39b28237d..a7db6c265 100644..100755
--- a/plugins/scd/scd
+++ b/plugins/scd/scd
@@ -1,29 +1,39 @@
#!/bin/zsh -f
emulate -L zsh
+
+local RUNNING_AS_COMMAND=
local EXIT=return
if [[ $(whence -w $0) == *:' 'command ]]; then
- emulate -R zsh
- local RUNNING_AS_COMMAND=1
+ RUNNING_AS_COMMAND=1
EXIT=exit
fi
local DOC='scd -- smart change to a recently used directory
usage: scd [options] [pattern1 pattern2 ...]
-Go to a directory path that contains all fixed string patterns. Prefer
-recent or frequently visited directories as found in the directory index.
+Go to a directory path that matches all patterns. Prefer recent or
+frequently visited directories as found in the directory index.
Display a selection menu in case of multiple matches.
+Special patterns:
+ ^PAT match at the path root, "^/home"
+ PAT$ match paths ending with PAT, "man$"
+ ./ match paths under the current directory
+ :PAT require PAT to span the tail, ":doc", ":re/doc"
+
Options:
- -a, --add add specified directories to the directory index.
+ -a, --add add current or specified directories to the index.
--unindex remove current or specified directories from the index.
-r, --recursive apply options --add or --unindex recursively.
--alias=ALIAS create alias for the current or specified directory and
store it in ~/.scdalias.zsh.
--unalias remove ALIAS definition for the current or specified
directory from ~/.scdalias.zsh.
- -A, --all include all matching directories. Disregard matching by
- directory alias and filtering of less likely paths.
+ Use "OLD" to purge aliases to non-existent directories.
+ -A, --all display all directories even those excluded by patterns
+ in ~/.scdignore. Disregard unique match for a directory
+ alias and filtering of less likely paths.
+ -p, --push use "pushd" to change to the target directory.
--list show matching directories and exit.
-v, --verbose display directory rank in the selection menu.
-h, --help display this message and exit.
@@ -36,18 +46,28 @@ local SCD_MEANLIFE=${SCD_MEANLIFE:-86400}
local SCD_THRESHOLD=${SCD_THRESHOLD:-0.005}
local SCD_SCRIPT=${RUNNING_AS_COMMAND:+$SCD_SCRIPT}
local SCD_ALIAS=~/.scdalias.zsh
+local SCD_IGNORE=~/.scdignore
-local ICASE a d m p i maxrank threshold
+# Minimum logarithm of probability. Avoids out of range warning in exp().
+local -r MINLOGPROB=-15
+
+# When false, use case-insensitive globbing to fix PWD capitalization.
+local PWDCASECORRECT=true
+if [[ ${OSTYPE} == darwin* ]]; then
+ PWDCASECORRECT=false
+fi
+
+local a d m p i maxrank threshold
local opt_help opt_add opt_unindex opt_recursive opt_verbose
-local opt_alias opt_unalias opt_all opt_list
-local -A drank dalias
+local opt_alias opt_unalias opt_all opt_push opt_list
+local -A drank dalias scdignore
local dmatching
local last_directory
-setopt extendedhistory extendedglob noautonamedirs brace_ccl
+setopt extendedglob noautonamedirs brace_ccl
-# If SCD_SCRIPT is defined make sure the file exists and is empty.
-# This removes any previous old commands.
+# If SCD_SCRIPT is defined make sure that that file exists and is empty.
+# This removes any old previous commands from the SCD_SCRIPT file.
[[ -n "$SCD_SCRIPT" ]] && [[ -s $SCD_SCRIPT || ! -f $SCD_SCRIPT ]] && (
umask 077
: >| $SCD_SCRIPT
@@ -56,13 +76,17 @@ setopt extendedhistory extendedglob noautonamedirs brace_ccl
# process command line options
zmodload -i zsh/zutil
zmodload -i zsh/datetime
-zparseopts -D -- a=opt_add -add=opt_add -unindex=opt_unindex \
+zmodload -i zsh/parameter
+zparseopts -D -E -- a=opt_add -add=opt_add -unindex=opt_unindex \
r=opt_recursive -recursive=opt_recursive \
-alias:=opt_alias -unalias=opt_unalias \
- A=opt_all -all=opt_all -list=opt_list \
+ A=opt_all -all=opt_all p=opt_push -push=opt_push -list=opt_list \
v=opt_verbose -verbose=opt_verbose h=opt_help -help=opt_help \
|| $EXIT $?
+# remove the first instance of "--" from positional arguments
+argv[(i)--]=( )
+
if [[ -n $opt_help ]]; then
print $DOC
$EXIT
@@ -71,6 +95,22 @@ fi
# load directory aliases if they exist
[[ -r $SCD_ALIAS ]] && source $SCD_ALIAS
+# load scd-ignore patterns if available
+if [[ -s $SCD_IGNORE ]]; then
+ setopt noglob
+ <$SCD_IGNORE \
+ while read p; do
+ [[ $p != [\#]* ]] || continue
+ [[ -n $p ]] || continue
+ # expand leading tilde if it has valid expansion
+ if [[ $p == [~]* ]] && ( : ${~p} ) 2>/dev/null; then
+ p=${~p}
+ fi
+ scdignore[$p]=1
+ done
+ setopt glob
+fi
+
# Private internal functions are prefixed with _scd_Y19oug_.
# Clean them up when the scd function returns.
setopt localtraps
@@ -79,9 +119,17 @@ trap 'unfunction -m "_scd_Y19oug_*"' EXIT
# works faster than the (:a) modifier and is compatible with zsh 4.2.6
_scd_Y19oug_abspath() {
set -A $1 ${(ps:\0:)"$(
- unfunction -m "*"; shift
+ setopt pushdsilent
+ unfunction -m "*"
+ unalias -m "*"
+ unset CDPATH
+ shift
for d; do
- cd $d && print -Nr -- $PWD && cd $OLDPWD
+ pushd $d || continue
+ $PWDCASECORRECT &&
+ print -Nr -- $PWD ||
+ print -Nr -- (#i)$PWD
+ popd 2>/dev/null
done
)"}
}
@@ -106,47 +154,76 @@ if [[ -n $opt_alias ]]; then
$EXIT $?
fi
-# undefine directory alias
+# undefine one or more directory aliases
if [[ -n $opt_unalias ]]; then
- if [[ -n $1 && ! -d $1 ]]; then
- print -u2 "'$1' is not a directory."
- $EXIT 1
- fi
- _scd_Y19oug_abspath a ${1:-$PWD}
- a=$(print -rD ${a})
- if [[ $a != [~][^/]## ]]; then
- $EXIT
+ local -U uu
+ local ec=0
+ uu=( ${*:-${PWD}} )
+ if (( ${uu[(I)OLD]} && ${+nameddirs[OLD]} == 0 )); then
+ uu=( ${uu:#OLD} ${(ps:\0:)"$(
+ hash -dr
+ if [[ -r $SCD_ALIAS ]]; then
+ source $SCD_ALIAS
+ fi
+ for a d in ${(kv)nameddirs}; do
+ [[ -d $d ]] || print -Nr -- $a
+ done
+ )"}
+ )
fi
- a=${a#[~]}
- # unalias in the current shell, update alias file if successful
- if unhash -d -- $a 2>/dev/null && [[ -r $SCD_ALIAS ]]; then
+ m=( )
+ for p in $uu; do
+ d=$p
+ if [[ ${+nameddirs[$d]} == 0 && -d $d ]]; then
+ _scd_Y19oug_abspath d $d
+ fi
+ a=${(k)nameddirs[$d]:-${(k)nameddirs[(r)$d]}}
+ if [[ -z $a ]]; then
+ ec=1
+ print -u2 "'$p' is neither a directory alias nor an aliased path."
+ continue
+ fi
+ # unalias in the current shell and remember to update the alias file
+ if unhash -d -- $a 2>/dev/null; then
+ m+=( $a )
+ fi
+ done
+ if [[ $#m != 0 && -r $SCD_ALIAS ]]; then
(
umask 077
hash -dr
source $SCD_ALIAS
- unhash -d -- $a 2>/dev/null &&
+ for a in $m; do
+ unhash -d -- $a 2>/dev/null
+ done
hash -dL >| $SCD_ALIAS
- )
+ ) || ec=$?
fi
- $EXIT $?
+ $EXIT $ec
fi
-# The "compress" function collapses repeated directories to
-# one entry with a time stamp that gives equivalent-probability.
+# The "compress" function collapses repeated directories into
+# a single entry with a time-stamp yielding an equivalent probability.
_scd_Y19oug_compress() {
- awk -v epochseconds=$EPOCHSECONDS -v meanlife=$SCD_MEANLIFE '
- BEGIN { FS = "[:;]"; }
- length($0) < 4096 && $2 > 0 {
+ awk -v epochseconds=$EPOCHSECONDS \
+ -v meanlife=$SCD_MEANLIFE \
+ -v minlogprob=$MINLOGPROB \
+ '
+ BEGIN {
+ FS = "[:;]";
+ pmin = exp(minlogprob);
+ }
+ /^: deleted:0;/ { next; }
+ length($0) < 4096 && $2 > 1000 {
+ df = $0;
+ sub("^[^;]*;", "", df);
+ if (!df) next;
tau = 1.0 * ($2 - epochseconds) / meanlife;
- if (tau < -6.9078) tau = -6.9078;
- prob = exp(tau);
- sub(/^[^;]*;/, "");
- if (NF) {
- dlist[last[$0]] = "";
- dlist[NR] = $0;
- last[$0] = NR;
- ptot[$0] += prob;
- }
+ prob = (tau < minlogprob) ? pmin : exp(tau);
+ dlist[last[df]] = "";
+ dlist[NR] = df;
+ last[df] = NR;
+ ptot[df] += prob;
}
END {
for (i = 1; i <= NR; ++i) {
@@ -157,26 +234,38 @@ _scd_Y19oug_compress() {
}
}
}
- ' $*
+ ' $*
}
-# Rewrite directory index if it is at least 20% oversized
-if [[ -s $SCD_HISTFILE ]] && \
-(( $(wc -l <$SCD_HISTFILE) > 1.2 * $SCD_HISTSIZE )); then
- # compress repeated entries
- m=( ${(f)"$(_scd_Y19oug_compress $SCD_HISTFILE)"} )
- # purge non-existent directories
- m=( ${(f)"$(
- for a in $m; do
- if [[ -d ${a#*;} ]]; then print -r -- $a; fi
- done
- )"}
- )
- # cut old entries if still oversized
- if [[ $#m -gt $SCD_HISTSIZE ]]; then
- m=( ${m[-$SCD_HISTSIZE,-1]} )
- fi
- print -lr -- $m >| ${SCD_HISTFILE}
+# Rewrite directory index if it is at least 20% oversized.
+local curhistsize
+if [[ -z $opt_unindex && -s $SCD_HISTFILE ]] && \
+curhistsize=$(wc -l <$SCD_HISTFILE) && \
+(( $curhistsize > 1.2 * $SCD_HISTSIZE )); then
+ # Compress repeated entries in a background process.
+ (
+ m=( ${(f)"$(_scd_Y19oug_compress $SCD_HISTFILE)"} )
+ # purge non-existent and ignored directories
+ m=( ${(f)"$(
+ for a in $m; do
+ d=${a#*;}
+ [[ -z ${scdignore[(k)$d]} ]] || continue
+ [[ -d $d ]] || continue
+ $PWDCASECORRECT || d=( (#i)${d} )
+ t=${a%%;*}
+ print -r -- "${t};${d}"
+ done
+ )"}
+ )
+ # cut old entries if still oversized
+ if [[ $#m -gt $SCD_HISTSIZE ]]; then
+ m=( ${m[-$SCD_HISTSIZE,-1]} )
+ fi
+ # Checking existence of many directories could have taken a while.
+ # Append any index entries added in meantime.
+ m+=( ${(f)"$(sed "1,${curhistsize}d" $SCD_HISTFILE)"} )
+ print -lr -- $m >| ${SCD_HISTFILE}
+ ) &|
fi
# Determine the last recorded directory
@@ -197,13 +286,8 @@ _scd_Y19oug_record() {
}
if [[ -n $opt_add ]]; then
- for d; do
- if [[ ! -d $d ]]; then
- print -u2 "Directory '$d' does not exist."
- $EXIT 2
- fi
- done
- _scd_Y19oug_abspath m ${*:-$PWD}
+ m=( ${^${argv:-$PWD}}(N-/) )
+ _scd_Y19oug_abspath m ${m}
_scd_Y19oug_record $m
if [[ -n $opt_recursive ]]; then
for d in $m; do
@@ -220,6 +304,7 @@ if [[ -n $opt_unindex ]]; then
if [[ ! -s $SCD_HISTFILE ]]; then
$EXIT
fi
+ argv=( ${argv:-$PWD} )
# expand existing directories in the argument list
for i in {1..$#}; do
if [[ -d ${argv[i]} ]]; then
@@ -227,24 +312,28 @@ if [[ -n $opt_unindex ]]; then
argv[i]=${d}
fi
done
+ # strip trailing slashes, but preserve the root path
+ argv=( ${argv/(#m)?\/##(#e)/${MATCH[1]}} )
m="$(awk -v recursive=${opt_recursive} '
BEGIN {
for (i = 2; i < ARGC; ++i) {
argset[ARGV[i]] = 1;
delete ARGV[i];
}
+ unindex_root = ("/" in argset);
}
1 {
d = $0; sub(/^[^;]*;/, "", d);
if (d in argset) next;
}
recursive {
+ if (unindex_root) exit;
for (a in argset) {
if (substr(d, 1, length(a) + 1) == a"/") next;
}
}
{ print $0 }
- ' $SCD_HISTFILE ${*:-$PWD} )" || $EXIT $?
+ ' $SCD_HISTFILE $* )" || $EXIT $?
: >| ${SCD_HISTFILE}
[[ ${#m} == 0 ]] || print -r -- $m >> ${SCD_HISTFILE}
$EXIT
@@ -252,67 +341,113 @@ fi
# The "action" function is called when there is just one target directory.
_scd_Y19oug_action() {
- cd $1 || return $?
+ local cdcmd=cd
+ [[ -z ${opt_push} ]] || cdcmd=pushd
+ builtin $cdcmd $1 || return $?
if [[ -z $SCD_SCRIPT && -n $RUNNING_AS_COMMAND ]]; then
print -u2 "Warning: running as command with SCD_SCRIPT undefined."
fi
if [[ -n $SCD_SCRIPT ]]; then
- print -r "cd ${(q)1}" >| $SCD_SCRIPT
+ local d=$1
+ if [[ $OSTYPE == cygwin && ${(L)SCD_SCRIPT} == *.bat ]]; then
+ d=$(cygpath -aw .)
+ fi
+ print -r "${cdcmd} ${(qqq)d}" >| $SCD_SCRIPT
fi
}
-# Match and rank patterns to the index file
-# set global arrays dmatching and drank
+# Select and order indexed directories by matching command-line patterns.
+# Set global arrays dmatching and drank.
_scd_Y19oug_match() {
## single argument that is an existing directory or directory alias
if [[ -z $opt_all && $# == 1 ]] && \
- [[ -d ${d::=$1} || -d ${d::=${nameddirs[$1]}} ]] && [[ -x $d ]];
+ [[ -d ${d::=${nameddirs[$1]}} || -d ${d::=$1} ]] && [[ -x $d ]];
then
_scd_Y19oug_abspath dmatching $d
drank[${dmatching[1]}]=1
return
fi
- # ignore case unless there is an argument with an uppercase letter
- [[ "$*" == *[[:upper:]]* ]] || ICASE='(#i)'
- # support "$" as an anchor for the directory name ending
+ # quote brackets when PWD is /Volumes/[C]/
+ local qpwd=${PWD//(#m)[][]/\\${MATCH}}
+
+ # support "./" as an alias for $PWD to match only subdirectories.
+ argv=( ${argv/(#s).\/(#e)/(#s)${qpwd}(|/*)(#e)} )
+
+ # support "./pat" as an alias for $PWD/pat.
+ argv=( ${argv/(#m)(#s).\/?*/(#s)${qpwd}${MATCH#.}} )
+
+ # support "^" as an anchor for the root directory, e.g., "^$HOME".
+ argv=( ${argv/(#m)(#s)\^?*/(#s)${${~MATCH[2,-1]}}} )
+
+ # support "$" as an anchor at the end of directory name.
argv=( ${argv/(#m)?[$](#e)/${MATCH[1]}(#e)} )
- # calculate rank of all directories in the SCD_HISTFILE and keep it as drank
- # include a dummy entry for splitting of an empty string is buggy
+ # support prefix ":" to match over the tail component.
+ argv=( ${argv/(#m)(#s):?*/${MATCH[2,-1]}[^/]#(#e)} )
+
+ # calculate rank of all directories in SCD_HISTFILE and store it in drank.
+ # include a dummy entry to avoid issues with splitting an empty string.
[[ -s $SCD_HISTFILE ]] && drank=( ${(f)"$(
print -l /dev/null -10
<$SCD_HISTFILE \
- awk -v epochseconds=$EPOCHSECONDS -v meanlife=$SCD_MEANLIFE '
- BEGIN { FS = "[:;]"; }
+ awk -v epochseconds=$EPOCHSECONDS \
+ -v meanlife=$SCD_MEANLIFE \
+ -v minlogprob=$MINLOGPROB \
+ '
+ BEGIN {
+ FS = "[:;]";
+ pmin = exp(minlogprob);
+ }
+ /^: deleted:0;/ {
+ df = $0;
+ sub("^[^;]*;", "", df);
+ delete ptot[df];
+ next;
+ }
length($0) < 4096 && $2 > 0 {
+ df = $0;
+ sub("^[^;]*;", "", df);
+ if (!df) next;
+ dp = df;
+ while (!(dp in ptot)) {
+ ptot[dp] = pmin;
+ sub("//*[^/]*$", "", dp);
+ if (!dp) break;
+ }
+ if ($2 <= 1000) next;
tau = 1.0 * ($2 - epochseconds) / meanlife;
- if (tau < -6.9078) tau = -6.9078;
- prob = exp(tau);
- sub(/^[^;]*;/, "");
- if (NF) ptot[$0] += prob;
+ prob = (tau < minlogprob) ? pmin : exp(tau);
+ ptot[df] += prob;
}
- END { for (di in ptot) { print di; print ptot[di]; } }'
+ END { for (di in ptot) { print di; print ptot[di]; } }
+ '
)"}
)
unset "drank[/dev/null]"
# filter drank to the entries that match all arguments
for a; do
- p=${ICASE}"*(${a})*"
+ p="(#l)*(${a})*"
drank=( ${(kv)drank[(I)${~p}]} )
done
- # require at least one argument matches the directory name
- p=${ICASE}"*(${(j:|:)argv})[^/]#"
+ # require that at least one argument matches in directory tail name.
+ p="(#l)*(${(j:|:)argv})[^/]#"
drank=( ${(kv)drank[(I)${~p}]} )
+ # discard ignored directories
+ if [[ -z ${opt_all} ]]; then
+ for d in ${(k)drank}; do
+ [[ -z ${scdignore[(k)$d]} ]] || unset "drank[$d]"
+ done
+ fi
+
# build a list of matching directories reverse-sorted by their probabilities
dmatching=( ${(f)"$(
- for d p in ${(kv)drank}; do
- print -r -- "$p $d";
- done | sort -grk1 | cut -d ' ' -f 2-
- )"}
+ builtin printf "%s %s\n" ${(Oakv)drank} |
+ /usr/bin/sort -grk1 )"}
)
+ dmatching=( ${dmatching#*[[:blank:]]} )
# do not match $HOME or $PWD when run without arguments
if [[ $# == 0 ]]; then
@@ -320,12 +455,20 @@ _scd_Y19oug_match() {
fi
# keep at most SCD_MENUSIZE of matching and valid directories
+ # mark up any deleted entries in the index
+ local -A isdeleted
m=( )
+ isdeleted=( )
for d in $dmatching; do
[[ ${#m} == $SCD_MENUSIZE ]] && break
- [[ -d $d && -x $d ]] && m+=$d
+ (( ${+isdeleted[$d]} == 0 )) || continue
+ [[ -d $d ]] || { isdeleted[$d]=1; continue }
+ [[ -x $d ]] && m+=$d
done
dmatching=( $m )
+ if [[ -n ${isdeleted} ]]; then
+ print -lr -- ": deleted:0;"${^${(k)isdeleted}} >> $SCD_HISTFILE
+ fi
# find the maximum rank
maxrank=0.0
@@ -343,7 +486,7 @@ _scd_Y19oug_match() {
_scd_Y19oug_match $*
-## process whatever directories that remained
+## process matching directories.
if [[ ${#dmatching} == 0 ]]; then
print -u2 "No matching directory."
$EXIT 1
@@ -367,13 +510,13 @@ if [[ -n $opt_list ]]; then
$EXIT
fi
-## process single directory match
+## handle a single matching directory here.
if [[ ${#dmatching} == 1 ]]; then
_scd_Y19oug_action $dmatching
$EXIT $?
fi
-## here we have multiple matches - display selection menu
+## Here we have multiple matches. Let's use the selection menu.
a=( {a-z} {A-Z} )
a=( ${a[1,${#dmatching}]} )
p=( )
diff --git a/plugins/scd/scd.plugin.zsh b/plugins/scd/scd.plugin.zsh
index 0197c53a1..1a6c18654 100644
--- a/plugins/scd/scd.plugin.zsh
+++ b/plugins/scd/scd.plugin.zsh
@@ -1,19 +1,17 @@
## The scd script should autoload as a shell function.
-autoload scd
+autoload -Uz scd
## If the scd function exists, define a change-directory-hook function
## to record visited directories in the scd index.
if [[ ${+functions[scd]} == 1 ]]; then
- scd_chpwd_hook() { scd --add $PWD }
- autoload add-zsh-hook
- add-zsh-hook chpwd scd_chpwd_hook
+ chpwd_scd() { scd --add $PWD }
+ autoload -Uz add-zsh-hook
+ add-zsh-hook chpwd chpwd_scd
fi
-## Allow scd usage with unquoted wildcard characters such as "*" or "?".
-alias scd='noglob scd'
-
-
## Load the directory aliases created by scd if any.
-if [[ -s ~/.scdalias.zsh ]]; then source ~/.scdalias.zsh; fi
+if [[ -s ~/.scdalias.zsh ]]; then
+ source ~/.scdalias.zsh
+fi
diff --git a/plugins/shell-proxy/proxy.py b/plugins/shell-proxy/proxy.py
index 2b62f6cb5..d2e5361cb 100755
--- a/plugins/shell-proxy/proxy.py
+++ b/plugins/shell-proxy/proxy.py
@@ -30,7 +30,7 @@ def merge(mapping: dict):
class CommandSet:
proxies = make_proxies(get_http_proxy())
aliases = {
- _: "env NAME=%s %s" % (_, ssh_agent)
+ _: "env __SSH_PROGRAM_NAME__=%s %s" % (_, ssh_agent)
for _ in ("ssh", "sftp", "scp", "slogin", "ssh-copy-id")
}
diff --git a/plugins/shell-proxy/ssh-agent.py b/plugins/shell-proxy/ssh-agent.py
index 61cf84c0b..4ee24b755 100755
--- a/plugins/shell-proxy/ssh-agent.py
+++ b/plugins/shell-proxy/ssh-agent.py
@@ -6,7 +6,7 @@ import sys
ssh_proxy = os.path.join(os.path.dirname(__file__), "ssh-proxy.py")
argv = [
- os.environ.get("NAME", "ssh"),
+ os.environ.get("__SSH_PROGRAM_NAME__", "ssh"),
"-o",
"ProxyCommand={} %h %p".format(ssh_proxy),
"-o",
diff --git a/plugins/sublime-merge/README.md b/plugins/sublime-merge/README.md
new file mode 100644
index 000000000..534479179
--- /dev/null
+++ b/plugins/sublime-merge/README.md
@@ -0,0 +1,17 @@
+## sublime-merge
+
+Plugin for Sublime Merge, a cross platform text and code editor, available for Linux, Mac OS X, and Windows.
+
+### Requirements
+
+ * [Sublime Merge](https://www.sublimemerge.com)
+
+### Usage
+
+ * If `sm` command is called without an argument, launch Sublime Merge
+
+ * If `sm` is passed a directory, `cd` to it and open the existing git repository in Sublime Merge
+
+ * If `smt` command is called, it is equivalent to `sm .`, opening the existing git repository in the current folder in Sublime Merge
+
+ * If `ssm` command is called, it is like `sudo sm`, opening the git repository in Sublime Merge. Useful for editing system protected repositories. \ No newline at end of file
diff --git a/plugins/sublime-merge/sublime-merge.plugin.zsh b/plugins/sublime-merge/sublime-merge.plugin.zsh
new file mode 100644
index 000000000..15452e61a
--- /dev/null
+++ b/plugins/sublime-merge/sublime-merge.plugin.zsh
@@ -0,0 +1,55 @@
+# Sublime Merge Aliases
+
+() {
+
+ if [[ "$OSTYPE" == linux* ]]; then
+ local _sublime_linux_paths
+ _sublime_linux_paths=(
+ "$HOME/bin/sublime_merge"
+ "/opt/sublime_merge/sublime_merge"
+ "/usr/bin/sublime_merge"
+ "/usr/local/bin/sublime_merge"
+ "/usr/bin/sublime_merge"
+ "/usr/local/bin/smerge"
+ "/usr/bin/smerge"
+ )
+ for _sublime_merge_path in $_sublime_linux_paths; do
+ if [[ -a $_sublime_merge_path ]]; then
+ sm_run() { $_sublime_merge_path "$@" >/dev/null 2>&1 &| }
+ ssm_run_sudo() {sudo $_sublime_merge_path "$@" >/dev/null 2>&1}
+ alias ssm=ssm_run_sudo
+ alias sm=sm_run
+ break
+ fi
+ done
+ elif [[ "$OSTYPE" = darwin* ]]; then
+ local _sublime_darwin_paths
+ _sublime_darwin_paths=(
+ "/usr/local/bin/smerge"
+ "/Applications/Sublime Merge.app/Contents/SharedSupport/bin/smerge"
+ "$HOME/Applications/Sublime Merge.app/Contents/SharedSupport/bin/smerge"
+ )
+ for _sublime_merge_path in $_sublime_darwin_paths; do
+ if [[ -a $_sublime_merge_path ]]; then
+ subm () { "$_sublime_merge_path" "$@" }
+ alias sm=subm
+ break
+ fi
+ done
+ elif [[ "$OSTYPE" = 'cygwin' ]]; then
+ local sublime_merge_cygwin_paths
+ sublime_merge_cygwin_paths=(
+ "$(cygpath $ProgramW6432/Sublime\ Merge)/sublime_merge.exe"
+ )
+ for _sublime_merge_path in $_sublime_merge_cygwin_paths; do
+ if [[ -a $_sublime_merge_path ]]; then
+ subm () { "$_sublime_merge_path" "$@" }
+ alias sm=subm
+ break
+ fi
+ done
+ fi
+
+}
+
+alias smt='sm .'
diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh
index 179342595..618dd8ee8 100644
--- a/plugins/sublime/sublime.plugin.zsh
+++ b/plugins/sublime/sublime.plugin.zsh
@@ -37,9 +37,11 @@ alias stn=create_project
_sublime_paths=(
"/usr/local/bin/subl"
"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
+ "/Applications/Sublime Text 4.app/Contents/SharedSupport/bin/subl"
"/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
"/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
"$HOME/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
+ "$HOME/Applications/Sublime Text 4.app/Contents/SharedSupport/bin/subl"
"$HOME/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
"$HOME/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
)
diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh
index 51579377d..f2445a762 100644
--- a/plugins/sudo/sudo.plugin.zsh
+++ b/plugins/sudo/sudo.plugin.zsh
@@ -9,37 +9,58 @@
# -------
#
# * Dongweiming <ciici123@gmail.com>
+# * Subhaditya Nath <github.com/subnut>
+# * Marc Cornellà <github.com/mcornella>
#
# ------------------------------------------------------------------------------
+__sudo-replace-buffer() {
+ local old=$1 new=$2 space=${2:+ }
+ if [[ ${#LBUFFER} -le ${#old} ]]; then
+ RBUFFER="${space}${BUFFER#$old }"
+ LBUFFER="${new}"
+ else
+ LBUFFER="${new}${space}${LBUFFER#$old }"
+ fi
+}
+
sudo-command-line() {
[[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)"
- if [[ -n $EDITOR && $BUFFER == $EDITOR\ * ]]; then
- if [[ ${#LBUFFER} -le ${#EDITOR} ]]; then
- RBUFFER=" ${BUFFER#$EDITOR }"
- LBUFFER="sudoedit"
- else
- LBUFFER="sudoedit ${LBUFFER#$EDITOR }"
- fi
- elif [[ $BUFFER == sudoedit\ * ]]; then
- if [[ ${#LBUFFER} -le 8 ]]; then
- RBUFFER=" ${BUFFER#sudoedit }"
- LBUFFER="$EDITOR"
- else
- LBUFFER="$EDITOR ${LBUFFER#sudoedit }"
- fi
- elif [[ $BUFFER == sudo\ * ]]; then
- if [[ ${#LBUFFER} -le 4 ]]; then
- RBUFFER="${BUFFER#sudo }"
- LBUFFER=""
- else
- LBUFFER="${LBUFFER#sudo }"
+
+ # Save beginning space
+ local WHITESPACE=""
+ if [[ ${LBUFFER:0:1} = " " ]]; then
+ WHITESPACE=" "
+ LBUFFER="${LBUFFER:1}"
+ fi
+
+ # Get the first part of the typed command and check if it's an alias to $EDITOR
+ # If so, locally change $EDITOR to the alias so that it matches below
+ if [[ -n "$EDITOR" ]]; then
+ local cmd="${${(Az)BUFFER}[1]}"
+ if [[ "${aliases[$cmd]} " = (\$EDITOR|$EDITOR)\ * ]]; then
+ local EDITOR="$cmd"
fi
+ fi
+
+ if [[ -n $EDITOR && $BUFFER = $EDITOR\ * ]]; then
+ __sudo-replace-buffer "$EDITOR" "sudoedit"
+ elif [[ -n $EDITOR && $BUFFER = \$EDITOR\ * ]]; then
+ __sudo-replace-buffer "\$EDITOR" "sudoedit"
+ elif [[ $BUFFER = sudoedit\ * ]]; then
+ __sudo-replace-buffer "sudoedit" "$EDITOR"
+ elif [[ $BUFFER = sudo\ * ]]; then
+ __sudo-replace-buffer "sudo" ""
else
LBUFFER="sudo $LBUFFER"
fi
+
+ # Preserve beginning space
+ LBUFFER="${WHITESPACE}${LBUFFER}"
}
+
zle -N sudo-command-line
+
# Defined shortcut keys: [Esc] [Esc]
bindkey -M emacs '\e\e' sudo-command-line
bindkey -M vicmd '\e\e' sudo-command-line
diff --git a/plugins/systemadmin/README.md b/plugins/systemadmin/README.md
index edca4d87d..243db03f2 100644
--- a/plugins/systemadmin/README.md
+++ b/plugins/systemadmin/README.md
@@ -16,8 +16,8 @@ plugins=(... systemadmin)
| clr | `clear; echo Currently logged in on $TTY, as $USER in directory $PWD.` | Clears the screen and prints the current user, TTY, and directory |
| path | `print -l $path` | Displays PATH with each entry on a separate line |
| mkdir | `mkdir -pv` | Automatically create parent directories and display verbose output |
-| psmem | `ps -e -orss=,args= \| sort -b -k1,1n` | Display the processes using the most memory |
-| psmem10 | `ps -e -orss=,args= \| sort -b -k1,1n \| head -10` | Display the top 10 processes using the most memory |
+| psmem | `ps -e -orss=,args= \| sort -b -k1 -nr` | Display the processes using the most memory |
+| psmem10 | `ps -e -orss=,args= \| sort -b -k1 -nr \| head -10` | Display the top 10 processes using the most memory |
| pscpu | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr` | Display the top processes using the most CPU |
| pscpu10 | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr \| head -10` | Display the top 10 processes using the most CPU |
| hist10 | `print -l ${(o)history%% *} \| uniq -c \| sort -nr \| head -n 10` | Display the top 10 most used commands in the history |
diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh
index ded25c3a9..03064c035 100644
--- a/plugins/systemadmin/systemadmin.plugin.zsh
+++ b/plugins/systemadmin/systemadmin.plugin.zsh
@@ -25,8 +25,8 @@ alias clr='clear; echo Currently logged in on $TTY, as $USER in directory $PWD.'
alias path='print -l $path'
alias mkdir='mkdir -pv'
# get top process eating memory
-alias psmem='ps -e -orss=,args= | sort -b -k1,1n'
-alias psmem10='ps -e -orss=,args= | sort -b -k1,1n| head -10'
+alias psmem='ps -e -orss=,args= | sort -b -k1 -nr'
+alias psmem10='ps -e -orss=,args= | sort -b -k1 -nr | head -10'
# get top process eating cpu if not work try excute : export LC_ALL='C'
alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr'
alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr | head -10'
diff --git a/plugins/terraform/README.md b/plugins/terraform/README.md
index 471aef24e..9e9f0cdfb 100644
--- a/plugins/terraform/README.md
+++ b/plugins/terraform/README.md
@@ -2,7 +2,7 @@
Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently.
-Current as of Terraform v0.11.7
+Current as of Terraform v0.13
### Requirements
@@ -17,6 +17,7 @@ plugins=(... terraform)
```
* Type `terraform` into your prompt and hit `TAB` to see available completion options
+ * Type `tf` into your prompt as a short alias to `terraform`
### Expanding ZSH prompt with current Terraform workspace name
diff --git a/plugins/terraform/_terraform b/plugins/terraform/_terraform
index e4298f2ab..a19e50670 100644
--- a/plugins/terraform/_terraform
+++ b/plugins/terraform/_terraform
@@ -6,14 +6,16 @@ _terraform_cmds=(
'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'
- 'push:Upload this Terraform module to Atlas to run'
'refresh:Update local state file against real resources'
'show:Inspect Terraform state or plan'
'state:Advanced state management'
@@ -23,6 +25,7 @@ _terraform_cmds=(
'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() {
@@ -31,45 +34,51 @@ __012upgrade() {
'-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 \
- '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
'-auto-approve[Skip interactive approval of plan before applying.]' \
- '-lock=[(true) Lock the state file when locking is supported.]' \
+ '-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 wil be colorless.]' \
'-parallelism=[(10) Limit the number of parallel resource operations.]' \
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
- '-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]' \
- '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
- '-target=[(resource) 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.]'
+ '-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.]'
+ '*-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.]' \
+ '-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) 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).]' \
- '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
- '-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.]'
+ '-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() {
@@ -81,33 +90,36 @@ __fmt() {
'-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[If specified, output will contain no color.]'
+ '-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.]' \
- '-no-color[If specified, output will contain no color.]' \
'-type=[(plan) Type of graph to output. Can be: plan, plan-destroy, apply, validate, input, refresh.]'
}
__import() {
_arguments \
- '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
+ '-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) 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.]' \
- '-provider=[(provider) Specific provider to use for import. This is used for specifying aliases, such as "aws.eu". Defaults to the normal provider prefix of the resource being imported.]' \
- '-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]' \
- '-state-out=[(PATH) Path to the destination state file to write to. If this is not specified, the source state file will be used. This can be a new or existing path.]' \
- '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times. This is only useful with the "-config" flag.]' \
- '-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]'
+ '-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() {
@@ -115,80 +127,94 @@ __init() {
'-backend=[(true) Configure the backend for this configuration.]' \
'-backend-config=[This can be either a path to an HCL file with key/value assignments (same format as terraform.tfvars) or a 'key=value' format. This is merged with what is in the configuration file. This can be specified multiple times. The backend type must be in the configuration itself.]' \
'-force-copy[Suppress prompts about copying state data. This is equivalent to providing a "yes" to all confirmation prompts.]' \
- '-from-module=[Copy the contents of the given module into the target directory before initialization.]' \
+ '-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) 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[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".]' \
- '-no-color[ If specified, output will contain no color.]' \
- '-module=[(name) If specified, returns the outputs for a specific module]' \
+ '-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 \
- '-destroy[() If set, a plan will be generated to destroy all resources managed by the given configuration and state.]' \
+ '-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) Lock the state file when locking is supported.]:lock:(true false)' \
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
- '-module-depth=[(n) Specifies the depth of modules to show in the output. This does not affect the plan itself, only the output shown. By default, this is -1, which will expand all.]' \
'-no-color[() If specified, output will contain no color.]' \
'-out=[(path) Write a plan file to the given path. This can be used as input to the "apply" command.]' \
'-parallelism=[(10) Limit the number of concurrent operations.]' \
'-refresh=[(true) Update state prior to checking for differences.]' \
- '-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]' \
- '-target=[(resource) 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.]' \
+ '-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() {
- _arguments \
+ 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 -/"
}
-__push() {
+__providers_schema() {
_arguments \
- '-atlas-address=[(url) An alternate address to an Atlas instance. Defaults to https://atlas.hashicorp.com.]' \
- '-upload-modules=[(true) If true (default), then the modules being used are all locked at their current checkout and uploaded completely to Atlas. This prevents Atlas from running terraform get for you.]' \
- '-name=[(name) Name of the infrastructure configuration in Atlas. The format of this is: "username/name" so that you can upload configurations not just to your account but to other accounts and organizations. This setting can also be set in the configuration in the Atlas section.]' \
- '-no-color[Disables output with coloring]' \
- '-overwrite=[(foo) Marks a specific variable to be updated on Atlas. Normally, if a variable is already set in Atlas, Terraform will not send the local value (even if it is different). This forces it to send the local value to Atlas. This flag can be repeated multiple times.]' \
- '-token=[(token) Atlas API token to use to authorize the upload. If blank or unspecified, the ATLAS_TOKEN environmental variable will be used.]' \
- '-var=[("foo=bar") Set the value of a variable for the Terraform configuration.]' \
- '-var-file=[(foo) Set the value of variables using a variable file.]' \
- '-vcs=[(true) If true (default), then Terraform will detect if a VCS is in use, such as Git, and will only upload files that are committed to version control. If no version control system is detected, Terraform will upload all files in path (parameter to the command).]'
+ '-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.]' \
+ '-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) 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".]' \
- '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
- '-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
- '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
- '-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
+ '-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 \
- '-module-depth=[(n) The maximum depth to expand modules. By default this is zero, which will not expand modules at all.]' \
+ '-json[If specified, output the Terraform plan or state in a machine-readable form.]' \
'-no-color[If specified, output will not contain any color.]'
}
@@ -199,6 +225,7 @@ __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'
)
@@ -207,7 +234,7 @@ __state() {
__state_list() {
_arguments \
- '-state=[(path) 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.]' \
+ '-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"
}
@@ -215,12 +242,12 @@ __state_list() {
__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.]:file:_files" \
- "-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.]:file:_files" \
- "-lock=[(true|false) Lock the state files when locking is supported.]:lock:(true false)" \
- "-lock-timeout=[(seconds) Duration to retry a state lock.]" \
- '-state=[(path) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:file:_files' \
- "-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.]:file:_files" \
+ '-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: "
@@ -229,26 +256,37 @@ __state_mv() {
__state_push() {
_arguments \
"-force[Write the state even if lineages don't match or the remote serial is higher.]" \
- '-lock=[(true|false) Lock the state file when locking is supported.]:lock:(true false)' \
- "-lock-timeout=[(seconds) Duration to retry a state lock.]" \
+ '-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.]:file:_files" \
- "-lock=[(true|false) Lock the state files when locking is supported.]:lock:(true false)" \
- "-lock-timeout=[(seconds) Duration to retry a state lock.]" \
- '-state=[(path) Path to the state file to update. Defaults to the current workspace state.]:file:_files' \
+ '-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=[(path) 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.]' \
+ '-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"
}
@@ -259,34 +297,36 @@ __statelist() {
__taint() {
_arguments \
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
- '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
- '-lock=[(true) Lock the state file when locking is supported.]' \
+ '-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).]' \
- '-no-color[If specified, output will not contain any color.]' \
- '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
- '-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]' \
+ '-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.]' \
- '-lock=[(true) Lock the state file when locking is supported.]' \
+ '-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).]' \
- '-no-color[If specified, output will not contain any color.]' \
- '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
- '-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]'
+ '-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 \
- '-check-variables=[(true) If set to true (default), the command will check whether all required variables have been specified.]' \
'-no-color[If specified, output will not contain any color.]' \
- '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
- '-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
+ '-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() {
@@ -312,6 +352,8 @@ local -a _command_args
case "$words[1]" in
0.12upgrade)
__012upgrade ;;
+ 0.13upgrade)
+ __013upgrade ;;
apply)
__apply ;;
console)
@@ -320,6 +362,8 @@ case "$words[1]" in
__destroy ;;
fmt)
__fmt;;
+ force-unlock)
+ __force_unlock;;
get)
__get ;;
graph)
@@ -328,14 +372,19 @@ case "$words[1]" in
__import;;
init)
__init ;;
+ login)
+ __login ;;
+ logout)
+ __logout ;;
output)
__output ;;
plan)
__plan ;;
providers)
- __providers ;;
- push)
- __push ;;
+ test $CURRENT -lt 3 && __providers
+ [[ $words[2] = "mirror" ]] && __providers_mirror
+ [[ $words[2] = "schema" ]] && __providers_schema
+ ;;
refresh)
__refresh ;;
show)
@@ -345,6 +394,7 @@ case "$words[1]" in
[[ $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
;;
@@ -354,6 +404,8 @@ case "$words[1]" in
__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 d727c1ee0..2c42d394d 100644
--- a/plugins/terraform/terraform.plugin.zsh
+++ b/plugins/terraform/terraform.plugin.zsh
@@ -7,3 +7,5 @@ function tf_prompt_info() {
echo "[${workspace}]"
fi
}
+
+alias tf='terraform'
diff --git a/plugins/thefuck/README.md b/plugins/thefuck/README.md
index bd407b316..84f7255ce 100644
--- a/plugins/thefuck/README.md
+++ b/plugins/thefuck/README.md
@@ -2,6 +2,10 @@
[The Fuck](https://github.com/nvbn/thefuck) plugin — magnificent app which corrects your previous console command.
+To use it, add thefuck to the plugins array of your zshrc file:
+
+plugins=(... thefuck)
+
## Usage
Press `ESC` twice to correct previous console command.
diff --git a/plugins/timer/timer.plugin.zsh b/plugins/timer/timer.plugin.zsh
index 1be7516a3..b261f71c5 100644
--- a/plugins/timer/timer.plugin.zsh
+++ b/plugins/timer/timer.plugin.zsh
@@ -1,5 +1,8 @@
+zmodload zsh/datetime
+
__timer_current_time() {
- perl -MTime::HiRes=time -e'print time'
+ zmodload zsh/datetime
+ echo $EPOCHREALTIME
}
__timer_format_duration() {
diff --git a/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh b/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh
index 28bf31f91..d7c76c3c9 100644
--- a/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh
+++ b/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh
@@ -16,22 +16,17 @@
# ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED="%{$fg_no_bold[white]%}○"
function vagrant_prompt_info() {
- test -d .vagrant && test -f Vagrantfile
- if [[ "$?" == "0" ]]; then
- statuses=$(vagrant status 2> /dev/null | grep -P "\w+\s+[\w\s]+\s\(\w+\)")
- statuses=("${(f)statuses}")
+ local vm_states vm_state
+ if [[ -d .vagrant && -f Vagrantfile ]]; then
+ vm_states=(${(f)"$(vagrant status 2> /dev/null | sed -nE 's/^.*(saved|poweroff|running|not created) \([[:alnum:]_]+\)$/\1/p')"})
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_PREFIX
- for vm_details in $statuses; do
- vm_state=$(echo $vm_details | grep -o -E "saved|poweroff|not created|running")
- if [[ "$vm_state" == "running" ]]; then
- printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING
- elif [[ "$vm_state" == "saved" ]]; then
- printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED
- elif [[ "$vm_state" == "not created" ]]; then
- printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED
- elif [[ "$vm_state" == "poweroff" ]]; then
- printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF
- fi
+ for vm_state in $vm_states; do
+ case "$vm_state" in
+ saved) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED ;;
+ running) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING ;;
+ poweroff) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF ;;
+ "not created") printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED ;;
+ esac
done
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUFFIX
fi
diff --git a/plugins/wd/README.md b/plugins/wd/README.md
index a454a6c1e..8791f9f0e 100644
--- a/plugins/wd/README.md
+++ b/plugins/wd/README.md
@@ -2,19 +2,19 @@
[![Build Status](https://travis-ci.org/mfaerevaag/wd.png?branch=master)](https://travis-ci.org/mfaerevaag/wd)
-`wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`. Why? Because `cd` seems inefficient when the folder is frequently visited or has a long path.
+`wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`.
+Why?
+Because `cd` seems inefficient when the folder is frequently visited or has a long path.
![tty.gif](https://raw.githubusercontent.com/mfaerevaag/wd/master/tty.gif)
-*NEWS*: If you are not using zsh, check out the c-port, [wd-c](https://github.com/mfaerevaag/wd-c), which works with all shells using wrapper functions.
-
## Setup
-### oh-my-zsh
+### [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)
-`wd` comes bundled with [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)!
+`wd` comes bundled with oh-my-zsh!
-Just add the plugin in your `~/.zshrc` file:
+Just add the plugin in your `.zshrc` file:
```zsh
plugins=(... wd)
@@ -38,11 +38,21 @@ antibody bundle mfaerevaag/wd
### Arch ([AUR](https://aur.archlinux.org/packages/zsh-plugin-wd-git/))
+1. Install from the AUR
+
```zsh
yay -S zsh-plugin-wd-git
# or use any other AUR helper
```
+2. Then add to your `.zshrc`:
+
+```zsh
+wd() {
+ . /usr/share/wd/wd.sh
+}
+```
+
### [zplug](https://github.com/zplug/zplug)
```zsh
@@ -51,7 +61,9 @@ zplug "mfaerevaag/wd", as:command, use:"wd.sh", hook-load:"wd() { . $ZPLUG_REPOS
### Automatic
-Run either in terminal:
+_Note: automatic install does not provide the manpage. It is also poor security practice to run remote code without first reviewing it, so you ought to look [here](https://github.com/mfaerevaag/wd/blob/master/install.sh)_
+
+Run either command in your terminal:
```zsh
curl -L https://github.com/mfaerevaag/wd/raw/master/install.sh | sh
@@ -65,28 +77,33 @@ wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.
### Manual
-* Clone this repo to your liking
+1. Clone this repository on your local machine in a sensible location (if you know what you're doing of course all of this is up to you):
-* Add `wd` function to `.zshrc` (or `.profile` etc.):
+```zsh
+git clone git@github.com:mfaerevaag/wd.git ~/.local/wd --depth 1
+```
- ```zsh
- wd() {
- . ~/path/to/cloned/repo/wd/wd.sh
- }
- ```
+2. Add `wd` function to `.zshrc` (or `.profile` etc.):
-* Install manpage. From `wd`'s base directory (requires root permissions):
+```zsh
+wd() {
+ . ~/.local/wd/wd.sh
+}
+```
- ```zsh
- cp wd.1 /usr/share/man/man1/wd.1
- chmod 644 /usr/share/man/man1/wd.1
- ```
+3. Install manpage (optional):
- **Note:** when pulling and updating `wd`, you'll need to do this again in case of changes to the manpage.
+```zsh
+sudo cp ~/.local/wd/wd.1 /usr/share/man/man1/wd.1
+sudo chmod 644 /usr/share/man/man1/wd.1
+```
+
+**Note:** when pulling and updating `wd`, you'll need to repeat step 3 should the manpage change
## Completion
-If you're NOT using [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) and you want to utilize the zsh-completion feature, you will also need to add the path to your `wd` installation (`~/bin/wd` if you used the automatic installer) to your `fpath`. E.g. in your `~/.zshrc`:
+If you're NOT using [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) and you want to utilize the zsh-completion feature, you will also need to add the path to your `wd` installation (`~/bin/wd` if you used the automatic installer) to your `fpath`.
+E.g. in your `~/.zshrc`:
```zsh
fpath=(~/path/to/wd $fpath)
@@ -102,109 +119,110 @@ rm -f ~/.zcompdump; compinit
* Add warp point to current working directory:
- ```zsh
- wd add foo
- ```
+```zsh
+wd add foo
+```
- If a warp point with the same name exists, use `wd add! foo` to overwrite it.
+If a warp point with the same name exists, use `wd add foo --force` to overwrite it.
- **Note:** a warp point cannot contain colons, or consist of only spaces and dots. The first will conflict in how `wd` stores the warp points, and the second will conflict with other features, as below.
+**Note:** a warp point cannot contain colons, or consist of only spaces and dots.
+The first will conflict in how `wd` stores the warp points, and the second will conflict with other features, as below.
- You can omit point name to automatically use the current directory's name instead.
+You can omit point name to automatically use the current directory's name instead.
* From any directory, warp to `foo` with:
- ```zsh
- wd foo
- ```
+```zsh
+wd foo
+```
-* You can also warp to a directory within foo, with autocompletion:
+* You can also warp to a directory within `foo`, with autocompletion:
- ```zsh
- wd foo some/inner/path
- ```
+```zsh
+wd foo some/inner/path
+```
* You can warp back to previous directory and higher, with this dot syntax:
- ```zsh
- wd ..
- wd ...
- ```
+```zsh
+wd ..
+wd ...
+```
- This is a wrapper for the zsh's `dirs` function.
- _You might need to add `setopt AUTO_PUSHD` to your `.zshrc` if you are not using [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh))._
+This is a wrapper for the zsh's `dirs` function.
+_You might need to add `setopt AUTO_PUSHD` to your `.zshrc` if you are not using [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)._
* Remove warp point:
- ```zsh
- wd rm foo
- ```
+```zsh
+wd rm foo
+```
- You can omit point name to use the current directory's name instead.
+You can omit point name to use the current directory's name instead.
-* List all warp points (stored in `~/.warprc`):
+* List all warp points (stored in `~/.warprc` by default):
- ```zsh
- wd list
- ```
+```zsh
+wd list
+```
* List files in given warp point:
- ```zsh
- wd ls foo
- ```
+```zsh
+wd ls foo
+```
* Show path of given warp point:
- ```zsh
- wd path foo
- ```
+```zsh
+wd path foo
+```
* List warp points to current directory, or optionally, path to given warp point:
- ```zsh
- wd show
- ```
+```zsh
+wd show
+```
* Remove warp points to non-existent directories.
- ```zsh
- wd clean
- ```
+```zsh
+wd clean
+```
- Use `wd clean!` to not be prompted with confirmation (force).
+Use `wd clean --force` to not be prompted with confirmation.
* Print usage info:
- ```zsh
- wd help
- ```
+```zsh
+wd help
+```
- The usage will be printed also if you call `wd` with no command
+The usage will be printed also if you call `wd` with no command
* Print the running version of `wd`:
- ```zsh
- wd --version
- ```
+```zsh
+wd --version
+```
* Specifically set the config file (default being `~/.warprc`), which is useful for testing:
- ```zsh
- wd --config ./file <command>
- ```
+```zsh
+wd --config ./file <command>
+```
* Force `exit` with return code after running. This is not default, as it will *exit your terminal*, though required for testing/debugging.
- ```zsh
- wd --debug <command>
- ```
+```zsh
+wd --debug <command>
+```
* Silence all output:
- ```zsh
- wd --quiet <command>
- ```
+```zsh
+wd --quiet <command>
+```
## Configuration
@@ -216,7 +234,7 @@ Defines the path where warp points get stored. Defaults to `$HOME/.warprc`.
## Testing
-`wd` comes with a small test suite, run with [shunit2](https://code.google.com/p/shunit2/). This can be used to confirm that things are working as they should on your setup, or to demonstrate an issue.
+`wd` comes with a small test suite, run with [shunit2](https://github.com/kward/shunit2). This can be used to confirm that things are working as they should on your setup, or to demonstrate an issue.
To run, simply `cd` into the `test` directory and run the `tests.sh`.
@@ -225,15 +243,17 @@ cd ./test
./tests.sh
```
-## License
+## Maintainers
+
+Following @mfaerevaag stepping away from active maintainership of this repository, the following users now are also maintainers of the repo:
-The project is licensed under the [MIT license](https://github.com/mfaerevaag/wd/blob/master/LICENSE).
+* @alpha-tango-kilo
-## Contributing
+* @MattLewin
-If you have issues, feedback or improvements, don't hesitate to report it or submit a pull request. In the case of an issue, we would much appreciate if you would include a failing test in `test/tests.sh`. For an explanation on how to run the tests, read the section "Testing" in this README.
+Anyone else contributing is greatly appreciated and will be mentioned in the release notes!
-----
+---
Credit to [altschuler](https://github.com/altschuler) for an awesome idea.
diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
index 618995c63..9085c5b7b 100644
--- a/plugins/wd/wd.sh
+++ b/plugins/wd/wd.sh
@@ -8,7 +8,7 @@
# @github.com/mfaerevaag/wd
# version
-readonly WD_VERSION=0.4.6
+readonly WD_VERSION=0.5.0
# colors
readonly WD_BLUE="\033[96m"
@@ -71,7 +71,7 @@ wd_print_msg()
wd_print_usage()
{
- cat <<- EOF
+ command cat <<- EOF
Usage: wd [command] [point]
Commands:
@@ -79,8 +79,6 @@ Commands:
<point> <path> Warps to the directory specified by the warp point with path appended
add <point> Adds the current working directory to your warp points
add Adds the current working directory to your warp points with current directory's name
- add! <point> Overwrites existing warp point
- add! Overwrites existing warp point with current directory's name
rm <point> Removes the given warp point
rm Removes the given warp point with current directory's name
show <point> Print path to given warp point
@@ -88,12 +86,13 @@ Commands:
list Print all stored warp points
ls <point> Show files from given warp point (ls)
path <point> Show the path to given warp point (pwd)
- clean! Remove points warping to nonexistent directories
+ clean Remove points warping to nonexistent directories (will prompt unless --force is used)
-v | --version Print version
-d | --debug Exit after execution with exit codes (for testing)
-c | --config Specify config file (default ~/.warprc)
-q | --quiet Suppress all output
+ -f | --force Allows overwriting without warning (for add & clean)
help Show this extremely helpful text
EOF
@@ -103,7 +102,7 @@ wd_exit_fail()
{
local msg=$1
- wd_print_msg $WD_RED $msg
+ wd_print_msg "$WD_RED" "$msg"
WD_EXIT_CODE=1
}
@@ -111,7 +110,7 @@ wd_exit_warn()
{
local msg=$1
- wd_print_msg $WD_YELLOW $msg
+ wd_print_msg "$WD_YELLOW" "$msg"
WD_EXIT_CODE=1
}
@@ -119,7 +118,7 @@ wd_getdir()
{
local name_arg=$1
- point=$(wd_show $name_arg)
+ point=$(wd_show "$name_arg")
dir=${point:28+$#name_arg+7}
if [[ -z $name_arg ]]; then
@@ -162,12 +161,12 @@ wd_warp()
wd_add()
{
- local force=$1
- local point=$2
+ local point=$1
+ local force=$2
if [[ $point == "" ]]
then
- point=$(basename $PWD)
+ point=$(basename "$PWD")
fi
if [[ $point =~ "^[\.]+$" ]]
@@ -176,60 +175,62 @@ wd_add()
elif [[ $point =~ "[[:space:]]+" ]]
then
wd_exit_fail "Warp point should not contain whitespace"
- elif [[ $point == *:* ]]
+ elif [[ $point =~ : ]] || [[ $point =~ / ]]
then
- wd_exit_fail "Warp point cannot contain colons"
- elif [[ ${points[$point]} == "" ]] || $force
+ wd_exit_fail "Warp point contains illegal character (:/)"
+ elif [[ ${points[$point]} == "" ]] || [ ! -z "$force" ]
then
- wd_remove $point > /dev/null
- printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> $WD_CONFIG
+ wd_remove "$point" > /dev/null
+ printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> "$WD_CONFIG"
if (whence sort >/dev/null); then
local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
# use 'cat' below to ensure we respect $WD_CONFIG as a symlink
- sort -o "${config_tmp}" $WD_CONFIG && cat "${config_tmp}" > $WD_CONFIG && rm "${config_tmp}"
+ command sort -o "${config_tmp}" "$WD_CONFIG" && command cat "${config_tmp}" > "$WD_CONFIG" && command rm "${config_tmp}"
fi
wd_export_static_named_directories
- wd_print_msg $WD_GREEN "Warp point added"
+ wd_print_msg "$WD_GREEN" "Warp point added"
# override exit code in case wd_remove did not remove any points
# TODO: we should handle this kind of logic better
WD_EXIT_CODE=0
else
- wd_exit_warn "Warp point '${point}' already exists. Use 'add!' to overwrite."
+ wd_exit_warn "Warp point '${point}' already exists. Use 'add --force' to overwrite."
fi
}
wd_remove()
{
- local point=$1
+ local point_list=$1
- if [[ $point == "" ]]
+ if [[ "$point_list" == "" ]]
then
- point=$(basename $PWD)
+ point_list=$(basename "$PWD")
fi
- if [[ ${points[$point]} != "" ]]
- then
- local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
- # Copy and delete in two steps in order to preserve symlinks
- if sed -n "/^${point}:.*$/!p" $WD_CONFIG > $config_tmp && cp $config_tmp $WD_CONFIG && rm $config_tmp
+ for point_name in $point_list ; do
+ if [[ ${points[$point_name]} != "" ]]
then
- wd_print_msg $WD_GREEN "Warp point removed"
+ local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
+ # Copy and delete in two steps in order to preserve symlinks
+ if sed -n "/^${point_name}:.*$/!p" "$WD_CONFIG" > "$config_tmp" && command cp "$config_tmp" "$WD_CONFIG" && command rm "$config_tmp"
+ then
+ wd_print_msg "$WD_GREEN" "Warp point removed"
+ else
+ wd_exit_fail "Something bad happened! Sorry."
+ fi
else
- wd_exit_fail "Something bad happened! Sorry."
+ wd_exit_fail "Warp point was not found"
fi
- else
- wd_exit_fail "Warp point was not found"
- fi
+ done
}
wd_list_all()
{
- wd_print_msg $WD_BLUE "All warp points:"
+ wd_print_msg "$WD_BLUE" "All warp points:"
- entries=$(sed "s:${HOME}:~:g" $WD_CONFIG)
+ entries=$(sed "s:${HOME}:~:g" "$WD_CONFIG")
max_warp_point_length=0
while IFS= read -r line
@@ -242,7 +243,7 @@ wd_list_all()
then
max_warp_point_length=$length
fi
- done <<< $entries
+ done <<< "$entries"
while IFS= read -r line
do
@@ -254,35 +255,35 @@ wd_list_all()
if [[ -z $wd_quiet_mode ]]
then
- printf "%${max_warp_point_length}s -> %s\n" $key $val
+ printf "%${max_warp_point_length}s -> %s\n" "$key" "$val"
fi
fi
- done <<< $entries
+ done <<< "$entries"
}
wd_ls()
{
- wd_getdir $1
- ls ${dir/#\~/$HOME}
+ wd_getdir "$1"
+ ls "${dir/#\~/$HOME}"
}
wd_path()
{
- wd_getdir $1
- echo $(echo $dir | sed "s:${HOME}:~:g")
+ wd_getdir "$1"
+ echo "$(echo "$dir" | sed "s:~:${HOME}:g")"
}
wd_show()
{
local name_arg=$1
# if there's an argument we look up the value
- if [[ ! -z $name_arg ]]
+ if [[ -n $name_arg ]]
then
if [[ -z $points[$name_arg] ]]
then
- wd_print_msg $WD_BLUE "No warp point named $name_arg"
+ wd_print_msg "$WD_BLUE" "No warp point named $name_arg"
else
- wd_print_msg $WD_GREEN "Warp point: ${WD_GREEN}$name_arg${WD_NOC} -> $points[$name_arg]"
+ wd_print_msg "$WD_GREEN" "Warp point: ${WD_GREEN}$name_arg${WD_NOC} -> $points[$name_arg]"
fi
else
# hax to create a local empty array
@@ -290,19 +291,19 @@ wd_show()
wd_matches=()
# do a reverse lookup to check whether PWD is in $points
PWD="${PWD/$HOME/~}"
- if [[ ${points[(r)$PWD]} == $PWD ]]
+ if [[ ${points[(r)$PWD]} == "$PWD" ]]
then
for name in ${(k)points}
do
- if [[ $points[$name] == $PWD ]]
+ if [[ $points[$name] == "$PWD" ]]
then
wd_matches[$(($#wd_matches+1))]=$name
fi
done
- wd_print_msg $WD_BLUE "$#wd_matches warp point(s) to current directory: ${WD_GREEN}$wd_matches${WD_NOC}"
+ wd_print_msg "$WD_BLUE" "$#wd_matches warp point(s) to current directory: ${WD_GREEN}$wd_matches${WD_NOC}"
else
- wd_print_msg $WD_YELLOW "No warp point to $(echo $PWD | sed "s:$HOME:~:")"
+ wd_print_msg "$WD_YELLOW" "No warp point to $(echo "$PWD" | sed "s:$HOME:~:")"
fi
fi
}
@@ -312,7 +313,7 @@ wd_clean() {
local count=0
local wd_tmp=""
- while read line
+ while read -r line
do
if [[ $line != "" ]]
then
@@ -322,32 +323,32 @@ wd_clean() {
if [ -d "${val/#\~/$HOME}" ]
then
- wd_tmp=$wd_tmp"\n"`echo $line`
+ wd_tmp=$wd_tmp"\n"`echo "$line"`
else
- wd_print_msg $WD_YELLOW "Nonexistent directory: ${key} -> ${val}"
+ wd_print_msg "$WD_YELLOW" "Nonexistent directory: ${key} -> ${val}"
count=$((count+1))
fi
fi
- done < $WD_CONFIG
+ done < "$WD_CONFIG"
if [[ $count -eq 0 ]]
then
- wd_print_msg $WD_BLUE "No warp points to clean, carry on!"
+ wd_print_msg "$WD_BLUE" "No warp points to clean, carry on!"
else
- if $force || wd_yesorno "Removing ${count} warp points. Continue? (Y/n)"
+ if [ ! -z "$force" ] || wd_yesorno "Removing ${count} warp points. Continue? (y/n)"
then
- echo $wd_tmp >! $WD_CONFIG
- wd_print_msg $WD_GREEN "Cleanup complete. ${count} warp point(s) removed"
+ echo "$wd_tmp" >! "$WD_CONFIG"
+ wd_print_msg "$WD_GREEN" "Cleanup complete. ${count} warp point(s) removed"
else
- wd_print_msg $WD_BLUE "Cleanup aborted"
+ wd_print_msg "$WD_BLUE" "Cleanup aborted"
fi
fi
}
wd_export_static_named_directories() {
- if [[ -z $WD_SKIP_EXPORT ]]
+ if [[ ! -z $WD_EXPORT ]]
then
- command grep '^[0-9a-zA-Z_-]\+:' "$WD_CONFIG" | sed -e "s,~,$HOME," -e 's/:/=/' | while read warpdir ; do
+ command grep '^[0-9a-zA-Z_-]\+:' "$WD_CONFIG" | sed -e "s,~,$HOME," -e 's/:/=/' | while read -r warpdir ; do
hash -d "$warpdir"
done
fi
@@ -366,7 +367,8 @@ zparseopts -D -E \
c:=wd_alt_config -config:=wd_alt_config \
q=wd_quiet_mode -quiet=wd_quiet_mode \
v=wd_print_version -version=wd_print_version \
- d=wd_debug_mode -debug=wd_debug_mode
+ d=wd_debug_mode -debug=wd_debug_mode \
+ f=wd_force_mode -force=wd_force_mode
if [[ ! -z $wd_print_version ]]
then
@@ -379,10 +381,10 @@ then
fi
# check if config file exists
-if [ ! -e $WD_CONFIG ]
+if [ ! -e "$WD_CONFIG" ]
then
# if not, create config file
- touch $WD_CONFIG
+ touch "$WD_CONFIG"
else
wd_export_static_named_directories
fi
@@ -397,25 +399,24 @@ do
val=${(j,:,)arr[2,-1]}
points[$key]=$val
-done < $WD_CONFIG
+done < "$WD_CONFIG"
# get opts
-args=$(getopt -o a:r:c:lhs -l add:,rm:,clean\!,list,ls:,path:,help,show -- $*)
+args=$(getopt -o a:r:c:lhs -l add:,rm:,clean,list,ls:,path:,help,show -- $*)
# check if no arguments were given, and that version is not set
if [[ ($? -ne 0 || $#* -eq 0) && -z $wd_print_version ]]
then
wd_print_usage
- # check if config file is writeable
-elif [ ! -w $WD_CONFIG ]
+# check if config file is writeable
+elif [ ! -w "$WD_CONFIG" ]
then
# do nothing
# can't run `exit`, as this would exit the executing shell
wd_exit_fail "\'$WD_CONFIG\' is not writeable."
else
-
# parse rest of options
local wd_o
for wd_o
@@ -423,11 +424,7 @@ else
case "$wd_o"
in
"-a"|"--add"|"add")
- wd_add false $2
- break
- ;;
- "-a!"|"--add!"|"add!")
- wd_add true $2
+ wd_add "$2" "$wd_force_mode"
break
;;
"-e"|"export")
@@ -435,10 +432,8 @@ else
break
;;
"-r"|"--remove"|"rm")
- # Loop over all arguments after "rm", separated by whitespace
- for pointname in "${@:2}" ; do
- wd_remove $pointname
- done
+ # Passes all the arguments as a single string separated by whitespace to wd_remove
+ wd_remove "${@:2}"
break
;;
"-l"|"list")
@@ -446,11 +441,11 @@ else
break
;;
"-ls"|"ls")
- wd_ls $2
+ wd_ls "$2"
break
;;
"-p"|"--path"|"path")
- wd_path $2
+ wd_path "$2"
break
;;
"-h"|"--help"|"help")
@@ -458,19 +453,15 @@ else
break
;;
"-s"|"--show"|"show")
- wd_show $2
+ wd_show "$2"
break
;;
"-c"|"--clean"|"clean")
- wd_clean false
- break
- ;;
- "-c!"|"--clean!"|"clean!")
- wd_clean true
+ wd_clean "$wd_force_mode"
break
;;
*)
- wd_warp $wd_o $2
+ wd_warp "$wd_o" "$2"
break
;;
--)
@@ -502,7 +493,7 @@ unset args
unset points
unset val &> /dev/null # fixes issue #1
-if [[ ! -z $wd_debug_mode ]]
+if [[ -n $wd_debug_mode ]]
then
exit $WD_EXIT_CODE
else
diff --git a/plugins/wp-cli/README.md b/plugins/wp-cli/README.md
index 43c41eb53..c4993ab4c 100644
--- a/plugins/wp-cli/README.md
+++ b/plugins/wp-cli/README.md
@@ -1,107 +1,109 @@
# WP-CLI
-**Maintainer:** [joshmedeski](https://github.com/joshmedeski)
-
-WordPress Command Line Interface (https://wp-cli.org/)
-
-WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser.
-
-This plugin adds [tab completion](https://wp-cli.org/#tab-completions) for `wp-cli` as well as several aliases.
-
-## List of Aliases
-
-### Core
-- wpcc='wp core config'
-- wpcd='wp core download'
-- wpci='wp core install'
-- wpcii='wp core is-installed'
-- wpcmc='wp core multisite-convert'
-- wpcmi='wp core multisite-install'
-- wpcu='wp core update'
-- wpcudb='wp core update-db'
-- wpcvc='wp core verify-checksums'
-
-### Cron
-- wpcre='wp cron event'
-- wpcrs='wp cron schedule'
-- wpcrt='wp cron test'
+The [WordPress CLI](https://wp-cli.org/) is a command-line tool for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser.
-### Menu
-- wpmc='wp menu create'
-- wpmd='wp menu delete'
-- wpmi='wp menu item'
-- wpml='wp menu list'
-- wpmlo='wp menu location'
+This plugin adds [tab completion](https://wp-cli.org/#tab-completions) for `wp-cli` as well as several aliases for commonly used commands.
-### Plugin
-- wppa='activate'
-- wppda='deactivate'
-- wppd='delete'
-- wppg='get'
-- wppi='install'
-- wppis='is-installed'
-- wppl='list'
-- wppp='path'
-- wpps='search'
-- wppst='status'
-- wppt='toggle'
-- wppun='uninstall'
-- wppu='update'
+To use it, add `wp-cli` to the plugins array in your zshrc file:
-### Post
-- wppoc='wp post create'
-- wppod='wp post delete'
-- wppoe='wp post edit'
-- wppogen='wp post generate'
-- wppog='wp post get'
-- wppol='wp post list'
-- wppom='wp post meta'
-- wppou='wp post update'
-- wppourl='wp post url'
+```zsh
+plugins=(... wp-cli)
+```
-### Sidebar
-- wpsbl='wp sidebar list'
-
-### Theme
-- wpta='wp theme activate'
-- wptd='wp theme delete'
-- wptdis='wp theme disable'
-- wpte='wp theme enable'
-- wptg='wp theme get'
-- wpti='wp theme install'
-- wptis='wp theme is-installed'
-- wptl='wp theme list'
-- wptm='wp theme mod'
-- wptp='wp theme path'
-- wpts='wp theme search'
-- wptst='wp theme status'
-- wptu='wp theme update'
-
-### User
-- wpuac='wp user add-cap'
-- wpuar='wp user add-role'
-- wpuc='wp user create'
-- wpud='wp user delete'
-- wpugen='wp user generate'
-- wpug='wp user get'
-- wpui='wp user import-csv'
-- wpul='wp user list'
-- wpulc='wp user list-caps'
-- wpum='wp user meta'
-- wpurc='wp user remove-cap'
-- wpurr='wp user remove-role'
-- wpusr='wp user set-role'
-- wpuu='wp user update'
-
-### Widget
-- wpwa='wp widget add'
-- wpwda='wp widget deactivate'
-- wpwd='wp widget delete'
-- wpwl='wp widget list'
-- wpwm='wp widget move'
-- wpwu='wp widget update'
-
-The entire list of wp-cli commands can be found here: https://wp-cli.org/commands/
-
-I only included the commands that are most used. Please feel free to contribute to this project if you want more commands.
+**Maintainer:** [joshmedeski](https://github.com/joshmedeski)
+## Aliases
+
+The entire list of `wp-cli` commands can be found here: https://developer.wordpress.org/cli/commands/
+
+| Alias | Command |
+|-----------|-----------------------------|
+| **Core** |
+| `wpcc` | `wp core config` |
+| `wpcd` | `wp core download` |
+| `wpci` | `wp core install` |
+| `wpcii` | `wp core is-installed` |
+| `wpcmc` | `wp core multisite-convert` |
+| `wpcmi` | `wp core multisite-install` |
+| `wpcu` | `wp core update` |
+| `wpcudb` | `wp core update-db` |
+| `wpcvc` | `wp core verify-checksums` |
+| **Cron** |
+| `wpcre` | `wp cron event` |
+| `wpcrs` | `wp cron schedule` |
+| `wpcrt` | `wp cron test` |
+| **Database** |
+| `wpdbe` | `wp db export` |
+| `wpdbi` | `wp db import` |
+| `wpdbcr` | `wp db create` |
+| `wpdbs` | `wp db search` |
+| `wpdbch` | `wp db check` |
+| `wpdbr` | `wp db repair` |
+| **Menu** |
+| `wpmc` | `wp menu create` |
+| `wpmd` | `wp menu delete` |
+| `wpmi` | `wp menu item` |
+| `wpml` | `wp menu list` |
+| `wpmlo` | `wp menu location` |
+| **Plugin** |
+| `wppa` | `wp plugin activate` |
+| `wppda` | `wp plugin deactivate` |
+| `wppd` | `wp plugin delete` |
+| `wppg` | `wp plugin get` |
+| `wppi` | `wp plugin install` |
+| `wppis` | `wp plugin is-installed` |
+| `wppl` | `wp plugin list` |
+| `wppp` | `wp plugin path` |
+| `wpps` | `wp plugin search` |
+| `wppst` | `wp plugin status` |
+| `wppt` | `wp plugin toggle` |
+| `wppun` | `wp plugin uninstall` |
+| `wppu` | `wp plugin update` |
+| **Post** |
+| `wppoc` | `wp post create` |
+| `wppod` | `wp post delete` |
+| `wppoe` | `wp post edit` |
+| `wppogen` | `wp post generate` |
+| `wppog` | `wp post get` |
+| `wppol` | `wp post list` |
+| `wppom` | `wp post meta` |
+| `wppou` | `wp post update` |
+| `wppourl` | `wp post url` |
+| **Sidebar** |
+| `wpsbl` | `wp sidebar list` |
+| **Theme** |
+| `wpta` | `wp theme activate` |
+| `wptd` | `wp theme delete` |
+| `wptdis` | `wp theme disable` |
+| `wpte` | `wp theme enable` |
+| `wptg` | `wp theme get` |
+| `wpti` | `wp theme install` |
+| `wptis` | `wp theme is-installed` |
+| `wptl` | `wp theme list` |
+| `wptm` | `wp theme mod` |
+| `wptp` | `wp theme path` |
+| `wpts` | `wp theme search` |
+| `wptst` | `wp theme status` |
+| `wptu` | `wp theme update` |
+| **User** |
+| `wpuac` | `wp user add-cap` |
+| `wpuar` | `wp user add-role` |
+| `wpuc` | `wp user create` |
+| `wpud` | `wp user delete` |
+| `wpugen` | `wp user generate` |
+| `wpug` | `wp user get` |
+| `wpui` | `wp user import-csv` |
+| `wpul` | `wp user list` |
+| `wpulc` | `wp user list-caps` |
+| `wpum` | `wp user meta` |
+| `wpurc` | `wp user remove-cap` |
+| `wpurr` | `wp user remove-role` |
+| `wpusr` | `wp user set-role` |
+| `wpuu` | `wp user update` |
+| **Widget** |
+| `wpwa` | `wp widget add` |
+| `wpwda` | `wp widget deactivate` |
+| `wpwd` | `wp widget delete` |
+| `wpwl` | `wp widget list` |
+| `wpwm` | `wp widget move` |
+| `wpwu` | `wp widget update` |
diff --git a/plugins/wp-cli/wp-cli.plugin.zsh b/plugins/wp-cli/wp-cli.plugin.zsh
index 97bed406e..09bdf3260 100644
--- a/plugins/wp-cli/wp-cli.plugin.zsh
+++ b/plugins/wp-cli/wp-cli.plugin.zsh
@@ -2,14 +2,6 @@
# A command line interface for WordPress
# https://wp-cli.org/
-# Cache
-
-# Cap
-
-# CLI
-
-# Comment
-
# Core
alias wpcc='wp core config'
alias wpcd='wp core download'
@@ -27,18 +19,12 @@ alias wpcrs='wp cron schedule'
alias wpcrt='wp cron test'
# Db
-
-# Eval
-
-# Eval-File
-
-# Export
-
-# Help
-
-# Import
-
-# Media
+alias wpdbe='wp db export'
+alias wpdbi='wp db import'
+alias wpdbcr='wp db create'
+alias wpdbs='wp db search'
+alias wpdbch='wp db check'
+alias wpdbr='wp db repair'
# Menu
alias wpmc='wp menu create'
@@ -47,10 +33,6 @@ alias wpmi='wp menu item'
alias wpml='wp menu list'
alias wpmlo='wp menu location'
-# Network
-
-# Option
-
# Plugin
alias wppa='wp plugin activate'
alias wppda='wp plugin deactivate'
@@ -77,25 +59,9 @@ alias wppom='wp post meta'
alias wppou='wp post update'
alias wppourl='wp post url'
-# Rewrite
-
-# Role
-
-# Scaffold
-
-# Search-Replace
-
-# Shell
-
# Sidebar
alias wpsbl='wp sidebar list'
-# Site
-
-# Super-Admin
-
-# Term
-
# Theme
alias wpta='wp theme activate'
alias wptd='wp theme delete'
@@ -111,8 +77,6 @@ alias wpts='wp theme search'
alias wptst='wp theme status'
alias wptu='wp theme update'
-# Transient
-
# User
alias wpuac='wp user add-cap'
alias wpuar='wp user add-role'
@@ -138,9 +102,8 @@ alias wpwm='wp widget move'
alias wpwu='wp widget update'
+# Completion for wp
autoload -U +X bashcompinit && bashcompinit
-# bash completion for the `wp` command
-
_wp_complete() {
local cur=${COMP_WORDS[COMP_CWORD]}
diff --git a/plugins/z/README b/plugins/z/README
index 56261cff4..47e54c57a 100644
--- a/plugins/z/README
+++ b/plugins/z/README
@@ -23,6 +23,8 @@ DESCRIPTION
OPTIONS
-c restrict matches to subdirectories of the current directory
+ -e echo the best match, don't cd
+
-h show a brief help message
-l list only
@@ -57,6 +59,8 @@ NOTES
Optionally:
Set $_Z_CMD to change the command name (default z).
Set $_Z_DATA to change the datafile (default $HOME/.z).
+ Set $_Z_MAX_SCORE lower to age entries out faster (default
+ 9000).
Set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
Set $_Z_NO_PROMPT_COMMAND to handle PROMPT_COMMAND/precmd your-
self.
@@ -64,8 +68,8 @@ NOTES
Set $_Z_OWNER to allow usage when in 'sudo -s' mode.
(These settings should go in .bashrc/.zshrc before the line
added above.)
- Install the provided man page z.1 somewhere like
- /usr/local/man/man1.
+ Install the provided man page z.1 somewhere in your MANPATH,
+ like /usr/local/man/man1.
Aging:
The rank of directories maintained by z undergoes aging based on a sim-
diff --git a/plugins/z/z.1 b/plugins/z/z.1
index d4cac1ac2..182f98176 100644
--- a/plugins/z/z.1
+++ b/plugins/z/z.1
@@ -78,6 +78,9 @@ Set \fB$_Z_CMD\fR to change the command name (default \fBz\fR).
Set \fB$_Z_DATA\fR to change the datafile (default \fB$HOME/.z\fR).
.RE
.RS
+Set \fB$_Z_MAX_SCORE\fR lower to age entries out faster (default \fB9000\fR).
+.RE
+.RS
Set \fB$_Z_NO_RESOLVE_SYMLINKS\fR to prevent symlink resolution.
.RE
.RS
diff --git a/plugins/z/z.sh b/plugins/z/z.sh
index 5c5771d62..13008a60e 100644
--- a/plugins/z/z.sh
+++ b/plugins/z/z.sh
@@ -10,6 +10,7 @@
# * optionally:
# set $_Z_CMD in .bashrc/.zshrc to change the command (default z).
# set $_Z_DATA in .bashrc/.zshrc to change the datafile (default ~/.z).
+# set $_Z_MAX_SCORE lower to age entries out faster (default 9000).
# set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
# set $_Z_NO_PROMPT_COMMAND if you're handling PROMPT_COMMAND yourself.
# set $_Z_EXCLUDE_DIRS to an array of directories to exclude.
@@ -23,6 +24,8 @@
# * z -l foo # list matches instead of cd
# * z -e foo # echo the best match, don't cd
# * z -c foo # restrict matches to subdirs of $PWD
+# * z -x # remove the current directory from the datafile
+# * z -h # show a brief help message
[ -d "${_Z_DATA:-$HOME/.z}" ] && {
echo "ERROR: z.sh's datafile (${_Z_DATA:-$HOME/.z}) is a directory."
@@ -62,7 +65,8 @@ _z() {
# maintain the data file
local tempfile="$datafile.$RANDOM"
- _z_dirs | awk -v path="$*" -v now="$(date +%s)" -F"|" '
+ local score=${_Z_MAX_SCORE:-9000}
+ _z_dirs | awk -v path="$*" -v now="$(date +%s)" -v score=$score -F"|" '
BEGIN {
rank[path] = 1
time[path] = now
@@ -79,7 +83,7 @@ _z() {
count += $2
}
END {
- if( count > 9000 ) {
+ if( count > score ) {
# aging
for( x in rank ) print x "|" 0.99*rank[x] "|" time[x]
} else for( x in rank ) print x "|" rank[x] "|" time[x]
@@ -138,27 +142,24 @@ _z() {
local cd
cd="$( < <( _z_dirs ) awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
function frecent(rank, time) {
- # relate frequency and time
- dx = t - time
- if( dx < 3600 ) return rank * 4
- if( dx < 86400 ) return rank * 2
- if( dx < 604800 ) return rank / 2
- return rank / 4
+ # relate frequency and time
+ dx = t - time
+ return int(10000 * rank * (3.75/((0.0001 * dx + 1) + 0.25)))
}
function output(matches, best_match, common) {
# list or return the desired directory
if( list ) {
- cmd = "sort -g >&2"
+ if( common ) {
+ printf "%-10s %s\n", "common:", common > "/dev/stderr"
+ }
+ cmd = "sort -n >&2"
for( x in matches ) {
if( matches[x] ) {
printf "%-10s %s\n", matches[x], x | cmd
}
}
- if( common ) {
- printf "%-10s %s\n", "common:", common > "/dev/stderr"
- }
} else {
- if( common ) best_match = common
+ if( common && !typ ) best_match = common
print best_match
}
}
@@ -200,15 +201,22 @@ _z() {
# prefer case sensitive
if( best_match ) {
output(matches, best_match, common(matches))
+ exit
} else if( ibest_match ) {
output(imatches, ibest_match, common(imatches))
+ exit
}
+ exit(1)
}
')"
- [ $? -eq 0 ] && [ "$cd" ] && {
- if [ "$echo" ]; then echo "$cd"; else builtin cd "$cd"; fi
- }
+ if [ "$?" -eq 0 ]; then
+ if [ "$cd" ]; then
+ if [ "$echo" ]; then echo "$cd"; else builtin cd "$cd"; fi
+ fi
+ else
+ return $?
+ fi
fi
}
@@ -223,15 +231,11 @@ if type compctl >/dev/null 2>&1; then
if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then
_z_precmd() {
(_z --add "${PWD:a}" &)
- # Reference $RANDOM to refresh its value inside the subshell
- # Otherwise, multiple runs get the same value
: $RANDOM
}
else
_z_precmd() {
(_z --add "${PWD:A}" &)
- # Reference $RANDOM to refresh its value inside the subshell
- # Otherwise, multiple runs get the same value
: $RANDOM
}
fi
diff --git a/plugins/zsh_reload/zsh_reload.plugin.zsh b/plugins/zsh_reload/zsh_reload.plugin.zsh
index 83f8da733..0d29a7ce3 100644
--- a/plugins/zsh_reload/zsh_reload.plugin.zsh
+++ b/plugins/zsh_reload/zsh_reload.plugin.zsh
@@ -7,6 +7,16 @@ src() {
zrecompile -p $f && command rm -f $f.zwc.old
done
- # Use $SHELL if available; remove leading dash if login shell
- [[ -n "$SHELL" ]] && exec ${SHELL#-} || exec zsh
+ # Use $SHELL if it's available and a zsh shell
+ local shell="$ZSH_ARGZERO"
+ if [[ "${${SHELL:t}#-}" = zsh ]]; then
+ shell="$SHELL"
+ fi
+
+ # Remove leading dash if login shell and run accordingly
+ if [[ "${shell:0:1}" = "-" ]]; then
+ exec -l "${shell#-}"
+ else
+ exec "$shell"
+ fi
}