mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-11-27 10:53:03 +01:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34aec8b799 | ||
|
|
82bfc95f7f | ||
|
|
58d76b0c10 |
No files matched your search
@@ -36,6 +36,8 @@ jobs:
|
||||
run: |
|
||||
for file in ./oh-my-zsh.sh \
|
||||
./lib/*.zsh \
|
||||
./functions/* \
|
||||
./completions/_* \
|
||||
./plugins/*/*.plugin.zsh \
|
||||
./plugins/*/_* \
|
||||
./themes/*.zsh-theme; do
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
#compdef omz
|
||||
|
||||
local -a cmds subcmds
|
||||
cmds=(
|
||||
'changelog:Print the changelog'
|
||||
'diagnose:Run configuration diagnostics'
|
||||
'help:Usage information'
|
||||
'plugin:Manage plugins'
|
||||
'pr:Manage Oh My Zsh Pull Requests'
|
||||
'reload:Reload the current zsh session'
|
||||
'shellsaver:Launch a whimsical terminal screensaver'
|
||||
'shop:Open the Oh My Zsh shop'
|
||||
'theme:Manage themes'
|
||||
'update:Update Oh My Zsh'
|
||||
'version:Show the version'
|
||||
)
|
||||
|
||||
if [[ "$words[2]" == (screensaver|shellsaver) ]] && (( CURRENT > 2 )); then
|
||||
_arguments \
|
||||
'1:command:' \
|
||||
'2::scene:(aquarium logo hermit party)' \
|
||||
'--list[List available scenes]' \
|
||||
'--mono[Use the default foreground color]' \
|
||||
'--seconds[Exit after a number of seconds]:seconds:' \
|
||||
'--snapshot[Print a plain-text still]::frame:' \
|
||||
'--help[Show Shellsaver help]'
|
||||
return
|
||||
fi
|
||||
|
||||
if (( CURRENT == 2 )); then
|
||||
_describe 'command' cmds
|
||||
elif (( CURRENT == 3 )); then
|
||||
case "$words[2]" in
|
||||
changelog) local -a refs
|
||||
refs=("${(@f)$(builtin cd -q "$ZSH"; command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
|
||||
_describe 'command' refs ;;
|
||||
plugin) subcmds=(
|
||||
'disable:Disable plugin(s)'
|
||||
'enable:Enable plugin(s)'
|
||||
'info:Get plugin information'
|
||||
'list:List plugins'
|
||||
'load:Load plugin(s)'
|
||||
)
|
||||
_describe 'command' subcmds ;;
|
||||
pr) subcmds=('clean:Delete all Pull Request branches' 'test:Test a Pull Request')
|
||||
_describe 'command' subcmds ;;
|
||||
theme) subcmds=('list:List themes' 'set:Set a theme in your .zshrc file' 'use:Load a theme')
|
||||
_describe 'command' subcmds ;;
|
||||
esac
|
||||
elif (( CURRENT == 4 )); then
|
||||
case "${words[2]}::${words[3]}" in
|
||||
plugin::(disable|enable|load))
|
||||
local -aU valid_plugins
|
||||
|
||||
if [[ "${words[3]}" = disable ]]; then
|
||||
# if command is "disable", only offer already enabled plugins
|
||||
valid_plugins=($plugins)
|
||||
else
|
||||
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||
# if command is "enable", remove already enabled plugins
|
||||
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
|
||||
fi
|
||||
|
||||
_describe 'plugin' valid_plugins ;;
|
||||
plugin::info)
|
||||
local -aU plugins
|
||||
plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||
_describe 'plugin' plugins ;;
|
||||
plugin::list)
|
||||
local -a opts
|
||||
opts=('--enabled:List enabled plugins only')
|
||||
_describe -o 'options' opts ;;
|
||||
theme::(set|use))
|
||||
local -aU themes
|
||||
themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
|
||||
_describe 'theme' themes ;;
|
||||
esac
|
||||
elif (( CURRENT > 4 )); then
|
||||
case "${words[2]}::${words[3]}" in
|
||||
plugin::(enable|disable|load))
|
||||
local -aU valid_plugins
|
||||
|
||||
if [[ "${words[3]}" = disable ]]; then
|
||||
# if command is "disable", only offer already enabled plugins
|
||||
valid_plugins=($plugins)
|
||||
else
|
||||
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||
# if command is "enable", remove already enabled plugins
|
||||
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
|
||||
fi
|
||||
|
||||
# Remove plugins already passed as arguments
|
||||
# NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which
|
||||
# has a space after them. This is to avoid removing plugins partially passed, which makes
|
||||
# the completion not add a space after the completed plugin.
|
||||
local -a args
|
||||
args=(${words[4,$(( CURRENT - 1))]})
|
||||
valid_plugins=(${valid_plugins:|args})
|
||||
|
||||
_describe 'plugin' valid_plugins ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
return 0
|
||||
+4
-114
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
function omz {
|
||||
setopt localoptions noksharrays
|
||||
[[ $# -gt 0 ]] || {
|
||||
@@ -20,116 +18,6 @@ function omz {
|
||||
_omz::$command "$@"
|
||||
}
|
||||
|
||||
function _omz {
|
||||
local -a cmds subcmds
|
||||
cmds=(
|
||||
'changelog:Print the changelog'
|
||||
'diagnose:Run configuration diagnostics'
|
||||
'help:Usage information'
|
||||
'plugin:Manage plugins'
|
||||
'pr:Manage Oh My Zsh Pull Requests'
|
||||
'reload:Reload the current zsh session'
|
||||
'shellsaver:Launch a whimsical terminal screensaver'
|
||||
'shop:Open the Oh My Zsh shop'
|
||||
'theme:Manage themes'
|
||||
'update:Update Oh My Zsh'
|
||||
'version:Show the version'
|
||||
)
|
||||
|
||||
if [[ "$words[2]" == (screensaver|shellsaver) ]] && (( CURRENT > 2 )); then
|
||||
_arguments \
|
||||
'1:command:' \
|
||||
'2::scene:(aquarium logo hermit party)' \
|
||||
'--list[List available scenes]' \
|
||||
'--mono[Use the default foreground color]' \
|
||||
'--seconds[Exit after a number of seconds]:seconds:' \
|
||||
'--snapshot[Print a plain-text still]::frame:' \
|
||||
'--help[Show Shellsaver help]'
|
||||
return
|
||||
fi
|
||||
|
||||
if (( CURRENT == 2 )); then
|
||||
_describe 'command' cmds
|
||||
elif (( CURRENT == 3 )); then
|
||||
case "$words[2]" in
|
||||
changelog) local -a refs
|
||||
refs=("${(@f)$(builtin cd -q "$ZSH"; command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
|
||||
_describe 'command' refs ;;
|
||||
plugin) subcmds=(
|
||||
'disable:Disable plugin(s)'
|
||||
'enable:Enable plugin(s)'
|
||||
'info:Get plugin information'
|
||||
'list:List plugins'
|
||||
'load:Load plugin(s)'
|
||||
)
|
||||
_describe 'command' subcmds ;;
|
||||
pr) subcmds=('clean:Delete all Pull Request branches' 'test:Test a Pull Request')
|
||||
_describe 'command' subcmds ;;
|
||||
theme) subcmds=('list:List themes' 'set:Set a theme in your .zshrc file' 'use:Load a theme')
|
||||
_describe 'command' subcmds ;;
|
||||
esac
|
||||
elif (( CURRENT == 4 )); then
|
||||
case "${words[2]}::${words[3]}" in
|
||||
plugin::(disable|enable|load))
|
||||
local -aU valid_plugins
|
||||
|
||||
if [[ "${words[3]}" = disable ]]; then
|
||||
# if command is "disable", only offer already enabled plugins
|
||||
valid_plugins=($plugins)
|
||||
else
|
||||
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||
# if command is "enable", remove already enabled plugins
|
||||
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
|
||||
fi
|
||||
|
||||
_describe 'plugin' valid_plugins ;;
|
||||
plugin::info)
|
||||
local -aU plugins
|
||||
plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||
_describe 'plugin' plugins ;;
|
||||
plugin::list)
|
||||
local -a opts
|
||||
opts=('--enabled:List enabled plugins only')
|
||||
_describe -o 'options' opts ;;
|
||||
theme::(set|use))
|
||||
local -aU themes
|
||||
themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
|
||||
_describe 'theme' themes ;;
|
||||
esac
|
||||
elif (( CURRENT > 4 )); then
|
||||
case "${words[2]}::${words[3]}" in
|
||||
plugin::(enable|disable|load))
|
||||
local -aU valid_plugins
|
||||
|
||||
if [[ "${words[3]}" = disable ]]; then
|
||||
# if command is "disable", only offer already enabled plugins
|
||||
valid_plugins=($plugins)
|
||||
else
|
||||
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||
# if command is "enable", remove already enabled plugins
|
||||
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
|
||||
fi
|
||||
|
||||
# Remove plugins already passed as arguments
|
||||
# NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which
|
||||
# has a space after them. This is to avoid removing plugins partially passed, which makes
|
||||
# the completion not add a space after the completed plugin.
|
||||
local -a args
|
||||
args=(${words[4,$(( CURRENT - 1))]})
|
||||
valid_plugins=(${valid_plugins:|args})
|
||||
|
||||
_describe 'plugin' valid_plugins ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# If run from a script, do not set the completion function
|
||||
if (( ${+functions[compdef]} )); then
|
||||
compdef _omz omz
|
||||
fi
|
||||
|
||||
## Utility functions
|
||||
|
||||
function _omz::confirm {
|
||||
@@ -392,8 +280,8 @@ function _omz::plugin::enable {
|
||||
|
||||
# Enable plugins awk script
|
||||
local awk_script="
|
||||
# if plugins=() is in oneline form (empty or not), substitute ) with new plugins and go to the next line
|
||||
/^[ \t]*plugins=\([^#]*\).*\$/ {
|
||||
# if plugins=() is in oneline form, substitute ) with new plugins and go to the next line
|
||||
/^[ \t]*plugins=\([^#]+\).*\$/ {
|
||||
sub(/\)/, \" $add_plugins&\")
|
||||
print \$0
|
||||
next
|
||||
@@ -999,3 +887,5 @@ function _omz::version {
|
||||
printf "%s (%s)\n" "$version" "$commit"
|
||||
)
|
||||
}
|
||||
|
||||
omz "$@"
|
||||
@@ -1,4 +1,4 @@
|
||||
# diagnostics.zsh
|
||||
# omz_diagnostic_dump
|
||||
#
|
||||
# Diagnostic and debugging support for oh-my-zsh
|
||||
|
||||
@@ -351,3 +351,5 @@ function _omz_diag_dump_os_specific_version() {
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
omz_diagnostic_dump "$@"
|
||||
@@ -78,6 +78,10 @@ fpath=($ZSH/{functions,completions} $ZSH_CUSTOM/{functions,completions} $fpath)
|
||||
# Load all stock functions (from $fpath files) called below.
|
||||
autoload -U compaudit compinit zrecompile
|
||||
|
||||
# The omz CLI and omz_diagnostic_dump are loaded on first use; -z keeps
|
||||
# zsh-style loading under kshautoload so the trailing call runs once
|
||||
autoload -Uz omz omz_diagnostic_dump
|
||||
|
||||
is_plugin() {
|
||||
local base_dir=$1
|
||||
local name=$2
|
||||
|
||||
@@ -35,8 +35,7 @@ plugins=(... aws)
|
||||
|
||||
* `aws_change_access_key`: changes the AWS access key of a profile.
|
||||
|
||||
* `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`) and
|
||||
`$AWS_SHARED_CREDENTIALS_FILE` (default: `~/.aws/credentials`).
|
||||
* `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`).
|
||||
Used to provide completion for the `asp` function.
|
||||
|
||||
* `aws_regions`: lists the available regions.
|
||||
|
||||
@@ -42,7 +42,7 @@ function asp() {
|
||||
export AWS_PROFILE=$1
|
||||
export AWS_EB_PROFILE=$1
|
||||
|
||||
export AWS_PROFILE_REGION=$(_aws_profile_region "$1")
|
||||
export AWS_PROFILE_REGION=$(aws configure get region)
|
||||
|
||||
_aws_update_state
|
||||
|
||||
@@ -239,47 +239,9 @@ function aws_regions() {
|
||||
}
|
||||
|
||||
function aws_profiles() {
|
||||
emulate -L zsh
|
||||
local config="${AWS_CONFIG_FILE:-$HOME/.aws/config}"
|
||||
local creds="${AWS_SHARED_CREDENTIALS_FILE:-$HOME/.aws/credentials}"
|
||||
# Read the files directly; the AWS CLI is slow to start
|
||||
if [[ ! -r "$config" && ! -r "$creds" ]]; then
|
||||
aws --no-cli-pager configure list-profiles 2> /dev/null
|
||||
return
|
||||
fi
|
||||
local line words
|
||||
# Only read the section headers, so the credentials never enter the shell
|
||||
for line in "${(@f)$(command grep -h '^[[:space:]]*\[' -- "$config" "$creds" 2> /dev/null)}"; do
|
||||
line=${line#*\[} # drop up to the first [
|
||||
line=${line%\]*} # drop from the last ] (comments, CR)
|
||||
words=(${=line})
|
||||
if (( $#words == 1 )); then
|
||||
print -r -- $words[1] # [default], or [foo] in the credentials file
|
||||
elif (( $#words == 2 )) && [[ $words[1] == profile ]]; then
|
||||
print -r -- $words[2]
|
||||
fi
|
||||
done | command sort -u
|
||||
}
|
||||
|
||||
# Read a profile's region from the config file, falling back to the AWS CLI
|
||||
function _aws_profile_region() {
|
||||
emulate -L zsh
|
||||
local config="${AWS_CONFIG_FILE:-$HOME/.aws/config}" line words in_profile
|
||||
if [[ -r "$config" ]]; then
|
||||
# Only read headers and region lines, so any credentials never enter the shell
|
||||
for line in "${(@f)$(command grep -e '\[' -e region -- "$config" 2> /dev/null)}"; do
|
||||
line=${line%$'\r'}
|
||||
words=(${=line//[\[\]=]/ }) # "[profile foo]" -> (profile foo), "region = x" -> (region x)
|
||||
if [[ ${${=line}[1]} == \[* ]]; then # header, possibly indented
|
||||
in_profile=
|
||||
[[ "$words" == "profile $1" || ( $1 == default && "$words" == default ) ]] && in_profile=1
|
||||
elif [[ -n $in_profile && $words[1] == region ]]; then
|
||||
print -r -- $words[2]
|
||||
return
|
||||
fi
|
||||
done
|
||||
fi
|
||||
aws configure get region
|
||||
aws --no-cli-pager configure list-profiles 2> /dev/null && return
|
||||
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
|
||||
command grep -Eo '^[[:space:]]*\[[[:space:]]*(profile[[:space:]]+)?[^][:space:]]+[[:space:]]*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | command sed -E 's/^[[:space:]]*\[[[:space:]]*(profile[[:space:]]+)?([^][:space:]]+)[[:space:]]*\]$/\2/'
|
||||
}
|
||||
|
||||
function _aws_regions() {
|
||||
@@ -323,7 +285,7 @@ if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||
export AWS_PROFILE="$AWS_DEFAULT_PROFILE"
|
||||
export AWS_EB_PROFILE="$AWS_DEFAULT_PROFILE"
|
||||
|
||||
test -z "${aws_state[2]}" && AWS_REGION=$(_aws_profile_region "$AWS_PROFILE")
|
||||
test -z "${aws_state[2]}" && AWS_REGION=$(aws configure get region)
|
||||
|
||||
export AWS_REGION=${AWS_REGION:-$aws_state[2]}
|
||||
export AWS_DEFAULT_REGION="$AWS_REGION"
|
||||
|
||||
@@ -90,7 +90,6 @@ colorize_less() {
|
||||
# (e.g. when not scrolled to the bottom) while already the next file will be displayed.
|
||||
local LESSOPEN="| zsh -c 'source \"$ZSH_COLORIZE_PLUGIN_PATH\"; \
|
||||
ZSH_COLORIZE_TOOL=$ZSH_COLORIZE_TOOL ZSH_COLORIZE_STYLE=$ZSH_COLORIZE_STYLE \
|
||||
ZSH_COLORIZE_CHROMA_FORMATTER=$ZSH_COLORIZE_CHROMA_FORMATTER \
|
||||
colorize_cat %s 2> /dev/null'"
|
||||
|
||||
# LESSCLOSE will be set to prevent any errors by executing a user script
|
||||
|
||||
@@ -84,7 +84,6 @@ If you use Podman's Docker wrapper, you need to enable legacy completion. See ab
|
||||
| dtop | `docker top` | Display the running processes of a container |
|
||||
| dvi | `docker volume inspect` | Display detailed information about one or more volumes |
|
||||
| dvls | `docker volume ls` | List all the volumes known to docker |
|
||||
| dvrm | `docker volume rm` | Remove one or more volumes |
|
||||
| dvprune | `docker volume prune` | Cleanup dangling volumes |
|
||||
| dxc | `docker container exec` | Run a new command in a running container |
|
||||
| dxcit | `docker container exec -it` | Run a new command in a running container in an interactive shell |
|
||||
@@ -35,7 +35,6 @@ alias dsts='docker stats'
|
||||
alias dtop='docker top'
|
||||
alias dvi='docker volume inspect'
|
||||
alias dvls='docker volume ls'
|
||||
alias dvrm='docker volume rm'
|
||||
alias dvprune='docker volume prune'
|
||||
alias dxc='docker container exec'
|
||||
alias dxcit='docker container exec -it'
|
||||
|
||||
@@ -135,40 +135,9 @@ EOF
|
||||
(*.deb)
|
||||
command mkdir -p "control" "data"
|
||||
ar vx "$full_path" > /dev/null
|
||||
local member= dest= failed=0
|
||||
for member in control.tar.* data.tar.*; do
|
||||
dest="${member%%.*}"
|
||||
case "${member:l}" in
|
||||
(*.tar.gz)
|
||||
(( $+commands[pigz] )) && { tar -I pigz -xvf "$member" -C "$dest" } \
|
||||
|| tar zxvf "$member" -C "$dest" ;;
|
||||
(*.tar.bz2)
|
||||
(( $+commands[pbzip2] )) && { tar -I pbzip2 -xvf "$member" -C "$dest" } \
|
||||
|| tar xvjf "$member" -C "$dest" ;;
|
||||
(*.tar.xz)
|
||||
# .deb members are small, so skip extract()'s pixz fast path and
|
||||
# let tar use its built-in xz support (or a plain pipe).
|
||||
tar --xz --help &> /dev/null \
|
||||
&& tar --xz -xvf "$member" -C "$dest" \
|
||||
|| xzcat "$member" | tar xvf - -C "$dest" ;;
|
||||
(*.tar.zst)
|
||||
tar --zstd --help &> /dev/null \
|
||||
&& tar --zstd -xvf "$member" -C "$dest" \
|
||||
|| zstdcat "$member" | tar xvf - -C "$dest" ;;
|
||||
(*.tar)
|
||||
tar xvf "$member" -C "$dest" ;;
|
||||
(*)
|
||||
echo "extract: cannot extract unexpected .deb member '$member'" >&2
|
||||
failed=1
|
||||
success=1 ;;
|
||||
esac
|
||||
done
|
||||
if (( failed )); then
|
||||
# Keep the archive members so the unexpected one can be inspected.
|
||||
echo "extract: leaving .deb members in place" >&2
|
||||
else
|
||||
command rm *.tar.* debian-binary
|
||||
fi ;;
|
||||
builtin cd -q control; extract ../control.tar.*
|
||||
builtin cd -q ../data; extract ../data.tar.*
|
||||
builtin cd -q ..; command rm *.tar.* debian-binary ;;
|
||||
(*.zst) unzstd --stdout "$full_path" > "${file:t:r}" ;;
|
||||
(*.cab|*.exe) cabextract "$full_path" ;;
|
||||
(*.cpio|*.obscpio) cpio -idmvF "$full_path" ;;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
emulate -L zsh
|
||||
setopt err_return
|
||||
|
||||
for tool in ar lzma unlzma uncompress; do
|
||||
for tool in lzma unlzma uncompress; do
|
||||
(( $+commands[$tool] )) || {
|
||||
print -u2 -r -- "These tests require $tool."
|
||||
exit 1
|
||||
@@ -46,120 +46,6 @@ check_extract() {
|
||||
print -r -- "PASS: $extension ($mode)"
|
||||
}
|
||||
|
||||
# Extracting a .deb must place the control members directly in <name>/control
|
||||
# and the data members directly in <name>/data, whatever their member count.
|
||||
check_deb_extract() {
|
||||
local mode=$1
|
||||
local case_dir="$test_dir/deb-$mode"
|
||||
mkdir -p "$case_dir/source files" "$case_dir/work/target dir" \
|
||||
"$case_dir/src/ctl" "$case_dir/src/data/usr/bin"
|
||||
print -r -- "postinst script" > "$case_dir/src/ctl/postinst"
|
||||
print -r -- "conf:1" > "$case_dir/src/ctl/conffiles"
|
||||
print -r -- "app main" > "$case_dir/src/data/usr/bin/app"
|
||||
tar czf "$case_dir/src/control.tar.gz" -C "$case_dir/src/ctl" conffiles postinst
|
||||
tar czf "$case_dir/src/data.tar.gz" -C "$case_dir/src/data" usr
|
||||
print -r -- "2.0" > "$case_dir/src/debian-binary"
|
||||
(
|
||||
builtin cd "$case_dir/src"
|
||||
rm -f "$case_dir/source files/pkg.deb"
|
||||
ar rS "$case_dir/source files/pkg.deb" debian-binary control.tar.gz data.tar.gz
|
||||
)
|
||||
local archive="$case_dir/source files/pkg.deb"
|
||||
|
||||
builtin cd "$case_dir/work"
|
||||
local base="$PWD/pkg"
|
||||
local -a args
|
||||
case "$mode" in
|
||||
target)
|
||||
args=(-t 'target dir')
|
||||
base="$PWD/target dir/pkg"
|
||||
;;
|
||||
remove) args=(-r) ;;
|
||||
esac
|
||||
|
||||
() {
|
||||
emulate -L zsh
|
||||
extract "${args[@]}" "$archive"
|
||||
} || return 1
|
||||
|
||||
[[ -f "$base/control/conffiles" && -f "$base/control/postinst" ]] ||
|
||||
{ print -u2 -r -- "$mode: control members not extracted into $base/control"; return 1 }
|
||||
[[ -f "$base/data/usr/bin/app" ]] ||
|
||||
{ print -u2 -r -- "$mode: data members not extracted into $base/data"; return 1 }
|
||||
[[ ! -d "$base/control/control" && ! -d "$base/data/data" ]] ||
|
||||
{ print -u2 -r -- "$mode: deb extraction double-nested the member directories"; return 1 }
|
||||
[[ ! -e "$base/control.tar.gz" && ! -e "$base/data.tar.gz" && ! -e "$base/debian-binary" ]] ||
|
||||
{ print -u2 -r -- "$mode: deb member debris left behind"; return 1 }
|
||||
if [[ $mode == remove ]]; then
|
||||
[[ ! -e $archive ]]
|
||||
else
|
||||
[[ -f $archive ]]
|
||||
fi
|
||||
print -r -- "PASS: deb ($mode)"
|
||||
}
|
||||
|
||||
# An unexpected member must be reported and left on disk for inspection, and
|
||||
# the cleanup must not delete the other members around it either.
|
||||
check_deb_unexpected_member() {
|
||||
local case_dir="$test_dir/deb-unexpected"
|
||||
mkdir -p "$case_dir/src/ctl" "$case_dir/src/data/usr/bin"
|
||||
print -r -- "postinst script" > "$case_dir/src/ctl/postinst"
|
||||
print -r -- "app main" > "$case_dir/src/data/usr/bin/app"
|
||||
tar czf "$case_dir/src/control.tar.gz" -C "$case_dir/src/ctl" postinst
|
||||
print -r -- "unknown compression" > "$case_dir/src/control.tar.weird"
|
||||
tar czf "$case_dir/src/data.tar.gz" -C "$case_dir/src/data" usr
|
||||
print -r -- "2.0" > "$case_dir/src/debian-binary"
|
||||
(
|
||||
builtin cd "$case_dir/src"
|
||||
ar rS "$case_dir/pkg.deb" debian-binary control.tar.weird data.tar.gz
|
||||
)
|
||||
|
||||
builtin cd "$case_dir"
|
||||
() {
|
||||
emulate -L zsh
|
||||
extract "$case_dir/pkg.deb"
|
||||
} || return 1
|
||||
|
||||
[[ -f "$case_dir/pkg/data/usr/bin/app" ]] ||
|
||||
{ print -u2 -r -- "deb-unexpected: known members were not extracted"; return 1 }
|
||||
[[ -f "$case_dir/pkg/control.tar.weird" && -f "$case_dir/pkg/data.tar.gz" &&
|
||||
-f "$case_dir/pkg/debian-binary" ]] ||
|
||||
{ print -u2 -r -- "deb-unexpected: archive members were deleted"; return 1 }
|
||||
print -r -- "PASS: deb (unexpected member)"
|
||||
}
|
||||
|
||||
# Passing more than one .deb in a single call must not leak the loop variables
|
||||
# between archives; the stale `member`/`dest` locals used to be printed by the
|
||||
# second archive.
|
||||
check_deb_multiple() {
|
||||
local case_dir="$test_dir/deb-multiple"
|
||||
mkdir -p "$case_dir/src/ctl" "$case_dir/src/data/usr/bin"
|
||||
print -r -- "postinst script" > "$case_dir/src/ctl/postinst"
|
||||
print -r -- "app main" > "$case_dir/src/data/usr/bin/app"
|
||||
tar czf "$case_dir/src/control.tar.gz" -C "$case_dir/src/ctl" postinst
|
||||
tar czf "$case_dir/src/data.tar.gz" -C "$case_dir/src/data" usr
|
||||
print -r -- "2.0" > "$case_dir/src/debian-binary"
|
||||
(
|
||||
builtin cd "$case_dir/src"
|
||||
ar rS "$case_dir/one.deb" debian-binary control.tar.gz data.tar.gz
|
||||
ar rS "$case_dir/two.deb" debian-binary control.tar.gz data.tar.gz
|
||||
)
|
||||
|
||||
builtin cd "$case_dir"
|
||||
local output
|
||||
output=$( () {
|
||||
emulate -L zsh
|
||||
extract one.deb two.deb
|
||||
} 2>&1 ) || return 1
|
||||
|
||||
[[ $output != *member=* && $output != *dest=* ]] ||
|
||||
{ print -u2 -r -- "deb-multiple: stale loop variables were printed"; return 1 }
|
||||
[[ -f one/control/postinst && -f one/data/usr/bin/app &&
|
||||
-f two/control/postinst && -f two/data/usr/bin/app ]] ||
|
||||
{ print -u2 -r -- "deb-multiple: both archives were not extracted"; return 1 }
|
||||
print -r -- "PASS: deb (multiple archives)"
|
||||
}
|
||||
|
||||
{
|
||||
print -r -- hello > "$test_dir/plain"
|
||||
lzma -c "$test_dir/plain" > "$test_dir/fixture.lzma"
|
||||
@@ -172,11 +58,6 @@ check_deb_multiple() {
|
||||
check_extract "$extension" "$mode"
|
||||
done
|
||||
done
|
||||
check_deb_extract default
|
||||
check_deb_extract target
|
||||
check_deb_extract remove
|
||||
check_deb_unexpected_member
|
||||
check_deb_multiple
|
||||
print 'All extract compressed-file tests passed.'
|
||||
} always {
|
||||
builtin cd "$original_dir"
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
# fnox
|
||||
|
||||
Adds shell integration and completions for [fnox](https://github.com/jdx/fnox), a tool for provider-agnostic secret injection.
|
||||
|
||||
## Installation
|
||||
|
||||
[Install fnox](https://fnox.jdx.dev/guide/quick-start.html), then add it to your plugins in `~/.zshrc`:
|
||||
|
||||
```zsh
|
||||
plugins=(fnox)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
See the [fnox documentation](https://fnox.jdx.dev/guide/shell-integration.html) for shell integration and usage.
|
||||
@@ -1,23 +0,0 @@
|
||||
if (( ! $+commands[fnox] )); then
|
||||
# if we don't have fnox at all just bail out
|
||||
return
|
||||
fi
|
||||
|
||||
eval "$(fnox activate zsh)"
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `fnox`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnox" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _fnox
|
||||
_comps[fnox]=_fnox
|
||||
fi
|
||||
|
||||
# Regenerate completions when the executable changes.
|
||||
if [[ ! -s "$ZSH_CACHE_DIR/completions/_fnox" || "$commands[fnox]" -nt "$ZSH_CACHE_DIR/completions/_fnox" ]]; then
|
||||
zmodload -F zsh/files b:zf_mv
|
||||
() {
|
||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._fnox"
|
||||
zf_mv -f -- =( fnox completion zsh ) "$ZSH_CACHE_DIR/completions/_fnox"
|
||||
} &|
|
||||
fi
|
||||
@@ -12,7 +12,7 @@ plugins=(... git-commit)
|
||||
## Syntax
|
||||
|
||||
```zsh
|
||||
git <type> [(-s, --scope) "<scope>"] [(-a, --attention)] [(-b, --body) "<body>"] "<message>"
|
||||
git <type> [(-s, --scope) "<scope>"] [(-a, --attention)] "<message>"
|
||||
```
|
||||
|
||||
Where `type` is one of the following:
|
||||
@@ -30,9 +30,6 @@ Where `type` is one of the following:
|
||||
- `test`
|
||||
- `wip`
|
||||
|
||||
The optional `-b` / `--body` becomes the commit body (a blank line after the subject), as defined by
|
||||
[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary).
|
||||
|
||||
> NOTE: the subcommand 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>`
|
||||
@@ -42,7 +39,6 @@ The optional `-b` / `--body` becomes the commit body (a blank line after the sub
|
||||
| Git subcommand | Command |
|
||||
| --------------------------------------------- | ---------------------------------------------------- |
|
||||
| `git style "remove trailing whitespace"` | `git commit -m "style: remove trailing whitespace"` |
|
||||
| `git wip "work in progress"` | `git commit -m "wip: work in progress"` |
|
||||
| `git wip "work in progress"` | `git commit -m "work in progress"` |
|
||||
| `git fix -s "router" "correct redirect link"` | `git commit -m "fix(router): correct redirect link"` |
|
||||
| `git rev -s "api" "rollback v2"` | `git commit -m "revert(api): rollback v2"` |
|
||||
| `git feat -s "auth" -b "Keep session across redirects." "add login redirect"` | `git commit -m "feat(auth): add login redirect" -m "Keep session across redirects."` |
|
||||
@@ -12,11 +12,11 @@ _omz_git_commit() {
|
||||
if [[ "$_type" == rev ]]; then
|
||||
_type=revert
|
||||
fi
|
||||
local _scope _attention _message _body
|
||||
local _scope _attention _message
|
||||
while [ $# -ne 0 ]; do
|
||||
case $1 in
|
||||
-s | --scope )
|
||||
if [ -z "$2" ]; then
|
||||
if [ -z $2 ]; then
|
||||
echo >&2 "Missing scope!"
|
||||
return 1
|
||||
fi
|
||||
@@ -27,20 +27,12 @@ _omz_git_commit() {
|
||||
_attention="!"
|
||||
shift 1
|
||||
;;
|
||||
-b | --body )
|
||||
if [ -z "$2" ]; then
|
||||
echo >&2 "Missing body!"
|
||||
return 1
|
||||
fi
|
||||
_body="$2"
|
||||
shift 2
|
||||
;;
|
||||
* )
|
||||
_message="${_message} $1"
|
||||
shift 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
git commit -m "${_type}${_scope:+(${_scope})}${_attention}:${_message}" ${_body:+-m} ${_body:+"$_body"}
|
||||
git commit -m "${_type}${_scope:+(${_scope})}${_attention}:${_message}"
|
||||
}
|
||||
_omz_git_commit "$@"
|
||||
@@ -21,7 +21,7 @@ plugins=(... git)
|
||||
| `gapa` | `git add --patch` |
|
||||
| `gau` | `git add --update` |
|
||||
| `gav` | `git add --verbose` |
|
||||
| `gwip` | `git add -A; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"` |
|
||||
| `gwip` | `git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"` |
|
||||
| `gam` | `git am` |
|
||||
| `gama` | `git am --abort` |
|
||||
| `gamc` | `git am --continue` |
|
||||
|
||||
@@ -119,7 +119,7 @@ alias gaa='git add --all'
|
||||
alias gapa='git add --patch'
|
||||
alias gau='git add --update'
|
||||
alias gav='git add --verbose'
|
||||
alias gwip='git add -A; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"'
|
||||
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"'
|
||||
alias gam='git am'
|
||||
alias gama='git am --abort'
|
||||
alias gamc='git am --continue'
|
||||
|
||||
@@ -112,37 +112,6 @@ plugins=(... hcloud)
|
||||
| hcst | `hcloud server-type list` | List all server types |
|
||||
| hcit | `hcloud image list --type system` | List all system images |
|
||||
|
||||
## Prompt function
|
||||
|
||||
This plugin provides `hcloud_prompt_info` which can be added to your prompt to display the current Hetzner Cloud context.
|
||||
|
||||
- If `HCLOUD_TOKEN` environment variable is set, it displays `HCLOUD_TOKEN` (indicating direct token usage)
|
||||
- Otherwise, it displays the active context name
|
||||
|
||||
### Usage
|
||||
|
||||
Add `$(hcloud_prompt_info)` to your `PROMPT` or `RPROMPT` in your `.zshrc`:
|
||||
|
||||
```zsh
|
||||
RPROMPT='$(hcloud_prompt_info)'
|
||||
```
|
||||
|
||||
### Theme variables
|
||||
|
||||
| Variable | Default | Description |
|
||||
| :----------------------------- | :-------------- | :----------------------------------------------- |
|
||||
| `ZSH_THEME_HCLOUD_PREFIX` | `<hcloud:` | Prefix before the context name |
|
||||
| `ZSH_THEME_HCLOUD_SUFFIX` | `>` | Suffix after the context name |
|
||||
| `ZSH_THEME_HCLOUD_TOKEN_TEXT` | `HCLOUD_TOKEN` | Text shown when `HCLOUD_TOKEN` env var is set |
|
||||
|
||||
### Example with custom styling
|
||||
|
||||
```zsh
|
||||
ZSH_THEME_HCLOUD_PREFIX="%{$fg[blue]%}hcloud:("
|
||||
ZSH_THEME_HCLOUD_SUFFIX=")%{$reset_color%}"
|
||||
RPROMPT='$(hcloud_prompt_info)'
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
This plugin requires the [Hetzner Cloud CLI](https://github.com/hetznercloud/cli) to be installed.
|
||||
|
||||
@@ -131,20 +131,3 @@ alias hcdc='hcloud datacenter list'
|
||||
alias hcloc='hcloud location list'
|
||||
alias hcst='hcloud server-type list'
|
||||
alias hcit='hcloud image list --type system'
|
||||
|
||||
# Prompt function to display current hcloud context
|
||||
# Usage: add $(hcloud_prompt_info) to your PROMPT or RPROMPT
|
||||
function hcloud_prompt_info() {
|
||||
# Check if HCLOUD_TOKEN is set (overrides context)
|
||||
if [[ -n "$HCLOUD_TOKEN" ]]; then
|
||||
echo "${ZSH_THEME_HCLOUD_PREFIX=<hcloud:}${ZSH_THEME_HCLOUD_TOKEN_TEXT=HCLOUD_TOKEN}${ZSH_THEME_HCLOUD_SUFFIX=>}"
|
||||
return
|
||||
fi
|
||||
|
||||
# Get active context
|
||||
local context
|
||||
context=$(hcloud context active 2>/dev/null)
|
||||
[[ -n "$context" ]] || return
|
||||
|
||||
echo "${ZSH_THEME_HCLOUD_PREFIX=<hcloud:}${context}${ZSH_THEME_HCLOUD_SUFFIX=>}"
|
||||
}
|
||||
@@ -80,17 +80,3 @@ zstyle ':omz:plugins:laravel' php 'herd php'
|
||||
| `paqr` | `php artisan queue:retry` |
|
||||
| `paqt` | `php artisan queue:table` |
|
||||
| `paqw` | `php artisan queue:work` |
|
||||
|
||||
## Modules
|
||||
|
||||
Aliases for [nWidart/laravel-modules](https://github.com/nWidart/laravel-modules).
|
||||
|
||||
| Alias | Description |
|
||||
|:-:|:-:|
|
||||
| `pamol` | `php artisan module:list` |
|
||||
| `pamomk` | `php artisan module:make` |
|
||||
| `pamoe` | `php artisan module:enable` |
|
||||
| `pamod` | `php artisan module:disable` |
|
||||
| `pamom` | `php artisan module:migrate` |
|
||||
| `pamomr` | `php artisan module:migrate-rollback` |
|
||||
| `pamos` | `php artisan module:seed` |
|
||||
@@ -53,13 +53,4 @@ alias paqr="$_omz_laravel_php artisan queue:retry"
|
||||
alias paqt="$_omz_laravel_php artisan queue:table"
|
||||
alias paqw="$_omz_laravel_php artisan queue:work"
|
||||
|
||||
# Modules (nWidart/laravel-modules)
|
||||
alias pamol="$_omz_laravel_php artisan module:list"
|
||||
alias pamomk="$_omz_laravel_php artisan module:make"
|
||||
alias pamoe="$_omz_laravel_php artisan module:enable"
|
||||
alias pamod="$_omz_laravel_php artisan module:disable"
|
||||
alias pamom="$_omz_laravel_php artisan module:migrate"
|
||||
alias pamomr="$_omz_laravel_php artisan module:migrate-rollback"
|
||||
alias pamos="$_omz_laravel_php artisan module:seed"
|
||||
|
||||
unset _omz_laravel_php
|
||||
@@ -30,7 +30,6 @@ man-command-line() {
|
||||
else
|
||||
BUFFER="man ${args[1]}"
|
||||
fi
|
||||
zle end-of-line
|
||||
}
|
||||
|
||||
zle -N man-command-line
|
||||
|
||||
@@ -30,8 +30,6 @@ if it's found, or the mvn command otherwise.
|
||||
| `mvncisto` | `mvn clean install -DskipTests --offline` |
|
||||
| `mvncom` | `mvn compile` |
|
||||
| `mvncp` | `mvn clean package` |
|
||||
| `mvncpst` | `mvn clean package -DskipTests` |
|
||||
| `mvncpsto` | `mvn clean package -DskipTests --offline` |
|
||||
| `mvnct` | `mvn clean test` |
|
||||
| `mvncv` | `mvn clean verify` |
|
||||
| `mvncvst` | `mvn clean verify -DskipTests` |
|
||||
|
||||
@@ -59,8 +59,6 @@ alias mvncist='mvn clean install -DskipTests'
|
||||
alias mvncisto='mvn clean install -DskipTests --offline'
|
||||
alias mvncom='mvn compile'
|
||||
alias mvncp='mvn clean package'
|
||||
alias mvncpst='mvn clean package -DskipTests'
|
||||
alias mvncpsto='mvn clean package -DskipTests --offline'
|
||||
alias mvnct='mvn clean test'
|
||||
alias mvncv='mvn clean verify'
|
||||
alias mvncvst='mvn clean verify -DskipTests'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Pre-commit plugin
|
||||
|
||||
This plugin adds aliases for common commands of [pre-commit](https://pre-commit.com/).
|
||||
It also supports [prek](https://github.com/j178/prek) as a drop-in replacement.
|
||||
It also supports [prek](https://github.com/prek/prek) as a drop-in replacement.
|
||||
If `prek` is available, it will be used; otherwise, `pre-commit` is used as fallback.
|
||||
|
||||
To use this plugin, add it to the plugins array in your zshrc file:
|
||||
|
||||
@@ -34,8 +34,6 @@ virtual environments:
|
||||
`<venv-name>/bin/activate`, and automatically deactivate it when navigating out of it (keeps venv activated
|
||||
in subdirectories).
|
||||
- To enable the feature, set `PYTHON_AUTO_VRUN=true` before sourcing oh-my-zsh.
|
||||
- To also search parent directories (useful for monorepos), set `PYTHON_AUTO_VRUN_RECURSIVE=true` as well.
|
||||
The search stops before `$HOME`, so a venv in your home directory is not activated in every folder under it.
|
||||
- The plugin activates the first existing virtual environment, in order, appearing in `$PYTHON_VENV_NAMES`.
|
||||
The default virtual environment name is `venv`. To use a different name, set
|
||||
`PYTHON_VENV_NAME=<venv-name>`. For example: `PYTHON_VENV_NAME=".venv"`
|
||||
|
||||
@@ -113,23 +113,8 @@ if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then
|
||||
# make sure we're not in a venv already
|
||||
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
|
||||
source $file > /dev/null 2>&1
|
||||
return
|
||||
break
|
||||
done
|
||||
|
||||
# Search parent directories if recursive mode is enabled, stopping before $HOME
|
||||
if [[ "$PYTHON_AUTO_VRUN_RECURSIVE" == "true" ]]; then
|
||||
local search_dir="$PWD:h"
|
||||
while [[ "$search_dir" != "/" && "$search_dir" != "." && "$search_dir" != "$HOME" ]]; do
|
||||
for file in "${search_dir}/"${^PYTHON_VENV_NAMES[@]}"/bin/activate"(N.); do
|
||||
# the venv found is already active
|
||||
[[ "${file:h:h:A}" == "${VIRTUAL_ENV:A}" ]] && return
|
||||
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
|
||||
source $file > /dev/null 2>&1
|
||||
return
|
||||
done
|
||||
search_dir="${search_dir:h}"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
add-zsh-hook chpwd auto_vrun
|
||||
|
||||
@@ -24,7 +24,7 @@ plugins=(... systemd)
|
||||
| `sc-show-environment` | `systemctl show-environment` | Dump the systemd manager environment block |
|
||||
| `sc-cat` | `systemctl cat` | Show backing files of one or more units |
|
||||
| `sc-list-timers` | `systemctl list-timers` | List timer units currently in memory |
|
||||
| **Privileged aliases** |||
|
||||
| **Aliases with sudo** |||
|
||||
| `sc-start` | `sudo systemctl start` | Start Unit(s) |
|
||||
| `sc-stop` | `sudo systemctl stop` | Stop Unit(s) |
|
||||
| `sc-reload` | `sudo systemctl reload` | Reload Unit(s) |
|
||||
@@ -50,28 +50,6 @@ plugins=(... systemd)
|
||||
| `sc-disable-now` | `sudo systemctl disable --now` | Disable and stop unit(s) |
|
||||
| `sc-mask-now` | `sudo systemctl mask --now` | Mask and stop unit(s) |
|
||||
|
||||
### Privileged aliases
|
||||
|
||||
systemd plugin supports alternative privilege elevation tools. You can prepend an arbitrary string,
|
||||
replacing `sudo`, to the privileged aliases by setting `$ZSH_SYSTEMD_SUDO` variable. You can leave
|
||||
authorization to systemd by setting `$ZSH_SYSTEMD_SUDO` to an empty string.
|
||||
|
||||
To use `doas` as your elevation tool you will need to add the following line to your zshrc;
|
||||
|
||||
```zsh
|
||||
ZSH_SYSTEMD_SUDO="doas"
|
||||
```
|
||||
|
||||
After shell restart, you will see that alias for `sc-enable` is changed:
|
||||
|
||||
```sh
|
||||
$ which sc-enable
|
||||
sc-enable: aliased to doas systemctl enable
|
||||
```
|
||||
|
||||
These aliases are evaluated during oh-my-zsh startup, and can't be changed interactively (you will
|
||||
need to restart shell to see changes).
|
||||
|
||||
### User aliases
|
||||
|
||||
You can use the above aliases as `--user` by using the prefix `scu` instead of `sc`.
|
||||
|
||||
@@ -67,27 +67,15 @@ power_commands=(
|
||||
suspend
|
||||
)
|
||||
|
||||
if ! [[ -v ZSH_SYSTEMD_SUDO ]]; then
|
||||
ZSH_SYSTEMD_SUDO="sudo"
|
||||
fi
|
||||
|
||||
for c in $user_commands; do
|
||||
alias "sc-$c"="systemctl $c"
|
||||
alias "scu-$c"="systemctl --user $c"
|
||||
done
|
||||
|
||||
# Avoids leading space in alias when using polkit
|
||||
if [[ -n "${ZSH_SYSTEMD_SUDO}" ]]; then
|
||||
for c in $sudo_commands; do
|
||||
alias "sc-$c"="$ZSH_SYSTEMD_SUDO systemctl $c"
|
||||
for c in $sudo_commands; do
|
||||
alias "sc-$c"="sudo systemctl $c"
|
||||
alias "scu-$c"="systemctl --user $c"
|
||||
done
|
||||
else
|
||||
for c in $sudo_commands; do
|
||||
alias "sc-$c"="systemctl $c"
|
||||
alias "scu-$c"="systemctl --user $c"
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
for c in $power_commands; do
|
||||
alias "sc-$c"="systemctl $c"
|
||||
@@ -95,6 +83,7 @@ done
|
||||
|
||||
unset c user_commands sudo_commands power_commands
|
||||
|
||||
|
||||
# --now commands
|
||||
alias sc-enable-now="sc-enable --now"
|
||||
alias sc-disable-now="sc-disable --now"
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
# talosctl plugin
|
||||
|
||||
This plugin adds completion for the [talosctl](https://docs.siderolabs.com/talos/v1.12/learn-more/talosctl) CLI for managing [Talos](https://github.com/siderolabs/talos) Linux.
|
||||
|
||||
To use it, add `talosctl` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... talosctl)
|
||||
```
|
||||
|
||||
This plugin does not add any aliases.
|
||||
|
||||
## Cache
|
||||
|
||||
This plugin caches the completion script and is automatically updated asynchronously when the plugin is
|
||||
loaded, which is usually when you start up a new terminal emulator.
|
||||
|
||||
The cache is stored at:
|
||||
|
||||
- `$ZSH_CACHE/completions/_talosctl` completions script
|
||||
@@ -1,18 +0,0 @@
|
||||
# Autocompletion for talosctl
|
||||
if (( ! $+commands[talosctl] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `talosctl`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_talosctl" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _talosctl
|
||||
_comps[talosctl]=_talosctl
|
||||
fi
|
||||
|
||||
zmodload -F zsh/files b:zf_mv
|
||||
() {
|
||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._talosctl"
|
||||
zf_mv -f -- =( talosctl completion zsh ) "$ZSH_CACHE_DIR/completions/_talosctl"
|
||||
} &|
|
||||
@@ -1,53 +0,0 @@
|
||||
# Terragrunt plugin
|
||||
|
||||
Terragrunt is a thin wrapper for opentofu/terraform that provides extra tools
|
||||
and features to enhance the management of Infrastructure as Code (IaC) using
|
||||
opentofu/terraform. This plugin adds completion for `terragrunt` command, as well
|
||||
as aliases and a prompt function.
|
||||
|
||||
To use it, add `terragrunt` to the plugins array of your `~/.zshrc` file:
|
||||
|
||||
```shell
|
||||
plugins=(... terragrunt)
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Terragrunt](https://docs.terragrunt.com/) v0.77.22 or later
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command |
|
||||
| ------ | ----------------------------------------- |
|
||||
| `tg` | `terragrunt` |
|
||||
| `tga` | `terragrunt run -- apply` |
|
||||
| `tgaa` | `terragrunt run -- apply -auto-approve` |
|
||||
| `tgc` | `terragrunt run -- console` |
|
||||
| `tgd` | `terragrunt run -- destroy` |
|
||||
| `tgd!` | `terragrunt run -- destroy -auto-approve` |
|
||||
| `tgi` | `terragrunt run -- init` |
|
||||
| `tgo` | `terragrunt run -- output` |
|
||||
| `tgp` | `terragrunt run -- plan` |
|
||||
| `tgv` | `terragrunt run -- validate` |
|
||||
| `tgs` | `terragrunt run -- state` |
|
||||
| `tgsh` | `terragrunt run -- show` |
|
||||
| `tgr` | `terragrunt run -- refresh` |
|
||||
| `tgt` | `terragrunt run -- test` |
|
||||
| `tgws` | `terragrunt run -- workspace` |
|
||||
|
||||
## Prompt function
|
||||
|
||||
- `terragrunt_version_prompt_info` shows the current version of the `terragrunt` command.
|
||||
|
||||
To use it, add it to a `PROMPT` or `RPROMPT` variable in your theme or `.zshrc` file.
|
||||
|
||||
```sh
|
||||
RPROMPT='$(terragrunt_version_prompt_info)'
|
||||
```
|
||||
|
||||
You can also specify the PREFIX and SUFFIX strings with the following variables.
|
||||
|
||||
```sh
|
||||
ZSH_THEME_TERRAGRUNT_VERSION_PROMPT_PREFIX="%{$fg[white]%}"
|
||||
ZSH_THEME_TERRAGRUNT_VERSION_PROMPT_SUFFIX="%{$reset_color%}"
|
||||
```
|
||||
@@ -1,27 +0,0 @@
|
||||
# set up the terragrunt completion (compatible for zsh)
|
||||
autoload -Uz bashcompinit && bashcompinit
|
||||
complete -C terragrunt terragrunt
|
||||
|
||||
# terragrunt version prompt function
|
||||
function terragrunt_version_prompt_info() {
|
||||
# get the output of `terragrunt --version` in a single line, and get the third word after splitting by a space
|
||||
local terragrunt_version=${${(s: :)$(terragrunt --version)}[3]}
|
||||
# make sure to escape % signs in the version string to prevent command injection
|
||||
echo "${ZSH_THEME_TERRAGRUNT_VERSION_PROMPT_PREFIX-[}${terragrunt_version:gs/%/%%}${ZSH_THEME_TERRAGRUNT_VERSION_PROMPT_SUFFIX-]}"
|
||||
}
|
||||
|
||||
alias tg='terragrunt'
|
||||
alias tga='terragrunt run -- apply'
|
||||
alias tgaa='terragrunt run -- apply -auto-approve'
|
||||
alias tgc='terragrunt run -- console'
|
||||
alias tgd='terragrunt run -- destroy'
|
||||
alias tgd!='terragrunt run -- destroy -auto-approve'
|
||||
alias tgi='terragrunt run -- init'
|
||||
alias tgo='terragrunt run -- output'
|
||||
alias tgp='terragrunt run -- plan'
|
||||
alias tgv='terragrunt run -- validate'
|
||||
alias tgs='terragrunt run -- state'
|
||||
alias tgsh='terragrunt run -- show'
|
||||
alias tgr='terragrunt run -- refresh'
|
||||
alias tgt='terragrunt run -- test'
|
||||
alias tgws='terragrunt run -- workspace'
|
||||
@@ -11,7 +11,6 @@ tldr-command-line() {
|
||||
args=(${${(Az)BUFFER}[1]} ${${(Az)BUFFER}[2]})
|
||||
|
||||
BUFFER="tldr ${args[1]}"
|
||||
zle end-of-line
|
||||
}
|
||||
|
||||
zle -N tldr-command-line
|
||||
|
||||
@@ -22,7 +22,7 @@ plugins=(... uv)
|
||||
| uvlu | `uv lock --upgrade` | Lock the dependencies to the newest compatible versions |
|
||||
| uvp | `uv pip` | Manage pip packages |
|
||||
| uvpi | `uv python install` | Install a specific version of python |
|
||||
| uvpl | `uv python list` | List all installed Python versions. |
|
||||
| uvpl | `uv python list` | Lists all python version installed |
|
||||
| uvpp | `uv python pin` | Pin the current project to use a specific Python version |
|
||||
| uvpu | `uv python uninstall` | Remove a specific version of python |
|
||||
| uvpy | `uv python` | Manage Python installs |
|
||||
|
||||
@@ -39,15 +39,6 @@ plugins=(... vi-mode)
|
||||
|
||||
- `VI_MODE_DISABLE_CLIPBOARD`: If set, disables clipboard integration on yank/paste
|
||||
|
||||
Clipboard integration keeps put widgets (`p`/`P`) in sync with the system
|
||||
clipboard, but only while the last copy to the clipboard actually succeeded.
|
||||
If that copy failed — no `xclip`/`xsel`, Wayland without `wl-clipboard`, a dead
|
||||
X forwarding over SSH — the clipboard no longer mirrors what you killed inside
|
||||
the line editor, so puts use the internal kill buffer instead of the stale
|
||||
clipboard contents. After a failed push, puts keep using the kill buffer only
|
||||
while the clipboard still holds exactly what it held when the push failed; a
|
||||
new external copy is picked up again immediately.
|
||||
|
||||
## Mode indicators
|
||||
|
||||
*Normal mode* is indicated with a red `<<<` mark at the right prompt, when it
|
||||
|
||||
@@ -118,15 +118,6 @@ bindkey '^s' history-incremental-search-forward
|
||||
bindkey '^a' beginning-of-line
|
||||
bindkey '^e' end-of-line
|
||||
|
||||
# Snapshot of the clipboard taken when the most recent push to it failed.
|
||||
# While the marker is set, put widgets compare the live clipboard against the
|
||||
# snapshot: unchanged means the clipboard is stale (it never received the
|
||||
# kill), so the internal CUTBUFFER is used instead. As soon as the clipboard
|
||||
# differs again - e.g. an external copy - it is trusted immediately, so
|
||||
# external copies are never lost for longer than the failure itself.
|
||||
typeset -g _OMZ_VI_CLIPBOARD_STALE=""
|
||||
typeset -g _OMZ_VI_CLIPBOARD_STALE_SET=""
|
||||
|
||||
function wrap_clipboard_widgets() {
|
||||
# NB: Assume we are the first wrapper and that we only wrap native widgets
|
||||
# See zsh-autosuggestions.zsh for a more generic and more robust wrapper
|
||||
@@ -141,33 +132,13 @@ function wrap_clipboard_widgets() {
|
||||
eval "
|
||||
function ${wrapped_name}() {
|
||||
zle .${widget}
|
||||
# On a failed push, snapshot the clipboard so put widgets can tell
|
||||
# stale content (which never received this kill) apart from later
|
||||
# external copies.
|
||||
if printf %s \"\${CUTBUFFER}\" | clipcopy 2>/dev/null; then
|
||||
_OMZ_VI_CLIPBOARD_STALE_SET=\"\"
|
||||
else
|
||||
_OMZ_VI_CLIPBOARD_STALE=\"\$(clippaste 2>/dev/null)\"
|
||||
_OMZ_VI_CLIPBOARD_STALE_SET=1
|
||||
fi
|
||||
printf %s \"\${CUTBUFFER}\" | clipcopy 2>/dev/null || true
|
||||
}
|
||||
"
|
||||
else
|
||||
eval "
|
||||
function ${wrapped_name}() {
|
||||
if [[ -n \"\${_OMZ_VI_CLIPBOARD_STALE_SET:-}\" ]]; then
|
||||
# Last push failed. If the clipboard still matches the snapshot
|
||||
# taken at the failure, it is stale: keep the internal CUTBUFFER.
|
||||
# If it differs, an external copy arrived since - trust it again
|
||||
# and clear the stale state.
|
||||
local _clip=\"\$(clippaste 2>/dev/null)\"
|
||||
if [[ \"\$_clip\" != \"\${_OMZ_VI_CLIPBOARD_STALE}\" ]]; then
|
||||
CUTBUFFER=\"\$_clip\"
|
||||
_OMZ_VI_CLIPBOARD_STALE_SET=\"\"
|
||||
fi
|
||||
else
|
||||
CUTBUFFER=\"\$(clippaste 2>/dev/null || echo \$CUTBUFFER)\"
|
||||
fi
|
||||
zle .${widget}
|
||||
}
|
||||
"
|
||||
|
||||
@@ -53,11 +53,10 @@ function web_search() {
|
||||
|
||||
# search or go to main page depending on number of arguments passed
|
||||
if [[ $# -gt 1 ]]; then
|
||||
# if search goes in the query string ==> space as + and escape reserved
|
||||
# characters like & and +, otherwise %20
|
||||
# if search goes in the query string ==> space as +, otherwise %20
|
||||
# see https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20
|
||||
local param="-P"
|
||||
[[ "$urls[$1]" == *\?*= ]] && param="-r"
|
||||
[[ "$urls[$1]" == *\?*= ]] && param=""
|
||||
|
||||
# build search url:
|
||||
# join arguments passed with '+', then append to search engine URL
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
# zsh-patina plugin
|
||||
|
||||
Initializes [zsh-patina](https://github.com/michel-kraemer/zsh-patina), a
|
||||
"blazingly fast Zsh plugin performing syntax highlighting of your command line
|
||||
while you type 🌈"
|
||||
|
||||
The plugin also caches completions for the `zsh-patina` command in
|
||||
`$ZSH_CACHE_DIR/completions/_zsh-patina`, refreshed each time the plugin loads.
|
||||
|
||||
To use it, add `zsh-patina` to the plugins array in your `.zshrc` file:
|
||||
|
||||
```zsh
|
||||
plugins=(... zsh-patina)
|
||||
```
|
||||
|
||||
zsh-patina replaces [zsh-syntax-highlighting](../zsh-syntax-highlighting), so
|
||||
enable only one of them. If zsh-syntax-highlighting is in the plugins array or
|
||||
already loaded, this plugin prints a warning and does not activate.
|
||||
|
||||
## Binary location
|
||||
|
||||
If `zsh-patina` is not in your `PATH` when Oh My Zsh loads (eg: it lives in
|
||||
`~/.cargo/bin`), set `ZSH_PATINA_BINARY` to its full path before sourcing
|
||||
Oh My Zsh:
|
||||
|
||||
```zsh
|
||||
ZSH_PATINA_BINARY=$HOME/.cargo/bin/zsh-patina
|
||||
```
|
||||
|
||||
**Note:** you have to [install zsh-patina](https://github.com/michel-kraemer/zsh-patina#how-to-install) first.
|
||||
@@ -1,21 +0,0 @@
|
||||
if (( $+ZSH_HIGHLIGHT_VERSION )) || (( ${plugins[(Ie)zsh-syntax-highlighting]} )); then
|
||||
echo '[oh-my-zsh] zsh-patina conflicts with zsh-syntax-highlighting, please enable only one of them'
|
||||
elif [[ -x ${ZSH_PATINA_BINARY:-$commands[zsh-patina]} ]]; then
|
||||
eval "$(${ZSH_PATINA_BINARY:-$commands[zsh-patina]} activate)"
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `zsh-patina`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_zsh-patina" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _zsh-patina
|
||||
_comps[zsh-patina]=_zsh-patina
|
||||
fi
|
||||
|
||||
zmodload -F zsh/files b:zf_mv
|
||||
() {
|
||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._zsh-patina"
|
||||
zf_mv -f -- =( "$1" completion ) "$ZSH_CACHE_DIR/completions/_zsh-patina"
|
||||
} "${ZSH_PATINA_BINARY:-$commands[zsh-patina]}" &|
|
||||
else
|
||||
echo '[oh-my-zsh] zsh-patina not found, please install it from https://github.com/michel-kraemer/zsh-patina'
|
||||
fi
|
||||
Regular → Executable
File mode changed.
Reference in new issue
Block a user