mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-12-03 21:58:56 +01:00
Compare commits
44
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c184381d0 | ||
|
|
9f9b28a13d | ||
|
|
361fb5c1ac | ||
|
|
3d9b557be3 | ||
|
|
60c9a7a839 | ||
|
|
d745fbf3bd | ||
|
|
277993de0a | ||
|
|
4d4cfc287e | ||
|
|
92bf53f1ae | ||
|
|
5c4bb4aec5 | ||
|
|
868da9cfd5 | ||
|
|
83a0ec79ee | ||
|
|
c5852b1101 | ||
|
|
68795c2170 | ||
|
|
f809d46c10 | ||
|
|
0431f1c33d | ||
|
|
a3c88eba72 | ||
|
|
6881f37316 | ||
|
|
1d66682636 | ||
|
|
ce7f8c3224 | ||
|
|
f8e13d714e | ||
|
|
95ba6ae764 | ||
|
|
74965c9609 | ||
|
|
1b2d741f19 | ||
|
|
4ccc63333c | ||
|
|
40bddc3c1a | ||
|
|
8d421b6309 | ||
|
|
7d1b2a25ca | ||
|
|
86ef6555e0 | ||
|
|
32d7277ac3 | ||
|
|
e0d3557e14 | ||
|
|
b6830a53d5 | ||
|
|
fa82d8a3eb | ||
|
|
6421f8e104 | ||
|
|
0b50afdbfd | ||
|
|
157eb033f2 | ||
|
|
e7852049a5 | ||
|
|
7ce781ea37 | ||
|
|
def0f255c5 | ||
|
|
0ee67f0428 | ||
|
|
ec2901b7d0 | ||
|
|
1396cdd674 | ||
|
|
2ea948e05b | ||
|
|
6cd3a0baf6 |
No files matched your search
@@ -5,6 +5,7 @@ plugins/eza/ @pepoluan
|
|||||||
plugins/genpass/ @atoponce
|
plugins/genpass/ @atoponce
|
||||||
plugins/git-lfs/ @hellovietduc
|
plugins/git-lfs/ @hellovietduc
|
||||||
plugins/gitfast/ @felipec
|
plugins/gitfast/ @felipec
|
||||||
|
plugins/hermes/ @Uhm-why
|
||||||
plugins/kube-ps1/ @mcornella
|
plugins/kube-ps1/ @mcornella
|
||||||
plugins/kubectl/ @mcornella
|
plugins/kubectl/ @mcornella
|
||||||
plugins/kubectx/ @mcornella
|
plugins/kubectx/ @mcornella
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ dependencies:
|
|||||||
plugins/gradle:
|
plugins/gradle:
|
||||||
repo: gradle/gradle-completion
|
repo: gradle/gradle-completion
|
||||||
branch: master
|
branch: master
|
||||||
version: e7c881dbef7462bc35ad05328397e1582fe25cb8
|
version: 05693a01fcb246bc4e8fc32a8d561dc537aaedf2
|
||||||
precopy: |
|
precopy: |
|
||||||
set -e
|
set -e
|
||||||
find . ! -name _gradle ! -name LICENSE -delete
|
find . ! -name _gradle ! -name LICENSE -delete
|
||||||
plugins/history-substring-search:
|
plugins/history-substring-search:
|
||||||
repo: zsh-users/zsh-history-substring-search
|
repo: zsh-users/zsh-history-substring-search
|
||||||
branch: master
|
branch: master
|
||||||
version: 14c8d2e0ffaee98f2df9850b19944f32546fdea5
|
version: a0bdb0d47dbaba31dba2db7af8c48a5d9c74049a
|
||||||
precopy: |
|
precopy: |
|
||||||
set -e
|
set -e
|
||||||
rm -f zsh-history-substring-search.plugin.zsh
|
rm -f zsh-history-substring-search.plugin.zsh
|
||||||
@@ -30,7 +30,7 @@ dependencies:
|
|||||||
plugins/kube-ps1:
|
plugins/kube-ps1:
|
||||||
repo: jonmosco/kube-ps1
|
repo: jonmosco/kube-ps1
|
||||||
branch: master
|
branch: master
|
||||||
version: b4cd09ec8d4dc007173e28da40aeebf8eff8c87f
|
version: 7aaaeee5eaa29f920acd850ea63839d9f87b8ac5
|
||||||
precopy: |
|
precopy: |
|
||||||
set -e
|
set -e
|
||||||
find . ! -name kube-ps1.sh ! -name LICENSE ! -name README.md -delete
|
find . ! -name kube-ps1.sh ! -name LICENSE ! -name README.md -delete
|
||||||
@@ -46,7 +46,7 @@ dependencies:
|
|||||||
plugins/z:
|
plugins/z:
|
||||||
branch: master
|
branch: master
|
||||||
repo: agkozak/zsh-z
|
repo: agkozak/zsh-z
|
||||||
version: 102fb78036ed76feedf623907483691777a1d510
|
version: 7f8ff4df11b50a14e3666c7cd212baa399c9b92a
|
||||||
precopy: |
|
precopy: |
|
||||||
set -e
|
set -e
|
||||||
rm -r tests
|
rm -r tests
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
certifi==2026.7.22
|
certifi==2026.7.22
|
||||||
charset-normalizer==3.5.1
|
charset-normalizer==3.5.2
|
||||||
idna==3.19
|
idna==3.20
|
||||||
PyYAML==6.0.3
|
PyYAML==6.0.3
|
||||||
requests==2.34.2
|
requests==2.34.2
|
||||||
semver==3.0.4
|
semver==3.1.0
|
||||||
urllib3==2.7.0
|
urllib3==2.8.0
|
||||||
@@ -60,6 +60,6 @@ jobs:
|
|||||||
retention-days: 5
|
retention-days: 5
|
||||||
|
|
||||||
- name: "Upload to code-scanning"
|
- name: "Upload to code-scanning"
|
||||||
uses: github/codeql-action/upload-sarif@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
|
uses: github/codeql-action/upload-sarif@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
|
||||||
with:
|
with:
|
||||||
sarif_file: results.sarif
|
sarif_file: results.sarif
|
||||||
@@ -738,6 +738,9 @@ function _omz::reload {
|
|||||||
|
|
||||||
# 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]%:*}}"
|
||||||
|
# ZSH_ARGZERO is how zsh was invoked, not the path to it, so re-resolve
|
||||||
|
# anything that is not absolute via $PATH at exec time (see #13919)
|
||||||
|
[[ "${zsh#-}" != /* ]] && (( $+commands[zsh] )) && zsh="zsh"
|
||||||
# Check whether to run a login shell
|
# Check whether to run a login shell
|
||||||
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
||||||
}
|
}
|
||||||
@@ -919,6 +922,9 @@ function _omz::update {
|
|||||||
if [[ "$(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]%:*}}"
|
||||||
|
# ZSH_ARGZERO is how zsh was invoked, not the path to it, so re-resolve
|
||||||
|
# anything that is not absolute via $PATH at exec time (see #13919)
|
||||||
|
[[ "${zsh#-}" != /* ]] && (( $+commands[zsh] )) && zsh="zsh"
|
||||||
# Check whether to run a login shell
|
# Check whether to run a login shell
|
||||||
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
||||||
fi
|
fi
|
||||||
|
|||||||
+2
-1
@@ -178,7 +178,8 @@ function omz_urlencode() {
|
|||||||
setopt norematchpcre
|
setopt norematchpcre
|
||||||
|
|
||||||
local -a opts
|
local -a opts
|
||||||
zparseopts -D -E -a opts r m P
|
# Quote the specs so global aliases (e.g. common-aliases' P) don't expand here
|
||||||
|
zparseopts -D -E -a opts 'r' 'm' 'P'
|
||||||
|
|
||||||
local in_str="$@"
|
local in_str="$@"
|
||||||
local url_str=""
|
local url_str=""
|
||||||
|
|||||||
@@ -110,6 +110,23 @@ bindkey -M emacs '^[[1;5D' backward-word
|
|||||||
bindkey -M viins '^[[1;5D' backward-word
|
bindkey -M viins '^[[1;5D' backward-word
|
||||||
bindkey -M vicmd '^[[1;5D' backward-word
|
bindkey -M vicmd '^[[1;5D' backward-word
|
||||||
|
|
||||||
|
# [Keypad] - application mode (enabled above) makes the keypad send escape
|
||||||
|
# sequences instead of characters, so map them back to the plain keys
|
||||||
|
() {
|
||||||
|
local seq key
|
||||||
|
local -A keypad=(
|
||||||
|
'^[Op' '0' '^[Oq' '1' '^[Or' '2' '^[Os' '3' '^[Ot' '4'
|
||||||
|
'^[Ou' '5' '^[Ov' '6' '^[Ow' '7' '^[Ox' '8' '^[Oy' '9'
|
||||||
|
'^[On' '.' '^[Ol' ',' '^[Ok' '+' '^[Om' '-' '^[Oj' '*'
|
||||||
|
'^[Oo' '/' '^[OX' '=' '^[OM' '^M'
|
||||||
|
)
|
||||||
|
for seq key in "${(@kv)keypad}"; do
|
||||||
|
bindkey -M emacs -s "$seq" "$key"
|
||||||
|
bindkey -M viins -s "$seq" "$key"
|
||||||
|
bindkey -M vicmd -s "$seq" "$key"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark
|
bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark
|
||||||
bindkey -s '\el' '^q ls\n' # [Esc-l] - run command: ls
|
bindkey -s '\el' '^q ls\n' # [Esc-l] - run command: ls
|
||||||
|
|||||||
@@ -13,69 +13,92 @@ ZSH_THEME_RUBY_PROMPT_PREFIX="("
|
|||||||
ZSH_THEME_RUBY_PROMPT_SUFFIX=")"
|
ZSH_THEME_RUBY_PROMPT_SUFFIX=")"
|
||||||
|
|
||||||
|
|
||||||
|
# The command probes below fork a process each, and their result doesn't change
|
||||||
|
# from one shell to the next, so they're cached for a day (like lib/grep.zsh).
|
||||||
|
typeset -A __omz_probes
|
||||||
|
__omz_probe_cache="$ZSH_CACHE_DIR/appearance-probes"
|
||||||
|
__omz_probe_cached=("$__omz_probe_cache"(Nm-1))
|
||||||
|
[[ -z "$__omz_probe_cached" ]] || source "$__omz_probe_cache"
|
||||||
|
|
||||||
|
function __omz_test_cmd_args {
|
||||||
|
# Usage: __omz_test_cmd_args cmd args...
|
||||||
|
# Runs `cmd args... /dev/null` and remembers whether it succeeded, so a
|
||||||
|
# command needing two operands passes the first one itself:
|
||||||
|
# e.g. __omz_test_cmd_args gls --color -> gls --color /dev/null
|
||||||
|
# __omz_test_cmd_args diff --color /dev/null -> diff --color /dev/null /dev/null
|
||||||
|
local key="$*"
|
||||||
|
if (( ! ${+__omz_probes[$key]} )); then
|
||||||
|
command "$@" /dev/null &>/dev/null
|
||||||
|
__omz_probes[$key]=$?
|
||||||
|
if [[ -w "$ZSH_CACHE_DIR" ]]; then
|
||||||
|
print -r -- "__omz_probes=(" "${(@qqkv)__omz_probes}" ")" >| "$__omz_probe_cache"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
return $__omz_probes[$key]
|
||||||
|
}
|
||||||
|
|
||||||
# Use diff --color if available
|
# Use diff --color if available
|
||||||
if command diff --color /dev/null{,} &>/dev/null; then
|
if __omz_test_cmd_args diff --color /dev/null; then
|
||||||
function diff {
|
function diff {
|
||||||
command diff --color "$@"
|
command diff --color "$@"
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Don't set ls coloring if disabled
|
# Set up ls coloring. Done in a function so the early return below still
|
||||||
[[ "$DISABLE_LS_COLORS" != true ]] || return 0
|
# reaches the cleanup at the end of this file.
|
||||||
|
() {
|
||||||
|
# Don't set ls coloring if disabled
|
||||||
|
[[ "$DISABLE_LS_COLORS" != true ]] || return 0
|
||||||
|
|
||||||
# Default coloring for BSD-based ls
|
# Default coloring for BSD-based ls
|
||||||
export LSCOLORS="Gxfxcxdxbxegedabagacad"
|
export LSCOLORS="Gxfxcxdxbxegedabagacad"
|
||||||
|
|
||||||
# Default coloring for GNU-based ls
|
# Default coloring for GNU-based ls
|
||||||
if [[ -z "$LS_COLORS" ]]; then
|
if [[ -z "$LS_COLORS" ]]; then
|
||||||
# Define LS_COLORS via dircolors if available. Otherwise, set a default
|
# Define LS_COLORS via dircolors if available. Otherwise, set a default
|
||||||
# equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
|
# equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
|
||||||
if (( $+commands[dircolors] )); then
|
if (( $+commands[dircolors] )); then
|
||||||
[[ -f "$HOME/.dircolors" ]] \
|
[[ -f "$HOME/.dircolors" ]] \
|
||||||
&& source <(dircolors -b "$HOME/.dircolors") \
|
&& source <(dircolors -b "$HOME/.dircolors") \
|
||||||
|| source <(dircolors -b)
|
|| source <(dircolors -b)
|
||||||
else
|
else
|
||||||
export LS_COLORS="di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"
|
export LS_COLORS="di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
function test-ls-args {
|
# Find the option for using colors in ls, depending on the version
|
||||||
# Usage: test-ls-args cmd args...
|
case "$OSTYPE" in
|
||||||
# e.g. test-ls-args gls --color
|
netbsd*)
|
||||||
command "$@" /dev/null &>/dev/null
|
# On NetBSD, test if `gls` (GNU ls) is installed (this one supports colors);
|
||||||
|
# otherwise, leave ls as is, because NetBSD's ls doesn't support -G
|
||||||
|
__omz_test_cmd_args gls --color && alias ls='gls --color=tty'
|
||||||
|
;;
|
||||||
|
openbsd*)
|
||||||
|
# On OpenBSD, `gls` (ls from GNU coreutils) and `colorls` (ls from base,
|
||||||
|
# with color and multibyte support) are available from ports.
|
||||||
|
# `colorls` will be installed on purpose and can't be pulled in by installing
|
||||||
|
# coreutils (which might be installed for ), so prefer it to `gls`.
|
||||||
|
__omz_test_cmd_args gls --color && alias ls='gls --color=tty'
|
||||||
|
__omz_test_cmd_args colorls -G && alias ls='colorls -G'
|
||||||
|
;;
|
||||||
|
(darwin|freebsd)*)
|
||||||
|
# This alias works by default just using $LSCOLORS
|
||||||
|
__omz_test_cmd_args ls -G && alias ls='ls -G'
|
||||||
|
# Only use GNU ls if installed and there are user defaults for $LS_COLORS,
|
||||||
|
# as the default coloring scheme is not very pretty
|
||||||
|
zstyle -t ':omz:lib:theme-and-appearance' gnu-ls \
|
||||||
|
&& __omz_test_cmd_args gls --color \
|
||||||
|
&& alias ls='gls --color=tty'
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if __omz_test_cmd_args ls --color; then
|
||||||
|
alias ls='ls --color=tty'
|
||||||
|
elif __omz_test_cmd_args ls -G; then
|
||||||
|
alias ls='ls -G'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Find the option for using colors in ls, depending on the version
|
unfunction __omz_test_cmd_args
|
||||||
case "$OSTYPE" in
|
unset __omz_probes __omz_probe_cache __omz_probe_cached
|
||||||
netbsd*)
|
|
||||||
# On NetBSD, test if `gls` (GNU ls) is installed (this one supports colors);
|
|
||||||
# otherwise, leave ls as is, because NetBSD's ls doesn't support -G
|
|
||||||
test-ls-args gls --color && alias ls='gls --color=tty'
|
|
||||||
;;
|
|
||||||
openbsd*)
|
|
||||||
# On OpenBSD, `gls` (ls from GNU coreutils) and `colorls` (ls from base,
|
|
||||||
# with color and multibyte support) are available from ports.
|
|
||||||
# `colorls` will be installed on purpose and can't be pulled in by installing
|
|
||||||
# coreutils (which might be installed for ), so prefer it to `gls`.
|
|
||||||
test-ls-args gls --color && alias ls='gls --color=tty'
|
|
||||||
test-ls-args colorls -G && alias ls='colorls -G'
|
|
||||||
;;
|
|
||||||
(darwin|freebsd)*)
|
|
||||||
# This alias works by default just using $LSCOLORS
|
|
||||||
test-ls-args ls -G && alias ls='ls -G'
|
|
||||||
# Only use GNU ls if installed and there are user defaults for $LS_COLORS,
|
|
||||||
# as the default coloring scheme is not very pretty
|
|
||||||
zstyle -t ':omz:lib:theme-and-appearance' gnu-ls \
|
|
||||||
&& test-ls-args gls --color \
|
|
||||||
&& alias ls='gls --color=tty'
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if test-ls-args ls --color; then
|
|
||||||
alias ls='ls --color=tty'
|
|
||||||
elif test-ls-args ls -G; then
|
|
||||||
alias ls='ls -G'
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
unfunction test-ls-args
|
|
||||||
+104
-3
@@ -100,7 +100,28 @@ done
|
|||||||
# Figure out the SHORT hostname
|
# Figure out the SHORT hostname
|
||||||
if [[ "$OSTYPE" = darwin* ]]; then
|
if [[ "$OSTYPE" = darwin* ]]; then
|
||||||
# macOS's $HOST changes with dhcp, etc. Use LocalHostName if possible.
|
# macOS's $HOST changes with dhcp, etc. Use LocalHostName if possible.
|
||||||
SHORT_HOST=$(scutil --get LocalHostName 2>/dev/null) || SHORT_HOST="${HOST/.*/}"
|
# scutil costs a fork on every start, so remember its answer for a day
|
||||||
|
# (like lib/grep.zsh) and re-check sooner if $HOST changes.
|
||||||
|
__omz_host_cache="$ZSH_CACHE_DIR/localhostname"
|
||||||
|
__omz_host_cached=("$__omz_host_cache"(Nm-1))
|
||||||
|
__omz_host_key=
|
||||||
|
SHORT_HOST=
|
||||||
|
if [[ -n "$__omz_host_cached" ]]; then
|
||||||
|
if ! { read -r __omz_host_key && read -r SHORT_HOST } < "$__omz_host_cache"; then
|
||||||
|
__omz_host_key=
|
||||||
|
SHORT_HOST=
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ "$__omz_host_key" != "$HOST" || -z "$SHORT_HOST" ]]; then
|
||||||
|
# only cache what scutil actually answered, so a transient failure
|
||||||
|
# doesn't pin the fallback name for a day
|
||||||
|
if SHORT_HOST=$(scutil --get LocalHostName 2>/dev/null) && [[ -n "$SHORT_HOST" ]]; then
|
||||||
|
[[ ! -w "$ZSH_CACHE_DIR" ]] || print -rl -- "$HOST" "$SHORT_HOST" >| "$__omz_host_cache"
|
||||||
|
else
|
||||||
|
SHORT_HOST="${HOST/.*/}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
unset __omz_host_cache __omz_host_cached __omz_host_key
|
||||||
else
|
else
|
||||||
SHORT_HOST="${HOST/.*/}"
|
SHORT_HOST="${HOST/.*/}"
|
||||||
fi
|
fi
|
||||||
@@ -110,9 +131,89 @@ if [[ -z "$ZSH_COMPDUMP" ]]; then
|
|||||||
ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
|
ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Construct zcompdump OMZ metadata
|
# Resolve the commit $ZSH is checked out at into $REPLY by reading the git
|
||||||
zcompdump_revision="#omz revision: $(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)"
|
# directory, so that no git process is forked on every startup.
|
||||||
|
# Handles .git files (worktrees, submodules), worktree common dirs, detached
|
||||||
|
# HEADs and packed refs. Returns 1 if anything is unexpected.
|
||||||
|
_omz_git_head() {
|
||||||
|
local gitdir="$ZSH/.git" common head ref
|
||||||
|
local -a lines
|
||||||
|
REPLY=
|
||||||
|
|
||||||
|
# .git may be a file pointing at the real git dir
|
||||||
|
if [[ -f "$gitdir" ]]; then
|
||||||
|
read -r head 2>/dev/null < "$gitdir" || return 1
|
||||||
|
[[ "$head" = "gitdir: "* ]] || return 1
|
||||||
|
gitdir="${head#gitdir: }"
|
||||||
|
[[ -n "$gitdir" ]] || return 1
|
||||||
|
[[ "$gitdir" = /* ]] || gitdir="$ZSH/$gitdir"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# worktrees keep their refs in the common git dir
|
||||||
|
common="$gitdir"
|
||||||
|
if [[ -f "$gitdir/commondir" ]]; then
|
||||||
|
read -r common 2>/dev/null < "$gitdir/commondir" || return 1
|
||||||
|
[[ "$common" = /* ]] || common="$gitdir/$common"
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ -r "$gitdir/HEAD" ]] || return 1
|
||||||
|
read -r head 2>/dev/null < "$gitdir/HEAD" || return 1
|
||||||
|
|
||||||
|
if [[ "$head" = ref:\ * ]]; then
|
||||||
|
ref="${head#ref: }"
|
||||||
|
|
||||||
|
# Only use well-formed full ref names as paths. Besides matching Git's ref
|
||||||
|
# rules, this prevents a malformed HEAD from escaping the git directory.
|
||||||
|
[[ "$ref" = refs/?* \
|
||||||
|
&& "$ref" != *..* \
|
||||||
|
&& "$ref" != *//* \
|
||||||
|
&& "$ref" != */ \
|
||||||
|
&& "$ref" != */.* \
|
||||||
|
&& "$ref" != *.lock \
|
||||||
|
&& "$ref" != *.lock/* \
|
||||||
|
&& "$ref" != *. \
|
||||||
|
&& "$ref" != *'@{'* \
|
||||||
|
&& "$ref" != *[[:cntrl:]\ \~\^\:\?\*\[\\]* \
|
||||||
|
]] || return 1
|
||||||
|
|
||||||
|
case "$ref" in
|
||||||
|
# These namespaces are private to each worktree and are never resolved
|
||||||
|
# from the common directory or its packed-refs file.
|
||||||
|
refs/bisect/*|refs/worktree/*|refs/rewritten/*)
|
||||||
|
[[ -r "$gitdir/$ref" ]] || return 1
|
||||||
|
read -r REPLY 2>/dev/null < "$gitdir/$ref" || return 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [[ -r "$common/$ref" ]]; then
|
||||||
|
read -r REPLY 2>/dev/null < "$common/$ref" || return 1
|
||||||
|
elif [[ -r "$common/packed-refs" ]]; then
|
||||||
|
lines=("${(@f)$(<"$common/packed-refs")}")
|
||||||
|
REPLY="${lines[(r)* ${(b)ref}]%% *}"
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
# detached HEAD: the file holds the commit itself
|
||||||
|
REPLY="$head"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# only an object ID is a usable answer: a symbolic ref, a malformed file or
|
||||||
|
# a missed packed entry all fall through to the git fallback instead
|
||||||
|
[[ -n "$REPLY" && -z "${REPLY//[0-9a-f]/}" ]] \
|
||||||
|
&& (( ${#REPLY} == 40 || ${#REPLY} == 64 ))
|
||||||
|
}
|
||||||
|
|
||||||
|
# Construct zcompdump OMZ metadata. The helper reports through $REPLY, so
|
||||||
|
# call it in a scope that keeps that out of the global namespace.
|
||||||
|
() {
|
||||||
|
local REPLY
|
||||||
|
_omz_git_head || REPLY="$(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)"
|
||||||
|
typeset -g zcompdump_revision="#omz revision: $REPLY"
|
||||||
|
}
|
||||||
zcompdump_fpath="#omz fpath: $fpath"
|
zcompdump_fpath="#omz fpath: $fpath"
|
||||||
|
unset -f _omz_git_head
|
||||||
|
|
||||||
# Check whether the zcompdump file carries the current OMZ metadata lines
|
# Check whether the zcompdump file carries the current OMZ metadata lines
|
||||||
_omz_compdump_has_metadata() {
|
_omz_compdump_has_metadata() {
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_op"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._op"
|
||||||
zf_mv -f -- =( op completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( op completion zsh ) "$ZSH_CACHE_DIR/completions/_op"
|
||||||
} &|
|
} &|
|
||||||
|
|
||||||
# Load opswd function
|
# Load opswd function
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
# Generate and load arduino-cli completion
|
# Generate and load arduino-cli completion
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_arduino-cli"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._arduino-cli"
|
||||||
zf_mv -f -- =( arduino-cli completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( arduino-cli completion zsh ) "$ZSH_CACHE_DIR/completions/_arduino-cli"
|
||||||
} &|
|
} &|
|
||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_argocd"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._argocd"
|
||||||
zf_mv -f -- =( argocd completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( argocd completion zsh ) "$ZSH_CACHE_DIR/completions/_argocd"
|
||||||
} &|
|
} &|
|
||||||
@@ -14,6 +14,6 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_asdf" ]]; then
|
|||||||
fi
|
fi
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_asdf"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._asdf"
|
||||||
zf_mv -f -- =( asdf completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( asdf completion zsh ) "$ZSH_CACHE_DIR/completions/_asdf"
|
||||||
} &|
|
} &|
|
||||||
@@ -25,10 +25,10 @@ if [[ "$OSTYPE" = darwin* ]]; then
|
|||||||
echo "$(ioreg -rc AppleSmartBattery | grep -o '"Watts"=[0-9]\+' | head -1 | grep -o '[0-9]\+')W "
|
echo "$(ioreg -rc AppleSmartBattery | grep -o '"Watts"=[0-9]\+' | head -1 | grep -o '[0-9]\+')W "
|
||||||
}
|
}
|
||||||
function battery_is_charging() {
|
function battery_is_charging() {
|
||||||
ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
|
ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected" = Yes'
|
||||||
}
|
}
|
||||||
function battery_pct() {
|
function battery_pct() {
|
||||||
pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
|
pmset -g batt | grep -Eo "[0-9]+%" | cut -d% -f1
|
||||||
}
|
}
|
||||||
function battery_pct_remaining() {
|
function battery_pct_remaining() {
|
||||||
if battery_is_charging; then
|
if battery_is_charging; then
|
||||||
@@ -39,8 +39,8 @@ if [[ "$OSTYPE" = darwin* ]]; then
|
|||||||
}
|
}
|
||||||
function battery_time_remaining() {
|
function battery_time_remaining() {
|
||||||
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
|
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
|
||||||
if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
|
if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected" = No') -eq 1 ]]; then
|
||||||
timeremaining=$(echo $smart_battery_status | command grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
|
timeremaining=$(echo $smart_battery_status | command grep '^.*"AvgTimeToEmpty" = ' | sed -e 's/^.*"AvgTimeToEmpty" = //')
|
||||||
if [ $timeremaining -gt 720 ]; then
|
if [ $timeremaining -gt 720 ]; then
|
||||||
echo "::"
|
echo "::"
|
||||||
else
|
else
|
||||||
@@ -52,7 +52,7 @@ if [[ "$OSTYPE" = darwin* ]]; then
|
|||||||
}
|
}
|
||||||
function battery_pct_prompt () {
|
function battery_pct_prompt () {
|
||||||
local battery_pct color
|
local battery_pct color
|
||||||
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
|
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected" = No'; then
|
||||||
battery_pct=$(battery_pct_remaining)
|
battery_pct=$(battery_pct_remaining)
|
||||||
if [[ $battery_pct -gt 50 ]]; then
|
if [[ $battery_pct -gt 50 ]]; then
|
||||||
color='green'
|
color='green'
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
# Generate and load buf completion
|
# Generate and load buf completion
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_buf"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._buf"
|
||||||
zf_mv -f -- =( buf completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( buf completion zsh ) "$ZSH_CACHE_DIR/completions/_buf"
|
||||||
} &|
|
} &|
|
||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_bun"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._bun"
|
||||||
zf_mv -f -- =( SHELL=zsh bun completions ) "$TMPPREFIX"
|
zf_mv -f -- =( SHELL=zsh bun completions ) "$ZSH_CACHE_DIR/completions/_bun"
|
||||||
} &|
|
} &|
|
||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_charm"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._charm"
|
||||||
zf_mv -f -- =( charm completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( charm completion zsh ) "$ZSH_CACHE_DIR/completions/_charm"
|
||||||
} &|
|
} &|
|
||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_chezmoi"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._chezmoi"
|
||||||
zf_mv -f -- =( chezmoi completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( chezmoi completion zsh ) "$ZSH_CACHE_DIR/completions/_chezmoi"
|
||||||
} &|
|
} &|
|
||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_codex"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._codex"
|
||||||
zf_mv -f -- =( codex completion zsh < /dev/null 2> /dev/null ) "$TMPPREFIX"
|
zf_mv -f -- =( codex completion zsh < /dev/null 2> /dev/null ) "$ZSH_CACHE_DIR/completions/_codex"
|
||||||
} &|
|
} &|
|
||||||
@@ -27,6 +27,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_deno"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._deno"
|
||||||
zf_mv -f -- =( deno completions zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( deno completions zsh ) "$ZSH_CACHE_DIR/completions/_deno"
|
||||||
} &|
|
} &|
|
||||||
@@ -17,7 +17,7 @@ plugins=(... docker-compose)
|
|||||||
|-----------|----------------------------------|----------------------------------------------------------------------------------|
|
|-----------|----------------------------------|----------------------------------------------------------------------------------|
|
||||||
| dco | `docker-compose` | Docker-compose main command |
|
| dco | `docker-compose` | Docker-compose main command |
|
||||||
| dcb | `docker-compose build` | Build containers |
|
| dcb | `docker-compose build` | Build containers |
|
||||||
| dcc | `docker-compose config` | Parse, resolve and render compose file in canonical format |
|
| dcc | `docker-compose config` | Parse, resolve and render compose file in canonical format |
|
||||||
| dce | `docker-compose exec` | Execute command inside a container |
|
| dce | `docker-compose exec` | Execute command inside a container |
|
||||||
| dcps | `docker-compose ps` | List containers |
|
| dcps | `docker-compose ps` | List containers |
|
||||||
| dcrestart | `docker-compose restart` | Restart container |
|
| dcrestart | `docker-compose restart` | Restart container |
|
||||||
@@ -35,3 +35,6 @@ plugins=(... docker-compose)
|
|||||||
| dcpull | `docker-compose pull` | Pull image of a service |
|
| dcpull | `docker-compose pull` | Pull image of a service |
|
||||||
| dcstart | `docker-compose start` | Start a container |
|
| dcstart | `docker-compose start` | Start a container |
|
||||||
| dck | `docker-compose kill` | Kills containers |
|
| dck | `docker-compose kill` | Kills containers |
|
||||||
|
| dcv | `docker-compose version` | Show version information |
|
||||||
|
| dcsts | `docker-compose stats` | Show stats of containers |
|
||||||
|
| dci | `docker-compose images` | List images |
|
||||||
@@ -24,5 +24,8 @@ alias dclF="$dccmd logs -f --tail 0"
|
|||||||
alias dcpull="$dccmd pull"
|
alias dcpull="$dccmd pull"
|
||||||
alias dcstart="$dccmd start"
|
alias dcstart="$dccmd start"
|
||||||
alias dck="$dccmd kill"
|
alias dck="$dccmd kill"
|
||||||
|
alias dcv="$dccmd version"
|
||||||
|
alias dcsts="$dccmd stats"
|
||||||
|
alias dci="$dccmd images"
|
||||||
|
|
||||||
unset dccmd
|
unset dccmd
|
||||||
@@ -68,7 +68,7 @@ zmodload -F zsh/files b:zf_mv
|
|||||||
! is-at-least 23.0.0 ${${(s:,:z)"$(command docker --version)"}[3]}; then
|
! is-at-least 23.0.0 ${${(s:,:z)"$(command docker --version)"}[3]}; then
|
||||||
command cp "${plugin_dir}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
|
command cp "${plugin_dir}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
|
||||||
else
|
else
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_docker"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._docker"
|
||||||
zf_mv -f -- =( command docker completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( command docker completion zsh ) "$ZSH_CACHE_DIR/completions/_docker"
|
||||||
fi
|
fi
|
||||||
} "${0:A:h}" &|
|
} "${0:A:h}" &|
|
||||||
@@ -16,6 +16,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_doctl"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._doctl"
|
||||||
zf_mv -f -- =( doctl completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( doctl completion zsh ) "$ZSH_CACHE_DIR/completions/_doctl"
|
||||||
} &|
|
} &|
|
||||||
@@ -35,7 +35,9 @@ 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" ]] && [[ "$INSIDE_EMACS" != "vterm" ]]; then
|
local excluded_terms=(vterm ghostel)
|
||||||
|
local current_term="${INSIDE_EMACS%%,*}"
|
||||||
|
if [[ -n "$INSIDE_EMACS" ]] && (( ! ${excluded_terms[(Ie)$current_term]} )); 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
|
||||||
|
|||||||
@@ -32,8 +32,9 @@ emacsfun() {
|
|||||||
# Check if there are suitable frames
|
# Check if there are suitable frames
|
||||||
frames="$(emacsclient -a '' -n -e "$cmd" 2>/dev/null |sed 's/.*\x07//g' )"
|
frames="$(emacsclient -a '' -n -e "$cmd" 2>/dev/null |sed 's/.*\x07//g' )"
|
||||||
|
|
||||||
# Only create another X frame if there isn't one present
|
# A bare emacs/e passes only --no-wait, so it still needs --create-frame.
|
||||||
if [ -z "$frames" -o "$frames" = nil ]; then
|
if [ -z "$frames" ] || [ "$frames" = nil ] || [ "$#" -eq 0 ] \
|
||||||
|
|| { [ "$#" -eq 1 ] && [ "$1" = --no-wait ]; }; then
|
||||||
emacsclient --alternate-editor="" --create-frame "$@"
|
emacsclient --alternate-editor="" --create-frame "$@"
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -119,7 +119,17 @@ EOF
|
|||||||
fi ;;
|
fi ;;
|
||||||
(*.rpm)
|
(*.rpm)
|
||||||
rpm2cpio "$full_path" | cpio --quiet -id ;;
|
rpm2cpio "$full_path" | cpio --quiet -id ;;
|
||||||
(*.7z | *.7z.[0-9]* | *.pk7) 7za x "$full_path" ;;
|
(*.7z | *.7z.[0-9]* | *.pk7)
|
||||||
|
if (( $+commands[7zz] )); then
|
||||||
|
7zz x "$full_path"
|
||||||
|
elif (( $+commands[7z] )); then
|
||||||
|
7z x "$full_path"
|
||||||
|
elif (( $+commands[7za] )); then
|
||||||
|
7za x "$full_path"
|
||||||
|
else
|
||||||
|
echo "extract: cannot extract 7z files: install 7zz, 7z or 7za" >&2
|
||||||
|
success=1
|
||||||
|
fi ;;
|
||||||
(*.deb)
|
(*.deb)
|
||||||
command mkdir -p "control" "data"
|
command mkdir -p "control" "data"
|
||||||
ar vx "$full_path" > /dev/null
|
ar vx "$full_path" > /dev/null
|
||||||
|
|||||||
@@ -45,6 +45,36 @@ If `yes`, always add `-h` flag to add a header row for each column.
|
|||||||
|
|
||||||
Default: `no`
|
Default: `no`
|
||||||
|
|
||||||
|
### `links`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'links' yes|no
|
||||||
|
```
|
||||||
|
|
||||||
|
If `yes`, always add `-H` flag to show hard links for each file.
|
||||||
|
|
||||||
|
Default: `no`
|
||||||
|
|
||||||
|
### `octal`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'octal' yes|no
|
||||||
|
```
|
||||||
|
|
||||||
|
If `yes`, always add `-o` flag to show file permissions as octal numbers.
|
||||||
|
|
||||||
|
Default: `no`
|
||||||
|
|
||||||
|
### `inodes`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'inodes' yes|no
|
||||||
|
```
|
||||||
|
|
||||||
|
If `yes`, always add `-i` flag to show the inode for each file.
|
||||||
|
|
||||||
|
Default: `no`
|
||||||
|
|
||||||
### `show-group`
|
### `show-group`
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
|
|||||||
@@ -21,6 +21,15 @@ function _configure_eza() {
|
|||||||
if zstyle -t ':omz:plugins:eza' 'header'; then
|
if zstyle -t ':omz:plugins:eza' 'header'; then
|
||||||
_EZA_HEAD+=("h")
|
_EZA_HEAD+=("h")
|
||||||
fi
|
fi
|
||||||
|
if zstyle -t ':omz:plugins:eza' 'links'; then
|
||||||
|
_EZA_HEAD+=("H")
|
||||||
|
fi
|
||||||
|
if zstyle -t ':omz:plugins:eza' 'octal'; then
|
||||||
|
_EZA_HEAD+=("o")
|
||||||
|
fi
|
||||||
|
if zstyle -t ':omz:plugins:eza' 'inodes'; then
|
||||||
|
_EZA_HEAD+=("i")
|
||||||
|
fi
|
||||||
zstyle -s ':omz:plugins:eza' 'size-prefix' _val
|
zstyle -s ':omz:plugins:eza' 'size-prefix' _val
|
||||||
case "${_val:l}" in
|
case "${_val:l}" in
|
||||||
binary)
|
binary)
|
||||||
|
|||||||
@@ -32,6 +32,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_flutter"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._flutter"
|
||||||
zf_mv -f -- =( flutter zsh-completion < /dev/null ) "$TMPPREFIX"
|
zf_mv -f -- =( flutter zsh-completion < /dev/null ) "$ZSH_CACHE_DIR/completions/_flutter"
|
||||||
} &|
|
} &|
|
||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_flux"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._flux"
|
||||||
zf_mv -f -- =( flux completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( flux completion zsh ) "$ZSH_CACHE_DIR/completions/_flux"
|
||||||
} &|
|
} &|
|
||||||
@@ -12,8 +12,8 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_fnm"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._fnm"
|
||||||
zf_mv -f -- =( fnm completions --shell=zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( fnm completions --shell=zsh ) "$ZSH_CACHE_DIR/completions/_fnm"
|
||||||
} &|
|
} &|
|
||||||
|
|
||||||
if zstyle -t ':omz:plugins:fnm' autostart; then
|
if zstyle -t ':omz:plugins:fnm' autostart; then
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ function frontend() {
|
|||||||
codepen 'https://codepen.io/search/pens?q='
|
codepen 'https://codepen.io/search/pens?q='
|
||||||
compassdoc 'http://compass-style.org/search?q='
|
compassdoc 'http://compass-style.org/search?q='
|
||||||
cssflow 'http://www.cssflow.com/search?q='
|
cssflow 'http://www.cssflow.com/search?q='
|
||||||
dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
|
dartlang $(_frontend_fallback 'dart.dev')
|
||||||
emberjs $(_frontend_fallback 'emberjs.com/')
|
emberjs $(_frontend_fallback 'emberjs.com/')
|
||||||
flowtype $(_frontend_fallback 'flow.org/en/docs/')
|
flowtype $(_frontend_fallback 'flow.org/en/docs/')
|
||||||
fontello 'http://fontello.com/#search='
|
fontello 'http://fontello.com/#search='
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_gcx"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._gcx"
|
||||||
zf_mv -f -- =( gcx completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( gcx completion zsh ) "$ZSH_CACHE_DIR/completions/_gcx"
|
||||||
} &|
|
} &|
|
||||||
@@ -17,7 +17,4 @@ plugin is loaded, which is usually when you start up a new terminal emulator.
|
|||||||
|
|
||||||
The cache is stored at:
|
The cache is stored at:
|
||||||
|
|
||||||
- `$ZSH/plugins/gh/_gh` completions script
|
- `$ZSH_CACHE_DIR/completions/_gh` completions script
|
||||||
|
|
||||||
- `$ZSH_CACHE_DIR/gh_version` version of GitHub CLI, used to invalidate
|
|
||||||
the cache.
|
|
||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_gh"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._gh"
|
||||||
zf_mv -f -- =( gh completion --shell zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( gh completion --shell zsh ) "$ZSH_CACHE_DIR/completions/_gh"
|
||||||
} &|
|
} &|
|
||||||
@@ -108,6 +108,7 @@ plugins=(... git)
|
|||||||
| `glo` | `git log --oneline --decorate` |
|
| `glo` | `git log --oneline --decorate` |
|
||||||
| `glog` | `git log --oneline --decorate --graph` |
|
| `glog` | `git log --oneline --decorate --graph` |
|
||||||
| `gloga` | `git log --oneline --decorate --graph --all` |
|
| `gloga` | `git log --oneline --decorate --graph --all` |
|
||||||
|
| `glom` | `git log --oneline --decorate --color $(git_main_branch)..` |
|
||||||
| `glp` | `git log --pretty=<format>` |
|
| `glp` | `git log --pretty=<format>` |
|
||||||
| `glg` | `git log --stat` |
|
| `glg` | `git log --stat` |
|
||||||
| `glgp` | `git log --stat --patch` |
|
| `glgp` | `git log --stat --patch` |
|
||||||
@@ -155,6 +156,8 @@ plugins=(... git)
|
|||||||
| `grba` | `git rebase --abort` |
|
| `grba` | `git rebase --abort` |
|
||||||
| `grbc` | `git rebase --continue` |
|
| `grbc` | `git rebase --continue` |
|
||||||
| `grbi` | `git rebase --interactive` |
|
| `grbi` | `git rebase --interactive` |
|
||||||
|
| `grbmi` | `git rebase $(git_main_branch) --interactive` |
|
||||||
|
| `grbmia` | `git rebase $(git_main_branch) --interactive --autosquash` |
|
||||||
| `grbo` | `git rebase --onto` |
|
| `grbo` | `git rebase --onto` |
|
||||||
| `grbs` | `git rebase --skip` |
|
| `grbs` | `git rebase --skip` |
|
||||||
| `grbd` | `git rebase $(git_develop_branch)` |
|
| `grbd` | `git rebase $(git_develop_branch)` |
|
||||||
@@ -202,8 +205,10 @@ plugins=(... git)
|
|||||||
| `gst` | `git status` |
|
| `gst` | `git status` |
|
||||||
| `gss` | `git status --short` |
|
| `gss` | `git status --short` |
|
||||||
| `gsb` | `git status --short -b` |
|
| `gsb` | `git status --short -b` |
|
||||||
|
| `gsnut` | `git status --untracked-files=no` |
|
||||||
| `gsi` | `git submodule init` |
|
| `gsi` | `git submodule init` |
|
||||||
| `gsu` | `git submodule update` |
|
| `gsu` | `git submodule update` |
|
||||||
|
| `gsuri` | `git submodule update --recursive --init` |
|
||||||
| `gsd` | `git svn dcommit` |
|
| `gsd` | `git svn dcommit` |
|
||||||
| `git-svn-dcommit-push` | `git svn dcommit && git push github $(git_main_branch):svntrunk` |
|
| `git-svn-dcommit-push` | `git svn dcommit && git push github $(git_main_branch):svntrunk` |
|
||||||
| `gsr` | `git svn rebase` |
|
| `gsr` | `git svn rebase` |
|
||||||
@@ -255,6 +260,7 @@ receive further support.
|
|||||||
| `git_current_user_name` | Returns the `user.name` config value (Lives in `lib/git.zsh`) |
|
| `git_current_user_name` | Returns the `user.name` config value (Lives in `lib/git.zsh`) |
|
||||||
| `git_develop_branch` | Returns the name of the “development” branch: `dev`, `devel`, `development` if they exist, `develop` otherwise |
|
| `git_develop_branch` | Returns the name of the “development” branch: `dev`, `devel`, `development` if they exist, `develop` otherwise |
|
||||||
| `git_main_branch` | Returns the name of the main branch: `main` if it exists, `master` otherwise |
|
| `git_main_branch` | Returns the name of the main branch: `main` if it exists, `master` otherwise |
|
||||||
|
| `gbcopy` | Copies current branch name to clipboard |
|
||||||
| `grename <old> <new>` | Renames branch `<old>` to `<new>`, including on the origin remote |
|
| `grename <old> <new>` | Renames branch `<old>` to `<new>`, including on the origin remote |
|
||||||
| `gbda` | Deletes all merged branches |
|
| `gbda` | Deletes all merged branches |
|
||||||
| `gbds` | Deletes all squash-merged branches (**Note: performance degrades with number of branches**) |
|
| `gbds` | Deletes all squash-merged branches (**Note: performance degrades with number of branches**) |
|
||||||
|
|||||||
@@ -49,6 +49,16 @@ function git_main_branch() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gbcopy() {
|
||||||
|
command git rev-parse --git-dir &>/dev/null || return
|
||||||
|
|
||||||
|
local branch
|
||||||
|
branch="$(git_current_branch)" || return
|
||||||
|
[[ -n "$branch" ]] || return 1
|
||||||
|
|
||||||
|
print -rn -- "$branch" | clipcopy
|
||||||
|
}
|
||||||
|
|
||||||
function grename() {
|
function grename() {
|
||||||
if [[ -z "$1" || -z "$2" ]]; then
|
if [[ -z "$1" || -z "$2" ]]; then
|
||||||
echo "Usage: $0 old_branch new_branch"
|
echo "Usage: $0 old_branch new_branch"
|
||||||
@@ -243,6 +253,7 @@ alias glolm='git log $(git_main_branch) --graph --pretty="%Cred%h%Creset -%C(aut
|
|||||||
alias glo='git log --oneline --decorate'
|
alias glo='git log --oneline --decorate'
|
||||||
alias glog='git log --oneline --decorate --graph'
|
alias glog='git log --oneline --decorate --graph'
|
||||||
alias gloga='git log --oneline --decorate --graph --all'
|
alias gloga='git log --oneline --decorate --graph --all'
|
||||||
|
alias glom='git log --oneline --decorate --color $(git_main_branch)..'
|
||||||
|
|
||||||
# Pretty log messages
|
# Pretty log messages
|
||||||
function _git_log_prettily(){
|
function _git_log_prettily(){
|
||||||
@@ -352,6 +363,8 @@ alias grbd='git rebase $(git_develop_branch)'
|
|||||||
alias grbm='git rebase $(git_main_branch)'
|
alias grbm='git rebase $(git_main_branch)'
|
||||||
alias grbom='git rebase origin/$(git_main_branch)'
|
alias grbom='git rebase origin/$(git_main_branch)'
|
||||||
alias grbum='git rebase upstream/$(git_main_branch)'
|
alias grbum='git rebase upstream/$(git_main_branch)'
|
||||||
|
alias grbmi='git rebase $(git_main_branch) --interactive'
|
||||||
|
alias grbmia='git rebase $(git_main_branch) --interactive --autosquash'
|
||||||
alias grf='git reflog'
|
alias grf='git reflog'
|
||||||
alias gr='git remote'
|
alias gr='git remote'
|
||||||
alias grv='git remote --verbose'
|
alias grv='git remote --verbose'
|
||||||
@@ -394,8 +407,10 @@ alias gsts='git stash show --patch'
|
|||||||
alias gst='git status'
|
alias gst='git status'
|
||||||
alias gss='git status --short'
|
alias gss='git status --short'
|
||||||
alias gsb='git status --short --branch'
|
alias gsb='git status --short --branch'
|
||||||
|
alias gsnut='git status --untracked-files=no'
|
||||||
alias gsi='git submodule init'
|
alias gsi='git submodule init'
|
||||||
alias gsu='git submodule update'
|
alias gsu='git submodule update'
|
||||||
|
alias gsuri='git submodule update --recursive --init'
|
||||||
alias gsd='git svn dcommit'
|
alias gsd='git svn dcommit'
|
||||||
alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
|
alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
|
||||||
alias gsr='git svn rebase'
|
alias gsr='git svn rebase'
|
||||||
|
|||||||
+34
-36
@@ -1,45 +1,43 @@
|
|||||||
# github plugin
|
# github plugin
|
||||||
|
|
||||||
This plugin supports working with GitHub from the command line. It provides a few things:
|
> [!WARNING]
|
||||||
|
> This plugin is deprecated and will be removed in a future release. It supports
|
||||||
|
> the legacy [`hub`](https://github.com/mislav/hub) CLI, not the current GitHub
|
||||||
|
> CLI. For `gh` completion, use the [`gh` plugin](../gh) instead.
|
||||||
|
|
||||||
* Sets up the `hub` wrapper and completions for the `git` command if you have [`hub`](https://github.com/github/hub) installed.
|
The plugin provides compatibility for existing `hub` users by:
|
||||||
* Completion for the [`github` Ruby gem](https://github.com/defunkt/github-gem).
|
|
||||||
* Convenience functions for working with repos and URLs.
|
|
||||||
|
|
||||||
### Functions
|
- aliasing `git` to `hub` when `hub` is installed;
|
||||||
|
- adding completion for `hub`; and
|
||||||
|
- defining convenience functions for creating repositories.
|
||||||
|
|
||||||
* `empty_gh` - Creates a new empty repo (with a `README.md`) and pushes it to GitHub
|
## Migrating to GitHub CLI
|
||||||
* `new_gh` - Initializes an existing directory as a repo and pushes it to GitHub
|
|
||||||
* `exist_gh` - Takes an existing repo and pushes it to GitHub
|
|
||||||
|
|
||||||
|
Install [GitHub CLI](https://cli.github.com/), replace `github` with `gh` in
|
||||||
## Installation
|
your plugin list, and restart your shell:
|
||||||
|
|
||||||
[Hub](https://github.com/github/hub) needs to be installed if you want to use it. On OS X with Homebrew, this can be done with `brew install hub`. The `hub` completion definition needs to be added to your `$FPATH` before initializing OMZ.
|
|
||||||
|
|
||||||
The [`github` Ruby gem](https://github.com/defunkt/github-gem) needs to be installed if you want to use it.
|
|
||||||
|
|
||||||
### Configuration
|
|
||||||
|
|
||||||
These settings affect `github`'s behavior.
|
|
||||||
|
|
||||||
#### Environment variables
|
|
||||||
|
|
||||||
* `$GITHUB_USER`
|
|
||||||
* `$GITHUB_PASSWORD`
|
|
||||||
|
|
||||||
#### Git configuration options
|
|
||||||
|
|
||||||
* `github.user` - GitHub username for repo operations
|
|
||||||
|
|
||||||
See `man hub` for more details.
|
|
||||||
|
|
||||||
### Homebrew installation note
|
|
||||||
|
|
||||||
If you have installed `hub` using Homebrew, its completions may not be on your `$FPATH` if you are using the system `zsh`. Homebrew installs `zsh` completion definitions to `/usr/local/share/zsh/site-functions`, which will be on `$FPATH` for the Homebrew-installed `zsh`, but not for the system `zsh`. If you want it to work with the system `zsh`, add this to your `~/.zshrc` before it sources `oh-my-zsh.sh`.
|
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
if (( ! ${fpath[(I)/usr/local/share/zsh/site-functions]} )); then
|
plugins=(... gh)
|
||||||
FPATH=/usr/local/share/zsh/site-functions:$FPATH
|
|
||||||
fi
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The `gh` plugin supplies completion for the installed GitHub CLI. It does not
|
||||||
|
alias `git`, because `gh` is not a Git wrapper.
|
||||||
|
|
||||||
|
The closest replacement for creating a GitHub repository from an existing
|
||||||
|
local repository is:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
gh repo create --source=. --push
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deprecated functions
|
||||||
|
|
||||||
|
- `empty_gh` - creates a new repository with a `README.md` and pushes it to GitHub
|
||||||
|
- `new_gh` - initializes an existing directory and pushes it to GitHub
|
||||||
|
- `exist_gh` - pushes an existing Git repository to GitHub
|
||||||
|
|
||||||
|
These functions remain available during the deprecation period and require
|
||||||
|
`hub`. They will be removed with the plugin.
|
||||||
|
|
||||||
|
If you continue using `hub`, see its documentation for authentication and
|
||||||
|
configuration details.
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
print -Pru2 -- '%F{yellow}[oh-my-zsh] The %Bgithub%b plugin is deprecated and will be removed in a future release.'
|
||||||
|
print -Pru2 -- 'It supports the legacy %Bhub%b CLI. Use the %Bgh%b plugin for GitHub CLI completion.%f'
|
||||||
|
|
||||||
# Set up hub wrapper for git, if it is available; https://github.com/github/hub
|
# Set up hub wrapper for git, if it is available; https://github.com/github/hub
|
||||||
if (( $+commands[hub] )); then
|
if (( $+commands[hub] )); then
|
||||||
alias git=hub
|
alias git=hub
|
||||||
@@ -26,7 +29,7 @@ empty_gh() { # [NAME_OF_REPO]
|
|||||||
# This function will add all non-hidden files to git.
|
# This function will add all non-hidden files to git.
|
||||||
new_gh() { # [DIRECTORY]
|
new_gh() { # [DIRECTORY]
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
local repo="$1"
|
local repo="${1-.}"
|
||||||
cd "$repo" \
|
cd "$repo" \
|
||||||
|| return
|
|| return
|
||||||
|
|
||||||
@@ -42,7 +45,7 @@ new_gh() { # [DIRECTORY]
|
|||||||
|| return
|
|| return
|
||||||
hub create \
|
hub create \
|
||||||
|| return
|
|| return
|
||||||
git push -u origin master \
|
git push -u origin HEAD \
|
||||||
|| return
|
|| return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,18 +55,19 @@ new_gh() { # [DIRECTORY]
|
|||||||
# to your GitHub.
|
# to your GitHub.
|
||||||
exist_gh() { # [DIRECTORY]
|
exist_gh() { # [DIRECTORY]
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
local repo=$1
|
local repo="${1:-.}"
|
||||||
cd "$repo"
|
cd "$repo" \
|
||||||
|
|| return
|
||||||
|
|
||||||
hub create \
|
hub create \
|
||||||
|| return
|
|| return
|
||||||
git push -u origin master
|
git push -u origin HEAD
|
||||||
}
|
}
|
||||||
|
|
||||||
# git.io "GitHub URL"
|
# git.io "GitHub URL"
|
||||||
#
|
#
|
||||||
# Shorten GitHub url, example:
|
# Shorten GitHub url, example:
|
||||||
# https://github.com/nvogel/dotzsh > https://git.io/8nU25w
|
# https://github.com/nvogel/dotzsh > https://git.io/8nU25w
|
||||||
# source: https://github.com/nvogel/dotzsh
|
# source: https://github.com/nvogel/dotzsh
|
||||||
# documentation: https://github.com/blog/985-git-io-github-url-shortener
|
# documentation: https://github.com/blog/985-git-io-github-url-shortener
|
||||||
#
|
#
|
||||||
@@ -74,4 +78,3 @@ git.io() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# End Functions #############################################################
|
# End Functions #############################################################
|
||||||
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# GitLab CLI plugin
|
||||||
|
|
||||||
|
This plugin adds completion for the [GitLab CLI](https://docs.gitlab.com/cli/).
|
||||||
|
|
||||||
|
To use it, add `glab` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
plugins=(... glab)
|
||||||
|
```
|
||||||
|
|
||||||
|
This plugin does not add any aliases.
|
||||||
|
|
||||||
|
## Cache
|
||||||
|
|
||||||
|
This plugin caches the completion script at `$ZSH_CACHE_DIR/completions/_glab`.
|
||||||
|
|
||||||
|
The cache is regenerated in the background whenever the plugin is loaded, which
|
||||||
|
usually happens when you start a new Zsh session.
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Autocompletion for the GitLab CLI (glab).
|
||||||
|
if (( ! $+commands[glab] )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
|
# bind it to `glab`. Otherwise, compinit will have already done that.
|
||||||
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_glab" ]]; then
|
||||||
|
typeset -g -A _comps
|
||||||
|
autoload -Uz _glab
|
||||||
|
_comps[glab]=_glab
|
||||||
|
fi
|
||||||
|
|
||||||
|
zmodload -F zsh/files b:zf_mv
|
||||||
|
() {
|
||||||
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._glab"
|
||||||
|
zf_mv -f -- =( glab completion -s zsh ) "$ZSH_CACHE_DIR/completions/_glab"
|
||||||
|
} &|
|
||||||
+95
-11
@@ -81,6 +81,7 @@ _go() {
|
|||||||
'tool[run specified go tool]'
|
'tool[run specified go tool]'
|
||||||
'version[print Go version]'
|
'version[print Go version]'
|
||||||
'vet[run go tool vet on packages]'
|
'vet[run go tool vet on packages]'
|
||||||
|
'work[workspace maintenance]'
|
||||||
)
|
)
|
||||||
if (( CURRENT == 2 )); then
|
if (( CURRENT == 2 )); then
|
||||||
# explain go commands
|
# explain go commands
|
||||||
@@ -88,19 +89,38 @@ _go() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
build_flags=(
|
build_flags=(
|
||||||
'-a[force reinstallation of packages that are already up to date]'
|
'-C[change to dir before running the command]:directory:_path_files -/'
|
||||||
|
'-a[force rebuilding of packages that are already up-to-date]'
|
||||||
'-n[print the commands but do not run them]'
|
'-n[print the commands but do not run them]'
|
||||||
'-p[number of parallel builds]:number'
|
'-p[number of parallel builds]:number'
|
||||||
'-race[enable data race detection]'
|
'-race[enable data race detection]'
|
||||||
'-x[print the commands]'
|
'-msan[enable interoperation with memory sanitizer]'
|
||||||
|
'-asan[enable interoperation with address sanitizer]'
|
||||||
|
'-cover[enable code coverage instrumentation]'
|
||||||
|
'-covermode[set the mode for coverage analysis]:mode:(set count atomic)'
|
||||||
|
'-coverpkg[apply coverage analysis to matching packages]:pattern'
|
||||||
|
'-v[print the names of packages as they are compiled]'
|
||||||
'-work[print temporary directory name and keep it]'
|
'-work[print temporary directory name and keep it]'
|
||||||
'-ccflags[flags for 5c/6c/8c]:flags'
|
'-x[print the commands]'
|
||||||
'-gcflags[flags for 5g/6g/8g]:flags'
|
'-asmflags[arguments to pass on each go tool asm invocation]:flags'
|
||||||
'-ldflags[flags for 5l/6l/8l]:flags'
|
'-buildmode[build mode to use]:mode:(archive c-archive c-shared default shared exe pie plugin)'
|
||||||
'-gccgoflags[flags for gccgo]:flags'
|
'-buildvcs[stamp binaries with version control information]:mode:(true false auto)'
|
||||||
'-compiler[name of compiler to use]:name'
|
'-compiler[name of compiler to use]:name:(gccgo gc)'
|
||||||
'-installsuffix[suffix to add to package directory]:suffix'
|
'-gccgoflags[arguments to pass on each gccgo compiler/linker invocation]:flags'
|
||||||
|
'-gcflags[arguments to pass on each go tool compile invocation]:flags'
|
||||||
|
'-installsuffix[suffix to use in the package installation directory]:suffix'
|
||||||
|
'-json[emit build output in JSON suitable for automated processing]'
|
||||||
|
'-ldflags[arguments to pass on each go tool link invocation]:flags'
|
||||||
|
'-linkshared[build code that will be linked against shared libraries]'
|
||||||
|
'-mod[module download mode to use]:mode:(readonly vendor mod)'
|
||||||
|
'-modcacherw[leave newly-created directories in the module cache read-write]'
|
||||||
|
'-modfile[read and write an alternate go.mod file]:file:_files -g "*.mod"'
|
||||||
|
'-overlay[read a JSON config file that provides an overlay for build operations]:file:_files -g "*.json"'
|
||||||
|
'-pgo[specify the file path of a profile for profile-guided optimization]:file:_files'
|
||||||
|
'-pkgdir[install and load all packages from dir]:directory:_path_files -/'
|
||||||
'-tags[list of build tags to consider satisfied]:tags'
|
'-tags[list of build tags to consider satisfied]:tags'
|
||||||
|
'-trimpath[remove all file system paths from the resulting executable]'
|
||||||
|
'-toolexec[program to use to invoke toolchain programs]:command'
|
||||||
)
|
)
|
||||||
|
|
||||||
case ${words[2]} in
|
case ${words[2]} in
|
||||||
@@ -125,17 +145,20 @@ _go() {
|
|||||||
;;
|
;;
|
||||||
install)
|
install)
|
||||||
_arguments -s -w : ${build_flags[@]} \
|
_arguments -s -w : ${build_flags[@]} \
|
||||||
"-v[show package names]" \
|
|
||||||
'*:importpaths:__go_packages'
|
'*:importpaths:__go_packages'
|
||||||
;;
|
;;
|
||||||
get)
|
get)
|
||||||
_arguments -s -w : \
|
_arguments -s -w : \
|
||||||
${build_flags[@]}
|
${build_flags[@]} \
|
||||||
|
"-t[consider modules needed to build tests of packages]" \
|
||||||
|
"-u[update modules providing dependencies to newer minor or patch releases]" \
|
||||||
|
"-u=[update modules providing dependencies to patch releases]:mode:(patch)" \
|
||||||
|
"-tool[add a matching tool line to go.mod for each listed package]" \
|
||||||
|
"*:importpaths:__go_packages"
|
||||||
;;
|
;;
|
||||||
build)
|
build)
|
||||||
_arguments -s -w : \
|
_arguments -s -w : \
|
||||||
${build_flags[@]} \
|
${build_flags[@]} \
|
||||||
"-v[show package names]" \
|
|
||||||
"-o[output file]:file:_files" \
|
"-o[output file]:file:_files" \
|
||||||
"*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }"
|
"*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }"
|
||||||
;;
|
;;
|
||||||
@@ -238,6 +261,60 @@ _go() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
work)
|
||||||
|
local -a work_commands
|
||||||
|
work_commands+=(
|
||||||
|
'edit[edit go.work from tools or scripts]'
|
||||||
|
'init[initialize workspace file]'
|
||||||
|
'sync[sync workspace build list to modules]'
|
||||||
|
'use[add modules to workspace file]'
|
||||||
|
'vendor[make vendored copy of dependencies]'
|
||||||
|
)
|
||||||
|
|
||||||
|
if (( CURRENT == 3 )); then
|
||||||
|
_values 'go work commands' ${work_commands[@]} "help[display help]"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
case ${words[3]} in
|
||||||
|
help)
|
||||||
|
_values 'go work commands' ${work_commands[@]}
|
||||||
|
;;
|
||||||
|
edit)
|
||||||
|
_arguments -s -w : \
|
||||||
|
"-fmt[reformat the go.work file]" \
|
||||||
|
"-godebug[=key=value add a godebug key=value line]:key=value" \
|
||||||
|
"-dropgodebug[=key drop an existing godebug line]:key" \
|
||||||
|
"-use[=path add a use directive]:directory:_path_files -/" \
|
||||||
|
"-dropuse[=path drop a use directive]:directory:_path_files -/" \
|
||||||
|
"-replace[=old{@v}=new{@v} add a replacement of the given module path and version pair]:name" \
|
||||||
|
"-dropreplace[=old{@v} drop a replacement of the given module path and version pair]:name" \
|
||||||
|
"-go[={version} set the expected Go language version]:number" \
|
||||||
|
"-toolchain[=name set the Go toolchain to use]:name" \
|
||||||
|
"-print[print the final go.work in its text format]" \
|
||||||
|
"-json[print the final go.work file in JSON format]" \
|
||||||
|
"1:go.work file:_files -g 'go.work'"
|
||||||
|
;;
|
||||||
|
init)
|
||||||
|
_arguments -s -w : \
|
||||||
|
"*:module directories:_path_files -/"
|
||||||
|
;;
|
||||||
|
sync)
|
||||||
|
;;
|
||||||
|
use)
|
||||||
|
_arguments -s -w : \
|
||||||
|
"-r[search recursively for modules in the argument directories]" \
|
||||||
|
"*:module directories:_path_files -/"
|
||||||
|
;;
|
||||||
|
vendor)
|
||||||
|
_arguments -s -w : \
|
||||||
|
"-e[attempt to proceed despite errors encountered while loading packages]" \
|
||||||
|
"-v[print the names of vendored modules and packages]" \
|
||||||
|
"-o[create the vendor directory at the given path]:output directory:_path_files -/" \
|
||||||
|
"*:flags"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
help)
|
help)
|
||||||
_values "${commands[@]}" \
|
_values "${commands[@]}" \
|
||||||
'environment[show Go environment variables available]' \
|
'environment[show Go environment variables available]' \
|
||||||
@@ -247,6 +324,13 @@ _go() {
|
|||||||
'testflag[description of testing flags]' \
|
'testflag[description of testing flags]' \
|
||||||
'testfunc[description of testing functions]'
|
'testfunc[description of testing functions]'
|
||||||
;;
|
;;
|
||||||
|
version)
|
||||||
|
_arguments -s -w : \
|
||||||
|
"-m[print module version information]" \
|
||||||
|
"-v[report unrecognized files]" \
|
||||||
|
"-json[print module version information in JSON format]" \
|
||||||
|
"*:file:_files"
|
||||||
|
;;
|
||||||
run)
|
run)
|
||||||
_arguments -s -w : \
|
_arguments -s -w : \
|
||||||
${build_flags[@]} \
|
${build_flags[@]} \
|
||||||
|
|||||||
@@ -267,6 +267,7 @@ __gradle_subcommand() {
|
|||||||
'-Dorg.gradle.configuration-cache.problems=[Configures how the configuration cache handles problems (fail or warn). Supported values are 'warn', or 'fail' (default).]:org.gradle.configuration cache.problems:(fail warn)' \
|
'-Dorg.gradle.configuration-cache.problems=[Configures how the configuration cache handles problems (fail or warn). Supported values are 'warn', or 'fail' (default).]:org.gradle.configuration cache.problems:(fail warn)' \
|
||||||
'-Dorg.gradle.configuration-cache.read-only=[]' \
|
'-Dorg.gradle.configuration-cache.read-only=[]' \
|
||||||
'-Dorg.gradle.configuration-cache.unsafe.ignore.unsupported-build-events-listeners=[]' \
|
'-Dorg.gradle.configuration-cache.unsafe.ignore.unsupported-build-events-listeners=[]' \
|
||||||
|
'-Dorg.gradle.configuration-cache.unsafe.skip-task-logging-listeners-serialization=[]' \
|
||||||
'-Dorg.gradle.configuration-cache=[Enables the configuration cache. Gradle will try to reuse the build configuration from previous builds.]' \
|
'-Dorg.gradle.configuration-cache=[Enables the configuration cache. Gradle will try to reuse the build configuration from previous builds.]' \
|
||||||
'-Dorg.gradle.configureondemand=[Configures necessary projects only. Gradle will attempt to reduce configuration time for large multi-project builds.]' \
|
'-Dorg.gradle.configureondemand=[Configures necessary projects only. Gradle will attempt to reduce configuration time for large multi-project builds.]' \
|
||||||
'-Dorg.gradle.console.interactive=[]' \
|
'-Dorg.gradle.console.interactive=[]' \
|
||||||
@@ -296,6 +297,7 @@ __gradle_subcommand() {
|
|||||||
'-Dorg.gradle.jvmargs=[]' \
|
'-Dorg.gradle.jvmargs=[]' \
|
||||||
'-Dorg.gradle.logging.level=[]:org.gradle.logging.level:(quiet warn info debug)' \
|
'-Dorg.gradle.logging.level=[]:org.gradle.logging.level:(quiet warn info debug)' \
|
||||||
'-Dorg.gradle.logging.stacktrace=[]' \
|
'-Dorg.gradle.logging.stacktrace=[]' \
|
||||||
|
'-Dorg.gradle.mirror.maven.settings=[]' \
|
||||||
'-Dorg.gradle.native=[]' \
|
'-Dorg.gradle.native=[]' \
|
||||||
'-Dorg.gradle.parallel=[Builds projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use.]:org.gradle.parallel:(true false)' \
|
'-Dorg.gradle.parallel=[Builds projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use.]:org.gradle.parallel:(true false)' \
|
||||||
'-Dorg.gradle.priority=[Specifies the scheduling priority for the Gradle daemon and all processes launched by it. Supported values are 'normal' (default) or 'low'.]:org.gradle.priority:(normal low)' \
|
'-Dorg.gradle.priority=[Specifies the scheduling priority for the Gradle daemon and all processes launched by it. Supported values are 'normal' (default) or 'low'.]:org.gradle.priority:(normal low)' \
|
||||||
@@ -407,6 +409,7 @@ _gradle() {
|
|||||||
'-Dorg.gradle.configuration-cache.problems=[Configures how the configuration cache handles problems (fail or warn). Supported values are 'warn', or 'fail' (default).]:org.gradle.configuration cache.problems:(fail warn):->argument-expected' \
|
'-Dorg.gradle.configuration-cache.problems=[Configures how the configuration cache handles problems (fail or warn). Supported values are 'warn', or 'fail' (default).]:org.gradle.configuration cache.problems:(fail warn):->argument-expected' \
|
||||||
'-Dorg.gradle.configuration-cache.read-only=[]:->argument-expected' \
|
'-Dorg.gradle.configuration-cache.read-only=[]:->argument-expected' \
|
||||||
'-Dorg.gradle.configuration-cache.unsafe.ignore.unsupported-build-events-listeners=[]:->argument-expected' \
|
'-Dorg.gradle.configuration-cache.unsafe.ignore.unsupported-build-events-listeners=[]:->argument-expected' \
|
||||||
|
'-Dorg.gradle.configuration-cache.unsafe.skip-task-logging-listeners-serialization=[]:->argument-expected' \
|
||||||
'-Dorg.gradle.configuration-cache=[Enables the configuration cache. Gradle will try to reuse the build configuration from previous builds.]:->argument-expected' \
|
'-Dorg.gradle.configuration-cache=[Enables the configuration cache. Gradle will try to reuse the build configuration from previous builds.]:->argument-expected' \
|
||||||
'-Dorg.gradle.configureondemand=[Configures necessary projects only. Gradle will attempt to reduce configuration time for large multi-project builds.]:->argument-expected' \
|
'-Dorg.gradle.configureondemand=[Configures necessary projects only. Gradle will attempt to reduce configuration time for large multi-project builds.]:->argument-expected' \
|
||||||
'-Dorg.gradle.console.interactive=[]:->argument-expected' \
|
'-Dorg.gradle.console.interactive=[]:->argument-expected' \
|
||||||
@@ -436,6 +439,7 @@ _gradle() {
|
|||||||
'-Dorg.gradle.jvmargs=[]:->argument-expected' \
|
'-Dorg.gradle.jvmargs=[]:->argument-expected' \
|
||||||
'-Dorg.gradle.logging.level=[]:org.gradle.logging.level:(quiet warn info debug):->argument-expected' \
|
'-Dorg.gradle.logging.level=[]:org.gradle.logging.level:(quiet warn info debug):->argument-expected' \
|
||||||
'-Dorg.gradle.logging.stacktrace=[]:->argument-expected' \
|
'-Dorg.gradle.logging.stacktrace=[]:->argument-expected' \
|
||||||
|
'-Dorg.gradle.mirror.maven.settings=[]:->argument-expected' \
|
||||||
'-Dorg.gradle.native=[]:->argument-expected' \
|
'-Dorg.gradle.native=[]:->argument-expected' \
|
||||||
'-Dorg.gradle.parallel=[Builds projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use.]:org.gradle.parallel:(true false):->argument-expected' \
|
'-Dorg.gradle.parallel=[Builds projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use.]:org.gradle.parallel:(true false):->argument-expected' \
|
||||||
'-Dorg.gradle.priority=[Specifies the scheduling priority for the Gradle daemon and all processes launched by it. Supported values are 'normal' (default) or 'low'.]:org.gradle.priority:(normal low):->argument-expected' \
|
'-Dorg.gradle.priority=[Specifies the scheduling priority for the Gradle daemon and all processes launched by it. Supported values are 'normal' (default) or 'low'.]:org.gradle.priority:(normal low):->argument-expected' \
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ function gradle-or-gradlew() {
|
|||||||
|
|
||||||
# if gradlew found, run it instead of gradle
|
# if gradlew found, run it instead of gradle
|
||||||
if [[ -f "$project_root/gradlew" ]]; then
|
if [[ -f "$project_root/gradlew" ]]; then
|
||||||
echo "executing gradlew instead of gradle"
|
|
||||||
"$project_root/gradlew" "$@"
|
"$project_root/gradlew" "$@"
|
||||||
else
|
else
|
||||||
command gradle "$@"
|
command gradle "$@"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ else
|
|||||||
source "$ZSH_CACHE_DIR/completions/_hasura"
|
source "$ZSH_CACHE_DIR/completions/_hasura"
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_hasura"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._hasura"
|
||||||
zf_mv -f -- =( hasura completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( hasura completion zsh ) "$ZSH_CACHE_DIR/completions/_hasura"
|
||||||
} &|
|
} &|
|
||||||
fi
|
fi
|
||||||
@@ -15,8 +15,8 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_hcloud"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._hcloud"
|
||||||
zf_mv -f -- =( hcloud completion zsh 2> /dev/null ) "$TMPPREFIX"
|
zf_mv -f -- =( hcloud completion zsh 2> /dev/null ) "$ZSH_CACHE_DIR/completions/_hcloud"
|
||||||
} &|
|
} &|
|
||||||
|
|
||||||
# Main alias
|
# Main alias
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ else
|
|||||||
source "$ZSH_CACHE_DIR/completions/_helm"
|
source "$ZSH_CACHE_DIR/completions/_helm"
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_helm"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._helm"
|
||||||
zf_mv -f -- =( helm completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( helm completion zsh ) "$ZSH_CACHE_DIR/completions/_helm"
|
||||||
} &|
|
} &|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_herdr"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._herdr"
|
||||||
zf_mv -f -- =( herdr completion zsh < /dev/null 2> /dev/null ) "$TMPPREFIX"
|
zf_mv -f -- =( herdr completion zsh < /dev/null 2> /dev/null ) "$ZSH_CACHE_DIR/completions/_herdr"
|
||||||
} &|
|
} &|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# hermes plugin
|
||||||
|
|
||||||
|
This plugin adds completions for the Hermes AI agent.
|
||||||
|
|
||||||
|
To use it, add `hermes` to the plugin array in your zshrc file:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
plugins=(... hermes)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
hermes <TAB>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Common Workflows
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
# First time setup/updating overall config
|
||||||
|
hermes setup
|
||||||
|
|
||||||
|
# Starting the tui chat
|
||||||
|
hermes
|
||||||
|
|
||||||
|
# Changing default model
|
||||||
|
hermes model
|
||||||
|
```
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
if (( ! $+commands[hermes] )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_hermes" ]]; then
|
||||||
|
typeset -g -A _comps
|
||||||
|
autoload -Uz _hermes
|
||||||
|
_comps[hermes]=_hermes
|
||||||
|
fi
|
||||||
|
|
||||||
|
zmodload -F zsh/files b:zf_mv
|
||||||
|
() {
|
||||||
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._hermes"
|
||||||
|
zf_mv -f -- =( hermes completion zsh < /dev/null 2> /dev/null ) "$ZSH_CACHE_DIR/completions/_hermes"
|
||||||
|
} &|
|
||||||
@@ -20,7 +20,7 @@ Requirements
|
|||||||
Install
|
Install
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
Using the [Homebrew](https://brew.sh) package manager:
|
Using the [Homebrew]( https://brew.sh ) package manager:
|
||||||
|
|
||||||
brew install zsh-history-substring-search
|
brew install zsh-history-substring-search
|
||||||
echo 'source $(brew --prefix)/share/zsh-history-substring-search/zsh-history-substring-search.zsh' >> ~/.zshrc
|
echo 'source $(brew --prefix)/share/zsh-history-substring-search/zsh-history-substring-search.zsh' >> ~/.zshrc
|
||||||
@@ -51,7 +51,7 @@ Using [zplug](https://github.com/zplug/zplug):
|
|||||||
|
|
||||||
1. Add this repo to `~/.zshrc`:
|
1. Add this repo to `~/.zshrc`:
|
||||||
|
|
||||||
zplug "zsh-users/zsh-history-substring-search", as: plugin
|
zplug "zsh-users/zsh-history-substring-search", as:plugin
|
||||||
|
|
||||||
Using [antigen](https://github.com/zsh-users/antigen):
|
Using [antigen](https://github.com/zsh-users/antigen):
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ Using [Zinit](https://github.com/zdharma-continuum/zinit):
|
|||||||
|
|
||||||
1. Use the `Oh-my-zsh` Zinit snippet in `~/.zshrc`:
|
1. Use the `Oh-my-zsh` Zinit snippet in `~/.zshrc`:
|
||||||
|
|
||||||
zinit snippet OMZ::plugins/git/git.plugin.zsh`
|
zinit snippet OMZ::plugins/git/git.plugin.zsh
|
||||||
|
|
||||||
2. Load the plugin in `~/.zshrc`:
|
2. Load the plugin in `~/.zshrc`:
|
||||||
|
|
||||||
|
|||||||
@@ -295,8 +295,8 @@ _history-substring-search-begin() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Escape and join query parts with wildcard character '*' as separator
|
# Escape and join query parts with wildcard character '*' as seperator
|
||||||
# `(j:CHAR:)` join array to string with CHAR as separator
|
# `(j:CHAR:)` join array to string with CHAR as seperator
|
||||||
#
|
#
|
||||||
local search_pattern="${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
|
local search_pattern="${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_jj"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._jj"
|
||||||
zf_mv -f -- =( COMPLETE=zsh jj ) "$TMPPREFIX"
|
zf_mv -f -- =( COMPLETE=zsh jj ) "$ZSH_CACHE_DIR/completions/_jj"
|
||||||
} &|
|
} &|
|
||||||
|
|
||||||
function __jj_prompt_jj() {
|
function __jj_prompt_jj() {
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
# the actual completion file will be loaded.
|
# the actual completion file will be loaded.
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_k9s"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._k9s"
|
||||||
zf_mv -f -- =( k9s completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( k9s completion zsh ) "$ZSH_CACHE_DIR/completions/_k9s"
|
||||||
} &|
|
} &|
|
||||||
@@ -13,8 +13,8 @@ fi
|
|||||||
# Generate and load kind completion
|
# Generate and load kind completion
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_kind"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._kind"
|
||||||
zf_mv -f -- =( kind completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( kind completion zsh ) "$ZSH_CACHE_DIR/completions/_kind"
|
||||||
} &|
|
} &|
|
||||||
|
|
||||||
# Register aliases
|
# Register aliases
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ KUBE_PS1_HIDE_IF_NOCONTEXT="${KUBE_PS1_HIDE_IF_NOCONTEXT:-false}"
|
|||||||
_KUBE_PS1_KUBECONFIG_CACHE="${KUBECONFIG}"
|
_KUBE_PS1_KUBECONFIG_CACHE="${KUBECONFIG}"
|
||||||
_KUBE_PS1_DISABLE_PATH="${HOME}/.kube/kube-ps1/disabled"
|
_KUBE_PS1_DISABLE_PATH="${HOME}/.kube/kube-ps1/disabled"
|
||||||
_KUBE_PS1_LAST_TIME=0
|
_KUBE_PS1_LAST_TIME=0
|
||||||
|
_KUBE_PS1_HAS_CONTEXT=false
|
||||||
|
|
||||||
# Determine our shell
|
# Determine our shell
|
||||||
_kube_ps1_shell_type() {
|
_kube_ps1_shell_type() {
|
||||||
@@ -264,15 +265,21 @@ _kube_ps1_prompt_update() {
|
|||||||
[[ "${KUBE_PS1_ENABLED}" == "off" ]] && return $return_code
|
[[ "${KUBE_PS1_ENABLED}" == "off" ]] && return $return_code
|
||||||
|
|
||||||
if ! _kube_ps1_binary_check "${KUBE_PS1_BINARY}"; then
|
if ! _kube_ps1_binary_check "${KUBE_PS1_BINARY}"; then
|
||||||
# No ability to fetch context/namespace; display N/A.
|
# Unable to determine context availability; preserve the existing
|
||||||
|
# BINARY-N/A prompt instead of treating it as no context.
|
||||||
KUBE_PS1_CONTEXT="BINARY-N/A"
|
KUBE_PS1_CONTEXT="BINARY-N/A"
|
||||||
KUBE_PS1_NAMESPACE="N/A"
|
KUBE_PS1_NAMESPACE="N/A"
|
||||||
|
unset _KUBE_PS1_HAS_CONTEXT
|
||||||
|
# Refresh when the binary becomes available again.
|
||||||
|
_KUBE_PS1_LAST_TIME=0
|
||||||
return $return_code
|
return $return_code
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${KUBECONFIG}" != "${_KUBE_PS1_KUBECONFIG_CACHE}" ]]; then
|
if [[ "${_KUBE_PS1_LAST_TIME}" == 0 ]] ||
|
||||||
# User changed KUBECONFIG; unconditionally refetch.
|
[[ "${KUBECONFIG}" != "${_KUBE_PS1_KUBECONFIG_CACHE}" ]]; then
|
||||||
_KUBE_PS1_KUBECONFIG_CACHE=${KUBECONFIG}
|
# Fetch initially, even if no config file exists, and whenever the
|
||||||
|
# user changes KUBECONFIG.
|
||||||
|
_KUBE_PS1_KUBECONFIG_CACHE="${KUBECONFIG}"
|
||||||
_kube_ps1_get_context_ns
|
_kube_ps1_get_context_ns
|
||||||
return $return_code
|
return $return_code
|
||||||
fi
|
fi
|
||||||
@@ -300,13 +307,30 @@ _kube_ps1_prompt_update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_kube_ps1_get_context() {
|
_kube_ps1_get_context() {
|
||||||
if [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]]; then
|
local context
|
||||||
KUBE_PS1_CONTEXT="$(${KUBE_PS1_BINARY} config current-context 2>/dev/null)"
|
|
||||||
KUBE_PS1_CONTEXT="${KUBE_PS1_CONTEXT:-N/A}"
|
|
||||||
|
|
||||||
if [[ -n "${KUBE_PS1_CLUSTER_FUNCTION}" ]]; then
|
# Context availability must be detected even when context display is
|
||||||
KUBE_PS1_CONTEXT="$("${KUBE_PS1_CLUSTER_FUNCTION}" "${KUBE_PS1_CONTEXT}")"
|
# disabled but KUBE_PS1_HIDE_IF_NOCONTEXT is enabled.
|
||||||
fi
|
if [[ "${KUBE_PS1_CONTEXT_ENABLE}" != true ]] &&
|
||||||
|
[[ "${KUBE_PS1_HIDE_IF_NOCONTEXT}" != true ]]; then
|
||||||
|
KUBE_PS1_CONTEXT=
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
context="$("${KUBE_PS1_BINARY}" config current-context 2>/dev/null)"
|
||||||
|
|
||||||
|
_KUBE_PS1_HAS_CONTEXT=false
|
||||||
|
[[ -n "${context}" ]] && _KUBE_PS1_HAS_CONTEXT=true
|
||||||
|
|
||||||
|
if [[ "${KUBE_PS1_CONTEXT_ENABLE}" != true ]]; then
|
||||||
|
KUBE_PS1_CONTEXT=
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
KUBE_PS1_CONTEXT="${context:-N/A}"
|
||||||
|
|
||||||
|
if [[ -n "${KUBE_PS1_CLUSTER_FUNCTION}" ]]; then
|
||||||
|
KUBE_PS1_CONTEXT="$("${KUBE_PS1_CLUSTER_FUNCTION}" "${KUBE_PS1_CONTEXT}")"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,7 +349,7 @@ _kube_ps1_get_context_ns() {
|
|||||||
# Set the command time
|
# Set the command time
|
||||||
if [[ "${_KUBE_PS1_SHELL}" == "bash" ]]; then
|
if [[ "${_KUBE_PS1_SHELL}" == "bash" ]]; then
|
||||||
if ((BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 2))); then
|
if ((BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 2))); then
|
||||||
_KUBE_PS1_LAST_TIME=$(printf '%(%s)T')
|
printf -v _KUBE_PS1_LAST_TIME '%(%s)T' -1
|
||||||
else
|
else
|
||||||
_KUBE_PS1_LAST_TIME=$(date +%s)
|
_KUBE_PS1_LAST_TIME=$(date +%s)
|
||||||
fi
|
fi
|
||||||
@@ -407,8 +431,11 @@ kubeoff() {
|
|||||||
# Build our prompt
|
# Build our prompt
|
||||||
kube_ps1() {
|
kube_ps1() {
|
||||||
[[ "${KUBE_PS1_ENABLED}" == "off" ]] && return
|
[[ "${KUBE_PS1_ENABLED}" == "off" ]] && return
|
||||||
|
|
||||||
|
[[ "${KUBE_PS1_HIDE_IF_NOCONTEXT}" == true ]] &&
|
||||||
|
[[ "${_KUBE_PS1_HAS_CONTEXT}" == false ]] && return
|
||||||
|
|
||||||
[[ -z "${KUBE_PS1_CONTEXT}" ]] && [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]] && return
|
[[ -z "${KUBE_PS1_CONTEXT}" ]] && [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]] && return
|
||||||
[[ "${KUBE_PS1_CONTEXT}" == "N/A" ]] && [[ ${KUBE_PS1_HIDE_IF_NOCONTEXT} == true ]] && return
|
|
||||||
|
|
||||||
local KUBE_PS1
|
local KUBE_PS1
|
||||||
local KUBE_PS1_RESET_COLOR="${_KUBE_PS1_OPEN_ESC}${_KUBE_PS1_DEFAULT_FG}${_KUBE_PS1_CLOSE_ESC}"
|
local KUBE_PS1_RESET_COLOR="${_KUBE_PS1_OPEN_ESC}${_KUBE_PS1_DEFAULT_FG}${_KUBE_PS1_CLOSE_ESC}"
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_kubectl"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._kubectl"
|
||||||
zf_mv -f -- =( kubectl completion zsh 2> /dev/null ) "$TMPPREFIX"
|
zf_mv -f -- =( kubectl completion zsh 2> /dev/null ) "$ZSH_CACHE_DIR/completions/_kubectl"
|
||||||
} &|
|
} &|
|
||||||
|
|
||||||
# This command is used a LOT both below and in daily life
|
# This command is used a LOT both below and in daily life
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# logcli plugin
|
||||||
|
|
||||||
|
This plugin adds completion for [Grafana Loki's logcli](https://grafana.com/docs/loki/latest/query/logcli/).
|
||||||
|
|
||||||
|
To use it, add `logcli` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
plugins=(... logcli)
|
||||||
|
```
|
||||||
|
|
||||||
|
This plugin does not add any aliases.
|
||||||
|
|
||||||
|
## Cache
|
||||||
|
|
||||||
|
This plugin caches the completion script and automatically updates it when the
|
||||||
|
plugin is loaded, which is usually when you start a new terminal emulator.
|
||||||
|
|
||||||
|
The cache is stored at `$ZSH_CACHE_DIR/completions/_logcli`.
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Autocompletion for Grafana Loki's CLI (logcli).
|
||||||
|
if (( ! $+commands[logcli] )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
|
# bind it to `logcli`. Otherwise, compinit will have already done that.
|
||||||
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_logcli" ]]; then
|
||||||
|
typeset -g -A _comps
|
||||||
|
autoload -Uz _logcli
|
||||||
|
_comps[logcli]=_logcli
|
||||||
|
fi
|
||||||
|
|
||||||
|
zmodload -F zsh/files b:zf_mv
|
||||||
|
() {
|
||||||
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._logcli"
|
||||||
|
zf_mv -f -- =( logcli --completion-script-zsh ) "$ZSH_CACHE_DIR/completions/_logcli"
|
||||||
|
} &|
|
||||||
@@ -12,6 +12,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_minikube"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._minikube"
|
||||||
zf_mv -f -- =( minikube completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( minikube completion zsh ) "$ZSH_CACHE_DIR/completions/_minikube"
|
||||||
} &|
|
} &|
|
||||||
@@ -21,6 +21,6 @@ fi
|
|||||||
# Generate and load mise completion
|
# Generate and load mise completion
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_mise"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._mise"
|
||||||
zf_mv -f -- =( mise completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( mise completion zsh ) "$ZSH_CACHE_DIR/completions/_mise"
|
||||||
} &|
|
} &|
|
||||||
@@ -13,8 +13,8 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_molecule"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._molecule"
|
||||||
zf_mv -f -- =( _MOLECULE_COMPLETE=zsh_source molecule ) "$TMPPREFIX"
|
zf_mv -f -- =( _MOLECULE_COMPLETE=zsh_source molecule ) "$ZSH_CACHE_DIR/completions/_molecule"
|
||||||
} &|
|
} &|
|
||||||
|
|
||||||
# Alias
|
# Alias
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_atlas"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._atlas"
|
||||||
zf_mv -f -- =( atlas completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( atlas completion zsh ) "$ZSH_CACHE_DIR/completions/_atlas"
|
||||||
} &|
|
} &|
|
||||||
@@ -9,8 +9,8 @@ if (( $+commands[nsc] )); then
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_nsc"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._nsc"
|
||||||
zf_mv -f -- =( nsc completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( nsc completion zsh ) "$ZSH_CACHE_DIR/completions/_nsc"
|
||||||
} &|
|
} &|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ if (( $+commands[nats] )); then
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_nats"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._nats"
|
||||||
zf_mv -f -- =( nats --completion-script-zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( nats --completion-script-zsh ) "$ZSH_CACHE_DIR/completions/_nats"
|
||||||
} &|
|
} &|
|
||||||
fi
|
fi
|
||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_ngrok"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._ngrok"
|
||||||
zf_mv -f -- =( ngrok completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( ngrok completion zsh ) "$ZSH_CACHE_DIR/completions/_ngrok"
|
||||||
} &|
|
} &|
|
||||||
@@ -19,4 +19,6 @@ Provided aliases:
|
|||||||
- `ot`: generates a MFA code based on the given key and copies it to the clipboard
|
- `ot`: generates a MFA code based on the given key and copies it to the clipboard
|
||||||
(on Linux it relies on xsel, on MacOS X it uses pbcopy instead).
|
(on Linux it relies on xsel, on MacOS X it uses pbcopy instead).
|
||||||
|
|
||||||
The plugin uses `$HOME/.otp` to store its internal files.
|
The plugin stores its internal files in `$OTP_HOME`, which can be set in your zshrc.
|
||||||
|
If `$OTP_HOME` is not set it defaults to either `$HOME/.otp` or `$XDG_DATA_HOME/otp`,
|
||||||
|
depending on whether `~/.otp` already exists, or whether `$XDG_DATA_HOME` is set.
|
||||||
@@ -1,4 +1,10 @@
|
|||||||
export OTP_HOME=~/.otp
|
if [[ -z "$OTP_HOME" ]]; then
|
||||||
|
if [[ ! -d "$HOME/.otp" ]] && [[ -n "$XDG_DATA_HOME" ]]; then
|
||||||
|
export OTP_HOME="$XDG_DATA_HOME/otp"
|
||||||
|
else
|
||||||
|
export OTP_HOME=~/.otp
|
||||||
|
fi
|
||||||
|
fi
|
||||||
mkdir -p $OTP_HOME
|
mkdir -p $OTP_HOME
|
||||||
|
|
||||||
function ot () {
|
function ot () {
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_pass-cli"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._pass-cli"
|
||||||
zf_mv -f -- =( pass-cli completions zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( pass-cli completions zsh ) "$ZSH_CACHE_DIR/completions/_pass-cli"
|
||||||
} &|
|
} &|
|
||||||
@@ -45,8 +45,8 @@ else
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_pipenv"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._pipenv"
|
||||||
zf_mv -f -- =( _PIPENV_COMPLETE=zsh_source pipenv ) "$TMPPREFIX"
|
zf_mv -f -- =( _PIPENV_COMPLETE=zsh_source pipenv ) "$ZSH_CACHE_DIR/completions/_pipenv"
|
||||||
} &|
|
} &|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,16 @@ plugins=(... podman)
|
|||||||
| pirm | `podman image rm` | Remove one or more images |
|
| pirm | `podman image rm` | Remove one or more images |
|
||||||
| pit | `podman image tag` | Add a name and tag to a particular image |
|
| pit | `podman image tag` | Add a name and tag to a particular image |
|
||||||
| plo | `podman container logs` | Fetch the logs of a podman container |
|
| plo | `podman container logs` | Fetch the logs of a podman container |
|
||||||
|
| pmif | `podman machine info` | Display machine host info |
|
||||||
|
| pmit | `podman machine init` | Initialize a virtual machine |
|
||||||
|
| pmis | `podman machine inspect` | Inspect an existing machine |
|
||||||
|
| pml | `podman machine list` | List machines |
|
||||||
|
| pmo | `podman machine os` | Manage a Podman virtual machine's OS |
|
||||||
|
| pmrm | `podman machine rm` | Remove an existing machine |
|
||||||
|
| pms | `podman machine set` | Set a virtual machine setting |
|
||||||
|
| pmss | `podman machine ssh` | SSH into an existing machine |
|
||||||
|
| pmst | `podman machine start` | Start an existing machine |
|
||||||
|
| pmsp | `podman machine stop` | Stop an existing machine |
|
||||||
| pnc | `podman network create` | Create a new network |
|
| pnc | `podman network create` | Create a new network |
|
||||||
| pncn | `podman network connect` | Connect a container to a network |
|
| pncn | `podman network connect` | Connect a container to a network |
|
||||||
| pndcn | `podman network disconnect` | Disconnect a container from a network |
|
| pndcn | `podman network disconnect` | Disconnect a container from a network |
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_podman"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._podman"
|
||||||
zf_mv -f -- =( podman completion zsh 2> /dev/null ) "$TMPPREFIX"
|
zf_mv -f -- =( podman completion zsh 2> /dev/null ) "$ZSH_CACHE_DIR/completions/_podman"
|
||||||
} &|
|
} &|
|
||||||
|
|
||||||
alias pbl='podman build'
|
alias pbl='podman build'
|
||||||
@@ -26,6 +26,16 @@ alias pils='podman image ls'
|
|||||||
alias pipu='podman image push'
|
alias pipu='podman image push'
|
||||||
alias pirm='podman image rm'
|
alias pirm='podman image rm'
|
||||||
alias pit='podman image tag'
|
alias pit='podman image tag'
|
||||||
|
alias pmif='podman machine info'
|
||||||
|
alias pmit='podman machine init'
|
||||||
|
alias pmis='podman machine inspect'
|
||||||
|
alias pml='podman machine list'
|
||||||
|
alias pmo='podman machine os'
|
||||||
|
alias pmrm='podman machine rm'
|
||||||
|
alias pms='podman machine set'
|
||||||
|
alias pmss='podman machine ssh'
|
||||||
|
alias pmst='podman machine start'
|
||||||
|
alias pmsp='podman machine stop'
|
||||||
alias plo='podman container logs'
|
alias plo='podman container logs'
|
||||||
alias pnc='podman network create'
|
alias pnc='podman network create'
|
||||||
alias pncn='podman network connect'
|
alias pncn='podman network connect'
|
||||||
|
|||||||
@@ -41,6 +41,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_poetry"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._poetry"
|
||||||
zf_mv -f -- =( poetry completions zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( poetry completions zsh ) "$ZSH_CACHE_DIR/completions/_poetry"
|
||||||
} &|
|
} &|
|
||||||
@@ -12,7 +12,7 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_procs"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._procs"
|
||||||
autoload -Uz is-at-least
|
autoload -Uz is-at-least
|
||||||
local _version=$(procs --version)
|
local _version=$(procs --version)
|
||||||
zf_mv -f -- =(
|
zf_mv -f -- =(
|
||||||
@@ -21,5 +21,5 @@ zmodload -F zsh/files b:zf_mv
|
|||||||
else
|
else
|
||||||
procs --completion-out zsh
|
procs --completion-out zsh
|
||||||
fi
|
fi
|
||||||
) "$TMPPREFIX"
|
) "$ZSH_CACHE_DIR/completions/_procs"
|
||||||
} &|
|
} &|
|
||||||
@@ -12,8 +12,8 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_pulumi"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._pulumi"
|
||||||
zf_mv -f -- =( pulumi gen-completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( pulumi gen-completion zsh ) "$ZSH_CACHE_DIR/completions/_pulumi"
|
||||||
} &|
|
} &|
|
||||||
|
|
||||||
# Aliases
|
# Aliases
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ function pyuserpaths() {
|
|||||||
|
|
||||||
# Get minor release version.
|
# Get minor release version.
|
||||||
# The patch version is variable length, truncate it.
|
# The patch version is variable length, truncate it.
|
||||||
version=${(M)${"$($python -V 2>&1)":7}#[^.]##.[^.]##}
|
version=${(M)${"$($python -V 2>&1)":7}##[^.]##.[^.]##}
|
||||||
|
|
||||||
# Add version specific path, if:
|
# Add version specific path, if:
|
||||||
# - it exists in the filesystem
|
# - it exists in the filesystem
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_qodana"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._qodana"
|
||||||
zf_mv -f -- =( qodana completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( qodana completion zsh ) "$ZSH_CACHE_DIR/completions/_qodana"
|
||||||
} &|
|
} &|
|
||||||
@@ -12,8 +12,8 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_rbw"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._rbw"
|
||||||
zf_mv -f -- =( rbw gen-completions zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( rbw gen-completions zsh ) "$ZSH_CACHE_DIR/completions/_rbw"
|
||||||
} &|
|
} &|
|
||||||
|
|
||||||
# rbwpw function copies the password of a service to the clipboard
|
# rbwpw function copies the password of a service to the clipboard
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_rclone"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._rclone"
|
||||||
zf_mv -f -- =( rclone completion zsh - ) "$TMPPREFIX"
|
zf_mv -f -- =( rclone completion zsh - ) "$ZSH_CACHE_DIR/completions/_rclone"
|
||||||
} &|
|
} &|
|
||||||
@@ -22,6 +22,6 @@ fi
|
|||||||
# Overwrites the file each time as completions might change with ruff versions.
|
# Overwrites the file each time as completions might change with ruff versions.
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_ruff"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._ruff"
|
||||||
zf_mv -f -- =( ruff generate-shell-completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( ruff generate-shell-completion zsh ) "$ZSH_CACHE_DIR/completions/_ruff"
|
||||||
} &|
|
} &|
|
||||||
@@ -21,8 +21,8 @@ fi
|
|||||||
# Generate completion files in the background
|
# Generate completion files in the background
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_rustup"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._rustup"
|
||||||
zf_mv -f -- =( rustup completions zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( 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
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ function install_autocompletion {
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_$1"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._$1"
|
||||||
zf_mv -f -- =( $1 completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( $1 completion zsh ) "$ZSH_CACHE_DIR/completions/_$1"
|
||||||
} "$1" &|
|
} "$1" &|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_skaffold"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._skaffold"
|
||||||
zf_mv -f -- =( skaffold completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( skaffold completion zsh ) "$ZSH_CACHE_DIR/completions/_skaffold"
|
||||||
} &|
|
} &|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
## Sops Plugin
|
||||||
|
|
||||||
|
This plugin sets up completion for [sops](https://getsops.io).
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# COMPLETION FUNCTION
|
||||||
|
if (( ! $+commands[sops] )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
|
# bind it to `sops`. Otherwise, compinit will have already done that.
|
||||||
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_sops" ]]; then
|
||||||
|
typeset -g -A _comps
|
||||||
|
autoload -Uz _sops
|
||||||
|
_comps[sops]=_sops
|
||||||
|
fi
|
||||||
|
|
||||||
|
zmodload -F zsh/files b:zf_mv
|
||||||
|
() {
|
||||||
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._sops"
|
||||||
|
zf_mv -f -- =( sops completion zsh ) "$ZSH_CACHE_DIR/completions/_sops"
|
||||||
|
} &|
|
||||||
@@ -12,6 +12,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_stripe"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._stripe"
|
||||||
zf_mv -f -- =( stripe completion --shell zsh --write-to-stdout ) "$TMPPREFIX"
|
zf_mv -f -- =( stripe completion --shell zsh --write-to-stdout ) "$ZSH_CACHE_DIR/completions/_stripe"
|
||||||
} &|
|
} &|
|
||||||
@@ -33,10 +33,10 @@ plugins=(... systemadmin)
|
|||||||
| killit | Kills any process that matches a regular expression passed to it |
|
| killit | Kills any process that matches a regular expression passed to it |
|
||||||
| tree | List contents of directories in a tree-like format (if tree isn't installed) |
|
| tree | List contents of directories in a tree-like format (if tree isn't installed) |
|
||||||
| sortcons | Sort connections by state |
|
| sortcons | Sort connections by state |
|
||||||
| con80 | View all 80 Port Connections |
|
| con80 | View all connections on ports 80 and 443, or on the ports given as arguments (`con80 8080`) |
|
||||||
| sortconip | On the connected IP sorted by the number of connections |
|
| sortconip | On the connected IP sorted by the number of connections |
|
||||||
| req20 | List the top 20 requests on port 80 |
|
| req20 | List the top 20 requests on ports 80 and 443, or on the ports given as arguments (`req20 8080`) |
|
||||||
| http20 | List the top 20 connections to port 80 based on tcpdump data |
|
| http20 | List the top 20 connections to ports 80 and 443 based on tcpdump data, or to the ports given as arguments |
|
||||||
| timewait20 | List the top 20 time_wait connections |
|
| timewait20 | List the top 20 time_wait connections |
|
||||||
| syn20 | List the top 20 SYN connections |
|
| syn20 | List the top 20 SYN connections |
|
||||||
| port_pro | Output all processes according to the port number |
|
| port_pro | Output all processes according to the port number |
|
||||||
|
|||||||
@@ -65,60 +65,90 @@ fi
|
|||||||
|
|
||||||
# Sort connection state
|
# Sort connection state
|
||||||
function sortcons() {
|
function sortcons() {
|
||||||
{
|
if (( $+commands[ss] )); then
|
||||||
LANG= ss -nat | awk 'NR > 1 {print $1}' \
|
LANG= ss -nat | awk 'NR > 1 {print $1}'
|
||||||
|| LANG= netstat -nat | awk 'NR > 2 {print $6}'
|
else
|
||||||
} | sort | uniq -c | sort -rn
|
LANG= netstat -nat | awk 'NR > 2 {print $6}'
|
||||||
|
fi | sort | uniq -c | sort -rn
|
||||||
}
|
}
|
||||||
|
|
||||||
# View all 80 Port Connections
|
function _systemadmin_validate_ports() {
|
||||||
|
local port
|
||||||
|
for port in "$@"; do
|
||||||
|
if [[ $port != <0-65535> || ( $port == 0* && $port != 0 ) ]]; then
|
||||||
|
print -u2 "systemadmin: invalid port '$port' (expected 0 to 65535 without leading zeros)"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# View all connections on the given ports (default 80 and 443)
|
||||||
function con80() {
|
function con80() {
|
||||||
{
|
local -a ports=("$@")
|
||||||
LANG= ss -nat || LANG= netstat -nat
|
(( $# )) || ports=(80 443)
|
||||||
} | grep -E ":80[^0-9]" | wc -l
|
_systemadmin_validate_ports "${ports[@]}" || return
|
||||||
|
if (( $+commands[ss] )); then
|
||||||
|
LANG= ss -nat
|
||||||
|
else
|
||||||
|
LANG= netstat -nat
|
||||||
|
fi | grep -E ":(${(j:|:)ports})([[:space:]]|$)" | wc -l
|
||||||
}
|
}
|
||||||
|
|
||||||
# On the connected IP sorted by the number of connections
|
# On the connected IP sorted by the number of connections
|
||||||
function sortconip() {
|
function sortconip() {
|
||||||
{
|
if (( $+commands[ss] )); then
|
||||||
LANG= ss -ntu | awk 'NR > 1 {print $6}' \
|
LANG= ss -ntu | awk 'NR > 1 {print $6}'
|
||||||
|| LANG= netstat -ntu | awk 'NR > 2 {print $5}'
|
else
|
||||||
} | cut -d: -f1 | sort | uniq -c | sort -n
|
LANG= netstat -ntu | awk 'NR > 2 {print $5}'
|
||||||
|
fi | cut -d: -f1 | sort | uniq -c | sort -n
|
||||||
}
|
}
|
||||||
|
|
||||||
# top20 of Find the number of requests on 80 port
|
# top20 of Find the number of requests on the given ports (default 80 and 443)
|
||||||
function req20() {
|
function req20() {
|
||||||
{
|
local -a ports=("$@")
|
||||||
LANG= ss -tn | awk '$4 ~ /:80$/ {print $5}' \
|
(( $# )) || ports=(80 443)
|
||||||
|| LANG= netstat -tn | awk '$4 ~ /:80$/ {print $5}'
|
_systemadmin_validate_ports "${ports[@]}" || return
|
||||||
} | awk -F: '{print $1}' | sort | uniq -c | sort -nr | head -n 20
|
if (( $+commands[ss] )); then
|
||||||
|
LANG= ss -tn
|
||||||
|
else
|
||||||
|
LANG= netstat -tn
|
||||||
|
fi | awk -v ports="${(j:|:)ports}" '$4 ~ ":("ports")$" {print $5}' \
|
||||||
|
| awk -F: '{print $1}' | sort | uniq -c | sort -nr | head -n 20
|
||||||
}
|
}
|
||||||
|
|
||||||
# top20 of Using tcpdump port 80 access to view
|
# top20 of Using tcpdump to view access to the given ports (default 80 and 443)
|
||||||
function http20() {
|
function http20() {
|
||||||
sudo tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr | head -n 20
|
local -a ports=("$@")
|
||||||
|
(( $# )) || ports=(80 443)
|
||||||
|
_systemadmin_validate_ports "${ports[@]}" || return
|
||||||
|
sudo tcpdump -i eth0 -tnn -c 1000 "dst port ${(j: or :)ports}" | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr | head -n 20
|
||||||
}
|
}
|
||||||
|
|
||||||
# top20 of Find time_wait connection
|
# top20 of Find time_wait connection
|
||||||
function timewait20() {
|
function timewait20() {
|
||||||
{
|
if (( $+commands[ss] )); then
|
||||||
LANG= ss -nat | awk 'NR > 1 && /TIME-WAIT/ {print $5}' \
|
LANG= ss -nat
|
||||||
|| LANG= netstat -nat | awk 'NR > 2 && /TIME_WAIT/ {print $5}'
|
else
|
||||||
} | sort | uniq -c | sort -rn | head -n 20
|
LANG= netstat -nat
|
||||||
|
fi | awk '/TIME[-_]WAIT/ {print $5}' | sort | uniq -c | sort -rn | head -n 20
|
||||||
}
|
}
|
||||||
|
|
||||||
# top20 of Find SYN connection
|
# top20 of Find SYN connection
|
||||||
function syn20() {
|
function syn20() {
|
||||||
{
|
if (( $+commands[ss] )); then
|
||||||
LANG= ss -an | awk '/SYN/ {print $5}' \
|
LANG= ss -an
|
||||||
|| LANG= netstat -an | awk '/SYN/ {print $5}'
|
else
|
||||||
} | awk -F: '{print $1}' | sort | uniq -c | sort -nr | head -n20
|
LANG= netstat -an
|
||||||
|
fi | awk '/SYN/ {print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr | head -n20
|
||||||
}
|
}
|
||||||
|
|
||||||
# Printing process according to the port number
|
# Printing process according to the port number
|
||||||
function port_pro() {
|
function port_pro() {
|
||||||
LANG= ss -ntlp | awk "NR > 1 && /:${1:-}/ {print \$6}" | sed 's/.*pid=\([^,]*\).*/\1/' \
|
if (( $+commands[ss] )); then
|
||||||
|| LANG= netstat -ntlp | awk "NR > 2 && /:${1:-}/ {print \$7}" | cut -d/ -f1
|
LANG= ss -ntlp | awk "NR > 1 && /:${1:-}/ {print \$6}" | sed 's/.*pid=\([^,]*\).*/\1/'
|
||||||
|
else
|
||||||
|
LANG= netstat -ntlp | awk "NR > 2 && /:${1:-}/ {print \$7}" | cut -d/ -f1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# top10 of gain access to the ip address
|
# top10 of gain access to the ip address
|
||||||
|
|||||||
@@ -24,6 +24,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_tailscale"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._tailscale"
|
||||||
zf_mv -f -- =( tailscale completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( tailscale completion zsh ) "$ZSH_CACHE_DIR/completions/_tailscale"
|
||||||
} &|
|
} &|
|
||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
# Generate and load task completion
|
# Generate and load task completion
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_task"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._task"
|
||||||
zf_mv -f -- =( task --completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( task --completion zsh ) "$ZSH_CACHE_DIR/completions/_task"
|
||||||
} &|
|
} &|
|
||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_timoni"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._timoni"
|
||||||
zf_mv -f -- =( timoni completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( timoni completion zsh ) "$ZSH_CACHE_DIR/completions/_timoni"
|
||||||
} &|
|
} &|
|
||||||
@@ -178,6 +178,11 @@ alias tmux=_zsh_tmux_plugin_run
|
|||||||
function _tmux_directory_session() {
|
function _tmux_directory_session() {
|
||||||
# current directory without leading path
|
# current directory without leading path
|
||||||
local dir=${PWD##*/}
|
local dir=${PWD##*/}
|
||||||
|
# tmux target syntax treats '.' and ':' as separators, a leading '$', '@' or '%'
|
||||||
|
# as an id and a leading '=' as an exact-match prefix, so a session named after
|
||||||
|
# such a directory can't be found on reattach
|
||||||
|
dir=${dir//[.:]/_}
|
||||||
|
dir=${dir/#[\$@%=]/_}
|
||||||
# md5 hash for the full working directory path
|
# md5 hash for the full working directory path
|
||||||
local md5=$(printf '%s' "$PWD" | md5sum | cut -d ' ' -f 1)
|
local md5=$(printf '%s' "$PWD" | md5sum | cut -d ' ' -f 1)
|
||||||
# human friendly unique session name for this directory
|
# human friendly unique session name for this directory
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ The plugin will generate a default archive filename based on the input:
|
|||||||
|
|
||||||
| Format | Description | Tool Used |
|
| Format | Description | Tool Used |
|
||||||
|:-----------------|:-------------------------------|:-----------------|
|
|:-----------------|:-------------------------------|:-----------------|
|
||||||
| `7z` | 7zip archive | `7z` |
|
| `7z` | 7zip archive | `7zz`,`7z`,`7za` |
|
||||||
| `bz2` | Bzip2-compressed file | `bzip2` |
|
| `bz2` | Bzip2-compressed file | `bzip2` |
|
||||||
| `gz` | Gzip-compressed file | `gzip` |
|
| `gz` | Gzip-compressed file | `gzip` |
|
||||||
| `lzma` | LZMA-compressed file | `lzma` |
|
| `lzma` | LZMA-compressed file | `lzma` |
|
||||||
|
|||||||
@@ -49,7 +49,17 @@ tlz (tar.lzma), txz (tar.xz), tZ (tar.Z), xz, Z, zip, and zst."
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
case "$ext" in
|
case "$ext" in
|
||||||
7z) 7z u "${output}" "${@}" ;;
|
7z)
|
||||||
|
if (( $+commands[7zz] )); then
|
||||||
|
7zz u "${output}" "${@}"
|
||||||
|
elif (( $+commands[7z] )); then
|
||||||
|
7z u "${output}" "${@}"
|
||||||
|
elif (( $+commands[7za] )); then
|
||||||
|
7za u "${output}" "${@}"
|
||||||
|
else
|
||||||
|
echo "ua: cannot create 7z files: install 7zz, 7z or 7za" >&2
|
||||||
|
return 1
|
||||||
|
fi ;;
|
||||||
bz2) bzip2 -vcf "${@}" > "${output}" ;;
|
bz2) bzip2 -vcf "${@}" > "${output}" ;;
|
||||||
gz) gzip -vcf "${@}" > "${output}" ;;
|
gz) gzip -vcf "${@}" > "${output}" ;;
|
||||||
lzma) lzma -vc -T0 "${@}" > "${output}" ;;
|
lzma) lzma -vc -T0 "${@}" > "${output}" ;;
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ fi
|
|||||||
# Overwrites the file each time as completions might change with uv versions.
|
# Overwrites the file each time as completions might change with uv versions.
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_uv"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._uv"
|
||||||
zf_mv -f -- =( uv generate-shell-completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( uv generate-shell-completion zsh ) "$ZSH_CACHE_DIR/completions/_uv"
|
||||||
} &|
|
} &|
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_uvx"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._uvx"
|
||||||
zf_mv -f -- =( uvx --generate-shell-completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( uvx --generate-shell-completion zsh ) "$ZSH_CACHE_DIR/completions/_uvx"
|
||||||
} &|
|
} &|
|
||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_volta"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._volta"
|
||||||
zf_mv -f -- =( volta completions zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( volta completions zsh ) "$ZSH_CACHE_DIR/completions/_volta"
|
||||||
} &|
|
} &|
|
||||||
+12
-1
@@ -38,6 +38,17 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
|
|||||||
|
|
||||||
## News
|
## News
|
||||||
|
|
||||||
|
### v2.0.1 (October 1, 2026)
|
||||||
|
|
||||||
|
- **Database writes now work with `setopt NO_CLOBBER`.** Under `NO_CLOBBER`,
|
||||||
|
every database write could fail with `can't clobber parameter tmpfd containing
|
||||||
|
file descriptor 0`, even when the database already existed. That error no longer
|
||||||
|
occurs ([#81](https://github.com/agkozak/zsh-z/issues/81)).
|
||||||
|
- **Database and lockfile creation now works with `setopt NO_CLOBBER`.** With
|
||||||
|
`NO_CLOBBER` set and `APPEND_CREATE` unset, Zsh-z could not create a missing
|
||||||
|
database or lockfile. It now creates them without changing your shell options or
|
||||||
|
losing existing directory history ([#105](https://github.com/agkozak/zsh-z/issues/105)).
|
||||||
|
|
||||||
### v2.0 (August 14, 2026)
|
### v2.0 (August 14, 2026)
|
||||||
|
|
||||||
Version **2.0** is a major step forward, and these are the changes most worth knowing about:
|
Version **2.0** is a major step forward, and these are the changes most worth knowing about:
|
||||||
@@ -47,7 +58,7 @@ Version **2.0** is a major step forward, and these are the changes most worth kn
|
|||||||
- **Safer, crash-resistant concurrent writes.** Writes are now guarded by a dedicated, stable lockfile using `zsh/system` file locking, with a bounded wait for lock acquisition (the new [`ZSHZ_LOCK_TIMEOUT`](#settings), default `1` second). Write errors are handled gracefully, and locks are always released even if a write is interrupted. On Cygwin and MSYS2 a write is also retried briefly if Windows refuses it: a virus scanner or the search indexer that opens the database in the instant between its being written and its being moved into place makes the move fail, which used to lose that one directory silently. Zsh-z now retries the move briefly.
|
- **Safer, crash-resistant concurrent writes.** Writes are now guarded by a dedicated, stable lockfile using `zsh/system` file locking, with a bounded wait for lock acquisition (the new [`ZSHZ_LOCK_TIMEOUT`](#settings), default `1` second). Write errors are handled gracefully, and locks are always released even if a write is interrupted. On Cygwin and MSYS2 a write is also retried briefly if Windows refuses it: a virus scanner or the search indexer that opens the database in the instant between its being written and its being moved into place makes the move fail, which used to lose that one directory silently. Zsh-z now retries the move briefly.
|
||||||
- **Your database file now has `600` permissions** -- readable and writable only by you -- so that other users on a shared system cannot read your directory history ([#92](https://github.com/agkozak/zsh-z/issues/92)). On Zsh 5+ this uses the in-process `zf_chmod` builtin; on Zsh 4.3.11 it uses a `umask`-in-a-subshell technique that avoids the fork-and-exec of an external `chmod`.
|
- **Your database file now has `600` permissions** -- readable and writable only by you -- so that other users on a shared system cannot read your directory history ([#92](https://github.com/agkozak/zsh-z/issues/92)). On Zsh 5+ this uses the in-process `zf_chmod` builtin; on Zsh 4.3.11 it uses a `umask`-in-a-subshell technique that avoids the fork-and-exec of an external `chmod`.
|
||||||
- **`COMPLETE_ALIASES` works automatically in normal setups.** Tab completion no longer breaks when you have `setopt COMPLETE_ALIASES` enabled. Zsh-z registers the alias automatically on the first Tab press, so the manual `compdef` line that earlier versions required is no longer necessary. [See below](#complete_aliases).
|
- **`COMPLETE_ALIASES` works automatically in normal setups.** Tab completion no longer breaks when you have `setopt COMPLETE_ALIASES` enabled. Zsh-z registers the alias automatically on the first Tab press, so the manual `compdef` line that earlier versions required is no longer necessary. [See below](#complete_aliases).
|
||||||
- **Fixed a `can't clobber parameter tmpfd` error on some Zsh builds.** On certain Zsh builds, every database write could fail with `can't clobber parameter tmpfd containing file descriptor 0`, leaving an error at each new prompt. The file descriptor used for the temporary database file is now held in an unset scalar rather than one seeded with `0`, so the write never trips Zsh's file-descriptor-clobber guard ([#81](https://github.com/agkozak/zsh-z/issues/81)).
|
- **Fixed a `can't clobber parameter tmpfd` error on some Zsh builds.** On certain Zsh builds, every database write could fail with `can't clobber parameter tmpfd containing file descriptor 0`, leaving an error at each new prompt ([#81](https://github.com/agkozak/zsh-z/issues/81)). *Correction:* the error occurs under `setopt NO_CLOBBER`, and the v2.0 change did not fix it there; v2.0.1 does.
|
||||||
- **A misconfigured database file no longer closes your shell -- or nags you at every prompt.** When `ZSHZ_DATA` points at a directory, or names a file without a directory, Zsh-z now reports the problem and returns instead of calling `exit`. The per-prompt `--add` stays quiet about it, so you are told once, when you actually run `z`, rather than at every prompt ([#103](https://github.com/agkozak/zsh-z/issues/103); props @ahjota).
|
- **A misconfigured database file no longer closes your shell -- or nags you at every prompt.** When `ZSHZ_DATA` points at a directory, or names a file without a directory, Zsh-z now reports the problem and returns instead of calling `exit`. The per-prompt `--add` stays quiet about it, so you are told once, when you actually run `z`, rather than at every prompt ([#103](https://github.com/agkozak/zsh-z/issues/103); props @ahjota).
|
||||||
- **`z -x` can now remove the entry for a directory that no longer exists -- and can no longer crash Zsh 4.3.11.** The removal target used to have to exist on disk, so a database entry whose directory had been deleted -- exactly the entry you most want gone -- could not be removed. `z -x /deleted/dir` (and `z -xR`) now canonicalizes the argument without requiring it to exist, resolving symlinks in as much of the path as is still present. The same change fixes a crash on Zsh 4.3.11, where an upstream bug makes `${x:A}` segfault when the top-level component of the path is missing: `z -x /gone/sub` -- or a `ZSHZ_DATA` pointing into a missing top-level directory -- could kill the shell there.
|
- **`z -x` can now remove the entry for a directory that no longer exists -- and can no longer crash Zsh 4.3.11.** The removal target used to have to exist on disk, so a database entry whose directory had been deleted -- exactly the entry you most want gone -- could not be removed. `z -x /deleted/dir` (and `z -xR`) now canonicalizes the argument without requiring it to exist, resolving symlinks in as much of the path as is still present. The same change fixes a crash on Zsh 4.3.11, where an upstream bug makes `${x:A}` segfault when the top-level component of the path is missing: `z -x /gone/sub` -- or a `ZSHZ_DATA` pointing into a missing top-level directory -- could kill the shell there.
|
||||||
- **More robust startup and operation.** A version check on an unsupported Zsh no longer risks exiting your interactive shell.
|
- **More robust startup and operation.** A version check on an unsupported Zsh no longer risks exiting your interactive shell.
|
||||||
|
|||||||
+14
-13
@@ -371,16 +371,17 @@ zshz() {
|
|||||||
# before the lock is taken, and on Cygwin/MSYS2 a concurrent writer's rename
|
# before the lock is taken, and on Cygwin/MSYS2 a concurrent writer's rename
|
||||||
# passes through a window in which the datafile is unlinked or delete-
|
# passes through a window in which the datafile is unlinked or delete-
|
||||||
# pending, so any second syscall on the path (chmod) -- or even the creating
|
# pending, so any second syscall on the path (chmod) -- or even the creating
|
||||||
# open itself -- can fail spuriously. Append mode (>>) creates the file
|
# open itself -- can fail spuriously. Forced append redirection (>>|) creates
|
||||||
# without truncating one that a concurrent writer has just renamed into
|
# the file even under NO_CLOBBER with APPEND_CREATE disabled, without
|
||||||
# place. The first attempt is silent; if the file still does not exist
|
# truncating one that a concurrent writer has just renamed into place.
|
||||||
|
# The first attempt is silent; if the file still does not exist
|
||||||
# afterward (so no concurrent writer supplied it), retry loudly so that real
|
# afterward (so no concurrent writer supplied it), retry loudly so that real
|
||||||
# failures (directory permissions, read-only filesystem) reach the user.
|
# failures (directory permissions, read-only filesystem) reach the user.
|
||||||
[[ -f $datafile ]] || {
|
[[ -f $datafile ]] || {
|
||||||
mkdir -p "${datafile:h}" &&
|
mkdir -p "${datafile:h}" &&
|
||||||
( umask 077; : >> "$datafile" ) 2> /dev/null ||
|
( umask 077; : >>| "$datafile" ) 2> /dev/null ||
|
||||||
[[ -f $datafile ]] ||
|
[[ -f $datafile ]] ||
|
||||||
( umask 077; : >> "$datafile" )
|
( umask 077; : >>| "$datafile" )
|
||||||
# When $ZSHZ_OWNER is set (e.g. under `sudo -s'), hand the freshly created
|
# When $ZSHZ_OWNER is set (e.g. under `sudo -s'), hand the freshly created
|
||||||
# file off to that user immediately, so a query-only invocation can't leave
|
# file off to that user immediately, so a query-only invocation can't leave
|
||||||
# behind a root-owned .z that the normal-user shell can't read. `-h' so a
|
# behind a root-owned .z that the normal-user shell can't read. `-h' so a
|
||||||
@@ -525,14 +526,14 @@ zshz() {
|
|||||||
# two-inodes race the stable lockfile exists to prevent.
|
# two-inodes race the stable lockfile exists to prevent.
|
||||||
# Under $ZSHZ_OWNER all of this runs with root's authority on a path the
|
# Under $ZSHZ_OWNER all of this runs with root's authority on a path the
|
||||||
# unprivileged owner controls, and every step follows a symlink: `-f'
|
# unprivileged owner controls, and every step follows a symlink: `-f'
|
||||||
# tests the target, `>>' creates a dangling one, and flock opens it.
|
# tests the target, `>>|' creates a dangling one, and flock opens it.
|
||||||
# $datafile survives a planted link only because the `mv' below replaces
|
# $datafile survives a planted link only because the `mv' below replaces
|
||||||
# it outright; the lockfile is deliberately never removed, so a symlink
|
# it outright; the lockfile is deliberately never removed, so a symlink
|
||||||
# here would persist and be acted on at every subsequent write. Refuse.
|
# here would persist and be acted on at every subsequent write. Refuse.
|
||||||
local _lock_owner=${ZSHZ_OWNER:-${_Z_OWNER}}
|
local _lock_owner=${ZSHZ_OWNER:-${_Z_OWNER}}
|
||||||
[[ -n $_lock_owner && -L $lockfile ]] && return 1
|
[[ -n $_lock_owner && -L $lockfile ]] && return 1
|
||||||
if [[ ! -f $lockfile ]]; then
|
if [[ ! -f $lockfile ]]; then
|
||||||
( umask 077; : >> "$lockfile" ) 2> /dev/null
|
( umask 077; : >>| "$lockfile" ) 2> /dev/null
|
||||||
[[ -n $_lock_owner ]] &&
|
[[ -n $_lock_owner ]] &&
|
||||||
${ZSHZ[CHOWN]} -h "${_lock_owner}:$(id -ng "${_lock_owner}")" "$lockfile"
|
${ZSHZ[CHOWN]} -h "${_lock_owner}:$(id -ng "${_lock_owner}")" "$lockfile"
|
||||||
fi
|
fi
|
||||||
@@ -585,13 +586,13 @@ zshz() {
|
|||||||
# Discard entries that are incomplete or incorrectly formatted
|
# Discard entries that are incomplete or incorrectly formatted
|
||||||
lines=( ${(M)lines:#/*\|[[:digit:]]##[.,]#[[:digit:]]#\|[[:digit:]]##} )
|
lines=( ${(M)lines:#/*\|[[:digit:]]##[.,]#[[:digit:]]#\|[[:digit:]]##} )
|
||||||
|
|
||||||
# Hold the fd in an *unset* scalar, not `integer tmpfd' (which seeds it
|
# Explicitly unset the local scalar before allocating a file descriptor.
|
||||||
# with 0). On some Zsh builds, `exec {tmpfd}>|...' refuses to clobber a
|
# Under NO_CLOBBER, even an empty scalar can be treated as fd 0 (stdin),
|
||||||
# parameter already holding a number that names an open fd -- and 0 is
|
# causing `exec {tmpfd}>|...' to refuse to overwrite it. The `>|' only
|
||||||
# stdin, always open -- yielding "can't clobber parameter tmpfd
|
# overrides file clobber protection, not the descriptor parameter check.
|
||||||
# containing file descriptor 0". An empty scalar isn't a valid fd, so
|
# See https://github.com/agkozak/zsh-z/issues/81
|
||||||
# the guard never fires. See https://github.com/agkozak/zsh-z/issues/81
|
|
||||||
local tmpfd
|
local tmpfd
|
||||||
|
unset tmpfd
|
||||||
case $action in
|
case $action in
|
||||||
--add)
|
--add)
|
||||||
# When zf_chmod isn't available (Zsh 4.3.11), avoid the
|
# When zf_chmod isn't available (Zsh 4.3.11), avoid the
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
PROMPT="${FG[117]}%~%{$reset_color%}\$(git_prompt_info)\$(virtualenv_prompt_info)${FG[133]}\$(git_prompt_status) ${FG[077]}ᐅ%{$reset_color%} "
|
PROMPT="${FG[117]}%~%{$reset_color%}\$(git_prompt_info)\$(virtualenv_prompt_info)${FG[133]}\$(git_prompt_status) ${FG[077]}%(?..${FG[160]}[%?] )ᐅ%{$reset_color%} "
|
||||||
|
|
||||||
ZSH_THEME_GIT_PROMPT_PREFIX=" ${FG[012]}("
|
ZSH_THEME_GIT_PROMPT_PREFIX=" ${FG[012]}("
|
||||||
ZSH_THEME_GIT_PROMPT_SUFFIX="${FG[012]})%{$reset_color%}"
|
ZSH_THEME_GIT_PROMPT_SUFFIX="${FG[012]})%{$reset_color%}"
|
||||||
|
|||||||
Reference in new issue
Block a user