mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-11-26 18:33:03 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2cd6260c5 |
No files matched your search
+2
-2
@@ -392,8 +392,8 @@ function _omz::plugin::enable {
|
|||||||
|
|
||||||
# Enable plugins awk script
|
# Enable plugins awk script
|
||||||
local awk_script="
|
local awk_script="
|
||||||
# if plugins=() is in oneline form (empty or not), substitute ) with new plugins and go to the next line
|
# if plugins=() is in oneline form, substitute ) with new plugins and go to the next line
|
||||||
/^[ \t]*plugins=\([^#]*\).*\$/ {
|
/^[ \t]*plugins=\([^#]+\).*\$/ {
|
||||||
sub(/\)/, \" $add_plugins&\")
|
sub(/\)/, \" $add_plugins&\")
|
||||||
print \$0
|
print \$0
|
||||||
next
|
next
|
||||||
|
|||||||
+14
-11
@@ -247,17 +247,20 @@ function aws_profiles() {
|
|||||||
aws --no-cli-pager configure list-profiles 2> /dev/null
|
aws --no-cli-pager configure list-profiles 2> /dev/null
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
local line words
|
local file line words
|
||||||
# Only read the section headers, so the credentials never enter the shell
|
for file in "$config" "$creds"; do
|
||||||
for line in "${(@f)$(command grep -h '^[[:space:]]*\[' -- "$config" "$creds" 2> /dev/null)}"; do
|
# Only read the section headers, so the credentials never enter the shell
|
||||||
line=${line#*\[} # drop up to the first [
|
for line in "${(@f)$(command grep '^[[:space:]]*\[' -- "$file" 2> /dev/null)}"; do
|
||||||
line=${line%\]*} # drop from the last ] (comments, CR)
|
line=${line#*\[} # drop up to the first [
|
||||||
words=(${=line})
|
line=${line%\]*} # drop from the last ] (comments, CR)
|
||||||
if (( $#words == 1 )); then
|
words=(${=line})
|
||||||
print -r -- $words[1] # [default], or [foo] in the credentials file
|
if (( $#words == 1 )); then
|
||||||
elif (( $#words == 2 )) && [[ $words[1] == profile ]]; then
|
# [default], or any [foo] in the credentials file
|
||||||
print -r -- $words[2]
|
[[ $file == $creds || $words[1] == default ]] && print -r -- $words[1]
|
||||||
fi
|
elif (( $#words == 2 )) && [[ $words[1] == profile ]]; then
|
||||||
|
print -r -- $words[2]
|
||||||
|
fi
|
||||||
|
done
|
||||||
done | command sort -u
|
done | command sort -u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ colorize_less() {
|
|||||||
# (e.g. when not scrolled to the bottom) while already the next file will be displayed.
|
# (e.g. when not scrolled to the bottom) while already the next file will be displayed.
|
||||||
local LESSOPEN="| zsh -c 'source \"$ZSH_COLORIZE_PLUGIN_PATH\"; \
|
local LESSOPEN="| zsh -c 'source \"$ZSH_COLORIZE_PLUGIN_PATH\"; \
|
||||||
ZSH_COLORIZE_TOOL=$ZSH_COLORIZE_TOOL ZSH_COLORIZE_STYLE=$ZSH_COLORIZE_STYLE \
|
ZSH_COLORIZE_TOOL=$ZSH_COLORIZE_TOOL ZSH_COLORIZE_STYLE=$ZSH_COLORIZE_STYLE \
|
||||||
ZSH_COLORIZE_CHROMA_FORMATTER=$ZSH_COLORIZE_CHROMA_FORMATTER \
|
|
||||||
colorize_cat %s 2> /dev/null'"
|
colorize_cat %s 2> /dev/null'"
|
||||||
|
|
||||||
# LESSCLOSE will be set to prevent any errors by executing a user script
|
# LESSCLOSE will be set to prevent any errors by executing a user script
|
||||||
|
|||||||
@@ -135,40 +135,9 @@ EOF
|
|||||||
(*.deb)
|
(*.deb)
|
||||||
command mkdir -p "control" "data"
|
command mkdir -p "control" "data"
|
||||||
ar vx "$full_path" > /dev/null
|
ar vx "$full_path" > /dev/null
|
||||||
local member= dest= failed=0
|
builtin cd -q control; extract ../control.tar.*
|
||||||
for member in control.tar.* data.tar.*; do
|
builtin cd -q ../data; extract ../data.tar.*
|
||||||
dest="${member%%.*}"
|
builtin cd -q ..; command rm *.tar.* debian-binary ;;
|
||||||
case "${member:l}" in
|
|
||||||
(*.tar.gz)
|
|
||||||
(( $+commands[pigz] )) && { tar -I pigz -xvf "$member" -C "$dest" } \
|
|
||||||
|| tar zxvf "$member" -C "$dest" ;;
|
|
||||||
(*.tar.bz2)
|
|
||||||
(( $+commands[pbzip2] )) && { tar -I pbzip2 -xvf "$member" -C "$dest" } \
|
|
||||||
|| tar xvjf "$member" -C "$dest" ;;
|
|
||||||
(*.tar.xz)
|
|
||||||
# .deb members are small, so skip extract()'s pixz fast path and
|
|
||||||
# let tar use its built-in xz support (or a plain pipe).
|
|
||||||
tar --xz --help &> /dev/null \
|
|
||||||
&& tar --xz -xvf "$member" -C "$dest" \
|
|
||||||
|| xzcat "$member" | tar xvf - -C "$dest" ;;
|
|
||||||
(*.tar.zst)
|
|
||||||
tar --zstd --help &> /dev/null \
|
|
||||||
&& tar --zstd -xvf "$member" -C "$dest" \
|
|
||||||
|| zstdcat "$member" | tar xvf - -C "$dest" ;;
|
|
||||||
(*.tar)
|
|
||||||
tar xvf "$member" -C "$dest" ;;
|
|
||||||
(*)
|
|
||||||
echo "extract: cannot extract unexpected .deb member '$member'" >&2
|
|
||||||
failed=1
|
|
||||||
success=1 ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
if (( failed )); then
|
|
||||||
# Keep the archive members so the unexpected one can be inspected.
|
|
||||||
echo "extract: leaving .deb members in place" >&2
|
|
||||||
else
|
|
||||||
command rm *.tar.* debian-binary
|
|
||||||
fi ;;
|
|
||||||
(*.zst) unzstd --stdout "$full_path" > "${file:t:r}" ;;
|
(*.zst) unzstd --stdout "$full_path" > "${file:t:r}" ;;
|
||||||
(*.cab|*.exe) cabextract "$full_path" ;;
|
(*.cab|*.exe) cabextract "$full_path" ;;
|
||||||
(*.cpio|*.obscpio) cpio -idmvF "$full_path" ;;
|
(*.cpio|*.obscpio) cpio -idmvF "$full_path" ;;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
setopt err_return
|
setopt err_return
|
||||||
|
|
||||||
for tool in ar lzma unlzma uncompress; do
|
for tool in lzma unlzma uncompress; do
|
||||||
(( $+commands[$tool] )) || {
|
(( $+commands[$tool] )) || {
|
||||||
print -u2 -r -- "These tests require $tool."
|
print -u2 -r -- "These tests require $tool."
|
||||||
exit 1
|
exit 1
|
||||||
@@ -46,120 +46,6 @@ check_extract() {
|
|||||||
print -r -- "PASS: $extension ($mode)"
|
print -r -- "PASS: $extension ($mode)"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Extracting a .deb must place the control members directly in <name>/control
|
|
||||||
# and the data members directly in <name>/data, whatever their member count.
|
|
||||||
check_deb_extract() {
|
|
||||||
local mode=$1
|
|
||||||
local case_dir="$test_dir/deb-$mode"
|
|
||||||
mkdir -p "$case_dir/source files" "$case_dir/work/target dir" \
|
|
||||||
"$case_dir/src/ctl" "$case_dir/src/data/usr/bin"
|
|
||||||
print -r -- "postinst script" > "$case_dir/src/ctl/postinst"
|
|
||||||
print -r -- "conf:1" > "$case_dir/src/ctl/conffiles"
|
|
||||||
print -r -- "app main" > "$case_dir/src/data/usr/bin/app"
|
|
||||||
tar czf "$case_dir/src/control.tar.gz" -C "$case_dir/src/ctl" conffiles postinst
|
|
||||||
tar czf "$case_dir/src/data.tar.gz" -C "$case_dir/src/data" usr
|
|
||||||
print -r -- "2.0" > "$case_dir/src/debian-binary"
|
|
||||||
(
|
|
||||||
builtin cd "$case_dir/src"
|
|
||||||
rm -f "$case_dir/source files/pkg.deb"
|
|
||||||
ar rS "$case_dir/source files/pkg.deb" debian-binary control.tar.gz data.tar.gz
|
|
||||||
)
|
|
||||||
local archive="$case_dir/source files/pkg.deb"
|
|
||||||
|
|
||||||
builtin cd "$case_dir/work"
|
|
||||||
local base="$PWD/pkg"
|
|
||||||
local -a args
|
|
||||||
case "$mode" in
|
|
||||||
target)
|
|
||||||
args=(-t 'target dir')
|
|
||||||
base="$PWD/target dir/pkg"
|
|
||||||
;;
|
|
||||||
remove) args=(-r) ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
() {
|
|
||||||
emulate -L zsh
|
|
||||||
extract "${args[@]}" "$archive"
|
|
||||||
} || return 1
|
|
||||||
|
|
||||||
[[ -f "$base/control/conffiles" && -f "$base/control/postinst" ]] ||
|
|
||||||
{ print -u2 -r -- "$mode: control members not extracted into $base/control"; return 1 }
|
|
||||||
[[ -f "$base/data/usr/bin/app" ]] ||
|
|
||||||
{ print -u2 -r -- "$mode: data members not extracted into $base/data"; return 1 }
|
|
||||||
[[ ! -d "$base/control/control" && ! -d "$base/data/data" ]] ||
|
|
||||||
{ print -u2 -r -- "$mode: deb extraction double-nested the member directories"; return 1 }
|
|
||||||
[[ ! -e "$base/control.tar.gz" && ! -e "$base/data.tar.gz" && ! -e "$base/debian-binary" ]] ||
|
|
||||||
{ print -u2 -r -- "$mode: deb member debris left behind"; return 1 }
|
|
||||||
if [[ $mode == remove ]]; then
|
|
||||||
[[ ! -e $archive ]]
|
|
||||||
else
|
|
||||||
[[ -f $archive ]]
|
|
||||||
fi
|
|
||||||
print -r -- "PASS: deb ($mode)"
|
|
||||||
}
|
|
||||||
|
|
||||||
# An unexpected member must be reported and left on disk for inspection, and
|
|
||||||
# the cleanup must not delete the other members around it either.
|
|
||||||
check_deb_unexpected_member() {
|
|
||||||
local case_dir="$test_dir/deb-unexpected"
|
|
||||||
mkdir -p "$case_dir/src/ctl" "$case_dir/src/data/usr/bin"
|
|
||||||
print -r -- "postinst script" > "$case_dir/src/ctl/postinst"
|
|
||||||
print -r -- "app main" > "$case_dir/src/data/usr/bin/app"
|
|
||||||
tar czf "$case_dir/src/control.tar.gz" -C "$case_dir/src/ctl" postinst
|
|
||||||
print -r -- "unknown compression" > "$case_dir/src/control.tar.weird"
|
|
||||||
tar czf "$case_dir/src/data.tar.gz" -C "$case_dir/src/data" usr
|
|
||||||
print -r -- "2.0" > "$case_dir/src/debian-binary"
|
|
||||||
(
|
|
||||||
builtin cd "$case_dir/src"
|
|
||||||
ar rS "$case_dir/pkg.deb" debian-binary control.tar.weird data.tar.gz
|
|
||||||
)
|
|
||||||
|
|
||||||
builtin cd "$case_dir"
|
|
||||||
() {
|
|
||||||
emulate -L zsh
|
|
||||||
extract "$case_dir/pkg.deb"
|
|
||||||
} || return 1
|
|
||||||
|
|
||||||
[[ -f "$case_dir/pkg/data/usr/bin/app" ]] ||
|
|
||||||
{ print -u2 -r -- "deb-unexpected: known members were not extracted"; return 1 }
|
|
||||||
[[ -f "$case_dir/pkg/control.tar.weird" && -f "$case_dir/pkg/data.tar.gz" &&
|
|
||||||
-f "$case_dir/pkg/debian-binary" ]] ||
|
|
||||||
{ print -u2 -r -- "deb-unexpected: archive members were deleted"; return 1 }
|
|
||||||
print -r -- "PASS: deb (unexpected member)"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Passing more than one .deb in a single call must not leak the loop variables
|
|
||||||
# between archives; the stale `member`/`dest` locals used to be printed by the
|
|
||||||
# second archive.
|
|
||||||
check_deb_multiple() {
|
|
||||||
local case_dir="$test_dir/deb-multiple"
|
|
||||||
mkdir -p "$case_dir/src/ctl" "$case_dir/src/data/usr/bin"
|
|
||||||
print -r -- "postinst script" > "$case_dir/src/ctl/postinst"
|
|
||||||
print -r -- "app main" > "$case_dir/src/data/usr/bin/app"
|
|
||||||
tar czf "$case_dir/src/control.tar.gz" -C "$case_dir/src/ctl" postinst
|
|
||||||
tar czf "$case_dir/src/data.tar.gz" -C "$case_dir/src/data" usr
|
|
||||||
print -r -- "2.0" > "$case_dir/src/debian-binary"
|
|
||||||
(
|
|
||||||
builtin cd "$case_dir/src"
|
|
||||||
ar rS "$case_dir/one.deb" debian-binary control.tar.gz data.tar.gz
|
|
||||||
ar rS "$case_dir/two.deb" debian-binary control.tar.gz data.tar.gz
|
|
||||||
)
|
|
||||||
|
|
||||||
builtin cd "$case_dir"
|
|
||||||
local output
|
|
||||||
output=$( () {
|
|
||||||
emulate -L zsh
|
|
||||||
extract one.deb two.deb
|
|
||||||
} 2>&1 ) || return 1
|
|
||||||
|
|
||||||
[[ $output != *member=* && $output != *dest=* ]] ||
|
|
||||||
{ print -u2 -r -- "deb-multiple: stale loop variables were printed"; return 1 }
|
|
||||||
[[ -f one/control/postinst && -f one/data/usr/bin/app &&
|
|
||||||
-f two/control/postinst && -f two/data/usr/bin/app ]] ||
|
|
||||||
{ print -u2 -r -- "deb-multiple: both archives were not extracted"; return 1 }
|
|
||||||
print -r -- "PASS: deb (multiple archives)"
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
print -r -- hello > "$test_dir/plain"
|
print -r -- hello > "$test_dir/plain"
|
||||||
lzma -c "$test_dir/plain" > "$test_dir/fixture.lzma"
|
lzma -c "$test_dir/plain" > "$test_dir/fixture.lzma"
|
||||||
@@ -172,11 +58,6 @@ check_deb_multiple() {
|
|||||||
check_extract "$extension" "$mode"
|
check_extract "$extension" "$mode"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
check_deb_extract default
|
|
||||||
check_deb_extract target
|
|
||||||
check_deb_extract remove
|
|
||||||
check_deb_unexpected_member
|
|
||||||
check_deb_multiple
|
|
||||||
print 'All extract compressed-file tests passed.'
|
print 'All extract compressed-file tests passed.'
|
||||||
} always {
|
} always {
|
||||||
builtin cd "$original_dir"
|
builtin cd "$original_dir"
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
# fnox
|
|
||||||
|
|
||||||
Adds shell integration and completions for [fnox](https://github.com/jdx/fnox), a tool for provider-agnostic secret injection.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
[Install fnox](https://fnox.jdx.dev/guide/quick-start.html), then add it to your plugins in `~/.zshrc`:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(fnox)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
See the [fnox documentation](https://fnox.jdx.dev/guide/shell-integration.html) for shell integration and usage.
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
if (( ! $+commands[fnox] )); then
|
|
||||||
# if we don't have fnox at all just bail out
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
eval "$(fnox activate zsh)"
|
|
||||||
|
|
||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
|
||||||
# bind it to `fnox`. Otherwise, compinit will have already done that.
|
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnox" ]]; then
|
|
||||||
typeset -g -A _comps
|
|
||||||
autoload -Uz _fnox
|
|
||||||
_comps[fnox]=_fnox
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Regenerate completions when the executable changes.
|
|
||||||
if [[ ! -s "$ZSH_CACHE_DIR/completions/_fnox" || "$commands[fnox]" -nt "$ZSH_CACHE_DIR/completions/_fnox" ]]; then
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
|
||||||
() {
|
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._fnox"
|
|
||||||
zf_mv -f -- =( fnox completion zsh ) "$ZSH_CACHE_DIR/completions/_fnox"
|
|
||||||
} &|
|
|
||||||
fi
|
|
||||||
@@ -12,7 +12,7 @@ plugins=(... git-commit)
|
|||||||
## Syntax
|
## Syntax
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
git <type> [(-s, --scope) "<scope>"] [(-a, --attention)] [(-b, --body) "<body>"] "<message>"
|
git <type> [(-s, --scope) "<scope>"] [(-a, --attention)] "<message>"
|
||||||
```
|
```
|
||||||
|
|
||||||
Where `type` is one of the following:
|
Where `type` is one of the following:
|
||||||
@@ -30,9 +30,6 @@ Where `type` is one of the following:
|
|||||||
- `test`
|
- `test`
|
||||||
- `wip`
|
- `wip`
|
||||||
|
|
||||||
The optional `-b` / `--body` becomes the commit body (a blank line after the subject), as defined by
|
|
||||||
[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary).
|
|
||||||
|
|
||||||
> NOTE: the subcommand for `revert` type is `rev`, as otherwise it conflicts with the
|
> NOTE: the subcommand for `revert` type is `rev`, as otherwise it conflicts with the
|
||||||
> git command of the same name. It will still generate a commit message in the format
|
> git command of the same name. It will still generate a commit message in the format
|
||||||
> `revert: <message>`
|
> `revert: <message>`
|
||||||
@@ -42,7 +39,6 @@ The optional `-b` / `--body` becomes the commit body (a blank line after the sub
|
|||||||
| Git subcommand | Command |
|
| Git subcommand | Command |
|
||||||
| --------------------------------------------- | ---------------------------------------------------- |
|
| --------------------------------------------- | ---------------------------------------------------- |
|
||||||
| `git style "remove trailing whitespace"` | `git commit -m "style: remove trailing whitespace"` |
|
| `git style "remove trailing whitespace"` | `git commit -m "style: remove trailing whitespace"` |
|
||||||
| `git wip "work in progress"` | `git commit -m "wip: work in progress"` |
|
| `git wip "work in progress"` | `git commit -m "work in progress"` |
|
||||||
| `git fix -s "router" "correct redirect link"` | `git commit -m "fix(router): correct redirect link"` |
|
| `git fix -s "router" "correct redirect link"` | `git commit -m "fix(router): correct redirect link"` |
|
||||||
| `git rev -s "api" "rollback v2"` | `git commit -m "revert(api): rollback v2"` |
|
| `git rev -s "api" "rollback v2"` | `git commit -m "revert(api): rollback v2"` |
|
||||||
| `git feat -s "auth" -b "Keep session across redirects." "add login redirect"` | `git commit -m "feat(auth): add login redirect" -m "Keep session across redirects."` |
|
|
||||||
@@ -12,11 +12,11 @@ _omz_git_commit() {
|
|||||||
if [[ "$_type" == rev ]]; then
|
if [[ "$_type" == rev ]]; then
|
||||||
_type=revert
|
_type=revert
|
||||||
fi
|
fi
|
||||||
local _scope _attention _message _body
|
local _scope _attention _message
|
||||||
while [ $# -ne 0 ]; do
|
while [ $# -ne 0 ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-s | --scope )
|
-s | --scope )
|
||||||
if [ -z "$2" ]; then
|
if [ -z $2 ]; then
|
||||||
echo >&2 "Missing scope!"
|
echo >&2 "Missing scope!"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@@ -27,20 +27,12 @@ _omz_git_commit() {
|
|||||||
_attention="!"
|
_attention="!"
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
-b | --body )
|
|
||||||
if [ -z "$2" ]; then
|
|
||||||
echo >&2 "Missing body!"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
_body="$2"
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
* )
|
* )
|
||||||
_message="${_message} $1"
|
_message="${_message} $1"
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
git commit -m "${_type}${_scope:+(${_scope})}${_attention}:${_message}" ${_body:+-m} ${_body:+"$_body"}
|
git commit -m "${_type}${_scope:+(${_scope})}${_attention}:${_message}"
|
||||||
}
|
}
|
||||||
_omz_git_commit "$@"
|
_omz_git_commit "$@"
|
||||||
@@ -21,7 +21,7 @@ plugins=(... git)
|
|||||||
| `gapa` | `git add --patch` |
|
| `gapa` | `git add --patch` |
|
||||||
| `gau` | `git add --update` |
|
| `gau` | `git add --update` |
|
||||||
| `gav` | `git add --verbose` |
|
| `gav` | `git add --verbose` |
|
||||||
| `gwip` | `git add -A; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"` |
|
| `gwip` | `git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"` |
|
||||||
| `gam` | `git am` |
|
| `gam` | `git am` |
|
||||||
| `gama` | `git am --abort` |
|
| `gama` | `git am --abort` |
|
||||||
| `gamc` | `git am --continue` |
|
| `gamc` | `git am --continue` |
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ alias gaa='git add --all'
|
|||||||
alias gapa='git add --patch'
|
alias gapa='git add --patch'
|
||||||
alias gau='git add --update'
|
alias gau='git add --update'
|
||||||
alias gav='git add --verbose'
|
alias gav='git add --verbose'
|
||||||
alias gwip='git add -A; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"'
|
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"'
|
||||||
alias gam='git am'
|
alias gam='git am'
|
||||||
alias gama='git am --abort'
|
alias gama='git am --abort'
|
||||||
alias gamc='git am --continue'
|
alias gamc='git am --continue'
|
||||||
|
|||||||
@@ -112,37 +112,6 @@ plugins=(... hcloud)
|
|||||||
| hcst | `hcloud server-type list` | List all server types |
|
| hcst | `hcloud server-type list` | List all server types |
|
||||||
| hcit | `hcloud image list --type system` | List all system images |
|
| hcit | `hcloud image list --type system` | List all system images |
|
||||||
|
|
||||||
## Prompt function
|
|
||||||
|
|
||||||
This plugin provides `hcloud_prompt_info` which can be added to your prompt to display the current Hetzner Cloud context.
|
|
||||||
|
|
||||||
- If `HCLOUD_TOKEN` environment variable is set, it displays `HCLOUD_TOKEN` (indicating direct token usage)
|
|
||||||
- Otherwise, it displays the active context name
|
|
||||||
|
|
||||||
### Usage
|
|
||||||
|
|
||||||
Add `$(hcloud_prompt_info)` to your `PROMPT` or `RPROMPT` in your `.zshrc`:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
RPROMPT='$(hcloud_prompt_info)'
|
|
||||||
```
|
|
||||||
|
|
||||||
### Theme variables
|
|
||||||
|
|
||||||
| Variable | Default | Description |
|
|
||||||
| :----------------------------- | :-------------- | :----------------------------------------------- |
|
|
||||||
| `ZSH_THEME_HCLOUD_PREFIX` | `<hcloud:` | Prefix before the context name |
|
|
||||||
| `ZSH_THEME_HCLOUD_SUFFIX` | `>` | Suffix after the context name |
|
|
||||||
| `ZSH_THEME_HCLOUD_TOKEN_TEXT` | `HCLOUD_TOKEN` | Text shown when `HCLOUD_TOKEN` env var is set |
|
|
||||||
|
|
||||||
### Example with custom styling
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
ZSH_THEME_HCLOUD_PREFIX="%{$fg[blue]%}hcloud:("
|
|
||||||
ZSH_THEME_HCLOUD_SUFFIX=")%{$reset_color%}"
|
|
||||||
RPROMPT='$(hcloud_prompt_info)'
|
|
||||||
```
|
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
This plugin requires the [Hetzner Cloud CLI](https://github.com/hetznercloud/cli) to be installed.
|
This plugin requires the [Hetzner Cloud CLI](https://github.com/hetznercloud/cli) to be installed.
|
||||||
|
|||||||
@@ -131,20 +131,3 @@ alias hcdc='hcloud datacenter list'
|
|||||||
alias hcloc='hcloud location list'
|
alias hcloc='hcloud location list'
|
||||||
alias hcst='hcloud server-type list'
|
alias hcst='hcloud server-type list'
|
||||||
alias hcit='hcloud image list --type system'
|
alias hcit='hcloud image list --type system'
|
||||||
|
|
||||||
# Prompt function to display current hcloud context
|
|
||||||
# Usage: add $(hcloud_prompt_info) to your PROMPT or RPROMPT
|
|
||||||
function hcloud_prompt_info() {
|
|
||||||
# Check if HCLOUD_TOKEN is set (overrides context)
|
|
||||||
if [[ -n "$HCLOUD_TOKEN" ]]; then
|
|
||||||
echo "${ZSH_THEME_HCLOUD_PREFIX=<hcloud:}${ZSH_THEME_HCLOUD_TOKEN_TEXT=HCLOUD_TOKEN}${ZSH_THEME_HCLOUD_SUFFIX=>}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get active context
|
|
||||||
local context
|
|
||||||
context=$(hcloud context active 2>/dev/null)
|
|
||||||
[[ -n "$context" ]] || return
|
|
||||||
|
|
||||||
echo "${ZSH_THEME_HCLOUD_PREFIX=<hcloud:}${context}${ZSH_THEME_HCLOUD_SUFFIX=>}"
|
|
||||||
}
|
|
||||||
@@ -80,17 +80,3 @@ zstyle ':omz:plugins:laravel' php 'herd php'
|
|||||||
| `paqr` | `php artisan queue:retry` |
|
| `paqr` | `php artisan queue:retry` |
|
||||||
| `paqt` | `php artisan queue:table` |
|
| `paqt` | `php artisan queue:table` |
|
||||||
| `paqw` | `php artisan queue:work` |
|
| `paqw` | `php artisan queue:work` |
|
||||||
|
|
||||||
## Modules
|
|
||||||
|
|
||||||
Aliases for [nWidart/laravel-modules](https://github.com/nWidart/laravel-modules).
|
|
||||||
|
|
||||||
| Alias | Description |
|
|
||||||
|:-:|:-:|
|
|
||||||
| `pamol` | `php artisan module:list` |
|
|
||||||
| `pamomk` | `php artisan module:make` |
|
|
||||||
| `pamoe` | `php artisan module:enable` |
|
|
||||||
| `pamod` | `php artisan module:disable` |
|
|
||||||
| `pamom` | `php artisan module:migrate` |
|
|
||||||
| `pamomr` | `php artisan module:migrate-rollback` |
|
|
||||||
| `pamos` | `php artisan module:seed` |
|
|
||||||
@@ -53,13 +53,4 @@ alias paqr="$_omz_laravel_php artisan queue:retry"
|
|||||||
alias paqt="$_omz_laravel_php artisan queue:table"
|
alias paqt="$_omz_laravel_php artisan queue:table"
|
||||||
alias paqw="$_omz_laravel_php artisan queue:work"
|
alias paqw="$_omz_laravel_php artisan queue:work"
|
||||||
|
|
||||||
# Modules (nWidart/laravel-modules)
|
|
||||||
alias pamol="$_omz_laravel_php artisan module:list"
|
|
||||||
alias pamomk="$_omz_laravel_php artisan module:make"
|
|
||||||
alias pamoe="$_omz_laravel_php artisan module:enable"
|
|
||||||
alias pamod="$_omz_laravel_php artisan module:disable"
|
|
||||||
alias pamom="$_omz_laravel_php artisan module:migrate"
|
|
||||||
alias pamomr="$_omz_laravel_php artisan module:migrate-rollback"
|
|
||||||
alias pamos="$_omz_laravel_php artisan module:seed"
|
|
||||||
|
|
||||||
unset _omz_laravel_php
|
unset _omz_laravel_php
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# Pre-commit plugin
|
# Pre-commit plugin
|
||||||
|
|
||||||
This plugin adds aliases for common commands of [pre-commit](https://pre-commit.com/).
|
This plugin adds aliases for common commands of [pre-commit](https://pre-commit.com/).
|
||||||
It also supports [prek](https://github.com/j178/prek) as a drop-in replacement.
|
It also supports [prek](https://github.com/prek/prek) as a drop-in replacement.
|
||||||
If `prek` is available, it will be used; otherwise, `pre-commit` is used as fallback.
|
If `prek` is available, it will be used; otherwise, `pre-commit` is used as fallback.
|
||||||
|
|
||||||
To use this plugin, add it to the plugins array in your zshrc file:
|
To use this plugin, add it to the plugins array in your zshrc file:
|
||||||
|
|||||||
@@ -34,8 +34,6 @@ virtual environments:
|
|||||||
`<venv-name>/bin/activate`, and automatically deactivate it when navigating out of it (keeps venv activated
|
`<venv-name>/bin/activate`, and automatically deactivate it when navigating out of it (keeps venv activated
|
||||||
in subdirectories).
|
in subdirectories).
|
||||||
- To enable the feature, set `PYTHON_AUTO_VRUN=true` before sourcing oh-my-zsh.
|
- To enable the feature, set `PYTHON_AUTO_VRUN=true` before sourcing oh-my-zsh.
|
||||||
- To also search parent directories (useful for monorepos), set `PYTHON_AUTO_VRUN_RECURSIVE=true` as well.
|
|
||||||
The search stops before `$HOME`, so a venv in your home directory is not activated in every folder under it.
|
|
||||||
- The plugin activates the first existing virtual environment, in order, appearing in `$PYTHON_VENV_NAMES`.
|
- The plugin activates the first existing virtual environment, in order, appearing in `$PYTHON_VENV_NAMES`.
|
||||||
The default virtual environment name is `venv`. To use a different name, set
|
The default virtual environment name is `venv`. To use a different name, set
|
||||||
`PYTHON_VENV_NAME=<venv-name>`. For example: `PYTHON_VENV_NAME=".venv"`
|
`PYTHON_VENV_NAME=<venv-name>`. For example: `PYTHON_VENV_NAME=".venv"`
|
||||||
|
|||||||
@@ -113,23 +113,8 @@ if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then
|
|||||||
# make sure we're not in a venv already
|
# make sure we're not in a venv already
|
||||||
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
|
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
|
||||||
source $file > /dev/null 2>&1
|
source $file > /dev/null 2>&1
|
||||||
return
|
break
|
||||||
done
|
done
|
||||||
|
|
||||||
# Search parent directories if recursive mode is enabled, stopping before $HOME
|
|
||||||
if [[ "$PYTHON_AUTO_VRUN_RECURSIVE" == "true" ]]; then
|
|
||||||
local search_dir="$PWD:h"
|
|
||||||
while [[ "$search_dir" != "/" && "$search_dir" != "." && "$search_dir" != "$HOME" ]]; do
|
|
||||||
for file in "${search_dir}/"${^PYTHON_VENV_NAMES[@]}"/bin/activate"(N.); do
|
|
||||||
# the venv found is already active
|
|
||||||
[[ "${file:h:h:A}" == "${VIRTUAL_ENV:A}" ]] && return
|
|
||||||
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
|
|
||||||
source $file > /dev/null 2>&1
|
|
||||||
return
|
|
||||||
done
|
|
||||||
search_dir="${search_dir:h}"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
add-zsh-hook chpwd auto_vrun
|
add-zsh-hook chpwd auto_vrun
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ plugins=(... systemd)
|
|||||||
| `sc-show-environment` | `systemctl show-environment` | Dump the systemd manager environment block |
|
| `sc-show-environment` | `systemctl show-environment` | Dump the systemd manager environment block |
|
||||||
| `sc-cat` | `systemctl cat` | Show backing files of one or more units |
|
| `sc-cat` | `systemctl cat` | Show backing files of one or more units |
|
||||||
| `sc-list-timers` | `systemctl list-timers` | List timer units currently in memory |
|
| `sc-list-timers` | `systemctl list-timers` | List timer units currently in memory |
|
||||||
| **Privileged aliases** |||
|
| **Aliases with sudo** |||
|
||||||
| `sc-start` | `sudo systemctl start` | Start Unit(s) |
|
| `sc-start` | `sudo systemctl start` | Start Unit(s) |
|
||||||
| `sc-stop` | `sudo systemctl stop` | Stop Unit(s) |
|
| `sc-stop` | `sudo systemctl stop` | Stop Unit(s) |
|
||||||
| `sc-reload` | `sudo systemctl reload` | Reload Unit(s) |
|
| `sc-reload` | `sudo systemctl reload` | Reload Unit(s) |
|
||||||
@@ -50,28 +50,6 @@ plugins=(... systemd)
|
|||||||
| `sc-disable-now` | `sudo systemctl disable --now` | Disable and stop unit(s) |
|
| `sc-disable-now` | `sudo systemctl disable --now` | Disable and stop unit(s) |
|
||||||
| `sc-mask-now` | `sudo systemctl mask --now` | Mask and stop unit(s) |
|
| `sc-mask-now` | `sudo systemctl mask --now` | Mask and stop unit(s) |
|
||||||
|
|
||||||
### Privileged aliases
|
|
||||||
|
|
||||||
systemd plugin supports alternative privilege elevation tools. You can prepend an arbitrary string,
|
|
||||||
replacing `sudo`, to the privileged aliases by setting `$ZSH_SYSTEMD_SUDO` variable. You can leave
|
|
||||||
authorization to systemd by setting `$ZSH_SYSTEMD_SUDO` to an empty string.
|
|
||||||
|
|
||||||
To use `doas` as your elevation tool you will need to add the following line to your zshrc;
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
ZSH_SYSTEMD_SUDO="doas"
|
|
||||||
```
|
|
||||||
|
|
||||||
After shell restart, you will see that alias for `sc-enable` is changed:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ which sc-enable
|
|
||||||
sc-enable: aliased to doas systemctl enable
|
|
||||||
```
|
|
||||||
|
|
||||||
These aliases are evaluated during oh-my-zsh startup, and can't be changed interactively (you will
|
|
||||||
need to restart shell to see changes).
|
|
||||||
|
|
||||||
### User aliases
|
### User aliases
|
||||||
|
|
||||||
You can use the above aliases as `--user` by using the prefix `scu` instead of `sc`.
|
You can use the above aliases as `--user` by using the prefix `scu` instead of `sc`.
|
||||||
|
|||||||
@@ -67,27 +67,15 @@ power_commands=(
|
|||||||
suspend
|
suspend
|
||||||
)
|
)
|
||||||
|
|
||||||
if ! [[ -v ZSH_SYSTEMD_SUDO ]]; then
|
|
||||||
ZSH_SYSTEMD_SUDO="sudo"
|
|
||||||
fi
|
|
||||||
|
|
||||||
for c in $user_commands; do
|
for c in $user_commands; do
|
||||||
alias "sc-$c"="systemctl $c"
|
alias "sc-$c"="systemctl $c"
|
||||||
alias "scu-$c"="systemctl --user $c"
|
alias "scu-$c"="systemctl --user $c"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Avoids leading space in alias when using polkit
|
for c in $sudo_commands; do
|
||||||
if [[ -n "${ZSH_SYSTEMD_SUDO}" ]]; then
|
alias "sc-$c"="sudo systemctl $c"
|
||||||
for c in $sudo_commands; do
|
alias "scu-$c"="systemctl --user $c"
|
||||||
alias "sc-$c"="$ZSH_SYSTEMD_SUDO systemctl $c"
|
done
|
||||||
alias "scu-$c"="systemctl --user $c"
|
|
||||||
done
|
|
||||||
else
|
|
||||||
for c in $sudo_commands; do
|
|
||||||
alias "sc-$c"="systemctl $c"
|
|
||||||
alias "scu-$c"="systemctl --user $c"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
for c in $power_commands; do
|
for c in $power_commands; do
|
||||||
alias "sc-$c"="systemctl $c"
|
alias "sc-$c"="systemctl $c"
|
||||||
@@ -95,6 +83,7 @@ done
|
|||||||
|
|
||||||
unset c user_commands sudo_commands power_commands
|
unset c user_commands sudo_commands power_commands
|
||||||
|
|
||||||
|
|
||||||
# --now commands
|
# --now commands
|
||||||
alias sc-enable-now="sc-enable --now"
|
alias sc-enable-now="sc-enable --now"
|
||||||
alias sc-disable-now="sc-disable --now"
|
alias sc-disable-now="sc-disable --now"
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
# talosctl plugin
|
|
||||||
|
|
||||||
This plugin adds completion for the [talosctl](https://docs.siderolabs.com/talos/v1.12/learn-more/talosctl) CLI for managing [Talos](https://github.com/siderolabs/talos) Linux.
|
|
||||||
|
|
||||||
To use it, add `talosctl` to the plugins array in your zshrc file:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(... talosctl)
|
|
||||||
```
|
|
||||||
|
|
||||||
This plugin does not add any aliases.
|
|
||||||
|
|
||||||
## Cache
|
|
||||||
|
|
||||||
This plugin caches the completion script and is automatically updated asynchronously when the plugin is
|
|
||||||
loaded, which is usually when you start up a new terminal emulator.
|
|
||||||
|
|
||||||
The cache is stored at:
|
|
||||||
|
|
||||||
- `$ZSH_CACHE/completions/_talosctl` completions script
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
# Autocompletion for talosctl
|
|
||||||
if (( ! $+commands[talosctl] )); then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
|
||||||
# bind it to `talosctl`. Otherwise, compinit will have already done that.
|
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_talosctl" ]]; then
|
|
||||||
typeset -g -A _comps
|
|
||||||
autoload -Uz _talosctl
|
|
||||||
_comps[talosctl]=_talosctl
|
|
||||||
fi
|
|
||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
|
||||||
() {
|
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._talosctl"
|
|
||||||
zf_mv -f -- =( talosctl completion zsh ) "$ZSH_CACHE_DIR/completions/_talosctl"
|
|
||||||
} &|
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
# Terragrunt plugin
|
|
||||||
|
|
||||||
Terragrunt is a thin wrapper for opentofu/terraform that provides extra tools
|
|
||||||
and features to enhance the management of Infrastructure as Code (IaC) using
|
|
||||||
opentofu/terraform. This plugin adds completion for `terragrunt` command, as well
|
|
||||||
as aliases and a prompt function.
|
|
||||||
|
|
||||||
To use it, add `terragrunt` to the plugins array of your `~/.zshrc` file:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
plugins=(... terragrunt)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
- [Terragrunt](https://docs.terragrunt.com/) v0.77.22 or later
|
|
||||||
|
|
||||||
## Aliases
|
|
||||||
|
|
||||||
| Alias | Command |
|
|
||||||
| ------ | ----------------------------------------- |
|
|
||||||
| `tg` | `terragrunt` |
|
|
||||||
| `tga` | `terragrunt run -- apply` |
|
|
||||||
| `tgaa` | `terragrunt run -- apply -auto-approve` |
|
|
||||||
| `tgc` | `terragrunt run -- console` |
|
|
||||||
| `tgd` | `terragrunt run -- destroy` |
|
|
||||||
| `tgd!` | `terragrunt run -- destroy -auto-approve` |
|
|
||||||
| `tgi` | `terragrunt run -- init` |
|
|
||||||
| `tgo` | `terragrunt run -- output` |
|
|
||||||
| `tgp` | `terragrunt run -- plan` |
|
|
||||||
| `tgv` | `terragrunt run -- validate` |
|
|
||||||
| `tgs` | `terragrunt run -- state` |
|
|
||||||
| `tgsh` | `terragrunt run -- show` |
|
|
||||||
| `tgr` | `terragrunt run -- refresh` |
|
|
||||||
| `tgt` | `terragrunt run -- test` |
|
|
||||||
| `tgws` | `terragrunt run -- workspace` |
|
|
||||||
|
|
||||||
## Prompt function
|
|
||||||
|
|
||||||
- `terragrunt_version_prompt_info` shows the current version of the `terragrunt` command.
|
|
||||||
|
|
||||||
To use it, add it to a `PROMPT` or `RPROMPT` variable in your theme or `.zshrc` file.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
RPROMPT='$(terragrunt_version_prompt_info)'
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also specify the PREFIX and SUFFIX strings with the following variables.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
ZSH_THEME_TERRAGRUNT_VERSION_PROMPT_PREFIX="%{$fg[white]%}"
|
|
||||||
ZSH_THEME_TERRAGRUNT_VERSION_PROMPT_SUFFIX="%{$reset_color%}"
|
|
||||||
```
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
# set up the terragrunt completion (compatible for zsh)
|
|
||||||
autoload -Uz bashcompinit && bashcompinit
|
|
||||||
complete -C terragrunt terragrunt
|
|
||||||
|
|
||||||
# terragrunt version prompt function
|
|
||||||
function terragrunt_version_prompt_info() {
|
|
||||||
# get the output of `terragrunt --version` in a single line, and get the third word after splitting by a space
|
|
||||||
local terragrunt_version=${${(s: :)$(terragrunt --version)}[3]}
|
|
||||||
# make sure to escape % signs in the version string to prevent command injection
|
|
||||||
echo "${ZSH_THEME_TERRAGRUNT_VERSION_PROMPT_PREFIX-[}${terragrunt_version:gs/%/%%}${ZSH_THEME_TERRAGRUNT_VERSION_PROMPT_SUFFIX-]}"
|
|
||||||
}
|
|
||||||
|
|
||||||
alias tg='terragrunt'
|
|
||||||
alias tga='terragrunt run -- apply'
|
|
||||||
alias tgaa='terragrunt run -- apply -auto-approve'
|
|
||||||
alias tgc='terragrunt run -- console'
|
|
||||||
alias tgd='terragrunt run -- destroy'
|
|
||||||
alias tgd!='terragrunt run -- destroy -auto-approve'
|
|
||||||
alias tgi='terragrunt run -- init'
|
|
||||||
alias tgo='terragrunt run -- output'
|
|
||||||
alias tgp='terragrunt run -- plan'
|
|
||||||
alias tgv='terragrunt run -- validate'
|
|
||||||
alias tgs='terragrunt run -- state'
|
|
||||||
alias tgsh='terragrunt run -- show'
|
|
||||||
alias tgr='terragrunt run -- refresh'
|
|
||||||
alias tgt='terragrunt run -- test'
|
|
||||||
alias tgws='terragrunt run -- workspace'
|
|
||||||
@@ -39,15 +39,6 @@ plugins=(... vi-mode)
|
|||||||
|
|
||||||
- `VI_MODE_DISABLE_CLIPBOARD`: If set, disables clipboard integration on yank/paste
|
- `VI_MODE_DISABLE_CLIPBOARD`: If set, disables clipboard integration on yank/paste
|
||||||
|
|
||||||
Clipboard integration keeps put widgets (`p`/`P`) in sync with the system
|
|
||||||
clipboard, but only while the last copy to the clipboard actually succeeded.
|
|
||||||
If that copy failed — no `xclip`/`xsel`, Wayland without `wl-clipboard`, a dead
|
|
||||||
X forwarding over SSH — the clipboard no longer mirrors what you killed inside
|
|
||||||
the line editor, so puts use the internal kill buffer instead of the stale
|
|
||||||
clipboard contents. After a failed push, puts keep using the kill buffer only
|
|
||||||
while the clipboard still holds exactly what it held when the push failed; a
|
|
||||||
new external copy is picked up again immediately.
|
|
||||||
|
|
||||||
## Mode indicators
|
## Mode indicators
|
||||||
|
|
||||||
*Normal mode* is indicated with a red `<<<` mark at the right prompt, when it
|
*Normal mode* is indicated with a red `<<<` mark at the right prompt, when it
|
||||||
|
|||||||
@@ -118,15 +118,6 @@ bindkey '^s' history-incremental-search-forward
|
|||||||
bindkey '^a' beginning-of-line
|
bindkey '^a' beginning-of-line
|
||||||
bindkey '^e' end-of-line
|
bindkey '^e' end-of-line
|
||||||
|
|
||||||
# Snapshot of the clipboard taken when the most recent push to it failed.
|
|
||||||
# While the marker is set, put widgets compare the live clipboard against the
|
|
||||||
# snapshot: unchanged means the clipboard is stale (it never received the
|
|
||||||
# kill), so the internal CUTBUFFER is used instead. As soon as the clipboard
|
|
||||||
# differs again - e.g. an external copy - it is trusted immediately, so
|
|
||||||
# external copies are never lost for longer than the failure itself.
|
|
||||||
typeset -g _OMZ_VI_CLIPBOARD_STALE=""
|
|
||||||
typeset -g _OMZ_VI_CLIPBOARD_STALE_SET=""
|
|
||||||
|
|
||||||
function wrap_clipboard_widgets() {
|
function wrap_clipboard_widgets() {
|
||||||
# NB: Assume we are the first wrapper and that we only wrap native widgets
|
# NB: Assume we are the first wrapper and that we only wrap native widgets
|
||||||
# See zsh-autosuggestions.zsh for a more generic and more robust wrapper
|
# See zsh-autosuggestions.zsh for a more generic and more robust wrapper
|
||||||
@@ -141,33 +132,13 @@ function wrap_clipboard_widgets() {
|
|||||||
eval "
|
eval "
|
||||||
function ${wrapped_name}() {
|
function ${wrapped_name}() {
|
||||||
zle .${widget}
|
zle .${widget}
|
||||||
# On a failed push, snapshot the clipboard so put widgets can tell
|
printf %s \"\${CUTBUFFER}\" | clipcopy 2>/dev/null || true
|
||||||
# stale content (which never received this kill) apart from later
|
|
||||||
# external copies.
|
|
||||||
if printf %s \"\${CUTBUFFER}\" | clipcopy 2>/dev/null; then
|
|
||||||
_OMZ_VI_CLIPBOARD_STALE_SET=\"\"
|
|
||||||
else
|
|
||||||
_OMZ_VI_CLIPBOARD_STALE=\"\$(clippaste 2>/dev/null)\"
|
|
||||||
_OMZ_VI_CLIPBOARD_STALE_SET=1
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
else
|
else
|
||||||
eval "
|
eval "
|
||||||
function ${wrapped_name}() {
|
function ${wrapped_name}() {
|
||||||
if [[ -n \"\${_OMZ_VI_CLIPBOARD_STALE_SET:-}\" ]]; then
|
CUTBUFFER=\"\$(clippaste 2>/dev/null || echo \$CUTBUFFER)\"
|
||||||
# Last push failed. If the clipboard still matches the snapshot
|
|
||||||
# taken at the failure, it is stale: keep the internal CUTBUFFER.
|
|
||||||
# If it differs, an external copy arrived since - trust it again
|
|
||||||
# and clear the stale state.
|
|
||||||
local _clip=\"\$(clippaste 2>/dev/null)\"
|
|
||||||
if [[ \"\$_clip\" != \"\${_OMZ_VI_CLIPBOARD_STALE}\" ]]; then
|
|
||||||
CUTBUFFER=\"\$_clip\"
|
|
||||||
_OMZ_VI_CLIPBOARD_STALE_SET=\"\"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
CUTBUFFER=\"\$(clippaste 2>/dev/null || echo \$CUTBUFFER)\"
|
|
||||||
fi
|
|
||||||
zle .${widget}
|
zle .${widget}
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|||||||
@@ -53,11 +53,10 @@ function web_search() {
|
|||||||
|
|
||||||
# search or go to main page depending on number of arguments passed
|
# search or go to main page depending on number of arguments passed
|
||||||
if [[ $# -gt 1 ]]; then
|
if [[ $# -gt 1 ]]; then
|
||||||
# if search goes in the query string ==> space as + and escape reserved
|
# if search goes in the query string ==> space as +, otherwise %20
|
||||||
# characters like & and +, otherwise %20
|
|
||||||
# see https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20
|
# see https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20
|
||||||
local param="-P"
|
local param="-P"
|
||||||
[[ "$urls[$1]" == *\?*= ]] && param="-r"
|
[[ "$urls[$1]" == *\?*= ]] && param=""
|
||||||
|
|
||||||
# build search url:
|
# build search url:
|
||||||
# join arguments passed with '+', then append to search engine URL
|
# join arguments passed with '+', then append to search engine URL
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ Initializes [zsh-patina](https://github.com/michel-kraemer/zsh-patina), a
|
|||||||
"blazingly fast Zsh plugin performing syntax highlighting of your command line
|
"blazingly fast Zsh plugin performing syntax highlighting of your command line
|
||||||
while you type 🌈"
|
while you type 🌈"
|
||||||
|
|
||||||
The plugin also caches completions for the `zsh-patina` command in
|
|
||||||
`$ZSH_CACHE_DIR/completions/_zsh-patina`, refreshed each time the plugin loads.
|
|
||||||
|
|
||||||
To use it, add `zsh-patina` to the plugins array in your `.zshrc` file:
|
To use it, add `zsh-patina` to the plugins array in your `.zshrc` file:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
|
|||||||
@@ -2,20 +2,6 @@ if (( $+ZSH_HIGHLIGHT_VERSION )) || (( ${plugins[(Ie)zsh-syntax-highlighting]} )
|
|||||||
echo '[oh-my-zsh] zsh-patina conflicts with zsh-syntax-highlighting, please enable only one of them'
|
echo '[oh-my-zsh] zsh-patina conflicts with zsh-syntax-highlighting, please enable only one of them'
|
||||||
elif [[ -x ${ZSH_PATINA_BINARY:-$commands[zsh-patina]} ]]; then
|
elif [[ -x ${ZSH_PATINA_BINARY:-$commands[zsh-patina]} ]]; then
|
||||||
eval "$(${ZSH_PATINA_BINARY:-$commands[zsh-patina]} activate)"
|
eval "$(${ZSH_PATINA_BINARY:-$commands[zsh-patina]} activate)"
|
||||||
|
|
||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
|
||||||
# bind it to `zsh-patina`. Otherwise, compinit will have already done that.
|
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_zsh-patina" ]]; then
|
|
||||||
typeset -g -A _comps
|
|
||||||
autoload -Uz _zsh-patina
|
|
||||||
_comps[zsh-patina]=_zsh-patina
|
|
||||||
fi
|
|
||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
|
||||||
() {
|
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._zsh-patina"
|
|
||||||
zf_mv -f -- =( "$1" completion ) "$ZSH_CACHE_DIR/completions/_zsh-patina"
|
|
||||||
} "${ZSH_PATINA_BINARY:-$commands[zsh-patina]}" &|
|
|
||||||
else
|
else
|
||||||
echo '[oh-my-zsh] zsh-patina not found, please install it from https://github.com/michel-kraemer/zsh-patina'
|
echo '[oh-my-zsh] zsh-patina not found, please install it from https://github.com/michel-kraemer/zsh-patina'
|
||||||
fi
|
fi
|
||||||
Reference in new issue
Block a user