Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Jeconias Santos 2025-06-14 15:02:51 -03:00
commit c70b79dca5
95 changed files with 2657 additions and 547 deletions

View file

@ -2,11 +2,13 @@ dependencies:
plugins/gitfast: plugins/gitfast:
repo: felipec/git-completion repo: felipec/git-completion
branch: master branch: master
version: tag:v2.1 version: tag:v2.2
postcopy: | postcopy: |
set -e set -e
rm -rf git-completion.plugin.zsh Makefile README.adoc t tools rm -rf git-completion.plugin.zsh Makefile t tools
test -e git-completion.zsh && mv -f git-completion.zsh _git mv README.adoc MANUAL.adoc
mv -f src/* .
rmdir src
plugins/gradle: plugins/gradle:
repo: gradle/gradle-completion repo: gradle/gradle-completion
branch: master branch: master
@ -28,7 +30,7 @@ dependencies:
plugins/wd: plugins/wd:
repo: mfaerevaag/wd repo: mfaerevaag/wd
branch: master branch: master
version: tag:v0.9.2 version: tag:v0.10.0
precopy: | precopy: |
set -e set -e
rm -r test rm -r test
@ -36,7 +38,7 @@ dependencies:
plugins/z: plugins/z:
branch: master branch: master
repo: agkozak/zsh-z repo: agkozak/zsh-z
version: afaf2965b41fdc6ca66066e09382726aa0b6aa04 version: cf9225feebfae55e557e103e95ce20eca5eff270
precopy: | precopy: |
set -e set -e
test -e README.md && mv -f README.md MANUAL.md test -e README.md && mv -f README.md MANUAL.md

View file

@ -1,7 +1,7 @@
certifi==2024.8.30 certifi==2025.4.26
charset-normalizer==3.4.0 charset-normalizer==3.4.2
idna==3.10 idna==3.10
PyYAML==6.0.2 PyYAML==6.0.2
requests==2.32.3 requests==2.32.4
semver==3.0.2 semver==3.0.4
urllib3==2.2.3 urllib3==2.4.0

3
.gitignore vendored
View file

@ -10,3 +10,6 @@ log/
# editor configs # editor configs
.vscode .vscode
.idea .idea
# zcompile cached files
*.zwc

View file

@ -163,7 +163,7 @@ adds any) and extra goodies that are included in that particular plugin.
### Themes ### Themes
We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme-happy. We have over one
hundred and fifty themes now bundled. Most of them have hundred and fifty themes now bundled. Most of them have
[screenshots](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) on the wiki (We are working on updating this!). [screenshots](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) on the wiki (We are working on updating this!).
Check them out! Check them out!
@ -218,7 +218,7 @@ terminal window.
ZSH_THEME="random" # (...please let it be pie... please be some pie..) ZSH_THEME="random" # (...please let it be pie... please be some pie..)
``` ```
And if you want to pick random theme from a list of your favorite themes: And if you want to pick a random theme from a list of your favorite themes:
```sh ```sh
ZSH_THEME_RANDOM_CANDIDATES=( ZSH_THEME_RANDOM_CANDIDATES=(
@ -426,7 +426,7 @@ turn it off by setting the following in your .zshrc file, before Oh My Zsh is so
zstyle ':omz:alpha:lib:git' async-prompt no zstyle ':omz:alpha:lib:git' async-prompt no
``` ```
If your problem is that the git prompt just stopped appearing, you can try to force it setting the following If your problem is that the git prompt just stopped appearing, you can try to force it by setting the following
configuration before `oh-my-zsh.sh` is sourced. If it still does not work, please open an issue with your configuration before `oh-my-zsh.sh` is sourced. If it still does not work, please open an issue with your
case. case.
@ -487,6 +487,17 @@ wait a week?) you just need to run:
omz update omz update
``` ```
> [!NOTE]
> If you want to automate this process in a script, you should call directly the `upgrade` script, like this:
>
> ```sh
> $ZSH/tools/upgrade.sh
> ```
>
> See more options in the [FAQ: How do I update Oh My Zsh?](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#how-do-i-update-oh-my-zsh).
>
> **USE OF `omz update --unattended` HAS BEEN REMOVED, AS IT HAS SIDE EFFECTS**.
Magic! 🎉 Magic! 🎉
## Uninstalling Oh My Zsh ## Uninstalling Oh My Zsh

View file

@ -26,7 +26,7 @@ autoload -Uz is-at-least
# This API is subject to change and optimization. Rely on it at your own risk. # This API is subject to change and optimization. Rely on it at your own risk.
function _omz_register_handler { function _omz_register_handler {
setopt localoptions noksharrays setopt localoptions noksharrays unset
typeset -ga _omz_async_functions typeset -ga _omz_async_functions
# we want to do nothing if there's no $1 function or we already set it up # we want to do nothing if there's no $1 function or we already set it up
if [[ -z "$1" ]] || (( ! ${+functions[$1]} )) \ if [[ -z "$1" ]] || (( ! ${+functions[$1]} )) \
@ -44,6 +44,7 @@ function _omz_register_handler {
# Set up async handlers and callbacks # Set up async handlers and callbacks
function _omz_async_request { function _omz_async_request {
setopt localoptions noksharrays unset
local -i ret=$? local -i ret=$?
typeset -gA _OMZ_ASYNC_FDS _OMZ_ASYNC_PIDS _OMZ_ASYNC_OUTPUT typeset -gA _OMZ_ASYNC_FDS _OMZ_ASYNC_PIDS _OMZ_ASYNC_OUTPUT

View file

@ -1,6 +1,7 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
function omz { function omz {
setopt localoptions noksharrays
[[ $# -gt 0 ]] || { [[ $# -gt 0 ]] || {
_omz::help _omz::help
return 1 return 1
@ -71,6 +72,10 @@ function _omz {
local -aU plugins local -aU plugins
plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t)) plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
_describe 'plugin' plugins ;; _describe 'plugin' plugins ;;
plugin::list)
local -a opts
opts=('--enabled:List enabled plugins only')
_describe -o 'options' opts ;;
theme::(set|use)) theme::(set|use))
local -aU themes local -aU themes
themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::)) themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
@ -192,7 +197,7 @@ EOF
return 1 return 1
fi fi
"$ZSH/tools/changelog.sh" "$version" "${2:-}" "$format" ZSH="$ZSH" command zsh -f "$ZSH/tools/changelog.sh" "$version" "${2:-}" "$format"
} }
function _omz::plugin { function _omz::plugin {
@ -205,7 +210,7 @@ Available commands:
disable <plugin> Disable plugin(s) disable <plugin> Disable plugin(s)
enable <plugin> Enable plugin(s) enable <plugin> Enable plugin(s)
info <plugin> Get information of a plugin info <plugin> Get information of a plugin
list List all available Oh My Zsh plugins list [--enabled] List Oh My Zsh plugins
load <plugin> Load plugin(s) load <plugin> Load plugin(s)
EOF EOF
@ -448,8 +453,21 @@ function _omz::plugin::info {
function _omz::plugin::list { function _omz::plugin::list {
local -a custom_plugins builtin_plugins local -a custom_plugins builtin_plugins
custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
builtin_plugins=("$ZSH"/plugins/*(-/N:t)) # If --enabled is provided, only list what's enabled
if [[ "$1" == "--enabled" ]]; then
local plugin
for plugin in "${plugins[@]}"; do
if [[ -d "${ZSH_CUSTOM}/plugins/${plugin}" ]]; then
custom_plugins+=("${plugin}")
elif [[ -d "${ZSH}/plugins/${plugin}" ]]; then
builtin_plugins+=("${plugin}")
fi
done
else
custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
builtin_plugins=("$ZSH"/plugins/*(-/N:t))
fi
# If the command is being piped, print all found line by line # If the command is being piped, print all found line by line
if [[ ! -t 1 ]]; then if [[ ! -t 1 ]]; then
@ -822,6 +840,13 @@ function _omz::update {
return 1 return 1
} }
# Check if --unattended was passed
[[ "$1" != --unattended ]] || {
_omz::log error "the \`\e[2m--unattended\e[0m\` flag is no longer supported, use the \`\e[2mupgrade.sh\e[0m\` script instead."
_omz::log error "for more information see https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#how-do-i-update-oh-my-zsh"
return 1
}
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null) local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)
[[ $? -eq 0 ]] || { [[ $? -eq 0 ]] || {
_omz::log error "\`$ZSH\` is not a git directory. Aborting..." _omz::log error "\`$ZSH\` is not a git directory. Aborting..."
@ -830,11 +855,7 @@ function _omz::update {
# Run update script # Run update script
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
if [[ "$1" != --unattended ]]; then ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode || return $?
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode || return $?
else
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -v $verbose_mode || return $?
fi
# Update last updated file # Update last updated file
zmodload zsh/datetime zmodload zsh/datetime
@ -843,7 +864,7 @@ function _omz::update {
command rm -rf "$ZSH/log/update.lock" command rm -rf "$ZSH/log/update.lock"
# Restart the zsh session if there were changes # Restart the zsh session if there were changes
if [[ "$1" != --unattended && "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then if [[ "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
# Old zsh versions don't have ZSH_ARGZERO # Old zsh versions don't have ZSH_ARGZERO
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell # Check whether to run a login shell

View file

@ -23,6 +23,9 @@ function open_command() {
linux*) [[ "$(uname -r)" != *icrosoft* ]] && open_cmd='nohup xdg-open' || { linux*) [[ "$(uname -r)" != *icrosoft* ]] && open_cmd='nohup xdg-open' || {
open_cmd='cmd.exe /c start ""' open_cmd='cmd.exe /c start ""'
[[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 } [[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 }
[[ "$1" = (http|https)://* ]] && {
1="$(echo "$1" | sed -E 's/([&|()<>^])/^\1/g')" || return 1
}
} ;; } ;;
msys*) open_cmd='start ""' ;; msys*) open_cmd='start ""' ;;
*) echo "Platform $OSTYPE not supported" *) echo "Platform $OSTYPE not supported"

View file

@ -39,6 +39,105 @@ function _omz_git_prompt_info() {
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}" echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
} }
function _omz_git_prompt_status() {
[[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
# Maps a git status prefix to an internal constant
# This cannot use the prompt constants, as they may be empty
local -A prefix_constant_map
prefix_constant_map=(
'\?\? ' 'UNTRACKED'
'A ' 'ADDED'
'M ' 'MODIFIED'
'MM ' 'MODIFIED'
' M ' 'MODIFIED'
'AM ' 'MODIFIED'
' T ' 'MODIFIED'
'R ' 'RENAMED'
' D ' 'DELETED'
'D ' 'DELETED'
'UU ' 'UNMERGED'
'ahead' 'AHEAD'
'behind' 'BEHIND'
'diverged' 'DIVERGED'
'stashed' 'STASHED'
)
# Maps the internal constant to the prompt theme
local -A constant_prompt_map
constant_prompt_map=(
'UNTRACKED' "$ZSH_THEME_GIT_PROMPT_UNTRACKED"
'ADDED' "$ZSH_THEME_GIT_PROMPT_ADDED"
'MODIFIED' "$ZSH_THEME_GIT_PROMPT_MODIFIED"
'RENAMED' "$ZSH_THEME_GIT_PROMPT_RENAMED"
'DELETED' "$ZSH_THEME_GIT_PROMPT_DELETED"
'UNMERGED' "$ZSH_THEME_GIT_PROMPT_UNMERGED"
'AHEAD' "$ZSH_THEME_GIT_PROMPT_AHEAD"
'BEHIND' "$ZSH_THEME_GIT_PROMPT_BEHIND"
'DIVERGED' "$ZSH_THEME_GIT_PROMPT_DIVERGED"
'STASHED' "$ZSH_THEME_GIT_PROMPT_STASHED"
)
# The order that the prompt displays should be added to the prompt
local status_constants
status_constants=(
UNTRACKED ADDED MODIFIED RENAMED DELETED
STASHED UNMERGED AHEAD BEHIND DIVERGED
)
local status_text
status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)"
# Don't continue on a catastrophic failure
if [[ $? -eq 128 ]]; then
return 1
fi
# A lookup table of each git status encountered
local -A statuses_seen
if __git_prompt_git rev-parse --verify refs/stash &>/dev/null; then
statuses_seen[STASHED]=1
fi
local status_lines
status_lines=("${(@f)${status_text}}")
# If the tracking line exists, get and parse it
if [[ "$status_lines[1]" =~ "^## [^ ]+ \[(.*)\]" ]]; then
local branch_statuses
branch_statuses=("${(@s/,/)match}")
for branch_status in $branch_statuses; do
if [[ ! $branch_status =~ "(behind|diverged|ahead) ([0-9]+)?" ]]; then
continue
fi
local last_parsed_status=$prefix_constant_map[$match[1]]
statuses_seen[$last_parsed_status]=$match[2]
done
fi
# For each status prefix, do a regex comparison
for status_prefix in ${(k)prefix_constant_map}; do
local status_constant="${prefix_constant_map[$status_prefix]}"
local status_regex=$'(^|\n)'"$status_prefix"
if [[ "$status_text" =~ $status_regex ]]; then
statuses_seen[$status_constant]=1
fi
done
# Display the seen statuses in the order specified
local status_prompt
for status_constant in $status_constants; do
if (( ${+statuses_seen[$status_constant]} )); then
local next_display=$constant_prompt_map[$status_constant]
status_prompt="$next_display$status_prompt"
fi
done
echo $status_prompt
}
# Use async version if setting is enabled, or unset but zsh version is at least 5.0.6. # Use async version if setting is enabled, or unset but zsh version is at least 5.0.6.
# This avoids async prompt issues caused by previous zsh versions: # This avoids async prompt issues caused by previous zsh versions:
# - https://github.com/ohmyzsh/ohmyzsh/issues/12331 # - https://github.com/ohmyzsh/ohmyzsh/issues/12331
@ -246,105 +345,6 @@ function git_prompt_long_sha() {
SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
} }
function _omz_git_prompt_status() {
[[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
# Maps a git status prefix to an internal constant
# This cannot use the prompt constants, as they may be empty
local -A prefix_constant_map
prefix_constant_map=(
'\?\? ' 'UNTRACKED'
'A ' 'ADDED'
'M ' 'MODIFIED'
'MM ' 'MODIFIED'
' M ' 'MODIFIED'
'AM ' 'MODIFIED'
' T ' 'MODIFIED'
'R ' 'RENAMED'
' D ' 'DELETED'
'D ' 'DELETED'
'UU ' 'UNMERGED'
'ahead' 'AHEAD'
'behind' 'BEHIND'
'diverged' 'DIVERGED'
'stashed' 'STASHED'
)
# Maps the internal constant to the prompt theme
local -A constant_prompt_map
constant_prompt_map=(
'UNTRACKED' "$ZSH_THEME_GIT_PROMPT_UNTRACKED"
'ADDED' "$ZSH_THEME_GIT_PROMPT_ADDED"
'MODIFIED' "$ZSH_THEME_GIT_PROMPT_MODIFIED"
'RENAMED' "$ZSH_THEME_GIT_PROMPT_RENAMED"
'DELETED' "$ZSH_THEME_GIT_PROMPT_DELETED"
'UNMERGED' "$ZSH_THEME_GIT_PROMPT_UNMERGED"
'AHEAD' "$ZSH_THEME_GIT_PROMPT_AHEAD"
'BEHIND' "$ZSH_THEME_GIT_PROMPT_BEHIND"
'DIVERGED' "$ZSH_THEME_GIT_PROMPT_DIVERGED"
'STASHED' "$ZSH_THEME_GIT_PROMPT_STASHED"
)
# The order that the prompt displays should be added to the prompt
local status_constants
status_constants=(
UNTRACKED ADDED MODIFIED RENAMED DELETED
STASHED UNMERGED AHEAD BEHIND DIVERGED
)
local status_text
status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)"
# Don't continue on a catastrophic failure
if [[ $? -eq 128 ]]; then
return 1
fi
# A lookup table of each git status encountered
local -A statuses_seen
if __git_prompt_git rev-parse --verify refs/stash &>/dev/null; then
statuses_seen[STASHED]=1
fi
local status_lines
status_lines=("${(@f)${status_text}}")
# If the tracking line exists, get and parse it
if [[ "$status_lines[1]" =~ "^## [^ ]+ \[(.*)\]" ]]; then
local branch_statuses
branch_statuses=("${(@s/,/)match}")
for branch_status in $branch_statuses; do
if [[ ! $branch_status =~ "(behind|diverged|ahead) ([0-9]+)?" ]]; then
continue
fi
local last_parsed_status=$prefix_constant_map[$match[1]]
statuses_seen[$last_parsed_status]=$match[2]
done
fi
# For each status prefix, do a regex comparison
for status_prefix in ${(k)prefix_constant_map}; do
local status_constant="${prefix_constant_map[$status_prefix]}"
local status_regex=$'(^|\n)'"$status_prefix"
if [[ "$status_text" =~ $status_regex ]]; then
statuses_seen[$status_constant]=1
fi
done
# Display the seen statuses in the order specified
local status_prompt
for status_constant in $status_constants; do
if (( ${+statuses_seen[$status_constant]} )); then
local next_display=$constant_prompt_map[$status_constant]
status_prompt="$next_display$status_prompt"
fi
done
echo $status_prompt
}
# Outputs the name of the current user # Outputs the name of the current user
# Usage example: $(git_current_user_name) # Usage example: $(git_current_user_name)
function git_current_user_name() { function git_current_user_name() {

View file

@ -18,10 +18,10 @@ function omz_history {
print -u2 History file deleted. print -u2 History file deleted.
elif [[ $# -eq 0 ]]; then elif [[ $# -eq 0 ]]; then
# if no arguments provided, show full history starting from 1 # if no arguments provided, show full history starting from 1
builtin fc $stamp -l 1 builtin fc "${stamp[@]}" -l 1
else else
# otherwise, run `fc -l` with a custom format # otherwise, run `fc -l` with a custom format
builtin fc $stamp -l "$@" builtin fc "${stamp[@]}" -l "$@"
fi fi
} }

View file

@ -17,7 +17,7 @@ function title {
: ${2=$1} : ${2=$1}
case "$TERM" in case "$TERM" in
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty*|st*|foot*|contour*) cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty*|st*|foot*|contour*|wezterm*)
print -Pn "\e]2;${2:q}\a" # set window name print -Pn "\e]2;${2:q}\a" # set window name
print -Pn "\e]1;${1:q}\a" # set tab name print -Pn "\e]1;${1:q}\a" # set tab name
;; ;;
@ -47,7 +47,7 @@ fi
# Runs before showing the prompt # Runs before showing the prompt
function omz_termsupport_precmd { function omz_termsupport_precmd {
[[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return [[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return 0
title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE" title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE"
} }
@ -145,6 +145,7 @@ esac
# Identifies the directory using a file: URI scheme, including # Identifies the directory using a file: URI scheme, including
# the host name to disambiguate local vs. remote paths. # the host name to disambiguate local vs. remote paths.
function omz_termsupport_cwd { function omz_termsupport_cwd {
setopt localoptions unset
# Percent-encode the host and path names. # Percent-encode the host and path names.
local URL_HOST URL_PATH local URL_HOST URL_PATH
URL_HOST="$(omz_urlencode -P $HOST)" || return 1 URL_HOST="$(omz_urlencode -P $HOST)" || return 1

View file

@ -192,7 +192,7 @@ _omz_source() {
fi fi
} }
# Load all of the lib files in ~/oh-my-zsh/lib that end in .zsh # Load all of the lib files in ~/.oh-my-zsh/lib that end in .zsh
# TIP: Add files you don't want in git to .gitignore # TIP: Add files you don't want in git to .gitignore
for lib_file ("$ZSH"/lib/*.zsh); do for lib_file ("$ZSH"/lib/*.zsh); do
_omz_source "lib/${lib_file:t}" _omz_source "lib/${lib_file:t}"

View file

@ -36,14 +36,18 @@ alias-finder() {
# make filter to find only shorter results than current cmd # make filter to find only shorter results than current cmd
if [[ $cheaper == true ]]; then if [[ $cheaper == true ]]; then
cmdLen=$(echo -n "$cmd" | wc -c) cmdLen=$(echo -n "$cmd" | wc -c)
filter="^'{0,1}.{0,$((cmdLen - 1))}=" if [[ $cmdLen -le 1 ]]; then
return
fi
filter="^'?.{1,$((cmdLen - 1))}'?=" # some aliases is surrounded by single quotes
fi fi
alias | grep -E "$filter" | grep -E "=$finder" alias | grep -E "$filter" | grep -E "=$finder"
if [[ $exact == true ]]; then if [[ $exact == true ]]; then
break # because exact case is only one break # because exact case is only one
elif [[ $longer = true ]]; then elif [[ $longer == true ]]; then
break # because above grep command already found every longer aliases during first cycle break # because above grep command already found every longer aliases during first cycle
fi fi

View file

@ -178,26 +178,27 @@ fi
# Check Arch Linux PGP Keyring before System Upgrade to prevent failure. # Check Arch Linux PGP Keyring before System Upgrade to prevent failure.
function upgrade() { function upgrade() {
sudo pacman -Sy
echo ":: Checking Arch Linux PGP Keyring..." echo ":: Checking Arch Linux PGP Keyring..."
local installedver="$(LANG= sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')" local installedver="$(LANG= sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
local currentver="$(LANG= sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')" local currentver="$(LANG= sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
if [ $installedver != $currentver ]; then if [ $installedver != $currentver ]; then
echo " Arch Linux PGP Keyring is out of date." echo " Arch Linux PGP Keyring is out of date."
echo " Updating before full system upgrade." echo " Updating before full system upgrade."
sudo pacman -Sy --needed --noconfirm archlinux-keyring sudo pacman -S --needed --noconfirm archlinux-keyring
else else
echo " Arch Linux PGP Keyring is up to date." echo " Arch Linux PGP Keyring is up to date."
echo " Proceeding with full system upgrade." echo " Proceeding with full system upgrade."
fi fi
if (( $+commands[yay] )); then if (( $+commands[yay] )); then
yay -Syu yay -Su
elif (( $+commands[trizen] )); then elif (( $+commands[trizen] )); then
trizen -Syu trizen -Su
elif (( $+commands[pacaur] )); then elif (( $+commands[pacaur] )); then
pacaur -Syu pacaur -Su
elif (( $+commands[aura] )); then elif (( $+commands[aura] )); then
sudo aura -Syu sudo aura -Su
else else
sudo pacman -Syu sudo pacman -Su
fi fi
} }

View file

@ -1,32 +1,48 @@
## asdf # asdf
Adds integration with [asdf](https://github.com/asdf-vm/asdf), the extendable version manager, with support for Ruby, Node.js, Elixir, Erlang and more. Adds integration with [asdf](https://github.com/asdf-vm/asdf), the extendable version manager, with support for Ruby, Node.js, Elixir, Erlang and more.
### Installation ## Installation
1. [Download asdf](https://asdf-vm.com/guide/getting-started.html#_2-download-asdf) by running the following: 1. [Install](https://asdf-vm.com/guide/getting-started.html#_1-install-asdf) asdf and ensure that's it's discoverable on `$PATH`;
2. Enable it by adding it to your `plugins` definition in `~/.zshrc`:
```
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
```
2. [Enable asdf](https://asdf-vm.com/guide/getting-started.html#_3-install-asdf) by adding it to your `plugins` definition in `~/.zshrc`.
```
plugins=(asdf)
```
### Usage
See the [asdf documentation](https://asdf-vm.com/guide/getting-started.html#_4-install-a-plugin) for information on how to use asdf:
```sh
plugins=(asdf)
``` ```
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
## Usage
Refer to the [asdf plugin documentation](https://asdf-vm.com/guide/getting-started.html#_4-install-a-plugin) for information on how to add a plugin and install the many runtime versions for it.
Example for installing the nodejs plugin and the many runtimes for it:
```sh
# Add plugin to asdf
asdf plugin add nodejs
# Install the latest available version
asdf install nodejs latest asdf install nodejs latest
asdf global nodejs latest
asdf local nodejs latest # Uninstall the latest version
asdf uninstall nodejs latest
# Install a specific version
asdf install nodejs 16.5.0
# Set the latest version in .tool-versions of the `current directory`
asdf set nodejs latest
# Set a specific version in the `parent directory`
asdf set -p nodejs 16.5.0 # -p is shorthand for --parent
# Set a global version under `$HOME`
asdf set -u nodejs 16.5.0 # -u is shorthand for --home
``` ```
### Maintainer For more commands, run `asdf help` or refer to the
[asdf CLI documentation](https://asdf-vm.com/manage/commands.html#all-commands).
## Maintainer
- [@RobLoach](https://github.com/RobLoach) - [@RobLoach](https://github.com/RobLoach)

View file

@ -1,30 +1,13 @@
# Find where asdf should be installed (( ! $+commands[asdf] )) && return
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
ASDF_COMPLETIONS="$ASDF_DIR/completions"
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/_asdf" ]]; then export ASDF_DATA_DIR="${ASDF_DATA_DIR:-$HOME/.asdf}"
# If not found, check for archlinux/AUR package (/opt/asdf-vm/) path=("$ASDF_DATA_DIR/shims" $path)
if [[ -f "/opt/asdf-vm/asdf.sh" ]]; then
ASDF_DIR="/opt/asdf-vm"
ASDF_COMPLETIONS="$ASDF_DIR"
# If not found, check for Homebrew package
elif (( $+commands[brew] )); then
_ASDF_PREFIX="$(brew --prefix asdf)"
ASDF_DIR="${_ASDF_PREFIX}/libexec"
ASDF_COMPLETIONS="${_ASDF_PREFIX}/share/zsh/site-functions"
unset _ASDF_PREFIX
else
return
fi
fi
# Load command # If the completion file doesn't exist yet, we need to autoload it and
if [[ -f "$ASDF_DIR/asdf.sh" ]]; then # bind it to `asdf`. Otherwise, compinit will have already done that.
source "$ASDF_DIR/asdf.sh" if [[ ! -f "$ZSH_CACHE_DIR/completions/_asdf" ]]; then
# Load completions typeset -g -A _comps
if [[ -f "$ASDF_COMPLETIONS/_asdf" ]]; then autoload -Uz _asdf
fpath+=("$ASDF_COMPLETIONS") _comps[asdf]=_asdf
autoload -Uz _asdf
compdef _asdf asdf # compdef is already loaded before loading plugins
fi
fi fi
asdf completion zsh >| "$ZSH_CACHE_DIR/completions/_asdf" &|

View file

@ -62,7 +62,7 @@ function bgnotify_formatted {
function bgnotify_appid { function bgnotify_appid {
if (( ${+commands[osascript]} )); then if (( ${+commands[osascript]} )); then
osascript -e "tell application id \"$(bgnotify_programid)\" to get the {id, frontmost, id of front window, visible of front window}" 2>/dev/null osascript -e "tell application id \"$(bgnotify_programid)\" to get the {id, frontmost, id of front window, visible of front window}" 2>/dev/null
elif [[ -n $WAYLAND_DISPLAY ]] && (( ${+commands[swaymsg]} )); then # wayland+sway elif [[ -n $WAYLAND_DISPLAY ]] && ([[ -n $SWAYSOCK ]] || [[ -n $I3SOCK ]]) && (( ${+commands[swaymsg]} )); then # wayland+sway
local app_id=$(bgnotify_find_sway_appid) local app_id=$(bgnotify_find_sway_appid)
[[ -n "$app_id" ]] && echo "$app_id" || echo $EPOCHSECONDS [[ -n "$app_id" ]] && echo "$app_id" || echo $EPOCHSECONDS
elif [[ -z $WAYLAND_DISPLAY ]] && [[ -n $DISPLAY ]] && (( ${+commands[xprop]} )); then elif [[ -z $WAYLAND_DISPLAY ]] && [[ -n $DISPLAY ]] && (( ${+commands[xprop]} )); then

View file

@ -8,7 +8,7 @@ function branch_prompt_info() {
while [[ "$dir" != '/' ]]; do while [[ "$dir" != '/' ]]; do
# Found .git directory # Found .git directory
if [[ -d "${dir}/.git" ]]; then if [[ -d "${dir}/.git" ]]; then
branch="${"$(<"${dir}/.git/HEAD")"##*/}" branch="${"$(<"${dir}/.git/HEAD")"##ref: refs/heads/}"
echo '±' "${branch:gs/%/%%}" echo '±' "${branch:gs/%/%%}"
return return
fi fi

View file

@ -22,6 +22,8 @@ _source-from-homebrew() {
# check default brew prefix # check default brew prefix
if [[ -h /usr/local/opt/chruby ]];then if [[ -h /usr/local/opt/chruby ]];then
_brew_prefix="/usr/local/opt/chruby" _brew_prefix="/usr/local/opt/chruby"
elif [[ -h /opt/homebrew/opt/chruby ]]; then
_brew_prefix="/opt/homebrew/opt/chruby"
else else
# ok , it is not default prefix # ok , it is not default prefix
# this call to brew is expensive ( about 400 ms ), so at least let's make it only once # this call to brew is expensive ( about 400 ms ), so at least let's make it only once

View file

@ -36,3 +36,10 @@ Last login: Fri Jan 30 23:12:26 on ttys001
- `cowsay` if using `chuck_cow` - `cowsay` if using `chuck_cow`
Available via homebrew, apt, ... Available via homebrew, apt, ...
> [!NOTE]
> In addition to installing `fortune`, it may be necessary to run:
>
> `strfile $ZSH/plugins/chucknorris/fortunes/chucknorris\n`
>
> (include the "\n" literally) to write the fortune data to the proper directory.

View file

@ -14,8 +14,8 @@ alias cnl='conda list'
alias cnle='conda list --export' alias cnle='conda list --export'
alias cnles='conda list --explicit > spec-file.txt' alias cnles='conda list --explicit > spec-file.txt'
alias cnr='conda remove' alias cnr='conda remove'
alias cnrn='conda remove -y -all -n' alias cnrn='conda remove -y --all -n'
alias cnrp='conda remove -y -all -p' alias cnrp='conda remove -y --all -p'
alias cnry='conda remove -y' alias cnry='conda remove -y'
alias cnsr='conda search' alias cnsr='conda search'
alias cnu='conda update' alias cnu='conda update'

View file

@ -83,9 +83,9 @@ else
} }
alias ac="su -ls '$apt_pref clean' root" alias ac="su -ls '$apt_pref clean' root"
alias ad="su -lc '$apt_pref update' root" alias ad="su -lc '$apt_pref update' root"
alias adg="su -lc '$apt_pref update && aptitude $apt_upgr' root" alias adg="su -lc '$apt_pref update && $apt_pref $apt_upgr' root"
alias adu="su -lc '$apt_pref update && aptitude dist-upgrade' root" alias adu="su -lc '$apt_pref update && $apt_pref dist-upgrade' root"
alias afu="su -lc '$apt-file update'" alias afu="su -lc 'apt-file update'"
alias au="su -lc '$apt_pref $apt_upgr' root" alias au="su -lc '$apt_pref $apt_upgr' root"
function ai() { function ai() {
cmd="su -lc '$apt_pref install $@' root" cmd="su -lc '$apt_pref install $@' root"

View file

@ -1,5 +1,8 @@
# Don't continue if direnv is not found # If direnv is not found, don't continue and print a warning
command -v direnv &>/dev/null || return if (( ! $+commands[direnv] )); then
echo "Warning: direnv not found. Please install direnv and ensure it's in your PATH before using this plugin."
return
fi
_direnv_hook() { _direnv_hook() {
trap -- '' SIGINT; trap -- '' SIGINT;

View file

@ -60,3 +60,46 @@ to `/usr` again.
After that, <kbd>Alt</kbd> + <kbd>Down</kbd> will probably go to `/usr/bin` if `bin` is the first directory in alphabetical After that, <kbd>Alt</kbd> + <kbd>Down</kbd> will probably go to `/usr/bin` if `bin` is the first directory in alphabetical
order (depends on your `/usr` folder structure). <kbd>Alt</kbd> + <kbd>Up</kbd> will return to `/usr`, and once more will get order (depends on your `/usr` folder structure). <kbd>Alt</kbd> + <kbd>Up</kbd> will return to `/usr`, and once more will get
you to the root folder (`/`). you to the root folder (`/`).
### cde
This plugin also provides a `cde` alias that allows you to change to a directory without clearing the next directory stack.
This changes the default behavior of `dirhistory`, which is to clear the next directory stack when changing directories.
For example, if the shell was started, and the following commands were entered:
```shell
cd ~
cd /usr
cd share
cd doc
# <Alt + Left>
# <Alt + Left>
```
The directory stack would look like this:
```sh
➜ /usr typeset -pm dirhistory_\*
typeset -ax dirhistory_past=( /home/user /usr )
typeset -ax dirhistory_future=( /usr/share/doc /usr/share )
```
This means that pressing <kbd>Alt</kbd> + <kbd>Right</kbd>, you'd go to `/usr/share` and `/usr/share/doc` (the "future" directories).
If you run `cd /usr/bin`, the "future" directories will be removed, and you won't be able to access them with <kbd>Alt</kbd> + <kbd>Right</kbd>:
```sh
➜ /u/bin typeset -pm dirhistory_\*
typeset -ax dirhistory_past=( /home/user /usr )
typeset -ax dirhistory_future=( /usr/bin )
```
If you instead run `cde /usr/bin`, the "future" directories will be preserved:
```sh
➜ /u/bin typeset -pm dirhistory_\*
typeset -ax dirhistory_past=( /home/user /usr /usr/bin )
typeset -ax dirhistory_future=( /usr/share/doc /usr/share )
```

View file

@ -11,9 +11,10 @@ dirhistory_past=($PWD)
dirhistory_future=() dirhistory_future=()
export dirhistory_past export dirhistory_past
export dirhistory_future export dirhistory_future
export DIRHISTORY_SIZE=30 export DIRHISTORY_SIZE=30
alias cde='dirhistory_cd'
# Pop the last element of dirhistory_past. # Pop the last element of dirhistory_past.
# Pass the name of the variable to return the result in. # Pass the name of the variable to return the result in.
# Returns the element if the array was not empty, # Returns the element if the array was not empty,
@ -136,7 +137,11 @@ for keymap in emacs vicmd viins; do
case "$TERM_PROGRAM" in case "$TERM_PROGRAM" in
Apple_Terminal) bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back ;; # Terminal.app Apple_Terminal) bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back ;; # Terminal.app
iTerm.app) bindkey -M $keymap "^[^[[D" dirhistory_zle_dirhistory_back ;; # iTerm2 ghostty) bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back ;; # ghostty
iTerm.app)
bindkey -M $keymap "^[^[[D" dirhistory_zle_dirhistory_back
bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back
;;
esac esac
if (( ${+terminfo[kcub1]} )); then if (( ${+terminfo[kcub1]} )); then
@ -151,7 +156,11 @@ for keymap in emacs vicmd viins; do
case "$TERM_PROGRAM" in case "$TERM_PROGRAM" in
Apple_Terminal) bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future ;; # Terminal.app Apple_Terminal) bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future ;; # Terminal.app
iTerm.app) bindkey -M $keymap "^[^[[C" dirhistory_zle_dirhistory_future ;; # iTerm2 ghostty) bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future ;; # ghostty
iTerm.app)
bindkey -M $keymap "^[^[[C" dirhistory_zle_dirhistory_future
bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future
;;
esac esac
if (( ${+terminfo[kcuf1]} )); then if (( ${+terminfo[kcuf1]} )); then
@ -200,6 +209,7 @@ for keymap in emacs vicmd viins; do
case "$TERM_PROGRAM" in case "$TERM_PROGRAM" in
Apple_Terminal) bindkey -M $keymap "^[[A" dirhistory_zle_dirhistory_up ;; # Terminal.app Apple_Terminal) bindkey -M $keymap "^[[A" dirhistory_zle_dirhistory_up ;; # Terminal.app
iTerm.app) bindkey -M $keymap "^[^[[A" dirhistory_zle_dirhistory_up ;; # iTerm2 iTerm.app) bindkey -M $keymap "^[^[[A" dirhistory_zle_dirhistory_up ;; # iTerm2
ghostty) bindkey -M $keymap "^[[1;3A" dirhistory_zle_dirhistory_up ;; # ghostty
esac esac
if (( ${+terminfo[kcuu1]} )); then if (( ${+terminfo[kcuu1]} )); then
@ -215,6 +225,7 @@ for keymap in emacs vicmd viins; do
case "$TERM_PROGRAM" in case "$TERM_PROGRAM" in
Apple_Terminal) bindkey -M $keymap "^[[B" dirhistory_zle_dirhistory_down ;; # Terminal.app Apple_Terminal) bindkey -M $keymap "^[[B" dirhistory_zle_dirhistory_down ;; # Terminal.app
iTerm.app) bindkey -M $keymap "^[^[[B" dirhistory_zle_dirhistory_down ;; # iTerm2 iTerm.app) bindkey -M $keymap "^[^[[B" dirhistory_zle_dirhistory_down ;; # iTerm2
ghostty) bindkey -M $keymap "^[[1;3B" dirhistory_zle_dirhistory_down ;; # ghostty
esac esac
if (( ${+terminfo[kcud1]} )); then if (( ${+terminfo[kcud1]} )); then

570
plugins/dnf/_dnf5 Normal file
View file

@ -0,0 +1,570 @@
#compdef dnf5
# based on dnf-5.2.6.2
# utility functions
_dnf5_helper() {
_call_program specs $service "${(q-)@}" "${(q-)PREFIX}\*" \
-qC --assumeno --nogpgcheck 2>/dev/null </dev/null
}
_dnf5_repositories() {
# required option: -T (all|disabled|enabled)
local selected expl
zparseopts -D -E - T:=selected
selected=$selected[2]
_wanted $selected-repositories expl "$selected repository" \
compadd "$@" - "${(@)${(f)$(_dnf5_helper repo list --$selected)}[2,-1]%% *}"
}
_dnf5_packages() {
# required option: -T (all|available|installed|upgradable)
local selected opt expl
zparseopts -D -E - T:=selected
selected=$selected[2]
case $selected in
all) opt='' ;; # option --all does not exist
upgradable) opt='--upgrades' ;;
*) opt="--$selected" ;;
esac
_wanted $selected-packages expl "$selected package" \
compadd "$@" - $(_dnf5_helper repoquery $opt --qf='%{name} ')
}
_dnf5_rpm_files() {
local expl
_wanted rpm-files expl 'rpm file' _files -g '(#i)*.rpm(-.)'
}
_dnf5_packages_or_rpms() {
if [[ "$words[CURRENT]" = (*/*|\~*) ]]; then # if looks like a path name
_dnf5_rpm_files
else
_dnf5_packages "$@"
fi
}
_dnf5_groups() {
# optional option: -T (available|installed)
local update_policy selected line pat groups
zparseopts -D -E - T:=selected
selected=$selected[2]
if [[ -z $selected ]]; then
selected=all
opt= # option --all does not exist
else
opt=--$selected
fi
# XXX hidden groups are not included
for line in ${${(f)"$(_dnf5_helper group list $opt)"}[2,-1]}; do
line=( ${(z)line} )
groups+=( "$line[1]:$line[2,-2]" )
done
_describe -t $selected-groups "$selected group" groups
}
_dnf5_environments() {
local line envs
for line in ${${(f)"$(_dnf5_helper environment list)"}[2,-1]}; do
line=( ${(z)line} )
envs+=( "$line[1]:$line[2,-2]" )
done
_describe -t environments 'environment' envs
}
# completers for (several) dnf commands
_dnf5-advisory () {
_arguments : \
$advisory_opts \
'--contains-pkgs=[only show advisories containing specified packages]: : _sequence _dnf5_packages -T installed' \
+ '(with)' \
'--with-cve[show only advisories referencing CVE ticket]' \
'--with-bz[show only advisories referencing Bugzilla ticket]' \
+ '(type)' \
'--all[show all advisories]' \
'--available[show advisories containing newer versions of installed packages (default)]' \
'--installed[show advisories containing equal and older version of installed packages]' \
'--updates[show advisories containing upgradable packages]' \
+ args \
':subcommand:(list info summary)' '*:advisory spec:'
}
_dnf5-group() {
local -a tmp
if (( CURRENT == 2 )); then
tmp=(
'list:list all matching groups'
'info:print detailed information about groups'
'install:install packages from specified groups'
'remove:remove removable packages in specified groups'
'upgrade:upgrade specified groups and packages in them'
)
_describe -t subcommands 'subcommand' tmp
else
case $words[2] in
list|info)
tmp=(
'(--installed)--available[show only available groups]'
'(--available)--installed[show only installed groups]'
'--hidden[show also hidden groups]'
'--contains-pkgs=[show only groups containing specified packages]: : _sequence _dnf5_packages -T all'
'*: : _dnf5_groups'
)
;;
install)
tmp=( $common_opts
'--with-optional[include optional packages from the groups]'
'*: : _dnf5_groups -T available' )
;|
upgrade)
tmp=( ${common_opts:#--skip-broken*}
'*: : _dnf5_groups -T installed' )
;|
remove)
tmp=( $offline_opts
'*: : _dnf5_groups -T installed' )
;|
install|remove)
tmp+=( '--no-packages[operate on groups only, not manipulate any packages]' )
;|
install|upgrade)
tmp+=( $downgrade_opts )
;;
esac
_arguments : $tmp
fi
}
_dnf5-history() {
local -a tmp
if (( CURRENT == 2 )); then
tmp=(
'list:list info about recorded transactions'
'info:print detailed about specific transactions'
'undo:revert all actions from the specified transaction'
'redo:repeat the specified transaction'
'rollback:undo all transactions performed after the specified transaction'
'store:store the transaction into a directory'
)
_describe -t subcommands 'subcommand' tmp
else
case $words[2] in
list|info)
tmp=( '--reverse[reverse the order of transactions in output]' )
;;
undo|rollback|redo)
tmp=( '--skip-unavailable[allow skipping impossible actions]' )
;|
undo|rollback)
tmp+=( $replay_opts )
;;
store)
tmp=( {-o,--output=}'[directory for storing the transaction (default ./transaction)]: : _directories')
esac
_arguments : $tmp '2:transaction:( )'
fi
}
_dnf5-mark() {
local -a tmp
if (( CURRENT == 2 )); then
tmp=(
'user:mark the package as user-installed'
'dependency:mark the package as a dependency'
'weak:mark the package as a weak dependency'
'group:mark the package as installed by the specified group'
)
_describe -t subcommands 'subcommand' tmp
else
tmp=(
'--skip-unavailable[skip packages not installed on the system]'
'--store=[store the transaction in specified directory]: : _directories'
)
if [[ $words[2] = group ]]; then
tmp+=( '2:group-id: _dnf5_groups -T installed' )
fi
_arguments : $tmp '*: : _dnf5_packages -T installed'
fi
}
_dnf5-module() {
local -a tmp
if (( CURRENT == 2 )); then
tmp=(
'list:list module streams'
'info:print details about module streams'
'enable:enable module streams'
'disable:disable modules including all their streams'
"reset:reset module state so it's no longer enabled or disabled"
)
_describe -t subcommands 'subcommand' tmp
elif (( CURRENT == 3 )) && [[ $cur = -* ]]; then
case $words[2] in
list|info) tmp=( --enabled --disabled ) ;;
enable) tmp=( --skip-broken --skip-unavailable ) ;;
*) tmp=( --skip-unavailable ) ;;
esac
_wanted options expl 'option' compadd -a tmp
else
_message 'module spec'
fi
}
_dnf5-offline() { # also used by the 'system-upgrade' command
local -a tmp
if (( CURRENT == 2 )); then
tmp=(
'clean:remove any stored offline transactions and cached packages'
'log:list boots during which offline transaction was attempted'
'reboot:prepare the system for offline transaction and reboot'
)
if [[ $cmd = offline ]]; then
tmp+=( 'status:show status of the current offline transaction' )
else
tmp+=( 'download:download all packages needed for upgrade' )
fi
_describe -t subcommands 'subcommand' tmp && ret=0
else
case $words[2] in
download)
_arguments : \
'--releasever=[the version to upgrade to]:version number:' \
'--no-downgrade:do not install packages older than currently installed' '*: :' && ret=0
;;
log)
_arguments : \
'--number=[show log of transaction specified by number]:transaction number:' '*: :' && ret=0
;;
reboot)
_wanted options expl 'option' compadd -- --poweroff && ret=0
;;
esac
fi
}
_dnf5-repoquery() {
local v
local -a opts=(
$advisory_opts
'--arch=[limit results to specified architectures]:list of archs: '
'--available[limit results to available packages]'
'--disable-modular-filtering[include packages of inactive module streams]'
'--duplicates[limit to installed duplicate packages]'
'--exactdeps[limit to packages that require capability specified by ==what{requires,depends}]'
'--extras[limit to installed packages that are not present in any available repository]'
'--file=[limit results to packages which own specified file]:list of files: _sequence _files'
'--installed[query installed packages]'
'--installonly[limit to installed installonly packages]'
'--latest-limit=[limit to latest packages of specified number]:number:'
'--leaves[limit to groups of installed packages not required by other installed packages]'
'--providers-of=[select packages that provide specified attribute]:attribute:(conflicts depends enhances obsoletes provides recommends requires requires_pre suggests supplement)'
'--recent[limit to only recently changed packages]'
'--recursive[make --whatrequires/--providers-of work recursively]'
'--security[limit to packages in security advisories]'
'--srpm[use the corresponding source RPM]'
'--unneeded[limit to unneeded installed packages]'
'--upgrades[limit to available packages that provide upgrade for installed packages]'
'--userinstalled[limit to packages that are not installed as dependencies]'
'--whatdepends=[limit to packages that require, enhance, recommend, suggest of supplement specified capability]:list of capability:'
'--whatconflicts=[limit to packages that conflicts with specified capabilities]:list of capability: '
)
for v in enhance obsolete provide recommend require suggest supplement; do
opts+=( "--what${v}s=[limit to packages that $v specified capabilities]:list of capability: ")
done
# mutually exclusive formating options
opts+=(
+ '(format)'
'--conflicts[display capabilities that the package conflicts with]'
'--depends[display capabilities that the package depends on, enables, recommends, suggests or supplements]'
'--files[show files in the package]'
'--requires-pre[display capabilities required to run pre/post scripts of the package]'
'--sourcerpm[display source RPM of the package]'
'--location[display location of the package]'
'--info[show detailed information about the package]'
'--changelogs[print the package changelogs]'
'(- *)--querytags[list tags recognized by --queryformat]'
'--queryformat=[specify output format]:format:'
)
for v in enhance obsolete provide recommend require suggest supplement; do
opts+=( "--${v}s[display capabilities ${v}ed by the package]" )
done
_arguments : '*: : _dnf5_packages -T all' $opts
}
# dnf commands
_dnf5_commands() {
local -a dnf_cmds=(
'advisory:manage advisories'
'autoremove:remove unneeded packages'
'check:check for problems in package database'
'check-upgrade:check for available package upgrades'
'clean:remove or invalidate cached data'
'distro-sync:up/downgrade installed packages to the latest available'
'downgrade:downgrade packages'
'download:download packages'
'environment:manage comps environments'
'group:manage comps groups'
'history:manage transaction history'
'info:provide detailed information about packages'
'install:install packages'
'leaves:list groups of leaf packages'
'list:list installed or available packages'
'makecache:generate the metadata cache'
'mark:change the reason of an installed package'
'module:manage modules'
'offline:manage offline transactions'
'provides:find what package provides the given value'
'reinstall:reinstall packages'
'remove:remove packages'
'replay:replay stored transactions'
'repo:manage repositories'
'repoquery:search for packages in repositories'
'search:search for packages using keywords'
'swap:remove software and install another in the single transaction'
'system-upgrade:upgrade the system to a new major release'
'upgrade:upgrade packages'
'versionlock:protect packages from updates to newer versions'
)
_describe -t dnf-commands 'dnf command' dnf_cmds
}
# subcommands and options
_dnf5_subcmds_opts() {
local cur=$words[CURRENT] cmd=$words[1] expl ret=1
local -a tmp
# common options
local -a offline_opts=(
'(--store)--offline[store the transaction to be performed offline]'
'(--offline)--store=[store the transaction in specified directory]: : _directories'
)
local -a common_opts=(
$offline_opts
'--allowerasing[allow erasing of installed packages]'
'--skip-broken[resolve dependency problems by skipping problematic packages]'
"--skip-unavailable[skip packages that can't be synchronized]"
'--downloadonly[download packages without executing transaction]'
)
local -a advisory_opts=(
'--advisories=[consider only specified advisories]:list of advisories:'
'--advisory-severities=[limit to advisories with specified severity]:severity:_sequence compadd - critical important moderate low none'
'--bzs=[limit to advisories that fix specified Bugzilla ID]:list of Bugzilla ID:'
'--cves=[limit to advisories that fix specified CVE ID]:list of CVD ID]:'
'--security[limit to security advisories]'
'--bugfix[limit to bugfix advisories]'
'--enhancement[limit to enhancement advisories]'
'--newpackage[limit to newpackage advisories]'
)
local -a downgrade_opts=(
'(--no-allow-downgrade)--allow-downgrade[enable downgrade of dependencies]'
'(--allow-downgrade)--no-allow-downgrade[disable downgrade of dependencies]'
)
local -a replay_opts=(
'--ignore-extras[not consider extra packages]'
'--ignore-installed[mismatches between installed and stored transaction are not errors]'
)
# Deal with some aliases (not comprehensive)
case $cmd in
check-updgrade) cmd=check-update;;
dg) cmd=downgrade;;
dsync) cmd=distro-sync;;
grp) cmd=group;;
if) cmd=info;;
in) cmd=install;;
ls) cmd=list;;
mc) cmd=makecache;;
rei) cmd=reinstall;;
rm) cmd=remove ;;
rq) cmd=repoquery;;
se) cmd=search;;
update|up) cmd=upgrade;;
esac
local curcontext="${curcontext%:*:*}:dnf-${cmd}:"
case $cmd in
advisory|group|history|mark|module|offline|repoquery)
_dnf5-$cmd && ret=0
;;
system-upgrade)
_dnf5-offline && ret=0
;;
autoremove)
_arguments : $offline_opts && ret=0
;;
check)
_arguments : \
'--dependencies[show missing dependencies and conflicts]' \
'--duplicates[show duplicated packages]' \
'--obsoleted[show obsoleted packages]' && ret=0
;;
check-upgrade)
_arguments : \
$advisory_opts \
'--changelogs[print package changelogs]' \
'--minimal[reports the lowest versions of packages that fix advisories]' \
'*: : _dnf5_packages -T installed' && ret=0
;;
clean)
tmp=(
'dbcache:remove cache files generated from the repository metadata'
'expire-cache:mark the repository metadata expired'
'metadata:remove the repository metadata'
'packages:remove any cached packages'
'all:clean all'
)
_describe -t cache-types 'cache type' tmp && ret=0
;;
distro-sync)
_arguments : $common_opts '*: : _dnf5_packages -T installed' && ret=0
;;
downgrade)
_arguments : \
$common_opts $downgrade_opts \
'*: : _dnf5_packages -T installed' && ret=0
;;
download)
_arguments : \
'--arch=[limit to packages of specified architecture]:list of architectures:' \
'--resolve[resolve and download needed dependencies]' \
'--alldeps[with --resolve, also download already installed dependencies]' \
'--destdir=[download to the specified directory]: : _directories' \
'--srpm[download the source rpm]' \
'--url[print the list of URLs where the rpms can be downloaded]' \
'*--urlprotocol=[with --url, limit to specified protocols]:protocol:_sequence compadd - http https ftp file' \
'*: : _dnf5_packages -T all' && ret=0
;;
environment)
_arguments : \
'--available[show only available environments]' \
'--installed[show only installed environments]' \
':subcommand:(list info)' \
'*: : _dnf5_environments' && ret=0
;;
info|list)
_arguments : \
'--showduplicates[show all versions of the packages]' \
'*: : _dnf5_packages -T all' \
+ '(type)' \
'--installed[list only installed packages]:*: : _dnf5_packages -T installed' \
'--available[list only available packages]:*: : _dnf5_packages -T available' \
'--extras[list only extras]' \
'--obsoletes[list only installed but obsoleted packages]:*: : _dnf5_packages -T installed' \
'--recent[list only recently added packages]' \
'--upgrades[list only available upgrades of installed packages]:*: : _dnf5_packages -T upgradable' \
'--autoremove[list only packages that will be autoremoved]:*: : _dnf5_packages -T installed' &&ret=0
;;
install)
_arguments : \
$common_opts $downgrade_opts $advisory_opts \
'*: : _dnf5_packages_or_rpms -T available' && ret=0
;;
leaves|makecache)
# nothing to complete
;;
provides)
_files && ret=0
;;
reinstall)
_arguments : \
$common_opts $downgrade_opts \
'*: : _dnf5_packages_or_rpms -T installed' && ret=0
;;
remove)
_arguments : \
$offline_opts \
'--no-autoremove[not remove dependencies that are no longer used]' \
'*: : _dnf5_packages -T installed' && ret=0
;;
replay)
_arguments : \
$replay_opts \
':transaction path:_directories' && ret=0
;;
repo)
_arguments : \
'--all[show info about all repositories]' \
'--enabled[show info only about enabled repositories]' \
'--disabled[show info only about disabled repositories]' \
':subcommand:(list info)' && ret=0
;;
search)
_arguments : \
'--all[search patterns also inside description and URL fields]' \
'--showduplicates[show all versions of packages, not only the latest ones]' \
'*:search pattern:' && ret=0
;;
swap)
_arguments : \
$offline_opts \
'--allowerasing[allow erasing of installed packages]' \
': : _dnf5_packages -T installed' \
': : _dnf5_packages -T available' && ret=0
;;
upgrade)
_arguments : \
${common_opts:#--skip-broken*} $downgrade_opts $advisory_opts \
'--minimal[upgrade only to the lowest available versions that fix advisories]' \
'--destdir=[specify directory into which downloading packages]: : _directories' \
'*: : _dnf5_packages_or_rpms -T upgradable' && ret=0
;;
versionlock)
_arguments : \
':subcommand:(add exclude clear delete list)' \
'*: : _dnf5_packages -T all' && ret=0
;;
esac
return ret
}
# main completer
_dnf5() {
local curcontext="$curcontext" state state_descr line ret=1
typeset -A opt_args
local -a opts=(
'(-y --assumeyes)--assumeno[answer no for all questions]'
'--best[try the best available package version]'
'(-C --cacheonly)'{-C,--cacheonly}"[run entirely from system cache, don't update cache]"
'--comment=[add comment to transaction history]:comment:'
'(-c --config)'{-c+,--config=}'[specify configuration file]:config file:_files'
'--debugsolver[dump detailed solving results in file ./debugdata]'
'*--disable-plugin=[disable specified plugins]:list of plugin names:'
'(--repo)*--disable-repo=[disable specified repos]: : _sequence _dnf5_repositories -T enabled'
'--dump-main-config[print main configuration values to stdout]'
'*--dump-repo-config=[print repository configuration values to stdout]:repi id'
'--dump-variables[print variable values to stdout]'
'*--enable-plugin=[enable specified plugins]:list of plugin names:'
'*--enable-repo=[enable additional repos]: : _sequence _dnf5_repositories -T disabled'
'--forcearch=[force the use of the specified arch]:arch:'
'(-)'{-h,--help}'[show the help message]'
'--installroot=[set install root]: : _directories'
'--no-best[do not limit transactions to best candidates]'
'--no-docs[do not install documentation]'
'--no-gpgcheck[skip checking GPG signatures on packages]'
'--no-plugins[disable all plugins]'
'(-q --quiet)'{-q,--quiet}'[show just the relevant content]'
'--refresh[force refreshing metadata before running the command]'
'--releasever=[override distribution release in config files]:release ver:'
'(--disablerepo)*--repo=[enable just the specified repo]: : _sequence _dnf5_repositories -T all'
'*--repofrompath=[specify additional repos]:repository_label,path_or_url: '
'*--setopt=[override option in config file]:repoid.option=value:'
'*--setvar=[override DNF5 variable value]'
'--show-new-leaves[show newly installed leaf packages]'
'--use-host-config[use config files and variables from host system]'
'(- *)--version[show dnf version]'
'(-y --assumeyes --assumeno)'{-y,--assumeyes}'[answer yes for all questions]'
'*'{-x+,--exclude=}'[exclude specified packages from transaction]: : _sequence _dnf5_packages -T all'
)
_arguments -C -s : $opts ': :->command' '*:: :->cmd_args' && ret=0
case $state in
command) _dnf5_commands && ret=0 ;;
cmd_args) _dnf5_subcmds_opts && ret=0 ;;
esac
return ret
}
_dnf5 "$@"

View file

@ -39,6 +39,10 @@ following setting. See https://github.com/ohmyzsh/ohmyzsh/issues/11789 for more
zstyle ':omz:plugins:docker' legacy-completion yes zstyle ':omz:plugins:docker' legacy-completion yes
``` ```
### For Podman's Docker wrapper users
If you use Podman's Docker wrapper, you need to enable legacy completion. See above section.
## Aliases ## Aliases
| Alias | Command | Description | | Alias | Command | Description |
@ -73,6 +77,7 @@ zstyle ':omz:plugins:docker' legacy-completion yes
| drs | `docker container restart` | Restart one or more containers | | drs | `docker container restart` | Restart one or more containers |
| dsta | `docker stop $(docker ps -q)` | Stop all running containers | | dsta | `docker stop $(docker ps -q)` | Stop all running containers |
| dstp | `docker container stop` | Stop one or more running containers | | dstp | `docker container stop` | Stop one or more running containers |
| dsts | `docker stats` | Display real-time streaming statistics for containers |
| dtop | `docker top` | Display the running processes of a container | | dtop | `docker top` | Display the running processes of a container |
| dvi | `docker volume inspect` | Display detailed information about one or more volumes | | dvi | `docker volume inspect` | Display detailed information about one or more volumes |
| dvls | `docker volume ls` | List all the volumes known to docker | | dvls | `docker volume ls` | List all the volumes known to docker |

View file

@ -28,6 +28,7 @@ alias dst='docker container start'
alias drs='docker container restart' alias drs='docker container restart'
alias dsta='docker stop $(docker ps -q)' alias dsta='docker stop $(docker ps -q)'
alias dstp='docker container stop' alias dstp='docker container stop'
alias dsts='docker stats'
alias dtop='docker top' alias dtop='docker top'
alias dvi='docker volume inspect' alias dvi='docker volume inspect'
alias dvls='docker volume ls' alias dvls='docker volume ls'

View file

@ -23,3 +23,4 @@ plugins=(... dotnet)
| dp | dotnet pack | Create a NuGet package. | | dp | dotnet pack | Create a NuGet package. |
| dng | dotnet nuget | Provides additional NuGet commands. | | dng | dotnet nuget | Provides additional NuGet commands. |
| db | dotnet build | Build a .NET project | | db | dotnet build | Build a .NET project |
| dres | dotnet restore | Restore dependencies and project-specific tools for a project. |

View file

@ -24,3 +24,4 @@ alias da='dotnet add'
alias dp='dotnet pack' alias dp='dotnet pack'
alias dng='dotnet nuget' alias dng='dotnet nuget'
alias db='dotnet build' alias db='dotnet build'
alias dres='dotnet restore'

View file

@ -35,7 +35,7 @@ alias eeval="$EMACS_PLUGIN_LAUNCHER --eval"
alias eframe='emacsclient --alternate-editor="" --create-frame' alias eframe='emacsclient --alternate-editor="" --create-frame'
# Emacs ANSI Term tracking # Emacs ANSI Term tracking
if [[ -n "$INSIDE_EMACS" ]]; then if [[ -n "$INSIDE_EMACS" ]] && [[ "$INSIDE_EMACS" != "vterm" ]]; then
chpwd_emacs() { print -P "\033AnSiTc %d"; } chpwd_emacs() { print -P "\033AnSiTc %d"; }
print -P "\033AnSiTc %d" # Track current working directory print -P "\033AnSiTc %d" # Track current working directory
print -P "\033AnSiTu %n" # Track username print -P "\033AnSiTu %n" # Track username

View file

@ -29,5 +29,5 @@ plugins=(... ember-cli)
- [BilalBudhani](https://github.com/BilalBudhani) - [BilalBudhani](https://github.com/BilalBudhani)
- [eubenesa](https://github.com/eubenesa) - [eubenesa](https://github.com/eubenesa)
- [scottkidder](https://github.com/scottkidder] - [scottkidder](https://github.com/scottkidder)
- [t-sauer](https://www.github.com/t-sauer) - [t-sauer](https://www.github.com/t-sauer)

View file

@ -65,6 +65,29 @@ If `yes`, sets the `--icons` option of `eza`, adding icons for files and folders
Default: `no` Default: `no`
### `color-scale`
```zsh
zstyle ':omz:plugins:eza' 'color-scale' all|age|size
```
Highlight levels of field(s) distinctly. Use comma(,) separated list of `all`, `age`, `size`
Default: `none`
### `color-scale-mode`
```zsh
zstyle ':omz:plugins:eza' 'color-scale-mode' gradient|fixed
```
Choose the mode for highlighting:
- `gradient` (default) -- gradient coloring
- `fixed` -- fixed coloring
Default: `gradient`
### `size-prefix` ### `size-prefix`
```zsh ```zsh

View file

@ -34,6 +34,14 @@ function _configure_eza() {
if zstyle -t ':omz:plugins:eza' 'icons'; then if zstyle -t ':omz:plugins:eza' 'icons'; then
_EZA_TAIL+=("--icons=auto") _EZA_TAIL+=("--icons=auto")
fi fi
zstyle -s ':omz:plugins:eza' 'color-scale' _val
if [[ $_val ]]; then
_EZA_TAIL+=("--color-scale=$_val")
fi
zstyle -s ':omz:plugins:eza' 'color-scale-mode' _val
if [[ $_val == (gradient|fixed) ]]; then
_EZA_TAIL+=("--color-scale-mode=$_val")
fi
zstyle -s ':omz:plugins:eza' 'time-style' _val zstyle -s ':omz:plugins:eza' 'time-style' _val
if [[ $_val ]]; then if [[ $_val ]]; then
_EZA_TAIL+=("--time-style='$_val'") _EZA_TAIL+=("--time-style='$_val'")

35
plugins/foot/README.md Normal file
View file

@ -0,0 +1,35 @@
# foot
This plugin adds shell integration for [foot, a fast, lightweight and
minimalistic Wayland terminal emulator](https://codeberg.org/dnkl/foot).
To use, add `foot` to the list of plugins in your `.zshrc` file:
```zsh
plugins=(... foot)
```
## Spawning new terminal instances in the current working directory
When spawning a new terminal instance (with `ctrl+shift+n` by default), the new
instance will start in the current working directory.
## Jumping between prompts
Foot can move the current viewport to focus prompts of already executed
commands (bound to ctrl+shift+z/x by default).
## Piping last command's output
The key binding `pipe-command-output` can pipe the last command's output to an
application of your choice (similar to the other `pipe-*` key bindings):
```
[key-bindings]
pipe-command-output=[sh -c "f=$(mktemp); cat - > $f; footclient emacsclient -nw $f; rm $f"] Control+Shift+g
```
When pressing ctrl+shift+g, the last command's output is written to a
temporary file, then an emacsclient is started in a new footclient instance.
The temporary file is removed after the footclient instance has closed.

View file

@ -0,0 +1,10 @@
function precmd {
print -Pn "\e]133;A\e\\"
if ! builtin zle; then
print -n "\e]133;D\e\\"
fi
}
function preexec {
print -n "\e]133;C\e\\"
}

View file

@ -18,7 +18,7 @@ You can change the fetch interval in your .zshrc:
GIT_AUTO_FETCH_INTERVAL=1200 # in seconds GIT_AUTO_FETCH_INTERVAL=1200 # in seconds
``` ```
A log of `git fetch --all` will be saved in `.git/FETCH_LOG`. A log of `git-fetch-all` will be saved in `.git/FETCH_LOG`.
## Toggle auto-fetch per folder ## Toggle auto-fetch per folder

View file

@ -23,9 +23,10 @@ def get_tagname_or_hash():
return hash_ return hash_
return None return None
# Re-use method from https://github.com/magicmonty/bash-git-prompt to get stashs count # Re-use method from https://github.com/magicmonty/bash-git-prompt to get stash count
# Use `--git-common-dir` to avoid problems with git worktrees, which don't have individual stashes
def get_stash(): def get_stash():
cmd = Popen(['git', 'rev-parse', '--git-dir'], stdout=PIPE, stderr=PIPE) cmd = Popen(['git', 'rev-parse', '--git-common-dir'], stdout=PIPE, stderr=PIPE)
so, se = cmd.communicate() so, se = cmd.communicate()
stash_file = '%s%s' % (so.decode('utf-8').rstrip(), '/logs/refs/stash') stash_file = '%s%s' % (so.decode('utf-8').rstrip(), '/logs/refs/stash')
@ -35,7 +36,6 @@ def get_stash():
except IOError: except IOError:
return 0 return 0
# `git status --porcelain --branch` can collect all information # `git status --porcelain --branch` can collect all information
# branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind # branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind
po = Popen(['git', 'status', '--porcelain', '--branch'], env=dict(os.environ, LANG="C"), stdout=PIPE, stderr=PIPE) po = Popen(['git', 'status', '--porcelain', '--branch'], env=dict(os.environ, LANG="C"), stdout=PIPE, stderr=PIPE)

View file

@ -79,6 +79,7 @@ plugins=(... git)
| `gcss` | `git commit -S -s` | | `gcss` | `git commit -S -s` |
| `gcssm` | `git commit -S -s -m` | | `gcssm` | `git commit -S -s -m` |
| `gcf` | `git config --list` | | `gcf` | `git config --list` |
| `gcfu` | `git commit --fixup` |
| `gdct` | `git describe --tags $(git rev-list --tags --max-count=1)` | | `gdct` | `git describe --tags $(git rev-list --tags --max-count=1)` |
| `gd` | `git diff` | | `gd` | `git diff` |
| `gdca` | `git diff --cached` | | `gdca` | `git diff --cached` |

View file

@ -200,6 +200,7 @@ alias gc!='git commit --verbose --amend'
alias gcn='git commit --verbose --no-edit' alias gcn='git commit --verbose --no-edit'
alias gcn!='git commit --verbose --no-edit --amend' alias gcn!='git commit --verbose --no-edit --amend'
alias gcf='git config --list' alias gcf='git config --list'
alias gcfu='git commit --fixup'
alias gdct='git describe --tags $(git rev-list --tags --max-count=1)' alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
alias gd='git diff' alias gd='git diff'
alias gdca='git diff --cached' alias gdca='git diff --cached'

View file

@ -0,0 +1,40 @@
This project is a friendly fork of the official Git completion
(`contrib/completion`) and prompt scripts for Bash, Zsh, and possibly other
shells.
Most Git developers use the Bash shell, for which the completion scripts work
rather well, however, Zsh is typically neglected. I've sent many patches to fix
the issues, many have been merged, but many have been ignored, thus the need for
a canonical location of a good, working Zsh completion.
There are advantages for Bash users too. Currently the scripts under `contrib` are tied to the
specific Git version, for example the completion scripts of version v2.40
(https://git.kernel.org/pub/scm/git/git.git/plain/contrib/completion/git-completion.bash?h=v2.40.0[git-completion.bash])
have issues with older versions of Git (e.g. v2.33); the ones in
this project don't.
With `git-completion` you can be sure you are using the latest completion that
works in both shells, and any Git version.
This is a sister project of the
https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/gitfast[Oh My Zsh
gitfast] plugin (that I also maintain), which has similar needs.
== Installation ==
* https://github.com/felipec/git-completion/wiki/Bash[Bash instructions]
* https://github.com/felipec/git-completion/wiki/Zsh[Zsh instructions]
== Improvements from upstream ==
This is a short list of the benefits you get:
* Easier installation
* Tons of bug fixes
* Works with older versions of git
* Zsh: much more options
* Zsh: quoting works properly
* Zsh: automatic suffix removal
For a full list of all the patches on top of upstream git check
https://github.com/felipec/git-completion/wiki/Patches[Patches].

View file

@ -2,23 +2,11 @@
# zsh completion wrapper for git # zsh completion wrapper for git
# #
# Copyright (c) 2012-2020 Felipe Contreras <felipe.contreras@gmail.com> # Copyright (c) 2012-2024 Felipe Contreras <felipe.contreras@gmail.com>
# #
# The recommended way to install this script is to make a copy of it as a # The recommended way to use this script is to prepend its location to your $fpath:
# file named '_git' inside any directory in your fpath.
# #
# For example, create a directory '~/.zsh/', copy this file to '~/.zsh/_git', # fpath=($git_completion_srcdir $fpath)
# and then add the following to your ~/.zshrc file:
#
# fpath=(~/.zsh $fpath)
#
# You need git's bash completion script installed. By default bash-completion's
# location will be used (e.g. pkg-config --variable=completionsdir bash-completion).
#
# If your bash completion script is somewhere else, you can specify the
# location in your ~/.zshrc:
#
# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
# #
zstyle -T ':completion:*:*:git:*' tag-order && \ zstyle -T ':completion:*:*:git:*' tag-order && \

View file

@ -1,6 +1,8 @@
# bash/zsh completion support for core Git. # bash/zsh completion support for core Git.
# #
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Copyright (c) 2012-2024 Felipe Contreras <felipe.contreras@gmail.com>
#
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0. # Distributed under the GNU General Public License, version 2.0.
# #

View file

@ -5,6 +5,7 @@ files=(
/etc/grc.zsh # default /etc/grc.zsh # default
/usr/local/etc/grc.zsh # homebrew darwin-x64 /usr/local/etc/grc.zsh # homebrew darwin-x64
/opt/homebrew/etc/grc.zsh # homebrew darwin-arm64 /opt/homebrew/etc/grc.zsh # homebrew darwin-arm64
/home/linuxbrew/.linuxbrew/etc/grc.zsh # linuxbrew
/usr/share/grc/grc.zsh # Gentoo Linux (app-misc/grc) /usr/share/grc/grc.zsh # Gentoo Linux (app-misc/grc)
) )

View file

@ -26,6 +26,7 @@ This plugin supplies one command, `jira`, through which all its features are exp
| `jira new` | Opens a new Jira issue dialogue | | `jira new` | Opens a new Jira issue dialogue |
| `jira ABC-123` | Opens an existing issue | | `jira ABC-123` | Opens an existing issue |
| `jira ABC-123 m` | Opens an existing issue for adding a comment | | `jira ABC-123 m` | Opens an existing issue for adding a comment |
| `jira project ABC` | Opens JIRA project summary |
| `jira dashboard [rapid_view]` | Opens your JIRA dashboard | | `jira dashboard [rapid_view]` | Opens your JIRA dashboard |
| `jira mine` | Queries for your own issues | | `jira mine` | Queries for your own issues |
| `jira tempo` | Opens your JIRA Tempo | | `jira tempo` | Opens your JIRA Tempo |
@ -43,6 +44,22 @@ starting with "_": "MP-1234_fix_dashboard". In both these cases, the issue opene
This is also checks if the prefix is in the name, and adds it if not, so: "MP-1234" opens the issue "MP-1234", This is also checks if the prefix is in the name, and adds it if not, so: "MP-1234" opens the issue "MP-1234",
"mp-1234" opens the issue "mp-1234", and "1234" opens the issue "MP-1234". "mp-1234" opens the issue "mp-1234", and "1234" opens the issue "MP-1234".
If your branch naming convention deviates, you can overwrite the jira_branch function to determine and echo the Jira issue key yourself.
Define a function `jira_branch` after sourcing `oh-my-zsh.sh` in your `.zshrc`.
Example:
```zsh
# Determine branch name from naming convention 'type/KEY-123/description'.
function jira_branch() {
# Get name of the branch
issue_arg=$(git rev-parse --abbrev-ref HEAD)
# Strip prefixes like feature/ or bugfix/
issue_arg=${issue_arg#*/}
# Strip suffixes like /some-branch-description
issue_arg=${issue_arg%%/*}
# Return the value
echo $issue_arg
}
```
#### Debugging usage #### Debugging usage

View file

@ -5,6 +5,7 @@ local -a _1st_arguments
_1st_arguments=( _1st_arguments=(
'new:create a new issue' 'new:create a new issue'
'mine:open my issues' 'mine:open my issues'
'project:open the project'
'dashboard:open the dashboard' 'dashboard:open the dashboard'
'tempo:open the tempo' 'tempo:open the tempo'
'reported:search for issues reported by a user' 'reported:search for issues reported by a user'

View file

@ -8,6 +8,7 @@ jira Performs the default action
jira new Opens a new Jira issue dialogue jira new Opens a new Jira issue dialogue
jira ABC-123 Opens an existing issue jira ABC-123 Opens an existing issue
jira ABC-123 m Opens an existing issue for adding a comment jira ABC-123 m Opens an existing issue for adding a comment
jira project ABC Opens JIRA project summary
jira dashboard [rapid_view] Opens your JIRA dashboard jira dashboard [rapid_view] Opens your JIRA dashboard
jira mine Queries for your own issues jira mine Queries for your own issues
jira tempo Opens your JIRA Tempo jira tempo Opens your JIRA Tempo
@ -17,6 +18,30 @@ jira branch Opens an existing issue matching the current bra
EOF EOF
} }
# If your branch naming convention deviates, you can partially override this plugin function
# to determine the jira issue key based on your formatting.
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#partially-overriding-an-existing-plugin
function jira_branch() {
# Get name of the branch
issue_arg=$(git rev-parse --abbrev-ref HEAD)
# Strip prefixes like feature/ or bugfix/
issue_arg=${issue_arg##*/}
# Strip suffixes starting with _
issue_arg=(${(s:_:)issue_arg})
# If there is only one part, it means that there is a different delimiter. Try with -
if [[ ${#issue_arg[@]} = 1 && ${issue_arg} == *-* ]]; then
issue_arg=(${(s:-:)issue_arg})
issue_arg="${issue_arg[1]}-${issue_arg[2]}"
else
issue_arg=${issue_arg[1]}
fi
if [[ "${issue_arg:l}" = ${jira_prefix:l}* ]]; then
echo "${issue_arg}"
else
echo "${jira_prefix}${issue_arg}"
fi
}
function jira() { function jira() {
emulate -L zsh emulate -L zsh
local action jira_url jira_prefix local action jira_url jira_prefix
@ -64,6 +89,9 @@ function jira() {
elif [[ "$action" == "mine" ]]; then elif [[ "$action" == "mine" ]]; then
echo "Opening my issues" echo "Opening my issues"
open_command "${jira_url}/issues/?filter=-1" open_command "${jira_url}/issues/?filter=-1"
elif [[ "$action" == "project" ]]; then
echo "Opening project"
open_command "${jira_url}/jira/software/c/projects/${2}/summary"
elif [[ "$action" == "dashboard" ]]; then elif [[ "$action" == "dashboard" ]]; then
echo "Opening dashboard" echo "Opening dashboard"
if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then
@ -91,24 +119,7 @@ function jira() {
# but `branch` is a special case that will parse the current git branch # but `branch` is a special case that will parse the current git branch
local issue_arg issue local issue_arg issue
if [[ "$action" == "branch" ]]; then if [[ "$action" == "branch" ]]; then
# Get name of the branch issue=$(jira_branch)
issue_arg=$(git rev-parse --abbrev-ref HEAD)
# Strip prefixes like feature/ or bugfix/
issue_arg=${issue_arg##*/}
# Strip suffixes starting with _
issue_arg=(${(s:_:)issue_arg})
# If there is only one part, it means that there is a different delimiter. Try with -
if [[ ${#issue_arg[@]} = 1 && ${issue_arg} == *-* ]]; then
issue_arg=(${(s:-:)issue_arg})
issue_arg="${issue_arg[1]}-${issue_arg[2]}"
else
issue_arg=${issue_arg[1]}
fi
if [[ "${issue_arg:l}" = ${jira_prefix:l}* ]]; then
issue="${issue_arg}"
else
issue="${jira_prefix}${issue_arg}"
fi
else else
issue_arg=${(U)action} issue_arg=${(U)action}
issue="${jira_prefix}${issue_arg}" issue="${jira_prefix}${issue_arg}"

90
plugins/jj/README.md Normal file
View file

@ -0,0 +1,90 @@
# jj - Jujutsu CLI
This plugin provides autocompletion for [jj](https://martinvonz.github.io/jj).
To use it, add `jj` to the plugins array of your zshrc file:
```zsh
plugins=(... jj)
```
## Aliases
| Alias | Command |
| ------ | ----------------------------- |
| jjc | `jj commit` |
| jjcmsg | `jj commit --message` |
| jjd | `jj diff` |
| jjdmsg | `jj desc --message` |
| jjds | `jj desc` |
| jje | `jj edit` |
| jjgcl | `jj git clone` |
| jjgf | `jj git fetch` |
| jjgfa | `jj git fetch --all-remotes` |
| jjgp | `jj git push` |
| jjl | `jj log` |
| jjla | `jj log -r "all()"` |
| jjn | `jj new` |
| jjrb | `jj rebase` |
| jjrs | `jj restore` |
| jjrt | `cd "$(jj root \|\| echo .)"` |
| jjsp | `jj split` |
| jjsq | `jj squash` |
## Prompt usage
Because `jj` has a very powerful [template syntax](https://martinvonz.github.io/jj/latest/templates/), this
plugin only exposes a convenience function `jj_prompt_template` to read information from the current change.
It is basically the same as `jj log --no-graph -r @ -T $1`:
```sh
_my_theme_jj_info() {
jj_prompt_template 'self.change_id().shortest(3)'
}
PROMPT='$(_my_theme_jj_info) $'
```
`jj_prompt_template` escapes `%` signs in the output. Use `jj_prompt_template_raw` if you don't want that
(e.g. to colorize the output).
However, because `jj` can be used inside a Git repository, some themes might clash with it. Generally, you can
fix it with a wrapper function that tries `jj` first and then falls back to `git` if it didn't work:
```sh
_my_theme_vcs_info() {
jj_prompt_template 'self.change_id().shortest(3)' \
|| git_prompt_info
}
PROMPT='$(_my_theme_vcs_info) $'
```
You can find an example
[here](https://github.com/nasso/omzsh/blob/e439e494f22f4fd4ef1b6cb64626255f4b341c1b/themes/sunakayu.zsh-theme).
### Performance
Sometimes `jj` can be slower than `git`.
If you feel slowdowns, consider using the following:
```
zstyle :omz:plugins:jj ignore-working-copy yes
```
This will add `--ignore-working-copy` to all `jj` commands executed by your prompt. The downside here is that
your prompt might be out-of-sync until the next time `jj` gets a chance to _not_ ignore the working copy (i.e.
you manually run a `jj` command).
If you prefer to keep your prompt always up-to-date but still don't want to _feel_ the slowdown, you can make
your prompt asynchronous. This plugin doesn't do this automatically so you'd have to hack your theme a bit for
that.
## See Also
- [martinvonz/jj](https://github.com/martinvonz/jj)
## Contributors
- [nasso](https://github.com/nasso) - Plugin Author

54
plugins/jj/jj.plugin.zsh Normal file
View file

@ -0,0 +1,54 @@
# if jj is not found, don't do the rest of the script
if (( ! $+commands[jj] )); then
return
fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `jj`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_jj" ]]; then
typeset -g -A _comps
autoload -Uz _jj
_comps[jj]=_jj
fi
COMPLETE=zsh jj >| "$ZSH_CACHE_DIR/completions/_jj" &|
function __jj_prompt_jj() {
local -a flags
flags=("--no-pager")
if zstyle -t ':omz:plugins:jj' ignore-working-copy; then
flags+=("--ignore-working-copy")
fi
command jj $flags "$@"
}
# convenience functions for themes
function jj_prompt_template_raw() {
__jj_prompt_jj log --no-graph -r @ -T "$@" 2> /dev/null
}
function jj_prompt_template() {
local out
out=$(jj_prompt_template_raw "$@") || return 1
echo "${out:gs/%/%%}"
}
# Aliases (sorted alphabetically)
alias jjc='jj commit'
alias jjcmsg='jj commit --message'
alias jjd='jj diff'
alias jjdmsg='jj desc --message'
alias jjds='jj desc'
alias jje='jj edit'
alias jjgcl='jj git clone'
alias jjgf='jj git fetch'
alias jjgfa='jj git fetch --all-remotes'
alias jjgp='jj git push'
alias jjl='jj log'
alias jjla='jj log -r "all()"'
alias jjn='jj new'
alias jjrb='jj rebase'
alias jjrs='jj restore'
alias jjrt='cd "$(jj root || echo .)"'
alias jjsp='jj split'
alias jjsq='jj squash'

16
plugins/kamal/README.md Normal file
View file

@ -0,0 +1,16 @@
# Kamal
This plugin provides completion for [Kamal](https://kamal-deploy.org/) as well as some
aliases for frequent Kamal commands.
To use it, add kamal to the plugins array of your zshrc file:
```zsh
plugins=(... kamal)
```
## Aliase
| Alias | Command | Description |
|-----------|----------------------------------|----------------------------------------------------------------------------------|
| kad | `kamal deploy` | Deploy app to servers |

691
plugins/kamal/_kamal Normal file
View file

@ -0,0 +1,691 @@
#compdef kamal
# Description
# -----------
# zsh completion for Kamal (https://kamal-deploy.org/)
# -------------------------------------------------------------------------
# Authors
# -------
# * Igor Aleksandrov <igor.alexandrov@gmail.com>
# -------------------------------------------------------------------------
# Inspiration
# -----------
# * docker-compose ohmyzsh completion script by @sdurrheimer Steve Durrheimer
# -------------------------------------------------------------------------
# _kamal_commands() {
# # Only initialize if empty
# if (( ${#kamal_commands} == 0 )); then
# kamal_commands=(
# accessory
# app
# audit
# build
# config
# deploy
# details
# docs
# help
# init
# lock
# proxy
# prune
# redeploy
# registry
# remove
# rollback
# secrets
# server
# setup
# upgrade
# version
# )
# fi
# _values 'Kamal commands' $kamal_commands
# }
typeset -gr _kamal_commands=(
'accessory:Control accessory services'
'app:Control application deployment'
'audit:Audit security of deployment'
'build:Build and manage app images'
'config:Show effective configuration'
'deploy:Deploy app to servers'
'details:Show details about deployment'
'docs:Open documentation in browser'
'help:Show command help'
'init:Initialize new Kamal project'
'lock:Manage deployment locks'
'proxy:Control reverse proxy'
'prune:Clean up containers and images'
'redeploy:Redeploy current version'
'registry:Manage Docker registry access'
'remove:Remove app from servers'
'rollback:Rollback to a previous version'
'secrets:Manage deployment secrets'
'server:Control server configuration'
'setup:Setup initial deployment'
'upgrade:Upgrade deployment'
'version:Show Kamal version'
)
# Helper function to display messages
_kamal_message() {
local msg="$1"
_kamal_message "==> $msg"
}
# Helper function to extract destination names from ./config/deploy.*.yml
_kamal_destinations() {
local -a dests
local file
# Check if config directory exists
if [[ ! -d "config" ]]; then
_kamal_message "Cannot find Kamal configuration directory at ./config" && return 1
fi
for file in config/deploy.*.yml(N); do
[[ $file =~ config/deploy\.(.+)\.yml ]] && dests+=("${match[1]}")
done
_values 'Destination' $dests
}
# Define global _kamal_flags array
typeset -ga _kamal_flags
_kamal_flags=(
'(-v --verbose )'{-v,--verbose}'[Detailed logging]'
'(--no-verbose --skip-verbose)'{--no-verbose,--skip-verbose}'[No detailed logging]'
'(-q --quiet --no-quiet --skip-quiet)'{-q,--quiet}'[Minimal logging]'
'(-q --quiet --no-quiet --skip-quiet)'{--no-quiet,--skip-quiet}'[No minimal logging]'
'--version=[Run commands against a specific app version]:version'
'(-p --primary --no-primary --skip-primary)'{-p,--primary}'[Run commands only on primary host instead of all]'
'(-p --primary --no-primary --skip-primary)'{--no-primary,--skip-primary}'[Do not run commands only on primary host]'
'(-h --hosts)'{-h,--hosts=}'[Run commands on these hosts instead of all]:hosts'
'(-r --roles)'{-r,--roles=}'[Run commands on these roles instead of all]:roles'
'(-c --config-file)'{-c,--config-file=}'[Path to config file]:config file:_files'
'(-d --destination)'{-d,--destination=}'[Specify destination to be used for config file]:destination:_kamal_destinations'
'(-H --skip-hooks)'{-H,--skip-hooks}'[Do not run hooks]'
)
_kamal() {
local context state state_descr line curcontext="$curcontext"
typeset -A opt_args
local ret=1
_arguments -C \
$_kamal_flags \
'1: :->command' \
'*:: :->args' && ret=0
case $state in
(command)
# First argument - show available commands
_describe -t kamal-commands "Kamal commands" _kamal_commands && ret=0
;;
(args)
# Subsequent arguments - handle based on the command
case $words[1] in
(accessory)
_kamal_accessory && ret=0
;;
(app)
_kamal_app && ret=0
;;
(audit)
_arguments $_kamal_flags && ret=0
;;
(build)
_kamal_build && ret=0
;;
(config)
_arguments $_kamal_flags && ret=0
;;
(deploy)
_arguments $_kamal_flags && ret=0
;;
(details)
_arguments $_kamal_flags && ret=0
;;
(docs)
_arguments $_kamal_flags && ret=0
;;
(help)
_kamal_help && ret=0
;;
(init)
local -a init_flags
init_flags=(
$_kamal_flags
'(--bundle --no-bundle --skip-bundle)--bundle[Add Kamal to the Gemfile and create a bin/kamal binstub]'
'(--bundle --no-bundle --skip-bundle)--no-bundle[Do not add Kamal to the Gemfile and create a bin/kamal binstub]'
'(--bundle --no-bundle --skip-bundle)--skip-bundle[Skip add Kamal to the Gemfile and create a bin/kamal binstub]'
)
_arguments $init_flags && ret=0
;;
(lock)
_kamal_lock && ret=0
;;
(proxy)
_kamal_proxy && ret=0
;;
(prune)
_kamal_prune && ret=0
;;
(redeploy)
_arguments $_kamal_flags && ret=0
;;
(registry)
_kamal_registry && ret=0
;;
(remove)
local -a remove_flags
remove_flags=(
$_kamal_flags
'(-y --confirmed --no-confirmed --skip-confirmed)'{-y,--confirmed}'[Proceed without confirmation question]'
'(-y --confirmed --no-confirmed --skip-confirmed)--no-confirmed[Proceed without confirmation question]'
'(-y --confirmed --no-confirmed --skip-confirmed)--skip-confirmed[Proceed without confirmation question]'
)
_arguments $remove_flags && ret=0
;;
(rollback)
if (( CURRENT == 2 )); then
_kamal_message "Enter the version to rollback to" && ret=0
else
_values $_kamal_flags && ret=0
fi
;;
(secrets)
_kamal_secrets && ret=0
;;
(server)
_kamal_server && ret=0
;;
(setup)
local -a setup_flags
setup_flags=(
$_kamal_flags
'(-P --skip-push)'{-P,--skip-push}'[Skip image build and push]'
)
_arguments $setup_flags && ret=0
;;
(upgrade)
local -a upgrade_flags
upgrade_flags=(
$_kamal_flags
'(-y --confirmed --no-confirmed --skip-confirmed)'{-y,--confirmed}'[Proceed without confirmation question]'
'(-y --confirmed --no-confirmed --skip-confirmed)--no-confirmed[Do not proceed without confirmation question]'
'(-y --confirmed --no-confirmed --skip-confirmed)--skip-confirmed[Skip confirmation question]'
'(--rolling --no-rolling --skip-rolling)--rolling[Upgrade one host at a time]'
'(--rolling --no-rolling --skip-rolling)--no-rolling[Do not upgrade one host at a time]'
'(--rolling --no-rolling --skip-rolling)--skip-rolling[Skip rolling upgrade]'
)
_arguments $upgrade_flags && ret=0
;;
(version)
_arguments $_kamal_flags && ret=0
esac
;;
esac
return ret
}
_kamal_accessory() {
local context state line
typeset -A opt_args
local ret=1
# Define accessory subcommands
local -a accessory_subcommands
accessory_subcommands=(
"boot:Boot new accessory service on host (use NAME=all to boot all accessories)"
"details:Show details about accessory on host (use NAME=all to show all accessories)"
"exec:Execute a custom command on servers within the accessory container (use --help to show options)"
"help:Describe subcommands or one specific subcommand"
"logs:Show log lines from accessory on host (use --help to show options)"
"reboot:Reboot existing accessory on host (stop container, remove container, start new container; use NAME=all to boot all accessories)"
"remove:Remove accessory container, image and data directory from host (use NAME=all to remove all accessories)"
"restart:Restart existing accessory container on host"
"start:Start existing accessory container on host"
"stop:Stop existing accessory container on host"
"upgrade:Upgrade accessories from Kamal 1.x to 2.0 (restart them in 'kamal' network)"
)
_arguments -C \
'1: :->subcmd' \
'*:: :->args' && ret=0
case $state in
(subcmd)
_describe -t accessory-commands "Kamal accessory commands" accessory_subcommands && ret=0
;;
(args)
case $words[1] in
(boot|details|exec|logs|reboot|remove|restart|start|stop)
# These commands require a NAME parameter
if (( CURRENT == 2 )); then
# At the NAME position - we could add accessory name completion here
# if we had a way to list available accessories
_kamal_message "Specify an accessory name (or 'all' for all accessories)" && ret=0
elif [[ "$words[1]" == "exec" && CURRENT == 3 ]]; then
# For exec, the 3rd argument is a command
_kamal_message "Enter a command to execute" && ret=0
elif (( CURRENT > 2 )) && [[ "$words[1]" != "exec" || CURRENT > 3 ]]; then
_values $_kamal_flags && ret=0
fi
;;
(help)
# Remove help itself from the list of commands
accessory_subcommands=("${(@)accessory_subcommands:#help*}")
_describe -t accessory-help-commands "Kamal accessory help commands" accessory_subcommands
;;
(upgrade)
# For upgrade, show flags immediately
_arguments $_kamal_flags && ret=0
;;
esac
;;
esac
return ret
}
_kamal_app() {
local context state line
typeset -A opt_args
local ret=1
local -a app_subcommands
app_subcommands=(
"boot:Boot app on servers (or reboot app if already running)"
"containers:Show app containers on servers"
"details:Show details about app containers"
"exec:Execute a custom command on servers within the app container (use --help to show options)"
"help:Describe subcommands or one specific subcommand"
"images:Show app images on servers"
"logs:Show log lines from app on servers (use --help to show options)"
"remove:Remove app containers and images from servers"
"stale_containers:Detect app stale containers"
"start:Start existing app container on servers"
"stop:Stop app container on servers"
"version:Show app version currently running on servers"
)
_arguments -C \
'1: :->subcmd' \
'*:: :->args' && ret=0
case $state in
(subcmd)
_describe -t app-commands "Kamal app commands" app_subcommands && ret=0
;;
(args)
case $words[1] in
(boot|containers|details|images|logs|remove|stale_containers|start|stop)
_arguments $_kamal_flags && ret=0
;;
(exec)
# For exec, the next argument is a command
if (( CURRENT == 2 )); then
_kamal_message "Enter a command to execute" && ret=0
else
_values $_kamal_flags && ret=0
fi
;;
(help)
# Remove help itself from the list of commands
app_subcommands=("${(@)app_subcommands:#help*}")
_describe -t app-help-commands "Kamal app help commands" app_subcommands
;;
esac
;;
esac
return ret
}
_kamal_build() {
local context state line
typeset -A opt_args
local ret=1
local -a build_subcommands
build_subcommands=(
"create:Create a build setup"
"deliver:Build app and push app image to registry then pull image on servers"
"details:Show build setup"
"dev:Build using the working directory, tag it as dirty, and push to local image store."
"help:Describe subcommands or one specific subcommand"
"pull:Pull app image from registry onto servers"
"push:Build and push app image to registry"
"remove:Remove build setup"
)
_arguments -C \
'1: :->subcmd' \
'*:: :->args' && ret=0
case $state in
(subcmd)
_describe -t build-commands "Kamal build commands" build_subcommands && ret=0
;;
(args)
case $words[1] in
(create|deliver|details|dev|pull|push|remove)
_arguments $_kamal_flags && ret=0
;;
(help)
# Remove help itself from the list of commands
build_subcommands=("${(@)build_subcommands:#help*}")
_describe -t build-help-commands "Kamal build help commands" build_subcommands
;;
esac
;;
esac
return ret
}
_kamal_help() {
local ret=1
# Make sure kamal_commands is initialized properly
# if (( ${#kamal_commands} == 0 )); then
# _kamal_commands >/dev/null
# fi
# If we already have a command after "help", return without suggestions
if (( CURRENT > 2 )); then
ret=0
else
local -a help_commands
# Filter out help from the list of commands
help_commands=("${(@)_kamal_commands:#help}")
_values 'Kamal help' $help_commands && ret=0
fi
return ret
}
_kamal_lock() {
local context state line
typeset -A opt_args
local ret=1
local -a lock_subcommands
lock_subcommands=(
"acquire:Acquire the deploy lock"
"help:Describe subcommands or one specific subcommand"
"release:Release the deploy lock"
"status:Report lock status"
)
_arguments -C \
'1: :->subcmd' \
'*:: :->args' && ret=0
case $state in
(subcmd)
_describe -t lock-commands "Kamal lock commands" lock_subcommands && ret=0
;;
(args)
case $words[1] in
(acquire)
local -a acquire_flags
acquire_flags=(
$_kamal_flags
'(-m --message)'{-m,--message=}'[A lock message]:message:' # Required flag
)
_arguments $acquire_flags && ret=0
;;
(release|status)
_arguments $_kamal_flags && ret=0
;;
(help)
# Remove help itself from the list of commands
lock_subcommands=("${(@)lock_subcommands:#help*}")
_describe -t lock-help-commands "Kamal lock help commands" lock_subcommands
;;
esac
;;
esac
return ret
}
_kamal_proxy() {
local context state line
typeset -A opt_args
local ret=1
local -a proxy_subcommands
proxy_subcommands=(
"boot:Boot proxy on servers"
"boot_config:Manage kamal-proxy boot configuration"
"details:Show details about proxy container from servers"
"help:Describe subcommands or one specific subcommand"
"logs:Show log lines from proxy on servers"
"reboot:Reboot proxy on servers (stop container, remove container, start new container)"
"remove:Remove proxy container and image from servers"
"restart:Restart existing proxy container on servers"
"start:Start existing proxy container on servers"
"stop:Stop existing proxy container on servers"
)
_arguments -C \
'1: :->subcmd' \
'*:: :->args' && ret=0
case $state in
(subcmd)
_describe -t proxy-commands "Kamal proxy commands" proxy_subcommands && ret=0
;;
(args)
case $words[1] in
(boot|details|logs|reboot|remove|restart|start|stop)
_arguments $_kamal_flags && ret=0
;;
(boot_config)
if (( CURRENT == 2 )); then
local -a boot_config_commands=(
"set:Set boot configuration"
"get:Get boot configuration"
"reset:Reset boot configuration"
)
_describe -t boot-config-commands "Boot config commands" boot_config_commands && ret=0
else
_values $_kamal_flags && ret=0
fi
;;
(help)
# Remove help itself from the list of commands
proxy_subcommands=("${(@)proxy_subcommands:#help*}")
_describe -t proxy-help-commands "Kamal proxy help commands" proxy_subcommands
;;
esac
;;
esac
return ret
}
_kamal_prune() {
local context state line
typeset -A opt_args
local ret=1
local -a prune_subcommands
prune_subcommands=(
"all:Prune unused images and stopped containers"
"containers:Prune all stopped containers, except the last n (default 5)"
"help:Describe subcommands or one specific subcommand"
"images:Prune unused images"
)
_arguments -C \
'1: :->subcmd' \
'*:: :->args' && ret=0
case $state in
(subcmd)
_describe -t prune-commands "Kamal prune commands" prune_subcommands && ret=0
;;
(args)
case $words[1] in
(all|containers|images)
_arguments $_kamal_flags && ret=0
;;
(help)
# Remove help itself from the list of commands
prune_subcommands=("${(@)prune_subcommands:#help*}")
_describe -t prune-help-commands "Kamal prune help commands" prune_subcommands
;;
esac
;;
esac
return ret
}
_kamal_registry() {
local context state line
typeset -A opt_args
local ret=1
local -a registry_subcommands
registry_subcommands=(
"help:Describe subcommands or one specific subcommand"
"login:Log in to registry locally and remotely"
"logout:Log out of registry locally and remotely"
)
_arguments -C \
'1: :->subcmd' \
'*:: :->args' && ret=0
case $state in
(subcmd)
_describe -t registry-commands "Kamal registry commands" registry_subcommands && ret=0
;;
(args)
case $words[1] in
(help)
# Remove help itself from the list of commands
registry_subcommands=("${(@)registry_subcommands:#help*}")
_describe -t registry-help-commands "Kamal registry help commands" registry_subcommands
;;
(login|logout)
_arguments $_kamal_flags && ret=0
;;
esac
;;
esac
return ret
}
_kamal_secrets() {
local context state line
typeset -A opt_args
local ret=1
local -a secrets_subcommands
secrets_subcommands=(
"extract:Extract a single secret from the results of a fetch call"
"fetch:Fetch secrets from a vault"
"help:Describe subcommands or one specific subcommand"
"print:Print the secrets (for debugging)"
)
_arguments -C \
'1: :->subcmd' \
'*:: :->args' && ret=0
case $state in
(subcmd)
_describe -t secrets-commands "Kamal secrets commands" secrets_subcommands && ret=0
;;
(args)
case $words[1] in
(fetch)
local -a fetch_flags
fetch_flags=(
$_kamal_flags
'(-a --adapter)'{-a,--adapter=}'[Secret storage adapter]:adapter:(aws-parameter-store)'
)
_arguments $fetch_flags && ret=0
;;
(extract|print)
_arguments $_kamal_flags && ret=0
;;
(help)
# Remove help itself from the list of commands
secrets_subcommands=("${(@)secrets_subcommands:#help*}")
_describe -t secrets-help-commands "Kamal secrets help commands" secrets_subcommands
;;
esac
;;
esac
return ret
}
_kamal_server() {
local context state line
typeset -A opt_args
local ret=1
local -a server_subcommands
server_subcommands=(
"bootstrap:Set up Docker to run Kamal apps"
"exec:Run a custom command on the server (use --help to show options)"
"help:Describe subcommands or one specific subcommand"
)
local -a server_flags
server_flags=(
$_kamal_flags
'(-i --interactive --no-interactive --skip-interactive)'{-i,--interactive}'[Run the command interactively]'
'(-i --interactive --no-interactive --skip-interactive)--no-interactive[Do not run the command interactively]'
'(-i --interactive --no-interactive --skip-interactive)--skip-interactive[Skip interactive mode]'
)
_arguments -C \
'1: :->subcmd' \
'*:: :->args' && ret=0
case $state in
(subcmd)
_describe -t server-commands "Kamal server commands" server_subcommands && ret=0
;;
(args)
case $words[1] in
(bootstrap)
_arguments $server_flags && ret=0
;;
(exec)
if (( CURRENT == 2 )); then
# For exec, the next argument is a command
_kamal_message "Enter a command to execute" && ret=0
else
_values $server_flags && ret=0
fi
;;
(help)
# Remove help itself from the list of commands
server_subcommands=("${(@)server_subcommands:#help*}")
_describe -t server-help-commands "Kamal server help commands" server_subcommands
;;
esac
;;
esac
return ret
}
_kamal "$@"

View file

@ -0,0 +1,25 @@
# Find kamal binary (local ./bin/kamal or global)
function _kamal_command () {
if [ -x "./bin/kamal" ]; then
./bin/kamal "$@"
else
command kamal "$@"
fi
}
function which-kamal() {
if [ -x "./bin/kamal" ]; then
echo "Using local ./bin/kamal"
else
echo "Using global $(command -v kamal)"
fi
}
# Use `_kamal_command`` function for `kamal` command
alias kamal='_kamal_command'
# Aliases
alias kad='kamal deploy'
# Hook up completion
compdef _kamal_command=kamal

View file

@ -11,124 +11,126 @@ plugins=(... kubectl)
## Aliases ## Aliases
| Alias | Command | Description | | Alias | Command | Description |
| :------- | :------------------------------------------------- | :----------------------------------------------------------------------------------------------- | | :------- | :------------------------------------------------------ | :----------------------------------------------------------------------------------------------- |
| k | `kubectl` | The kubectl command | | k | `kubectl` | The kubectl command |
| kca | `kubectl --all-namespaces` | The kubectl command targeting all namespaces | | kca | `kubectl --all-namespaces` | The kubectl command targeting all namespaces |
| kaf | `kubectl apply -f` | Apply a YML file | | kaf | `kubectl apply -f` | Apply a YML file |
| keti | `kubectl exec -ti` | Drop into an interactive terminal on a container | | keti | `kubectl exec -ti` | Drop into an interactive terminal on a container |
| | | **Manage configuration quickly to switch contexts between local, dev and staging** | | | | **Manage configuration quickly to switch contexts between local, dev and staging** |
| kcuc | `kubectl config use-context` | Set the current-context in a kubeconfig file | | kcuc | `kubectl config use-context` | Set the current-context in a kubeconfig file |
| kcsc | `kubectl config set-context` | Set a context entry in kubeconfig | | kcsc | `kubectl config set-context` | Set a context entry in kubeconfig |
| kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig | | kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig |
| kccc | `kubectl config current-context` | Display the current-context | | kccc | `kubectl config current-context` | Display the current-context |
| kcgc | `kubectl config get-contexts` | List of contexts available | | kcgc | `kubectl config get-contexts` | List of contexts available |
| | | **General aliases** | | | | **General aliases** |
| kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector | | kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector |
| kdelf | `kubectl delete -f` | Delete a pod using the type and name specified in -f argument | | kdelf | `kubectl delete -f` | Delete a pod using the type and name specified in -f argument |
| | | **Pod management** | | kge | `kubectl get events --sort-by=".lastTimestamp"` | Get events (sorted by timestamp) |
| kgp | `kubectl get pods` | List all pods in ps output format | | kgew | `kubectl get events --watch --sort-by=".lastTimestamp"` | Get events and watch as they occur (sorted by timestamp) |
| kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` | | | | **Pod management** |
| kgpn | `kgp -n` | Get pods by namespace. Example: `kgpn kube-system` | | kgp | `kubectl get pods` | List all pods in ps output format |
| kgpsl | `kubectl get pods --show-labels` | List all pods in ps output format with labels | | kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` |
| kgpw | `kgp --watch` | After listing/getting the requested object, watch for changes | | kgpn | `kgp -n` | Get pods by namespace. Example: `kgpn kube-system` |
| kgpwide | `kgp -o wide` | Output in plain-text format with any additional information. For pods, the node name is included | | kgpsl | `kubectl get pods --show-labels` | List all pods in ps output format with labels |
| kep | `kubectl edit pods` | Edit pods from the default editor | | kgpw | `kgp --watch` | After listing/getting the requested object, watch for changes |
| kdp | `kubectl describe pods` | Describe all pods | | kgpwide | `kgp -o wide` | Output in plain-text format with any additional information. For pods, the node name is included |
| kdelp | `kubectl delete pods` | Delete all pods matching passed arguments | | kep | `kubectl edit pods` | Edit pods from the default editor |
| | | **Service management** | | kdp | `kubectl describe pods` | Describe all pods |
| kgs | `kubectl get svc` | List all services in ps output format | | kdelp | `kubectl delete pods` | Delete all pods matching passed arguments |
| kgsw | `kgs --watch` | After listing all services, watch for changes | | | | **Service management** |
| kgswide | `kgs -o wide` | After listing all services, output in plain-text format with any additional information | | kgs | `kubectl get svc` | List all services in ps output format |
| kes | `kubectl edit svc` | Edit services(svc) from the default editor | | kgsw | `kgs --watch` | After listing all services, watch for changes |
| kds | `kubectl describe svc` | Describe all services in detail | | kgswide | `kgs -o wide` | After listing all services, output in plain-text format with any additional information |
| kdels | `kubectl delete svc` | Delete all services matching passed argument | | kes | `kubectl edit svc` | Edit services(svc) from the default editor |
| | | **Ingress management** | | kds | `kubectl describe svc` | Describe all services in detail |
| kgi | `kubectl get ingress` | List ingress resources in ps output format | | kdels | `kubectl delete svc` | Delete all services matching passed argument |
| kei | `kubectl edit ingress` | Edit ingress resource from the default editor | | | | **Ingress management** |
| kdi | `kubectl describe ingress` | Describe ingress resource in detail | | kgi | `kubectl get ingress` | List ingress resources in ps output format |
| kdeli | `kubectl delete ingress` | Delete ingress resources matching passed argument | | kei | `kubectl edit ingress` | Edit ingress resource from the default editor |
| | | **Namespace management** | | kdi | `kubectl describe ingress` | Describe ingress resource in detail |
| kgns | `kubectl get namespaces` | List the current namespaces in a cluster | | kdeli | `kubectl delete ingress` | Delete ingress resources matching passed argument |
| kcn | `kubectl config set-context --current --namespace` | Change current namespace | | | | **Namespace management** |
| kens | `kubectl edit namespace` | Edit namespace resource from the default editor | | kgns | `kubectl get namespaces` | List the current namespaces in a cluster |
| kdns | `kubectl describe namespace` | Describe namespace resource in detail | | kcn | `kubectl config set-context --current --namespace` | Change current namespace |
| kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace | | kens | `kubectl edit namespace` | Edit namespace resource from the default editor |
| | | **ConfigMap management** | | kdns | `kubectl describe namespace` | Describe namespace resource in detail |
| kgcm | `kubectl get configmaps` | List the configmaps in ps output format | | kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace |
| kecm | `kubectl edit configmap` | Edit configmap resource from the default editor | | | | **ConfigMap management** |
| kdcm | `kubectl describe configmap` | Describe configmap resource in detail | | kgcm | `kubectl get configmaps` | List the configmaps in ps output format |
| kdelcm | `kubectl delete configmap` | Delete the configmap | | kecm | `kubectl edit configmap` | Edit configmap resource from the default editor |
| | | **Secret management** | | kdcm | `kubectl describe configmap` | Describe configmap resource in detail |
| kgsec | `kubectl get secret` | Get secret for decoding | | kdelcm | `kubectl delete configmap` | Delete the configmap |
| kdsec | `kubectl describe secret` | Describe secret resource in detail | | | | **Secret management** |
| kdelsec | `kubectl delete secret` | Delete the secret | | kgsec | `kubectl get secret` | Get secret for decoding |
| | | **Deployment management** | | kdsec | `kubectl describe secret` | Describe secret resource in detail |
| kgd | `kubectl get deployment` | Get the deployment | | kdelsec | `kubectl delete secret` | Delete the secret |
| kgdw | `kgd --watch` | After getting the deployment, watch for changes | | | | **Deployment management** |
| kgdwide | `kgd -o wide` | After getting the deployment, output in plain-text format with any additional information | | kgd | `kubectl get deployment` | Get the deployment |
| ked | `kubectl edit deployment` | Edit deployment resource from the default editor | | kgdw | `kgd --watch` | After getting the deployment, watch for changes |
| kdd | `kubectl describe deployment` | Describe deployment resource in detail | | kgdwide | `kgd -o wide` | After getting the deployment, output in plain-text format with any additional information |
| kdeld | `kubectl delete deployment` | Delete the deployment | | ked | `kubectl edit deployment` | Edit deployment resource from the default editor |
| ksd | `kubectl scale deployment` | Scale a deployment | | kdd | `kubectl describe deployment` | Describe deployment resource in detail |
| krsd | `kubectl rollout status deployment` | Check the rollout status of a deployment | | kdeld | `kubectl delete deployment` | Delete the deployment |
| kres | `kubectl set env $@ REFRESHED_AT=...` | Recreate all pods in deployment with zero-downtime | | ksd | `kubectl scale deployment` | Scale a deployment |
| | | **Rollout management** | | krsd | `kubectl rollout status deployment` | Check the rollout status of a deployment |
| kgrs | `kubectl get replicaset` | List all ReplicaSets `rs` created by the deployment | | kres | `kubectl set env $@ REFRESHED_AT=...` | Recreate all pods in deployment with zero-downtime |
| kdrs | `kubectl describe replicaset` | Describe ReplicaSet in detail | | | | **Rollout management** |
| kers | `kubectl edit replicaset` | Edit ReplicaSet from the default editor | | kgrs | `kubectl get replicaset` | List all ReplicaSets `rs` created by the deployment |
| krh | `kubectl rollout history` | Check the revisions of this deployment | | kdrs | `kubectl describe replicaset` | Describe ReplicaSet in detail |
| kru | `kubectl rollout undo` | Rollback to the previous revision | | kers | `kubectl edit replicaset` | Edit ReplicaSet from the default editor |
| | | **Port forwarding** | | krh | `kubectl rollout history` | Check the revisions of this deployment |
| kpf | `kubectl port-forward` | Forward one or more local ports to a pod | | kru | `kubectl rollout undo` | Rollback to the previous revision |
| | | **Tools for accessing all information** | | | | **Port forwarding** |
| kga | `kubectl get all` | List all resources in ps format | | kpf | `kubectl port-forward` | Forward one or more local ports to a pod |
| kgaa | `kubectl get all --all-namespaces` | List the requested object(s) across all namespaces | | | | **Tools for accessing all information** |
| | | **Logs** | | kga | `kubectl get all` | List all resources in ps format |
| kl | `kubectl logs` | Print the logs for a container or resource | | kgaa | `kubectl get all --all-namespaces` | List the requested object(s) across all namespaces |
| klf | `kubectl logs -f` | Stream the logs for a container or resource (follow) | | | | **Logs** |
| | | **File copy** | | kl | `kubectl logs` | Print the logs for a container or resource |
| kcp | `kubectl cp` | Copy files and directories to and from containers | | klf | `kubectl logs -f` | Stream the logs for a container or resource (follow) |
| | | **Node management** | | | | **File copy** |
| kgno | `kubectl get nodes` | List the nodes in ps output format | | kcp | `kubectl cp` | Copy files and directories to and from containers |
| kgnosl | `kubectl get nodes --show-labels` | List the nodes in ps output format with labels | | | | **Node management** |
| keno | `kubectl edit node` | Edit nodes resource from the default editor | | kgno | `kubectl get nodes` | List the nodes in ps output format |
| kdno | `kubectl describe node` | Describe node resource in detail | | kgnosl | `kubectl get nodes --show-labels` | List the nodes in ps output format with labels |
| kdelno | `kubectl delete node` | Delete the node | | keno | `kubectl edit node` | Edit nodes resource from the default editor |
| | | **Persistent Volume Claim management** | | kdno | `kubectl describe node` | Describe node resource in detail |
| kgpvc | `kubectl get pvc` | List all PVCs | | kdelno | `kubectl delete node` | Delete the node |
| kgpvcw | `kgpvc --watch` | After listing/getting the requested object, watch for changes | | | | **Persistent Volume Claim management** |
| kepvc | `kubectl edit pvc` | Edit pvcs from the default editor | | kgpvc | `kubectl get pvc` | List all PVCs |
| kdpvc | `kubectl describe pvc` | Describe all pvcs | | kgpvcw | `kgpvc --watch` | After listing/getting the requested object, watch for changes |
| kdelpvc | `kubectl delete pvc` | Delete all pvcs matching passed arguments | | kepvc | `kubectl edit pvc` | Edit pvcs from the default editor |
| | | **StatefulSets management** | | kdpvc | `kubectl describe pvc` | Describe all pvcs |
| kgss | `kubectl get statefulset` | List the statefulsets in ps format | | kdelpvc | `kubectl delete pvc` | Delete all pvcs matching passed arguments |
| kgssw | `kgss --watch` | After getting the list of statefulsets, watch for changes | | | | **StatefulSets management** |
| kgsswide | `kgss -o wide` | After getting the statefulsets, output in plain-text format with any additional information | | kgss | `kubectl get statefulset` | List the statefulsets in ps format |
| kess | `kubectl edit statefulset` | Edit statefulset resource from the default editor | | kgssw | `kgss --watch` | After getting the list of statefulsets, watch for changes |
| kdss | `kubectl describe statefulset` | Describe statefulset resource in detail | | kgsswide | `kgss -o wide` | After getting the statefulsets, output in plain-text format with any additional information |
| kdelss | `kubectl delete statefulset` | Delete the statefulset | | kess | `kubectl edit statefulset` | Edit statefulset resource from the default editor |
| ksss | `kubectl scale statefulset` | Scale a statefulset | | kdss | `kubectl describe statefulset` | Describe statefulset resource in detail |
| krsss | `kubectl rollout status statefulset` | Check the rollout status of a deployment | | kdelss | `kubectl delete statefulset` | Delete the statefulset |
| | | **Service Accounts management** | | ksss | `kubectl scale statefulset` | Scale a statefulset |
| kdsa | `kubectl describe sa` | Describe a service account in details | | krsss | `kubectl rollout status statefulset` | Check the rollout status of a deployment |
| kdelsa | `kubectl delete sa` | Delete the service account | | | | **Service Accounts management** |
| | | **DaemonSet management** | | kdsa | `kubectl describe sa` | Describe a service account in details |
| kgds | `kubectl get daemonset` | List all DaemonSets in ps output format | | kdelsa | `kubectl delete sa` | Delete the service account |
| kgdsw | `kgds --watch` | After listing all DaemonSets, watch for changes | | | | **DaemonSet management** |
| keds | `kubectl edit daemonset` | Edit DaemonSets from the default editor | | kgds | `kubectl get daemonset` | List all DaemonSets in ps output format |
| kdds | `kubectl describe daemonset` | Describe all DaemonSets in detail | | kgdsw | `kgds --watch` | After listing all DaemonSets, watch for changes |
| kdelds | `kubectl delete daemonset` | Delete all DaemonSets matching passed argument | | keds | `kubectl edit daemonset` | Edit DaemonSets from the default editor |
| | | **CronJob management** | | kdds | `kubectl describe daemonset` | Describe all DaemonSets in detail |
| kgcj | `kubectl get cronjob` | List all CronJobs in ps output format | | kdelds | `kubectl delete daemonset` | Delete all DaemonSets matching passed argument |
| kecj | `kubectl edit cronjob` | Edit CronJob from the default editor | | | | **CronJob management** |
| kdcj | `kubectl describe cronjob` | Describe a CronJob in details | | kgcj | `kubectl get cronjob` | List all CronJobs in ps output format |
| kdelcj | `kubectl delete cronjob` | Delete the CronJob | | kecj | `kubectl edit cronjob` | Edit CronJob from the default editor |
| | | **Job management** | | kdcj | `kubectl describe cronjob` | Describe a CronJob in details |
| kgj | `kubectl get job` | List all Job in ps output format | | kdelcj | `kubectl delete cronjob` | Delete the CronJob |
| kej | `kubectl edit job` | Edit a Job in details | | | | **Job management** |
| kdj | `kubectl describe job` | Describe the Job | | kgj | `kubectl get job` | List all Job in ps output format |
| kdelj | `kubectl delete job` | Delete the Job | | kej | `kubectl edit job` | Edit a Job in details |
| kdj | `kubectl describe job` | Describe the Job |
| kdelj | `kubectl delete job` | Delete the Job |
## Wrappers ## Wrappers

View file

@ -36,6 +36,8 @@ alias kcgc='kubectl config get-contexts'
# General aliases # General aliases
alias kdel='kubectl delete' alias kdel='kubectl delete'
alias kdelf='kubectl delete -f' alias kdelf='kubectl delete -f'
alias kge='kubectl get events --sort-by=".lastTimestamp"'
alias kgew='kubectl get events --sort-by=".lastTimestamp" --watch'
# Pod management. # Pod management.
alias kgp='kubectl get pods' alias kgp='kubectl get pods'

View file

@ -21,6 +21,7 @@ plugins=(... laravel)
| `pamfs` | `php artisan migrate:fresh --seed` | | `pamfs` | `php artisan migrate:fresh --seed` |
| `pamr` | `php artisan migrate:rollback` | | `pamr` | `php artisan migrate:rollback` |
| `pads` | `php artisan db:seed` | | `pads` | `php artisan db:seed` |
| `padw` | `php artisan db:wipe` |
## Makers ## Makers

View file

@ -12,6 +12,7 @@ alias pamf='php artisan migrate:fresh'
alias pamfs='php artisan migrate:fresh --seed' alias pamfs='php artisan migrate:fresh --seed'
alias pamr='php artisan migrate:rollback' alias pamr='php artisan migrate:rollback'
alias pads='php artisan db:seed' alias pads='php artisan db:seed'
alias padw='php artisan db:wipe'
# Makers # Makers
alias pamm='php artisan make:model' alias pamm='php artisan make:model'

View file

@ -13,6 +13,7 @@ plugins=(... macos)
- [iTerm2](https://iterm2.com/) - [iTerm2](https://iterm2.com/)
- [Hyper](https://hyper.is/) - [Hyper](https://hyper.is/)
- [Tabby](https://tabby.sh/) - [Tabby](https://tabby.sh/)
- [Ghostty](https://ghostty.org)
## Commands ## Commands

View file

@ -85,6 +85,12 @@ EOF
tell application "System Events" tell application "System Events"
tell process "Tabby" to keystroke "t" using command down tell process "Tabby" to keystroke "t" using command down
end tell end tell
EOF
elif [[ "$the_app" == 'ghostty' ]]; then
osascript >/dev/null <<EOF
tell application "System Events"
tell process "Ghostty" to keystroke "t" using command down
end tell
EOF EOF
else else
echo "$0: unsupported terminal app: $the_app" >&2 echo "$0: unsupported terminal app: $the_app" >&2
@ -139,6 +145,12 @@ EOF
tell application "System Events" tell application "System Events"
tell process "Tabby" to keystroke "D" using command down tell process "Tabby" to keystroke "D" using command down
end tell end tell
EOF
elif [[ "$the_app" == 'ghostty' ]]; then
osascript >/dev/null <<EOF
tell application "System Events"
tell process "Ghostty" to keystroke "D" using command down
end tell
EOF EOF
else else
echo "$0: unsupported terminal app: $the_app" >&2 echo "$0: unsupported terminal app: $the_app" >&2
@ -194,6 +206,12 @@ EOF
tell application "System Events" tell application "System Events"
tell process "Tabby" to keystroke "d" using command down tell process "Tabby" to keystroke "d" using command down
end tell end tell
EOF
elif [[ "$the_app" == 'ghostty' ]]; then
osascript >/dev/null <<EOF
tell application "System Events"
tell process "Ghostty" to keystroke "d" using command down
end tell
EOF EOF
else else
echo "$0: unsupported terminal app: $the_app" >&2 echo "$0: unsupported terminal app: $the_app" >&2
@ -253,7 +271,7 @@ function man-preview() {
[[ $# -eq 0 ]] && >&2 echo "Usage: $0 command1 [command2 ...]" && return 1 [[ $# -eq 0 ]] && >&2 echo "Usage: $0 command1 [command2 ...]" && return 1
local page local page
for page in "${(@f)"$(man -w $@)"}"; do for page in "${(@f)"$(command man -w $@)"}"; do
command mandoc -Tpdf $page | open -f -a Preview command mandoc -Tpdf $page | open -f -a Preview
done done
} }

View file

@ -146,6 +146,16 @@ case $state in
(help) (help)
_arguments ':feature:__task_list' _arguments ':feature:__task_list'
;; ;;
(format)
_arguments -C \
'--check-formatted' \
'--dot-formatter' \
'--dry-run' \
'--force' \
'--migrate' \
'--no-exit' \
'*::file:_files'
;;
(test) (test)
_files _files
;; ;;

View file

@ -33,6 +33,8 @@ if it's found, or the mvn command otherwise.
| `mvnct` | `mvn clean test` | | `mvnct` | `mvn clean test` |
| `mvncv` | `mvn clean verify` | | `mvncv` | `mvn clean verify` |
| `mvncvst` | `mvn clean verify -DskipTests` | | `mvncvst` | `mvn clean verify -DskipTests` |
| `mvnv` | `mvn verify` |
| `mvnvst` | `mvn verify -DskipTests` |
| `mvndp` | `mvn deploy` | | `mvndp` | `mvn deploy` |
| `mvndocs` | `mvn dependency:resolve -Dclassifier=javadoc` | | `mvndocs` | `mvn dependency:resolve -Dclassifier=javadoc` |
| `mvndt` | `mvn dependency:tree` | | `mvndt` | `mvn dependency:tree` |

View file

@ -62,6 +62,8 @@ alias mvncp='mvn clean package'
alias mvnct='mvn clean test' alias mvnct='mvn clean test'
alias mvncv='mvn clean verify' alias mvncv='mvn clean verify'
alias mvncvst='mvn clean verify -DskipTests' alias mvncvst='mvn clean verify -DskipTests'
alias mvnv='mvn verify'
alias mvnvst='mvn verify -DskipTests'
alias mvndp='mvn deploy' alias mvndp='mvn deploy'
alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc' alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc'
alias mvndt='mvn dependency:tree' alias mvndt='mvn dependency:tree'
@ -101,8 +103,14 @@ function listMavenCompletions {
new_file="../pom.xml" new_file="../pom.xml"
fi fi
# if file doesn't exist break
file="${file:h}/${new_file}" file="${file:h}/${new_file}"
# if the file points to a directory, assume it is a pom.xml in that directory
if [[ -d "$file" ]]; then
file="${file}/pom.xml"
fi
# if file doesn't exist break
if ! [[ -e "$file" ]]; then if ! [[ -e "$file" ]]; then
break break
fi fi

View file

@ -35,6 +35,7 @@ toggle set the `PER_DIRECTORY_HISTORY_TOGGLE` environment variable.
function above (default `^G`) function above (default `^G`)
* `PER_DIRECTORY_HISTORY_PRINT_MODE_CHANGE` is a variable which toggles whether * `PER_DIRECTORY_HISTORY_PRINT_MODE_CHANGE` is a variable which toggles whether
the current mode is printed to the screen following a mode change (default `true`) the current mode is printed to the screen following a mode change (default `true`)
* `HISTORY_START_WITH_GLOBAL` is a global variable that defines how to start the plugin: global or local (default `false`)
## History ## History

View file

@ -8,30 +8,36 @@ To use it, add `perl` to the plugins array in your zshrc file:
plugins=(... perl) plugins=(... perl)
``` ```
## Perlbrew activation
If the plugin detects that `perlbrew` hasn't been activated, yet there is an installation of it in
`$PERLBREW_ROOT`, it'll initialize by default. To avoid this behaviour, set `ZSH_PERLBREW_ACTIVATE=false`
before `source oh-my-zsh.sh` in your zshrc.
## Aliases ## Aliases
| Aliases | Command | Description | | Aliases | Command | Description |
| :------------ | :----------------- | :------------------------------------- | | :---------- | :----------------- | :------------------------------------- |
| pbi | `perlbrew install` | Install specific perl version | | pbi | `perlbrew install` | Install specific perl version |
| pbl | `perlbrew list` | List all perl version installed | | pbl | `perlbrew list` | List all perl version installed |
| pbo | `perlbrew off` | Go back to the system perl | | pbo | `perlbrew off` | Go back to the system perl |
| pbs | `perlbrew switch` | Turn it back on | | pbs | `perlbrew switch` | Turn it back on |
| pbu | `perlbrew use` | Use specific version of perl | | pbu | `perlbrew use` | Use specific version of perl |
| pd | `perldoc` | Show the perl documentation | | pd | `perldoc` | Show the perl documentation |
| ple | `perl -wlne` | Use perl like awk/sed | | ple | `perl -wlne` | Use perl like awk/sed |
| latest-perl | `curl ...` | Show the latest stable release of Perl | | latest-perl | `curl ...` | Show the latest stable release of Perl |
## Functions ## Functions
* `newpl`: creates a basic Perl script file and opens it with $EDITOR. - `newpl`: creates a basic Perl script file and opens it with $EDITOR.
* `pgs`: Perl Global Substitution: `pgs <find_pattern> <replace_pattern> <filename>` - `pgs`: Perl Global Substitution: `pgs <find_pattern> <replace_pattern> <filename>` Looks for
Looks for `<find_pattern>` and replaces it with `<replace_pattern>` in `<filename>`. `<find_pattern>` and replaces it with `<replace_pattern>` in `<filename>`.
* `prep`: Perl grep, because 'grep -P' is terrible: `prep <pattern> [<filename>]` - `prep`: Perl grep, because 'grep -P' is terrible: `prep <pattern> [<filename>]` Lets you work with pipes or
Lets you work with pipes or files (if no `<filename>` provided, use stdin). files (if no `<filename>` provided, use stdin).
## Requirements ## Requirements
In order to make this work, you will need to have perl installed. In order to make this work, you will need to have perl installed. More info on the usage and install:
More info on the usage and install: https://www.perl.org/get.html https://www.perl.org/get.html

View file

@ -54,3 +54,12 @@ pgs() { # [find] [replace] [filename]
prep() { # [pattern] [filename unless STDOUT] prep() { # [pattern] [filename unless STDOUT]
perl -nle 'print if /'"$1"'/;' $2 perl -nle 'print if /'"$1"'/;' $2
} }
# If the 'perlbrew' function isn't defined, perlbrew isn't setup.
if [[ $ZSH_PERLBREW_ACTIVATE != false ]] && (( ! $+functions[perlbrew] )); then
local _perlbrew="${PERLBREW_ROOT:-${HOME}/perl5/perlbrew}"
if [[ -f "${_perlbrew}/etc/bashrc" ]]; then
source "${_perlbrew}/etc/bashrc"
fi
unset _perlbrew
fi

View file

@ -20,17 +20,17 @@ the next time you autocomplete `pip install`.
## Aliases ## Aliases
| Alias | Description | | Alias | Command | Description |
| :------- | :-------------------------------------------- | | :--------|:----------------------------------------------------------------------------------|:--------------------------------------------- |
| pipi | Install packages | | pipi | `pip install` | Install packages |
| pipig | Install package from GitHub repository | | pipig | `pip install "git+https://github.com/user/repo.git"` | Install package from GitHub repository |
| pipigb | Install package from GitHub branch | | pipigb | `pip install "git+https://github.com/user/repo.git@branch"` | Install package from GitHub branch |
| pipigp | Install package from GitHub pull request | | pipigp | `pip install "git+https://github.com/user/repo.git@refs/pull/PR_NUMBER/head"` | Install package from GitHub pull request |
| pipu | Upgrade packages | | pipu | `pip install --upgrade` | Upgrade packages |
| pipun | Uninstall packages | | pipun | `pip uninstall` | Uninstall packages |
| pipgi | Grep through installed packages | | pipgi | `pip freeze \| grep` | Grep through installed packages |
| piplo | List outdated packages | | piplo | `pip list --outdated` | List outdated packages |
| pipreq | Create requirements file | | pipreq | `pip freeze > requirements.txt` | Create requirements file |
| pipir | Install packages from `requirements.txt` file | | pipir | `pip install -r requirements.txt` | Install packages from `requirements.txt` file |
| pipupall | Update all installed packages | | pipupall | `pip list --outdated \| awk 'NR > 2 { print $1 }' \| xargs pip install --upgrade` | Update all installed packages |
| pipunall | Uninstall all installed packages | | pipunall | `pip list --format freeze \| cut -d= -f1 \| xargs pip uninstall` | Uninstall all installed packages |

View file

@ -3,11 +3,19 @@ if (( ! $+commands[procs] )); then
fi fi
# If the completion file doesn't exist yet, we need to autoload it and # If the completion file doesn't exist yet, we need to autoload it and
# bind it to `minikube`. Otherwise, compinit will have already done that. # bind it to `procs`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_procs" ]]; then if [[ ! -f "$ZSH_CACHE_DIR/completions/_procs" ]]; then
typeset -g -A _comps typeset -g -A _comps
autoload -Uz _procs autoload -Uz _procs
_comps[procs]=_procs _comps[procs]=_procs
fi fi
procs --gen-completion-out zsh >| "$ZSH_CACHE_DIR/completions/_procs" &| {
autoload -Uz is-at-least
local _version=$(procs --version)
if is-at-least "0.14" "${_version#procs }"; then
procs --gen-completion-out zsh >| "$ZSH_CACHE_DIR/completions/_procs"
else
procs --completion-out zsh >| "$ZSH_CACHE_DIR/completions/_procs"
fi
} &|

View file

@ -24,16 +24,45 @@ plugins=(... python)
The plugin provides three utilities to manage Python 3.3+ [venv](https://docs.python.org/3/library/venv.html) The plugin provides three utilities to manage Python 3.3+ [venv](https://docs.python.org/3/library/venv.html)
virtual environments: virtual environments:
- `mkv [name]`: make a new virtual environment called `name` (default: if set `$PYTHON_VENV_NAME`, else - `mkv [name]`: make a new virtual environment called `name` in the current directory.
`venv`) in the current directory. **Default**: `$PYTHON_VENV_NAME` if set, otherwise `venv`.
- `vrun [name]`: Activate the virtual environment called `name` (default: if set `$PYTHON_VENV_NAME`, else - `vrun [name]`: activate the virtual environment called `name` in the current directory.
`venv`) in the current directory. **Default**: the first existing in `$PYTHON_VENV_NAMES`.
- `auto_vrun`: Automatically activate the venv virtual environment when entering a directory containing - `auto_vrun`: automatically activate the venv virtual environment when entering a directory containing
`<venv-name>/bin/activate`, and automatically deactivate it when navigating out of it (keeps venv activated `<venv-name>/bin/activate`, and automatically deactivate it when navigating out of it (keeps venv activated
in subdirectories). in subdirectories).
- To enable the feature, set `export PYTHON_AUTO_VRUN=true` before sourcing oh-my-zsh. - To enable the feature, set `PYTHON_AUTO_VRUN=true` before sourcing oh-my-zsh.
- Plugin activates first virtual environment in lexicographic order whose name begins with `<venv-name>`. - 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 The default virtual environment name is `venv`. To use a different name, set
`export PYTHON_VENV_NAME=<venv-name>`. For example: `export PYTHON_VENV_NAME=".venv"` `PYTHON_VENV_NAME=<venv-name>`. For example: `PYTHON_VENV_NAME=".venv"`
### Settings
You can set these variables in your `.zshrc` file, before Oh My Zsh is sourced.
For example:
```sh
PYTHON_VENV_NAME=".venv"
PYTHON_VENV_NAMES=($PYTHON_VENV_NAME venv)
...
plugins=(... python)
source "$ZSH/oh-my-zsh.sh"
```
## `$PYTHON_VENV_NAME`
**Default**: `venv`.
Preferred name for virtual environments, for example when creating via `mkv`.
## `$PYTHON_VENV_NAMES`
**Default**: `$PYTHON_VENV_NAME venv .venv`.
Array of virtual environment names to be checked, in order, by `vrun` and `auto_vrun`.
This means these functions will load the first existing virtual environment in this list.
Duplicate names are ignored.

View file

@ -47,12 +47,29 @@ alias pygrep='grep -nr --include="*.py"'
alias pyserver="python3 -m http.server" alias pyserver="python3 -m http.server"
## venv utilities ## venv settings
: ${PYTHON_VENV_NAME:=venv} : ${PYTHON_VENV_NAME:=venv}
# Array of possible virtual environment names to look for, in order
# -U for removing duplicates
typeset -gaU PYTHON_VENV_NAMES
[[ -n "$PYTHON_VENV_NAMES" ]] || PYTHON_VENV_NAMES=($PYTHON_VENV_NAME venv .venv)
# Activate a the python virtual environment specified. # Activate a the python virtual environment specified.
# If none specified, use $PYTHON_VENV_NAME, else 'venv'. # If none specified, use the first existing in $PYTHON_VENV_NAMES.
function vrun() { function vrun() {
if [[ -z "$1" ]]; then
local name
for name in $PYTHON_VENV_NAMES; do
local venvpath="${name:P}"
if [[ -d "$venvpath" ]]; then
vrun "$name"
return $?
fi
done
echo >&2 "Error: no virtual environment found in current directory"
fi
local name="${1:-$PYTHON_VENV_NAME}" local name="${1:-$PYTHON_VENV_NAME}"
local venvpath="${name:P}" local venvpath="${name:P}"
@ -91,10 +108,11 @@ if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then
fi fi
if [[ $PWD != ${VIRTUAL_ENV:h} ]]; then if [[ $PWD != ${VIRTUAL_ENV:h} ]]; then
for _file in "${PYTHON_VENV_NAME}"*/bin/activate(N.); do local file
for file in "${^PYTHON_VENV_NAMES[@]}"/bin/activate(N.); do
# make sure we're not in a venv already # make sure we're not in a venv already
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1 (( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
source $_file > /dev/null 2>&1 source $file > /dev/null 2>&1
break break
done done
fi fi

View file

@ -8,7 +8,7 @@ function quote {
# Get random quote data # Get random quote data
local data local data
data="$(command curl -s --connect-timeout 2 "http://www.quotationspage.com/random.php" \ data="$(command curl -s --connect-timeout 2 "https://www.quotationspage.com/random.php" \
| iconv -c -f ISO-8859-1 -t UTF-8 \ | iconv -c -f ISO-8859-1 -t UTF-8 \
| command grep -a -m 1 'dt class="quote"')" | command grep -a -m 1 'dt class="quote"')"

View file

@ -1,16 +1,26 @@
# rsync # rsync
This plugin adds aliases for frequent [rsync](https://rsync.samba.org/) commands. This plugin adds aliases for frequent [rsync](https://rsync.samba.org/) commands, simplifying file transfer and synchronization tasks.
To use it add `rsync` to the plugins array in you zshrc file. To use it add `rsync` to the plugins array in you `.zshrc` file.
```zsh ```zsh
plugins=(... rsync) plugins=(... rsync)
``` ```
| Alias | Command | | Alias | Command | Description |
| ------------------- | ------------------------------------------------ | | ------------------- | ------------------------------------------------ | ------------|
| *rsync-copy* | `rsync -avz --progress -h` | | `rsync-copy` | `rsync -avz --progress -h` | Recursively copy files and directories, preserving permissions, timestamps, and symbolic links. Compression is enabled for faster transfers. Progress is displayed in a human-readable format. |
| *rsync-move* | `rsync -avz --progress -h --remove-source-files` | | `rsync-move` | `rsync -avz --progress -h --remove-source-files` | Same as rsync-copy, but removes the source files after a successful transfer (effectively performing a move). |
| *rsync-update* | `rsync -avzu --progress -h` | | `rsync-update` | `rsync -avzu --progress -h` | Like rsync-copy, but only updates files if the source is newer than the destination (or if the destination file is missing). |
| *rsync-synchronize* | `rsync -avzu --delete --progress -h` | | `rsync-synchronize` | `rsync -avzu --delete --progress -h` | Performs bidirectional-style sync: updates files as in rsync-update and deletes files in the destination that no longer exist in the source. Useful for directory synchronization. |
Explanation of Flags:
- -a: Archive mode; preserves symbolic links, permissions, timestamps, etc.
- -v: Verbose; shows details of the transfer process.
- -z: Compress file data during transfer for efficiency.
- -u: Skip files that are newer on the receiver.
- --progress: Show progress during file transfer.
- -h: Output numbers in human-readable format (e.g., 1K, 234M).
- --remove-source-files: Deletes source files after they are copied (used in rsync-move).
- --delete: Deletes files in the destination that are not present in the source (used in rsync-synchronize).

View file

@ -22,5 +22,5 @@ fi
rustup completions zsh >| "$ZSH_CACHE_DIR/completions/_rustup" &| rustup completions zsh >| "$ZSH_CACHE_DIR/completions/_rustup" &|
cat >| "$ZSH_CACHE_DIR/completions/_cargo" <<'EOF' cat >| "$ZSH_CACHE_DIR/completions/_cargo" <<'EOF'
#compdef cargo #compdef cargo
source "$(rustc +${${(z)$(rustup default)}[1]} --print sysroot)"/share/zsh/site-functions/_cargo source "$(rustup run ${${(z)$(rustup default)}[1]} rustc --print sysroot)"/share/zsh/site-functions/_cargo
EOF EOF

View file

@ -15,4 +15,11 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_tailscale" ]]; then
fi fi
fi fi
# If using the alias, let's make sure that the aliased executable is also bound
# in case the alias points to "Tailscale" instead of "tailscale".
# See https://github.com/ohmyzsh/ohmyzsh/discussions/12928
if (( $+aliases[tailscale] )); then
_comps[${aliases[tailscale]:t}]=_tailscale
fi
tailscale completion zsh >| "$ZSH_CACHE_DIR/completions/_tailscale" &| tailscale completion zsh >| "$ZSH_CACHE_DIR/completions/_tailscale" &|

View file

@ -15,28 +15,29 @@ plugins=(... terraform)
## Aliases ## Aliases
| Alias | Command | | Alias | Command |
|---------|----------------------------------| | ------- | -------------------------------------- |
| `tf` | `terraform` | | `tf` | `terraform` |
| `tfa` | `terraform apply` | | `tfa` | `terraform apply` |
| `tfaa` | `terraform apply -auto-approve` | | `tfaa` | `terraform apply -auto-approve` |
| `tfc` | `terraform console` | | `tfc` | `terraform console` |
| `tfd` | `terraform destroy` | | `tfd` | `terraform destroy` |
| `tfd!` | `terraform destroy -auto-approve`| | `tfd!` | `terraform destroy -auto-approve` |
| `tff` | `terraform fmt` | | `tff` | `terraform fmt` |
| `tffr` | `terraform fmt -recursive` | | `tffr` | `terraform fmt -recursive` |
| `tfi` | `terraform init` | | `tfi` | `terraform init` |
| `tfiu` | `terraform init -upgrade` | | `tfir` | `terraform init -reconfigure` |
| `tfo` | `terraform output` | | `tfiu` | `terraform init -upgrade` |
| `tfp` | `terraform plan` | | `tfiur` | `terraform init -upgrade -reconfigure` |
| `tfv` | `terraform validate` | | `tfo` | `terraform output` |
| `tfs` | `terraform state` | | `tfp` | `terraform plan` |
| `tft` | `terraform test` | | `tfv` | `terraform validate` |
| `tfsh` | `terraform show` | | `tfs` | `terraform state` |
| `tfw` | `terraform workspace` | | `tft` | `terraform test` |
| `tfwl` | `terraform workspace list` | | `tfsh` | `terraform show` |
| `tfws` | `terraform workspace select` | | `tfw` | `terraform workspace` |
| `tfwl` | `terraform workspace list` |
| `tfws` | `terraform workspace select` |
## Prompt function ## Prompt function

View file

@ -2,9 +2,9 @@ function tf_prompt_info() {
# dont show 'default' workspace in home dir # dont show 'default' workspace in home dir
[[ "$PWD" != ~ ]] || return [[ "$PWD" != ~ ]] || return
# check if in terraform dir and file exists # check if in terraform dir and file exists
[[ -d .terraform && -r .terraform/environment ]] || return [[ -d "${TF_DATA_DIR:-.terraform}" && -r "${TF_DATA_DIR:-.terraform}/environment" ]] || return
local workspace="$(< .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-]}"
} }
@ -24,7 +24,9 @@ alias 'tfd!'='terraform destroy -auto-approve'
alias tff='terraform fmt' alias tff='terraform fmt'
alias tffr='terraform fmt -recursive' alias tffr='terraform fmt -recursive'
alias tfi='terraform init' alias tfi='terraform init'
alias tfir='terraform init -reconfigure'
alias tfiu='terraform init -upgrade' alias tfiu='terraform init -upgrade'
alias tfiur='terraform init -upgrade -reconfigure'
alias tfo='terraform output' alias tfo='terraform output'
alias tfp='terraform plan' alias tfp='terraform plan'
alias tfv='terraform validate' alias tfv='terraform validate'

View file

@ -6,7 +6,7 @@ __timer_current_time() {
} }
__timer_format_duration() { __timer_format_duration() {
local mins=$(printf '%.0f' $(($1 / 60))) local mins=$(printf '%.0f' $(($(IFS='.' read int dec <<< "$1"; echo $int) / 60)))
local secs=$(printf "%.${TIMER_PRECISION:-1}f" $(($1 - 60 * mins))) local secs=$(printf "%.${TIMER_PRECISION:-1}f" $(($1 - 60 * mins)))
local duration_str=$(echo "${mins}m${secs}s") local duration_str=$(echo "${mins}m${secs}s")
local format="${TIMER_FORMAT:-/%d}" local format="${TIMER_FORMAT:-/%d}"

View file

@ -31,6 +31,7 @@ The plugin also supports the following:
| Variable | Description | | Variable | Description |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `ZSH_TMUX_AUTOREFRESH` | Automatically refresh global environments (default: `false`) |
| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) | | `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) |
| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) | | `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) |
| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) | | `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) |

View file

@ -15,6 +15,8 @@ fi
: ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART} : ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART}
# Automatically name the new session based on the basename of PWD # Automatically name the new session based on the basename of PWD
: ${ZSH_TMUX_AUTONAME_SESSION:=false} : ${ZSH_TMUX_AUTONAME_SESSION:=false}
# Automatically pick up tmux environments
: ${ZSH_TMUX_AUTOREFRESH:=false}
# Set term to screen or screen-256color based on current terminal support # Set term to screen or screen-256color based on current terminal support
: ${ZSH_TMUX_DETACHED:=false} : ${ZSH_TMUX_DETACHED:=false}
# Set detached mode # Set detached mode
@ -158,6 +160,15 @@ function _zsh_tmux_plugin_run() {
fi fi
} }
# Refresh tmux environment variables.
function _zsh_tmux_plugin_preexec()
{
local -a tmux_cmd
tmux_cmd=(command tmux)
eval $($tmux_cmd show-environment -s)
}
# Use the completions for tmux for our function # Use the completions for tmux for our function
compdef _tmux _zsh_tmux_plugin_run compdef _tmux _zsh_tmux_plugin_run
# Alias tmux to our wrapper function. # Alias tmux to our wrapper function.
@ -184,3 +195,9 @@ if [[ -z "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" && -z "$INSIDE_EMACS" && -z
_zsh_tmux_plugin_run _zsh_tmux_plugin_run
fi fi
fi fi
# Automatically refresh tmux environments if tmux is running.
if [[ -n "$TMUX" && "$ZSH_TMUX_AUTOREFRESH" == "true" ]] && tmux ls >/dev/null 2>/dev/null; then
autoload -U add-zsh-hook
add-zsh-hook preexec _zsh_tmux_plugin_preexec
fi

View file

@ -1,46 +1,76 @@
# universalarchive plugin # universalarchive plugin
Lets you compress files by a command `ua <format> <files>`, supporting various The `universalarchive` plugin provides a convenient command-line interface for archiving files and directories using a wide variety of compression formats - without having to remember the exact syntax for each tool.
compression formats (e.g. 7z, tar.gz, lzma, ...).
To enable it, add `universalarchive` to the plugins array in your zshrc file: To enable it, add `universalarchive` to the plugins array in your `.zshrc` file:
```zsh ```zsh
plugins=(... universalarchive) plugins=(... universalarchive)
``` ```
## Features
- Compress files and directories using a simple, unified command: ua <format> <files>
- Automatically detects file/directory names to generate appropriate output names
- Supports fallback naming if an output file already exists
- Works with many common and advanced compression formats
- Designed for simplicity and quick use in the terminal
## Usage ## Usage
Run `ua <format> <files>` to compress `<files>` into an archive file using `<format>`. Basic command format:
For example:
```sh ```sh
ua xz *.html ua <format> <files...>
```
- `<format>`: the archive format to use (e.g., `zip`, `tar.gz`, `xz`, `7z`, etc.)
- `<files...>`: one or more files or directories to compress
## Examples:
Compresses `notes.txt` and `images` into `notes.zip`
```sh
ua zip notes.txt images/
``` ```
this command will compress all `.html` files in directory `folder` into `folder.xz`. Creates `myproject.tar.gz`
```sh
ua tar.gz myproject/
```
This plugin saves you from having to remember which command line arguments compress a file. Compresses all .log files into `current_folder.xz`
```sh
ua xz *.log
```
## Supported compression formats The plugin will generate a default archive filename based on the input:
- For a file, the output is derived from the file name without its extension.
- For a directory, it uses the directory name.
- For multiple files, it uses the name of the common parent directory.
| Extension | Description | If the output file already exists, a unique filename is generated using `mktemp`.
|:-----------------|:-------------------------------|
| `7z` | 7zip file |
| `bz2` | Bzip2 file |
| `gz` | Gzip file |
| `lzma` | LZMA archive |
| `lzo` | LZO archive |
| `rar` | WinRAR archive |
| `tar` | Tarball |
| `tbz`/`tar.bz2` | Tarball with bzip2 compression |
| `tgz`/`tar.gz` | Tarball with gzip compression |
| `tlz`/`tar.lzma` | Tarball with lzma compression |
| `txz`/`tar.xz` | Tarball with lzma2 compression |
| `tZ`/`tar.Z` | Tarball with LZW compression |
| `xz` | LZMA2 archive |
| `Z` | Z archive (LZW) |
| `zip` | Zip archive |
| `zst` | Zstd archive |
See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for more information regarding the archive formats. ## Supported Archive Formats
| Format | Description | Tool Used |
|:-----------------|:-------------------------------|:-----------------|
| `7z` | 7zip archive | `7z` |
| `bz2` | Bzip2-compressed file | `bzip2` |
| `gz` | Gzip-compressed file | `gzip` |
| `lzma` | LZMA-compressed file | `lzma` |
| `lzo` | LZO-compressed file | `lzop` |
| `rar` | WinRAR archive | `rar` |
| `tar` | Uncompressed tarball | `tar` |
| `tbz`,`tar.bz2` | Tarball compressed with Bzip2 | `tar + bzip2` |
| `tgz`,`tar.gz` | Tarball compressed with Gzip | `tar + gzip` |
| `tlz`,`tar.lzma` | Tarball compressed with LZMA | `tar + lzma` |
| `txz`,`tar.xz` | Tarball compressed with LZMA2 | `tar + xz` |
| `tZ`,`tar.Z` | Tarball compressed with LZW | `tar + compress` |
| `xz` | XZ-compressed file | `xz` |
| `Z` | LZW-compressed file | `compress` |
| `zip` | Standard Zip archive | `zip` |
| `zst` | Zstandard-compressed file | `zstd` |
> Note: Some formats may require specific tools to be installed on your system (e.g. `7z`, `rar`, `lzop`, `zstd`). Make sure these tools are available in your `$PATH`.
## Auto-Completion
The plugin provides tab-completion for supported formats and input files. Type `ua <TAB>` to see available formats, and `ua <format> <TAB>` to browse files.

View file

@ -3,6 +3,8 @@ if (( ! ${+commands[uv]} )); then
return return
fi fi
alias uv="noglob uv"
alias uva='uv add' alias uva='uv add'
alias uvexp='uv export --format requirements-txt --no-hashes --output-file requirements.txt --quiet' alias uvexp='uv export --format requirements-txt --no-hashes --output-file requirements.txt --quiet'
alias uvl='uv lock' alias uvl='uv lock'

View file

@ -46,7 +46,7 @@ hasn't been defined by theme, *Insert mode* is not displayed by default.
You can change these indicators by setting the `MODE_INDICATOR` (*Normal mode*) and You can change these indicators by setting the `MODE_INDICATOR` (*Normal mode*) and
`INSERT_MODE_INDICATORS` (*Insert mode*) variables. `INSERT_MODE_INDICATORS` (*Insert mode*) variables.
This settings support Prompt Expansion sequences. For example: These settings support Prompt Expansion sequences. For example:
```zsh ```zsh
MODE_INDICATOR="%F{white}+%f" MODE_INDICATOR="%F{white}+%f"
@ -157,6 +157,27 @@ NOTE: delete/kill commands (`dd`, `D`, `c{motion}`, `C`, `x`,`X`) and yank comma
(`y`, `Y`) will copy to the clipboard. Contents can then be put back using paste commands (`y`, `Y`) will copy to the clipboard. Contents can then be put back using paste commands
(`P`, `p`). (`P`, `p`).
## Text objects
Standard text objects are supported with `i` ("inside") and `a` ("around"), e.g., for words; thus, you can select the word the cursor is in with `viw`, or delete the current word, including surrounding spaces, with `daw`.
For other text objects, you can rely on the built-in functionality of Zsh and enable it accordingly.
For example, for quoted strings, you can copy the commented snippet of <https://sourceforge.net/p/zsh/code/ci/master/tree/Functions/Zle/select-quoted>: place this in your `.zsrhc` file, e.g., after sourcing oh-my-zsh:
```sh
autoload -U select-quoted
zle -N select-quoted
for m in visual viopp; do
for c in {a,i}{\',\",\`}; do
bindkey -M $m $c select-quoted
done
done
```
Now, in normal mode, you can select everything inside a double-quoted string with `vi"`.
Note that this works even if you're not already inside a quoted string.
For example, you can replace everything inside a single-quoted string in the current line, from wherever the cursor is, with `ci'`.
## Known issues ## Known issues
### Low `$KEYTIMEOUT` ### Low `$KEYTIMEOUT`

View file

@ -37,6 +37,7 @@ function _wd() {
'rm:Removes the given warp point' 'rm:Removes the given warp point'
'list:Outputs all stored warp points' 'list:Outputs all stored warp points'
'ls:Show files from given warp point' 'ls:Show files from given warp point'
'open:Open warp point in the default file explorer'
'path:Show path to given warp point' 'path:Show path to given warp point'
'show:Outputs all warp points that point to the current directory or shows a specific target directory for a point' 'show:Outputs all warp points that point to the current directory or shows a specific target directory for a point'
'help:Show this extremely helpful text' 'help:Show this extremely helpful text'
@ -73,6 +74,9 @@ function _wd() {
ls) ls)
_describe -t points "Warp points" warp_points && ret=0 _describe -t points "Warp points" warp_points && ret=0
;; ;;
open)
_describe -t points "Warp points" warp_points && ret=0
;;
path) path)
_describe -t points "Warp points" warp_points && ret=0 _describe -t points "Warp points" warp_points && ret=0
;; ;;

View file

@ -8,7 +8,7 @@
# @github.com/mfaerevaag/wd # @github.com/mfaerevaag/wd
# version # version
readonly WD_VERSION=0.9.2 readonly WD_VERSION=0.10.0
# colors # colors
readonly WD_BLUE="\033[96m" readonly WD_BLUE="\033[96m"
@ -86,6 +86,7 @@ Commands:
show Print warp points to current directory show Print warp points to current directory
list Print all stored warp points list Print all stored warp points
ls <point> Show files from given warp point (ls) ls <point> Show files from given warp point (ls)
open <point> Open the warp point in the default file explorer (open / xdg-open)
path <point> Show the path to given warp point (pwd) path <point> Show the path to given warp point (pwd)
clean Remove points warping to nonexistent directories (will prompt unless --force is used) clean Remove points warping to nonexistent directories (will prompt unless --force is used)
@ -256,20 +257,47 @@ wd_remove()
} }
wd_browse() { wd_browse() {
# Check if fzf is installed
if ! command -v fzf >/dev/null; then if ! command -v fzf >/dev/null; then
echo "This functionality requires fzf. Please install fzf first." wd_print_msg "$WD_RED" "This functionality requires fzf. Please install fzf first."
return 1 return 1
fi fi
# Ensure wd_config_file is properly set
if [[ -z $wd_config_file ]]; then
wd_config_file="${WD_CONFIG:-$HOME/.warprc}"
fi
# Check if config file exists
if [[ ! -f $wd_config_file ]]; then
wd_print_msg "$WD_RED" "Config file $wd_config_file does not exist. Please create it first."
return 1
fi
# Read entries from the config file
local entries=("${(@f)$(sed "s:${HOME}:~:g" "$wd_config_file" | awk -F ':' '{print $1 " -> " $2}')}") local entries=("${(@f)$(sed "s:${HOME}:~:g" "$wd_config_file" | awk -F ':' '{print $1 " -> " $2}')}")
if [[ -z $entries ]]; then
wd_print_msg "$WD_YELLOW" "You don't have any warp points to browse"
return 1
fi
# Temp file for remove operations
local script_path="${${(%):-%x}:h}" local script_path="${${(%):-%x}:h}"
local wd_remove_output=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX") local wd_remove_output=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
# Create fzf bindings
entries=("All warp points:" "Press enter to select. Press delete to remove" "${entries[@]}") entries=("All warp points:" "Press enter to select. Press delete to remove" "${entries[@]}")
local fzf_bind="delete:execute(echo {} | awk -F ' -> ' '{print \$1}' | xargs -I {} "$script_path/wd.sh" rm {} > "$wd_remove_output")+abort" local fzf_bind="delete:execute(echo {} | awk -F ' -> ' '{print \$1}' | xargs -I {} \"$script_path/wd.sh\" rm {} > \"$wd_remove_output\")+abort"
# Run fzf
local selected_entry=$(printf '%s\n' "${entries[@]}" | fzf --height 100% --reverse --header-lines=2 --bind="$fzf_bind") local selected_entry=$(printf '%s\n' "${entries[@]}" | fzf --height 100% --reverse --header-lines=2 --bind="$fzf_bind")
# Handle selection
if [[ -e $wd_remove_output ]]; then if [[ -e $wd_remove_output ]]; then
cat "$wd_remove_output" cat "$wd_remove_output"
rm "$wd_remove_output" rm -f "$wd_remove_output"
fi fi
if [[ -n $selected_entry ]]; then if [[ -n $selected_entry ]]; then
local selected_point="${selected_entry%% ->*}" local selected_point="${selected_entry%% ->*}"
selected_point=$(echo "$selected_point" | xargs) selected_point=$(echo "$selected_point" | xargs)
@ -278,14 +306,26 @@ wd_browse() {
} }
wd_browse_widget() { wd_browse_widget() {
if [[ -e $wd_config_file ]]; then # Ensure wd_config_file is properly set
if [[ -z $wd_config_file ]]; then
wd_config_file="${WD_CONFIG:-$HOME/.warprc}"
fi
# Check if config file exists
if [[ ! -f $wd_config_file ]]; then
wd_print_msg "$WD_RED" "Config file $wd_config_file does not exist. Please create it first."
return 1
fi
# Call wd_browse to handle the selection
wd_browse wd_browse
# Restore the zsh buffer and cursor after running wd_browse
saved_buffer=$BUFFER saved_buffer=$BUFFER
saved_cursor=$CURSOR saved_cursor=$CURSOR
BUFFER= BUFFER=
zle redisplay zle redisplay
zle accept-line zle accept-line
fi
} }
wd_restore_buffer() { wd_restore_buffer() {
@ -338,6 +378,21 @@ wd_ls()
ls "${dir/#\~/$HOME}" ls "${dir/#\~/$HOME}"
} }
wd_open()
{
wd_getdir "$1"
if command -v open >/dev/null 2>&1; then
# MacOS, Ubuntu (alias)
open "${dir/#\~/$HOME}"
elif command -v xdg-open >/dev/null 2>&1; then
# Most Linux desktops
xdg-open "${dir/#\~/$HOME}"
else
echo "No known file opener found (need 'open' or 'xdg-open')." >&2
exit 1
fi
}
wd_path() wd_path()
{ {
wd_getdir "$1" wd_getdir "$1"
@ -482,7 +537,7 @@ do
done < "$wd_config_file" done < "$wd_config_file"
# get opts # get opts
args=$(getopt -o a:r:c:lhs -l add:,rm:,clean,list,ls:,path:,help,show -- $*) args=$(getopt -o a:r:c:lhs -l add:,rm:,clean,list,ls:,open:,path:,help,show -- $*)
# check if no arguments were given, and that version is not set # check if no arguments were given, and that version is not set
if [[ ($? -ne 0 || $#* -eq 0) && -z $wd_print_version ]] if [[ ($? -ne 0 || $#* -eq 0) && -z $wd_print_version ]]
@ -532,6 +587,10 @@ else
wd_ls "$2" wd_ls "$2"
break break
;; ;;
"-o"|"--open"|"open")
wd_open "$2"
break
;;
"-p"|"--path"|"path") "-p"|"--path"|"path")
wd_path "$2" wd_path "$2"
break break
@ -578,7 +637,7 @@ unset wd_print_msg
unset wd_yesorno unset wd_yesorno
unset wd_print_usage unset wd_print_usage
unset wd_alt_config unset wd_alt_config
unset wd_config_file #unset wd_config_file do not unset this - breaks keybind
unset wd_quiet_mode unset wd_quiet_mode
unset wd_print_version unset wd_print_version
unset wd_force_mode unset wd_force_mode

View file

@ -52,6 +52,7 @@ Available search contexts are:
| `gopkg` | `https://pkg.go.dev/search?m=package&q=` | | `gopkg` | `https://pkg.go.dev/search?m=package&q=` |
| `chatgpt` | `https://chatgpt.com/?q=` | | `chatgpt` | `https://chatgpt.com/?q=` |
| `reddit` | `https://www.reddit.com/search/?q=` | | `reddit` | `https://www.reddit.com/search/?q=` |
| `ppai` | `https://www.perplexity.ai/search/new?q=` |
Also there are aliases for bang-searching DuckDuckGo: Also there are aliases for bang-searching DuckDuckGo:

View file

@ -33,6 +33,7 @@ function web_search() {
gopkg "https://pkg.go.dev/search?m=package&q=" gopkg "https://pkg.go.dev/search?m=package&q="
chatgpt "https://chatgpt.com/?q=" chatgpt "https://chatgpt.com/?q="
reddit "https://www.reddit.com/search/?q=" reddit "https://www.reddit.com/search/?q="
ppai "https://www.perplexity.ai/search/new?q="
) )
# check whether the search engine is supported # check whether the search engine is supported
@ -87,6 +88,7 @@ alias packagist='web_search packagist'
alias gopkg='web_search gopkg' alias gopkg='web_search gopkg'
alias chatgpt='web_search chatgpt' alias chatgpt='web_search chatgpt'
alias reddit='web_search reddit' alias reddit='web_search reddit'
alias ppai='web_search ppai'
#add your own !bang searches here #add your own !bang searches here
alias wiki='web_search duckduckgo \!w' alias wiki='web_search duckduckgo \!w'

View file

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2018-2023 Alexandros Kozak Copyright (c) 2018-2025 Alexandros Kozak
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -6,15 +6,15 @@
![Zsh-z demo](img/demo.gif) ![Zsh-z demo](img/demo.gif)
Zsh-z is a command line tool that allows you to jump quickly to directories that you have visited frequently in the past, or recently -- but most often a combination of the two (a concept known as ["frecency"](https://en.wikipedia.org/wiki/Frecency)). It works by keeping track of when you go to directories and how much time you spend in them. It is then in the position to guess where you want to go when you type a partial string, e.g., `z src` might take you to `~/src/zsh`. `z zsh` might also get you there, and `z c/z` might prove to be even more specific -- it all depends on your habits and how much time you have been using Zsh-z to build up a database. After using Zsh-z for a little while, you will get to where you want to be by typing considerably less than you would need if you were using `cd`. Zsh-z is a command-line tool that allows you to jump quickly to directories that you have visited frequently or recently -- but most often a combination of the two (a concept known as ["frecency"](https://en.wikipedia.org/wiki/Frecency)). It works by keeping track of when you go to directories and how much time you spend in them. Based on this data, it predicts where you want to go when you type a partial string. For example, `z src` might take you to `~/src/zsh`. `z zsh` might also get you there, and `z c/z` might prove to be even more specific -- it all depends on your habits and how long you have been using Zsh-z to build up a database. After using Zsh-z for a little while, you will get to where you want to be by typing considerably less than you would need to if you were using `cd`.
Zsh-z is a native Zsh port of [rupa/z](https://github.com/rupa/z), a tool written for `bash` and Zsh that uses embedded `awk` scripts to do the heavy lifting. It was quite possibly my most used command line tool for a couple of years. I decided to translate it, `awk` parts and all, into pure Zsh script, to see if by eliminating calls to external tools (`awk`, `sort`, `date`, `sed`, `mv`, `rm`, and `chown`) and reducing forking through subshells I could make it faster. The performance increase is impressive, particularly on systems where forking is slow, such as Cygwin, MSYS2, and WSL. I have found that, in those environments, switching directories using Zsh-z can be over 100% faster than it is using `rupa/z`. Zsh-z is a native Zsh port of [`rupa/z`](https://github.com/rupa/z), a tool written for `bash` and Zsh that uses embedded `awk` scripts to do the heavy lifting. `rupa/z` was my most used command-line tool for a couple of years. I decided to translate it, `awk` parts and all, into pure Zsh script, to see if by eliminating calls to external tools (`awk`, `sort`, `date`, `sed`, `mv`, `rm`, and `chown`) and reducing forking through subshells I could make it faster. The performance increase is impressive, particularly on systems where forking is slow, such as Cygwin, MSYS2, and WSL. I have found that in those environments, switching directories using Zsh-z can be over 100% faster than it is using `rupa/z`.
There is a noteworthy stability increase as well. Race conditions have always been a problem with `rupa/z`, and users of that utility will occasionally lose their `.z` databases. By having Zsh-z only use Zsh (`rupa/z` uses a hybrid shell code that works on `bash` as well), I have been able to implement a `zsh/system`-based file-locking mechanism similar to [the one @mafredri once proposed for `rupa/z`](https://github.com/rupa/z/pull/199). It is now nearly impossible to crash the database, even through extreme testing. There is also a significant stability improvement. Race conditions have always been a problem with `rupa/z`, and users of that utility occasionally lose their `~/.z` databases. By having Zsh-z only use Zsh (`rupa/z` uses a hybrid shell code standard that works on `bash` as well), I have been able to implement a `zsh/system`-based file-locking mechanism similar to [the one @mafredri once proposed for `rupa/z`](https://github.com/rupa/z/pull/199). It is now nearly impossible to crash the database.
There are other, smaller improvements which I try to document in [Improvements and Fixes](#improvements-and-fixes). These include the new default behavior of sorting your tab completions by frecency rather than just letting Zsh sort the raw results alphabetically (a behavior which can be restored if you like it -- [see below](#settings)). There are other, smaller improvements which I document below in [Improvements and Fixes](#improvements-and-fixes). For instance, tab completions are now sorted by frecency by default rather than alphabetically (the latter behavior can be restored if you like it -- [see below](#settings)).
Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same database (`~/.z`), so you can go on using `rupa/z` when you launch `bash`. Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same database (`~/.z`, or whatever database file you specify), so you can go on using `rupa/z` when you launch `bash`.
## Table of Contents ## Table of Contents
- [News](#news) - [News](#news)
@ -37,13 +37,13 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
- August 24, 2023 - August 24, 2023
+ Zsh-z will now run when `setopt NO_UNSET` has been enabled (props @ntninja). + Zsh-z will now run when `setopt NO_UNSET` has been enabled (props @ntninja).
- August 23, 2023 - August 23, 2023
+ Better logic for loading `zsh/files` (props @z0rc) + Better logic for loading `zsh/files` (props @z0rc).
- August 2, 2023 - August 2, 2023
+ Zsh-z still uses the `zsh/files` module when possible, but will fall back on the standard `chown`, `mv`, and `rm` commands in its absence. + Zsh-z still uses the `zsh/files` module when possible but will fall back on the standard `chown`, `mv`, and `rm` commands in its absence.
- April 27, 2023 - April 27, 2023
+ Zsh-z now allows the user to specify the directory-changing command using the `ZSHZ_CD` environment variable (default: `builtin cd`; props @basnijholt). + Zsh-z now allows the user to specify the directory-changing command using the `ZSHZ_CD` environment variable (default: `builtin cd`; props @basnijholt).
- January 27, 2023 - January 27, 2023
+ If the datafile directory specified by `ZSHZ_DATA` or `_Z_DATA` does not already exist, create it (props @mattmc3). + If the database file directory specified by `ZSHZ_DATA` or `_Z_DATA` does not already exist, create it (props @mattmc3).
- June 29, 2022 - June 29, 2022
+ Zsh-z is less likely to leave temporary files sitting around (props @mafredri). + Zsh-z is less likely to leave temporary files sitting around (props @mafredri).
- June 27, 2022 - June 27, 2022
@ -69,7 +69,7 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
+ Fixed the explanation string printed during completion so that it may be formatted with `zstyle`. + Fixed the explanation string printed during completion so that it may be formatted with `zstyle`.
+ Zsh-z now declares `ZSHZ_EXCLUDE_DIRS` as an array with unique elements so that you do not have to. + Zsh-z now declares `ZSHZ_EXCLUDE_DIRS` as an array with unique elements so that you do not have to.
- July 29, 2021 - July 29, 2021
+ Temporarily disabling use of `print -v`, which seems to be mangling CJK multibyte strings. + Temporarily disabling the use of `print -v`, which was mangling CJK multibyte strings.
- July 27, 2021 - July 27, 2021
+ Internal escaping of path names now works with older versions of ZSH. + Internal escaping of path names now works with older versions of ZSH.
+ Zsh-z now detects and discards any incomplete or incorrectly formatted database entries. + Zsh-z now detects and discards any incomplete or incorrectly formatted database entries.
@ -102,7 +102,7 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
- December 22, 2020 - December 22, 2020
+ `ZSHZ_CASE`: when set to `ignore`, pattern matching is case-insensitive; when set to `smart`, patterns are matched case-insensitively when they are all lowercase and case-sensitively when they have uppercase characters in them (a behavior very much like Vim's `smartcase` setting). + `ZSHZ_CASE`: when set to `ignore`, pattern matching is case-insensitive; when set to `smart`, patterns are matched case-insensitively when they are all lowercase and case-sensitively when they have uppercase characters in them (a behavior very much like Vim's `smartcase` setting).
+ `ZSHZ_KEEP_DIRS` is an array of directory names that should not be removed from the database, even if they are not currently available (useful when a drive is not always mounted). + `ZSHZ_KEEP_DIRS` is an array of directory names that should not be removed from the database, even if they are not currently available (useful when a drive is not always mounted).
+ Symlinked datafiles were having their symlinks overwritten; this bug has been fixed. + Symlinked database files were having their symlinks overwritten; this bug has been fixed.
</details> </details>
@ -118,7 +118,7 @@ For tab completion to work, `_zshz` *must* be in the same directory as `zsh-z.pl
autoload -U compinit; compinit autoload -U compinit; compinit
in your .zshrc somewhere below where you source `zsh-z.plugin.zsh`. in your `.zshrc` somewhere below where you source `zsh-z.plugin.zsh`.
If you add If you add
@ -188,7 +188,7 @@ Add a backslash to the end of the last line add `'zsh-z'` to the list, e.g.,
Then relaunch `zsh`. Then relaunch `zsh`.
### For [zcomet](https://github.com/agkozak/zcomet) users ### For [zcomet](https://github.com/agkozak/zcomet) users
Simply add Simply add
zcomet load agkozak/zsh-z zcomet load agkozak/zsh-z
@ -228,7 +228,7 @@ Add the line
to your `.zshrc`. to your `.zshrc`.
`zsh-z` supports `zinit`'s `unload` feature; just run `zinit unload agkozak/zshz` to restore the shell to its state before `zsh-z` was loaded. Zsh-z supports `zinit`'s `unload` feature; just run `zinit unload agkozak/zsh-z` to restore the shell to its state before Zsh-z was loaded.
### For [Znap](https://github.com/marlonrichert/zsh-snap) users ### For [Znap](https://github.com/marlonrichert/zsh-snap) users
@ -249,7 +249,7 @@ somewhere above the line that says `zplug load`. Then run
zplug install zplug install
zplug load zplug load
to install `zsh-z`. to install Zsh-z.
## Command Line Options ## Command Line Options
@ -263,9 +263,9 @@ to install `zsh-z`.
- `-x` Remove a directory (by default, the current directory) from the database - `-x` Remove a directory (by default, the current directory) from the database
- `-xR` Remove a directory (by default, the current directory) and its subdirectories from the database - `-xR` Remove a directory (by default, the current directory) and its subdirectories from the database
# Settings ## Settings
Zsh-z has environment variables (they all begin with `ZSHZ_`) that change its behavior if you set them; you can also keep your old ones if you have been using `rupa/z` (they begin with `_Z_`). Zsh-z has environment variables (they all begin with `ZSHZ_`) that change its behavior if you set them. You can also keep your old ones if you have been using `rupa/z` (whose environment variables begin with `_Z_`).
* `ZSHZ_CMD` changes the command name (default: `z`) * `ZSHZ_CMD` changes the command name (default: `z`)
* `ZSHZ_CD` specifies the default directory-changing command (default: `builtin cd`) * `ZSHZ_CD` specifies the default directory-changing command (default: `builtin cd`)
@ -324,19 +324,18 @@ A good example might involve a directory tree that has Git repositories within i
(As a Zsh user, I tend to use `**` instead of `find`, but it is good to see how deep your directory trees go before doing that.) (As a Zsh user, I tend to use `**` instead of `find`, but it is good to see how deep your directory trees go before doing that.)
## Other Improvements and Fixes ## Other Improvements and Fixes
* `z -x` works, with the help of `chpwd_functions`. * `z -x` works, with the help of `chpwd_functions`.
* Zsh-z works on Solaris. * Zsh-z is compatible with Solaris.
* Zsh-z uses the "new" `zshcompsys` completion system instead of the old `compctl` one. * Zsh-z uses the "new" `zshcompsys` completion system instead of the old `compctl` one.
* There is no error message when the database file has not yet been created. * No error message is displayed when the database file has not yet been created.
* There is support for special characters (e.g., `[`) in directory names. * Special characters (e.g., `[`) in directory names are now supported.
* If `z -l` only returns one match, a common root is not printed. * If `z -l` returns only one match, a common root is not printed.
* Exit status codes increasingly make sense. * Exit status codes are more logical.
* Completions work with options `-c`, `-r`, and `-t`. * Completions now work with options `-c`, `-r`, and `-t`.
* If `~/foo` and `~/foob` are matches, `~/foo` is *not* the common root. Only a common parent directory can be a common root. * If `~/foo` and `~/foob` are matches, `~/foo` is no longer considered the common root. Only a common parent directory can be a common root.
* `z -x` and the new, recursive `z -xR` can take an argument so that you can remove directories other than `PWD` from the database. * `z -x` and the new, recursive `z -xR` can now accept an argument so that you can remove directories other than `PWD` from the database.
## Migrating from Other Tools ## Migrating from Other Tools
@ -358,7 +357,7 @@ the line
That will re-bind `z` or the command of your choice to the underlying Zsh-z function. That will re-bind `z` or the command of your choice to the underlying Zsh-z function.
## Known Bugs ## Known Bug
It is possible to run a completion on a string with spaces in it, e.g., `z us bi<TAB>` might take you to `/usr/local/bin`. This works, but as things stand, after the completion the command line reads It is possible to run a completion on a string with spaces in it, e.g., `z us bi<TAB>` might take you to `/usr/local/bin`. This works, but as things stand, after the completion the command line reads
z us /usr/local/bin. z us /usr/local/bin.

View file

@ -4,7 +4,7 @@
# #
# https://github.com/agkozak/zsh-z # https://github.com/agkozak/zsh-z
# #
# Copyright (c) 2018-2023 Alexandros Kozak # Copyright (c) 2018-2025 Alexandros Kozak
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal # of this software and associated documentation files (the "Software"), to deal
@ -120,7 +120,6 @@ fi
[[ ${builtins[zf_mv]-} == 'defined' ]] && ZSHZ[MV]='zf_mv' [[ ${builtins[zf_mv]-} == 'defined' ]] && ZSHZ[MV]='zf_mv'
[[ ${builtins[zf_rm]-} == 'defined' ]] && ZSHZ[RM]='zf_rm' [[ ${builtins[zf_rm]-} == 'defined' ]] && ZSHZ[RM]='zf_rm'
# Load zsh/system, if necessary # Load zsh/system, if necessary
[[ ${modules[zsh/system]-} == 'loaded' ]] || zmodload zsh/system &> /dev/null [[ ${modules[zsh/system]-} == 'loaded' ]] || zmodload zsh/system &> /dev/null
@ -295,7 +294,16 @@ zshz() {
owner=${ZSHZ_OWNER:-${_Z_OWNER}} owner=${ZSHZ_OWNER:-${_Z_OWNER}}
if (( ZSHZ[USE_FLOCK] )); then if (( ZSHZ[USE_FLOCK] )); then
${ZSHZ[MV]} "$tempfile" "$datafile" 2> /dev/null || ${ZSHZ[RM]} -f "$tempfile" # An unsual case: if inside Docker container where datafile could be bind
# mounted
if [[ -r '/proc/1/cgroup' && "$(< '/proc/1/cgroup')" == *docker* ]]; then
print "$(< "$tempfile")" > "$datafile" 2> /dev/null
${ZSHZ[RM]} -f "$tempfile"
# All other cases
else
${ZSHZ[MV]} "$tempfile" "$datafile" 2> /dev/null ||
${ZSHZ[RM]} -f "$tempfile"
fi
if [[ -n $owner ]]; then if [[ -n $owner ]]; then
${ZSHZ[CHOWN]} ${owner}:"$(id -ng ${owner})" "$datafile" ${ZSHZ[CHOWN]} ${owner}:"$(id -ng ${owner})" "$datafile"

View file

@ -13,6 +13,8 @@ function afmagic_dashes {
# the prompt, account for it when returning the number of dashes # the prompt, account for it when returning the number of dashes
if [[ -n "$python_env" && "$PS1" = *\(${python_env}\)* ]]; then if [[ -n "$python_env" && "$PS1" = *\(${python_env}\)* ]]; then
echo $(( COLUMNS - ${#python_env} - 3 )) echo $(( COLUMNS - ${#python_env} - 3 ))
elif [[ -n "$VIRTUAL_ENV_PROMPT" && "$PS1" = *${VIRTUAL_ENV_PROMPT}* ]]; then
echo $(( COLUMNS - ${#VIRTUAL_ENV_PROMPT} ))
else else
echo $COLUMNS echo $COLUMNS
fi fi

View file

@ -35,10 +35,74 @@
CURRENT_BG='NONE' CURRENT_BG='NONE'
case ${SOLARIZED_THEME:-dark} in case ${SOLARIZED_THEME:-dark} in
light) CURRENT_FG='white';; light)
*) CURRENT_FG='black';; CURRENT_FG=${CURRENT_FG:-'white'}
CURRENT_DEFAULT_FG=${CURRENT_DEFAULT_FG:-'white'}
;;
*)
CURRENT_FG=${CURRENT_FG:-'black'}
CURRENT_DEFAULT_FG=${CURRENT_DEFAULT_FG:-'default'}
;;
esac esac
### Theme Configuration Initialization
#
# Override these settings in your ~/.zshrc
# Current working directory
: ${AGNOSTER_DIR_FG:=${CURRENT_FG}}
: ${AGNOSTER_DIR_BG:=blue}
# user@host
: ${AGNOSTER_CONTEXT_FG:=${CURRENT_DEFAULT_FG}}
: ${AGNOSTER_CONTEXT_BG:=black}
# Git related
: ${AGNOSTER_GIT_CLEAN_FG:=${CURRENT_FG}}
: ${AGNOSTER_GIT_CLEAN_BG:=green}
: ${AGNOSTER_GIT_DIRTY_FG:=black}
: ${AGNOSTER_GIT_DIRTY_BG:=yellow}
# Bazaar related
: ${AGNOSTER_BZR_CLEAN_FG:=${CURRENT_FG}}
: ${AGNOSTER_BZR_CLEAN_BG:=green}
: ${AGNOSTER_BZR_DIRTY_FG:=black}
: ${AGNOSTER_BZR_DIRTY_BG:=yellow}
# Mercurial related
: ${AGNOSTER_HG_NEWFILE_FG:=white}
: ${AGNOSTER_HG_NEWFILE_BG:=red}
: ${AGNOSTER_HG_CHANGED_FG:=black}
: ${AGNOSTER_HG_CHANGED_BG:=yellow}
: ${AGNOSTER_HG_CLEAN_FG:=${CURRENT_FG}}
: ${AGNOSTER_HG_CLEAN_BG:=green}
# VirtualEnv colors
: ${AGNOSTER_VENV_FG:=black}
: ${AGNOSTER_VENV_BG:=blue}
# AWS Profile colors
: ${AGNOSTER_AWS_PROD_FG:=yellow}
: ${AGNOSTER_AWS_PROD_BG:=red}
: ${AGNOSTER_AWS_FG:=black}
: ${AGNOSTER_AWS_BG:=green}
# Status symbols
: ${AGNOSTER_STATUS_RETVAL_FG:=red}
: ${AGNOSTER_STATUS_ROOT_FG:=yellow}
: ${AGNOSTER_STATUS_JOB_FG:=cyan}
: ${AGNOSTER_STATUS_FG:=${CURRENT_DEFAULT_FG}}
: ${AGNOSTER_STATUS_BG:=black}
## Non-Color settings - set to 'true' to enable
# Show the actual numeric return value rather than a cross symbol.
: ${AGNOSTER_STATUS_RETVAL_NUMERIC:=false}
# Show git working dir in the style "/git/root   master  relative/dir" instead of "/git/root/relative/dir   master"
: ${AGNOSTER_GIT_INLINE:=false}
# Show the git branch status in the prompt rather than the generic branch symbol
: ${AGNOSTER_GIT_BRANCH_STATUS:=true}
# Special Powerline characters # Special Powerline characters
() { () {
@ -83,16 +147,36 @@ prompt_end() {
CURRENT_BG='' CURRENT_BG=''
} }
git_toplevel() {
local repo_root=$(git rev-parse --show-toplevel)
if [[ $repo_root = '' ]]; then
# We are in a bare repo. Use git dir as root
repo_root=$(git rev-parse --git-dir)
if [[ $repo_root = '.' ]]; then
repo_root=$PWD
fi
fi
echo -n $repo_root
}
### Prompt components ### Prompt components
# Each component will draw itself, and hide itself if no information needs to be shown # Each component will draw itself, and hide itself if no information needs to be shown
# Context: user@hostname (who am I and where am I) # Context: user@hostname (who am I and where am I)
prompt_context() { prompt_context() {
if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m" prompt_segment "$AGNOSTER_CONTEXT_BG" "$AGNOSTER_CONTEXT_FG" "%(!.%{%F{$AGNOSTER_STATUS_ROOT_FG}%}.)%n@%m"
fi fi
} }
prompt_git_relative() {
local repo_root=$(git_toplevel)
local path_in_repo=$(pwd | sed "s/^$(echo "$repo_root" | sed 's:/:\\/:g;s/\$/\\$/g')//;s:^/::;s:/$::;")
if [[ $path_in_repo != '' ]]; then
prompt_segment "$AGNOSTER_DIR_BG" "$AGNOSTER_DIR_FG" "$path_in_repo"
fi;
}
# Git: branch/detached head, dirty status # Git: branch/detached head, dirty status
prompt_git() { prompt_git() {
(( $+commands[git] )) || return (( $+commands[git] )) || return
@ -113,20 +197,22 @@ prompt_git() {
ref="◈ $(command git describe --exact-match --tags HEAD 2> /dev/null)" || \ ref="◈ $(command git describe --exact-match --tags HEAD 2> /dev/null)" || \
ref="➦ $(command git rev-parse --short HEAD 2> /dev/null)" ref="➦ $(command git rev-parse --short HEAD 2> /dev/null)"
if [[ -n $dirty ]]; then if [[ -n $dirty ]]; then
prompt_segment yellow black prompt_segment "$AGNOSTER_GIT_DIRTY_BG" "$AGNOSTER_GIT_DIRTY_FG"
else else
prompt_segment green $CURRENT_FG prompt_segment "$AGNOSTER_GIT_CLEAN_BG" "$AGNOSTER_GIT_CLEAN_FG"
fi fi
local ahead behind if [[ $AGNOSTER_GIT_BRANCH_STATUS == 'true' ]]; then
ahead=$(command git log --oneline @{upstream}.. 2>/dev/null) local ahead behind
behind=$(command git log --oneline ..@{upstream} 2>/dev/null) ahead=$(command git log --oneline @{upstream}.. 2>/dev/null)
if [[ -n "$ahead" ]] && [[ -n "$behind" ]]; then behind=$(command git log --oneline ..@{upstream} 2>/dev/null)
PL_BRANCH_CHAR=$'\u21c5' if [[ -n "$ahead" ]] && [[ -n "$behind" ]]; then
elif [[ -n "$ahead" ]]; then PL_BRANCH_CHAR=$'\u21c5'
PL_BRANCH_CHAR=$'\u21b1' elif [[ -n "$ahead" ]]; then
elif [[ -n "$behind" ]]; then PL_BRANCH_CHAR=$'\u21b1'
PL_BRANCH_CHAR=$'\u21b0' elif [[ -n "$behind" ]]; then
PL_BRANCH_CHAR=$'\u21b0'
fi
fi fi
if [[ -e "${repo_path}/BISECT_LOG" ]]; then if [[ -e "${repo_path}/BISECT_LOG" ]]; then
@ -149,6 +235,7 @@ prompt_git() {
zstyle ':vcs_info:*' actionformats ' %u%c' zstyle ':vcs_info:*' actionformats ' %u%c'
vcs_info vcs_info
echo -n "${${ref:gs/%/%%}/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}" echo -n "${${ref:gs/%/%%}/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
[[ $AGNOSTER_GIT_INLINE == 'true' ]] && prompt_git_relative
fi fi
} }
@ -168,12 +255,12 @@ prompt_bzr() {
status_all=$(echo -n "$bzr_status" | head -n1 | wc -m) status_all=$(echo -n "$bzr_status" | head -n1 | wc -m)
revision=${$(command bzr log -r-1 --log-format line | cut -d: -f1):gs/%/%%} revision=${$(command bzr log -r-1 --log-format line | cut -d: -f1):gs/%/%%}
if [[ $status_mod -gt 0 ]] ; then if [[ $status_mod -gt 0 ]] ; then
prompt_segment yellow black "bzr@$revision ✚" prompt_segment "$AGNOSTER_BZR_DIRTY_BG" "$AGNOSTER_BZR_DIRTY_FG" "bzr@$revision ✚"
else else
if [[ $status_all -gt 0 ]] ; then if [[ $status_all -gt 0 ]] ; then
prompt_segment yellow black "bzr@$revision" prompt_segment "$AGNOSTER_BZR_DIRTY_BG" "$AGNOSTER_BZR_DIRTY_FG" "bzr@$revision"
else else
prompt_segment green black "bzr@$revision" prompt_segment "$AGNOSTER_BZR_CLEAN_BG" "$AGNOSTER_BZR_CLEAN_FG" "bzr@$revision"
fi fi
fi fi
fi fi
@ -186,15 +273,15 @@ prompt_hg() {
if $(command hg prompt >/dev/null 2>&1); then if $(command hg prompt >/dev/null 2>&1); then
if [[ $(command hg prompt "{status|unknown}") = "?" ]]; then if [[ $(command hg prompt "{status|unknown}") = "?" ]]; then
# if files are not added # if files are not added
prompt_segment red white prompt_segment "$AGNOSTER_HG_NEWFILE_BG" "$AGNOSTER_HG_NEWFILE_FG"
st='±' st='±'
elif [[ -n $(command hg prompt "{status|modified}") ]]; then elif [[ -n $(command hg prompt "{status|modified}") ]]; then
# if any modification # if any modification
prompt_segment yellow black prompt_segment "$AGNOSTER_HG_CHANGED_BG" "$AGNOSTER_HG_CHANGED_FG"
st='±' st='±'
else else
# if working copy is clean # if working copy is clean
prompt_segment green $CURRENT_FG prompt_segment "$AGNOSTER_HG_CLEAN_BG" "$AGNOSTER_HG_CLEAN_FG"
fi fi
echo -n ${$(command hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st echo -n ${$(command hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st
else else
@ -202,13 +289,13 @@ prompt_hg() {
rev=$(command hg id -n 2>/dev/null | sed 's/[^-0-9]//g') rev=$(command hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
branch=$(command hg id -b 2>/dev/null) branch=$(command hg id -b 2>/dev/null)
if command hg st | command grep -q "^\?"; then if command hg st | command grep -q "^\?"; then
prompt_segment red black prompt_segment "$AGNOSTER_HG_NEWFILE_BG" "$AGNOSTER_HG_NEWFILE_FG"
st='±' st='±'
elif command hg st | command grep -q "^[MA]"; then elif command hg st | command grep -q "^[MA]"; then
prompt_segment yellow black prompt_segment "$AGNOSTER_HG_CHANGED_BG" "$AGNOSTER_HG_CHANGED_FG"
st='±' st='±'
else else
prompt_segment green $CURRENT_FG prompt_segment "$AGNOSTER_HG_CLEAN_BG" "$AGNOSTER_HG_CLEAN_FG"
fi fi
echo -n "☿ ${rev:gs/%/%%}@${branch:gs/%/%%}" $st echo -n "☿ ${rev:gs/%/%%}@${branch:gs/%/%%}" $st
fi fi
@ -217,13 +304,21 @@ prompt_hg() {
# Dir: current working directory # Dir: current working directory
prompt_dir() { prompt_dir() {
prompt_segment blue $CURRENT_FG '%~' if [[ $AGNOSTER_GIT_INLINE == 'true' ]] && $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
# Git repo and inline path enabled, hence only show the git root
prompt_segment "$AGNOSTER_DIR_BG" "$AGNOSTER_DIR_FG" "$(git_toplevel | sed "s:^$HOME:~:")"
else
prompt_segment "$AGNOSTER_DIR_BG" "$AGNOSTER_DIR_FG" '%~'
fi
} }
# Virtualenv: current working virtualenv # Virtualenv: current working virtualenv
prompt_virtualenv() { prompt_virtualenv() {
if [ -n "$CONDA_DEFAULT_ENV" ]; then
prompt_segment magenta $CURRENT_FG "🐍 $CONDA_DEFAULT_ENV"
fi
if [[ -n "$VIRTUAL_ENV" && -n "$VIRTUAL_ENV_DISABLE_PROMPT" ]]; then if [[ -n "$VIRTUAL_ENV" && -n "$VIRTUAL_ENV_DISABLE_PROMPT" ]]; then
prompt_segment blue black "(${VIRTUAL_ENV:t:gs/%/%%})" prompt_segment "$AGNOSTER_VENV_BG" "$AGNOSTER_VENV_FG" "(${VIRTUAL_ENV:t:gs/%/%%})"
fi fi
} }
@ -234,11 +329,15 @@ prompt_virtualenv() {
prompt_status() { prompt_status() {
local -a symbols local -a symbols
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" if [[ $AGNOSTER_STATUS_RETVAL_NUMERIC == 'true' ]]; then
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" [[ $RETVAL -ne 0 ]] && symbols+="%{%F{$AGNOSTER_STATUS_RETVAL_FG}%}$RETVAL"
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" else
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{$AGNOSTER_STATUS_RETVAL_FG}%}✘"
fi
[[ $UID -eq 0 ]] && symbols+="%{%F{$AGNOSTER_STATUS_ROOT_FG}%}⚡"
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{$AGNOSTER_STATUS_JOB_FG}%}⚙"
[[ -n "$symbols" ]] && prompt_segment black default "$symbols" [[ -n "$symbols" ]] && prompt_segment "$AGNOSTER_STATUS_BG" "$AGNOSTER_STATUS_FG" "$symbols"
} }
#AWS Profile: #AWS Profile:
@ -249,17 +348,24 @@ prompt_status() {
prompt_aws() { prompt_aws() {
[[ -z "$AWS_PROFILE" || "$SHOW_AWS_PROMPT" = false ]] && return [[ -z "$AWS_PROFILE" || "$SHOW_AWS_PROMPT" = false ]] && return
case "$AWS_PROFILE" in case "$AWS_PROFILE" in
*-prod|*production*) prompt_segment red yellow "AWS: ${AWS_PROFILE:gs/%/%%}" ;; *-prod|*production*) prompt_segment "$AGNOSTER_AWS_PROD_BG" "$AGNOSTER_AWS_PROD_FG" "AWS: ${AWS_PROFILE:gs/%/%%}" ;;
*) prompt_segment green black "AWS: ${AWS_PROFILE:gs/%/%%}" ;; *) prompt_segment "$AGNOSTER_AWS_BG" "$AGNOSTER_AWS_FG" "AWS: ${AWS_PROFILE:gs/%/%%}" ;;
esac esac
} }
prompt_terraform() {
local terraform_info=$(tf_prompt_info)
[[ -z "$terraform_info" ]] && return
prompt_segment magenta yellow "TF: $terraform_info"
}
## Main prompt ## Main prompt
build_prompt() { build_prompt() {
RETVAL=$? RETVAL=$?
prompt_status prompt_status
prompt_virtualenv prompt_virtualenv
prompt_aws prompt_aws
prompt_terraform
prompt_context prompt_context
prompt_dir prompt_dir
prompt_git prompt_git

View file

@ -11,11 +11,11 @@ function _prompt_char() {
# This theme works with both the "dark" and "light" variants of the # This theme works with both the "dark" and "light" variants of the
# Solarized color schema. Set the SOLARIZED_THEME variable to one of # Solarized color schema. Set the SOLARIZED_THEME variable to one of
# these two values to choose. If you don't specify, we'll assume you're # these two values to choose. If you don't specify, we'll assume you're
# using the "dark" variant. # using neither variant.
case ${SOLARIZED_THEME:-dark} in case ${SOLARIZED_THEME:-dark} in
light) bkg=white;; light) bkg=white;;
*) bkg=black;; *) bkg=default;;
esac esac
ZSH_THEME_GIT_PROMPT_PREFIX=" [%{%B%F{blue}%}" ZSH_THEME_GIT_PROMPT_PREFIX=" [%{%B%F{blue}%}"

12
themes/nicoulaj.zsh-theme Normal file → Executable file
View file

@ -12,12 +12,12 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Customizable parameters. # Customizable parameters.
PROMPT_PATH_MAX_LENGTH=30 PROMPT_PATH_MAX_LENGTH=${PROMPT_PATH_MAX_LENGTH:-30}
PROMPT_DEFAULT_END= PROMPT_DEFAULT_END=${PROMPT_DEFAULT_END:-}
PROMPT_ROOT_END= PROMPT_ROOT_END=${PROMPT_ROOT_END:-}
PROMPT_SUCCESS_COLOR=$FG[071] PROMPT_SUCCESS_COLOR=${PROMPT_SUCCESS_COLOR:-$FG[071]}
PROMPT_FAILURE_COLOR=$FG[124] PROMPT_FAILURE_COLOR=${PROMPT_FAILURE_COLOR:-$FG[124]}
PROMPT_VCS_INFO_COLOR=$FG[242] PROMPT_VCS_INFO_COLOR=${PROMPT_VCS_INFO_COLOR:-$FG[242]}
# Set required options. # Set required options.
setopt promptsubst setopt promptsubst

View file

@ -29,7 +29,7 @@ ZSH_THEME_GIT_PROMPT_SUFFIX="%{$GIT_PROMPT_INFO%} :"
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$GIT_DIRTY_COLOR%}✘" ZSH_THEME_GIT_PROMPT_DIRTY=" %{$GIT_DIRTY_COLOR%}✘"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$GIT_CLEAN_COLOR%}✔" ZSH_THEME_GIT_PROMPT_CLEAN=" %{$GIT_CLEAN_COLOR%}✔"
ZSH_THEME_GIT_PROMPT_ADDED="%{$FG[103]%}✚%{$rset_color%}" ZSH_THEME_GIT_PROMPT_ADDED="%{$FG[103]%}✚%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$FG[103]%}✹%{$reset_color%}" ZSH_THEME_GIT_PROMPT_MODIFIED="%{$FG[103]%}✹%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DELETED="%{$FG[103]%}✖%{$reset_color%}" ZSH_THEME_GIT_PROMPT_DELETED="%{$FG[103]%}✖%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_RENAMED="%{$FG[103]%}➜%{$reset_color%}" ZSH_THEME_GIT_PROMPT_RENAMED="%{$FG[103]%}➜%{$reset_color%}"

View file

@ -400,6 +400,9 @@ function display-release {
function display:breaking { function display:breaking {
(( $#breaking != 0 )) || return 0 (( $#breaking != 0 )) || return 0
# If we reach here we have shown commits, set flag
shown_commits=1
case "$output" in case "$output" in
text) printf '\e[31m'; fmt:header "BREAKING CHANGES" 3 ;; text) printf '\e[31m'; fmt:header "BREAKING CHANGES" 3 ;;
raw) fmt:header "BREAKING CHANGES" 3 ;; raw) fmt:header "BREAKING CHANGES" 3 ;;
@ -427,6 +430,9 @@ function display-release {
# If no commits found of type $type, go to next type # If no commits found of type $type, go to next type
(( $#hashes != 0 )) || return 0 (( $#hashes != 0 )) || return 0
# If we reach here we have shown commits, set flag
shown_commits=1
fmt:header "${TYPES[$type]}" 3 fmt:header "${TYPES[$type]}" 3
for hash in $hashes; do for hash in $hashes; do
echo " - $(fmt:hash) $(fmt:scope)$(fmt:subject)" echo " - $(fmt:hash) $(fmt:scope)$(fmt:subject)"
@ -444,6 +450,9 @@ function display-release {
# If no commits found under "other" types, don't display anything # If no commits found under "other" types, don't display anything
(( $#changes != 0 )) || return 0 (( $#changes != 0 )) || return 0
# If we reach here we have shown commits, set flag
shown_commits=1
fmt:header "Other changes" 3 fmt:header "Other changes" 3
for hash type in ${(kv)changes}; do for hash type in ${(kv)changes}; do
case "$type" in case "$type" in
@ -498,7 +507,7 @@ function main {
# Commit classification arrays # Commit classification arrays
local -A types subjects scopes breaking reverts local -A types subjects scopes breaking reverts
local truncate=0 read_commits=0 local truncate=0 read_commits=0 shown_commits=0
local version tag local version tag
local hash refs subject body local hash refs subject body
@ -569,6 +578,10 @@ function main {
echo " ...more commits omitted" echo " ...more commits omitted"
echo echo
fi fi
if (( ! shown_commits )); then
echo "No changes to mention."
fi
} }
# Use raw output if stdout is not a tty # Use raw output if stdout is not a tty

View file

@ -27,7 +27,7 @@ zstyle -s ':omz:update' mode update_mode || {
# - $ZSH is not a git repository # - $ZSH is not a git repository
if [[ "$update_mode" = disabled ]] \ if [[ "$update_mode" = disabled ]] \
|| [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \ || [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \
|| [[ ! -t 1 ]] \ || [[ ! -t 1 && ${POWERLEVEL9K_INSTANT_PROMPT:-off} == off ]] \
|| ! command git --version 2>&1 >/dev/null \ || ! command git --version 2>&1 >/dev/null \
|| (builtin cd -q "$ZSH"; ! command git rev-parse --is-inside-work-tree &>/dev/null); then || (builtin cd -q "$ZSH"; ! command git rev-parse --is-inside-work-tree &>/dev/null); then
unset update_mode unset update_mode
@ -112,6 +112,11 @@ function update_ohmyzsh() {
local verbose_mode local verbose_mode
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
# Force verbose mode to silent if p10k instant prompt is enabled
if [[ ${POWERLEVEL9K_INSTANT_PROMPT:-off} != "off" ]]; then
verbose_mode=silent
fi
if [[ "$update_mode" != background-alpha ]] \ if [[ "$update_mode" != background-alpha ]] \
&& LANG= ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode; then && LANG= ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode; then
update_last_updated_file update_last_updated_file

View file

@ -399,8 +399,8 @@ EOF
"$FMT_YELLOW" "$FMT_RESET" "$FMT_YELLOW" "$FMT_RESET"
read -r opt read -r opt
case $opt in case $opt in
y*|Y*|"") ;; [Yy]*|"") ;;
n*|N*) echo "Shell change skipped."; return ;; [Nn]*) echo "Shell change skipped."; return ;;
*) echo "Invalid choice. Shell change skipped."; return ;; *) echo "Invalid choice. Shell change skipped."; return ;;
esac esac

View file

@ -254,7 +254,7 @@ if LANG= git pull --quiet --rebase $remote $branch; then
# Print changelog to the terminal # Print changelog to the terminal
if [[ $interactive == true && $verbose_mode == default ]]; then if [[ $interactive == true && $verbose_mode == default ]]; then
"$ZSH/tools/changelog.sh" HEAD "$last_commit" ZSH="$ZSH" command zsh -f "$ZSH/tools/changelog.sh" HEAD "$last_commit"
fi fi
if [[ $verbose_mode != silent ]]; then if [[ $verbose_mode != silent ]]; then