Zsh update
This commit is contained in:
parent
1335bbb251
commit
a37bb1d85b
@ -24,9 +24,9 @@ set softtabstop=2
|
|||||||
" Преобразовать табуляцию в пробелы
|
" Преобразовать табуляцию в пробелы
|
||||||
set expandtab
|
set expandtab
|
||||||
" Копирует отступ от предыдущей строки
|
" Копирует отступ от предыдущей строки
|
||||||
set autoindent
|
set noautoindent
|
||||||
" Включаем 'умную' автоматическую расстановку отступов
|
" Включаем 'умную' автоматическую расстановку отступов
|
||||||
set smartindent
|
set nosmartindent
|
||||||
" Включаем подсветку синтаксиса
|
" Включаем подсветку синтаксиса
|
||||||
syntax on
|
syntax on
|
||||||
|
|
||||||
|
@ -132,23 +132,26 @@ EOF
|
|||||||
|
|
||||||
function _omz::plugin::list {
|
function _omz::plugin::list {
|
||||||
local -a custom_plugins builtin_plugins
|
local -a custom_plugins builtin_plugins
|
||||||
custom_plugins=("$ZSH_CUSTOM"/plugins/*(/N:t))
|
custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
|
||||||
builtin_plugins=("$ZSH"/plugins/*(/N:t))
|
builtin_plugins=("$ZSH"/plugins/*(-/N:t))
|
||||||
|
|
||||||
{
|
# If the command is being piped, print all found line by line
|
||||||
(( ${#custom_plugins} )) && {
|
if [[ ! -t 1 ]]; then
|
||||||
print -Pn "%U%BCustom plugins%b%u: "
|
print -l ${(q-)custom_plugins} ${(q-)builtin_plugins}
|
||||||
print -l ${(q-)custom_plugins}
|
return
|
||||||
}
|
fi
|
||||||
|
|
||||||
(( ${#builtin_plugins} )) && {
|
if (( ${#custom_plugins} )); then
|
||||||
# add a line of separation
|
print -P "%U%BCustom plugins%b%u:"
|
||||||
(( ${#custom_plugins} )) && echo
|
print -l ${(q-)custom_plugins} | column
|
||||||
|
fi
|
||||||
|
|
||||||
print -Pn "%U%BBuilt-in plugins%b%u: "
|
if (( ${#builtin_plugins} )); then
|
||||||
print -l ${(q-)builtin_plugins}
|
(( ${#custom_plugins} )) && echo # add a line of separation
|
||||||
}
|
|
||||||
} | fmt -w $COLUMNS | sed -E $'s/\e?(\\[[0-9]*m)/\e\\1/g' # deal with fmt removing ESC
|
print -P "%U%BBuilt-in plugins%b%u:"
|
||||||
|
print -l ${(q-)builtin_plugins} | column
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function _omz::pr {
|
function _omz::pr {
|
||||||
@ -308,20 +311,23 @@ function _omz::theme::list {
|
|||||||
custom_themes=("$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
|
custom_themes=("$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
|
||||||
builtin_themes=("$ZSH"/themes/*.zsh-theme(.N:t:r))
|
builtin_themes=("$ZSH"/themes/*.zsh-theme(.N:t:r))
|
||||||
|
|
||||||
{
|
# If the command is being piped, print all found line by line
|
||||||
(( ${#custom_themes} )) && {
|
if [[ ! -t 1 ]]; then
|
||||||
print -Pn "%U%BCustom themes%b%u: "
|
print -l ${(q-)custom_themes} ${(q-)builtin_themes}
|
||||||
print -l ${(q-)custom_themes}
|
return
|
||||||
}
|
fi
|
||||||
|
|
||||||
(( ${#builtin_themes} )) && {
|
if (( ${#custom_themes} )); then
|
||||||
# add a line of separation
|
print -P "%U%BCustom themes%b%u:"
|
||||||
(( ${#custom_themes} )) && echo
|
print -l ${(q-)custom_themes} | column
|
||||||
|
fi
|
||||||
|
|
||||||
print -Pn "%U%BBuilt-in themes%b%u: "
|
if (( ${#builtin_themes} )); then
|
||||||
print -l ${(q-)builtin_themes}
|
(( ${#custom_themes} )) && echo # add a line of separation
|
||||||
}
|
|
||||||
} | fmt -w $COLUMNS | sed -E $'s/\e?(\\[[0-9]*m)/\e\\1/g' # deal with fmt removing ESC
|
print -P "%U%BBuilt-in themes%b%u:"
|
||||||
|
print -l ${(q-)builtin_themes} | column
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function _omz::theme::use {
|
function _omz::theme::use {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# fixme - the load process here seems a bit bizarre
|
# fixme - the load process here seems a bit bizarre
|
||||||
zmodload -i zsh/complist
|
zmodload -i zsh/complist
|
||||||
|
|
||||||
WORDCHARS='_-'
|
WORDCHARS=''
|
||||||
|
|
||||||
unsetopt menu_complete # do not autoselect the first completion entry
|
unsetopt menu_complete # do not autoselect the first completion entry
|
||||||
unsetopt flowcontrol
|
unsetopt flowcontrol
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
This plugin provides completion support for [awscli](https://docs.aws.amazon.com/cli/latest/reference/index.html)
|
This plugin provides completion support for [awscli](https://docs.aws.amazon.com/cli/latest/reference/index.html)
|
||||||
and a few utilities to manage AWS profiles and display them in the prompt.
|
and a few utilities to manage AWS profiles and display them in the prompt.
|
||||||
|
|
||||||
To use it, add `aws` to the plugins array in your zshrc file.
|
To use it, make sure [jq](https://stedolan.github.io/jq/download/) is installed, and add `aws` to the plugins array in your zshrc file.
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
plugins=(... aws)
|
plugins=(... aws)
|
||||||
|
@ -5,7 +5,7 @@ function agp() {
|
|||||||
# AWS profile selection
|
# AWS profile selection
|
||||||
function asp() {
|
function asp() {
|
||||||
if [[ -z "$1" ]]; then
|
if [[ -z "$1" ]]; then
|
||||||
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE
|
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
|
||||||
echo AWS profile cleared.
|
echo AWS profile cleared.
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -18,9 +18,61 @@ function asp() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export AWS_DEFAULT_PROFILE=$1
|
local exists="$(aws configure get aws_access_key_id --profile $1)"
|
||||||
export AWS_PROFILE=$1
|
local role_arn="$(aws configure get role_arn --profile $1)"
|
||||||
export AWS_EB_PROFILE=$1
|
local aws_access_key_id=""
|
||||||
|
local aws_secret_access_key=""
|
||||||
|
local aws_session_token=""
|
||||||
|
if [[ -n $exists || -n $role_arn ]]; then
|
||||||
|
if [[ -n $role_arn ]]; then
|
||||||
|
local mfa_serial="$(aws configure get mfa_serial --profile $1)"
|
||||||
|
local mfa_token=""
|
||||||
|
local mfa_opt=""
|
||||||
|
if [[ -n $mfa_serial ]]; then
|
||||||
|
echo "Please enter your MFA token for $mfa_serial:"
|
||||||
|
read mfa_token
|
||||||
|
echo "Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role):"
|
||||||
|
read sess_duration
|
||||||
|
if [[ -z $sess_duration ]]; then
|
||||||
|
sess_duration = 3600
|
||||||
|
fi
|
||||||
|
mfa_opt="--serial-number $mfa_serial --token-code $mfa_token --duration-seconds $sess_duration"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local ext_id="$(aws configure get external_id --profile $1)"
|
||||||
|
local extid_opt=""
|
||||||
|
if [[ -n $ext_id ]]; then
|
||||||
|
extid_opt="--external-id $ext_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local profile=$1
|
||||||
|
local source_profile="$(aws configure get source_profile --profile $1)"
|
||||||
|
if [[ -n $source_profile ]]; then
|
||||||
|
profile=$source_profile
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Assuming role $role_arn using profile $profile"
|
||||||
|
local assume_cmd=(aws sts assume-role "--profile=$profile" "--role-arn $role_arn" "--role-session-name "$profile"" "$mfa_opt" "$extid_opt")
|
||||||
|
local JSON="$(eval ${assume_cmd[@]})"
|
||||||
|
|
||||||
|
aws_access_key_id="$(echo $JSON | jq -r '.Credentials.AccessKeyId')"
|
||||||
|
aws_secret_access_key="$(echo $JSON | jq -r '.Credentials.SecretAccessKey')"
|
||||||
|
aws_session_token="$(echo $JSON | jq -r '.Credentials.SessionToken')"
|
||||||
|
else
|
||||||
|
aws_access_key_id="$(aws configure get aws_access_key_id --profile $1)"
|
||||||
|
aws_secret_access_key="$(aws configure get aws_secret_access_key --profile $1)"
|
||||||
|
aws_session_token=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
export AWS_DEFAULT_PROFILE=$1
|
||||||
|
export AWS_PROFILE=$1
|
||||||
|
export AWS_EB_PROFILE=$1
|
||||||
|
export AWS_ACCESS_KEY_ID=$aws_access_key_id
|
||||||
|
export AWS_SECRET_ACCESS_KEY=$aws_secret_access_key
|
||||||
|
[[ -z "$aws_session_token" ]] && unset AWS_SESSION_TOKEN || export AWS_SESSION_TOKEN=$aws_session_token
|
||||||
|
|
||||||
|
echo "Switched to AWS Profile: $1";
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function aws_change_access_key() {
|
function aws_change_access_key() {
|
||||||
@ -41,7 +93,7 @@ function aws_change_access_key() {
|
|||||||
|
|
||||||
function aws_profiles() {
|
function aws_profiles() {
|
||||||
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
|
[[ -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() {
|
function _aws_profiles() {
|
||||||
|
@ -12,8 +12,8 @@ _cargo() {
|
|||||||
'(-q --quiet)*'{-v,--verbose}'[use verbose output]'
|
'(-q --quiet)*'{-v,--verbose}'[use verbose output]'
|
||||||
'(-q --quiet -v --verbose)'{-q,--quiet}'[no output printed to stdout]'
|
'(-q --quiet -v --verbose)'{-q,--quiet}'[no output printed to stdout]'
|
||||||
'-Z+[pass unstable (nightly-only) flags to cargo]: :_cargo_unstable_flags'
|
'-Z+[pass unstable (nightly-only) flags to cargo]: :_cargo_unstable_flags'
|
||||||
'--frozen[require that Cargo.lock and cache are up-to-date]'
|
'--frozen[require that Cargo.lock and cache are up to date]'
|
||||||
'--locked[require that Cargo.lock is up-to-date]'
|
'--locked[require that Cargo.lock is up to date]'
|
||||||
'--color=[specify colorization option]:coloring:(auto always never)'
|
'--color=[specify colorization option]:coloring:(auto always never)'
|
||||||
'(- 1 *)'{-h,--help}'[show help message]'
|
'(- 1 *)'{-h,--help}'[show help message]'
|
||||||
)
|
)
|
||||||
|
@ -1,33 +1,52 @@
|
|||||||
# fzf
|
# 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:
|
To use it, add `fzf` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
plugins=(... fzf)
|
plugins=(... fzf)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
|
|
||||||
Add these before the `plugins=()` line in your zshrc file:
|
All these settings should go in your zshrc file, before Oh My Zsh is sourced.
|
||||||
|
|
||||||
|
### `FZF_BASE`
|
||||||
|
|
||||||
|
Set to fzf installation directory path:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
# Set fzf installation directory path
|
export FZF_BASE=/path/to/fzf/install/dir
|
||||||
# export FZF_BASE=/path/to/fzf/install/dir
|
|
||||||
|
|
||||||
# Uncomment to set the FZF_DEFAULT_COMMAND
|
|
||||||
# export FZF_DEFAULT_COMMAND='<your fzf default commmand>'
|
|
||||||
|
|
||||||
# Uncomment the following line to disable fuzzy completion
|
|
||||||
# DISABLE_FZF_AUTO_COMPLETION="true"
|
|
||||||
|
|
||||||
# Uncomment the following line to disable key bindings (CTRL-T, CTRL-R, ALT-C)
|
|
||||||
# DISABLE_FZF_KEY_BINDINGS="true"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
| Setting | Example value | Description |
|
### `FZF_DEFAULT_COMMAND`
|
||||||
|-----------------------------|----------------------------|-------------------------------------------------------------|
|
|
||||||
| FZF_BASE | `/path/to/fzf/install/dir` | Set fzf installation directory path (**export**) |
|
Set default command to use when input is tty:
|
||||||
| FZF_DEFAULT_COMMAND | `fd --type f` | Set default command to use when input is tty (**export**) |
|
|
||||||
| DISABLE_FZF_AUTO_COMPLETION | `true` | Set whether to load fzf auto-completion |
|
```zsh
|
||||||
| DISABLE_FZF_KEY_BINDINGS | `true` | Set whether to disable key bindings (CTRL-T, CTRL-R, ALT-C) |
|
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:
|
||||||
|
|
||||||
|
- [`rg`](https://github.com/BurntSushi/ripgrep)
|
||||||
|
- [`fd`](https://github.com/sharkdp/fd)
|
||||||
|
- [`ag`](https://github.com/ggreer/the_silver_searcher)
|
||||||
|
|
||||||
|
### `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"
|
||||||
|
```
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
function setup_using_base_dir() {
|
function setup_using_base_dir() {
|
||||||
# Declare all variables local not no mess with outside env in any way
|
local fzf_base fzf_shell fzfdirs dir
|
||||||
local fzf_base
|
|
||||||
local fzf_shell
|
|
||||||
local fzfdirs
|
|
||||||
local dir
|
|
||||||
|
|
||||||
test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
|
test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
|
||||||
|
|
||||||
@ -31,38 +27,37 @@ function setup_using_base_dir() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d "${fzf_base}" ]]; then
|
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
|
|
||||||
|
|
||||||
# Setup fzf binary path
|
|
||||||
if ! (( ${+commands[fzf]} )) && [[ ! "$PATH" == *$fzf_base/bin* ]]; then
|
|
||||||
export PATH="$PATH:$fzf_base/bin"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Auto-completion
|
|
||||||
if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
|
|
||||||
[[ $- == *i* ]] && 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
|
|
||||||
else
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
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
|
||||||
|
|
||||||
|
# Setup fzf binary path
|
||||||
|
if (( ! ${+commands[fzf]} )) && [[ "$PATH" != *$fzf_base/bin* ]]; then
|
||||||
|
export PATH="$PATH:$fzf_base/bin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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() {
|
function setup_using_debian_package() {
|
||||||
(( $+commands[dpkg] )) && dpkg -s fzf &> /dev/null
|
if (( ! $+commands[dpkg] )) || ! dpkg -s fzf &>/dev/null; then
|
||||||
if (( $? )); then
|
# Either not a debian based distro, or no fzf installed
|
||||||
# Either not a debian based distro, or no fzf installed. In any case skip ahead
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -76,8 +71,8 @@ function setup_using_debian_package() {
|
|||||||
local key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh"
|
local key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh"
|
||||||
|
|
||||||
# Auto-completion
|
# Auto-completion
|
||||||
if [[ $- == *i* ]] && [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
|
if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
|
||||||
source $completions 2> /dev/null
|
source $completions 2> /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Key bindings
|
# Key bindings
|
||||||
@ -88,16 +83,74 @@ function setup_using_debian_package() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function indicate_error() {
|
function setup_using_opensuse_package() {
|
||||||
print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\
|
# OpenSUSE installs fzf in /usr/bin/fzf
|
||||||
"Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2
|
# 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
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check for debian package first, because it easy to short cut
|
function setup_using_openbsd_package() {
|
||||||
# Indicate to user that fzf installation not found if nothing worked
|
# openBSD installs fzf in /usr/local/bin/fzf
|
||||||
setup_using_debian_package || setup_using_base_dir || indicate_error
|
if [[ "$OSTYPE" != openbsd* ]] || (( ! $+commands[fzf] )); then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
unset -f setup_using_debian_package setup_using_base_dir indicate_error
|
# 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() {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
# Indicate to user that fzf installation not found if nothing worked
|
||||||
|
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 [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
|
||||||
if (( $+commands[rg] )); then
|
if (( $+commands[rg] )); then
|
||||||
|
@ -2,25 +2,24 @@
|
|||||||
|
|
||||||
# zsh completion wrapper for git
|
# 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
|
# The recommended way to install this script is to make a copy of it as a
|
||||||
# would be the location bash-completion uses.
|
# 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
|
|
||||||
#
|
|
||||||
# The recommended way to install this script is to copy to '~/.zsh/_git', and
|
|
||||||
# then add the following to your ~/.zshrc file:
|
|
||||||
#
|
#
|
||||||
# fpath=(~/.zsh $fpath)
|
# fpath=(~/.zsh $fpath)
|
||||||
|
#
|
||||||
complete ()
|
# 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).
|
||||||
# do nothing
|
#
|
||||||
return 0
|
# If your bash completion script is somewhere else, you can specify the
|
||||||
}
|
# location in your ~/.zshrc:
|
||||||
|
#
|
||||||
|
# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
|
||||||
|
#
|
||||||
|
|
||||||
zstyle -T ':completion:*:*:git:*' tag-order && \
|
zstyle -T ':completion:*:*:git:*' tag-order && \
|
||||||
zstyle ':completion:*:*:git:*' tag-order 'common-commands'
|
zstyle ':completion:*:*:git:*' tag-order 'common-commands'
|
||||||
@ -30,16 +29,17 @@ if [ -z "$script" ]; then
|
|||||||
local -a locations
|
local -a locations
|
||||||
local e
|
local e
|
||||||
locations=(
|
locations=(
|
||||||
"$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash"
|
"$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
|
||||||
'/etc/bash_completion.d/git' # fedora, old debian
|
"$HOME/.local/share/bash-completion/completions/git"
|
||||||
'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
|
"$(pkg-config --variable=completionsdir bash-completion)"/git
|
||||||
'/usr/share/bash-completion/git' # gentoo
|
'/usr/share/bash-completion/completions/git'
|
||||||
|
'/etc/bash_completion.d/git' # old debian
|
||||||
)
|
)
|
||||||
for e in $locations; do
|
for e in $locations; do
|
||||||
test -f $e && script="$e" && break
|
test -f $e && script="$e" && break
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
ZSH_VERSION='' . "$script"
|
GIT_SOURCING_ZSH_COMPLETION=y . "$script"
|
||||||
|
|
||||||
__gitcomp ()
|
__gitcomp ()
|
||||||
{
|
{
|
||||||
@ -50,13 +50,35 @@ __gitcomp ()
|
|||||||
case "$cur_" in
|
case "$cur_" in
|
||||||
--*=)
|
--*=)
|
||||||
;;
|
;;
|
||||||
|
--no-*)
|
||||||
|
local c IFS=$' \t\n'
|
||||||
|
local -a array
|
||||||
|
for c in ${=1}; do
|
||||||
|
if [[ $c == "--" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
c="$c${4-}"
|
||||||
|
case $c in
|
||||||
|
--*=|*.) ;;
|
||||||
|
*) c="$c " ;;
|
||||||
|
esac
|
||||||
|
array+=("$c")
|
||||||
|
done
|
||||||
|
compset -P '*[=:]'
|
||||||
|
compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
local c IFS=$' \t\n'
|
local c IFS=$' \t\n'
|
||||||
local -a array
|
local -a array
|
||||||
for c in ${=1}; do
|
for c in ${=1}; do
|
||||||
|
if [[ $c == "--" ]]; then
|
||||||
|
c="--no-...${4-}"
|
||||||
|
array+=("$c ")
|
||||||
|
break
|
||||||
|
fi
|
||||||
c="$c${4-}"
|
c="$c${4-}"
|
||||||
case $c in
|
case $c in
|
||||||
--*=*|*.) ;;
|
--*=|*.) ;;
|
||||||
*) c="$c " ;;
|
*) c="$c " ;;
|
||||||
esac
|
esac
|
||||||
array+=("$c")
|
array+=("$c")
|
||||||
@ -71,35 +93,57 @@ __gitcomp_direct ()
|
|||||||
{
|
{
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
|
|
||||||
local IFS=$'\n'
|
|
||||||
compset -P '*[=:]'
|
compset -P '*[=:]'
|
||||||
compadd -Q -- ${=1} && _ret=0
|
compadd -Q -S '' -- ${(f)1} && _ret=0
|
||||||
}
|
}
|
||||||
|
|
||||||
__gitcomp_nl ()
|
__gitcomp_nl ()
|
||||||
{
|
{
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
|
|
||||||
local IFS=$'\n'
|
|
||||||
compset -P '*[=:]'
|
compset -P '*[=:]'
|
||||||
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
|
compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0
|
||||||
}
|
}
|
||||||
|
|
||||||
__gitcomp_nl_append ()
|
__gitcomp_nl_append ()
|
||||||
{
|
{
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
|
|
||||||
local IFS=$'\n'
|
compset -P '*[=:]'
|
||||||
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
|
compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0
|
||||||
|
}
|
||||||
|
|
||||||
|
__gitcomp_file_direct ()
|
||||||
|
{
|
||||||
|
emulate -L zsh
|
||||||
|
|
||||||
|
compadd -f -- ${(f)1} && _ret=0
|
||||||
}
|
}
|
||||||
|
|
||||||
__gitcomp_file ()
|
__gitcomp_file ()
|
||||||
{
|
{
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
|
|
||||||
local IFS=$'\n'
|
compadd -f -p "${2-}" -- ${(f)1} && _ret=0
|
||||||
compset -P '*[=:]'
|
}
|
||||||
compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
|
|
||||||
|
_git_zsh ()
|
||||||
|
{
|
||||||
|
__gitcomp "v1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
__git_complete_command ()
|
||||||
|
{
|
||||||
|
emulate -L zsh
|
||||||
|
|
||||||
|
local command="$1"
|
||||||
|
local completion_func="_git_${command//-/_}"
|
||||||
|
if (( $+functions[$completion_func] )); then
|
||||||
|
emulate ksh -c $completion_func
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
__git_zsh_bash_func ()
|
__git_zsh_bash_func ()
|
||||||
@ -108,14 +152,12 @@ __git_zsh_bash_func ()
|
|||||||
|
|
||||||
local command=$1
|
local command=$1
|
||||||
|
|
||||||
local completion_func="_git_${command//-/_}"
|
__git_complete_command "$command" && return
|
||||||
declare -f $completion_func >/dev/null && $completion_func && return
|
|
||||||
|
|
||||||
local expansion=$(__git_aliased_command "$command")
|
local expansion=$(__git_aliased_command "$command")
|
||||||
if [ -n "$expansion" ]; then
|
if [ -n "$expansion" ]; then
|
||||||
words[1]=$expansion
|
words[1]=$expansion
|
||||||
completion_func="_git_${expansion//-/_}"
|
__git_complete_command "$expansion"
|
||||||
declare -f $completion_func >/dev/null && $completion_func
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,9 +182,11 @@ __git_zsh_cmd_common ()
|
|||||||
push:'update remote refs along with associated objects'
|
push:'update remote refs along with associated objects'
|
||||||
rebase:'forward-port local commits to the updated upstream head'
|
rebase:'forward-port local commits to the updated upstream head'
|
||||||
reset:'reset current HEAD to the specified state'
|
reset:'reset current HEAD to the specified state'
|
||||||
|
restore:'restore working tree files'
|
||||||
rm:'remove files from the working tree and from the index'
|
rm:'remove files from the working tree and from the index'
|
||||||
show:'show various types of objects'
|
show:'show various types of objects'
|
||||||
status:'show the working tree status'
|
status:'show the working tree status'
|
||||||
|
switch:'switch branches'
|
||||||
tag:'create, list, delete or verify a tag object signed with GPG')
|
tag:'create, list, delete or verify a tag object signed with GPG')
|
||||||
_describe -t common-commands 'common commands' list && _ret=0
|
_describe -t common-commands 'common commands' list && _ret=0
|
||||||
}
|
}
|
||||||
@ -150,8 +194,9 @@ __git_zsh_cmd_common ()
|
|||||||
__git_zsh_cmd_alias ()
|
__git_zsh_cmd_alias ()
|
||||||
{
|
{
|
||||||
local -a list
|
local -a list
|
||||||
list=(${${${(0)"$(git config -z --get-regexp '^alias\.')"}#alias.}%$'\n'*})
|
list=(${${(0)"$(git config -z --get-regexp '^alias\.*')"}#alias.})
|
||||||
_describe -t alias-commands 'aliases' list $* && _ret=0
|
list=(${(f)"$(printf "%s:alias for '%s'\n" ${(f@)list})"})
|
||||||
|
_describe -t alias-commands 'aliases' list && _ret=0
|
||||||
}
|
}
|
||||||
|
|
||||||
__git_zsh_cmd_all ()
|
__git_zsh_cmd_all ()
|
||||||
@ -189,10 +234,13 @@ __git_zsh_main ()
|
|||||||
|
|
||||||
case $state in
|
case $state in
|
||||||
(command)
|
(command)
|
||||||
_alternative \
|
_tags common-commands alias-commands all-commands
|
||||||
'alias-commands:alias:__git_zsh_cmd_alias' \
|
while _tags; do
|
||||||
'common-commands:common:__git_zsh_cmd_common' \
|
_requested common-commands && __git_zsh_cmd_common
|
||||||
'all-commands:all:__git_zsh_cmd_all' && _ret=0
|
_requested alias-commands && __git_zsh_cmd_alias
|
||||||
|
_requested all-commands && __git_zsh_cmd_all
|
||||||
|
let _ret || break
|
||||||
|
done
|
||||||
;;
|
;;
|
||||||
(arg)
|
(arg)
|
||||||
local command="${words[1]}" __git_dir
|
local command="${words[1]}" __git_dir
|
||||||
@ -227,6 +275,8 @@ _git ()
|
|||||||
emulate ksh -c __${service}_main
|
emulate ksh -c __${service}_main
|
||||||
elif (( $+functions[_${service}] )); then
|
elif (( $+functions[_${service}] )); then
|
||||||
emulate ksh -c _${service}
|
emulate ksh -c _${service}
|
||||||
|
elif (( $+functions[_${service//-/_}] )); then
|
||||||
|
emulate ksh -c _${service//-/_}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
let _ret && _default && _ret=0
|
let _ret && _default && _ret=0
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -70,6 +70,15 @@
|
|||||||
# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator
|
# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator
|
||||||
# is SP.
|
# 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
|
# By default, __git_ps1 will compare HEAD to your SVN upstream if it can
|
||||||
# find one, or @{upstream} otherwise. Once you have set
|
# find one, or @{upstream} otherwise. Once you have set
|
||||||
# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by
|
# 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
|
# 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
|
# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
|
||||||
# the colored output of "git status -sb" and are available only when
|
# 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
|
# 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
|
# 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"
|
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)
|
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
|
||||||
# when called from PS1 using command substitution
|
# when called from PS1 using command substitution
|
||||||
# in this mode it prints text to add to bash PS1 prompt (includes branch name)
|
# in this mode it prints text to add to bash PS1 prompt (includes branch name)
|
||||||
@ -390,6 +431,13 @@ __git_ps1 ()
|
|||||||
return $exit
|
return $exit
|
||||||
fi
|
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 r=""
|
||||||
local b=""
|
local b=""
|
||||||
local step=""
|
local step=""
|
||||||
@ -398,11 +446,7 @@ __git_ps1 ()
|
|||||||
__git_eread "$g/rebase-merge/head-name" b
|
__git_eread "$g/rebase-merge/head-name" b
|
||||||
__git_eread "$g/rebase-merge/msgnum" step
|
__git_eread "$g/rebase-merge/msgnum" step
|
||||||
__git_eread "$g/rebase-merge/end" total
|
__git_eread "$g/rebase-merge/end" total
|
||||||
if [ -f "$g/rebase-merge/interactive" ]; then
|
r="|REBASE"
|
||||||
r="|REBASE-i"
|
|
||||||
else
|
|
||||||
r="|REBASE-m"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
if [ -d "$g/rebase-apply" ]; then
|
if [ -d "$g/rebase-apply" ]; then
|
||||||
__git_eread "$g/rebase-apply/next" step
|
__git_eread "$g/rebase-apply/next" step
|
||||||
@ -417,10 +461,8 @@ __git_ps1 ()
|
|||||||
fi
|
fi
|
||||||
elif [ -f "$g/MERGE_HEAD" ]; then
|
elif [ -f "$g/MERGE_HEAD" ]; then
|
||||||
r="|MERGING"
|
r="|MERGING"
|
||||||
elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
|
elif __git_sequencer_status; then
|
||||||
r="|CHERRY-PICKING"
|
:
|
||||||
elif [ -f "$g/REVERT_HEAD" ]; then
|
|
||||||
r="|REVERTING"
|
|
||||||
elif [ -f "$g/BISECT_LOG" ]; then
|
elif [ -f "$g/BISECT_LOG" ]; then
|
||||||
r="|BISECTING"
|
r="|BISECTING"
|
||||||
fi
|
fi
|
||||||
@ -467,6 +509,7 @@ __git_ps1 ()
|
|||||||
local i=""
|
local i=""
|
||||||
local s=""
|
local s=""
|
||||||
local u=""
|
local u=""
|
||||||
|
local h=""
|
||||||
local c=""
|
local c=""
|
||||||
local p=""
|
local p=""
|
||||||
|
|
||||||
@ -499,6 +542,11 @@ __git_ps1 ()
|
|||||||
u="%${ZSH_VERSION+%}"
|
u="%${ZSH_VERSION+%}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
|
||||||
|
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
|
||||||
|
h="?"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
|
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
|
||||||
__git_ps1_show_upstream
|
__git_ps1_show_upstream
|
||||||
fi
|
fi
|
||||||
@ -519,8 +567,8 @@ __git_ps1 ()
|
|||||||
b="\${__git_ps1_branch_name}"
|
b="\${__git_ps1_branch_name}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local f="$w$i$s$u"
|
local f="$h$w$i$s$u"
|
||||||
local gitstring="$c$b${f:+$z$f}$r$p"
|
local gitstring="$c$b${f:+$z$f}${sparse}$r$p"
|
||||||
|
|
||||||
if [ $pcmode = yes ]; then
|
if [ $pcmode = yes ]; then
|
||||||
if [ "${__git_printf_supports_v-}" != yes ]; then
|
if [ "${__git_printf_supports_v-}" != yes ]; then
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
url="https://git.kernel.org/pub/scm/git/git.git/plain/contrib/completion"
|
url="https://raw.githubusercontent.com/felipec/git-completion"
|
||||||
version="2.16.0"
|
version="1.0"
|
||||||
|
|
||||||
curl -s -o _git "${url}/git-completion.zsh?h=v${version}" &&
|
curl -s -o _git "${url}/v${version}/git-completion.zsh" &&
|
||||||
curl -s -o git-completion.bash "${url}/git-completion.bash?h=v${version}" &&
|
curl -s -o git-completion.bash "${url}/v${version}/git-completion.bash" &&
|
||||||
curl -s -o git-prompt.sh "${url}/git-prompt.sh?h=v${version}" &&
|
curl -s -o git-prompt.sh "${url}/v${version}/git-prompt.sh"
|
||||||
git apply updates.patch
|
|
||||||
|
@ -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/}
|
|
@ -41,7 +41,7 @@ __go_tool_complete() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
build_flags=(
|
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]'
|
'-n[print the commands but do not run them]'
|
||||||
'-p[number of parallel builds]:number'
|
'-p[number of parallel builds]:number'
|
||||||
'-race[enable data race detection]'
|
'-race[enable data race detection]'
|
||||||
|
@ -22,7 +22,7 @@ plugins=(... kubectl)
|
|||||||
| kcsc | `kubectl config set-context` | Set a context entry in kubeconfig |
|
| kcsc | `kubectl config set-context` | Set a context entry in kubeconfig |
|
||||||
| kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig |
|
| kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig |
|
||||||
| kccc | `kubectl config current-context` | Display the current-context |
|
| 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** |
|
| | | **General aliases** |
|
||||||
| kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector |
|
| 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 |
|
| 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 |
|
| keno | `kubectl edit node` | Edit nodes resource from the default editor |
|
||||||
| kdno | `kubectl describe node` | Describe node resource in detail |
|
| kdno | `kubectl describe node` | Describe node resource in detail |
|
||||||
| kdelno | `kubectl delete node` | Delete the node |
|
| kdelno | `kubectl delete node` | Delete the node |
|
||||||
| | | **Persistent Volume Claim management** |
|
| | | **Persistent Volume Claim management** |
|
||||||
| kgpvc | `kubectl get pvc` | List all PVCs |
|
| kgpvc | `kubectl get pvc` | List all PVCs |
|
||||||
| kgpvcw | `kgpvc --watch` | After listing/getting the requested object, watch for changes |
|
| kgpvcw | `kgpvc --watch` | After listing/getting the requested object, watch for changes |
|
||||||
| kepvc | `kubectl edit pvc` | Edit pvcs from the default editor |
|
| 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 |
|
| kdelpvc | `kubectl delete pvc` | Delete all pvcs matching passed arguments |
|
||||||
| | | |
|
| | | **StatefulSets management** |
|
||||||
| kgss | `kubectl get statefulset` | List the statefulsets in ps format |
|
| kgss | `kubectl get statefulset` | List the statefulsets in ps format |
|
||||||
| kgssw | `kgss --watch` | After getting the list of statefulsets, watch for changes |
|
| 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 |
|
| kgsswide| `kgss -o wide` | After getting the statefulsets, output in plain-text format with any additional information |
|
||||||
@ -106,6 +106,21 @@ plugins=(... kubectl)
|
|||||||
| kdelss | `kubectl delete statefulset` | Delete the statefulset |
|
| kdelss | `kubectl delete statefulset` | Delete the statefulset |
|
||||||
| ksss | `kubectl scale statefulset` | Scale a statefulset |
|
| ksss | `kubectl scale statefulset` | Scale a statefulset |
|
||||||
| krsss | `kubectl rollout status statefulset`| Check the rollout status of a deployment |
|
| 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
|
## Wrappers
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
if (( $+commands[kubectl] )); then
|
if (( $+commands[kubectl] )); then
|
||||||
__KUBECTL_COMPLETION_FILE="${ZSH_CACHE_DIR}/kubectl_completion"
|
__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
|
kubectl completion zsh >! $__KUBECTL_COMPLETION_FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -150,8 +150,26 @@ alias kepvc='kubectl edit pvc'
|
|||||||
alias kdpvc='kubectl describe pvc'
|
alias kdpvc='kubectl describe pvc'
|
||||||
alias kdelpvc='kubectl delete 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
|
# Only run if the user actually has kubectl installed
|
||||||
if (( $+commands[kubectl] )); then
|
if (( ${+_comps[kubectl]} )); then
|
||||||
kj() { kubectl "$@" -o json | jq; }
|
kj() { kubectl "$@" -o json | jq; }
|
||||||
kjx() { kubectl "$@" -o json | fx; }
|
kjx() { kubectl "$@" -o json | fx; }
|
||||||
ky() { kubectl "$@" -o yaml | yh; }
|
ky() { kubectl "$@" -o yaml | yh; }
|
||||||
|
@ -1,21 +1,15 @@
|
|||||||
# NPX Plugin
|
# NPX Plugin
|
||||||
> npx(1) -- execute npm package binaries. ([more info](https://github.com/zkat/npx))
|
|
||||||
|
> npx(1) -- execute npm package binaries. ([more info](https://github.com/npm/npx))
|
||||||
|
|
||||||
This plugin automatically registers npx command-not-found handler if `npx` exists in your `$PATH`.
|
This plugin automatically registers npx command-not-found handler if `npx` exists in your `$PATH`.
|
||||||
|
|
||||||
## Setup
|
To use it, add `npx` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
- Add plugin to `~/.zshrc`
|
```zsh
|
||||||
|
|
||||||
```bash
|
|
||||||
plugins=(.... npx)
|
plugins=(.... npx)
|
||||||
```
|
```
|
||||||
|
|
||||||
- Globally install npx binary (npx will be auto installed with recent versions of Node.js)
|
|
||||||
```bash
|
|
||||||
sudo npm install -g npx
|
|
||||||
```
|
|
||||||
|
|
||||||
## Note
|
## Note
|
||||||
|
|
||||||
The shell auto-fallback doesn't auto-install plain packages. In order to get it to install something, you need to add `@`:
|
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.
|
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user