mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-23 02:35:38 +01:00
Merge branch 'master' of https://github.com/ohmyzsh/ohmyzsh
This commit is contained in:
commit
9a32988974
138 changed files with 1492 additions and 805 deletions
5
.github/CODEOWNERS
vendored
5
.github/CODEOWNERS
vendored
|
|
@ -1,13 +1,14 @@
|
||||||
# Plugin owners
|
# Plugin owners
|
||||||
plugins/archlinux/ @ratijas
|
plugins/archlinux/ @ratijas
|
||||||
|
plugins/dbt/ @msempere
|
||||||
|
plugins/eza/ @pepoluan
|
||||||
plugins/genpass/ @atoponce
|
plugins/genpass/ @atoponce
|
||||||
plugins/git-lfs/ @hellovietduc
|
plugins/git-lfs/ @hellovietduc
|
||||||
plugins/gitfast/ @felipec
|
plugins/gitfast/ @felipec
|
||||||
plugins/react-native @esthor
|
plugins/react-native @esthor
|
||||||
plugins/sdk/ @rgoldberg
|
plugins/sdk/ @rgoldberg
|
||||||
plugins/shell-proxy/ @septs
|
plugins/shell-proxy/ @septs
|
||||||
|
plugins/starship/ @axieax
|
||||||
plugins/universalarchive/ @Konfekt
|
plugins/universalarchive/ @Konfekt
|
||||||
plugins/wp-cli/ @joshmedeski
|
plugins/wp-cli/ @joshmedeski
|
||||||
plugins/zoxide/ @ajeetdsouza
|
plugins/zoxide/ @ajeetdsouza
|
||||||
plugins/starship/ @axieax
|
|
||||||
plugins/dbt/ @msempere
|
|
||||||
|
|
|
||||||
9
.github/dependencies.yml
vendored
9
.github/dependencies.yml
vendored
|
|
@ -2,7 +2,7 @@ dependencies:
|
||||||
plugins/gitfast:
|
plugins/gitfast:
|
||||||
repo: felipec/git-completion
|
repo: felipec/git-completion
|
||||||
branch: master
|
branch: master
|
||||||
version: tag:v2.0
|
version: tag:v2.1
|
||||||
postcopy: |
|
postcopy: |
|
||||||
set -e
|
set -e
|
||||||
rm -rf git-completion.plugin.zsh Makefile README.adoc t tools
|
rm -rf git-completion.plugin.zsh Makefile README.adoc t tools
|
||||||
|
|
@ -29,3 +29,10 @@ dependencies:
|
||||||
postcopy: |
|
postcopy: |
|
||||||
set -e
|
set -e
|
||||||
test -e dependencies/OMZ-README.md && cat dependencies/OMZ-README.md >> README.md
|
test -e dependencies/OMZ-README.md && cat dependencies/OMZ-README.md >> README.md
|
||||||
|
plugins/gradle:
|
||||||
|
repo: gradle/gradle-completion
|
||||||
|
branch: master
|
||||||
|
version: 25da917cf5a88f3e58f05be3868a7b2748c8afe6
|
||||||
|
precopy: |
|
||||||
|
set -e
|
||||||
|
find . ! -name _gradle ! -name LICENSE -delete
|
||||||
|
|
|
||||||
16
README.md
16
README.md
|
|
@ -70,6 +70,7 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
|
||||||
- [Custom Plugins And Themes](#custom-plugins-and-themes)
|
- [Custom Plugins And Themes](#custom-plugins-and-themes)
|
||||||
- [Enable GNU ls In macOS And freeBSD Systems](#enable-gnu-ls-in-macos-and-freebsd-systems)
|
- [Enable GNU ls In macOS And freeBSD Systems](#enable-gnu-ls-in-macos-and-freebsd-systems)
|
||||||
- [Skip Aliases](#skip-aliases)
|
- [Skip Aliases](#skip-aliases)
|
||||||
|
- [Disable async git prompt](#disable-async-git-prompt)
|
||||||
- [Getting Updates](#getting-updates)
|
- [Getting Updates](#getting-updates)
|
||||||
- [Updates Verbosity](#updates-verbosity)
|
- [Updates Verbosity](#updates-verbosity)
|
||||||
- [Manual Updates](#manual-updates)
|
- [Manual Updates](#manual-updates)
|
||||||
|
|
@ -388,6 +389,17 @@ Instead, you can now use the following:
|
||||||
zstyle ':omz:lib:directories' aliases no
|
zstyle ':omz:lib:directories' aliases no
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Disable async git prompt
|
||||||
|
|
||||||
|
Async prompt functions are an experimental feature (included on April 3, 2024) that allows Oh My Zsh to render prompt information
|
||||||
|
asyncronously. This can improve prompt rendering performance, but it might not work well with some setups. We hope that's not an
|
||||||
|
issue, but if you're seeing problems with this new feature, you can turn it off by setting the following in your .zshrc file,
|
||||||
|
before Oh My Zsh is sourced:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
zstyle ':omz:alpha:lib:git' async-prompt no
|
||||||
|
```
|
||||||
|
|
||||||
#### Notice <!-- omit in toc -->
|
#### Notice <!-- omit in toc -->
|
||||||
|
|
||||||
> This feature is currently in a testing phase and it may be subject to change in the future.
|
> This feature is currently in a testing phase and it may be subject to change in the future.
|
||||||
|
|
@ -476,6 +488,10 @@ Oh My Zsh has a vibrant community of happy users and delightful contributors. Wi
|
||||||
|
|
||||||
Thank you so much!
|
Thank you so much!
|
||||||
|
|
||||||
|
<a href="https://github.com/ohmyzsh/ohmyzsh/graphs/contributors">
|
||||||
|
<img src="https://contrib.rocks/image?repo=ohmyzsh/ohmyzsh" width="100%"/>
|
||||||
|
</a>
|
||||||
|
|
||||||
## Follow Us
|
## Follow Us
|
||||||
|
|
||||||
We're on social media:
|
We're on social media:
|
||||||
|
|
|
||||||
144
lib/async_prompt.zsh
Normal file
144
lib/async_prompt.zsh
Normal file
|
|
@ -0,0 +1,144 @@
|
||||||
|
# The async code is taken from
|
||||||
|
# https://github.com/zsh-users/zsh-autosuggestions/blob/master/src/async.zsh
|
||||||
|
# https://github.com/woefe/git-prompt.zsh/blob/master/git-prompt.zsh
|
||||||
|
|
||||||
|
zmodload zsh/system
|
||||||
|
autoload -Uz is-at-least
|
||||||
|
|
||||||
|
# For now, async prompt function handlers are set up like so:
|
||||||
|
# First, define the async function handler and register the handler
|
||||||
|
# with _omz_register_handler:
|
||||||
|
#
|
||||||
|
# function _git_prompt_status_async {
|
||||||
|
# # Do some expensive operation that outputs to stdout
|
||||||
|
# }
|
||||||
|
# _omz_register_handler _git_prompt_status_async
|
||||||
|
#
|
||||||
|
# Then add a stub prompt function in `$PROMPT` or similar prompt variables,
|
||||||
|
# which will show the output of "$_OMZ_ASYNC_OUTPUT[handler_name]":
|
||||||
|
#
|
||||||
|
# function git_prompt_status {
|
||||||
|
# echo -n $_OMZ_ASYNC_OUTPUT[_git_prompt_status_async]
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# RPROMPT='$(git_prompt_status)'
|
||||||
|
#
|
||||||
|
# This API is subject to change and optimization. Rely on it at your own risk.
|
||||||
|
|
||||||
|
function _omz_register_handler {
|
||||||
|
setopt localoptions noksharrays
|
||||||
|
typeset -ga _omz_async_functions
|
||||||
|
# we want to do nothing if there's no $1 function or we already set it up
|
||||||
|
if [[ -z "$1" ]] || (( ! ${+functions[$1]} )) \
|
||||||
|
|| (( ${_omz_async_functions[(Ie)$1]} )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
_omz_async_functions+=("$1")
|
||||||
|
# let's add the hook to async_request if it's not there yet
|
||||||
|
if (( ! ${precmd_functions[(Ie)_omz_async_request]} )) \
|
||||||
|
&& (( ${+functions[_omz_async_request]})); then
|
||||||
|
autoload -Uz add-zsh-hook
|
||||||
|
add-zsh-hook precmd _omz_async_request
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set up async handlers and callbacks
|
||||||
|
function _omz_async_request {
|
||||||
|
local -i ret=$?
|
||||||
|
typeset -gA _OMZ_ASYNC_FDS _OMZ_ASYNC_PIDS _OMZ_ASYNC_OUTPUT
|
||||||
|
|
||||||
|
# executor runs a subshell for all async requests based on key
|
||||||
|
local handler
|
||||||
|
for handler in ${_omz_async_functions}; do
|
||||||
|
(( ${+functions[$handler]} )) || continue
|
||||||
|
|
||||||
|
local fd=${_OMZ_ASYNC_FDS[$handler]:--1}
|
||||||
|
local pid=${_OMZ_ASYNC_PIDS[$handler]:--1}
|
||||||
|
|
||||||
|
# If we've got a pending request, cancel it
|
||||||
|
if (( fd != -1 && pid != -1 )) && { true <&$fd } 2>/dev/null; then
|
||||||
|
# Close the file descriptor and remove the handler
|
||||||
|
exec {fd}<&-
|
||||||
|
zle -F $fd
|
||||||
|
|
||||||
|
# Zsh will make a new process group for the child process only if job
|
||||||
|
# control is enabled (MONITOR option)
|
||||||
|
if [[ -o MONITOR ]]; then
|
||||||
|
# Send the signal to the process group to kill any processes that may
|
||||||
|
# have been forked by the async function handler
|
||||||
|
kill -TERM -$pid 2>/dev/null
|
||||||
|
else
|
||||||
|
# Kill just the child process since it wasn't placed in a new process
|
||||||
|
# group. If the async function handler forked any child processes they may
|
||||||
|
# be orphaned and left behind.
|
||||||
|
kill -TERM $pid 2>/dev/null
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Define global variables to store the file descriptor, PID and output
|
||||||
|
_OMZ_ASYNC_FDS[$handler]=-1
|
||||||
|
_OMZ_ASYNC_PIDS[$handler]=-1
|
||||||
|
|
||||||
|
# Fork a process to fetch the git status and open a pipe to read from it
|
||||||
|
exec {fd}< <(
|
||||||
|
# Tell parent process our PID
|
||||||
|
builtin echo ${sysparams[pid]}
|
||||||
|
# Set exit code for the handler if used
|
||||||
|
() { return $ret }
|
||||||
|
# Run the async function handler
|
||||||
|
$handler
|
||||||
|
)
|
||||||
|
|
||||||
|
# Save FD for handler
|
||||||
|
_OMZ_ASYNC_FDS[$handler]=$fd
|
||||||
|
|
||||||
|
# There's a weird bug here where ^C stops working unless we force a fork
|
||||||
|
# See https://github.com/zsh-users/zsh-autosuggestions/issues/364
|
||||||
|
# and https://github.com/zsh-users/zsh-autosuggestions/pull/612
|
||||||
|
is-at-least 5.8 || command true
|
||||||
|
|
||||||
|
# Save the PID from the handler child process
|
||||||
|
read -u $fd "_OMZ_ASYNC_PIDS[$handler]"
|
||||||
|
|
||||||
|
# When the fd is readable, call the response handler
|
||||||
|
zle -F "$fd" _omz_async_callback
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Called when new data is ready to be read from the pipe
|
||||||
|
function _omz_async_callback() {
|
||||||
|
emulate -L zsh
|
||||||
|
|
||||||
|
local fd=$1 # First arg will be fd ready for reading
|
||||||
|
local err=$2 # Second arg will be passed in case of error
|
||||||
|
|
||||||
|
if [[ -z "$err" || "$err" == "hup" ]]; then
|
||||||
|
# Get handler name from fd
|
||||||
|
local handler="${(k)_OMZ_ASYNC_FDS[(r)$fd]}"
|
||||||
|
|
||||||
|
# Store old output which is supposed to be already printed
|
||||||
|
local old_output="${_OMZ_ASYNC_OUTPUT[$handler]}"
|
||||||
|
|
||||||
|
# Read output from fd
|
||||||
|
IFS= read -r -u $fd -d '' "_OMZ_ASYNC_OUTPUT[$handler]"
|
||||||
|
|
||||||
|
# Repaint prompt if output has changed
|
||||||
|
if [[ "$old_output" != "${_OMZ_ASYNC_OUTPUT[$handler]}" ]]; then
|
||||||
|
zle .reset-prompt
|
||||||
|
zle -R
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Close the fd
|
||||||
|
exec {fd}<&-
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Always remove the handler
|
||||||
|
zle -F "$fd"
|
||||||
|
|
||||||
|
# Unset global FD variable to prevent closing user created FDs in the precmd hook
|
||||||
|
_OMZ_ASYNC_FDS[$handler]=-1
|
||||||
|
_OMZ_ASYNC_PIDS[$handler]=-1
|
||||||
|
}
|
||||||
|
|
||||||
|
autoload -Uz add-zsh-hook
|
||||||
|
add-zsh-hook precmd _omz_async_request
|
||||||
14
lib/cli.zsh
14
lib/cli.zsh
|
|
@ -448,7 +448,7 @@ function _omz::plugin::load {
|
||||||
if [[ ! -f "$base/_$plugin" && ! -f "$base/$plugin.plugin.zsh" ]]; then
|
if [[ ! -f "$base/_$plugin" && ! -f "$base/$plugin.plugin.zsh" ]]; then
|
||||||
_omz::log warn "'$plugin' is not a valid plugin"
|
_omz::log warn "'$plugin' is not a valid plugin"
|
||||||
continue
|
continue
|
||||||
# It it is a valid plugin, add its directory to $fpath unless it is already there
|
# It is a valid plugin, add its directory to $fpath unless it is already there
|
||||||
elif (( ! ${fpath[(Ie)$base]} )); then
|
elif (( ! ${fpath[(Ie)$base]} )); then
|
||||||
fpath=("$base" $fpath)
|
fpath=("$base" $fpath)
|
||||||
fi
|
fi
|
||||||
|
|
@ -773,7 +773,17 @@ function _omz::theme::use {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _omz::update {
|
function _omz::update {
|
||||||
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD)
|
# Check if git command is available
|
||||||
|
(( $+commands[git] )) || {
|
||||||
|
_omz::log error "git is not installed. Aborting..."
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)
|
||||||
|
[[ $? -eq 0 ]] || {
|
||||||
|
_omz::log error "\`$ZSH\` is not a git directory. Aborting..."
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# Run update script
|
# Run update script
|
||||||
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
||||||
|
|
|
||||||
58
lib/git.zsh
58
lib/git.zsh
|
|
@ -1,3 +1,5 @@
|
||||||
|
autoload -Uz is-at-least
|
||||||
|
|
||||||
# The git prompt's git commands are read-only and should not interfere with
|
# The git prompt's git commands are read-only and should not interfere with
|
||||||
# other processes. This environment variable is equivalent to running with `git
|
# other processes. This environment variable is equivalent to running with `git
|
||||||
# --no-optional-locks`, but falls back gracefully for older versions of git.
|
# --no-optional-locks`, but falls back gracefully for older versions of git.
|
||||||
|
|
@ -9,14 +11,18 @@ function __git_prompt_git() {
|
||||||
GIT_OPTIONAL_LOCKS=0 command git "$@"
|
GIT_OPTIONAL_LOCKS=0 command git "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function git_prompt_info() {
|
function _omz_git_prompt_info() {
|
||||||
# If we are on a folder not tracked by git, get out.
|
# If we are on a folder not tracked by git, get out.
|
||||||
# Otherwise, check for hide-info at global and local repository level
|
# Otherwise, check for hide-info at global and local repository level
|
||||||
if ! __git_prompt_git rev-parse --git-dir &> /dev/null \
|
if ! __git_prompt_git rev-parse --git-dir &> /dev/null \
|
||||||
|| [[ "$(__git_prompt_git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
|
|| [[ "$(__git_prompt_git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Get either:
|
||||||
|
# - the current branch name
|
||||||
|
# - the tag name if we are on a tag
|
||||||
|
# - the short SHA of the current commit
|
||||||
local ref
|
local ref
|
||||||
ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \
|
ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \
|
||||||
|| ref=$(__git_prompt_git describe --tags --exact-match HEAD 2> /dev/null) \
|
|| ref=$(__git_prompt_git describe --tags --exact-match HEAD 2> /dev/null) \
|
||||||
|
|
@ -33,6 +39,52 @@ function git_prompt_info() {
|
||||||
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
|
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Use async version if setting is enabled or undefined
|
||||||
|
if zstyle -T ':omz:alpha:lib:git' async-prompt; then
|
||||||
|
function git_prompt_info() {
|
||||||
|
if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}" ]]; then
|
||||||
|
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function git_prompt_status() {
|
||||||
|
if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}" ]]; then
|
||||||
|
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Conditionally register the async handler, only if it's needed in $PROMPT
|
||||||
|
# or any of the other prompt variables
|
||||||
|
function _defer_async_git_register() {
|
||||||
|
# Check if git_prompt_info is used in a prompt variable
|
||||||
|
case "${PS1}:${PS2}:${PS3}:${PS4}:${RPROMPT}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in
|
||||||
|
*(\$\(git_prompt_info\)|\`git_prompt_info\`)*)
|
||||||
|
_omz_register_handler _omz_git_prompt_info
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "${PS1}:${PS2}:${PS3}:${PS4}:${RPROMPT}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in
|
||||||
|
*(\$\(git_prompt_status\)|\`git_prompt_status\`)*)
|
||||||
|
_omz_register_handler _omz_git_prompt_status
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
add-zsh-hook -d precmd _defer_async_git_register
|
||||||
|
unset -f _defer_async_git_register
|
||||||
|
}
|
||||||
|
|
||||||
|
# Register the async handler first. This needs to be done before
|
||||||
|
# the async request prompt is run
|
||||||
|
precmd_functions=(_defer_async_git_register $precmd_functions)
|
||||||
|
else
|
||||||
|
function git_prompt_info() {
|
||||||
|
_omz_git_prompt_info
|
||||||
|
}
|
||||||
|
function git_prompt_status() {
|
||||||
|
_omz_git_prompt_status
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
# Checks if working tree is dirty
|
# Checks if working tree is dirty
|
||||||
function parse_git_dirty() {
|
function parse_git_dirty() {
|
||||||
local STATUS
|
local STATUS
|
||||||
|
|
@ -161,7 +213,7 @@ function git_prompt_long_sha() {
|
||||||
SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
|
SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
|
||||||
}
|
}
|
||||||
|
|
||||||
function git_prompt_status() {
|
function _omz_git_prompt_status() {
|
||||||
[[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
|
[[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
|
||||||
|
|
||||||
# Maps a git status prefix to an internal constant
|
# Maps a git status prefix to an internal constant
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,20 @@
|
||||||
## History wrapper
|
## History wrapper
|
||||||
function omz_history {
|
function omz_history {
|
||||||
local clear list
|
# parse arguments and remove from $@
|
||||||
zparseopts -E c=clear l=list
|
local clear list stamp
|
||||||
|
zparseopts -E -D c=clear l=list f=stamp E=stamp i=stamp t:=stamp
|
||||||
|
|
||||||
if [[ -n "$clear" ]]; then
|
if [[ -n "$clear" ]]; then
|
||||||
# if -c provided, clobber the history file
|
# if -c provided, clobber the history file
|
||||||
echo -n >| "$HISTFILE"
|
echo -n >| "$HISTFILE"
|
||||||
fc -p "$HISTFILE"
|
fc -p "$HISTFILE"
|
||||||
echo >&2 History file deleted.
|
echo >&2 History file deleted.
|
||||||
elif [[ -n "$list" ]]; then
|
elif [[ $# -eq 0 ]]; then
|
||||||
# if -l provided, run as if calling `fc' directly
|
# if no arguments provided, show full history starting from 1
|
||||||
builtin fc "$@"
|
builtin fc $stamp -l 1
|
||||||
else
|
else
|
||||||
# unless a number is provided, show all history events (starting from 1)
|
# otherwise, run `fc -l` with a custom format
|
||||||
[[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
|
builtin fc $stamp -l "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ function title {
|
||||||
: ${2=$1}
|
: ${2=$1}
|
||||||
|
|
||||||
case "$TERM" in
|
case "$TERM" in
|
||||||
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*|foot*|contour*)
|
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty*|st*|foot*|contour*)
|
||||||
print -Pn "\e]2;${2:q}\a" # set window name
|
print -Pn "\e]2;${2:q}\a" # set window name
|
||||||
print -Pn "\e]1;${1:q}\a" # set tab name
|
print -Pn "\e]1;${1:q}\a" # set tab name
|
||||||
;;
|
;;
|
||||||
|
|
@ -129,7 +129,7 @@ fi
|
||||||
# Don't define the function if we're in an unsupported terminal
|
# Don't define the function if we're in an unsupported terminal
|
||||||
case "$TERM" in
|
case "$TERM" in
|
||||||
# all of these either process OSC 7 correctly or ignore entirely
|
# all of these either process OSC 7 correctly or ignore entirely
|
||||||
xterm*|putty*|rxvt*|konsole*|mlterm*|alacritty|screen*|tmux*) ;;
|
xterm*|putty*|rxvt*|konsole*|mlterm*|alacritty*|screen*|tmux*) ;;
|
||||||
contour*|foot*) ;;
|
contour*|foot*) ;;
|
||||||
*)
|
*)
|
||||||
# Terminal.app and iTerm2 process OSC 7 correctly
|
# Terminal.app and iTerm2 process OSC 7 correctly
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ plugins=(... ansible)
|
||||||
| `acon` | command `ansible-console` |
|
| `acon` | command `ansible-console` |
|
||||||
| `ainv` | command `ansible-inventory` |
|
| `ainv` | command `ansible-inventory` |
|
||||||
| `aplaybook` | command `ansible-playbook` |
|
| `aplaybook` | command `ansible-playbook` |
|
||||||
| `ainv` | command `ansible-inventory` |
|
|
||||||
| `adoc` | command `ansible-doc` |
|
| `adoc` | command `ansible-doc` |
|
||||||
| `agal` | command `ansible-galaxy` |
|
| `agal` | command `ansible-galaxy` |
|
||||||
| `apull` | command `ansible-pull` |
|
| `apull` | command `ansible-pull` |
|
||||||
|
|
|
||||||
|
|
@ -179,8 +179,8 @@ fi
|
||||||
# Check Arch Linux PGP Keyring before System Upgrade to prevent failure.
|
# Check Arch Linux PGP Keyring before System Upgrade to prevent failure.
|
||||||
function upgrade() {
|
function upgrade() {
|
||||||
echo ":: Checking Arch Linux PGP Keyring..."
|
echo ":: Checking Arch Linux PGP Keyring..."
|
||||||
local installedver="$(sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
local installedver="$(LANG= sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
||||||
local currentver="$(sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
local currentver="$(LANG= sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
||||||
if [ $installedver != $currentver ]; then
|
if [ $installedver != $currentver ]; then
|
||||||
echo " Arch Linux PGP Keyring is out of date."
|
echo " Arch Linux PGP Keyring is out of date."
|
||||||
echo " Updating before full system upgrade."
|
echo " Updating before full system upgrade."
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,9 @@ autojump_paths=(
|
||||||
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
|
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
|
||||||
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
|
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
|
||||||
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
|
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
|
||||||
|
/opt/pkg/share/autojump/autojump.zsh # macOS with pkgsrc
|
||||||
/etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes
|
/etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes
|
||||||
|
/nix/var/nix/gcroots/current-system/sw/share/zsh/site-functions/autojump.zsh # macOS Nix, nix-darwin
|
||||||
)
|
)
|
||||||
|
|
||||||
for file in $autojump_paths; do
|
for file in $autojump_paths; do
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# catimg
|
# catimg
|
||||||
|
|
||||||
Plugin for displaying images on the terminal using the the `catimg.sh` script provided by [posva](https://github.com/posva/catimg)
|
Plugin for displaying images on the terminal using the `catimg.sh` script provided by [posva](https://github.com/posva/catimg)
|
||||||
|
|
||||||
To use it, add `catimg` to the plugins array in your zshrc file:
|
To use it, add `catimg` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# onto the system clipboard
|
# onto the system clipboard
|
||||||
|
|
||||||
copybuffer () {
|
copybuffer () {
|
||||||
if which clipcopy &>/dev/null; then
|
if builtin which clipcopy &>/dev/null; then
|
||||||
printf "%s" "$BUFFER" | clipcopy
|
printf "%s" "$BUFFER" | clipcopy
|
||||||
else
|
else
|
||||||
zle -M "clipcopy not found. Please make sure you have Oh My Zsh installed correctly."
|
zle -M "clipcopy not found. Please make sure you have Oh My Zsh installed correctly."
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ __docker-compose_subcommand() {
|
||||||
'--resolve-image-digests[Pin image tags to digests.]' \
|
'--resolve-image-digests[Pin image tags to digests.]' \
|
||||||
'--services[Print the service names, one per line.]' \
|
'--services[Print the service names, one per line.]' \
|
||||||
'--volumes[Print the volume names, one per line.]' \
|
'--volumes[Print the volume names, one per line.]' \
|
||||||
'--hash[Print the service config hash, one per line. Set "service1,service2" for a list of specified services.]' \ && ret=0
|
'--hash[Print the service config hash, one per line. Set "service1,service2" for a list of specified services.]' && ret=0
|
||||||
;;
|
;;
|
||||||
(create)
|
(create)
|
||||||
_arguments \
|
_arguments \
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,6 @@ fi
|
||||||
! is-at-least 23.0.0 ${${(s:,:z)"$(command docker --version)"}[3]}; then
|
! is-at-least 23.0.0 ${${(s:,:z)"$(command docker --version)"}[3]}; then
|
||||||
command cp "${0:h}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
|
command cp "${0:h}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
|
||||||
else
|
else
|
||||||
command docker completion zsh >| "$ZSH_CACHE_DIR/completions/_docker"
|
command docker completion zsh | tee "$ZSH_CACHE_DIR/completions/_docker" > /dev/null
|
||||||
fi
|
fi
|
||||||
} &|
|
} &|
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,4 @@ The plugin uses a custom launcher (which we'll call here `$EMACS_LAUNCHER`) that
|
||||||
| eeval | `$EMACS_LAUNCHER --eval` | Same as `M-x eval` but from outside Emacs |
|
| eeval | `$EMACS_LAUNCHER --eval` | Same as `M-x eval` but from outside Emacs |
|
||||||
| eframe | `emacsclient --alternate-editor="" --create-frame` | Create new X frame |
|
| eframe | `emacsclient --alternate-editor="" --create-frame` | Create new X frame |
|
||||||
| efile | - | Print the path to the file open in the current buffer |
|
| efile | - | Print the path to the file open in the current buffer |
|
||||||
| ecd | - | Print the directory of the file open in the the current buffer |
|
| ecd | - | Print the directory of the file open in the current buffer |
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ function efile {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Write to standard output the directory of the file
|
# Write to standard output the directory of the file
|
||||||
# opened in the the current buffer
|
# opened in the current buffer
|
||||||
function ecd {
|
function ecd {
|
||||||
local file
|
local file
|
||||||
file="$(efile)" || return $?
|
file="$(efile)" || return $?
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ EOF
|
||||||
(*.tar.lz4) lz4 -c -d "$full_path" | tar xvf - ;;
|
(*.tar.lz4) lz4 -c -d "$full_path" | tar xvf - ;;
|
||||||
(*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$full_path" ;;
|
(*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$full_path" ;;
|
||||||
(*.gz) (( $+commands[pigz] )) && pigz -cdk "$full_path" > "${file:t:r}" || gunzip -ck "$full_path" > "${file:t:r}" ;;
|
(*.gz) (( $+commands[pigz] )) && pigz -cdk "$full_path" > "${file:t:r}" || gunzip -ck "$full_path" > "${file:t:r}" ;;
|
||||||
(*.bz2) bunzip2 "$full_path" ;;
|
(*.bz2) (( $+commands[pbzip2] )) && pbzip2 -d "$full_path" || bunzip2 "$full_path" ;;
|
||||||
(*.xz) unxz "$full_path" ;;
|
(*.xz) unxz "$full_path" ;;
|
||||||
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$full_path" ;;
|
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$full_path" ;;
|
||||||
(*.lz4) lz4 -d "$full_path" ;;
|
(*.lz4) lz4 -d "$full_path" ;;
|
||||||
|
|
@ -87,7 +87,7 @@ EOF
|
||||||
builtin cd -q control; extract ../control.tar.*
|
builtin cd -q control; extract ../control.tar.*
|
||||||
builtin cd -q ../data; extract ../data.tar.*
|
builtin cd -q ../data; extract ../data.tar.*
|
||||||
builtin cd -q ..; command rm *.tar.* debian-binary ;;
|
builtin cd -q ..; command rm *.tar.* debian-binary ;;
|
||||||
(*.zst) unzstd "$full_path" ;;
|
(*.zst) unzstd --stdout "$full_path" > "${file:t:r}" ;;
|
||||||
(*.cab|*.exe) cabextract "$full_path" ;;
|
(*.cab|*.exe) cabextract "$full_path" ;;
|
||||||
(*.cpio|*.obscpio) cpio -idmvF "$full_path" ;;
|
(*.cpio|*.obscpio) cpio -idmvF "$full_path" ;;
|
||||||
(*.zpaq) zpaq x "$full_path" ;;
|
(*.zpaq) zpaq x "$full_path" ;;
|
||||||
|
|
|
||||||
101
plugins/eza/README.md
Normal file
101
plugins/eza/README.md
Normal file
|
|
@ -0,0 +1,101 @@
|
||||||
|
# eza plugin
|
||||||
|
|
||||||
|
This provides aliases that invoke the [`eza`](https://github.com/eza-community/eza) utility rather than `ls`
|
||||||
|
|
||||||
|
To use it add `eza` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
plugins=(... eza)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
All configurations are done using the `zstyle` command in the `:omz:plugins:eza` namespace.
|
||||||
|
|
||||||
|
**NOTE:** The configuring needs to be done prior to OMZ loading the plugins. When the plugin is loaded,
|
||||||
|
changing the `zstyle` won't have any effect.
|
||||||
|
|
||||||
|
### `dirs-first`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'dirs-first' yes|no
|
||||||
|
```
|
||||||
|
|
||||||
|
If `yes`, directories will be grouped first.
|
||||||
|
|
||||||
|
Default: `no`
|
||||||
|
|
||||||
|
### `git-status`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'git-status' yes|no
|
||||||
|
```
|
||||||
|
|
||||||
|
If `yes`, always add `--git` flag to indicate git status (if tracked / in a git repo).
|
||||||
|
|
||||||
|
Default: `no`
|
||||||
|
|
||||||
|
### `header`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'header' yes|no
|
||||||
|
```
|
||||||
|
|
||||||
|
If `yes`, always add `-h` flag to add a header row for each column.
|
||||||
|
|
||||||
|
Default: `no`
|
||||||
|
|
||||||
|
### `show-group`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'show-group' yes|no
|
||||||
|
```
|
||||||
|
|
||||||
|
If `yes` (default), always add `-g` flag to show the group ownership.
|
||||||
|
|
||||||
|
Default: `yes`
|
||||||
|
|
||||||
|
### `size-prefix`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'size-prefix' (binary|none|si)
|
||||||
|
```
|
||||||
|
|
||||||
|
Choose the prefix to be used in displaying file size:
|
||||||
|
|
||||||
|
- `binary` -- use [binary prefixes](https://en.wikipedia.org/wiki/Binary_prefix) such as "Ki", "Mi", "Gi" and
|
||||||
|
so on
|
||||||
|
- `none` -- don't use any prefix, show size in bytes
|
||||||
|
- `si` (default) -- use [Metric/S.I. prefixes](https://en.wikipedia.org/wiki/Metric_prefix)
|
||||||
|
|
||||||
|
Default: `si`
|
||||||
|
|
||||||
|
### `time-style`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'time-style' $TIME_STYLE
|
||||||
|
```
|
||||||
|
|
||||||
|
Sets the `--time-style` option of `eza`. (See `man eza` for the options)
|
||||||
|
|
||||||
|
Default: Not set, which means the default behavior of `eza` will take place.
|
||||||
|
|
||||||
|
## Aliases
|
||||||
|
|
||||||
|
**Notes:**
|
||||||
|
|
||||||
|
- Aliases may be modified by Configuration
|
||||||
|
- The term "files" without "only" qualifier means both files & directories
|
||||||
|
|
||||||
|
| Alias | Command | Description |
|
||||||
|
| ------ | ----------------- | -------------------------------------------------------------------------- |
|
||||||
|
| `la` | `eza -la` | List all files (except . and ..) as a long list |
|
||||||
|
| `ldot` | `eza -ld .*` | List dotfiles only (directories shown as entries instead of recursed into) |
|
||||||
|
| `lD` | `eza -lD` | List only directories (excluding dotdirs) as a long list |
|
||||||
|
| `lDD` | `eza -laD` | List only directories (including dotdirs) as a long list |
|
||||||
|
| `ll` | `eza -l` | List files as a long list |
|
||||||
|
| `ls` | `eza` | Plain eza call |
|
||||||
|
| `lsd` | `eza -d` | List specified files with directories as entries, in a grid |
|
||||||
|
| `lsdl` | `eza -dl` | List specified files with directories as entries, in a long list |
|
||||||
|
| `lS` | `eza -l -ssize` | List files as a long list, sorted by size |
|
||||||
|
| `lT` | `eza -l -snewest` | List files as a long list, sorted by date (newest last) |
|
||||||
62
plugins/eza/eza.plugin.zsh
Normal file
62
plugins/eza/eza.plugin.zsh
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
if ! (( $+commands[eza] )); then
|
||||||
|
print "zsh eza plugin: eza not found. Please install eza before using this plugin." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
typeset -a _EZA_HEAD
|
||||||
|
typeset -a _EZA_TAIL
|
||||||
|
|
||||||
|
function _configure_eza() {
|
||||||
|
local _val
|
||||||
|
# Get the head flags
|
||||||
|
if zstyle -T ':omz:plugins:eza' 'show-group'; then
|
||||||
|
_EZA_HEAD+=("g")
|
||||||
|
fi
|
||||||
|
if zstyle -t ':omz:plugins:eza' 'header'; then
|
||||||
|
_EZA_HEAD+=("h")
|
||||||
|
fi
|
||||||
|
zstyle -s ':omz:plugins:eza' 'size-prefix' _val
|
||||||
|
case "${_val:l}" in
|
||||||
|
binary)
|
||||||
|
_EZA_HEAD+=("b")
|
||||||
|
;;
|
||||||
|
none)
|
||||||
|
_EZA_HEAD+=("B")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
# Get the tail long-options
|
||||||
|
if zstyle -t ':omz:plugins:eza' 'dirs-first'; then
|
||||||
|
_EZA_TAIL+=("--group-directories-first")
|
||||||
|
fi
|
||||||
|
if zstyle -t ':omz:plugins:eza' 'git-status'; then
|
||||||
|
_EZA_TAIL+=("--git")
|
||||||
|
fi
|
||||||
|
zstyle -s ':omz:plugins:eza' 'time-style' _val
|
||||||
|
if [[ $_val ]]; then
|
||||||
|
_EZA_TAIL+=("--time-style='$_val'")
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_configure_eza
|
||||||
|
|
||||||
|
function _alias_eza() {
|
||||||
|
local _head="${(j::)_EZA_HEAD}$2"
|
||||||
|
local _tail="${(j: :)_EZA_TAIL}"
|
||||||
|
alias "$1"="eza${_head:+ -}${_head}${_tail:+ }${_tail}${3:+ }$3"
|
||||||
|
}
|
||||||
|
|
||||||
|
_alias_eza la la
|
||||||
|
_alias_eza ldot ld ".*"
|
||||||
|
_alias_eza lD lD
|
||||||
|
_alias_eza lDD lDa
|
||||||
|
_alias_eza ll l
|
||||||
|
_alias_eza ls
|
||||||
|
_alias_eza lsd d
|
||||||
|
_alias_eza lsdl dl
|
||||||
|
_alias_eza lS "l -ssize"
|
||||||
|
_alias_eza lT "l -snewest"
|
||||||
|
|
||||||
|
unfunction _alias_eza
|
||||||
|
unfunction _configure_eza
|
||||||
|
unset _EZA_HEAD
|
||||||
|
unset _EZA_TAIL
|
||||||
|
|
@ -1,3 +1,14 @@
|
||||||
|
function fzf_setup_using_fzf() {
|
||||||
|
(( ${+commands[fzf]} )) || return 1
|
||||||
|
|
||||||
|
# we remove "fzf " prefix, this fixes really old fzf versions behaviour
|
||||||
|
# see https://github.com/ohmyzsh/ohmyzsh/issues/12387
|
||||||
|
local fzf_ver=${"$(fzf --version)"#fzf }
|
||||||
|
is-at-least 0.48.0 ${${(s: :)fzf_ver}[1]} || return 1
|
||||||
|
|
||||||
|
eval "$(fzf --zsh)"
|
||||||
|
}
|
||||||
|
|
||||||
function fzf_setup_using_base_dir() {
|
function fzf_setup_using_base_dir() {
|
||||||
local fzf_base fzf_shell fzfdirs dir
|
local fzf_base fzf_shell fzfdirs dir
|
||||||
|
|
||||||
|
|
@ -8,6 +19,7 @@ function fzf_setup_using_base_dir() {
|
||||||
"${HOME}/.fzf"
|
"${HOME}/.fzf"
|
||||||
"${HOME}/.nix-profile/share/fzf"
|
"${HOME}/.nix-profile/share/fzf"
|
||||||
"${XDG_DATA_HOME:-$HOME/.local/share}/fzf"
|
"${XDG_DATA_HOME:-$HOME/.local/share}/fzf"
|
||||||
|
"${MSYSTEM_PREFIX}/share/fzf"
|
||||||
"/usr/local/opt/fzf"
|
"/usr/local/opt/fzf"
|
||||||
"/opt/homebrew/opt/fzf"
|
"/opt/homebrew/opt/fzf"
|
||||||
"/usr/share/fzf"
|
"/usr/share/fzf"
|
||||||
|
|
@ -216,7 +228,8 @@ Please add `export FZF_BASE=/path/to/fzf/install/dir` to your .zshrc
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
fzf_setup_using_openbsd \
|
fzf_setup_using_fzf \
|
||||||
|
|| fzf_setup_using_openbsd \
|
||||||
|| fzf_setup_using_debian \
|
|| fzf_setup_using_debian \
|
||||||
|| fzf_setup_using_opensuse \
|
|| fzf_setup_using_opensuse \
|
||||||
|| fzf_setup_using_cygwin \
|
|| fzf_setup_using_cygwin \
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ if [[ -z "${CLOUDSDK_HOME}" ]]; then
|
||||||
"/usr/local/share/google-cloud-sdk"
|
"/usr/local/share/google-cloud-sdk"
|
||||||
"/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
|
"/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
|
||||||
"/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
|
"/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
|
||||||
|
"/opt/homebrew/share/google-cloud-sdk"
|
||||||
"/usr/share/google-cloud-sdk"
|
"/usr/share/google-cloud-sdk"
|
||||||
"/snap/google-cloud-sdk/current"
|
"/snap/google-cloud-sdk/current"
|
||||||
"/snap/google-cloud-cli/current"
|
"/snap/google-cloud-cli/current"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
# git-commit plugin
|
# git-commit plugin
|
||||||
|
|
||||||
The git-commit plugin adds several [git aliases](https://www.git-scm.com/docs/git-config#Documentation/git-config.txt-alias) for [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) messages.
|
The git-commit plugin adds several
|
||||||
|
[git aliases](https://www.git-scm.com/docs/git-config#Documentation/git-config.txt-alias) for
|
||||||
|
[conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) messages.
|
||||||
|
|
||||||
To use it, add `git-commit` to the plugins array in your zshrc file:
|
To use it, add `git-commit` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
|
|
@ -11,11 +13,9 @@ plugins=(... git-commit)
|
||||||
## Syntax
|
## Syntax
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
git <type> [(-s, --scope) "<scope>"] "<message>"
|
git <type> [(-s, --scope) "<scope>"] [(-a, --attention)] "<message>"
|
||||||
```
|
```
|
||||||
|
|
||||||
> ⚠️ Single/Double quotes around the scope and message are required
|
|
||||||
|
|
||||||
Where `type` is one of the following:
|
Where `type` is one of the following:
|
||||||
|
|
||||||
- `build`
|
- `build`
|
||||||
|
|
@ -34,6 +34,9 @@ Where `type` is one of the following:
|
||||||
> NOTE: the alias for `revert` type is `rev`, as otherwise it conflicts with the git command of the same name.
|
> NOTE: the alias for `revert` type is `rev`, as otherwise it conflicts with the git command of the same name.
|
||||||
> It will still generate a commit message in the format `revert: <message>`
|
> It will still generate a commit message in the format `revert: <message>`
|
||||||
|
|
||||||
|
> ⚠️ Enabling this plugin will (potentially) overwrite all `alias.<type>` that you manually set. Use with
|
||||||
|
> care!
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
| Git alias | Command |
|
| Git alias | Command |
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
local _rev="$(git -C $ZSH rev-parse HEAD 2> /dev/null)"
|
||||||
|
if [[ $_rev == $(git config --global --get oh-my-zsh.git-commit-alias 2> /dev/null) ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
git config --global oh-my-zsh.git-commit-alias "$_rev"
|
||||||
|
|
||||||
local -a _git_commit_aliases
|
local -a _git_commit_aliases
|
||||||
_git_commit_aliases=(
|
_git_commit_aliases=(
|
||||||
'build'
|
'build'
|
||||||
|
|
@ -14,19 +20,39 @@ _git_commit_aliases=(
|
||||||
'wip'
|
'wip'
|
||||||
)
|
)
|
||||||
|
|
||||||
local alias type
|
local _alias _type
|
||||||
for type in "${_git_commit_aliases[@]}"; do
|
for _type in "${_git_commit_aliases[@]}"; do
|
||||||
# an alias can't be named "revert" because the git command takes precedence
|
# an alias can't be named "revert" because the git command takes precedence
|
||||||
# https://stackoverflow.com/a/3538791
|
# https://stackoverflow.com/a/3538791
|
||||||
case "$type" in
|
case "$_type" in
|
||||||
revert) alias=rev ;;
|
revert) _alias=rev ;;
|
||||||
*) alias=$type ;;
|
*) _alias=$_type ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
local func='!a() { if [ "$1" = "-s" ] || [ "$1" = "--scope" ]; then local scope="$2"; shift 2; git commit -m "'$type'(${scope}): ${@}"; else git commit -m "'$type': ${@}"; fi }; a'
|
local _func='!a() {
|
||||||
if ! git config --global --get-all alias.${alias} >/dev/null 2>&1; then
|
local _scope _attention _message
|
||||||
git config --global alias.${alias} "$func"
|
while [ $# -ne 0 ]; do
|
||||||
fi
|
case $1 in
|
||||||
|
-s | --scope )
|
||||||
|
if [ -z $2 ]; then
|
||||||
|
echo "Missing scope!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
_scope="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
-a | --attention )
|
||||||
|
_attention="!"
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
_message="${_message} $1"
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
git commit -m "'$_type'${_scope:+(${_scope})}${_attention}:${_message}"
|
||||||
|
}; a'
|
||||||
|
|
||||||
unset _git_commit_aliases alias type func
|
git config --global alias.$_alias "$_func"
|
||||||
|
done
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@ To use it, add `git-prompt` to the plugins array in your zshrc file:
|
||||||
plugins=(... git-prompt)
|
plugins=(... git-prompt)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You may also need to [customize your theme](https://github.com/ohmyzsh/ohmyzsh/issues/9395#issuecomment-1027130429)
|
||||||
|
to change the way the prompt is built. See the
|
||||||
|
[OMZ wiki on customizing themes](https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-themes).
|
||||||
|
|
||||||
See the [original repository](https://github.com/olivierverdier/zsh-git-prompt).
|
See the [original repository](https://github.com/olivierverdier/zsh-git-prompt).
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,7 @@ plugins=(... git)
|
||||||
| `gfg` | `git ls-files \| grep` |
|
| `gfg` | `git ls-files \| grep` |
|
||||||
| `gm` | `git merge` |
|
| `gm` | `git merge` |
|
||||||
| `gma` | `git merge --abort` |
|
| `gma` | `git merge --abort` |
|
||||||
|
| `gmc` | `git merge --continue` |
|
||||||
| `gms` | `git merge --squash` |
|
| `gms` | `git merge --squash` |
|
||||||
| `gmom` | `git merge origin/$(git_main_branch)` |
|
| `gmom` | `git merge origin/$(git_main_branch)` |
|
||||||
| `gmum` | `git merge upstream/$(git_main_branch)` |
|
| `gmum` | `git merge upstream/$(git_main_branch)` |
|
||||||
|
|
@ -166,6 +167,7 @@ plugins=(... git)
|
||||||
| `grhk` | `git reset --keep` |
|
| `grhk` | `git reset --keep` |
|
||||||
| `grhs` | `git reset --soft` |
|
| `grhs` | `git reset --soft` |
|
||||||
| `gpristine` | `git reset --hard && git clean --force -dfx` |
|
| `gpristine` | `git reset --hard && git clean --force -dfx` |
|
||||||
|
| `gwipe` | `git reset --hard && git clean --force -df` |
|
||||||
| `groh` | `git reset origin/$(git_current_branch) --hard` |
|
| `groh` | `git reset origin/$(git_current_branch) --hard` |
|
||||||
| `grs` | `git restore` |
|
| `grs` | `git restore` |
|
||||||
| `grss` | `git restore --source` |
|
| `grss` | `git restore --source` |
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,7 @@ alias gignored='git ls-files -v | grep "^[[:lower:]]"'
|
||||||
alias gfg='git ls-files | grep'
|
alias gfg='git ls-files | grep'
|
||||||
alias gm='git merge'
|
alias gm='git merge'
|
||||||
alias gma='git merge --abort'
|
alias gma='git merge --abort'
|
||||||
|
alias gmc='git merge --continue'
|
||||||
alias gms="git merge --squash"
|
alias gms="git merge --squash"
|
||||||
alias gmom='git merge origin/$(git_main_branch)'
|
alias gmom='git merge origin/$(git_main_branch)'
|
||||||
alias gmum='git merge upstream/$(git_main_branch)'
|
alias gmum='git merge upstream/$(git_main_branch)'
|
||||||
|
|
@ -349,6 +350,7 @@ alias grhh='git reset --hard'
|
||||||
alias grhk='git reset --keep'
|
alias grhk='git reset --keep'
|
||||||
alias grhs='git reset --soft'
|
alias grhs='git reset --soft'
|
||||||
alias gpristine='git reset --hard && git clean --force -dfx'
|
alias gpristine='git reset --hard && git clean --force -dfx'
|
||||||
|
alias gwipe='git reset --hard && git clean --force -df'
|
||||||
alias groh='git reset origin/$(git_current_branch) --hard'
|
alias groh='git reset origin/$(git_current_branch) --hard'
|
||||||
alias grs='git restore'
|
alias grs='git restore'
|
||||||
alias grss='git restore --source'
|
alias grss='git restore --source'
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,3 @@ To use it, add `gitfast` to the plugins array in your zshrc file:
|
||||||
```zsh
|
```zsh
|
||||||
plugins=(... gitfast)
|
plugins=(... gitfast)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Aliases
|
|
||||||
|
|
||||||
An earlier version of the plugin also loaded the git plugin. If you want to keep those
|
|
||||||
aliases enable the [git plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git)
|
|
||||||
as well.
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Handle $0 according to the standard:
|
# Handle $0 according to the standard:
|
||||||
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
||||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
0="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"
|
||||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||||
|
|
||||||
source "${0:A:h}/git-prompt.sh"
|
source "${0:A:h}/git-prompt.sh"
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
url="https://raw.githubusercontent.com/felipec/git-completion"
|
|
||||||
version="1.3.7"
|
|
||||||
|
|
||||||
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"
|
|
||||||
19
plugins/gradle/LICENSE
Normal file
19
plugins/gradle/LICENSE
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
Copyright (c) 2017 Eric Wendelin
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
@ -1,28 +1,4 @@
|
||||||
#compdef gradle gradlew gw
|
#compdef gradle gradlew gw
|
||||||
# THE LINE ABOVE MUST BE THE FIRST LINE OF THIS FILE IN ORDER FOR COMPLETION TO WORK
|
|
||||||
|
|
||||||
#
|
|
||||||
# Taken from https://github.com/gradle/gradle-completion
|
|
||||||
# Copyright (c) 2017 Eric Wendelin
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
# Terms
|
|
||||||
|
|
||||||
__gradle-set-project-root-dir() {
|
__gradle-set-project-root-dir() {
|
||||||
local dir=`pwd`
|
local dir=`pwd`
|
||||||
|
|
@ -38,7 +14,7 @@ __gradle-set-project-root-dir() {
|
||||||
}
|
}
|
||||||
|
|
||||||
__gradle-init-cache-dir() {
|
__gradle-init-cache-dir() {
|
||||||
cache_dir="$HOME/.gradle/completion"
|
cache_dir="${GRADLE_USER_HOME:-$HOME/.gradle}/completion"
|
||||||
mkdir -p $cache_dir
|
mkdir -p $cache_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,7 +74,7 @@ __gradle-generate-script-cache() {
|
||||||
zle -R "Generating Gradle build script cache"
|
zle -R "Generating Gradle build script cache"
|
||||||
# Cache all Gradle scripts
|
# Cache all Gradle scripts
|
||||||
local -a gradle_build_scripts
|
local -a gradle_build_scripts
|
||||||
gradle_build_scripts=( $(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | egrep -v "$script_exclude_pattern") )
|
gradle_build_scripts=( $(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | grep -E -v "$script_exclude_pattern") )
|
||||||
printf "%s\n" "${gradle_build_scripts[@]}" >| $cache_dir/$cache_name
|
printf "%s\n" "${gradle_build_scripts[@]}" >| $cache_dir/$cache_name
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -125,7 +101,7 @@ __gradle-generate-tasks-cache() {
|
||||||
local gradle_all_tasks="" root_tasks="" subproject_tasks="" output_line
|
local gradle_all_tasks="" root_tasks="" subproject_tasks="" output_line
|
||||||
local -a match
|
local -a match
|
||||||
for output_line in ${(f)"$(printf "%s\n" "${gradle_tasks_output[@]}")"}; do
|
for output_line in ${(f)"$(printf "%s\n" "${gradle_tasks_output[@]}")"}; do
|
||||||
if [[ $output_line =~ ^([[:lower:]][[:alnum:][:punct:]]*)([[:space:]]-[[:space:]]([[:print:]]*))? ]]; then
|
if [[ $output_line =~ ^([[:alpha:]][[:alnum:][:punct:]]*)([[:space:]]-[[:space:]]([[:print:]]*))? ]]; then
|
||||||
local task_name="${match[1]}"
|
local task_name="${match[1]}"
|
||||||
local task_description="${match[3]}"
|
local task_description="${match[3]}"
|
||||||
# Completion for subproject tasks with ':' prefix
|
# Completion for subproject tasks with ':' prefix
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#compdef http
|
#compdef http https
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2015 GitHub zsh-users - http://github.com/zsh-users
|
# Copyright (c) 2015 GitHub zsh-users - http://github.com/zsh-users
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ _ipfs_subcommand(){
|
||||||
_arguments \
|
_arguments \
|
||||||
'--resolve[Check if the given path can be resolved before publishing. Default: true.]' \
|
'--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.]' \
|
'(-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.]' \
|
'--allow-offline[When offline, save the IPNS record to 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).]' \
|
'--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.]" \
|
'(-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.]' \
|
'(-Q --quieter)'{-Q,--quieter}'[Write only final hash.]' \
|
||||||
|
|
|
||||||
|
|
@ -16,18 +16,21 @@ This plugin supplies one command, `jira`, through which all its features are exp
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
|
`jira help` or `jira usage` will print the below usage instructions
|
||||||
|
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
| :------------ | :-------------------------------------------------------- |
|
| :------------ | :-------------------------------------------------------- |
|
||||||
| `jira` | Performs the default action |
|
| `jira` | Performs the default action |
|
||||||
| `jira new` | Opens a new Jira issue dialogue |
|
| `jira new` | Opens a new Jira issue dialogue |
|
||||||
| `jira ABC-123` | Opens an existing issue |
|
| `jira ABC-123` | Opens an existing issue |
|
||||||
| `jira ABC-123 m` | Opens an existing issue for adding a comment |
|
| `jira ABC-123 m` | Opens an existing issue for adding a comment |
|
||||||
| `jira dashboard [rapid_view]` | # opens your JIRA dashboard |
|
| `jira dashboard [rapid_view]` | Opens your JIRA dashboard |
|
||||||
| `jira mine` | Queries for your own issues |
|
| `jira mine` | Queries for your own issues |
|
||||||
| `jira tempo` | Opens your JIRA Tempo |
|
| `jira tempo` | Opens your JIRA Tempo |
|
||||||
| `jira reported [username]` | Queries for issues reported by a user |
|
| `jira reported [username]` | Queries for issues reported by a user |
|
||||||
| `jira assigned [username]` | Queries for issues assigned to a user |
|
| `jira assigned [username]` | Queries for issues assigned to a user |
|
||||||
| `jira branch` | Opens an existing issue matching the current branch name |
|
| `jira branch` | Opens an existing issue matching the current branch name |
|
||||||
|
| `jira help` | Prints usage instructions |
|
||||||
|
|
||||||
|
|
||||||
### Jira Branch usage notes
|
### Jira Branch usage notes
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ _1st_arguments=(
|
||||||
'assigned:search for issues assigned to a user'
|
'assigned:search for issues assigned to a user'
|
||||||
'branch:open the issue named after the git branch of the current directory'
|
'branch:open the issue named after the git branch of the current directory'
|
||||||
'dumpconfig:display effective jira configuration'
|
'dumpconfig:display effective jira configuration'
|
||||||
|
'help:print usage help to stdout'
|
||||||
)
|
)
|
||||||
|
|
||||||
_arguments -C \
|
_arguments -C \
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,21 @@
|
||||||
#
|
#
|
||||||
# See README.md for details
|
# See README.md for details
|
||||||
|
|
||||||
|
function _jira_usage() {
|
||||||
|
cat <<EOF
|
||||||
|
jira Performs the default action
|
||||||
|
jira new Opens a new Jira issue dialogue
|
||||||
|
jira ABC-123 Opens an existing issue
|
||||||
|
jira ABC-123 m Opens an existing issue for adding a comment
|
||||||
|
jira dashboard [rapid_view] Opens your JIRA dashboard
|
||||||
|
jira mine Queries for your own issues
|
||||||
|
jira tempo Opens your JIRA Tempo
|
||||||
|
jira reported [username] Queries for issues reported by a user
|
||||||
|
jira assigned [username] Queries for issues assigned to a user
|
||||||
|
jira branch Opens an existing issue matching the current branch name
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
function jira() {
|
function jira() {
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
local action jira_url jira_prefix
|
local action jira_url jira_prefix
|
||||||
|
|
@ -44,6 +59,8 @@ function jira() {
|
||||||
open_command "${jira_url}/secure/CreateIssue!default.jspa"
|
open_command "${jira_url}/secure/CreateIssue!default.jspa"
|
||||||
elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then
|
elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then
|
||||||
_jira_query ${@:-$action}
|
_jira_query ${@:-$action}
|
||||||
|
elif [[ "$action" == "help" || "$action" == "usage" ]]; then
|
||||||
|
_jira_usage
|
||||||
elif [[ "$action" == "mine" ]]; then
|
elif [[ "$action" == "mine" ]]; then
|
||||||
echo "Opening my issues"
|
echo "Opening my issues"
|
||||||
open_command "${jira_url}/issues/?filter=-1"
|
open_command "${jira_url}/issues/?filter=-1"
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,7 @@ the following environment variables:
|
||||||
| `KUBE_PS1_SUFFIX` | `)` | Prompt closing character |
|
| `KUBE_PS1_SUFFIX` | `)` | Prompt closing character |
|
||||||
| `KUBE_PS1_CLUSTER_FUNCTION` | No default, must be user supplied | Function to customize how cluster is displayed |
|
| `KUBE_PS1_CLUSTER_FUNCTION` | No default, must be user supplied | Function to customize how cluster is displayed |
|
||||||
| `KUBE_PS1_NAMESPACE_FUNCTION` | No default, must be user supplied | Function to customize how namespace is displayed |
|
| `KUBE_PS1_NAMESPACE_FUNCTION` | No default, must be user supplied | Function to customize how namespace is displayed |
|
||||||
|
| `KUBE_PS1_KUBECONFIG_SYMLINK` | `false` | Treat `KUBECONFIG` and `~/.kube/config` files as symbolic links |
|
||||||
|
|
||||||
For terminals that do not support UTF-8, the symbol will be replaced with the
|
For terminals that do not support UTF-8, the symbol will be replaced with the
|
||||||
string `k8s`.
|
string `k8s`.
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ KUBE_PS1_NS_COLOR="${KUBE_PS1_NS_COLOR-cyan}"
|
||||||
KUBE_PS1_BG_COLOR="${KUBE_PS1_BG_COLOR}"
|
KUBE_PS1_BG_COLOR="${KUBE_PS1_BG_COLOR}"
|
||||||
|
|
||||||
KUBE_PS1_KUBECONFIG_CACHE="${KUBECONFIG}"
|
KUBE_PS1_KUBECONFIG_CACHE="${KUBECONFIG}"
|
||||||
|
KUBE_PS1_KUBECONFIG_SYMLINK="${KUBE_PS1_KUBECONFIG_SYMLINK:-false}"
|
||||||
KUBE_PS1_DISABLE_PATH="${HOME}/.kube/kube-ps1/disabled"
|
KUBE_PS1_DISABLE_PATH="${HOME}/.kube/kube-ps1/disabled"
|
||||||
KUBE_PS1_LAST_TIME=0
|
KUBE_PS1_LAST_TIME=0
|
||||||
KUBE_PS1_CLUSTER_FUNCTION="${KUBE_PS1_CLUSTER_FUNCTION}"
|
KUBE_PS1_CLUSTER_FUNCTION="${KUBE_PS1_CLUSTER_FUNCTION}"
|
||||||
|
|
@ -190,14 +191,26 @@ _kube_ps1_file_newer_than() {
|
||||||
local file=$1
|
local file=$1
|
||||||
local check_time=$2
|
local check_time=$2
|
||||||
|
|
||||||
if [[ "${KUBE_PS1_SHELL}" == "zsh" ]]; then
|
if [[ "${KUBE_PS1_KUBECONFIG_SYMLINK}" == "true" ]]; then
|
||||||
mtime=$(zstat +mtime "${file}")
|
if [[ "${KUBE_PS1_SHELL}" == "zsh" ]]; then
|
||||||
elif stat -c "%s" /dev/null &> /dev/null; then
|
mtime=$(zstat -L +mtime "${file}")
|
||||||
# GNU stat
|
elif stat -c "%s" /dev/null &> /dev/null; then
|
||||||
mtime=$(stat -L -c %Y "${file}")
|
# GNU stat
|
||||||
|
mtime=$(stat -c %Y "${file}")
|
||||||
|
else
|
||||||
|
# BSD stat
|
||||||
|
mtime=$(stat -f %m "$file")
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# BSD stat
|
if [[ "${KUBE_PS1_SHELL}" == "zsh" ]]; then
|
||||||
mtime=$(stat -L -f %m "$file")
|
mtime=$(zstat +mtime "${file}")
|
||||||
|
elif stat -c "%s" /dev/null &> /dev/null; then
|
||||||
|
# GNU stat
|
||||||
|
mtime=$(stat -L -c %Y "${file}")
|
||||||
|
else
|
||||||
|
# BSD stat
|
||||||
|
mtime=$(stat -L -f %m "$file")
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ "${mtime}" -gt "${check_time}" ]]
|
[[ "${mtime}" -gt "${check_time}" ]]
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ plugins=(... laravel)
|
||||||
|:-:|:-:|
|
|:-:|:-:|
|
||||||
| `artisan` | `php artisan` |
|
| `artisan` | `php artisan` |
|
||||||
| `pas` | `php artisan serve` |
|
| `pas` | `php artisan serve` |
|
||||||
|
| `pats` | `php artisan test` |
|
||||||
|
|
||||||
## Database
|
## Database
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ alias bob='php artisan bob::build'
|
||||||
|
|
||||||
# Development
|
# Development
|
||||||
alias pas='php artisan serve'
|
alias pas='php artisan serve'
|
||||||
|
alias pats='php artisan test'
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
alias pam='php artisan migrate'
|
alias pam='php artisan migrate'
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
|
||||||
| `tab` | Open the current directory in a new tab |
|
| `tab` | Open the current directory in a new tab |
|
||||||
| `split_tab` | Split the current terminal tab horizontally |
|
| `split_tab` | Split the current terminal tab horizontally |
|
||||||
| `vsplit_tab` | Split the current terminal tab vertically |
|
| `vsplit_tab` | Split the current terminal tab vertically |
|
||||||
| `ofd` | Open the current directory in a Finder window |
|
| `ofd` | Open passed directories (or $PWD by default) in Finder |
|
||||||
| `pfd` | Return the path of the frontmost Finder window |
|
| `pfd` | Return the path of the frontmost Finder window |
|
||||||
| `pfs` | Return the current Finder selection |
|
| `pfs` | Return the current Finder selection |
|
||||||
| `cdf` | `cd` to the current Finder directory |
|
| `cdf` | `cd` to the current Finder directory |
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,15 @@
|
||||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||||
|
|
||||||
# Open the current directory in a Finder window
|
# Open in Finder the directories passed as arguments, or the current directory if
|
||||||
alias ofd='open_command $PWD'
|
# no directories are passed
|
||||||
|
function ofd {
|
||||||
|
if (( ! $# )); then
|
||||||
|
open_command $PWD
|
||||||
|
else
|
||||||
|
open_command $@
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Show/hide hidden files in the Finder
|
# Show/hide hidden files in the Finder
|
||||||
alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
|
alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ fi
|
||||||
# Load mise hooks
|
# Load mise hooks
|
||||||
eval "$($__mise activate zsh)"
|
eval "$($__mise activate zsh)"
|
||||||
|
|
||||||
|
# Hook mise into current environment
|
||||||
|
eval "$($__mise hook-env -s zsh)"
|
||||||
|
|
||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
# bind it to `mise`. Otherwise, compinit will have already done that.
|
# bind it to `mise`. Otherwise, compinit will have already done that.
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_$__mise" ]]; then
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_$__mise" ]]; then
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ __run() {
|
||||||
'-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
|
'-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
|
||||||
'-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
|
'-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
|
||||||
'-no-color[Disables colored command output.]' \
|
'-no-color[Disables colored command output.]' \
|
||||||
'-check-index[If set, the job is only registered or updated if the the passed job modify index matches the server side version. If a check-index value of zero is passed, the job is only registered if it does not yet exist. If a non-zero value is passed, it ensures that the job is being updated from a known state. The use of this flag is most common in conjunction with plan command.]' \
|
'-check-index[If set, the job is only registered or updated if the passed job modify index matches the server side version. If a check-index value of zero is passed, the job is only registered if it does not yet exist. If a non-zero value is passed, it ensures that the job is being updated from a known state. The use of this flag is most common in conjunction with plan command.]' \
|
||||||
'-detach[Return immediately instead of entering monitor mode. After job submission, the evaluation ID will be printed to the screen, which can be used to examine the evaluation using the eval-status command.]' \
|
'-detach[Return immediately instead of entering monitor mode. After job submission, the evaluation ID will be printed to the screen, which can be used to examine the evaluation using the eval-status command.]' \
|
||||||
'-output[Output the JSON that would be submitted to the HTTP API without submitting the job.]' \
|
'-output[Output the JSON that would be submitted to the HTTP API without submitting the job.]' \
|
||||||
'-verbose[Show full information.]'
|
'-verbose[Show full information.]'
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,7 @@ zstyle ':omz:plugins:nvm' lazy-cmd eslint prettier typescript ...
|
||||||
|
|
||||||
#### `.nvmrc` autoload
|
#### `.nvmrc` autoload
|
||||||
|
|
||||||
Note: _this option cannot be used at the same time as `lazy`. `autoload` will override it and load `nvm` at
|
Note: _if used at the same time as `lazy`, `autoload` will start working only after nvm has been lazy-loaded_
|
||||||
startup._
|
|
||||||
|
|
||||||
If set, the plugin will automatically load a node version when if finds a
|
If set, 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
|
[`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating which node
|
||||||
|
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
#compdef nvm
|
|
||||||
#autoload
|
|
||||||
|
|
||||||
[[ -f "$NVM_DIR/nvm.sh" ]] || return 0
|
|
||||||
|
|
||||||
local -a _1st_arguments
|
|
||||||
_1st_arguments=(
|
|
||||||
'help:show help'
|
|
||||||
'--version:print out the latest released version of nvm'
|
|
||||||
'install:download and install a version in <node|iojs|node version number>'
|
|
||||||
'install-latest-npm:download and install the latest npm version'
|
|
||||||
'uninstall:uninstall a version'
|
|
||||||
'use:modify PATH to use <version>. Uses .nvmrc if available'
|
|
||||||
'exec:run <command> on <version>. Uses .nvmrc if available'
|
|
||||||
'run:run `node` on <version> with <args> as arguments. Uses .nvmrc if available'
|
|
||||||
'current:list installed versions'
|
|
||||||
'ls:list installed versions or versions matching a given description'
|
|
||||||
'version:resolve the given description to a single local version'
|
|
||||||
'version-remote:resolve the given description to a single remote version'
|
|
||||||
'ls-remote:list remote versions available for install'
|
|
||||||
'deactivate:undo effects of `nvm` on current shell'
|
|
||||||
'alias:show or set aliases'
|
|
||||||
'unalias:deletes an alias'
|
|
||||||
'reinstall-packages:reinstall global `npm` packages contained in <version> to current version'
|
|
||||||
'unload:unload `nvm` from shell'
|
|
||||||
'which:display path to installed node version. Uses .nvmrc if available'
|
|
||||||
)
|
|
||||||
|
|
||||||
_arguments -C '*:: :->subcmds' && return 0
|
|
||||||
|
|
||||||
if (( CURRENT == 1 )); then
|
|
||||||
_describe -t commands "nvm subcommand" _1st_arguments
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
# Don't try to load nvm if command already available
|
||||||
|
# Note: nvm is a function so we need to use `which`
|
||||||
|
which nvm &>/dev/null && return
|
||||||
|
|
||||||
# See https://github.com/nvm-sh/nvm#installation-and-update
|
# See https://github.com/nvm-sh/nvm#installation-and-update
|
||||||
if [[ -z "$NVM_DIR" ]]; then
|
if [[ -z "$NVM_DIR" ]]; then
|
||||||
if [[ -d "$HOME/.nvm" ]]; then
|
if [[ -d "$HOME/.nvm" ]]; then
|
||||||
|
|
@ -12,41 +16,35 @@ if [[ -z "$NVM_DIR" ]]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Don't try to load nvm if command already available
|
|
||||||
# Note: nvm is a function so we need to use `which`
|
|
||||||
which nvm &>/dev/null && return
|
|
||||||
|
|
||||||
if [[ -z "$NVM_DIR" ]] || [[ ! -f "$NVM_DIR/nvm.sh" ]]; then
|
if [[ -z "$NVM_DIR" ]] || [[ ! -f "$NVM_DIR/nvm.sh" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if zstyle -t ':omz:plugins:nvm' lazy && \
|
function _omz_load_nvm_completion {
|
||||||
! zstyle -t ':omz:plugins:nvm' autoload; then
|
local _nvm_completion
|
||||||
# Call nvm when first using nvm, node, npm, pnpm, yarn or other commands in lazy-cmd
|
# Load nvm bash completion
|
||||||
zstyle -a ':omz:plugins:nvm' lazy-cmd nvm_lazy_cmd
|
for _nvm_completion in "$NVM_DIR/bash_completion" "$NVM_HOMEBREW/etc/bash_completion.d/nvm"; do
|
||||||
nvm_lazy_cmd=(nvm node npm npx pnpm yarn $nvm_lazy_cmd) # default values
|
if [[ -f "$_nvm_completion" ]]; then
|
||||||
eval "
|
# Load bashcompinit
|
||||||
function $nvm_lazy_cmd {
|
autoload -U +X bashcompinit && bashcompinit
|
||||||
for func in $nvm_lazy_cmd; do
|
# Bypass compinit call in nvm bash completion script. See:
|
||||||
if (( \$+functions[\$func] )); then
|
# https://github.com/nvm-sh/nvm/blob/4436638/bash_completion#L86-L93
|
||||||
unfunction \$func
|
ZSH_VERSION= source "$_nvm_completion"
|
||||||
fi
|
break
|
||||||
done
|
fi
|
||||||
# Load nvm if it exists in \$NVM_DIR
|
done
|
||||||
[[ -f \"\$NVM_DIR/nvm.sh\" ]] && source \"\$NVM_DIR/nvm.sh\"
|
unfunction _omz_load_nvm_completion
|
||||||
\"\$0\" \"\$@\"
|
}
|
||||||
}
|
|
||||||
"
|
|
||||||
unset nvm_lazy_cmd
|
|
||||||
else
|
|
||||||
source "$NVM_DIR/nvm.sh"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Autoload nvm when finding a .nvmrc file in the current directory
|
function _omz_setup_autoload {
|
||||||
# Adapted from: https://github.com/nvm-sh/nvm#zsh
|
if ! zstyle -t ':omz:plugins:nvm' autoload; then
|
||||||
if zstyle -t ':omz:plugins:nvm' autoload; then
|
unfunction _omz_setup_autoload
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Autoload nvm when finding a .nvmrc file in the current directory
|
||||||
|
# Adapted from: https://github.com/nvm-sh/nvm#zsh
|
||||||
function load-nvmrc {
|
function load-nvmrc {
|
||||||
local node_version="$(nvm version)"
|
|
||||||
local nvmrc_path="$(nvm_find_nvmrc)"
|
local nvmrc_path="$(nvm_find_nvmrc)"
|
||||||
local nvm_silent=""
|
local nvm_silent=""
|
||||||
zstyle -t ':omz:plugins:nvm' silent-autoload && nvm_silent="--silent"
|
zstyle -t ':omz:plugins:nvm' silent-autoload && nvm_silent="--silent"
|
||||||
|
|
@ -59,10 +57,8 @@ if zstyle -t ':omz:plugins:nvm' autoload; then
|
||||||
elif [[ "$nvmrc_node_version" != "$node_version" ]]; then
|
elif [[ "$nvmrc_node_version" != "$node_version" ]]; then
|
||||||
nvm use $nvm_silent
|
nvm use $nvm_silent
|
||||||
fi
|
fi
|
||||||
elif [[ "$node_version" != "$(nvm version default)" ]]; then
|
elif [[ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ]] && [[ "$(nvm version)" != "$(nvm version default)" ]]; then
|
||||||
if [[ -z $nvm_silent ]]; then
|
[[ -z $nvm_silent ]] && echo "Reverting to nvm default version"
|
||||||
echo "Reverting to nvm default version"
|
|
||||||
fi
|
|
||||||
|
|
||||||
nvm use default $nvm_silent
|
nvm use default $nvm_silent
|
||||||
fi
|
fi
|
||||||
|
|
@ -72,18 +68,30 @@ if zstyle -t ':omz:plugins:nvm' autoload; then
|
||||||
add-zsh-hook chpwd load-nvmrc
|
add-zsh-hook chpwd load-nvmrc
|
||||||
|
|
||||||
load-nvmrc
|
load-nvmrc
|
||||||
|
unfunction _omz_setup_autoload
|
||||||
|
}
|
||||||
|
|
||||||
|
if zstyle -t ':omz:plugins:nvm' lazy; then
|
||||||
|
# Call nvm when first using nvm, node, npm, pnpm, yarn or other commands in lazy-cmd
|
||||||
|
zstyle -a ':omz:plugins:nvm' lazy-cmd nvm_lazy_cmd
|
||||||
|
nvm_lazy_cmd=(nvm node npm npx pnpm yarn $nvm_lazy_cmd) # default values
|
||||||
|
eval "
|
||||||
|
function $nvm_lazy_cmd {
|
||||||
|
for func in $nvm_lazy_cmd; do
|
||||||
|
if (( \$+functions[\$func] )); then
|
||||||
|
unfunction \$func
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# Load nvm if it exists in \$NVM_DIR
|
||||||
|
[[ -f \"\$NVM_DIR/nvm.sh\" ]] && source \"\$NVM_DIR/nvm.sh\"
|
||||||
|
_omz_load_nvm_completion
|
||||||
|
_omz_setup_autoload
|
||||||
|
\"\$0\" \"\$@\"
|
||||||
|
}
|
||||||
|
"
|
||||||
|
unset nvm_lazy_cmd
|
||||||
|
else
|
||||||
|
source "$NVM_DIR/nvm.sh"
|
||||||
|
_omz_load_nvm_completion
|
||||||
|
_omz_setup_autoload
|
||||||
fi
|
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_completion
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# The idea/inspiration for a per directory history is from Stewart MacArthur[1]
|
# The idea/inspiration for a per directory history is from Stewart MacArthur[1]
|
||||||
# and Dieter[2], the implementation idea is from Bart Schaefer on the the zsh
|
# and Dieter[2], the implementation idea is from Bart Schaefer on the zsh
|
||||||
# mailing list[3]. The implementation is by Jim Hester in September 2012.
|
# mailing list[3]. The implementation is by Jim Hester in September 2012.
|
||||||
#
|
#
|
||||||
# [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html
|
# [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,27 @@
|
||||||
# Automatic poetry environment activation/deactivation
|
|
||||||
_togglePoetryShell() {
|
_togglePoetryShell() {
|
||||||
# deactivate environment if pyproject.toml doesn't exist and not in a subdir
|
# Determine if currently in a Poetry-managed directory
|
||||||
if [[ ! -f "$PWD/pyproject.toml" ]] ; then
|
local in_poetry_dir=0
|
||||||
if [[ "$poetry_active" == 1 ]]; then
|
if [[ -f "$PWD/pyproject.toml" ]] && grep -q 'tool.poetry' "$PWD/pyproject.toml"; then
|
||||||
if [[ "$PWD" != "$poetry_dir"* ]]; then
|
in_poetry_dir=1
|
||||||
export poetry_active=0
|
|
||||||
deactivate
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# activate the environment if pyproject.toml exists
|
# Deactivate the current environment if moving out of a Poetry directory or into a different Poetry directory
|
||||||
if [[ "$poetry_active" != 1 ]]; then
|
if [[ $poetry_active -eq 1 ]] && { [[ $in_poetry_dir -eq 0 ]] && [[ "$PWD" != "$poetry_dir"* ]]; }; then
|
||||||
if [[ -f "$PWD/pyproject.toml" ]]; then
|
export poetry_active=0
|
||||||
if grep -q 'tool.poetry' "$PWD/pyproject.toml"; then
|
unset poetry_dir
|
||||||
export poetry_active=1
|
deactivate
|
||||||
export poetry_dir="$PWD"
|
fi
|
||||||
source "$(poetry env info --path)/bin/activate"
|
|
||||||
fi
|
# Activate the environment if in a Poetry directory and no environment is currently active
|
||||||
|
if [[ $in_poetry_dir -eq 1 ]] && [[ $poetry_active -ne 1 ]]; then
|
||||||
|
venv_dir=$(poetry env info --path 2>/dev/null)
|
||||||
|
if [[ -n "$venv_dir" ]]; then
|
||||||
|
export poetry_active=1
|
||||||
|
export poetry_dir="$PWD"
|
||||||
|
source "${venv_dir}/bin/activate"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
autoload -U add-zsh-hook
|
autoload -U add-zsh-hook
|
||||||
add-zsh-hook chpwd _togglePoetryShell
|
add-zsh-hook chpwd _togglePoetryShell
|
||||||
_togglePoetryShell
|
_togglePoetryShell # Initial call to check the current directory at shell startup
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ To use it, add `pyenv` to the plugins array in your zshrc file:
|
||||||
plugins=(... pyenv)
|
plugins=(... pyenv)
|
||||||
```
|
```
|
||||||
|
|
||||||
If you receive a `Found pyenv, but it is badly configured.` error on startup, you may need to ensure that `pyenv` is initialized before the oh-my-zsh pyenv plugin is loaded. This can be achived by adding the following earlier in the `.zshrc` file than the `plugins=(...)` line:
|
If you receive a `Found pyenv, but it is badly configured.` error on startup, you may need to ensure that `pyenv` is initialized before the oh-my-zsh pyenv plugin is loaded. This can be achieved by adding the following earlier in the `.zshrc` file than the `plugins=(...)` line:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
export PYENV_ROOT="$HOME/.pyenv"
|
export PYENV_ROOT="$HOME/.pyenv"
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,18 @@ plugins=(... python)
|
||||||
|
|
||||||
## Virtual environments
|
## Virtual environments
|
||||||
|
|
||||||
The plugin provides two utilities to manage Python venvs:
|
The plugin provides three utilities to manage Python 3.3+ [venv](https://docs.python.org/3/library/venv.html)
|
||||||
|
virtual environments:
|
||||||
|
|
||||||
- `mkv [name]`: make a new virtual environment called `name` (default: `venv`) in current directory.
|
- `mkv [name]`: make a new virtual environment called `name` (default: if set `$PYTHON_VENV_NAME`, else
|
||||||
|
`venv`) in the current directory.
|
||||||
|
|
||||||
- `vrun [name]`: activate virtual environment called `name` (default: `venv`) in current directory.
|
- `vrun [name]`: Activate the virtual environment called `name` (default: if set `$PYTHON_VENV_NAME`, else
|
||||||
|
`venv`) in the current directory.
|
||||||
|
|
||||||
|
- `auto_vrun`: Automatically activate the venv virtual environment when entering a directory containing
|
||||||
|
`<venv-name>/bin/activate`, and automatically deactivate it when navigating out of it (including
|
||||||
|
subdirectories!).
|
||||||
|
- To enable the feature, set `export PYTHON_AUTO_VRUN=true` before sourcing oh-my-zsh.
|
||||||
|
- The default virtual environment name is `venv`. To use a different name, set
|
||||||
|
`export PYTHON_VENV_NAME=<venv-name>`. For example: `export PYTHON_VENV_NAME=".venv"`
|
||||||
|
|
|
||||||
|
|
@ -51,11 +51,12 @@ alias pyserver="python3 -m http.server"
|
||||||
|
|
||||||
|
|
||||||
## venv utilities
|
## venv utilities
|
||||||
|
: ${PYTHON_VENV_NAME:=venv}
|
||||||
|
|
||||||
# Activate a the python virtual environment specified.
|
# Activate a the python virtual environment specified.
|
||||||
# If none specified, use 'venv'.
|
# If none specified, use $PYTHON_VENV_NAME, else 'venv'.
|
||||||
function vrun() {
|
function vrun() {
|
||||||
local name="${1:-venv}"
|
local name="${1:-$PYTHON_VENV_NAME}"
|
||||||
local venvpath="${name:P}"
|
local venvpath="${name:P}"
|
||||||
|
|
||||||
if [[ ! -d "$venvpath" ]]; then
|
if [[ ! -d "$venvpath" ]]; then
|
||||||
|
|
@ -72,12 +73,26 @@ function vrun() {
|
||||||
echo "Activated virtual environment ${name}"
|
echo "Activated virtual environment ${name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a new virtual environment, with default name 'venv'.
|
# Create a new virtual environment using the specified name.
|
||||||
|
# If none specfied, use $PYTHON_VENV_NAME
|
||||||
function mkv() {
|
function mkv() {
|
||||||
local name="${1:-venv}"
|
local name="${1:-$PYTHON_VENV_NAME}"
|
||||||
local venvpath="${name:P}"
|
local venvpath="${name:P}"
|
||||||
|
|
||||||
python3 -m venv "${name}" || return
|
python3 -m venv "${name}" || return
|
||||||
echo >&2 "Created venv in '${venvpath}'"
|
echo >&2 "Created venv in '${venvpath}'"
|
||||||
vrun "${name}"
|
vrun "${name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then
|
||||||
|
# Automatically activate venv when changing dir
|
||||||
|
auto_vrun() {
|
||||||
|
if [[ -f "${PYTHON_VENV_NAME}/bin/activate" ]]; then
|
||||||
|
source "${PYTHON_VENV_NAME}/bin/activate" > /dev/null 2>&1
|
||||||
|
else
|
||||||
|
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
add-zsh-hook chpwd auto_vrun
|
||||||
|
auto_vrun
|
||||||
|
fi
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@ if parsed.scheme not in proxy_protocols:
|
||||||
|
|
||||||
def make_argv():
|
def make_argv():
|
||||||
yield "nc"
|
yield "nc"
|
||||||
if sys.platform == 'linux':
|
if sys.platform in {'linux', 'cygwin'}:
|
||||||
|
# caveats: the built-in netcat of most linux distributions and cygwin support proxy type
|
||||||
# caveats: macOS built-in netcat command not supported proxy-type
|
# caveats: macOS built-in netcat command not supported proxy-type
|
||||||
yield "-X" # --proxy-type
|
yield "-X" # --proxy-type
|
||||||
# Supported protocols are 4 (SOCKS v4), 5 (SOCKS v5) and connect (HTTP proxy).
|
# Supported protocols are 4 (SOCKS v4), 5 (SOCKS v5) and connect (HTTP proxy).
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ use the `ssh-add-args` setting. You can pass multiple arguments separated by spa
|
||||||
zstyle :omz:plugins:ssh-agent ssh-add-args -K -c -a /run/user/1000/ssh-auth
|
zstyle :omz:plugins:ssh-agent ssh-add-args -K -c -a /run/user/1000/ssh-auth
|
||||||
```
|
```
|
||||||
|
|
||||||
These will then be passed the the `ssh-add` call as if written directly. The example
|
These will then be passed the `ssh-add` call as if written directly. The example
|
||||||
above will turn into:
|
above will turn into:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ function _add_identities() {
|
||||||
# if id is an absolute path, make file equal to id
|
# if id is an absolute path, make file equal to id
|
||||||
[[ "$id" = /* ]] && file="$id" || file="$HOME/.ssh/$id"
|
[[ "$id" = /* ]] && file="$id" || file="$HOME/.ssh/$id"
|
||||||
# check for filename match, otherwise try for signature match
|
# check for filename match, otherwise try for signature match
|
||||||
if [[ ${loaded_ids[(I)$file]} -le 0 ]]; then
|
if [[ -f $file && ${loaded_ids[(I)$file]} -le 0 ]]; then
|
||||||
sig="$(ssh-keygen -lf "$file" | awk '{print $2}')"
|
sig="$(ssh-keygen -lf "$file" | awk '{print $2}')"
|
||||||
[[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+=("$file")
|
[[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+=("$file")
|
||||||
fi
|
fi
|
||||||
|
|
@ -98,8 +98,10 @@ function _add_identities() {
|
||||||
|
|
||||||
# Add a nifty symlink for screen/tmux if agent forwarding is enabled
|
# Add a nifty symlink for screen/tmux if agent forwarding is enabled
|
||||||
if zstyle -t :omz:plugins:ssh-agent agent-forwarding \
|
if zstyle -t :omz:plugins:ssh-agent agent-forwarding \
|
||||||
&& [[ -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then
|
&& [[ -n "$SSH_AUTH_SOCK" ]]; then
|
||||||
ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
|
if [[ ! -L "$SSH_AUTH_SOCK" ]]; then
|
||||||
|
ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
_start_agent
|
_start_agent
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,16 @@
|
||||||
# Filter out wildcard host sections.
|
# Filter out wildcard host sections.
|
||||||
_ssh_configfile="$HOME/.ssh/config"
|
_ssh_configfile="$HOME/.ssh/config"
|
||||||
if [[ -f "$_ssh_configfile" ]]; then
|
if [[ -f "$_ssh_configfile" ]]; then
|
||||||
_hosts=($(egrep '^Host.*' "$_ssh_configfile" | awk '{print $2}' | grep -v '^*' | sed -e 's/\.*\*$//'))
|
_ssh_hosts=($(
|
||||||
zstyle ':completion:*:hosts' hosts $_hosts
|
egrep '^Host.*' "$_ssh_configfile" |\
|
||||||
unset _hosts
|
awk '{for (i=2; i<=NF; i++) print $i}' |\
|
||||||
|
sort |\
|
||||||
|
uniq |\
|
||||||
|
grep -v '^*' |\
|
||||||
|
sed -e 's/\.*\*$//'
|
||||||
|
))
|
||||||
|
zstyle ':completion:*:hosts' hosts $_ssh_hosts
|
||||||
|
unset _ssh_hosts
|
||||||
fi
|
fi
|
||||||
unset _ssh_configfile
|
unset _ssh_configfile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# ignore oh-my-zsh theme
|
|
||||||
unset ZSH_THEME
|
|
||||||
|
|
||||||
if (( $+commands[starship] )); then
|
if (( $+commands[starship] )); then
|
||||||
|
# ignore oh-my-zsh theme
|
||||||
|
unset ZSH_THEME
|
||||||
|
|
||||||
eval "$(starship init zsh)"
|
eval "$(starship init zsh)"
|
||||||
else
|
else
|
||||||
echo '[oh-my-zsh] starship not found, please install it from https://starship.rs'
|
echo '[oh-my-zsh] starship not found, please install it from https://starship.rs'
|
||||||
|
|
|
||||||
|
|
@ -15,19 +15,20 @@ plugins=(... terraform)
|
||||||
|
|
||||||
## Aliases
|
## Aliases
|
||||||
|
|
||||||
| Alias | Command |
|
| Alias | Command |
|
||||||
| ----- | -------------------- |
|
| ------ | -------------------- |
|
||||||
| `tf` | `terraform` |
|
| `tf` | `terraform` |
|
||||||
| `tfa` | `terraform apply` |
|
| `tfa` | `terraform apply` |
|
||||||
| `tfc` | `terraform console` |
|
| `tfc` | `terraform console` |
|
||||||
| `tfd` | `terraform destroy` |
|
| `tfd` | `terraform destroy` |
|
||||||
| `tff` | `terraform fmt` |
|
| `tff` | `terraform fmt` |
|
||||||
| `tfi` | `terraform init` |
|
| `tfi` | `terraform init` |
|
||||||
| `tfo` | `terraform output` |
|
| `tfo` | `terraform output` |
|
||||||
| `tfp` | `terraform plan` |
|
| `tfp` | `terraform plan` |
|
||||||
| `tfv` | `terraform validate` |
|
| `tfv` | `terraform validate` |
|
||||||
| `tfs` | `terraform state` |
|
| `tfs` | `terraform state` |
|
||||||
| `tfsh`| `terraform show` |
|
| `tft` | `terraform test` |
|
||||||
|
| `tfsh` | `terraform show` |
|
||||||
|
|
||||||
|
|
||||||
## Prompt function
|
## Prompt function
|
||||||
|
|
|
||||||
|
|
@ -1,411 +1,545 @@
|
||||||
#compdef terraform
|
#compdef terraform
|
||||||
|
compdef _terraform terraform
|
||||||
|
|
||||||
local -a _terraform_cmds opt_args
|
(( ${+functions[_terraform_commands]} )) || _terraform_commands() {
|
||||||
_terraform_cmds=(
|
local -a _terraform_cmds
|
||||||
'apply:Builds or changes infrastructure'
|
_terraform_cmds=(
|
||||||
'console:Interactive console for Terraform interpolations'
|
'apply:Create or update infrastructure'
|
||||||
'destroy:Destroy Terraform-managed infrastructure'
|
'console:Try Terraform expressions at an interactive command prompt'
|
||||||
'fmt:Rewrites config files to canonical format'
|
'destroy:Destroy previously-created infrastructure'
|
||||||
'force-unlock:Manually unlock the terraform state'
|
'fmt:Reformat your configuration in the standard style'
|
||||||
'get:Download and install modules for the configuration'
|
'force-unlock:Release a stuck lock on the current workspace'
|
||||||
'graph:Create a visual graph of Terraform resources'
|
'get:Install or upgrade remote Terraform modules'
|
||||||
'import:Import existing infrastructure into Terraform'
|
'graph:Generate a Graphviz graph of the steps in an operation'
|
||||||
'init:Initialize a Terraform working directory'
|
'import:Associate existing infrastructure with a Terraform resource'
|
||||||
|
'init:Prepare your working directory for other commands'
|
||||||
'login:Obtain and save credentials for a remote host'
|
'login:Obtain and save credentials for a remote host'
|
||||||
'logout:Remove locally-stored credentials for a remote host'
|
'logout:Remove locally-stored credentials for a remote host'
|
||||||
'output:Read an output from a state file'
|
'metadata:Metadata related commands'
|
||||||
'plan:Generate and show an execution plan'
|
'output:Show output values from your root module'
|
||||||
'providers:Prints a tree of the providers used in the configuration'
|
'plan:Show changes required by the current configuration'
|
||||||
'refresh:Update local state file against real resources'
|
'providers:Show the providers required for this configuration'
|
||||||
'show:Inspect Terraform state or plan'
|
'refresh:Update the state to match remote systems'
|
||||||
|
'show:Show the current state or a saved plan'
|
||||||
'state:Advanced state management'
|
'state:Advanced state management'
|
||||||
'taint:Manually mark a resource for recreation'
|
'taint:Mark a resource instance as not fully functional'
|
||||||
'untaint:Manually unmark a resource as tainted'
|
'test:Execute integration tests for Terraform modules'
|
||||||
'validate:Validates the Terraform files'
|
'untaint:Remove the '\''tainted'\'' state from a resource instance'
|
||||||
'version:Prints the Terraform version'
|
'validate:Check whether the configuration is valid'
|
||||||
|
'version:Show the current Terraform version'
|
||||||
'workspace:Workspace management'
|
'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'
|
if (( CURRENT == 1 )); then
|
||||||
)
|
_describe -t commands 'terraform commands' _terraform_cmds
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
__012upgrade() {
|
local curcontext="${curcontext}"
|
||||||
|
cmd="${${_terraform_cmds[(r)$words[1]:*]%%:*}}"
|
||||||
|
curcontext="${curcontext%:*:*}:terraform-${cmd}:"
|
||||||
|
|
||||||
|
local __chdir="${opt_args[-chdir]:-.}"
|
||||||
|
|
||||||
|
if (( ${+functions[_terraform_$cmd]} )); then
|
||||||
|
"_terraform_${cmd}"
|
||||||
|
else
|
||||||
|
_message "no more options"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_apply]} )) || _terraform_apply() {
|
||||||
_arguments \
|
_arguments \
|
||||||
'-yes[Skip the initial introduction messages and interactive confirmation. This can be used to run this command in batch from a script.]' \
|
'-auto-approve[Skip interactive approval of plan before applying.]' \
|
||||||
'-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.]'
|
'-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 -W __chdir -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.]' \
|
||||||
|
'-destroy[Destroy Terraform-managed infrastructure. The command "terraform destroy" is a convenience alias for this option.]' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-input=[(true) Ask for input for variables if not directly set.]:input:(true false)' \
|
||||||
|
'-no-color[If specified, output won'\''t contain any color.]' \
|
||||||
|
'-parallelism=[(10) Limit the number of parallel resource operations.]:parallelism:' \
|
||||||
|
'-refresh=[(true) Skip checking for external changes to remote objects while creating the plan. This can potentially make planning faster, but at the expense of possibly planning against a stale record of the remote system state.]:refresh:(true false)' \
|
||||||
|
'*-replace=[(resource) Force replacement of a particular resource instance using its resource address. If applying would'\''ve normally produced an update or no-op action for this instance, Terraform will replace it instead. You can use this option multiple times to replace more than one object.]:resource:__terraform_state_resources' \
|
||||||
|
'-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -W __chdir -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 -W __chdir -g "*.tfstate"' \
|
||||||
|
'*-target=[(resource) Limit the operation to only the given module, resource, or resource instance and all of its dependencies. You can use this option multiple times to include more than one object. This is for exceptional use only.]:target:__terraform_state_resources' \
|
||||||
|
'*-var=[(for=bar) Set a value for one of the input variables in the root module of the configuration. Use this option more than once to set more than one variable.]:var:' \
|
||||||
|
'*-var-file=[(foo) Load variable values from the given file, in addition to the default files terraform.tfvars and *.auto.tfvars. Use this option more than once to include more than one variables file.]:file:_files -W __chdir -g "*.tfvars{,.json}"' \
|
||||||
|
':plan:_files -W __chdir -'
|
||||||
}
|
}
|
||||||
|
|
||||||
__013upgrade() {
|
(( ${+functions[_terraform_console]} )) || _terraform_console() {
|
||||||
_arguments \
|
_arguments \
|
||||||
'-yes[Skip the initial introduction messages and interactive confirmation. This can be used to run this command in batch from a script.]'
|
'-state=[(terraform.tfstate) Legacy option for the local backend only. See the local backend'\''s documentation for more information.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'-plan[Create a new plan (as if running "terraform plan") and then evaluate expressions against its planned state, instead of evaluating against the current state. You can use this to inspect the effects of configuration changes that haven'\''t been applied yet.]' \
|
||||||
|
'*-var=[(for=bar) Set a variable in the Terraform configuration. This flag can be set multiple times.]:var:' \
|
||||||
|
'*-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 -W __chdir -g "*.tfvars{,.json}"'
|
||||||
}
|
}
|
||||||
|
|
||||||
__apply() {
|
(( ${+functions[_terraform_destroy]} )) || _terraform_destroy() {
|
||||||
_arguments \
|
|
||||||
'-auto-approve[Skip interactive approval of plan before applying.]' \
|
|
||||||
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
|
|
||||||
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
|
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
|
||||||
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
||||||
'-input=[(true) Ask for input for variables if not directly set.]' \
|
|
||||||
'-no-color[If specified, output will be colorless.]' \
|
|
||||||
'-parallelism=[(10) Limit the number of parallel resource operations.]' \
|
|
||||||
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
|
|
||||||
'-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
|
|
||||||
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
|
||||||
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
|
||||||
}
|
|
||||||
|
|
||||||
__console() {
|
|
||||||
_arguments \
|
|
||||||
'-state=[(terraform.tfstate) Path to read state.]' \
|
|
||||||
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
|
||||||
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
|
||||||
}
|
|
||||||
|
|
||||||
__destroy() {
|
|
||||||
_arguments \
|
|
||||||
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
|
|
||||||
'-auto-approve[Skip interactive approval before destroying.]' \
|
|
||||||
'-force[Deprecated: same as auto-approve.]' \
|
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
|
||||||
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
||||||
'-no-color[If specified, output will contain no color.]' \
|
|
||||||
'-parallelism=[(10) Limit the number of concurrent operations.]' \
|
|
||||||
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
|
|
||||||
'-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
|
|
||||||
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
|
||||||
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
|
||||||
}
|
|
||||||
|
|
||||||
__fmt() {
|
|
||||||
_arguments \
|
|
||||||
'-list=[(true) List files whose formatting differs (always false if using STDIN)]' \
|
|
||||||
'-write=[(true) Write result to source file instead of STDOUT (always false if using STDIN or -check)]' \
|
|
||||||
'-diff=[(false) Display diffs of formatting changes]' \
|
|
||||||
'-check=[(false) Check if the input is formatted. Exit status will be 0 if all input is properly formatted and non-zero otherwise.]' \
|
|
||||||
'-recursive=[(false) Also process files in subdirectories. By default, only the given directory (or current directory) is processed.]'
|
|
||||||
}
|
|
||||||
|
|
||||||
__force_unlock() {
|
|
||||||
_arguments \
|
|
||||||
"-force[Don't ask for input for unlock confirmation.]"
|
|
||||||
}
|
|
||||||
|
|
||||||
__get() {
|
|
||||||
_arguments \
|
|
||||||
'-update=[(false) If true, modules already downloaded will be checked for updates and updated if necessary.]' \
|
|
||||||
'-no-color[Disable text coloring in the output.]'
|
|
||||||
}
|
|
||||||
|
|
||||||
__graph() {
|
|
||||||
_arguments \
|
|
||||||
'-draw-cycles[Highlight any cycles in the graph with colored edges. This helps when diagnosing cycle errors.]' \
|
|
||||||
'-type=[(plan) Type of graph to output. Can be: plan, plan-destroy, apply, validate, input, refresh.]'
|
|
||||||
}
|
|
||||||
|
|
||||||
__import() {
|
|
||||||
_arguments \
|
|
||||||
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
|
|
||||||
'-config=[(path) Path to a directory of Terraform configuration files to use to configure the provider. Defaults to pwd. If no config files are present, they must be provided via the input prompts or env vars.]' \
|
|
||||||
'-allow-missing-config[Allow import when no resource configuration block exists.]' \
|
|
||||||
'-input=[(true) Ask for input for variables if not directly set.]' \
|
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
|
||||||
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
||||||
'-no-color[If specified, output will contain no color.]' \
|
|
||||||
'-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'-state-out=[(PATH) Path to the destination state file to write to. If this is not specified, the source state file will be used. This can be a new or existing path.]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times. This is only useful with the "-config" flag.]' \
|
|
||||||
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
|
||||||
}
|
|
||||||
|
|
||||||
__init() {
|
|
||||||
_arguments \
|
|
||||||
'-backend=[(true) Configure the backend for this configuration.]' \
|
|
||||||
'-backend-config=[This can be either a path to an HCL file with key/value assignments (same format as terraform.tfvars) or a 'key=value' format. This is merged with what is in the configuration file. This can be specified multiple times. The backend type must be in the configuration itself.]' \
|
|
||||||
'-force-copy[Suppress prompts about copying state data. This is equivalent to providing a "yes" to all confirmation prompts.]' \
|
|
||||||
'-from-module=[(SOURCE) Copy the contents of the given module into the target directory before initialization.]' \
|
|
||||||
'-get=[(true) Download any modules for this configuration.]' \
|
|
||||||
'-get-plugins=[(true) Download any missing plugins for this configuration.]' \
|
|
||||||
'-input=[(true) Ask for input if necessary. If false, will error if input was required.]' \
|
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
|
||||||
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
||||||
'-no-color[If specified, output will contain no color.]' \
|
|
||||||
'-plugin-dir[Directory containing plugin binaries. This overrides all default search paths for plugins, and prevents the automatic installation of plugins. This flag can be used multiple times.]:plugin_dir:_files -/' \
|
|
||||||
'-reconfigure[Reconfigure the backend, ignoring any saved configuration.]' \
|
|
||||||
'-upgrade=[(false) If installing modules (-get) or plugins (-get-plugins), ignore previously-downloaded objects and install the latest version allowed within configured constraints.]' \
|
|
||||||
'-verify-plugins=[(true) Verify the authenticity and integrity of automatically downloaded plugins.]'
|
|
||||||
}
|
|
||||||
|
|
||||||
__login() {
|
|
||||||
_arguments \
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
__logout() {
|
|
||||||
_arguments \
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
__output() {
|
|
||||||
_arguments \
|
|
||||||
'-state=[(path) Path to the state file to read. Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'-no-color[If specified, output will contain no color.]' \
|
|
||||||
'-json[If specified, machine readable output will be printed in JSON format]'
|
|
||||||
}
|
|
||||||
|
|
||||||
__plan() {
|
|
||||||
_arguments \
|
|
||||||
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
|
|
||||||
'-destroy[If set, a plan will be generated to destroy all resources managed by the given configuration and state.]' \
|
|
||||||
'-detailed-exitcode[() Return detailed exit codes when the command exits. This will change the meaning of exit codes to: 0 - Succeeded, diff is empty (no changes); 1 - Errored, 2 - Succeeded; there is a diff]' \
|
|
||||||
'-input=[(true) Ask for input for variables if not directly set.]' \
|
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
|
||||||
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
||||||
'-no-color[() If specified, output will contain no color.]' \
|
|
||||||
'-out=[(path) Write a plan file to the given path. This can be used as input to the "apply" command.]' \
|
|
||||||
'-parallelism=[(10) Limit the number of concurrent operations.]' \
|
|
||||||
'-refresh=[(true) Update state prior to checking for differences.]' \
|
|
||||||
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
|
|
||||||
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
|
||||||
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
|
||||||
}
|
|
||||||
|
|
||||||
__providers() {
|
|
||||||
local -a __providers_cmds
|
|
||||||
__providers_cmds=(
|
|
||||||
'mirror:Mirrors the provider plugins needed for the current configuration'
|
|
||||||
'schema:Prints the schemas of the providers used in the configuration'
|
|
||||||
)
|
|
||||||
_describe -t providers "providers commands" __providers_cmds
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
__providers_mirror() {
|
|
||||||
_arguments \
|
|
||||||
'-platform=[(os_arch) Choose which target platform to build a mirror for.]' \
|
|
||||||
"*:target_dir:_files -/"
|
|
||||||
}
|
|
||||||
|
|
||||||
__providers_schema() {
|
|
||||||
_arguments \
|
|
||||||
'-json[]' \
|
|
||||||
'::'
|
|
||||||
}
|
|
||||||
|
|
||||||
__refresh() {
|
|
||||||
_arguments \
|
|
||||||
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]::backupfile:_files -g "*.backup"' \
|
|
||||||
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
|
|
||||||
'-input=[(true) Ask for input for variables if not directly set.]' \
|
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
|
||||||
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
||||||
'-no-color[If specified, output will not contain any color.]' \
|
|
||||||
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'*-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
|
|
||||||
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
|
||||||
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
|
||||||
}
|
|
||||||
|
|
||||||
__show() {
|
|
||||||
_arguments \
|
|
||||||
'-json[If specified, output the Terraform plan or state in a machine-readable form.]' \
|
|
||||||
'-no-color[If specified, output will not contain any color.]'
|
|
||||||
}
|
|
||||||
|
|
||||||
__state() {
|
|
||||||
local -a __state_cmds
|
|
||||||
__state_cmds=(
|
|
||||||
'list:List resources in the state'
|
|
||||||
'mv:Move an item in the state'
|
|
||||||
'pull:Pull current state and output to stdout'
|
|
||||||
'push:Update remote state from a local state file'
|
|
||||||
'replace-provider:Replace provider for resources in the Terraform state'
|
|
||||||
'rm:Remove instances from the state'
|
|
||||||
'show:Show a resource in the state'
|
|
||||||
)
|
|
||||||
_describe -t state "state commands" __state_cmds
|
|
||||||
}
|
|
||||||
|
|
||||||
__state_list() {
|
|
||||||
_arguments \
|
_arguments \
|
||||||
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default, Terraform will consult the state of the currently-selected workspace.]' \
|
'-auto-approve[Skip interactive approval of plan before applying.]' \
|
||||||
'-id=[(id) Filters the results to include only instances whose resource types have an attribute named id whose value equals the given id string.]' \
|
'-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 -W __chdir -g "*.backup"' \
|
||||||
"*:address:__statelist"
|
'-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) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-input=[(true) Ask for input for variables if not directly set.]:input:(true false)' \
|
||||||
|
'-no-color[If specified, output won'\''t contain any color.]' \
|
||||||
|
'-parallelism=[(10) Limit the number of parallel resource operations.]:parallelism:' \
|
||||||
|
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]:refresh:(true false)' \
|
||||||
|
'-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -W __chdir -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 -W __chdir -g "*.tfstate"' \
|
||||||
|
'*-target=[(resource) Limit the operation to only the given module, resource, or resource instance and all of its dependencies. You can use this option multiple times to include more than one object. This is for exceptional use only.]:target:__terraform_state_resources' \
|
||||||
|
'*-var=[(for=bar) Set a value for one of the input variables in the root module of the configuration. Use this option more than once to set more than one variable.]:var:' \
|
||||||
|
'*-var-file=[(foo) Load variable values from the given file, in addition to the default files terraform.tfvars and *.auto.tfvars. Use this option more than once to include more than one variables file.]:file:_files -W __chdir -g "*.tfvars{,.json}"'
|
||||||
}
|
}
|
||||||
|
|
||||||
__state_mv() {
|
(( ${+functions[_terraform_fmt]} )) || _terraform_fmt() {
|
||||||
_arguments \
|
_arguments \
|
||||||
"-dry-run[If set, prints out what would've been moved but doesn't actually move anything.]" \
|
'-list=[(true) Don'\''t list files whose formatting differs (always disabled if using STDIN)]:list:(true false)' \
|
||||||
'-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"' \
|
'-write=[(true) Don'\''t write to source files (always disabled if using STDIN or -check)]:write:(true false)' \
|
||||||
'-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"' \
|
'-diff[Display diffs of formatting changes]' \
|
||||||
"-lock=[(true) Lock the state files when locking is supported.]:lock:(true false)" \
|
'-check[Check if the input is formatted. Exit status will be 0 if all input is properly formatted and non-zero otherwise.]' \
|
||||||
"-lock-timeout=[(0s) Duration to retry a state lock.]" \
|
'-no-color[If specified, output won'\''t contain any color.]' \
|
||||||
'-state=[(path) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
|
'-recursive[Also process files in subdirectories. By default, only the given directory (or current directory) is processed.]' \
|
||||||
'-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"' \
|
'*:targets:_files -W __chdir -'
|
||||||
"::" \
|
|
||||||
":source:__statelist" \
|
|
||||||
":destination: "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__state_push() {
|
(( ${+functions[_terraform_force-unlock]} )) || _terraform_force-unlock() {
|
||||||
_arguments \
|
_arguments \
|
||||||
"-force[Write the state even if lineages don't match or the remote serial is higher.]" \
|
'-force[Don'\''t ask for input for unlock confirmation.]' \
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
':lock_id:'
|
||||||
"-lock-timeout=[(0s) Duration to retry a state lock.]" \
|
|
||||||
"::" \
|
|
||||||
":destination:_files"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__state_replace_provider() {
|
(( ${+functions[_terraform_get]} )) || _terraform_get() {
|
||||||
|
_arguments \
|
||||||
|
'-update[Check already-downloaded modules for available updates and install the newest versions available.]' \
|
||||||
|
'-no-color[Disable text coloring in the output.]' \
|
||||||
|
'-test-directory=[(tests) Set the Terraform test directory, defaults to "tests".]:test_directory:_files -W __chdir -/'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_graph]} )) || _terraform_graph() {
|
||||||
|
_arguments \
|
||||||
|
'-draw-cycles[Highlight any cycles in the graph with colored edges. This helps when diagnosing cycle errors. This option is supported only when illustrating a real evaluation graph, selected using the -type=TYPE option.]' \
|
||||||
|
'-module-depth=[(-1) (deprecated) In prior versions of Terraform, specified the depth of modules to show in the output.]:module_depth:' \
|
||||||
|
'-plan=[Render graph using the specified plan file instead of the configuration in the current directory. Implies -type=apply.]:plan:_files -W __chdir -' \
|
||||||
|
'-type=[(plan) Type of operation graph to output. Can be: plan, plan-refresh-only, plan-destroy, or apply. By default Terraform just summarizes the relationships between the resources in your configuration, without any particular operation in mind. Full operation graphs are more detailed but therefore often harder to read.]:type:(plan plan-refresh-only plan-destroy apply)'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_import]} )) || _terraform_import() {
|
||||||
|
_arguments \
|
||||||
|
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -W __chdir -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.]:config:_files -W __chdir -/' \
|
||||||
|
'-input=[(true) Disable interactive input prompts.]:input:(true false)' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-no-color[If specified, output will contain no color.]' \
|
||||||
|
'-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -W __chdir -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 -W __chdir -g "*.tfstate"' \
|
||||||
|
'*-var=[(for=bar) Set a variable in the Terraform configuration. This flag can be set multiple times. This is only useful with the "-config" flag.]:var:' \
|
||||||
|
'*-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 -W __chdir -g "*.tfvars{,.json}"' \
|
||||||
|
':addr:' \
|
||||||
|
':id:'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_init]} )) || _terraform_init() {
|
||||||
|
_arguments \
|
||||||
|
'-backend=[(true) Disable backend or Terraform Cloud initialization for this configuration and use what was previously initialized instead.]:backend:(true false)' \
|
||||||
|
'-backend-config=[Configuration to be merged with what is in the configuration file'\''s '\''backend'\'' block. This can be either a path to an HCL file with key/value assignments (same format as terraform.tfvars) or a '\''key=value'\'' format, and can be specified multiple times. The backend type must be in the configuration itself.]:backend_config:_files -W __chdir -' \
|
||||||
|
'-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:_files -W __chdir -/' \
|
||||||
|
'-get=[(true) Disable downloading modules for this configuration.]:get:(true false)' \
|
||||||
|
'-input=[(true) Disable interactive prompts. Note that some actions may require interactive prompts and will error if input is disabled.]:input:(true false)' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during backend migration. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-no-color[If specified, output will contain no color.]' \
|
||||||
|
'-plugin-dir[Directory containing plugin binaries. This overrides all default search paths for plugins, and prevents the automatic installation of plugins. This flag can be used multiple times.]:plugin_dir:_files -W __chdir -/' \
|
||||||
|
'-reconfigure[Reconfigure the backend, ignoring any saved configuration.]' \
|
||||||
|
'-migrate-state[Reconfigure a backend, and attempt to migrate any existing state.]' \
|
||||||
|
'-upgrade[Install the latest module and provider versions allowed within configured constraints, overriding the default behavior of selecting exactly the version recorded in the dependency lockfile.]' \
|
||||||
|
'-lockfile=[Set a dependency lockfile mode. Currently only "readonly" is valid.]:lockfile:( readonly )' \
|
||||||
|
'-ignore-remote-version[A rare option used for Terraform Cloud and the remote backend only. Set this to ignore checking that the local and remote Terraform versions use compatible state representations, making an operation proceed even when there is a potential mismatch. See the documentation on configuring Terraform with Terraform Cloud for more information.]' \
|
||||||
|
'-test-directory=[(tests) Set the Terraform test directory, defaults to "tests".]:test_directory:_files -W __chdir -/'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_login]} )) || _terraform_login() {
|
||||||
|
_arguments \
|
||||||
|
':hostname:'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_logout]} )) || _terraform_logout() {
|
||||||
|
_arguments \
|
||||||
|
':hostname:'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_metadata]} )) || _terraform_metadata() {
|
||||||
|
_arguments \
|
||||||
|
'*::terraform metadata command:_terraform_metadata_commands'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_metadata_commands]} )) || _terraform_metadata_commands() {
|
||||||
|
local -a _metadata_cmds
|
||||||
|
_metadata_cmds=(
|
||||||
|
'functions:Show signatures and descriptions for the available functions'
|
||||||
|
)
|
||||||
|
if (( CURRENT == 1 )); then
|
||||||
|
_describe -t commands "terraform metadata commands" _metadata_cmds
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local curcontext="${curcontext}"
|
||||||
|
cmd="${${_metadata_cmds[(r)$words[1]:*]%%:*}}"
|
||||||
|
curcontext="${curcontext%:*:*}:terraform-metadata-${cmd}:"
|
||||||
|
|
||||||
|
if (( ${+functions[_terraform_metadata_$cmd]} )); then
|
||||||
|
"_terraform_metadata_${cmd}"
|
||||||
|
else
|
||||||
|
_message "no more options"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_metadata_functions]} )) || _terraform_metadata_functions() {
|
||||||
|
_arguments \
|
||||||
|
'-json[]'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_output]} )) || _terraform_output() {
|
||||||
|
_arguments \
|
||||||
|
'-state=[(path) Path to the state file to read. Defaults to "terraform.tfstate". Ignored when remote state is used.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'-no-color[If specified, output will contain no color.]' \
|
||||||
|
'-json[If specified, machine readable output will be printed in JSON format]' \
|
||||||
|
'-raw[For value types that can be automatically converted to a string, will print the raw string directly, rather than a human-oriented representation of the value.]' \
|
||||||
|
':name:'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_plan]} )) || _terraform_plan() {
|
||||||
|
_arguments \
|
||||||
|
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
|
||||||
|
'-destroy[Select the "destroy" planning mode, which creates a plan to destroy all objects currently managed by this Terraform configuration instead of the usual behavior.]' \
|
||||||
|
'-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.]:input:(true false)' \
|
||||||
|
'-generate-config-out=[(path) (Experimental) If import blocks are present in configuration, instructs Terraform to generate HCL for any imported resources not already present. The configuration is written to a new file at PATH, which must not already exist. Terraform may still attempt to write configuration if the plan errors.]:generate_config_out:' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-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.]:out:' \
|
||||||
|
'-parallelism=[(10) Limit the number of concurrent operations.]:parallelism:' \
|
||||||
|
'-refresh=[(true) Skip checking for external changes to remote objects while creating the plan. This can potentially make planning faster, but at the expense of possibly planning against a stale record of the remote system state.]:refresh:(true false)' \
|
||||||
|
'-refresh-only[Select the "refresh only" planning mode, which checks whether remote objects still match the outcome of the most recent Terraform apply but does not propose any actions to undo any changes made outside of Terraform.]' \
|
||||||
|
'*-replace=[(resource) Force replacement of a particular resource instance using its resource address. If the plan would'\''ve normally produced an update or no-op action for this instance, Terraform will plan to replace it instead. You can use this option multiple times to replace more than one object.]:replace:__terraform_state_resources' \
|
||||||
|
'-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 -W __chdir -g "*.tfstate"' \
|
||||||
|
'*-target=[(resource) Limit the planning operation to only the given module, resource, or resource instance and all of its dependencies. You can use this option multiple times to include more than one object. This is for exceptional use only.]:target:__terraform_state_resources' \
|
||||||
|
'*-var=[(for=bar) Set a value for one of the input variables in the root module of the configuration. Use this option more than once to set more than one variable.]:var:' \
|
||||||
|
'*-var-file=[(foo) Load variable values from the given file, in addition to the default files terraform.tfvars and *.auto.tfvars. Use this option more than once to include more than one variables file.]:file:_files -W __chdir -g "*.tfvars{,.json}"'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_providers]} )) || _terraform_providers() {
|
||||||
|
_arguments \
|
||||||
|
'-test-directory=[(path) Set the Terraform test directory, defaults to "tests".]:test_directory:_files -W __chdir -/' \
|
||||||
|
'*::terraform providers command:_terraform_providers_commands'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_providers_commands]} )) || _terraform_providers_commands() {
|
||||||
|
local -a _providers_cmds
|
||||||
|
_providers_cmds=(
|
||||||
|
'lock:Write out dependency locks for the configured providers'
|
||||||
|
'mirror:Save local copies of all required provider plugins'
|
||||||
|
'schema:Show schemas for the providers used in the configuration'
|
||||||
|
)
|
||||||
|
if (( CURRENT == 1 )); then
|
||||||
|
_describe -t commands "terraform providers commands" _providers_cmds
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local curcontext="${curcontext}"
|
||||||
|
cmd="${${_providers_cmds[(r)$words[1]:*]%%:*}}"
|
||||||
|
curcontext="${curcontext%:*:*}:terraform-providers-${cmd}:"
|
||||||
|
|
||||||
|
if (( ${+functions[_terraform_providers_$cmd]} )); then
|
||||||
|
"_terraform_providers_${cmd}"
|
||||||
|
else
|
||||||
|
_message "no more options"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_providers_lock]} )) || _terraform_providers_lock() {
|
||||||
|
_arguments \
|
||||||
|
'-fs-mirror=[(dir) Consult the given filesystem mirror directory instead of the origin registry for each of the given providers.]:fs_mirror:_files -W __chdir -/' \
|
||||||
|
'-net-mirror=[(url) Consult the given network mirror (given as a base URL) instead of the origin registry for each of the given providers.]:net_mirror:' \
|
||||||
|
'*-platform=[(os_arch) Choose a target platform to request package checksums for.]:platform:' \
|
||||||
|
'*:provider:'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_providers_mirror]} )) || _terraform_providers_mirror() {
|
||||||
|
_arguments \
|
||||||
|
'*-platform=[(os_arch) Choose which target platform to build a mirror for.]:platform:' \
|
||||||
|
'::' \
|
||||||
|
':target_dir:_files -W __chdir -/'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_providers_schema]} )) || _terraform_providers_schema() {
|
||||||
|
_arguments \
|
||||||
|
'-json[]'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_refresh]} )) || _terraform_refresh() {
|
||||||
|
_arguments \
|
||||||
|
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]::backupfile:_files -W __chdir -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.]:input:(true false)' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-no-color[If specified, output will not contain any color.]' \
|
||||||
|
'-parallelism=[(10) Limit the number of parallel resource operations.]:parallelism:' \
|
||||||
|
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -W __chdir -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 -W __chdir -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:__terraform_state_resources' \
|
||||||
|
'*-var=[(for=bar) Set a variable in the Terraform configuration. This flag can be set multiple times.]:var:' \
|
||||||
|
'*-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 -W __chdir -g "*.tfvars{,.json}"'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_show]} )) || _terraform_show() {
|
||||||
|
_arguments \
|
||||||
|
'-json[If specified, output the Terraform plan or state in a machine-readable form.]' \
|
||||||
|
'-no-color[If specified, output will not contain any color.]' \
|
||||||
|
':path:_files -W __chdir -g "*.tfstate"'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_state]} )) || _terraform_state() {
|
||||||
|
_arguments \
|
||||||
|
'*::terraform state command:_terraform_state_commands'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_state_commands]} )) || _terraform_state_commands() {
|
||||||
|
local -a _state_cmds
|
||||||
|
_state_cmds=(
|
||||||
|
'list:List resources in the state'
|
||||||
|
'mv:Move an item in the state'
|
||||||
|
'pull:Pull current state and output to stdout'
|
||||||
|
'push:Update remote state from a local state file'
|
||||||
|
'replace-provider:Replace provider in the state'
|
||||||
|
'rm:Remove instances from the state'
|
||||||
|
'show:Show a resource in the state'
|
||||||
|
)
|
||||||
|
if (( CURRENT == 1 )); then
|
||||||
|
_describe -t commands "terraform state commands" _state_cmds
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local curcontext="${curcontext}"
|
||||||
|
cmd="${${_state_cmds[(r)$words[1]:*]%%:*}}"
|
||||||
|
curcontext="${curcontext%:*:*}:terraform-state-${cmd}:"
|
||||||
|
|
||||||
|
if (( ${+functions[_terraform_state_$cmd]} )); then
|
||||||
|
"_terraform_state_${cmd}"
|
||||||
|
else
|
||||||
|
_message "no more options"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_state_list]} )) || _terraform_state_list() {
|
||||||
|
_arguments \
|
||||||
|
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default, Terraform will consult the state of the currently-selected workspace.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'-id=[(id) Filters the results to include only instances whose resource types have an attribute named id whose value equals the given id string.]:id:' \
|
||||||
|
'*:address:__terraform_state_resources'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_state_mv]} )) || _terraform_state_mv() {
|
||||||
|
_arguments \
|
||||||
|
'-dry-run[If set, prints out what would'\''ve been moved but doesn'\''t actually move anything.]' \
|
||||||
|
'-backup=[(PATH) Path where Terraform should write the backup for the original state. This can"t be disabled. If not set, Terraform will write it to the same path as the statefile with a ".backup" extension.]:backupfile:_files -W __chdir -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 -W __chdir -g "*.backup"' \
|
||||||
|
'-ignore-remote-version[A rare option used for the remote backend only. See the remote backend documentation for more information.]' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-state=[(path) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -W __chdir -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 -W __chdir -g "*.tfstate"' \
|
||||||
|
'::' \
|
||||||
|
':source:__terraform_state_resources' \
|
||||||
|
':destination: '
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_state_push]} )) || _terraform_state_push() {
|
||||||
|
_arguments \
|
||||||
|
'-force[Write the state even if lineages don'\''t match or the remote serial is higher.]' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'::' \
|
||||||
|
':destination:_files'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_state_replace-provider]} )) || _terraform_state_replace-provider() {
|
||||||
_arguments \
|
_arguments \
|
||||||
'-auto-approve[Skip interactive approval.]' \
|
'-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"' \
|
'-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 -W __chdir -g "*.backup"' \
|
||||||
"-lock=[(true) Lock the state files when locking is supported.]:lock:(true false)" \
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
"-lock-timeout=[(0s) Duration to retry a state lock.]" \
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
'-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
|
'-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
":from_provider_fqn:" \
|
'::' \
|
||||||
":to_provider_fqn:"
|
':from_provider_fqn:' \
|
||||||
|
':to_provider_fqn:'
|
||||||
}
|
}
|
||||||
|
|
||||||
__state_rm() {
|
(( ${+functions[_terraform_state_rm]} )) || _terraform_state_rm() {
|
||||||
_arguments \
|
_arguments \
|
||||||
"-dry-run[If set, prints out what would've been removed but doesn't actually remove anything.]" \
|
'-dry-run[If set, prints out what would'\''ve been removed but doesn'\''t actually remove anything.]' \
|
||||||
'-backup=[(PATH) Path where Terraform should write the backup for the original state.]::backupfile:_files -g "*.backup"' \
|
'-backup=[(PATH) Path where Terraform should write the backup for the original state.]::backupfile:_files -W __chdir -g "*.backup"' \
|
||||||
"-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)" \
|
'-ignore-remote-version[Continue even if remote and local Terraform versions are incompatible. This may result in an unusable workspace, and should be used with extreme caution.]' \
|
||||||
"-lock-timeout=[(0s) Duration to retry a state lock.]" \
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
'-state=[(PATH) Path to the state file to update. Defaults to the current workspace state.]:statefile:_files -g "*.tfstate"' \
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
"*:address:__statelist"
|
'-state=[(PATH) Path to the state file to update. Defaults to the current workspace state.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'*:address:__terraform_state_resources'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_state_show]} )) || _terraform_state_show() {
|
||||||
__state_show() {
|
|
||||||
_arguments \
|
_arguments \
|
||||||
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]:statefile:_files -g "*.tfstate"' \
|
'-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 -W __chdir -g "*.tfstate"' \
|
||||||
"*:address:__statelist"
|
"*:address:__terraform_state_resources"
|
||||||
}
|
}
|
||||||
|
|
||||||
__statelist() {
|
(( ${+functions[__terraform_state_resources]} )) || __terraform_state_resources() {
|
||||||
compadd $(terraform state list $opt_args[-state])
|
local resource
|
||||||
|
local -a resources
|
||||||
|
terraform -chdir="${__chdir}" state list -state="${opt_args[-state]}" 2>/dev/null | while read -r resource; do
|
||||||
|
resources+=( "${resource}" )
|
||||||
|
done
|
||||||
|
compadd "${@}" - "${resources[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
__taint() {
|
(( ${+functions[_terraform_taint]} )) || _terraform_taint() {
|
||||||
_arguments \
|
_arguments \
|
||||||
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
|
|
||||||
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
|
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
|
||||||
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
||||||
'-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \
|
|
||||||
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -g "*.tfstate"' \
|
|
||||||
"*:address:__statelist"
|
|
||||||
}
|
|
||||||
|
|
||||||
__untaint() {
|
|
||||||
_arguments \
|
|
||||||
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
|
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
|
||||||
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
|
'-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 -W __chdir -g "*.backup"' \
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
'-ignore-remote-version[A rare option used for the remote backend only. See the remote backend documentation for more information.]' \
|
||||||
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
'-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).]' \
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
|
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -g "*.tfstate"'
|
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'*:address:__terraform_state_resources'
|
||||||
}
|
}
|
||||||
|
|
||||||
__validate() {
|
(( ${+functions[_terraform_test]} )) || _terraform_test() {
|
||||||
_arguments \
|
_arguments \
|
||||||
'-no-color[If specified, output will not contain any color.]' \
|
'-cloud-run=[(source) If specified, Terraform will execute this test run remotely using Terraform Cloud. You must specify the source of a module registered in a private module registry as the argument to this flag. This allows Terraform to associate the cloud run with the correct Terraform Cloud module and organization.]:cloud_run:' \
|
||||||
|
'*-filter=[(testfile) If specified, Terraform will only execute the test files specified by this flag. You can use this option multiple times to execute more than one test file.]:testfile:_files -W __chdir -g "*.tftest.hcl"' \
|
||||||
|
'-json[If specified, machine readable output will be printed in JSON format]' \
|
||||||
|
'-no-color[If specified, machine readable output will be printed in JSON format]' \
|
||||||
|
'-test-directory=[(path) Set the Terraform test directory, defaults to "tests".]:test_directory:_files -W __chdir -/' \
|
||||||
|
'*-var=[(for=bar) Set a value for one of the input variables in the root module of the configuration. Use this option more than once to set more than one variable.]:var:' \
|
||||||
|
'*-var-file=[(foo) Load variable values from the given file, in addition to the default files terraform.tfvars and *.auto.tfvars. Use this option more than once to include more than one variables file.]:file:_files -W __chdir -g "*.tfvars{,.json}"' \
|
||||||
|
'-verbose[Print the plan or state for each test run block as it executes.]' \
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_untaint]} )) || _terraform_untaint() {
|
||||||
|
_arguments \
|
||||||
|
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
|
||||||
|
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -W __chdir -g "*.backup"' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
':name:__terraform_state_resources'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_validate]} )) || _terraform_validate() {
|
||||||
|
_arguments \
|
||||||
'-json[Produce output in a machine-readable JSON format, suitable for use in text editor integrations and other automated systems.]' \
|
'-json[Produce output in a machine-readable JSON format, suitable for use in text editor integrations and other automated systems.]' \
|
||||||
':dir:_files -/'
|
'-no-color[If specified, output will not contain any color.]' \
|
||||||
|
'-no-tests[If specified, Terraform will not validate test files.]' \
|
||||||
|
'-test-directory=[(path) Set the Terraform test directory, defaults to "tests".]:test_directory:_files -W __chdir -/' \
|
||||||
|
':dir:_files -W __chdir -/'
|
||||||
}
|
}
|
||||||
|
|
||||||
__version() {
|
(( ${+functions[_terraform_version]} )) || _terraform_version() {
|
||||||
_arguments \
|
_arguments \
|
||||||
'-json[Output the version information as a JSON object.]'
|
'-json[Output the version information as a JSON object.]' \
|
||||||
|
'::'
|
||||||
}
|
}
|
||||||
|
|
||||||
__workspace() {
|
(( ${+functions[_terraform_workspace]} )) || _terraform_workspace() {
|
||||||
local -a __workspace_cmds
|
_arguments \
|
||||||
__workspace_cmds=(
|
'*::terraform workspace command:_terraform_workspace_commands'
|
||||||
'delete:Delete a workspace'
|
|
||||||
'list:List Workspaces'
|
|
||||||
'new:Create a new workspace'
|
|
||||||
'select:Select a workspace'
|
|
||||||
'show:Show the name of the current workspace'
|
|
||||||
)
|
|
||||||
_describe -t workspace "workspace commands" __workspace_cmds
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_arguments '*:: :->command'
|
(( ${+functions[_terraform_workspace_commands]} )) || _terraform_workspace_commands() {
|
||||||
|
local -a _workspace_cmds
|
||||||
|
_workspace_cmds=(
|
||||||
|
'delete:Delete a workspace'
|
||||||
|
'list:List Workspaces'
|
||||||
|
'new:Create a new workspace'
|
||||||
|
'select:Select a workspace'
|
||||||
|
'show:Show the name of the current workspace'
|
||||||
|
)
|
||||||
|
if (( CURRENT == 1 )); then
|
||||||
|
_describe -t commands "terraform workspace commands" _workspace_cmds
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
if (( CURRENT == 1 )); then
|
local curcontext="${curcontext}"
|
||||||
_describe -t commands "terraform command" _terraform_cmds
|
cmd="${${_workspace_cmds[(r)$words[1]:*]%%:*}}"
|
||||||
return
|
curcontext="${curcontext%:*:*}:terraform-workspace-${cmd}:"
|
||||||
|
|
||||||
|
if (( ${+functions[_terraform_workspace_$cmd]} )); then
|
||||||
|
"_terraform_workspace_${cmd}"
|
||||||
|
else
|
||||||
|
_message "no more options"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_workspace_delete]} )) || _terraform_workspace_delete() {
|
||||||
|
_arguments \
|
||||||
|
'-force[Remove a workspace even if it is managing resources. Terraform can no longer track or manage the workspace'\''s infrastructure.]' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'::' \
|
||||||
|
':name:__terraform_workspaces'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_workspace_list]} )) || _terraform_workspace_list() {
|
||||||
|
_arguments
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_workspace_new]} )) || _terraform_workspace_new() {
|
||||||
|
_arguments \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-state=[(path) Copy an existing state file into the new workspace.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'::' \
|
||||||
|
':name:'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_workspace_select]} )) || _terraform_workspace_select() {
|
||||||
|
_arguments \
|
||||||
|
'-or-create=[(false) Create the Terraform workspace if it doesn'\''t exist.]:or_create:(true false)' \
|
||||||
|
'::' \
|
||||||
|
':name:__terraform_workspaces'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_workspace_show]} )) || _terraform_workspace_show() {
|
||||||
|
_arguments
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[__terraform_workspaces]} )) || __terraform_workspaces() {
|
||||||
|
local workspace
|
||||||
|
local -a workspaces
|
||||||
|
terraform -chdir="${__chdir}" workspace list | while read -r workspace; do
|
||||||
|
if [[ -z "${workspace}" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
workspaces+=( "${workspace#[ *] }" )
|
||||||
|
done
|
||||||
|
compadd "${@}" - "${workspaces[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
_terraform() {
|
||||||
|
_arguments \
|
||||||
|
'-chdir=[(DIR) Switch to a different working directory before executing the given subcommand.]:chdir:_files -W __chdir -/' \
|
||||||
|
'-help[Show this help output, or the help for a specified subcommand.]' \
|
||||||
|
'-version[An alias for the "version" subcommand.]' \
|
||||||
|
'*::terraform command:_terraform_commands'
|
||||||
|
}
|
||||||
|
|
||||||
|
# don't run the completion function when being source-ed or eval-ed
|
||||||
|
if [ "${funcstack[1]}" = '_terraform' ]; then
|
||||||
|
_terraform
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local -a _command_args
|
|
||||||
case "$words[1]" in
|
|
||||||
0.12upgrade)
|
|
||||||
__012upgrade ;;
|
|
||||||
0.13upgrade)
|
|
||||||
__013upgrade ;;
|
|
||||||
apply)
|
|
||||||
__apply ;;
|
|
||||||
console)
|
|
||||||
__console;;
|
|
||||||
destroy)
|
|
||||||
__destroy ;;
|
|
||||||
fmt)
|
|
||||||
__fmt;;
|
|
||||||
force-unlock)
|
|
||||||
__force_unlock;;
|
|
||||||
get)
|
|
||||||
__get ;;
|
|
||||||
graph)
|
|
||||||
__graph ;;
|
|
||||||
import)
|
|
||||||
__import;;
|
|
||||||
init)
|
|
||||||
__init ;;
|
|
||||||
login)
|
|
||||||
__login ;;
|
|
||||||
logout)
|
|
||||||
__logout ;;
|
|
||||||
output)
|
|
||||||
__output ;;
|
|
||||||
plan)
|
|
||||||
__plan ;;
|
|
||||||
providers)
|
|
||||||
test $CURRENT -lt 3 && __providers
|
|
||||||
[[ $words[2] = "mirror" ]] && __providers_mirror
|
|
||||||
[[ $words[2] = "schema" ]] && __providers_schema
|
|
||||||
;;
|
|
||||||
refresh)
|
|
||||||
__refresh ;;
|
|
||||||
show)
|
|
||||||
__show ;;
|
|
||||||
state)
|
|
||||||
test $CURRENT -lt 3 && __state
|
|
||||||
[[ $words[2] = "list" ]] && __state_list
|
|
||||||
[[ $words[2] = "mv" ]] && __state_mv
|
|
||||||
[[ $words[2] = "push" ]] && __state_push
|
|
||||||
[[ $words[2] = "replace-provider" ]] && __state_replace_provider
|
|
||||||
[[ $words[2] = "rm" ]] && __state_rm
|
|
||||||
[[ $words[2] = "show" ]] && __state_show
|
|
||||||
;;
|
|
||||||
taint)
|
|
||||||
__taint ;;
|
|
||||||
untaint)
|
|
||||||
__untaint ;;
|
|
||||||
validate)
|
|
||||||
__validate ;;
|
|
||||||
version)
|
|
||||||
__version ;;
|
|
||||||
workspace)
|
|
||||||
test $CURRENT -lt 3 && __workspace ;;
|
|
||||||
esac
|
|
||||||
|
|
|
||||||
|
|
@ -25,4 +25,5 @@ alias tfo='terraform output'
|
||||||
alias tfp='terraform plan'
|
alias tfp='terraform plan'
|
||||||
alias tfv='terraform validate'
|
alias tfv='terraform validate'
|
||||||
alias tfs='terraform state'
|
alias tfs='terraform state'
|
||||||
|
alias tft='terraform test'
|
||||||
alias tfsh='terraform show'
|
alias tfsh='terraform show'
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# tmux
|
# tmux
|
||||||
|
|
||||||
This plugin provides aliases for [tmux](https://tmux.github.io/), the terminal multiplexer.
|
This plugin provides aliases for [tmux](https://tmux.github.io/), the terminal multiplexer. To use it add
|
||||||
To use it add `tmux` to the plugins array in your zshrc file.
|
`tmux` to the plugins array in your zshrc file.
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
plugins=(... tmux)
|
plugins=(... tmux)
|
||||||
|
|
@ -19,26 +19,28 @@ The plugin also supports the following:
|
||||||
| ---------- | -------------------------- | -------------------------------------------------------- |
|
| ---------- | -------------------------- | -------------------------------------------------------- |
|
||||||
| `ta` | tmux attach -t | Attach new tmux session to already running named session |
|
| `ta` | tmux attach -t | Attach new tmux session to already running named session |
|
||||||
| `tad` | tmux attach -d -t | Detach named tmux session |
|
| `tad` | tmux attach -d -t | Detach named tmux session |
|
||||||
| `ts` | tmux new-session -s | Create a new named tmux session |
|
| `tds` | `_tmux_directory_session` | Creates or attaches to a session for the current path |
|
||||||
| `tl` | tmux list-sessions | Displays a list of running tmux sessions |
|
|
||||||
| `tksv` | tmux kill-server | Terminate all running tmux sessions |
|
|
||||||
| `tkss` | tmux kill-session -t | Terminate named running tmux session |
|
| `tkss` | tmux kill-session -t | Terminate named running tmux session |
|
||||||
|
| `tksv` | tmux kill-server | Terminate all running tmux sessions |
|
||||||
|
| `tl` | tmux list-sessions | Displays a list of running tmux sessions |
|
||||||
| `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session |
|
| `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session |
|
||||||
| `tmuxconf` | `$EDITOR $ZSH_TMUX_CONFIG` | Open .tmux.conf file with an editor |
|
| `tmuxconf` | `$EDITOR $ZSH_TMUX_CONFIG` | Open .tmux.conf file with an editor |
|
||||||
| `tds` | `_tmux_directory_session` | Creates or attaches to a session for the current path |
|
| `ts` | tmux new-session -s | Create a new named tmux session |
|
||||||
|
|
||||||
## Configuration Variables
|
## Configuration Variables
|
||||||
|
|
||||||
| Variable | Description |
|
| Variable | Description |
|
||||||
| ----------------------------------- | ------------------------------------------------------------------------------------------- |
|
| ----------------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
||||||
| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) |
|
| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) |
|
||||||
| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) |
|
| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) |
|
||||||
| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) |
|
| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) |
|
||||||
| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) |
|
| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) |
|
||||||
| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support |
|
| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`, `$XDG_CONFIG_HOME/tmux/tmux.conf`) |
|
||||||
| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) |
|
| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled |
|
||||||
| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) |
|
| `ZSH_TMUX_AUTONAME_SESSION` | Automatically name new sessions based on the basename of `$PWD` (default: `false`) |
|
||||||
| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` |
|
| `ZSH_TMUX_DETACHED` | Set the detached mode (default: `false`) |
|
||||||
| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`, `$XDG_CONFIG_HOME/tmux/tmux.conf`) |
|
| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support |
|
||||||
| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode |
|
| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `tmux` if available, `screen` otherwise) |
|
||||||
| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled |
|
| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `tmux-256color` if available, `screen-256color` otherwise) |
|
||||||
|
| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) |
|
||||||
|
| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode |
|
||||||
|
|
|
||||||
|
|
@ -13,18 +13,30 @@ fi
|
||||||
: ${ZSH_TMUX_AUTOCONNECT:=true}
|
: ${ZSH_TMUX_AUTOCONNECT:=true}
|
||||||
# Automatically close the terminal when tmux exits
|
# Automatically close the terminal when tmux exits
|
||||||
: ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART}
|
: ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART}
|
||||||
|
# Automatically name the new session based on the basename of PWD
|
||||||
|
: ${ZSH_TMUX_AUTONAME_SESSION:=false}
|
||||||
# Set term to screen or screen-256color based on current terminal support
|
# Set term to screen or screen-256color based on current terminal support
|
||||||
|
: ${ZSH_TMUX_DETACHED:=false}
|
||||||
|
# Set detached mode
|
||||||
: ${ZSH_TMUX_FIXTERM:=true}
|
: ${ZSH_TMUX_FIXTERM:=true}
|
||||||
# Set '-CC' option for iTerm2 tmux integration
|
# Set '-CC' option for iTerm2 tmux integration
|
||||||
: ${ZSH_TMUX_ITERM2:=false}
|
: ${ZSH_TMUX_ITERM2:=false}
|
||||||
# The TERM to use for non-256 color terminals.
|
# The TERM to use for non-256 color terminals.
|
||||||
# Tmux states this should be screen, but you may need to change it on
|
# Tmux states this should be tmux|screen, but you may need to change it on
|
||||||
# systems without the proper terminfo
|
# systems without the proper terminfo
|
||||||
: ${ZSH_TMUX_FIXTERM_WITHOUT_256COLOR:=screen}
|
if [[ -e /usr/share/terminfo/t/tmux ]]; then
|
||||||
|
: ${ZSH_TMUX_FIXTERM_WITHOUT_256COLOR:=tmux}
|
||||||
|
else
|
||||||
|
: ${ZSH_TMUX_FIXTERM_WITHOUT_256COLOR:=screen}
|
||||||
|
fi
|
||||||
# The TERM to use for 256 color terminals.
|
# The TERM to use for 256 color terminals.
|
||||||
# Tmux states this should be screen-256color, but you may need to change it on
|
# Tmux states this should be (tmux|screen)-256color, but you may need to change it on
|
||||||
# systems without the proper terminfo
|
# systems without the proper terminfo
|
||||||
: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color}
|
if [[ -e /usr/share/terminfo/t/tmux-256color ]]; then
|
||||||
|
: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=tmux-256color}
|
||||||
|
else
|
||||||
|
: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color}
|
||||||
|
fi
|
||||||
# Set the configuration path
|
# Set the configuration path
|
||||||
if [[ -e $HOME/.tmux.conf ]]; then
|
if [[ -e $HOME/.tmux.conf ]]; then
|
||||||
: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
|
: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
|
||||||
|
|
@ -37,14 +49,27 @@ fi
|
||||||
: ${ZSH_TMUX_UNICODE:=false}
|
: ${ZSH_TMUX_UNICODE:=false}
|
||||||
|
|
||||||
# ALIASES
|
# ALIASES
|
||||||
alias ta='tmux attach -t'
|
function _build_tmux_alias {
|
||||||
alias tad='tmux attach -d -t'
|
eval "function $1 {
|
||||||
alias ts='tmux new-session -s'
|
if [[ -z \$1 ]] || [[ \${1:0:1} == '-' ]]; then
|
||||||
alias tl='tmux list-sessions'
|
tmux $2 \"\$@\"
|
||||||
|
else
|
||||||
|
tmux $2 $3 \"\$@\"
|
||||||
|
fi
|
||||||
|
}"
|
||||||
|
}
|
||||||
|
|
||||||
alias tksv='tmux kill-server'
|
alias tksv='tmux kill-server'
|
||||||
alias tkss='tmux kill-session -t'
|
alias tl='tmux list-sessions'
|
||||||
alias tmuxconf='$EDITOR $ZSH_TMUX_CONFIG'
|
alias tmuxconf='$EDITOR $ZSH_TMUX_CONFIG'
|
||||||
|
|
||||||
|
_build_tmux_alias "ta" "attach" "-t"
|
||||||
|
_build_tmux_alias "tad" "attach -d" "-t"
|
||||||
|
_build_tmux_alias "ts" "new-session" "-s"
|
||||||
|
_build_tmux_alias "tkss" "kill-session" "-t"
|
||||||
|
|
||||||
|
unfunction _build_tmux_alias
|
||||||
|
|
||||||
# Determine if the terminal supports 256 colors
|
# Determine if the terminal supports 256 colors
|
||||||
if [[ $terminfo[colors] == 256 ]]; then
|
if [[ $terminfo[colors] == 256 ]]; then
|
||||||
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
|
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
|
||||||
|
|
@ -77,11 +102,26 @@ function _zsh_tmux_plugin_run() {
|
||||||
[[ "$ZSH_TMUX_ITERM2" == "true" ]] && tmux_cmd+=(-CC)
|
[[ "$ZSH_TMUX_ITERM2" == "true" ]] && tmux_cmd+=(-CC)
|
||||||
[[ "$ZSH_TMUX_UNICODE" == "true" ]] && tmux_cmd+=(-u)
|
[[ "$ZSH_TMUX_UNICODE" == "true" ]] && tmux_cmd+=(-u)
|
||||||
|
|
||||||
# Try to connect to an existing session.
|
local _detached=""
|
||||||
if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then
|
[[ "$ZSH_TMUX_DETACHED" == "true" ]] && _detached="-d"
|
||||||
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach -t $ZSH_TMUX_DEFAULT_SESSION_NAME
|
|
||||||
|
local session_name
|
||||||
|
if [[ "$ZSH_TMUX_AUTONAME_SESSION" == "true" ]]; then
|
||||||
|
# Name the session after the basename of the current directory
|
||||||
|
session_name=${PWD##*/}
|
||||||
|
# If the current directory is the home directory, name it 'HOME'
|
||||||
|
[[ "$PWD" == "$HOME" ]] && session_name="HOME"
|
||||||
|
# If the current directory is the root directory, name it 'ROOT'
|
||||||
|
[[ "$PWD" == "/" ]] && session_name="ROOT"
|
||||||
else
|
else
|
||||||
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach
|
session_name="$ZSH_TMUX_DEFAULT_SESSION_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Try to connect to an existing session.
|
||||||
|
if [[ -n "$session_name" ]]; then
|
||||||
|
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached -t "$session_name"
|
||||||
|
else
|
||||||
|
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If failed, just run tmux, fixing the TERM variable if requested.
|
# If failed, just run tmux, fixing the TERM variable if requested.
|
||||||
|
|
@ -91,8 +131,9 @@ function _zsh_tmux_plugin_run() {
|
||||||
elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then
|
elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then
|
||||||
tmux_cmd+=(-f "$ZSH_TMUX_CONFIG")
|
tmux_cmd+=(-f "$ZSH_TMUX_CONFIG")
|
||||||
fi
|
fi
|
||||||
if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then
|
|
||||||
$tmux_cmd new-session -s $ZSH_TMUX_DEFAULT_SESSION_NAME
|
if [[ -n "$session_name" ]]; then
|
||||||
|
$tmux_cmd new-session -s "$session_name"
|
||||||
else
|
else
|
||||||
$tmux_cmd new-session
|
$tmux_cmd new-session
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ _global_commands=(
|
||||||
)
|
)
|
||||||
|
|
||||||
_yarn_find_package_json() {
|
_yarn_find_package_json() {
|
||||||
local dir=$(cd "$1" && pwd)
|
local dir=$(builtin cd "$1" && pwd)
|
||||||
|
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
|
|
@ -109,7 +109,7 @@ _yarn_commands_scripts() {
|
||||||
|
|
||||||
if [[ -n $opt_args[--cwd] ]]; then
|
if [[ -n $opt_args[--cwd] ]]; then
|
||||||
packageJson=$(_yarn_find_package_json $opt_args[--cwd])
|
packageJson=$(_yarn_find_package_json $opt_args[--cwd])
|
||||||
binaries=($(cd $opt_args[--cwd] && echo node_modules/.bin/*(x:t)))
|
binaries=($(builtin cd $opt_args[--cwd] && echo node_modules/.bin/*(x:t)))
|
||||||
else
|
else
|
||||||
packageJson=$(_yarn_find_package_json $pwd)
|
packageJson=$(_yarn_find_package_json $pwd)
|
||||||
binaries=($(echo node_modules/.bin/*(x:t)))
|
binaries=($(echo node_modules/.bin/*(x:t)))
|
||||||
|
|
@ -130,9 +130,9 @@ _yarn_scripts() {
|
||||||
if [[ -n $_yarn_run_cwd ]]; then
|
if [[ -n $_yarn_run_cwd ]]; then
|
||||||
packageJson=$(_yarn_find_package_json $_yarn_run_cwd)
|
packageJson=$(_yarn_find_package_json $_yarn_run_cwd)
|
||||||
if [[ -d "${_yarn_run_cwd}/node_modules" ]]; then
|
if [[ -d "${_yarn_run_cwd}/node_modules" ]]; then
|
||||||
binaries=($(cd $_yarn_run_cwd && echo node_modules/.bin/*(x:t)))
|
binaries=($(builtin cd $_yarn_run_cwd && echo node_modules/.bin/*(x:t)))
|
||||||
else
|
else
|
||||||
binaries=($(cd $_yarn_run_cwd && yarn bin | perl -wln -e 'm{^[^:]+: (\S+)$} and print $1'))
|
binaries=($(builtin cd $_yarn_run_cwd && yarn bin | perl -wln -e 'm{^[^:]+: (\S+)$} and print $1'))
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
packageJson=$(_yarn_find_package_json $pwd)
|
packageJson=$(_yarn_find_package_json $pwd)
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,8 @@ To use it, add `zoxide` to the plugins array in your `.zshrc` file:
|
||||||
```zsh
|
```zsh
|
||||||
plugins=(... zoxide)
|
plugins=(... zoxide)
|
||||||
```
|
```
|
||||||
|
## Overriding `z` Alias
|
||||||
|
|
||||||
|
You can set the `ZOXIDE_CMD_OVERRIDE`, which will be passed to the `--cmd` flag of `zoxide init`. This allows you to set your `z` command to a default of `cd`.
|
||||||
|
|
||||||
**Note:** you have to [install zoxide](https://github.com/ajeetdsouza/zoxide#step-1-install-zoxide) first.
|
**Note:** you have to [install zoxide](https://github.com/ajeetdsouza/zoxide#step-1-install-zoxide) first.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
if (( $+commands[zoxide] )); then
|
if (( $+commands[zoxide] )); then
|
||||||
eval "$(zoxide init zsh)"
|
eval "$(zoxide init --cmd ${ZOXIDE_CMD_OVERRIDE:-z} zsh)"
|
||||||
else
|
else
|
||||||
echo '[oh-my-zsh] zoxide not found, please install it from https://github.com/ajeetdsouza/zoxide'
|
echo '[oh-my-zsh] zoxide not found, please install it from https://github.com/ajeetdsouza/zoxide'
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ prompt_context() {
|
||||||
# Git: branch/detached head, dirty status
|
# Git: branch/detached head, dirty status
|
||||||
prompt_git() {
|
prompt_git() {
|
||||||
(( $+commands[git] )) || return
|
(( $+commands[git] )) || return
|
||||||
if [[ "$(git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]]; then
|
if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
local PL_BRANCH_CHAR
|
local PL_BRANCH_CHAR
|
||||||
|
|
@ -106,12 +106,12 @@ prompt_git() {
|
||||||
}
|
}
|
||||||
local ref dirty mode repo_path
|
local ref dirty mode repo_path
|
||||||
|
|
||||||
if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then
|
if [[ "$(command git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then
|
||||||
repo_path=$(git rev-parse --git-dir 2>/dev/null)
|
repo_path=$(command git rev-parse --git-dir 2>/dev/null)
|
||||||
dirty=$(parse_git_dirty)
|
dirty=$(parse_git_dirty)
|
||||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
|
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
|
||||||
ref="◈ $(git describe --exact-match --tags HEAD 2> /dev/null)" || \
|
ref="◈ $(command git describe --exact-match --tags HEAD 2> /dev/null)" || \
|
||||||
ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
|
ref="➦ $(command git rev-parse --short HEAD 2> /dev/null)"
|
||||||
if [[ -n $dirty ]]; then
|
if [[ -n $dirty ]]; then
|
||||||
prompt_segment yellow black
|
prompt_segment yellow black
|
||||||
else
|
else
|
||||||
|
|
@ -119,8 +119,8 @@ prompt_git() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local ahead behind
|
local ahead behind
|
||||||
ahead=$(git log --oneline @{upstream}.. 2>/dev/null)
|
ahead=$(command git log --oneline @{upstream}.. 2>/dev/null)
|
||||||
behind=$(git log --oneline ..@{upstream} 2>/dev/null)
|
behind=$(command git log --oneline ..@{upstream} 2>/dev/null)
|
||||||
if [[ -n "$ahead" ]] && [[ -n "$behind" ]]; then
|
if [[ -n "$ahead" ]] && [[ -n "$behind" ]]; then
|
||||||
PL_BRANCH_CHAR=$'\u21c5'
|
PL_BRANCH_CHAR=$'\u21c5'
|
||||||
elif [[ -n "$ahead" ]]; then
|
elif [[ -n "$ahead" ]]; then
|
||||||
|
|
@ -163,10 +163,10 @@ prompt_bzr() {
|
||||||
done
|
done
|
||||||
|
|
||||||
local bzr_status status_mod status_all revision
|
local bzr_status status_mod status_all revision
|
||||||
if bzr_status=$(bzr status 2>&1); then
|
if bzr_status=$(command bzr status 2>&1); then
|
||||||
status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m)
|
status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m)
|
||||||
status_all=$(echo -n "$bzr_status" | head -n1 | wc -m)
|
status_all=$(echo -n "$bzr_status" | head -n1 | wc -m)
|
||||||
revision=${$(bzr log -r-1 --log-format line | cut -d: -f1):gs/%/%%}
|
revision=${$(command bzr log -r-1 --log-format line | cut -d: -f1):gs/%/%%}
|
||||||
if [[ $status_mod -gt 0 ]] ; then
|
if [[ $status_mod -gt 0 ]] ; then
|
||||||
prompt_segment yellow black "bzr@$revision ✚"
|
prompt_segment yellow black "bzr@$revision ✚"
|
||||||
else
|
else
|
||||||
|
|
@ -182,13 +182,13 @@ prompt_bzr() {
|
||||||
prompt_hg() {
|
prompt_hg() {
|
||||||
(( $+commands[hg] )) || return
|
(( $+commands[hg] )) || return
|
||||||
local rev st branch
|
local rev st branch
|
||||||
if $(hg id >/dev/null 2>&1); then
|
if $(command hg id >/dev/null 2>&1); then
|
||||||
if $(hg prompt >/dev/null 2>&1); then
|
if $(command hg prompt >/dev/null 2>&1); then
|
||||||
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
|
if [[ $(command hg prompt "{status|unknown}") = "?" ]]; then
|
||||||
# if files are not added
|
# if files are not added
|
||||||
prompt_segment red white
|
prompt_segment red white
|
||||||
st='±'
|
st='±'
|
||||||
elif [[ -n $(hg prompt "{status|modified}") ]]; then
|
elif [[ -n $(command hg prompt "{status|modified}") ]]; then
|
||||||
# if any modification
|
# if any modification
|
||||||
prompt_segment yellow black
|
prompt_segment yellow black
|
||||||
st='±'
|
st='±'
|
||||||
|
|
@ -196,15 +196,15 @@ prompt_hg() {
|
||||||
# if working copy is clean
|
# if working copy is clean
|
||||||
prompt_segment green $CURRENT_FG
|
prompt_segment green $CURRENT_FG
|
||||||
fi
|
fi
|
||||||
echo -n ${$(hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st
|
echo -n ${$(command hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st
|
||||||
else
|
else
|
||||||
st=""
|
st=""
|
||||||
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
|
rev=$(command hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
|
||||||
branch=$(hg id -b 2>/dev/null)
|
branch=$(command hg id -b 2>/dev/null)
|
||||||
if `hg st | grep -q "^\?"`; then
|
if command hg st | command grep -q "^\?"; then
|
||||||
prompt_segment red black
|
prompt_segment red black
|
||||||
st='±'
|
st='±'
|
||||||
elif `hg st | grep -q "^[MA]"`; then
|
elif command hg st | command grep -q "^[MA]"; then
|
||||||
prompt_segment yellow black
|
prompt_segment yellow black
|
||||||
st='±'
|
st='±'
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@ _fishy_collapsed_wd() {
|
||||||
}
|
}
|
||||||
|
|
||||||
local user_color='green'; [ $UID -eq 0 ] && user_color='red'
|
local user_color='green'; [ $UID -eq 0 ] && user_color='red'
|
||||||
PROMPT='%n@%m %{$fg[$user_color]%}$(_fishy_collapsed_wd)%{$reset_color%}%(!.#.>) '
|
local host_color='white'; [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] && host_color='yellow'
|
||||||
|
PROMPT='%{$fg[$user_color]%}%n%{$reset_color%}@%{$fg[$host_color]%}%m %{$fg[$user_color]%}$(_fishy_collapsed_wd)%{$reset_color%}%(!.#.>) '
|
||||||
PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
|
PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
|
||||||
|
|
||||||
local return_status="%{$fg_bold[red]%}%(?..%?)%{$reset_color%}"
|
local return_status="%{$fg_bold[red]%}%(?..%?)%{$reset_color%}"
|
||||||
|
|
|
||||||
|
|
@ -221,11 +221,16 @@ supports_hyperlinks() {
|
||||||
|
|
||||||
# If $TERM_PROGRAM is set, these terminals support hyperlinks
|
# If $TERM_PROGRAM is set, these terminals support hyperlinks
|
||||||
case "$TERM_PROGRAM" in
|
case "$TERM_PROGRAM" in
|
||||||
Hyper|iTerm.app|terminology|WezTerm) return 0 ;;
|
Hyper|iTerm.app|terminology|WezTerm|vscode) return 0 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# kitty supports hyperlinks
|
# These termcap entries support hyperlinks
|
||||||
if [ "$TERM" = xterm-kitty ]; then
|
case "$TERM" in
|
||||||
|
xterm-kitty|alacritty|alacritty-direct) return 0 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# xfce4-terminal supports hyperlinks
|
||||||
|
if [ "$COLORTERM" = "xfce4-terminal" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,16 @@ zstyle -s ':omz:update' mode update_mode || {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Cancel update if:
|
# Cancel update if:
|
||||||
# - the automatic update is disabled.
|
# - the automatic update is disabled
|
||||||
# - the current user doesn't have write permissions nor owns the $ZSH directory.
|
# - the current user doesn't have write permissions nor owns the $ZSH directory
|
||||||
# - is not run from a tty
|
# - is not run from a tty
|
||||||
# - git is unavailable on the system.
|
# - git is unavailable on the system
|
||||||
|
# - $ZSH is not a git repository
|
||||||
if [[ "$update_mode" = disabled ]] \
|
if [[ "$update_mode" = disabled ]] \
|
||||||
|| [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \
|
|| [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \
|
||||||
|| [[ ! -t 1 ]] \
|
|| [[ ! -t 1 ]] \
|
||||||
|| ! command git --version 2>&1 >/dev/null; then
|
|| ! command git --version 2>&1 >/dev/null \
|
||||||
|
|| (builtin cd -q "$ZSH"; ! command git rev-parse --is-inside-work-tree &>/dev/null); then
|
||||||
unset update_mode
|
unset update_mode
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -164,11 +164,16 @@ supports_hyperlinks() {
|
||||||
|
|
||||||
# If $TERM_PROGRAM is set, these terminals support hyperlinks
|
# If $TERM_PROGRAM is set, these terminals support hyperlinks
|
||||||
case "$TERM_PROGRAM" in
|
case "$TERM_PROGRAM" in
|
||||||
Hyper|iTerm.app|terminology|WezTerm) return 0 ;;
|
Hyper|iTerm.app|terminology|WezTerm|vscode) return 0 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# kitty supports hyperlinks
|
# These termcap entries support hyperlinks
|
||||||
if [ "$TERM" = xterm-kitty ]; then
|
case "$TERM" in
|
||||||
|
xterm-kitty|alacritty|alacritty-direct) return 0 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# xfce4-terminal supports hyperlinks
|
||||||
|
if [ "$COLORTERM" = "xfce4-terminal" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,14 @@ fi
|
||||||
|
|
||||||
# Protect against unwanted sourcing
|
# Protect against unwanted sourcing
|
||||||
case "$ZSH_EVAL_CONTEXT" in
|
case "$ZSH_EVAL_CONTEXT" in
|
||||||
*:file) echo "error: this file should not be sourced" && return ;;
|
*:file) echo "error: this file should not be sourced" && return 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Define "$ZSH" if not defined -- in theory this should be `export`ed by the calling script
|
||||||
|
if [[ -z "$ZSH" ]]; then
|
||||||
|
ZSH="${0:a:h:h}"
|
||||||
|
fi
|
||||||
|
|
||||||
cd "$ZSH"
|
cd "$ZSH"
|
||||||
|
|
||||||
verbose_mode="default"
|
verbose_mode="default"
|
||||||
|
|
@ -90,11 +95,16 @@ supports_hyperlinks() {
|
||||||
|
|
||||||
# If $TERM_PROGRAM is set, these terminals support hyperlinks
|
# If $TERM_PROGRAM is set, these terminals support hyperlinks
|
||||||
case "$TERM_PROGRAM" in
|
case "$TERM_PROGRAM" in
|
||||||
Hyper|iTerm.app|terminology|WezTerm) return 0 ;;
|
Hyper|iTerm.app|terminology|WezTerm|vscode) return 0 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# kitty supports hyperlinks
|
# These termcap entries support hyperlinks
|
||||||
if [ "$TERM" = xterm-kitty ]; then
|
case "$TERM" in
|
||||||
|
xterm-kitty|alacritty|alacritty-direct) return 0 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# xfce4-terminal supports hyperlinks
|
||||||
|
if [ "$COLORTERM" = "xfce4-terminal" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue