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

Compare commits

...

11 Commits

Author SHA1 Message Date
Marc Cornellà
0c044b34b4 Merge 85292e5ea6 into 7c10d9839f 2026-04-08 19:15:24 +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
ohmyzsh[bot]
f0e2160abb chore(kube-ps1): update to e19c9ee8 (#13666)
Co-authored-by: ohmyzsh[bot] <54982679+ohmyzsh[bot]@users.noreply.github.com>
2026-04-05 14:39:19 +02:00
Marc Cornellà
85292e5ea6 Fix initial setup on omz trace on 2026-02-12 10:29:45 +01:00
Marc Cornellà
e152f48316 Style fixes 2026-02-12 10:29:36 +01:00
Marc Cornellà
727ea94e65 Rename zshenv hook 2026-02-12 10:29:21 +01:00
Marc Cornellà
471958dfb3 feat: add tracing feature, CLI and web viewer 2026-02-03 20:17:48 +01:00
13 changed files with 473 additions and 34 deletions

View File

@@ -30,7 +30,7 @@ dependencies:
plugins/kube-ps1:
repo: jonmosco/kube-ps1
branch: master
version: 9b41c091d5dd4a99e58cf58b5d98a4847937b1bb
version: e19c9ee867c5655814c384a6bf543e330e6ef1b7
precopy: |
set -e
find . ! -name kube-ps1.sh ! -name LICENSE ! -name README.md -delete

View File

@@ -13,7 +13,7 @@ jobs:
contents: write # this is needed to push commits and branches
steps:
- 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:
egress-policy: audit

View File

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

View File

@@ -26,7 +26,7 @@ jobs:
- macos-latest
steps:
- 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:
egress-policy: audit
@@ -47,7 +47,7 @@ jobs:
- test
steps:
- 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:
egress-policy: audit

View File

@@ -24,7 +24,7 @@ jobs:
if: github.repository == 'ohmyzsh/ohmyzsh'
steps:
- 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:
egress-policy: audit

View File

@@ -17,7 +17,7 @@ jobs:
if: github.repository == 'ohmyzsh/ohmyzsh'
steps:
- 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:
egress-policy: audit
- name: Authenticate as @ohmyzsh

View File

@@ -36,7 +36,7 @@ jobs:
steps:
- 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:
egress-policy: audit

View File

@@ -0,0 +1,155 @@
#autoload
# This function serves a specified file over HTTP 1.0 on localhost, at a random
# available port. It waits for a single GET request to the correct URL and then
# responds with the file contents. If any other request is received, it responds
# with a 404 Not Found. The server automatically shuts down after serving the
# file or after a specified timeout.
#
# Usage:
# serve-file-and-quit <file-to-serve> [timeout-secs] [Access-Control-Allow-Origin]
# <file-to-serve> Path to the file to be served (required)
# [timeout-secs] Number of seconds to wait for a connection before quitting (default: 30, max: 60)
# [Access-Control-Allow-Origin] Value for the Access-Control-Allow-Origin header (default: "null")
#
# If called from a subshell, it outputs the URL where the file can be accessed, and
# then closes stdout to avoid hanging while the server is listening. The caller can
# capture this output.
#
# It is intended for temporary sharing of files between local applications,
# such as opening a trace file in a web-based viewer (trace.ohmyz.sh). It is not
# meant for production use or serving files over the internet.
#
# It's a minimal implementation using zsh's built-in TCP capabilities, primarily
# to avoid external dependencies.
#
# Security considerations:
#
# - This server listens on 0.0.0.0 (all interfaces), so it may be accessible from
# other devices on the same network. I haven't found a way to bind only to localhost
# using zsh's ztcp module.
# - As the port is randomized, and the server is short-lived, the risk is mitigated,
# but not eliminated. An additional mitigation could be to use a random URL path segment.
# - It's not a proper HTTP server, so it uses very rudimentary request parsing and
# response generation. It currently does not support binary files, and probably
# never will.
setopt localoptions localtraps
zmodload zsh/net/tcp
zmodload zsh/zselect
local file="$1"
local timeout_secs="${2:-30}"
local AccessControlAllowOrigin=${3:-"null"}
if [[ -z "$file" ]]; then
print -ru2 "Usage: $0 <file-to-serve> [timeout-secs] [Access-Control-Allow-Origin]"
return 1
fi
if [[ ! -r "$file" ]]; then
print -ru2 "Error: file '$file' not found or not readable."
return 1
fi
if (( timeout_secs < 1 || timeout_secs > 60 )); then
print -ru2 "Error: timeout must be a positive integer between 1 and 60."
return 1
fi
local pathname="$(omz_urlencode -P "/${file:t}")"
# 1. Get a random available port
local port=$(( RANDOM % 32767 + 1100 ))
while ! ztcp -l "$port" &>/dev/null; do
(( port++ ))
if (( port > 65535 )); then
print -ru2 "Error: failed to start server: no available ports."
return 1
fi
done
ztcp -c $REPLY # inmediately close the test connection
# 2. Output file URL to stdout for caller to use
# Here the subcommand substitution captures the output and returns it to the caller
if [[ $ZSH_SUBSHELL -gt 0 ]]; then
echo "http://localhost:$port${pathname}"
exec >/dev/null # close stdout in the subshell to avoid hanging
fi
# Start of asynchronous server block
{
local response_body request_line listen_fd fd
# 1. Start listening on the selected port
if ! ztcp -l $port; then
print -ru2 "Error: failed to start server on port $port."
return 1
fi
listen_fd=$REPLY
print -ru2 "Serving file '${file:t}' on http://localhost:$port${pathname} ..."
# 2. Wait for a connection, with a timeout (in hundredths of a second)
while zselect -t $(( timeout_secs * 100 )) -r $listen_fd; do
# 3. Accept the connection
ztcp -a $listen_fd
fd=$REPLY
# 4. Read the request line (the first line is usually enough to determine the path)
# Note: read up to 2048 bytes to avoid blocking indefinitely
sysread -s 2048 -i $fd request
local request_line="${${(f)request}[1]}"
# 5. If the request is not for the expected pathname, respond with 404 Not Found
if [[ "${${(f)request}[1]}" != "GET ${pathname} HTTP/1."* ]]; then
local response_body="404 Not Found"
local http_response=$'HTTP/1.0 404 Not Found\r
Content-Type: text/plain\r
Content-Length: %d\r
\r
%s\r
'
>&$fd builtin printf -- "$http_response" \
$(( ${#response_body} + 2 )) \
"$response_body"
# 5.1. Close the connection file descriptor and try again
ztcp -c $fd
continue
fi
# 6. If the request matches the pathname, respond with the contents of the file
local response_body="$(<$file)"
local http_response=$'HTTP/1.0 200 OK\r
Access-Control-Allow-Origin: %s\r
Content-Type: text/plain;charset=utf-8\r
Content-Length: %d\r
\r
%s\r
'
>&$fd builtin printf -- "$http_response" \
"$AccessControlAllowOrigin" \
$(( ${#response_body} + 2 )) \
"$response_body"
# 6.1. Close the connection file descriptor and stop the loop
ztcp -c $fd
break
done
return 0
} always {
# Non-zero if error or timeout occurred
local ret=$?
# 7. Close remaining file descriptors and shut down the server
print -ru2 "Server stopped."
[[ -z "$fd" ]] || ztcp -c $fd 2>/dev/null
[[ -z "$listen_fd" ]] || ztcp -c $listen_fd 2>/dev/null
return $ret
} &|

58
hooks/zshenv.zsh Normal file
View File

@@ -0,0 +1,58 @@
omzp:start() {
setopt localoptions localtraps
# initialization
zmodload zsh/datetime
typeset -Ag __OMZP
__OMZP=(
PS4 "$PS4"
start "$EPOCHREALTIME"
outfile "${1:-$HOME}/${${SHELL:t}#-}.$EPOCHSECONDS.$$.zsh-trace.log"
)
typeset -g PS4="+Z|%e|%D{%s.%9.}|%N|%x|%I> "
# unload profiler on startup end
autoload -Uz add-zsh-hook
add-zsh-hook precmd omzp:stop
# redirect debug output to profiler log file
exec 3>&2 2>${__OMZP[outfile]}
# enable zsh debug mode
trap 'setopt xtrace noevallineno' EXIT
}
# Force this function to be executed in noxtrace mode
emulate zsh +x -c '
omzp:stop() {
setopt localoptions localtraps
trap "{ setopt noxtrace evallineno } 2>/dev/null; exec 2>&3 3>&-" EXIT
# restore PS4
typeset -g PS4="$__OMZP[PS4]"
unset "__OMZP[PS4]"
# remove precmd function
add-zsh-hook -d precmd omzp:stop
unfunction omzp:stop
local startup=$(( (${(%):-"%D{%s.%9.}"} - __OMZP[start]) * 1e3 ))
printf "%.3f ms %s \n" "$startup" "${__OMZP[outfile]:t}"
}'
# TODO: this is duplicated from init script, fix later
# Init $ZSH path
[[ -n "$ZSH" ]] || export ZSH="${${(%):-%x}:a:h:h}"
# Set ZSH_CACHE_DIR to the path where cache files should be created
# or else we will use the default cache/
[[ -n "$ZSH_CACHE_DIR" ]] || ZSH_CACHE_DIR="$ZSH/cache"
# Make sure $ZSH_CACHE_DIR is writable, otherwise use a directory in $HOME
if [[ ! -w "$ZSH_CACHE_DIR" ]]; then
ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh"
fi
# Set OMZ_TRACES directory
OMZ_TRACES="${OMZ_TRACES:-"$ZSH_CACHE_DIR/.traces"}"
! 'builtin' 'test' -f "${OMZ_TRACES}/.enabled" || omzp:start "$OMZ_TRACES"

View File

@@ -30,6 +30,7 @@ function _omz {
'reload:Reload the current zsh session'
'shop:Open the Oh My Zsh shop'
'theme:Manage themes'
'trace:Manage debug tracing'
'update:Update Oh My Zsh'
'version:Show the version'
)
@@ -42,17 +43,26 @@ function _omz {
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)'
)
'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 ;;
trace) subcmds=(
'clean:Delete all traces'
'list:List traces'
'off:Turn debug tracing off'
'on:Turn debug tracing on'
'toggle:Toggle debug tracing'
'view:View trace in browser'
)
_describe 'command' subcmds ;;
esac
elif (( CURRENT == 4 )); then
case "${words[2]}::${words[3]}" in
@@ -81,6 +91,12 @@ function _omz {
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 ;;
trace::view)
local -a opts traces
traces=("${ZSH_CACHE_DIR}/.traces/"*.log(N:t))
opts=('--no-web:View file in terminal')
_describe 'options' opts
_describe 'trace' traces ;;
esac
elif (( CURRENT > 4 )); then
case "${words[2]}::${words[3]}" in
@@ -105,6 +121,12 @@ function _omz {
valid_plugins=(${valid_plugins:|args})
_describe 'plugin' valid_plugins ;;
trace::view)
local -a opts traces
# opts=('-w:View in browser')
traces=("${ZSH_CACHE_DIR}/.traces/"*.log(N:t))
# _describe 'options' opts
_describe 'trace' traces ;;
esac
fi
@@ -746,7 +768,7 @@ function _omz::theme {
(( $# > 0 && $+functions[$0::$1] )) || {
cat >&2 <<EOF
Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
$#traces
Available commands:
list List all available Oh My Zsh themes
@@ -882,6 +904,193 @@ function _omz::theme::use {
[[ $1 = random ]] || unset RANDOM_THEME
}
function _omz::trace {
(( $# > 0 && $+functions[$0::$1] )) || {
cat >&2 <<EOF
Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
Available commands:
clean [-a] Delete old or all traces
list List traces
off Turn debug tracing off
on Turn debug tracing on
toggle Toggle debug tracing
view View trace in browser
EOF
return 1
}
local command="$1"
shift
$0::$command "$@"
}
function _omz::trace::on {
# Check that .zshenv hook is added
if [[ ! -f "$HOME/.zshenv" ]]; then
touch "$HOME/.zshenv"
chmod u+rw "$HOME/.zshenv"
fi
# Check that hook is sourced in .zshenv
#
# 1. Compute the hook path relative to $HOME
local hook_path="$ZSH/hooks/zshenv.zsh"
hook_path="${hook_path/#$HOME\//\$HOME/}"
# 2. Compute the source command
local hook_source=". \"$hook_path\""
# 3. Check if already added to .zshenv, otherwise add it
if ! command grep -Fq "$hook_source" "$HOME/.zshenv"; then
# 4. If not, prepend the hook source command
local tmpfile==(:)
cat - "$HOME/.zshenv" >| "$tmpfile" <<EOF
$hook_source # set by \`omz\`
EOF
# 5. Check for syntax errors
if ! zsh -n "$tmpfile"; then
_omz::log error "error when adding the tracing hook to .zshenv"
_omz::log error "add the following line to your .zshenv file to enable tracing:"
_omz::log error "$hook_source"
echo
command rm -f "$tmpfile"
else
command mv -f "$tmpfile" "$HOME/.zshenv"
fi
fi
# Check that traces directory exists
local OMZ_TRACES="${OMZ_TRACES:-"$ZSH_CACHE_DIR/.traces"}"
if [[ ! -d "$OMZ_TRACES" ]]; then
command mkdir -p "$OMZ_TRACES"
fi
# Create .enabled file to turn on tracing
touch "${OMZ_TRACES}/.enabled" || return 1
print -ru2 '[oh-my-zsh] tracing enabled'
}
function _omz::trace::off {
'command' 'rm' "${OMZ_TRACES}/.enabled" 2>/dev/null
print -ru2 '[oh-my-zsh] tracing disabled'
}
function _omz::trace::toggle {
'builtin' 'test' -f "${OMZ_TRACES}/.enabled" \
&& _omz::trace::off || _omz::trace::on
}
function _omz::trace::clean {
if [[ -n "$1" && "$1" != "-a" ]]; then
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} [-a]"
return 1
fi
local -a traces
if [[ "$1" == "-a" ]]; then
traces=("${ZSH_CACHE_DIR}/.traces/"*.log(N))
if (( ! $#traces )); then
_omz::log info "there are no traces to remove"
return
fi
else
traces=("${ZSH_CACHE_DIR}/.traces/"*.log(m+7N))
if (( ! $#traces )); then
_omz::log info "there are no traces older than 7 days"
return
fi
fi
# Print found PR branches
print -l -- "Found these traces:" ${${traces:t}/#/\- }
# Confirm before removing the branches
_omz::confirm "do you want to remove them? [Y/n] "
# Only proceed if the answer is a valid yes option
[[ "$REPLY" != [yY$'\n'] ]] && return
_omz::log info "removing trace files..."
LANG= command rm -v "${traces[@]}"
}
function _omz::trace::list {
traces=("${ZSH_CACHE_DIR}/.traces/"*.log(N:t))
print -l -- ${(q-)traces}
}
function _omz::trace::view {
if [[ -z "$1" || "$1" = (-h|--help) ]] \
|| [[ "$1" == "--no-web" && -z "$2" ]]; then
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} [--no-web] <trace>"
return 1
fi
# If --no-web, open locally
local in_web=1
if [[ "$1" == "--no-web" ]]; then
in_web=0
shift
fi
# Get trace file
local trace="${OMZ_TRACES:-${ZSH_CACHE_DIR}/.traces}/$1"
if [[ ! -f "$trace" ]]; then
_omz::log error "Trace file not found: $trace"
return 1
fi
# If not in web mode, just display the trace file
if (( ! in_web )); then
# Enrich the file display depending on the tools we have
# - bat: https://github.com/sharkdp/bat
# - less: typical pager command
case 1 in
${+commands[bat]}) bat -l sh --style plain "$trace" ;;
${+commands[less]}) less "$trace" ;;
*) cat "$trace" ;;
esac
return $?
fi
# Load functions for web mode
autoload -Uz serve-file-and-quit omz_urlencode
local baseurl="https://trace.ohmyz.sh"
# Serve the trace file and get its URL
local profileURL
profileURL="$(serve-file-and-quit "$trace" 30 "$baseurl" 2>/dev/null)"
# If successful, open the trace viewer with the trace file URL
if [[ $? -eq 0 ]]; then
# Give the server some time to start
sleep 0.2
# -r and -P encode any special characters in the filename
local title="$(omz_urlencode -r -P "${trace:t}")"
_omz::log info "Opening ${baseurl} with trace file: '$trace' ..."
open_command "${baseurl}/#profileURL=${profileURL}&title=${title}"
return 0
fi
# Fallback: just open the trace viewer and let the user upload the file manually
_omz::log error "could not start HTTP server. Falling back to manual upload."
_omz::log info "Opening ${baseurl} ... Please manually upload the trace file from this path:"
_omz::log info "$trace"
open_command "$baseurl"
}
function _omz::update {
# Check if git command is available
(( $+commands[git] )) || {

View File

@@ -55,7 +55,17 @@ _kube_ps1_shell_type() {
_kube_ps1_init() {
[[ -f "${_KUBE_PS1_DISABLE_PATH}" ]] && KUBE_PS1_ENABLED=off
case "$(_kube_ps1_shell_type)" in
# Detect shell type once and cache it
_KUBE_PS1_SHELL="$(_kube_ps1_shell_type)"
# Check tput availability once
if tput setaf 1 &> /dev/null; then
_KUBE_PS1_TPUT_AVAILABLE=true
else
_KUBE_PS1_TPUT_AVAILABLE=false
fi
case "${_KUBE_PS1_SHELL}" in
"zsh")
_KUBE_PS1_OPEN_ESC="%{"
_KUBE_PS1_CLOSE_ESC="%}"
@@ -96,10 +106,10 @@ _kube_ps1_color_fg() {
if [[ "${_KUBE_PS1_FG_CODE}" == "default" ]]; then
_KUBE_PS1_FG_CODE="${_KUBE_PS1_DEFAULT_FG}"
return
elif [[ "$(_kube_ps1_shell_type)" == "zsh" ]]; then
elif [[ "${_KUBE_PS1_SHELL}" == "zsh" ]]; then
_KUBE_PS1_FG_CODE="%F{$_KUBE_PS1_FG_CODE}"
elif [[ "$(_kube_ps1_shell_type)" == "bash" ]]; then
if tput setaf 1 &> /dev/null; then
elif [[ "${_KUBE_PS1_SHELL}" == "bash" ]]; then
if [[ "${_KUBE_PS1_TPUT_AVAILABLE}" == "true" ]]; then
_KUBE_PS1_FG_CODE="$(tput setaf "${_KUBE_PS1_FG_CODE}")"
elif [[ $_KUBE_PS1_FG_CODE -ge 0 ]] && [[ $_KUBE_PS1_FG_CODE -le 256 ]]; then
_KUBE_PS1_FG_CODE="\033[38;5;${_KUBE_PS1_FG_CODE}m"
@@ -129,15 +139,15 @@ _kube_ps1_color_bg() {
if [[ "${_KUBE_PS1_BG_CODE}" == "default" ]]; then
_KUBE_PS1_FG_CODE="${_KUBE_PS1_DEFAULT_BG}"
return
elif [[ "$(_kube_ps1_shell_type)" == "zsh" ]]; then
elif [[ "${_KUBE_PS1_SHELL}" == "zsh" ]]; then
_KUBE_PS1_BG_CODE="%K{$_KUBE_PS1_BG_CODE}"
elif [[ "$(_kube_ps1_shell_type)" == "bash" ]]; then
if tput setaf 1 &> /dev/null; then
elif [[ "${_KUBE_PS1_SHELL}" == "bash" ]]; then
if [[ "${_KUBE_PS1_TPUT_AVAILABLE}" == "true" ]]; then
_KUBE_PS1_BG_CODE="$(tput setab "${_KUBE_PS1_BG_CODE}")"
elif [[ $_KUBE_PS1_BG_CODE -ge 0 ]] && [[ $_KUBE_PS1_BG_CODE -le 256 ]]; then
_KUBE_PS1_BG_CODE="\033[48;5;${_KUBE_PS1_BG_CODE}m"
else
_KUBE_PS1_BG_CODE="${DEFAULT_BG}"
_KUBE_PS1_BG_CODE="${_KUBE_PS1_DEFAULT_BG}"
fi
fi
echo "${_KUBE_PS1_OPEN_ESC}${_KUBE_PS1_BG_CODE}${_KUBE_PS1_CLOSE_ESC}"
@@ -174,7 +184,7 @@ _kube_ps1_symbol() {
symbol="$(_kube_ps1_color_fg ${oc_symbol_color})${oc_glyph}${KUBE_PS1_RESET_COLOR}"
;;
*)
case "$(_kube_ps1_shell_type)" in
case "${_KUBE_PS1_SHELL}" in
bash)
if ((BASH_VERSINFO[0] >= 4)) && [[ $'\u2388' != "\\u2388" ]]; then
symbol="$(_kube_ps1_color_fg $custom_symbol_color)${symbol_default}${KUBE_PS1_RESET_COLOR}"
@@ -212,7 +222,7 @@ _kube_ps1_file_newer_than() {
local file=$1
local check_time=$2
if [[ "$(_kube_ps1_shell_type)" == "zsh" ]]; then
if [[ "${_KUBE_PS1_SHELL}" == "zsh" ]]; then
# Use zstat '-F %s.%s' to make it compatible with low zsh version (eg: 5.0.2)
mtime=$(zstat -L +mtime -F %s.%s "${file}")
elif stat -c "%s" /dev/null &> /dev/null; then
@@ -292,13 +302,13 @@ _kube_ps1_get_ns() {
_kube_ps1_get_context_ns() {
# Set the command time
if [[ "$(_kube_ps1_shell_type)" == "bash" ]]; then
if [[ "${_KUBE_PS1_SHELL}" == "bash" ]]; then
if ((BASH_VERSINFO[0] >= 4 && BASH_VERSINFO[1] >= 2)); then
_KUBE_PS1_LAST_TIME=$(printf '%(%s)T')
else
_KUBE_PS1_LAST_TIME=$(date +%s)
fi
elif [[ "$(_kube_ps1_shell_type)" == "zsh" ]]; then
elif [[ "${_KUBE_PS1_SHELL}" == "zsh" ]]; then
_KUBE_PS1_LAST_TIME=$EPOCHREALTIME
fi
@@ -325,7 +335,7 @@ Toggle kube-ps1 prompt on
Usage: kubeon [-g | --global] [-h | --help]
With no arguments, turn oon kube-ps1 status for this shell instance (default).
With no arguments, turn on kube-ps1 status for this shell instance (default).
-g --global turn on kube-ps1 status globally
-h --help print this message

View File

@@ -30,14 +30,20 @@ function tofu_version_prompt_info() {
alias tt='tofu'
alias tta='tofu apply'
alias tta!='tofu apply -auto-approve'
alias ttap='tofu apply -parallelism=1'
alias ttapp='tofu apply tfplan'
alias ttc='tofu console'
alias ttd='tofu destroy'
alias ttd!='tofu destroy -auto-approve'
alias ttf='tofu fmt'
alias ttfr='tofu fmt -recursive'
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 ttp='tofu plan'
alias ttpo='tofu plan -out tfplan'
alias ttv='tofu validate'
alias tts='tofu state'
alias ttsh='tofu show'

View File

@@ -4,21 +4,21 @@ function tf_prompt_info() {
# check if in terraform dir and file exists
[[ -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-]}"
}
function tf_version_prompt_info() {
local terraform_version
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-]}"
local terraform_version
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-]}"
}
alias tf='terraform'
alias tfa='terraform apply'
alias tfa!='terraform apply -auto-approve'
alias tfap='terraform apply -parallelism=1'
alias tfapp='terraform apply tfplan'
alias tfc='terraform console'
alias tfd='terraform destroy'
alias tfd!='terraform destroy -auto-approve'
@@ -31,6 +31,7 @@ alias tfiu='terraform init -upgrade'
alias tfiur='terraform init -upgrade -reconfigure'
alias tfo='terraform output'
alias tfp='terraform plan'
alias tfpo='terraform plan -out tfplan'
alias tfv='terraform validate'
alias tfs='terraform state'
alias tft='terraform test'