mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-11-26 18:33:03 +01:00
Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abfce729ab | ||
|
|
070831e592 | ||
|
|
e333686c2a | ||
|
|
b1d468701a | ||
|
|
12a6ce7e42 | ||
|
|
f5a74e0347 | ||
|
|
0876f10264 | ||
|
|
4d643a3c86 | ||
|
|
1a05a1091b | ||
|
|
ad66117d08 | ||
|
|
964e5b65c6 | ||
|
|
1eebae3a3f | ||
|
|
ca5b808de8 | ||
|
|
c8aea70a11 | ||
|
|
799f9a8a8a | ||
|
|
7140fedbfa |
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, substitute ) with new plugins and go to the next line
|
# if plugins=() is in oneline form (empty or not), 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
|
||||||
|
|||||||
+3
-4
@@ -237,10 +237,9 @@ function _omz_diag_dump_one_big_text() {
|
|||||||
fi
|
fi
|
||||||
builtin echo
|
builtin echo
|
||||||
builtin echo "Zsh compdump files:"
|
builtin echo "Zsh compdump files:"
|
||||||
local dumpfile
|
local dumpfile dumpfiles
|
||||||
local -U dumpfiles
|
command ls -lad $zdotdir/.zcompdump*
|
||||||
dumpfiles=( $zdotdir/.zcompdump*(N) ${ZSH_COMPDUMP:h}/.zcompdump*(N) )
|
dumpfiles=( $zdotdir/.zcompdump*(N) )
|
||||||
(( $#dumpfiles )) && command ls -lad $dumpfiles
|
|
||||||
if [[ $verbose -ge 2 ]]; then
|
if [[ $verbose -ge 2 ]]; then
|
||||||
for dumpfile in $dumpfiles; do
|
for dumpfile in $dumpfiles; do
|
||||||
_omz_diag_dump_echo_file_w_header $dumpfile
|
_omz_diag_dump_echo_file_w_header $dumpfile
|
||||||
|
|||||||
+1
-1
@@ -128,7 +128,7 @@ fi
|
|||||||
|
|
||||||
# Save the location of the current completion dump file.
|
# Save the location of the current completion dump file.
|
||||||
if [[ -z "$ZSH_COMPDUMP" ]]; then
|
if [[ -z "$ZSH_COMPDUMP" ]]; then
|
||||||
ZSH_COMPDUMP="${ZSH_CACHE_DIR}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
|
ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Resolve the commit $ZSH is checked out at into $REPLY by reading the git
|
# Resolve the commit $ZSH is checked out at into $REPLY by reading the git
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ 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,9 +135,40 @@ 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
|
||||||
builtin cd -q control; extract ../control.tar.*
|
local member= dest= failed=0
|
||||||
builtin cd -q ../data; extract ../data.tar.*
|
for member in control.tar.* data.tar.*; do
|
||||||
builtin cd -q ..; command rm *.tar.* debian-binary ;;
|
dest="${member%%.*}"
|
||||||
|
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 lzma unlzma uncompress; do
|
for tool in ar 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,6 +46,120 @@ 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"
|
||||||
@@ -58,6 +172,11 @@ check_extract() {
|
|||||||
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"
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# 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.
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
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)] "<message>"
|
git <type> [(-s, --scope) "<scope>"] [(-a, --attention)] [(-b, --body) "<body>"] "<message>"
|
||||||
```
|
```
|
||||||
|
|
||||||
Where `type` is one of the following:
|
Where `type` is one of the following:
|
||||||
@@ -30,6 +30,9 @@ 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>`
|
||||||
@@ -39,6 +42,7 @@ Where `type` is one of the following:
|
|||||||
| 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 "work in progress"` |
|
| `git wip "work in progress"` | `git commit -m "wip: 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
|
local _scope _attention _message _body
|
||||||
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,12 +27,20 @@ _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}"
|
git commit -m "${_type}${_scope:+(${_scope})}${_attention}:${_message}" ${_body:+-m} ${_body:+"$_body"}
|
||||||
}
|
}
|
||||||
_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 rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"` |
|
| `gwip` | `git add -A; 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 rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"'
|
alias gwip='git add -A; 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'
|
||||||
|
|||||||
@@ -80,3 +80,17 @@ 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,4 +53,13 @@ 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/prek/prek) as a drop-in replacement.
|
It also supports [prek](https://github.com/j178/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,6 +34,8 @@ 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,8 +113,23 @@ 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
|
||||||
break
|
return
|
||||||
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 |
|
||||||
| **Aliases with sudo** |||
|
| **Privileged aliases** |||
|
||||||
| `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,6 +50,28 @@ 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,15 +67,27 @@ 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
|
||||||
|
|
||||||
for c in $sudo_commands; do
|
# Avoids leading space in alias when using polkit
|
||||||
alias "sc-$c"="sudo systemctl $c"
|
if [[ -n "${ZSH_SYSTEMD_SUDO}" ]]; then
|
||||||
|
for c in $sudo_commands; do
|
||||||
|
alias "sc-$c"="$ZSH_SYSTEMD_SUDO systemctl $c"
|
||||||
alias "scu-$c"="systemctl --user $c"
|
alias "scu-$c"="systemctl --user $c"
|
||||||
done
|
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"
|
||||||
@@ -83,7 +95,6 @@ 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"
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# 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
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# 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"
|
||||||
|
} &|
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
# 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%}"
|
||||||
|
```
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# 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,6 +39,15 @@ 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,6 +118,15 @@ 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
|
||||||
@@ -132,13 +141,33 @@ function wrap_clipboard_widgets() {
|
|||||||
eval "
|
eval "
|
||||||
function ${wrapped_name}() {
|
function ${wrapped_name}() {
|
||||||
zle .${widget}
|
zle .${widget}
|
||||||
printf %s \"\${CUTBUFFER}\" | clipcopy 2>/dev/null || true
|
# On a failed push, snapshot the clipboard so put widgets can tell
|
||||||
|
# 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
|
||||||
|
# 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)\"
|
CUTBUFFER=\"\$(clippaste 2>/dev/null || echo \$CUTBUFFER)\"
|
||||||
|
fi
|
||||||
zle .${widget}
|
zle .${widget}
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|||||||
@@ -53,10 +53,11 @@ 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 +, otherwise %20
|
# if search goes in the query string ==> space as + and escape reserved
|
||||||
|
# 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=""
|
[[ "$urls[$1]" == *\?*= ]] && param="-r"
|
||||||
|
|
||||||
# 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,6 +4,9 @@ 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,6 +2,20 @@ 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