1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-04-10 16:32:00 +00:00

Compare commits

...

8 Commits

Author SHA1 Message Date
Iyigun Cevik
d9bc5d37ad Merge c4c34b1446 into 7c10d9839f 2026-04-07 16:11:38 +02:00
Chris Schindlbeck
7c10d9839f feat(terraform): add aliases for terraform: tfapp, tfpo 2026-04-07 12:25:32 +02:00
Chris Schindlbeck
103246c198 feat(opentofu): add aliases for opentofu: ttap, ttapp, ttir, ttiu, ttiur, ttpo 2026-04-07 12:25:32 +02:00
dependabot[bot]
887a864aba chore(deps): bump charset-normalizer in /.github/workflows/dependencies (#13669)
Bumps [charset-normalizer](https://github.com/jawah/charset_normalizer) from 3.4.6 to 3.4.7.
- [Release notes](https://github.com/jawah/charset_normalizer/releases)
- [Changelog](https://github.com/jawah/charset_normalizer/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jawah/charset_normalizer/compare/3.4.6...3.4.7)

---
updated-dependencies:
- dependency-name: charset-normalizer
  dependency-version: 3.4.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-05 19:28:10 +02:00
dependabot[bot]
d1fb3ebfc7 chore(deps): bump requests in /.github/workflows/dependencies (#13668)
Bumps [requests](https://github.com/psf/requests) from 2.33.0 to 2.33.1.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](https://github.com/psf/requests/compare/v2.33.0...v2.33.1)

---
updated-dependencies:
- dependency-name: requests
  dependency-version: 2.33.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-05 19:27:23 +02:00
dependabot[bot]
beab0c0b3c chore(deps): bump step-security/harden-runner from 2.16.0 to 2.16.1 (#13667)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.16.0 to 2.16.1.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](fa2e9d605c...fe10465874)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  dependency-version: 2.16.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-05 19:26:46 +02:00
Iyigun Cevik
c4c34b1446 fix(juju): plugin utilities
- Respect $JUJU_DATA env var in jcontroller() and jmodel()
- Fix missing `local controller` declaration in jclean()
- Fix jmodel() to handle controller names with special chars and "null"
  yq output
- Change wjst() default poll interval from 5s to 1s
2026-04-03 18:03:49 +02:00
Iyigun Cevik
806f1a0ed3 feat(juju): add native zsh completion
Add _juju: native zsh completion script replacing bash-completion
sourcing; supports subcommand, flag, model, and controller tab
completion including "controller:model" format
2026-04-03 18:03:44 +02:00
10 changed files with 279 additions and 27 deletions

View File

@@ -13,7 +13,7 @@ jobs:
contents: write # this is needed to push commits and branches contents: write # this is needed to push commits and branches
steps: steps:
- name: Harden the runner (Audit all outbound calls) - name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0 uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
with: with:
egress-policy: audit egress-policy: audit

View File

@@ -1,7 +1,7 @@
certifi==2026.2.25 certifi==2026.2.25
charset-normalizer==3.4.6 charset-normalizer==3.4.7
idna==3.11 idna==3.11
PyYAML==6.0.3 PyYAML==6.0.3
requests==2.33.0 requests==2.33.1
semver==3.0.4 semver==3.0.4
urllib3==2.6.3 urllib3==2.6.3

View File

@@ -26,7 +26,7 @@ jobs:
- macos-latest - macos-latest
steps: steps:
- name: Harden the runner (Audit all outbound calls) - name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0 uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
with: with:
egress-policy: audit egress-policy: audit
@@ -47,7 +47,7 @@ jobs:
- test - test
steps: steps:
- name: Harden the runner (Audit all outbound calls) - name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0 uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
with: with:
egress-policy: audit egress-policy: audit

View File

@@ -24,7 +24,7 @@ jobs:
if: github.repository == 'ohmyzsh/ohmyzsh' if: github.repository == 'ohmyzsh/ohmyzsh'
steps: steps:
- name: Harden the runner (Audit all outbound calls) - name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0 uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
with: with:
egress-policy: audit egress-policy: audit

View File

@@ -17,7 +17,7 @@ jobs:
if: github.repository == 'ohmyzsh/ohmyzsh' if: github.repository == 'ohmyzsh/ohmyzsh'
steps: steps:
- name: Harden the runner (Audit all outbound calls) - name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0 uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
with: with:
egress-policy: audit egress-policy: audit
- name: Authenticate as @ohmyzsh - name: Authenticate as @ohmyzsh

View File

@@ -36,7 +36,7 @@ jobs:
steps: steps:
- name: Harden the runner (Audit all outbound calls) - name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0 uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
with: with:
egress-policy: audit egress-policy: audit

236
plugins/juju/_juju Normal file
View File

@@ -0,0 +1,236 @@
#compdef juju
(( $+functions[compdef] )) && compdef _juju juju
# zsh completion for juju -*- shell-script -*-
__juju_debug()
{
local file="$BASH_COMP_DEBUG_FILE"
if [[ -n ${file} ]]; then
echo "$*" >> "${file}"
fi
}
__juju_help_options()
{
local out line token cleaned desc f
local -a opts pending
typeset -U opts
__juju_debug "[options] called with args: $*"
out=$(command juju help "$@" 2>/dev/null)
local rc=$?
__juju_debug "[options] juju help exit code: $rc, output length: ${#out}"
(( rc )) && return 1
while IFS= read -r line; do
if [[ "$line" =~ '^[[:space:]]{0,3}-' ]]; then
for f in "${pending[@]}"; do opts+=("$f"); done
pending=()
for token in ${(z)line}; do
cleaned="${token%%,*}"
cleaned="${cleaned%%;*}"
cleaned="${cleaned%%]*}"
cleaned="${cleaned%%)*}"
cleaned="${cleaned%%=<*}"
cleaned="${cleaned%%=*}"
cleaned="${cleaned%%<*}"
cleaned="${cleaned%%\[*}"
cleaned="${cleaned%%\(*}"
[[ "$cleaned" == --* || "$cleaned" == -[[:alnum:]] ]] || continue
[[ "$cleaned" == "-" || "$cleaned" == "--" ]] && continue
__juju_debug "[options] found flag: $cleaned"
pending+=("$cleaned")
done
elif (( ${#pending} )) && [[ -n "$line" ]]; then
desc="${line#"${line%%[![:space:]]*}"}"
desc="${desc//:/\\:}"
__juju_debug "[options] desc for ${pending[*]}: $desc"
for f in "${pending[@]}"; do opts+=("${f}:${desc}"); done
pending=()
elif [[ -z "$line" ]]; then
for f in "${pending[@]}"; do opts+=("$f"); done
pending=()
fi
done < <(printf "%s\n" "$out")
for f in "${pending[@]}"; do opts+=("$f"); done
__juju_debug "[options] total opts: ${#opts}, first few: ${opts[1]} ${opts[2]} ${opts[3]}"
printf "%s\n" "${opts[@]}"
}
__juju_help_commands()
{
local line cmd desc out
out=$(command juju help commands 2>/dev/null) || return 1
while IFS= read -r line; do
# Strip leading whitespace
line="${line#"${line%%[![:space:]]*}"}"
# Only process lines starting with an alphanumeric (command names)
[[ "$line" =~ '^[[:alnum:]]' ]] || continue
# Split on the first run of 2+ spaces: left = cmd, right = description
cmd="${line%% *}"
# Validate it's a clean command token (no spaces, only alnum and dash)
[[ "$cmd" =~ '^[[:alnum:]][[:alnum:]-]*$' ]] || continue
desc="${line#"$cmd"}"
desc="${desc#"${desc%%[![:space:]]*}"}"
if [[ -n "$desc" ]]; then
printf "%s:%s\n" "$cmd" "$desc"
else
printf "%s\n" "$cmd"
fi
done <<< "$out"
}
__juju_models()
{
# Optional argument: controller name. If given, fetch models for that controller.
if [[ -n "$1" ]]; then
command juju models -c "$1" --format=json 2>/dev/null \
| command jq -r '.models[]."short-name"' 2>/dev/null
else
command juju models --format=json 2>/dev/null \
| command jq -r '.models[]."short-name"' 2>/dev/null
fi
}
# Complete a model token that may be prefixed with "controller:" — if a colon is
# present, fetch models for that controller and offer "ctrl:model" completions.
__juju_complete_model()
{
local current="$1"
local -a completions
__juju_debug "[complete_model] current='${current}'"
if [[ "$current" == *:* ]]; then
local ctrl="${current%%:*}"
local models
models=("${(@f)$(__juju_models "$ctrl")}")
completions=("${models[@]/#/${ctrl}:}")
__juju_debug "[complete_model] ctrl=${ctrl} completions=${#completions}: ${completions[*]}"
compadd -S '' -q -- "${completions[@]}"
else
local -a models ctrls
models=("${(@f)$(__juju_models)}")
ctrls=("${(@f)$(__juju_controllers)}")
__juju_debug "[complete_model] models=${#models}: ${models[*]}"
__juju_debug "[complete_model] ctrls=${#ctrls}: ${ctrls[*]}"
__juju_debug "[complete_model] calling _alternative"
_alternative \
'models:models:{__juju_debug "[complete_model] compadd models"; compadd "$expl[@]" -a models}' \
'controllers:controllers:{__juju_debug "[complete_model] compadd ctrls"; compadd "$expl[@]" -S : -q -a ctrls}'
__juju_debug "[complete_model] _alternative returned $?"
fi
}
# Commands whose first positional argument is a model name.
_juju_model_commands=(
destroy-model
grant-model
revoke-model
switch
)
# Flags that take a model name as their value.
_juju_model_flags=(
-m
--model
)
__juju_controllers()
{
command juju controllers --format=json 2>/dev/null \
| command jq -r '.controllers | keys | .[]' 2>/dev/null
}
# Commands whose first positional argument is a controller name.
_juju_controller_commands=(
destroy-controller
kill-controller
login
logout
unregister
)
# Flags that take a controller name as their value.
_juju_controller_flags=(
-c
--controller
)
_juju()
{
__juju_debug "[_juju] curcontext: ${curcontext}"
local -a completions
# Must be set at completion time (not just at sourcing time) so the
# completion system picks it up when rendering groups.
zstyle ':completion:*' group-name ''
zstyle ':completion::complete:juju:*' format '%B%d%b'
__juju_debug "[_juju] words: ${words[*]}, CURRENT: $CURRENT"
# Find the subcommand: first non-flag word typed after "juju", excluding the
# word currently being completed (words[CURRENT]).
local subcmd=""
local i
for (( i = 2; i < CURRENT; i++ )); do
if [[ "${words[i]}" != -* ]]; then
subcmd="${words[i]}"
break
fi
done
local current="${words[CURRENT]}"
local prev="${words[CURRENT-1]}"
__juju_debug "[_juju] subcmd: '${subcmd}', current: '${current}', prev: '${prev}'"
# Controller name completion: flag value (e.g. juju status -c <TAB>)
if (( ${_juju_controller_flags[(I)$prev]} )); then
completions=("${(@f)$(__juju_controllers)}")
__juju_debug "[_juju] controller flag completions: ${#completions}"
(( ${#completions} )) && _describe "controller" completions && return 0
return 1
fi
# Model name completion: flag value (e.g. juju status -m <TAB> or -m ctrl:<TAB>)
if (( ${_juju_model_flags[(I)$prev]} )); then
__juju_debug "[_juju] model flag completion, current: '${current}'"
__juju_complete_model "$current" && return 0
return 1
fi
if [[ -z "$subcmd" ]]; then
# No subcommand yet — complete subcommand names.
completions=("${(@f)$(__juju_help_commands)}")
__juju_debug "[_juju] command completions count: ${#completions}"
(( ${#completions} )) && _describe "command" completions && return 0
return 1
fi
# Controller name completion: positional arg (e.g. juju destroy-controller <TAB>)
if (( ${_juju_controller_commands[(I)$subcmd]} )) && [[ "$current" != -* ]]; then
completions=("${(@f)$(__juju_controllers)}")
__juju_debug "[_juju] controller command completions: ${#completions}"
(( ${#completions} )) && _describe "controller" completions && return 0
return 1
fi
# Model name completion: positional arg (e.g. juju destroy-model <TAB> or ctrl:<TAB>)
if (( ${_juju_model_commands[(I)$subcmd]} )) && [[ "$current" != -* ]]; then
__juju_debug "[_juju] model command completion, current: '${current}'"
__juju_complete_model "$current" && return 0
return 1
fi
# Flag completion for all other subcommands (also shown without leading dash)
completions=("${(@f)$(__juju_help_options "$subcmd")}")
__juju_debug "[_juju] option completions count: ${#completions}"
(( ${#completions} )) && _describe "option" completions && return 0
return 1
}

View File

@@ -3,12 +3,14 @@
# ---------------------------------------------------------- # # ---------------------------------------------------------- #
# Load TAB completions # Load TAB completions
# You need juju's bash completion script installed. By default bash-completion's source "${0:A:h}/_juju"
# location will be used (i.e. pkg-config --variable=completionsdir bash-completion).
completion_file="$(pkg-config --variable=completionsdir bash-completion 2>/dev/null)/juju" || \ # group-name '' enables visual separation between completion groups (e.g. models
completion_file="/usr/share/bash-completion/completions/juju" # vs controllers in juju switch <TAB>). This is a safe global setting that
[[ -f "$completion_file" ]] && source "$completion_file" # improves completion display for all commands.
unset completion_file zstyle ':completion:*' group-name ''
# Show group headers only for juju completions.
zstyle ':completion::complete:juju:*' format '%B%d%b'
# ---------------------------------------------------------- # # ---------------------------------------------------------- #
# Aliases (in alphabetic order) # # Aliases (in alphabetic order) #
@@ -132,6 +134,7 @@ jclean() {
fi fi
echo echo
local controller
for controller in ${=controllers}; do for controller in ${=controllers}; do
timeout 2m juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y $controller timeout 2m juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y $controller
timeout 2m juju kill-controller -y -t 0 $controller 2>/dev/null timeout 2m juju kill-controller -y -t 0 $controller 2>/dev/null
@@ -165,10 +168,11 @@ jreld() {
# Return Juju current controller # Return Juju current controller
jcontroller() { jcontroller() {
local controller="$(awk '/current-controller/ {print $2}' ~/.local/share/juju/controllers.yaml)" local file=${JUJU_DATA:=~/.local/share/juju}/controllers.yaml
if [[ -z "$controller" ]]; then [[ -f "$file" ]] || return 1
return 1
fi local controller="$(awk '/current-controller/ {print $2}' "$file")"
[[ -z "$controller" ]] && return 1
echo $controller echo $controller
return 0 return 0
@@ -176,6 +180,9 @@ jcontroller() {
# Return Juju current model # Return Juju current model
jmodel() { jmodel() {
local file=${JUJU_DATA:=~/.local/share/juju}/models.yaml
[[ -f "$file" ]] || return 1
local yqbin="$(whereis yq | awk '{print $2}')" local yqbin="$(whereis yq | awk '{print $2}')"
if [[ -z "$yqbin" ]]; then if [[ -z "$yqbin" ]]; then
@@ -183,9 +190,10 @@ jmodel() {
return 1 return 1
fi fi
local model="$(yq e ".controllers.$(jcontroller).current-model" < ~/.local/share/juju/models.yaml | cut -d/ -f2)" local controller="$(jcontroller)"
local model="$(yq e ".controllers.[\"${controller}\"].current-model" < "${file}" | cut -d/ -f2)"
if [[ -z "$model" ]]; then if [[ -z "$model" || $model == "null" ]]; then
echo "--" echo "--"
return 1 return 1
fi fi
@@ -194,9 +202,10 @@ jmodel() {
return 0 return 0
} }
# Watch juju status, with optional interval (default: 5 sec) # Watch juju status, with optional interval (default: 1 sec)
wjst() { wjst() {
local interval="${1:-5}" command -v juju >/dev/null 2>&1 || return 1
local interval="${1:-1}"
shift $(( $# > 0 )) shift $(( $# > 0 ))
watch -n "$interval" --color juju status --relations --color "$@" watch -n "$interval" --color juju status --relations --color "$@"
} }

View File

@@ -30,14 +30,20 @@ function tofu_version_prompt_info() {
alias tt='tofu' alias tt='tofu'
alias tta='tofu apply' alias tta='tofu apply'
alias tta!='tofu apply -auto-approve' alias tta!='tofu apply -auto-approve'
alias ttap='tofu apply -parallelism=1'
alias ttapp='tofu apply tfplan'
alias ttc='tofu console' alias ttc='tofu console'
alias ttd='tofu destroy' alias ttd='tofu destroy'
alias ttd!='tofu destroy -auto-approve' alias ttd!='tofu destroy -auto-approve'
alias ttf='tofu fmt' alias ttf='tofu fmt'
alias ttfr='tofu fmt -recursive' alias ttfr='tofu fmt -recursive'
alias tti='tofu init' alias tti='tofu init'
alias ttir='tofu init -reconfigure'
alias ttiu='tofu init -upgrade'
alias ttiur='tofu init -upgrade -reconfigure'
alias tto='tofu output' alias tto='tofu output'
alias ttp='tofu plan' alias ttp='tofu plan'
alias ttpo='tofu plan -out tfplan'
alias ttv='tofu validate' alias ttv='tofu validate'
alias tts='tofu state' alias tts='tofu state'
alias ttsh='tofu show' alias ttsh='tofu show'

View File

@@ -4,21 +4,21 @@ function tf_prompt_info() {
# check if in terraform dir and file exists # check if in terraform dir and file exists
[[ -d "${TF_DATA_DIR:-.terraform}" && -r "${TF_DATA_DIR:-.terraform}/environment" ]] || return [[ -d "${TF_DATA_DIR:-.terraform}" && -r "${TF_DATA_DIR:-.terraform}/environment" ]] || return
local workspace="$(< "${TF_DATA_DIR:-.terraform}/environment")" local workspace="$(<"${TF_DATA_DIR:-.terraform}/environment")"
echo "${ZSH_THEME_TF_PROMPT_PREFIX-[}${workspace:gs/%/%%}${ZSH_THEME_TF_PROMPT_SUFFIX-]}" echo "${ZSH_THEME_TF_PROMPT_PREFIX-[}${workspace:gs/%/%%}${ZSH_THEME_TF_PROMPT_SUFFIX-]}"
} }
function tf_version_prompt_info() { function tf_version_prompt_info() {
local terraform_version local terraform_version
terraform_version=$(terraform --version | head -n 1 | cut -d ' ' -f 2) terraform_version=$(terraform --version | head -n 1 | cut -d ' ' -f 2)
echo "${ZSH_THEME_TF_VERSION_PROMPT_PREFIX-[}${terraform_version:gs/%/%%}${ZSH_THEME_TF_VERSION_PROMPT_SUFFIX-]}" echo "${ZSH_THEME_TF_VERSION_PROMPT_PREFIX-[}${terraform_version:gs/%/%%}${ZSH_THEME_TF_VERSION_PROMPT_SUFFIX-]}"
} }
alias tf='terraform' alias tf='terraform'
alias tfa='terraform apply' alias tfa='terraform apply'
alias tfa!='terraform apply -auto-approve' alias tfa!='terraform apply -auto-approve'
alias tfap='terraform apply -parallelism=1' alias tfap='terraform apply -parallelism=1'
alias tfapp='terraform apply tfplan'
alias tfc='terraform console' alias tfc='terraform console'
alias tfd='terraform destroy' alias tfd='terraform destroy'
alias tfd!='terraform destroy -auto-approve' alias tfd!='terraform destroy -auto-approve'
@@ -31,6 +31,7 @@ alias tfiu='terraform init -upgrade'
alias tfiur='terraform init -upgrade -reconfigure' alias tfiur='terraform init -upgrade -reconfigure'
alias tfo='terraform output' alias tfo='terraform output'
alias tfp='terraform plan' alias tfp='terraform plan'
alias tfpo='terraform plan -out tfplan'
alias tfv='terraform validate' alias tfv='terraform validate'
alias tfs='terraform state' alias tfs='terraform state'
alias tft='terraform test' alias tft='terraform test'