mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-03-04 04:40:13 +08:00
Merge branch 'master' into refactoring/reddit-search-v2.0
This commit is contained in:
commit
4d969fde5d
20
.devcontainer/devcontainer.json
Normal file
20
.devcontainer/devcontainer.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"image": "mcr.microsoft.com/devcontainers/base:noble",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/common-utils": {
|
||||
"installZsh": true,
|
||||
"configureZshAsDefaultShell": true,
|
||||
"username": "vscode",
|
||||
"userUid": 1000,
|
||||
"userGid": 1000
|
||||
}
|
||||
},
|
||||
"postCreateCommand": "dir=/workspaces/ohmyzsh; rm -rf $HOME/.oh-my-zsh && ln -s $dir $HOME/.oh-my-zsh && cp $dir/templates/minimal.zshrc $HOME/.zshrc && chgrp -R 1000 $dir && chmod g-w,o-w $dir",
|
||||
"customizations": {
|
||||
"codespaces": {
|
||||
"openFiles": [
|
||||
"README.md"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -9,3 +9,7 @@ indent_style = space
|
||||
|
||||
[*.py]
|
||||
indent_size = 4
|
||||
|
||||
[devcontainer.json]
|
||||
indent_size = 4
|
||||
indent_style = tab
|
||||
|
12
.github/dependencies.yml
vendored
12
.github/dependencies.yml
vendored
@ -2,11 +2,13 @@ dependencies:
|
||||
plugins/gitfast:
|
||||
repo: felipec/git-completion
|
||||
branch: master
|
||||
version: tag:v2.1
|
||||
version: tag:v2.2
|
||||
postcopy: |
|
||||
set -e
|
||||
rm -rf git-completion.plugin.zsh Makefile README.adoc t tools
|
||||
test -e git-completion.zsh && mv -f git-completion.zsh _git
|
||||
rm -rf git-completion.plugin.zsh Makefile t tools
|
||||
mv README.adoc MANUAL.adoc
|
||||
mv -f src/* .
|
||||
rmdir src
|
||||
plugins/gradle:
|
||||
repo: gradle/gradle-completion
|
||||
branch: master
|
||||
@ -28,7 +30,7 @@ dependencies:
|
||||
plugins/wd:
|
||||
repo: mfaerevaag/wd
|
||||
branch: master
|
||||
version: tag:v0.9.0
|
||||
version: tag:v0.9.3
|
||||
precopy: |
|
||||
set -e
|
||||
rm -r test
|
||||
@ -36,7 +38,7 @@ dependencies:
|
||||
plugins/z:
|
||||
branch: master
|
||||
repo: agkozak/zsh-z
|
||||
version: afaf2965b41fdc6ca66066e09382726aa0b6aa04
|
||||
version: dd94ef04acc41748ba171eb219971cb455e0040b
|
||||
precopy: |
|
||||
set -e
|
||||
test -e README.md && mv -f README.md MANUAL.md
|
||||
|
@ -1,7 +1,7 @@
|
||||
certifi==2024.8.30
|
||||
charset-normalizer==3.3.2
|
||||
certifi==2025.1.31
|
||||
charset-normalizer==3.4.1
|
||||
idna==3.10
|
||||
PyYAML==6.0.2
|
||||
requests==2.32.3
|
||||
semver==3.0.2
|
||||
urllib3==2.2.3
|
||||
semver==3.0.4
|
||||
urllib3==2.3.0
|
||||
|
2
.github/workflows/dependencies/updater.py
vendored
2
.github/workflows/dependencies/updater.py
vendored
@ -228,7 +228,7 @@ class Dependency:
|
||||
self.__apply_upstream_changes()
|
||||
|
||||
# Add all changes and commit
|
||||
has_new_commit = Git.add_and_commit(self.name, short_sha)
|
||||
has_new_commit = Git.add_and_commit(self.name, new_version)
|
||||
|
||||
if has_new_commit:
|
||||
# Push changes to remote
|
||||
|
4
.github/workflows/installer/vercel.json
vendored
4
.github/workflows/installer/vercel.json
vendored
@ -1,7 +1,7 @@
|
||||
{
|
||||
"headers": [
|
||||
{
|
||||
"source": "/((?!favicon.ico).*)",
|
||||
"source": "/(|install.sh)",
|
||||
"headers": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
@ -16,7 +16,7 @@
|
||||
],
|
||||
"rewrites": [
|
||||
{
|
||||
"source": "/((?!favicon.ico|install.sh).*)",
|
||||
"source": "/",
|
||||
"destination": "/install.sh"
|
||||
}
|
||||
]
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -10,3 +10,6 @@ log/
|
||||
# editor configs
|
||||
.vscode
|
||||
.idea
|
||||
|
||||
# zcompile cached files
|
||||
*.zwc
|
||||
|
15
README.md
15
README.md
@ -190,8 +190,7 @@ ZSH_THEME="agnoster" # (this is one of the fancy ones)
|
||||
<!-- prettier-ignore-start -->
|
||||
> [!NOTE]
|
||||
> You will many times see screenshots for a zsh theme, and try it out, and find that it doesn't look the same for you.
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
>
|
||||
> This is because many themes require installing a [Powerline Font](https://github.com/powerline/fonts) or a
|
||||
> [Nerd Font](https://github.com/ryanoasis/nerd-fonts) in order to render properly. Without them, these themes
|
||||
> will render weird prompt symbols. Check out
|
||||
@ -203,6 +202,7 @@ ZSH_THEME="agnoster" # (this is one of the fancy ones)
|
||||
> terminal window (known as _color scheme_) or the font of your terminal. These are settings that you can
|
||||
> change in your terminal emulator. For more information, see
|
||||
> [what is a zsh theme](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#what-is-a-zsh-theme).
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
Open up a new terminal window and your prompt should look something like this:
|
||||
|
||||
@ -487,6 +487,17 @@ wait a week?) you just need to run:
|
||||
omz update
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> If you want to automate this process in a script, you should call directly the `upgrade` script, like this:
|
||||
>
|
||||
> ```sh
|
||||
> $ZSH/tools/upgrade.sh
|
||||
> ```
|
||||
>
|
||||
> See more options in the [FAQ: How do I update Oh My Zsh?](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#how-do-i-update-oh-my-zsh).
|
||||
>
|
||||
> **USE OF `omz update --unattended` HAS BEEN REMOVED, AS IT HAS SIDE EFFECTS**.
|
||||
|
||||
Magic! 🎉
|
||||
|
||||
## Uninstalling Oh My Zsh
|
||||
|
16
lib/cli.zsh
16
lib/cli.zsh
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
function omz {
|
||||
setopt localoptions noksharrays
|
||||
[[ $# -gt 0 ]] || {
|
||||
_omz::help
|
||||
return 1
|
||||
@ -822,6 +823,13 @@ function _omz::update {
|
||||
return 1
|
||||
}
|
||||
|
||||
# Check if --unattended was passed
|
||||
[[ "$1" != --unattended ]] || {
|
||||
_omz::log error "the \`\e[2m--unattended\e[0m\` flag is no longer supported, use the \`\e[2mupgrade.sh\e[0m\` script instead."
|
||||
_omz::log error "for more information see https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#how-do-i-update-oh-my-zsh"
|
||||
return 1
|
||||
}
|
||||
|
||||
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)
|
||||
[[ $? -eq 0 ]] || {
|
||||
_omz::log error "\`$ZSH\` is not a git directory. Aborting..."
|
||||
@ -830,11 +838,7 @@ function _omz::update {
|
||||
|
||||
# Run update script
|
||||
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
||||
if [[ "$1" != --unattended ]]; then
|
||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode || return $?
|
||||
else
|
||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -v $verbose_mode || return $?
|
||||
fi
|
||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode || return $?
|
||||
|
||||
# Update last updated file
|
||||
zmodload zsh/datetime
|
||||
@ -843,7 +847,7 @@ function _omz::update {
|
||||
command rm -rf "$ZSH/log/update.lock"
|
||||
|
||||
# Restart the zsh session if there were changes
|
||||
if [[ "$1" != --unattended && "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
|
||||
if [[ "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
|
||||
# Old zsh versions don't have ZSH_ARGZERO
|
||||
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
||||
# Check whether to run a login shell
|
||||
|
@ -19,7 +19,7 @@ setopt multios # enable redirect to multiple streams: echo >file1 >
|
||||
setopt long_list_jobs # show long list format job notifications
|
||||
setopt interactivecomments # recognize comments
|
||||
|
||||
# define pager dependant on what is available (less or more)
|
||||
# define pager depending on what is available (less or more)
|
||||
if (( ${+commands[less]} )); then
|
||||
env_default 'PAGER' 'less'
|
||||
env_default 'LESS' '-R'
|
||||
|
@ -1,3 +1,21 @@
|
||||
if (( $+commands[asdf] )); then
|
||||
export ASDF_DATA_DIR="${ASDF_DATA_DIR:-$HOME/.asdf}"
|
||||
path=("$ASDF_DATA_DIR/shims" $path)
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `asdf`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_asdf" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _asdf
|
||||
_comps[asdf]=_asdf
|
||||
fi
|
||||
asdf completion zsh >| "$ZSH_CACHE_DIR/completions/_asdf" &|
|
||||
|
||||
return
|
||||
fi
|
||||
|
||||
# TODO:(2025-02-12): remove deprecated asdf <0.16 code
|
||||
|
||||
# Find where asdf should be installed
|
||||
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR/completions"
|
||||
|
@ -6,6 +6,7 @@ autojump_paths=(
|
||||
/run/current-system/sw/share/autojump/autojump.zsh # NixOS installation
|
||||
/etc/profiles/per-user/$USER/share/autojump/autojump.zsh # Home Manager, NixOS with user-scoped packages
|
||||
/usr/share/autojump/autojump.zsh # Debian and Ubuntu package
|
||||
$PREFIX/share/autojump/autojump.zsh # Termux package
|
||||
/etc/profile.d/autojump.zsh # manual installation
|
||||
/etc/profile.d/autojump.sh # Gentoo installation
|
||||
/usr/local/share/autojump/autojump.zsh # FreeBSD installation
|
||||
|
@ -1,6 +1,7 @@
|
||||
# Bazel plugin
|
||||
|
||||
This plugin adds completion and aliases for [bazel](https://bazel.build), an open-source build and test tool that scalably supports multi-language and multi-platform projects.
|
||||
This plugin adds completion and aliases for [bazel](https://bazel.build), an open-source build and test tool
|
||||
that scalably supports multi-language and multi-platform projects.
|
||||
|
||||
To use it, add `bazel` to the plugins array in your zshrc file:
|
||||
|
||||
@ -14,9 +15,15 @@ The plugin has a copy of [the completion script from the git repository][1].
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| ------- | -------------------------------------- | ------------------------------------------------------ |
|
||||
| bzb | `bazel build` | The `bazel build` command |
|
||||
| bzt | `bazel test` | The `bazel test` command |
|
||||
| bzr | `bazel run` | The `bazel run` command |
|
||||
| bzq | `bazel query` | The `bazel query` command |
|
||||
| Alias | Command | Description |
|
||||
| ----- | ------------- | ------------------------- |
|
||||
| bzb | `bazel build` | The `bazel build` command |
|
||||
| bzt | `bazel test` | The `bazel test` command |
|
||||
| bzr | `bazel run` | The `bazel run` command |
|
||||
| bzq | `bazel query` | The `bazel query` command |
|
||||
|
||||
## Functions
|
||||
|
||||
| Function | Description |
|
||||
| -------- | -------------------------------- |
|
||||
| sri-hash | Generate SRI hash used by bzlmod |
|
||||
|
@ -3,3 +3,7 @@ alias bzb='bazel build'
|
||||
alias bzt='bazel test'
|
||||
alias bzr='bazel run'
|
||||
alias bzq='bazel query'
|
||||
|
||||
sri-hash() {
|
||||
openssl dgst -sha256 -binary $1 | openssl base64 -A | sed 's/^/sha256-/'
|
||||
}
|
||||
|
9
plugins/buf/README.md
Normal file
9
plugins/buf/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Buf plugin
|
||||
|
||||
This plugin adds completion for [Buf CLI](https://github.com/bufbuild/buf), a tool working with Protocol Buffers.
|
||||
|
||||
To use it, add `buf` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... buf)
|
||||
```
|
14
plugins/buf/buf.plugin.zsh
Normal file
14
plugins/buf/buf.plugin.zsh
Normal file
@ -0,0 +1,14 @@
|
||||
# Autocompletion for the Buf CLI (buf).
|
||||
if (( !$+commands[buf] )); then
|
||||
return
|
||||
fi
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `buf`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_buf" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _buf
|
||||
_comps[buf]=_buf
|
||||
fi
|
||||
|
||||
# Generate and load buf completion
|
||||
buf completion zsh >! "$ZSH_CACHE_DIR/completions/_buf" &|
|
@ -22,6 +22,8 @@ _source-from-homebrew() {
|
||||
# check default brew prefix
|
||||
if [[ -h /usr/local/opt/chruby ]];then
|
||||
_brew_prefix="/usr/local/opt/chruby"
|
||||
elif [[ -h /opt/homebrew/opt/chruby ]]; then
|
||||
_brew_prefix="/opt/homebrew/opt/chruby"
|
||||
else
|
||||
# ok , it is not default prefix
|
||||
# this call to brew is expensive ( about 400 ms ), so at least let's make it only once
|
||||
|
@ -36,3 +36,10 @@ Last login: Fri Jan 30 23:12:26 on ttys001
|
||||
- `cowsay` if using `chuck_cow`
|
||||
|
||||
Available via homebrew, apt, ...
|
||||
|
||||
> [!NOTE]
|
||||
> In addition to installing `fortune`, it may be necessary to run:
|
||||
>
|
||||
> `strfile $ZSH/plugins/chucknorris/fortunes/chucknorris\n`
|
||||
>
|
||||
> (include the "\n" literally) to write the fortune data to the proper directory.
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Usage: dash [keyword:]query
|
||||
dash() { open -a Dash.app dash://"$*" }
|
||||
dash() { open -a Dash.app "dash://$(omz_urlencode -r $*)" }
|
||||
compdef _dash dash
|
||||
|
||||
_dash() {
|
||||
|
@ -1,5 +1,8 @@
|
||||
# Don't continue if direnv is not found
|
||||
command -v direnv &>/dev/null || return
|
||||
# If direnv is not found, don't continue and print a warning
|
||||
if (( ! $+commands[direnv] )); then
|
||||
echo "Warning: direnv not found. Please install direnv and ensure it's in your PATH before using this plugin."
|
||||
return
|
||||
fi
|
||||
|
||||
_direnv_hook() {
|
||||
trap -- '' SIGINT;
|
||||
|
570
plugins/dnf/_dnf5
Normal file
570
plugins/dnf/_dnf5
Normal file
@ -0,0 +1,570 @@
|
||||
#compdef dnf5
|
||||
# based on dnf-5.2.6.2
|
||||
|
||||
# utility functions
|
||||
|
||||
_dnf5_helper() {
|
||||
_call_program specs $service "${(q-)@}" "${(q-)PREFIX}\*" \
|
||||
-qC --assumeno --nogpgcheck 2>/dev/null </dev/null
|
||||
}
|
||||
|
||||
_dnf5_repositories() {
|
||||
# required option: -T (all|disabled|enabled)
|
||||
local selected expl
|
||||
zparseopts -D -E - T:=selected
|
||||
selected=$selected[2]
|
||||
_wanted $selected-repositories expl "$selected repository" \
|
||||
compadd "$@" - "${(@)${(f)$(_dnf5_helper repo list --$selected)}[2,-1]%% *}"
|
||||
}
|
||||
|
||||
_dnf5_packages() {
|
||||
# required option: -T (all|available|installed|upgradable)
|
||||
local selected opt expl
|
||||
zparseopts -D -E - T:=selected
|
||||
selected=$selected[2]
|
||||
case $selected in
|
||||
all) opt='' ;; # option --all does not exist
|
||||
upgradable) opt='--upgrades' ;;
|
||||
*) opt="--$selected" ;;
|
||||
esac
|
||||
_wanted $selected-packages expl "$selected package" \
|
||||
compadd "$@" - $(_dnf5_helper repoquery $opt --qf='%{name} ')
|
||||
}
|
||||
|
||||
_dnf5_rpm_files() {
|
||||
local expl
|
||||
_wanted rpm-files expl 'rpm file' _files -g '(#i)*.rpm(-.)'
|
||||
}
|
||||
|
||||
_dnf5_packages_or_rpms() {
|
||||
if [[ "$words[CURRENT]" = (*/*|\~*) ]]; then # if looks like a path name
|
||||
_dnf_rpm_files
|
||||
else
|
||||
_dnf5_packages "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5_groups() {
|
||||
# optional option: -T (available|installed)
|
||||
local update_policy selected line pat groups
|
||||
zparseopts -D -E - T:=selected
|
||||
selected=$selected[2]
|
||||
if [[ -z $selected ]]; then
|
||||
selected=all
|
||||
opt= # option --all does not exist
|
||||
else
|
||||
opt=--$selected
|
||||
fi
|
||||
# XXX hidden groups are not included
|
||||
for line in ${${(f)"$(_dnf5_helper group list $opt)"}[2,-1]}; do
|
||||
line=( ${(z)line} )
|
||||
groups+=( "$line[1]:$line[2,-2]" )
|
||||
done
|
||||
_describe -t $selected-groups "$selected group" groups
|
||||
}
|
||||
|
||||
_dnf5_environments() {
|
||||
local line envs
|
||||
for line in ${${(f)"$(_dnf5_helper environment list)"}[2,-1]}; do
|
||||
line=( ${(z)line} )
|
||||
envs+=( "$line[1]:$line[2,-2]" )
|
||||
done
|
||||
_describe -t environments 'environment' envs
|
||||
}
|
||||
|
||||
# completers for (several) dnf commands
|
||||
|
||||
_dnf5-advisory () {
|
||||
_arguments : \
|
||||
$advisory_opts \
|
||||
'--contains-pkgs=[only show advisories containing specified packages]: : _sequence _dnf5_packages -T installed' \
|
||||
+ '(with)' \
|
||||
'--with-cve[show only advisories referencing CVE ticket]' \
|
||||
'--with-bz[show only advisories referencing Bugzilla ticket]' \
|
||||
+ '(type)' \
|
||||
'--all[show all advisories]' \
|
||||
'--available[show advisories containing newer versions of installed packages (default)]' \
|
||||
'--installed[show advisories containing equal and older version of installed packages]' \
|
||||
'--updates[show advisories containing upgradable packages]' \
|
||||
+ args \
|
||||
':subcommand:(list info summary)' '*:advisory spec:'
|
||||
}
|
||||
|
||||
_dnf5-group() {
|
||||
local -a tmp
|
||||
if (( CURRENT == 2 )); then
|
||||
tmp=(
|
||||
'list:list all matching groups'
|
||||
'info:print detailed information about groups'
|
||||
'install:install packages from specified groups'
|
||||
'remove:remove removable packages in specified groups'
|
||||
'upgrade:upgrade specified groups and packages in them'
|
||||
)
|
||||
_describe -t subcommands 'subcommand' tmp
|
||||
else
|
||||
case $words[2] in
|
||||
list|info)
|
||||
tmp=(
|
||||
'(--installed)--available[show only available groups]'
|
||||
'(--available)--installed[show only installed groups]'
|
||||
'--hidden[show also hidden groups]'
|
||||
'--contains-pkgs=[show only groups containing specified packages]: : _sequence _dnf5_packages -T all'
|
||||
'*: : _dnf5_groups'
|
||||
)
|
||||
;;
|
||||
install)
|
||||
tmp=( $common_opts
|
||||
'--with-optional[include optional packages from the groups]'
|
||||
'*: : _dnf5_groups -T available' )
|
||||
;|
|
||||
upgrade)
|
||||
tmp=( ${common_opts:#--skip-broken*}
|
||||
'*: : _dnf5_groups -T installed' )
|
||||
;|
|
||||
remove)
|
||||
tmp=( $offline_opts
|
||||
'*: : _dnf5_groups -T installed' )
|
||||
;|
|
||||
install|remove)
|
||||
tmp+=( '--no-packages[operate on groups only, not manipulate any packages]' )
|
||||
;|
|
||||
install|upgrade)
|
||||
tmp+=( $downgrade_opts )
|
||||
;;
|
||||
esac
|
||||
_arguments : $tmp
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5-history() {
|
||||
local -a tmp
|
||||
if (( CURRENT == 2 )); then
|
||||
tmp=(
|
||||
'list:list info about recorded transactions'
|
||||
'info:print detailed about specific transactions'
|
||||
'undo:revert all actions from the specified transaction'
|
||||
'redo:repeat the specified transaction'
|
||||
'rollback:undo all transactions performed after the specified transaction'
|
||||
'store:store the transaction into a directory'
|
||||
)
|
||||
_describe -t subcommands 'subcommand' tmp
|
||||
else
|
||||
case $words[2] in
|
||||
list|info)
|
||||
tmp=( '--reverse[reverse the order of transactions in output]' )
|
||||
;;
|
||||
undo|rollback|redo)
|
||||
tmp=( '--skip-unavailable[allow skipping impossible actions]' )
|
||||
;|
|
||||
undo|rollback)
|
||||
tmp+=( $replay_opts )
|
||||
;;
|
||||
store)
|
||||
tmp=( {-o,--output=}'[directory for storing the transaction (default ./transaction)]: : _directories')
|
||||
esac
|
||||
_arguments : $tmp '2:transaction:( )'
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5-mark() {
|
||||
local -a tmp
|
||||
if (( CURRENT == 2 )); then
|
||||
tmp=(
|
||||
'user:mark the package as user-installed'
|
||||
'dependency:mark the package as a dependency'
|
||||
'weak:mark the package as a weak dependency'
|
||||
'group:mark the package as installed by the specified group'
|
||||
)
|
||||
_describe -t subcommands 'subcommand' tmp
|
||||
else
|
||||
tmp=(
|
||||
'--skip-unavailable[skip packages not installed on the system]'
|
||||
'--store=[store the transaction in specified directory]: : _directories'
|
||||
)
|
||||
if [[ $words[2] = group ]]; then
|
||||
tmp+=( '2:group-id: _dnf5_groups -T installed' )
|
||||
fi
|
||||
_arguments : $tmp '*: : _dnf5_packages -T installed'
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5-module() {
|
||||
local -a tmp
|
||||
if (( CURRENT == 2 )); then
|
||||
tmp=(
|
||||
'list:list module streams'
|
||||
'info:print details about module streams'
|
||||
'enable:enable module streams'
|
||||
'disable:disable modules including all their streams'
|
||||
"reset:reset module state so it's no longer enabled or disabled"
|
||||
)
|
||||
_describe -t subcommands 'subcommand' tmp
|
||||
elif (( CURRENT == 3 )) && [[ $cur = -* ]]; then
|
||||
case $words[2] in
|
||||
list|info) tmp=( --enabled --disabled ) ;;
|
||||
enable) tmp=( --skip-broken --skip-unavailable ) ;;
|
||||
*) tmp=( --skip-unavailable ) ;;
|
||||
esac
|
||||
_wanted options expl 'option' compadd -a tmp
|
||||
else
|
||||
_message 'module spec'
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5-offline() { # also used by the 'system-upgrade' command
|
||||
local -a tmp
|
||||
if (( CURRENT == 2 )); then
|
||||
tmp=(
|
||||
'clean:remove any stored offline transactions and cached packages'
|
||||
'log:list boots during which offline transaction was attempted'
|
||||
'reboot:prepare the system for offline transaction and reboot'
|
||||
)
|
||||
if [[ $cmd = offline ]]; then
|
||||
tmp+=( 'status:show status of the current offline transaction' )
|
||||
else
|
||||
tmp+=( 'download:download all packages needed for upgrade' )
|
||||
fi
|
||||
_describe -t subcommands 'subcommand' tmp && ret=0
|
||||
else
|
||||
case $words[2] in
|
||||
download)
|
||||
_arguments : \
|
||||
'--releasever=[the version to upgrade to]:version number:' \
|
||||
'--no-downgrade:do not install packages older than currently installed' '*: :' && ret=0
|
||||
;;
|
||||
log)
|
||||
_arguments : \
|
||||
'--number=[show log of transaction specified by number]:transaction number:' '*: :' && ret=0
|
||||
;;
|
||||
reboot)
|
||||
_wanted options expl 'option' compadd -- --poweroff && ret=0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5-repoquery() {
|
||||
local v
|
||||
local -a opts=(
|
||||
$advisory_opts
|
||||
'--arch=[limit results to specified architectures]:list of archs: '
|
||||
'--available[limit results to available packages]'
|
||||
'--disable-modular-filtering[include packages of inactive module streams]'
|
||||
'--duplicates[limit to installed duplicate packages]'
|
||||
'--exactdeps[limit to packages that require capability specified by ==what{requires,depends}]'
|
||||
'--extras[limit to installed packages that are not present in any available repository]'
|
||||
'--file=[limit results to packages which own specified file]:list of files: _sequence _files'
|
||||
'--installed[query installed packages]'
|
||||
'--installonly[limit to installed installonly packages]'
|
||||
'--latest-limit=[limit to latest packages of specified number]:number:'
|
||||
'--leaves[limit to groups of installed packages not required by other installed packages]'
|
||||
'--providers-of=[select packages that provide specified attribute]:attribute:(conflicts depends enhances obsoletes provides recommends requires requires_pre suggests supplement)'
|
||||
'--recent[limit to only recently changed packages]'
|
||||
'--recursive[make --whatrequires/--providers-of work recursively]'
|
||||
'--security[limit to packages in security advisories]'
|
||||
'--srpm[use the corresponding source RPM]'
|
||||
'--unneeded[limit to unneeded installed packages]'
|
||||
'--upgrades[limit to available packages that provide upgrade for installed packages]'
|
||||
'--userinstalled[limit to packages that are not installed as dependencies]'
|
||||
'--whatdepends=[limit to packages that require, enhance, recommend, suggest of supplement specified capability]:list of capability:'
|
||||
'--whatconflicts=[limit to packages that conflicts with specified capabilities]:list of capability: '
|
||||
)
|
||||
for v in enhance obsolete provide recommend require suggest supplement; do
|
||||
opts+=( "--what${v}s=[limit to packages that $v specified capabilities]:list of capability: ")
|
||||
done
|
||||
# mutually exclusive formating options
|
||||
opts+=(
|
||||
+ '(format)'
|
||||
'--conflicts[display capabilities that the package conflicts with]'
|
||||
'--depends[display capabilities that the package depends on, enables, recommends, suggests or supplements]'
|
||||
'--files[show files in the package]'
|
||||
'--requires-pre[display capabilities required to run pre/post scripts of the package]'
|
||||
'--sourcerpm[display source RPM of the package]'
|
||||
'--location[display location of the package]'
|
||||
'--info[show detailed information about the package]'
|
||||
'--changelogs[print the package changelogs]'
|
||||
'(- *)--querytags[list tags recognized by --queryformat]'
|
||||
'--queryformat=[specify output format]:format:'
|
||||
)
|
||||
for v in enhance obsolete provide recommend require suggest supplement; do
|
||||
opts+=( "--${v}s[display capabilities ${v}ed by the package]" )
|
||||
done
|
||||
|
||||
_arguments : '*: : _dnf5_packages -T all' $opts
|
||||
}
|
||||
|
||||
# dnf commands
|
||||
|
||||
_dnf5_commands() {
|
||||
local -a dnf_cmds=(
|
||||
'advisory:manage advisories'
|
||||
'autoremove:remove unneeded packages'
|
||||
'check:check for problems in package database'
|
||||
'check-upgrade:check for available package upgrades'
|
||||
'clean:remove or invalidate cached data'
|
||||
'distro-sync:up/downgrade installed packages to the latest available'
|
||||
'downgrade:downgrade packages'
|
||||
'download:download packages'
|
||||
'environment:manage comps environments'
|
||||
'group:manage comps groups'
|
||||
'history:manage transaction history'
|
||||
'info:provide detailed information about packages'
|
||||
'install:install packages'
|
||||
'leaves:list groups of leaf packages'
|
||||
'list:list installed or available packages'
|
||||
'makecache:generate the metadata cache'
|
||||
'mark:change the reason of an installed package'
|
||||
'module:manage modules'
|
||||
'offline:manage offline transactions'
|
||||
'provides:find what package provides the given value'
|
||||
'reinstall:reinstall packages'
|
||||
'remove:remove packages'
|
||||
'replay:replay stored transactions'
|
||||
'repo:manage repositories'
|
||||
'repoquery:search for packages in repositories'
|
||||
'search:search for packages using keywords'
|
||||
'swap:remove software and install another in the single transaction'
|
||||
'system-upgrade:upgrade the system to a new major release'
|
||||
'upgrade:upgrade packages'
|
||||
'versionlock:protect packages from updates to newer versions'
|
||||
)
|
||||
_describe -t dnf-commands 'dnf command' dnf_cmds
|
||||
}
|
||||
|
||||
# subcommands and options
|
||||
|
||||
_dnf5_subcmds_opts() {
|
||||
local cur=$words[CURRENT] cmd=$words[1] expl ret=1
|
||||
local -a tmp
|
||||
# common options
|
||||
local -a offline_opts=(
|
||||
'(--store)--offline[store the transaction to be performed offline]'
|
||||
'(--offline)--store=[store the transaction in specified directory]: : _directories'
|
||||
)
|
||||
local -a common_opts=(
|
||||
$offline_opts
|
||||
'--allowerasing[allow erasing of installed packages]'
|
||||
'--skip-broken[resolve dependency problems by skipping problematic packages]'
|
||||
"--skip-unavailable[skip packages that can't be synchronized]"
|
||||
'--downloadonly[download packages without executing transaction]'
|
||||
)
|
||||
local -a advisory_opts=(
|
||||
'--advisories=[consider only specified advisories]:list of advisories:'
|
||||
'--advisory-severities=[limit to advisories with specified severity]:severity:_sequence compadd - critical important moderate low none'
|
||||
'--bzs=[limit to advisories that fix specified Bugzilla ID]:list of Bugzilla ID:'
|
||||
'--cves=[limit to advisories that fix specified CVE ID]:list of CVD ID]:'
|
||||
'--security[limit to security advisories]'
|
||||
'--bugfix[limit to bugfix advisories]'
|
||||
'--enhancement[limit to enhancement advisories]'
|
||||
'--newpackage[limit to newpackage advisories]'
|
||||
)
|
||||
local -a downgrade_opts=(
|
||||
'(--no-allow-downgrade)--allow-downgrade[enable downgrade of dependencies]'
|
||||
'(--allow-downgrade)--no-allow-downgrade[disable downgrade of dependencies]'
|
||||
)
|
||||
local -a replay_opts=(
|
||||
'--ignore-extras[not consider extra packages]'
|
||||
'--ignore-installed[mismatches between installed and stored transaction are not errors]'
|
||||
)
|
||||
# Deal with some aliases (not comprehensive)
|
||||
case $cmd in
|
||||
check-updgrade) cmd=check-update;;
|
||||
dg) cmd=downgrade;;
|
||||
dsync) cmd=distro-sync;;
|
||||
grp) cmd=group;;
|
||||
if) cmd=info;;
|
||||
in) cmd=install;;
|
||||
ls) cmd=list;;
|
||||
mc) cmd=makecache;;
|
||||
rei) cmd=reinstall;;
|
||||
rm) cmd=remove ;;
|
||||
rq) cmd=repoquery;;
|
||||
se) cmd=search;;
|
||||
update|up) cmd=upgrade;;
|
||||
esac
|
||||
local curcontext="${curcontext%:*:*}:dnf-${cmd}:"
|
||||
|
||||
case $cmd in
|
||||
advisory|group|history|mark|module|offline|repoquery)
|
||||
_dnf5-$cmd && ret=0
|
||||
;;
|
||||
system-upgrade)
|
||||
_dnf5-offline && ret=0
|
||||
;;
|
||||
autoremove)
|
||||
_arguments : $offline_opts && ret=0
|
||||
;;
|
||||
check)
|
||||
_arguments : \
|
||||
'--dependencies[show missing dependencies and conflicts]' \
|
||||
'--duplicates[show duplicated packages]' \
|
||||
'--obsoleted[show obsoleted packages]' && ret=0
|
||||
;;
|
||||
check-upgrade)
|
||||
_arguments : \
|
||||
$advisory_opts \
|
||||
'--changelogs[print package changelogs]' \
|
||||
'--minimal[reports the lowest versions of packages that fix advisories]' \
|
||||
'*: : _dnf5_packages -T installed' && ret=0
|
||||
;;
|
||||
clean)
|
||||
tmp=(
|
||||
'dbcache:remove cache files generated from the repository metadata'
|
||||
'expire-cache:mark the repository metadata expired'
|
||||
'metadata:remove the repository metadata'
|
||||
'packages:remove any cached packages'
|
||||
'all:clean all'
|
||||
)
|
||||
_describe -t cache-types 'cache type' tmp && ret=0
|
||||
;;
|
||||
distro-sync)
|
||||
_arguments : $common_opts '*: : _dnf5_packages -T installed' && ret=0
|
||||
;;
|
||||
downgrade)
|
||||
_arguments : \
|
||||
$common_opts $downgrade_opts \
|
||||
'*: : _dnf5_packages -T installed' && ret=0
|
||||
;;
|
||||
download)
|
||||
_arguments : \
|
||||
'--arch=[limit to packages of specified architecture]:list of architectures:' \
|
||||
'--resolve[resolve and download needed dependencies]' \
|
||||
'--alldeps[with --resolve, also download already installed dependencies]' \
|
||||
'--destdir=[download to the specified directory]: : _directories' \
|
||||
'--srpm[download the source rpm]' \
|
||||
'--url[print the list of URLs where the rpms can be downloaded]' \
|
||||
'*--urlprotocol=[with --url, limit to specified protocols]:protocol:_sequence compadd - http https ftp file' \
|
||||
'*: : _dnf5_packages -T all' && ret=0
|
||||
;;
|
||||
environment)
|
||||
_arguments : \
|
||||
'--available[show only available environments]' \
|
||||
'--installed[show only installed environments]' \
|
||||
':subcommand:(list info)' \
|
||||
'*: : _dnf5_environments' && ret=0
|
||||
;;
|
||||
info|list)
|
||||
_arguments : \
|
||||
'--showduplicates[show all versions of the packages]' \
|
||||
'*: : _dnf5_packages -T all' \
|
||||
+ '(type)' \
|
||||
'--installed[list only installed packages]:*: : _dnf5_packages -T installed' \
|
||||
'--available[list only available packages]:*: : _dnf5_packages -T available' \
|
||||
'--extras[list only extras]' \
|
||||
'--obsoletes[list only installed but obsoleted packages]:*: : _dnf5_packages -T installed' \
|
||||
'--recent[list only recently added packages]' \
|
||||
'--upgrades[list only available upgrades of installed packages]:*: : _dnf5_packages -T upgradable' \
|
||||
'--autoremove[list only packages that will be autoremoved]:*: : _dnf5_packages -T installed' &&ret=0
|
||||
;;
|
||||
install)
|
||||
_arguments : \
|
||||
$common_opts $downgrade_opts $advisory_opts \
|
||||
'*: : _dnf5_packages_or_rpms -T available' && ret=0
|
||||
;;
|
||||
leaves|makecache)
|
||||
# nothing to complete
|
||||
;;
|
||||
provides)
|
||||
_files && ret=0
|
||||
;;
|
||||
reinstall)
|
||||
_arguments : \
|
||||
$common_opts $downgrade_opts \
|
||||
'*: : _dnf5_packages_or_rpms -T installed' && ret=0
|
||||
;;
|
||||
remove)
|
||||
_arguments : \
|
||||
$offline_opts \
|
||||
'--no-autoremove[not remove dependencies that are no longer used]' \
|
||||
'*: : _dnf5_packages -T installed' && ret=0
|
||||
;;
|
||||
replay)
|
||||
_arguments : \
|
||||
$replay_opts \
|
||||
':transaction path:_directories' && ret=0
|
||||
;;
|
||||
repo)
|
||||
_arguments : \
|
||||
'--all[show info about all repositories]' \
|
||||
'--enabled[show info only about enabled repositories]' \
|
||||
'--disabled[show info only about disabled repositories]' \
|
||||
':subcommand:(list info)' && ret=0
|
||||
;;
|
||||
search)
|
||||
_arguments : \
|
||||
'--all[search patterns also inside description and URL fields]' \
|
||||
'--showduplicates[show all versions of packages, not only the latest ones]' \
|
||||
'*:search pattern:' && ret=0
|
||||
;;
|
||||
swap)
|
||||
_arguments : \
|
||||
$offline_opts \
|
||||
'--allowerasing[allow erasing of installed packages]' \
|
||||
': : _dnf5_packages -T installed' \
|
||||
': : _dnf5_packages -T available' && ret=0
|
||||
;;
|
||||
upgrade)
|
||||
_arguments : \
|
||||
${common_opts:#--skip-broken*} $downgrade_opts $advisory_opts \
|
||||
'--minimal[upgrade only to the lowest available versions that fix advisories]' \
|
||||
'--destdir=[specify directory into which downloading packages]: : _directories' \
|
||||
'*: : _dnf5_packages_or_rpms -T upgradable' && ret=0
|
||||
;;
|
||||
versionlock)
|
||||
_arguments : \
|
||||
':subcommand:(add exclude clear delete list)' \
|
||||
'*: : _dnf5_packages -T all' && ret=0
|
||||
;;
|
||||
esac
|
||||
return ret
|
||||
}
|
||||
|
||||
# main completer
|
||||
|
||||
_dnf5() {
|
||||
local curcontext="$curcontext" state state_descr line ret=1
|
||||
typeset -A opt_args
|
||||
local -a opts=(
|
||||
'(-y --assumeyes)--assumeno[answer no for all questions]'
|
||||
'--best[try the best available package version]'
|
||||
'(-C --cacheonly)'{-C,--cacheonly}"[run entirely from system cache, don't update cache]"
|
||||
'--comment=[add comment to transaction history]:comment:'
|
||||
'(-c --config)'{-c+,--config=}'[specify configuration file]:config file:_files'
|
||||
'--debugsolver[dump detailed solving results in file ./debugdata]'
|
||||
'*--disable-plugin=[disable specified plugins]:list of plugin names:'
|
||||
'(--repo)*--disable-repo=[disable specified repos]: : _sequence _dnf5_repositories -T enabled'
|
||||
'--dump-main-config[print main configuration values to stdout]'
|
||||
'*--dump-repo-config=[print repository configuration values to stdout]:repi id'
|
||||
'--dump-variables[print variable values to stdout]'
|
||||
'*--enable-plugin=[enable specified plugins]:list of plugin names:'
|
||||
'*--enable-repo=[enable additional repos]: : _sequence _dnf5_repositories -T disabled'
|
||||
'--forcearch=[force the use of the specified arch]:arch:'
|
||||
'(-)'{-h,--help}'[show the help message]'
|
||||
'--installroot=[set install root]: : _directories'
|
||||
'--no-best[do not limit transactions to best candidates]'
|
||||
'--no-docs[do not install documentation]'
|
||||
'--no-gpgcheck[skip checking GPG signatures on packages]'
|
||||
'--no-plugins[disable all plugins]'
|
||||
'(-q --quiet)'{-q,--quiet}'[show just the relevant content]'
|
||||
'--refresh[force refreshing metadata before running the command]'
|
||||
'--releasever=[override distribution release in config files]:release ver:'
|
||||
'(--disablerepo)*--repo=[enable just the specified repo]: : _sequence _dnf5_repositories -T all'
|
||||
'*--repofrompath=[specify additional repos]:repository_label,path_or_url: '
|
||||
'*--setopt=[override option in config file]:repoid.option=value:'
|
||||
'*--setvar=[override DNF5 variable value]'
|
||||
'--show-new-leaves[show newly installed leaf packages]'
|
||||
'--use-host-config[use config files and variables from host system]'
|
||||
'(- *)--version[show dnf version]'
|
||||
'(-y --assumeyes --assumeno)'{-y,--assumeyes}'[answer yes for all questions]'
|
||||
'*'{-x+,--exclude=}'[exclude specified packages from transaction]: : _sequence _dnf5_packages -T all'
|
||||
)
|
||||
_arguments -C -s : $opts ': :->command' '*:: :->cmd_args' && ret=0
|
||||
|
||||
case $state in
|
||||
command) _dnf5_commands && ret=0 ;;
|
||||
cmd_args) _dnf5_subcmds_opts && ret=0 ;;
|
||||
esac
|
||||
return ret
|
||||
}
|
||||
|
||||
_dnf5 "$@"
|
@ -29,5 +29,5 @@ plugins=(... ember-cli)
|
||||
|
||||
- [BilalBudhani](https://github.com/BilalBudhani)
|
||||
- [eubenesa](https://github.com/eubenesa)
|
||||
- [scottkidder](https://github.com/scottkidder]
|
||||
- [scottkidder](https://github.com/scottkidder)
|
||||
- [t-sauer](https://www.github.com/t-sauer)
|
||||
|
@ -65,6 +65,29 @@ If `yes`, sets the `--icons` option of `eza`, adding icons for files and folders
|
||||
|
||||
Default: `no`
|
||||
|
||||
### `color-scale`
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:eza' 'color-scale' all|age|size
|
||||
```
|
||||
|
||||
Highlight levels of field(s) distinctly. Use comma(,) separated list of `all`, `age`, `size`
|
||||
|
||||
Default: `none`
|
||||
|
||||
### `color-scale-mode`
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:eza' 'color-scale-mode' gradient|fixed
|
||||
```
|
||||
|
||||
Choose the mode for highlighting:
|
||||
|
||||
- `gradient` (default) -- gradient coloring
|
||||
- `fixed` -- fixed coloring
|
||||
|
||||
Default: `gradient`
|
||||
|
||||
### `size-prefix`
|
||||
|
||||
```zsh
|
||||
|
@ -34,6 +34,14 @@ function _configure_eza() {
|
||||
if zstyle -t ':omz:plugins:eza' 'icons'; then
|
||||
_EZA_TAIL+=("--icons=auto")
|
||||
fi
|
||||
zstyle -s ':omz:plugins:eza' 'color-scale' _val
|
||||
if [[ $_val ]]; then
|
||||
_EZA_TAIL+=("--color-scale=$_val")
|
||||
fi
|
||||
zstyle -s ':omz:plugins:eza' 'color-scale-mode' _val
|
||||
if [[ $_val == (gradient|fixed) ]]; then
|
||||
_EZA_TAIL+=("--color-scale-mode=$_val")
|
||||
fi
|
||||
zstyle -s ':omz:plugins:eza' 'time-style' _val
|
||||
if [[ $_val ]]; then
|
||||
_EZA_TAIL+=("--time-style='$_val'")
|
||||
|
35
plugins/foot/README.md
Normal file
35
plugins/foot/README.md
Normal file
@ -0,0 +1,35 @@
|
||||
# foot
|
||||
|
||||
This plugin adds shell integration for [foot, a fast, lightweight and
|
||||
minimalistic Wayland terminal emulator](https://codeberg.org/dnkl/foot).
|
||||
|
||||
To use, add `foot` to the list of plugins in your `.zshrc` file:
|
||||
|
||||
```zsh
|
||||
plugins=(... foot)
|
||||
```
|
||||
|
||||
## Spawning new terminal instances in the current working directory
|
||||
|
||||
When spawning a new terminal instance (with `ctrl+shift+n` by default), the new
|
||||
instance will start in the current working directory.
|
||||
|
||||
## Jumping between prompts
|
||||
|
||||
Foot can move the current viewport to focus prompts of already executed
|
||||
commands (bound to ctrl+shift+z/x by default).
|
||||
|
||||
## Piping last command's output
|
||||
|
||||
The key binding `pipe-command-output` can pipe the last command's output to an
|
||||
application of your choice (similar to the other `pipe-*` key bindings):
|
||||
|
||||
```
|
||||
[key-bindings]
|
||||
pipe-command-output=[sh -c "f=$(mktemp); cat - > $f; footclient emacsclient -nw $f; rm $f"] Control+Shift+g
|
||||
```
|
||||
|
||||
When pressing ctrl+shift+g, the last command's output is written to a
|
||||
temporary file, then an emacsclient is started in a new footclient instance.
|
||||
The temporary file is removed after the footclient instance has closed.
|
||||
|
10
plugins/foot/foot.plugin.zsh
Normal file
10
plugins/foot/foot.plugin.zsh
Normal file
@ -0,0 +1,10 @@
|
||||
function precmd {
|
||||
print -Pn "\e]133;A\e\\"
|
||||
if ! builtin zle; then
|
||||
print -n "\e]133;D\e\\"
|
||||
fi
|
||||
}
|
||||
|
||||
function preexec {
|
||||
print -n "\e]133;C\e\\"
|
||||
}
|
@ -18,7 +18,7 @@ You can change the fetch interval in your .zshrc:
|
||||
GIT_AUTO_FETCH_INTERVAL=1200 # in seconds
|
||||
```
|
||||
|
||||
A log of `git fetch --all` will be saved in `.git/FETCH_LOG`.
|
||||
A log of `git-fetch-all` will be saved in `.git/FETCH_LOG`.
|
||||
|
||||
## Toggle auto-fetch per folder
|
||||
|
||||
|
40
plugins/gitfast/MANUAL.adoc
Normal file
40
plugins/gitfast/MANUAL.adoc
Normal file
@ -0,0 +1,40 @@
|
||||
This project is a friendly fork of the official Git completion
|
||||
(`contrib/completion`) and prompt scripts for Bash, Zsh, and possibly other
|
||||
shells.
|
||||
|
||||
Most Git developers use the Bash shell, for which the completion scripts work
|
||||
rather well, however, Zsh is typically neglected. I've sent many patches to fix
|
||||
the issues, many have been merged, but many have been ignored, thus the need for
|
||||
a canonical location of a good, working Zsh completion.
|
||||
|
||||
There are advantages for Bash users too. Currently the scripts under `contrib` are tied to the
|
||||
specific Git version, for example the completion scripts of version v2.40
|
||||
(https://git.kernel.org/pub/scm/git/git.git/plain/contrib/completion/git-completion.bash?h=v2.40.0[git-completion.bash])
|
||||
have issues with older versions of Git (e.g. v2.33); the ones in
|
||||
this project don't.
|
||||
|
||||
With `git-completion` you can be sure you are using the latest completion that
|
||||
works in both shells, and any Git version.
|
||||
|
||||
This is a sister project of the
|
||||
https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/gitfast[Oh My Zsh
|
||||
gitfast] plugin (that I also maintain), which has similar needs.
|
||||
|
||||
== Installation ==
|
||||
|
||||
* https://github.com/felipec/git-completion/wiki/Bash[Bash instructions]
|
||||
* https://github.com/felipec/git-completion/wiki/Zsh[Zsh instructions]
|
||||
|
||||
== Improvements from upstream ==
|
||||
|
||||
This is a short list of the benefits you get:
|
||||
|
||||
* Easier installation
|
||||
* Tons of bug fixes
|
||||
* Works with older versions of git
|
||||
* Zsh: much more options
|
||||
* Zsh: quoting works properly
|
||||
* Zsh: automatic suffix removal
|
||||
|
||||
For a full list of all the patches on top of upstream git check
|
||||
https://github.com/felipec/git-completion/wiki/Patches[Patches].
|
@ -2,23 +2,11 @@
|
||||
|
||||
# zsh completion wrapper for git
|
||||
#
|
||||
# Copyright (c) 2012-2020 Felipe Contreras <felipe.contreras@gmail.com>
|
||||
# Copyright (c) 2012-2024 Felipe Contreras <felipe.contreras@gmail.com>
|
||||
#
|
||||
# The recommended way to install this script is to make a copy of it as a
|
||||
# file named '_git' inside any directory in your fpath.
|
||||
# The recommended way to use this script is to prepend its location to your $fpath:
|
||||
#
|
||||
# For example, create a directory '~/.zsh/', copy this file to '~/.zsh/_git',
|
||||
# and then add the following to your ~/.zshrc file:
|
||||
#
|
||||
# fpath=(~/.zsh $fpath)
|
||||
#
|
||||
# You need git's bash completion script installed. By default bash-completion's
|
||||
# location will be used (e.g. pkg-config --variable=completionsdir bash-completion).
|
||||
#
|
||||
# If your bash completion script is somewhere else, you can specify the
|
||||
# location in your ~/.zshrc:
|
||||
#
|
||||
# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
|
||||
# fpath=($git_completion_srcdir $fpath)
|
||||
#
|
||||
|
||||
zstyle -T ':completion:*:*:git:*' tag-order && \
|
||||
|
@ -1,6 +1,8 @@
|
||||
# bash/zsh completion support for core Git.
|
||||
#
|
||||
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
|
||||
# Copyright (c) 2012-2024 Felipe Contreras <felipe.contreras@gmail.com>
|
||||
#
|
||||
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
|
||||
# Distributed under the GNU General Public License, version 2.0.
|
||||
#
|
||||
|
@ -5,6 +5,7 @@ files=(
|
||||
/etc/grc.zsh # default
|
||||
/usr/local/etc/grc.zsh # homebrew darwin-x64
|
||||
/opt/homebrew/etc/grc.zsh # homebrew darwin-arm64
|
||||
/home/linuxbrew/.linuxbrew/etc/grc.zsh # linuxbrew
|
||||
/usr/share/grc/grc.zsh # Gentoo Linux (app-misc/grc)
|
||||
)
|
||||
|
||||
|
@ -43,6 +43,22 @@ starting with "_": "MP-1234_fix_dashboard". In both these cases, the issue opene
|
||||
This is also checks if the prefix is in the name, and adds it if not, so: "MP-1234" opens the issue "MP-1234",
|
||||
"mp-1234" opens the issue "mp-1234", and "1234" opens the issue "MP-1234".
|
||||
|
||||
If your branch naming convention deviates, you can overwrite the jira_branch function to determine and echo the Jira issue key yourself.
|
||||
Define a function `jira_branch` after sourcing `oh-my-zsh.sh` in your `.zshrc`.
|
||||
Example:
|
||||
```zsh
|
||||
# Determine branch name from naming convention 'type/KEY-123/description'.
|
||||
function jira_branch() {
|
||||
# Get name of the branch
|
||||
issue_arg=$(git rev-parse --abbrev-ref HEAD)
|
||||
# Strip prefixes like feature/ or bugfix/
|
||||
issue_arg=${issue_arg#*/}
|
||||
# Strip suffixes like /some-branch-description
|
||||
issue_arg=${issue_arg%%/*}
|
||||
# Return the value
|
||||
echo $issue_arg
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Debugging usage
|
||||
|
@ -17,6 +17,30 @@ jira branch Opens an existing issue matching the current bra
|
||||
EOF
|
||||
}
|
||||
|
||||
# If your branch naming convention deviates, you can partially override this plugin function
|
||||
# to determine the jira issue key based on your formatting.
|
||||
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#partially-overriding-an-existing-plugin
|
||||
function jira_branch() {
|
||||
# Get name of the branch
|
||||
issue_arg=$(git rev-parse --abbrev-ref HEAD)
|
||||
# Strip prefixes like feature/ or bugfix/
|
||||
issue_arg=${issue_arg##*/}
|
||||
# Strip suffixes starting with _
|
||||
issue_arg=(${(s:_:)issue_arg})
|
||||
# If there is only one part, it means that there is a different delimiter. Try with -
|
||||
if [[ ${#issue_arg[@]} = 1 && ${issue_arg} == *-* ]]; then
|
||||
issue_arg=(${(s:-:)issue_arg})
|
||||
issue_arg="${issue_arg[1]}-${issue_arg[2]}"
|
||||
else
|
||||
issue_arg=${issue_arg[1]}
|
||||
fi
|
||||
if [[ "${issue_arg:l}" = ${jira_prefix:l}* ]]; then
|
||||
echo "${issue_arg}"
|
||||
else
|
||||
echo "${jira_prefix}${issue_arg}"
|
||||
fi
|
||||
}
|
||||
|
||||
function jira() {
|
||||
emulate -L zsh
|
||||
local action jira_url jira_prefix
|
||||
@ -91,24 +115,7 @@ function jira() {
|
||||
# but `branch` is a special case that will parse the current git branch
|
||||
local issue_arg issue
|
||||
if [[ "$action" == "branch" ]]; then
|
||||
# Get name of the branch
|
||||
issue_arg=$(git rev-parse --abbrev-ref HEAD)
|
||||
# Strip prefixes like feature/ or bugfix/
|
||||
issue_arg=${issue_arg##*/}
|
||||
# Strip suffixes starting with _
|
||||
issue_arg=(${(s:_:)issue_arg})
|
||||
# If there is only one part, it means that there is a different delimiter. Try with -
|
||||
if [[ ${#issue_arg[@]} = 1 && ${issue_arg} == *-* ]]; then
|
||||
issue_arg=(${(s:-:)issue_arg})
|
||||
issue_arg="${issue_arg[1]}-${issue_arg[2]}"
|
||||
else
|
||||
issue_arg=${issue_arg[1]}
|
||||
fi
|
||||
if [[ "${issue_arg:l}" = ${jira_prefix:l}* ]]; then
|
||||
issue="${issue_arg}"
|
||||
else
|
||||
issue="${jira_prefix}${issue_arg}"
|
||||
fi
|
||||
issue=$(jira_branch)
|
||||
else
|
||||
issue_arg=${(U)action}
|
||||
issue="${jira_prefix}${issue_arg}"
|
||||
|
@ -8,6 +8,17 @@ To use it, add `jsontools` to the plugins array in your zshrc file:
|
||||
plugins=(... jsontools)
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
The plugin uses one of these tools to process JSON data, in the following order:
|
||||
|
||||
- `node`
|
||||
- `python3`
|
||||
- `ruby`
|
||||
|
||||
Any of these must be in `$PATH` before the plugin is loaded, otherwise the plugin exits
|
||||
prematurely and the functions will not be available.
|
||||
|
||||
## Usage
|
||||
|
||||
Usage is simple... just take your json data and pipe it into the appropriate jsontool:
|
||||
|
@ -49,6 +49,7 @@ plugins=(... laravel)
|
||||
| `pacoc` | `php artisan config:clear` |
|
||||
| `pavic` | `php artisan view:clear` |
|
||||
| `paroc` | `php artisan route:clear` |
|
||||
| `paopc` | `php artisan optimize:clear` |
|
||||
|
||||
## Queues
|
||||
|
||||
|
@ -36,6 +36,7 @@ alias pacac='php artisan cache:clear'
|
||||
alias pacoc='php artisan config:clear'
|
||||
alias pavic='php artisan view:clear'
|
||||
alias paroc='php artisan route:clear'
|
||||
alias paopc='php artisan optimize:clear'
|
||||
|
||||
# queues
|
||||
alias paqf='php artisan queue:failed'
|
||||
|
@ -9,20 +9,23 @@ chpwd_last_working_dir() {
|
||||
[[ "$ZSH_SUBSHELL" -eq 0 ]] || return 0
|
||||
# Add ".$SSH_USER" suffix to cache file if $SSH_USER is set and non-empty
|
||||
local cache_file="$ZSH_CACHE_DIR/last-working-dir${SSH_USER:+.$SSH_USER}"
|
||||
builtin pwd >| "$cache_file"
|
||||
'builtin' 'echo' '-E' "$PWD" >| "$cache_file"
|
||||
}
|
||||
|
||||
# Changes directory to the last working directory
|
||||
lwd() {
|
||||
# Add ".$SSH_USER" suffix to cache file if $SSH_USER is set and non-empty
|
||||
local cache_file="$ZSH_CACHE_DIR/last-working-dir${SSH_USER:+.$SSH_USER}"
|
||||
[[ -r "$cache_file" ]] && cd "$(cat "$cache_file")"
|
||||
[[ -r "$cache_file" ]] && cd "$(<"$cache_file")"
|
||||
}
|
||||
|
||||
# Jump to last directory automatically unless:
|
||||
# - this isn't the first time the plugin is loaded
|
||||
# - it's not in $HOME directory
|
||||
[[ -n "$ZSH_LAST_WORKING_DIRECTORY" ]] && return
|
||||
[[ "$PWD" != "$HOME" ]] && return
|
||||
#
|
||||
# - This isn't the first time the plugin is loaded
|
||||
# - We're not in the $HOME directory (e.g. if terminal opened a different folder)
|
||||
[[ -z "$ZSH_LAST_WORKING_DIRECTORY" ]] || return
|
||||
[[ "$PWD" == "$HOME" ]] || return
|
||||
|
||||
lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true
|
||||
if lwd 2>/dev/null; then
|
||||
ZSH_LAST_WORKING_DIRECTORY=1
|
||||
fi
|
||||
|
@ -16,7 +16,7 @@ plugins=(... macports)
|
||||
| pc | `sudo port clean --all installed` | Clean up intermediate installation files for installed ports |
|
||||
| pi | `sudo port install` | Install package given as argument |
|
||||
| pli | `port livecheck installed` | Check for updates for installed ports |
|
||||
| plm | `port-livecheck-maintainer` | Check for updates of ports mainained by the specified users |
|
||||
| plm | `port-livecheck-maintainer` | Check for updates of ports maintained by the specified users |
|
||||
| psu | `sudo port selfupdate` | Update ports tree with MacPorts repository |
|
||||
| puni | `sudo port uninstall inactive` | Uninstall inactive ports |
|
||||
| puo | `sudo port upgrade outdated` | Upgrade ports with newer versions available |
|
||||
|
@ -101,8 +101,14 @@ function listMavenCompletions {
|
||||
new_file="../pom.xml"
|
||||
fi
|
||||
|
||||
# if file doesn't exist break
|
||||
file="${file:h}/${new_file}"
|
||||
|
||||
# if the file points to a directory, assume it is a pom.xml in that directory
|
||||
if [[ -d "$file" ]]; then
|
||||
file="${file}/pom.xml"
|
||||
fi
|
||||
|
||||
# if file doesn't exist break
|
||||
if ! [[ -e "$file" ]]; then
|
||||
break
|
||||
fi
|
||||
|
20
plugins/ngrok/README.md
Normal file
20
plugins/ngrok/README.md
Normal file
@ -0,0 +1,20 @@
|
||||
# ngrok plugin
|
||||
|
||||
This plugin adds completion for the [ngrok](https://ngrok.com) CLI.
|
||||
|
||||
To use it, add `ngrok` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... ngrok)
|
||||
```
|
||||
|
||||
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/_ngrok` completions script
|
14
plugins/ngrok/ngrok.plugin.zsh
Normal file
14
plugins/ngrok/ngrok.plugin.zsh
Normal file
@ -0,0 +1,14 @@
|
||||
# Autocompletion for ngrok
|
||||
if (( ! $+commands[ngrok] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `ngrok`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_ngrok" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _ngrok
|
||||
_comps[ngrok]=_ngrok
|
||||
fi
|
||||
|
||||
ngrok completion zsh >| "$ZSH_CACHE_DIR/completions/_ngrok" &|
|
@ -40,7 +40,7 @@ plugins=(... opentofu)
|
||||
|
||||
- `tofu_prompt_info`: shows the current workspace when in an OpenTofu project directory.
|
||||
|
||||
- `tofu_version_prompt_info`: shows the current version of the `tofu` commmand.
|
||||
- `tofu_version_prompt_info`: shows the current version of the `tofu` command.
|
||||
|
||||
To use them, add them to a `PROMPT` variable in your theme or `.zshrc` file:
|
||||
|
||||
|
@ -35,6 +35,7 @@ toggle set the `PER_DIRECTORY_HISTORY_TOGGLE` environment variable.
|
||||
function above (default `^G`)
|
||||
* `PER_DIRECTORY_HISTORY_PRINT_MODE_CHANGE` is a variable which toggles whether
|
||||
the current mode is printed to the screen following a mode change (default `true`)
|
||||
* `HISTORY_START_WITH_GLOBAL` is a global variable that defines how to start the plugin: global or local (default `false`)
|
||||
|
||||
## History
|
||||
|
||||
|
@ -8,30 +8,36 @@ To use it, add `perl` to the plugins array in your zshrc file:
|
||||
plugins=(... perl)
|
||||
```
|
||||
|
||||
## Perlbrew activation
|
||||
|
||||
If the plugin detects that `perlbrew` hasn't been activated, yet there is an installation of it in
|
||||
`$PERLBREW_ROOT`, it'll initialize by default. To avoid this behaviour, set `ZSH_PERLBREW_ACTIVATE=false`
|
||||
before `source oh-my-zsh.sh` in your zshrc.
|
||||
|
||||
## Aliases
|
||||
|
||||
| Aliases | Command | Description |
|
||||
| :------------ | :----------------- | :------------------------------------- |
|
||||
| pbi | `perlbrew install` | Install specific perl version |
|
||||
| pbl | `perlbrew list` | List all perl version installed |
|
||||
| pbo | `perlbrew off` | Go back to the system perl |
|
||||
| pbs | `perlbrew switch` | Turn it back on |
|
||||
| pbu | `perlbrew use` | Use specific version of perl |
|
||||
| pd | `perldoc` | Show the perl documentation |
|
||||
| ple | `perl -wlne` | Use perl like awk/sed |
|
||||
| latest-perl | `curl ...` | Show the latest stable release of Perl |
|
||||
| Aliases | Command | Description |
|
||||
| :---------- | :----------------- | :------------------------------------- |
|
||||
| pbi | `perlbrew install` | Install specific perl version |
|
||||
| pbl | `perlbrew list` | List all perl version installed |
|
||||
| pbo | `perlbrew off` | Go back to the system perl |
|
||||
| pbs | `perlbrew switch` | Turn it back on |
|
||||
| pbu | `perlbrew use` | Use specific version of perl |
|
||||
| pd | `perldoc` | Show the perl documentation |
|
||||
| ple | `perl -wlne` | Use perl like awk/sed |
|
||||
| latest-perl | `curl ...` | Show the latest stable release of Perl |
|
||||
|
||||
## Functions
|
||||
|
||||
* `newpl`: creates a basic Perl script file and opens it with $EDITOR.
|
||||
- `newpl`: creates a basic Perl script file and opens it with $EDITOR.
|
||||
|
||||
* `pgs`: Perl Global Substitution: `pgs <find_pattern> <replace_pattern> <filename>`
|
||||
Looks for `<find_pattern>` and replaces it with `<replace_pattern>` in `<filename>`.
|
||||
- `pgs`: Perl Global Substitution: `pgs <find_pattern> <replace_pattern> <filename>` Looks for
|
||||
`<find_pattern>` and replaces it with `<replace_pattern>` in `<filename>`.
|
||||
|
||||
* `prep`: Perl grep, because 'grep -P' is terrible: `prep <pattern> [<filename>]`
|
||||
Lets you work with pipes or files (if no `<filename>` provided, use stdin).
|
||||
- `prep`: Perl grep, because 'grep -P' is terrible: `prep <pattern> [<filename>]` Lets you work with pipes or
|
||||
files (if no `<filename>` provided, use stdin).
|
||||
|
||||
## Requirements
|
||||
|
||||
In order to make this work, you will need to have perl installed.
|
||||
More info on the usage and install: https://www.perl.org/get.html
|
||||
In order to make this work, you will need to have perl installed. More info on the usage and install:
|
||||
https://www.perl.org/get.html
|
||||
|
@ -54,3 +54,12 @@ pgs() { # [find] [replace] [filename]
|
||||
prep() { # [pattern] [filename unless STDOUT]
|
||||
perl -nle 'print if /'"$1"'/;' $2
|
||||
}
|
||||
|
||||
# If the 'perlbrew' function isn't defined, perlbrew isn't setup.
|
||||
if [[ $ZSH_PERLBREW_ACTIVATE != false ]] && (( ! $+functions[perlbrew] )); then
|
||||
local _perlbrew="${PERLBREW_ROOT:-${HOME}/perl5/perlbrew}"
|
||||
if [[ -f "${_perlbrew}/etc/bashrc" ]]; then
|
||||
source "${_perlbrew}/etc/bashrc"
|
||||
fi
|
||||
unset _perlbrew
|
||||
fi
|
||||
|
@ -19,7 +19,8 @@ if zstyle -T ':omz:plugins:pipenv' auto-shell; then
|
||||
if [[ ! -f "$PWD/Pipfile" ]]; then
|
||||
if [[ "$PIPENV_ACTIVE" == 1 ]]; then
|
||||
if [[ "$PWD" != "$pipfile_dir"* ]]; then
|
||||
exit
|
||||
unset PIPENV_ACTIVE pipfile_dir
|
||||
deactivate
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@ -28,7 +29,8 @@ if zstyle -T ':omz:plugins:pipenv' auto-shell; then
|
||||
if [[ "$PIPENV_ACTIVE" != 1 ]]; then
|
||||
if [[ -f "$PWD/Pipfile" ]]; then
|
||||
export pipfile_dir="$PWD"
|
||||
pipenv shell
|
||||
source "$(pipenv --venv)/bin/activate"
|
||||
export PIPENV_ACTIVE=1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
398
plugins/pm2/_pm2
398
plugins/pm2/_pm2
@ -1,16 +1,233 @@
|
||||
#!/bin/zsh -f
|
||||
#compdef pm2
|
||||
#autoload
|
||||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# Completion script for pm2 5.2.2 (https://pm2.keymetrics.io/).
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Myoungdo Park <mdo.park@gmail.com>
|
||||
# * Shohei Yoshida <https://github.com/syohex>
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
local -a _1st_arguments
|
||||
_pm2() {
|
||||
typeset -A opt_args
|
||||
local context state line
|
||||
|
||||
_1st_arguments=(
|
||||
local curcontext="$curcontext"
|
||||
|
||||
local ret=1
|
||||
|
||||
_arguments -C \
|
||||
'(- *)'{-v,-V,--version}'[print pm2 version]' \
|
||||
'(-s --silent)'{-s,--silent}'[hide all messages]' \
|
||||
'--ext[watch only this file extension]:extension' \
|
||||
'(-n --name)'{-n,--name}'[set a name for the process in the process list]:name' \
|
||||
'(-m --mini-list)'{-m,--mini-list}'[display a compacted list without formatting]' \
|
||||
'--interpreter[set a specific interpreter to use for executing app(default: node)]:prog' \
|
||||
'(--interpreter-args --node-args)'{--interpreter-args,--node-args}'[set arguments to pass to the interpreter]:args' \
|
||||
'(-o --output)'{-o,--output}'[specify log file for stdout]: :_files' \
|
||||
'(-e --error)'{-e,--error}'[specify log file for stderr]: :_files' \
|
||||
'(-l --log)'{-l,--log}'[specify log file which gathers both stdout and stderr]' \
|
||||
'--filter-env[filter out outgoing global values that contain provided strings]:envs' \
|
||||
'--log-type[specify log output style]: :(raw json)' \
|
||||
'--log-date-format[specify log output style]:format' \
|
||||
'--time[enable time logging]' \
|
||||
'--disable-logs[disable all logs storage]' \
|
||||
'*--env[specify which set of environment variables from ecosystem file must be injected]:env' \
|
||||
'(-a --update-env)'{-a,--update-env}'[force and update of the environment with restart/reload]' \
|
||||
'(-f --force)'{-f,--force}'[force actions]' \
|
||||
'(-i --instances)'{-i,--instances}'[launch number instances]:num' \
|
||||
'--parallel[number of parallel actions]:num' \
|
||||
'--shutdown-with-message[shutdown an application with process.send("shutdown") instead of process.kill(pid, SIGINT)]' \
|
||||
'(-p --pid)'{-p,--pid}'[specify pid file]: :_files' \
|
||||
'(-k --kill-timeout)'{-k,--kill-timeout}'[delay before sending final SIGKILL signal to process]:delay' \
|
||||
'--listen-timeout[listen timeout an application reload]:delay' \
|
||||
'--max-memory-restart[restart the app if an amount of memory is exceeded (in bytes)]:bytes' \
|
||||
'--restart-delay[specify a delay between restarts(in milliseconds)]:delay' \
|
||||
'--exp-backoff-restart-delay[specify a delay between restarts(in milliseconds)]:delay' \
|
||||
'(-x --execute-command)'{-e,--execute-command}'[execute a program using fork system]' \
|
||||
'--max-restarts[only start the script COUNT times]:count' \
|
||||
'(-u --user)'{-u,--user}'[define user when generating startup script]:username' \
|
||||
'--uid[run target script with <uid> rights]:uid' \
|
||||
'--gid[run target script with <gid> rights]:gui' \
|
||||
'--namespace[start application within specified namespace]:namespace' \
|
||||
'--cwd[run target script from path <cwd>]:cwd:_paths -/' \
|
||||
'--hp[define home path when generating startup script]: :_paths -/' \
|
||||
'--wait-ip[override systemd script to wait for full internet connectivity to launch pm2]' \
|
||||
'--service-name[define service name when generating startup script]' \
|
||||
'(-c --cron --cron-restart)'{-c,--cron,--cron-restart}'[restart a running process based on a cron pattern]:pattern' \
|
||||
'(-w --write)'{-w,--write}'[write configuration in local folder]' \
|
||||
'--no-daemon[run pm2 daemon in the foreground if it does not exist already]' \
|
||||
'(--disable-source-map-support --source-map-support)--source-map-support[force source map support]' \
|
||||
'--only[with json declaration, allow to only act on one application]:app' \
|
||||
'(--disable-source-map-support --source-map-support)--disable-source-map-support[force disable source map support]' \
|
||||
'--wait-ready[ask pm2 to wait for ready event from your app]' \
|
||||
'--merge-logs[merge logs from different instances but keep error and out separated]' \
|
||||
'*--watch[watch application folder for changes]: :_files -/' \
|
||||
'*--ignore-watch[list of paths to ignore]: :_files' \
|
||||
'--no-color[skip colors]' \
|
||||
'--no-vizion[start an app without vizion feature]' \
|
||||
'--np-autorestart[start an app without automatic restart]' \
|
||||
'--no-treekill[Only kill the main process, not detached children]' \
|
||||
'--no-pmx[start an app without pmx]' \
|
||||
'--no-automation[start an app without automation]' \
|
||||
'(--disable-trace --trace)--trace[enable transaction tracing with km]' \
|
||||
'(--disable-trace --trace)--disable-trace[disable transaction tracing with km]' \
|
||||
"--sort[sort process according to field's]:field_name" \
|
||||
'--attach[attach logging after your start/restart/stop/reload]' \
|
||||
'--v8[enable v8 data collecting]' \
|
||||
'--event-loop-inspector[enable event-loop-inspector dump in pmx]' \
|
||||
'--deep-monitoring[enable all monitoring tools]' \
|
||||
'(- *)'{-h,--help}'[output usage information]' \
|
||||
'1: :_pm2_subcommands' \
|
||||
'*:: :->subcmds' && return 0
|
||||
|
||||
case "$state" in
|
||||
(subcmds)
|
||||
case $words[1] in
|
||||
(start)
|
||||
_arguments \
|
||||
'--watch[watch folder for changes]' \
|
||||
'--fresh[Rebuild Dockerfile]' \
|
||||
'--daemon[Run container in Daemon mode(debug purposes)]' \
|
||||
'--container[Start application in container mode]' \
|
||||
'--dist[--with-container; change local Dockerfile to containerize all files in current directory]' \
|
||||
'--image-name[with --dist; set the exported image name]:name' \
|
||||
'--node-version[with --container, set a specific major Node.js version]:version' \
|
||||
'--dockerdaemon[for debugging purpose]' \
|
||||
'(- *)'{-h,--help}'[output usage information]' \
|
||||
'*: :_pm2_id_namespace_file' \
|
||||
&& ret=0
|
||||
;;
|
||||
(trigger)
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[output usage information]' \
|
||||
'1: :_pm2_id_names' \
|
||||
&& ret=0
|
||||
;;
|
||||
(deploy|startOrRestart|startOrReload|startOrGracefulReload)
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[output usage information]' \
|
||||
'1: :_files -g "*.json"' \
|
||||
&& ret=0
|
||||
;;
|
||||
(stop|restart)
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[output usage information]' \
|
||||
'--watch[Stop watching folder for changes]' \
|
||||
'*: :_pm2_id_namespace_all' \
|
||||
&& ret=0
|
||||
;;
|
||||
(reload|delete|reset)
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[output usage information]' \
|
||||
'*: :_pm2_id_namespace_all' \
|
||||
&& ret=0
|
||||
;;
|
||||
(module:install)
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[output usage information]' \
|
||||
'--tarball[is local tarball]' \
|
||||
'--install[run yarn install before starting module]' \
|
||||
'--docker[is docker container]' \
|
||||
'--v1[install module in v1 manner(do not use it)]' \
|
||||
'--safe[keep module backup, if new module fail = restore with previous]:time' \
|
||||
&& ret=0
|
||||
;;
|
||||
(publish|module:publish)
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[output usage information]' \
|
||||
'--npm[publish on npm]' \
|
||||
'*: :_files -/' \
|
||||
&& ret=0
|
||||
;;
|
||||
(link)
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[output usage information]' \
|
||||
'--info-node[set url info node]:url' \
|
||||
&& ret=0
|
||||
;;
|
||||
(plus)
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[output usage information]' \
|
||||
'--info-node[set url info node]:url' \
|
||||
'(-d --discrete)'{-d,--discrete}'[silent mode]' \
|
||||
'(-a --install-all)'{-a,--install-all}'[install all modules (force yes)]' \
|
||||
&& ret=0
|
||||
;;
|
||||
(dump|save)
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[output usage information]' \
|
||||
'--force[force deletion of dump file even if empty]' \
|
||||
&& ret=0
|
||||
;;
|
||||
(send|attach|describe|env)
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[output usage information]' \
|
||||
'1: :_pm2_id_names' \
|
||||
&& ret=0
|
||||
;;
|
||||
(slist|sysinfos)
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[output usage information]' \
|
||||
'--tree[show as tree]' \
|
||||
&& ret=0
|
||||
;;
|
||||
(logs)
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[output usage information]' \
|
||||
'--json[json log output]' \
|
||||
'--format[formatted log output]' \
|
||||
'--raw[raw output]' \
|
||||
'--err[only shows error output]' \
|
||||
'--out[only shows standard output]' \
|
||||
'--line[output the last N lines, instead of the last 15 by default]:lines' \
|
||||
'--timestamp[add timestamps(default format YYYY-MM-DD-HH:mm:ss)]:format' \
|
||||
'--nostream[print logs without launching the log stream]' \
|
||||
'*--highlight[highlights the given value]' \
|
||||
'1: :_pm2_id_namespace' \
|
||||
&& ret=0
|
||||
;;
|
||||
(serve)
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[output usage information]' \
|
||||
'--port[specify port to listen to]:port' \
|
||||
'--spa[always serving index.html on inexistent sub path]' \
|
||||
'--basic-auth-username[set basic auth username]:username' \
|
||||
'--basic-auth-password[set basic auth password]:password' \
|
||||
'--monitor[frontend app monitoring]:app' \
|
||||
'*: :_files -/' \
|
||||
&& ret=0
|
||||
;;
|
||||
(*)
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[output usage information]' \
|
||||
'*: :_files' \
|
||||
&& ret=0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
(( $+functions[_pm2_subcommands] )) ||
|
||||
_pm2_subcommands() {
|
||||
local -a subcommands=(
|
||||
"start:start and daemonize an app"
|
||||
"trigger:trigger process action"
|
||||
"deploy:deploy your json"
|
||||
"startOrRestart:start or restart JSON file"
|
||||
"startOrReload:start or gracefully reload JSON file"
|
||||
"pid:return pid of [app_name] or all"
|
||||
"create:return pid of [app_name] or all"
|
||||
"startOrGracefulReload:start or gracefully reload JSON file"
|
||||
"stop:stop a process"
|
||||
"restart:restart a process"
|
||||
"scale:scale up/down a process in cluster mode depending on total_number param"
|
||||
@ -23,18 +240,23 @@ _1st_arguments=(
|
||||
"sendSignal:send a system signal to the target process"
|
||||
"ping:ping pm2 daemon - if not up it will launch it"
|
||||
"updatePM2:update in-memory PM2 with local PM2"
|
||||
"update:update in-memory PM2 with local PM2"
|
||||
"install:install or update a module and run it forever"
|
||||
"module\:install:install or update a module and run it forever"
|
||||
"module\:update:update a module and run it forever"
|
||||
"module\:generate:Generate a sample module in current folder"
|
||||
"uninstall:stop and uninstall a module"
|
||||
"module\:uninstall:stop and uninstall a module"
|
||||
"package:Check & Package TAR type module"
|
||||
"publish:Publish the module you are currently on"
|
||||
"module\:publish:Publish the module you are currently on"
|
||||
"set:sets the specified config <key> <value>"
|
||||
"multiset:multiset eg \"key1 val1 key2 val2\""
|
||||
"get:get value for <key>"
|
||||
"conf:get / set module config values"
|
||||
"config:get / set module config values"
|
||||
"unset:clears the specified config <key>"
|
||||
"report:give a full pm2 report for https\://github.com/Unitech/pm2/issues"
|
||||
"report:give a full pm2 report for https://github.com/Unitech/pm2/issues"
|
||||
"link:link with the pm2 monitoring dashboard"
|
||||
"unlink:unlink with the pm2 monitoring dashboard"
|
||||
"monitor:monitor target process"
|
||||
@ -43,8 +265,8 @@ _1st_arguments=(
|
||||
"plus:enable pm2 plus"
|
||||
"login:Login to pm2 plus"
|
||||
"logout:Logout from pm2 plus"
|
||||
"web:launch a health API on 0.0.0.0\:9615"
|
||||
"dump:dump all processes for resurrecting them later"
|
||||
"save:dump all processes for resurrecting them later"
|
||||
"cleardump:Create empty dump file"
|
||||
"send:send stdin to <pm_id>"
|
||||
"attach:attach stdin/stdout to application identified by <pm_id>"
|
||||
@ -52,15 +274,27 @@ _1st_arguments=(
|
||||
"unstartup:disable the pm2 startup hook"
|
||||
"startup:enable the pm2 startup hook"
|
||||
"logrotate:copy default logrotate configuration"
|
||||
"ecosystem:generate a process conf file. (mode = null or simple)"
|
||||
"ecosystem:generate a process conf file"
|
||||
"init:generate a process conf file"
|
||||
"reset:reset counters for process"
|
||||
"describe:describe all parameters of a process id"
|
||||
"describe:describe all parameters of a process"
|
||||
"desc:describe all parameters of a process"
|
||||
"info:describe all parameters of a process"
|
||||
"show:describe all parameters of a process"
|
||||
"env:list all environment variables of a process id"
|
||||
"list:list all processes"
|
||||
"l:list all processes"
|
||||
"ps:list all processes"
|
||||
"status:list all processes"
|
||||
"jlist:list all processes in JSON format"
|
||||
"sysmonit:start system monitoring daemon"
|
||||
"slist:list system infos in JSON"
|
||||
"sysinfos:list system infos in JSON"
|
||||
"prettylist:print json in a prettified JSON"
|
||||
"monit:launch termcaps monitoring"
|
||||
"imonit:launch legacy termcaps monitoring"
|
||||
"dashboard:launch dashboard with monitoring and logs"
|
||||
"dash:launch dashboard with monitoring and logs"
|
||||
"flush:flush logs"
|
||||
"reloadLogs:reload all logs"
|
||||
"logs:stream logs file. Default stream all logs"
|
||||
@ -70,99 +304,71 @@ _1st_arguments=(
|
||||
"backward:downgrades repository to the previous commit for a given app"
|
||||
"deepUpdate:performs a deep update of PM2"
|
||||
"serve:serve a directory over http via port"
|
||||
"autoinstall:auto install"
|
||||
"examples:display pm2 usage examples"
|
||||
)
|
||||
)
|
||||
|
||||
local -a id_names
|
||||
|
||||
_id_names() {
|
||||
local app_list
|
||||
app_list=`pm2 list -m`
|
||||
|
||||
local -a names ids
|
||||
names=(`echo $app_list | grep '+---' | awk '{print $2}'`)
|
||||
ids=(`echo $app_list | grep 'pm2 id' | awk '{print $4}'`)
|
||||
|
||||
if (( ${#ids} > 0 )); then
|
||||
for i in {1..${#ids}}; do
|
||||
id_names+=( "${ids[i]}:${names[i]}" )
|
||||
done
|
||||
fi
|
||||
_describe -t subcommands 'subcommand' subcommands "$@"
|
||||
}
|
||||
|
||||
_arguments \
|
||||
'(-v --version)'{-v,--version}'[output version]' \
|
||||
'(-h --help)'{-h,--help}'[output usage information]' \
|
||||
'*:: :->subcmds' && return 0
|
||||
(( $+functions[_pm2_id_names] )) ||
|
||||
_pm2_id_names() {
|
||||
local app_list=$(pm2 list -m)
|
||||
local -a names=(${(@f)"$(echo $app_list | awk '/^\+---/{sub("+--- ", ""); print}')"})
|
||||
local -a ids=(${(@f)"$(echo $app_list | awk '/^pm2 id/{sub("pm2 id :", ""); print}')"})
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe "command" _1st_arguments
|
||||
return
|
||||
if (( ${#ids} > 0 )); then
|
||||
local -a id_names
|
||||
for i in {1..${#ids}}; do
|
||||
id_names+=( "${ids[i]}:${names[i]}" )
|
||||
done
|
||||
|
||||
_describe 'id' id_names
|
||||
fi
|
||||
}
|
||||
|
||||
(( $+functions[_pm2_namespaces] )) ||
|
||||
_pm2_namespaces() {
|
||||
local -a namespaces=(${(@f)"$(pm2 list -m | awk '/^namespace :/{ print $3 }')"})
|
||||
if (( ${#namespaces} > 0 )); then
|
||||
_values 'namespace' $namespaces
|
||||
fi
|
||||
}
|
||||
|
||||
(( $+functions[_pm2_id_namespace] )) ||
|
||||
_pm2_id_namespace() {
|
||||
_alternative \
|
||||
'ids:id:_pm2_id_names' \
|
||||
'namespaces:namespace:_pm2_namespaces'
|
||||
}
|
||||
|
||||
(( $+functions[_pm2_id_namespace_all] )) ||
|
||||
_pm2_id_namespace_all() {
|
||||
_alternative \
|
||||
'ids:id:_pm2_id_names' \
|
||||
'namespaces:namespace:_pm2_namespaces' \
|
||||
'all:all:(all)'
|
||||
}
|
||||
|
||||
(( $+functions[_pm2_id_namespace_file] )) ||
|
||||
_pm2_id_namespace_file() {
|
||||
_alternative \
|
||||
'ids:id:_pm2_id_names' \
|
||||
'namespaces:namespace:_pm2_namespaces' \
|
||||
'files:file:_files'
|
||||
}
|
||||
|
||||
if [ "$funcstack[1]" = "_pm2" ]; then
|
||||
_pm2 "$@"
|
||||
else
|
||||
compdef _pm2 pm2
|
||||
fi
|
||||
|
||||
local -a id_comp id_all_comp id_all_files_comp start_options logs_options
|
||||
id_comp=('1: :->id_comp')
|
||||
id_all_comp=('1: :->id_all_comp')
|
||||
id_all_files_comp=('1: :->id_all_files_comp')
|
||||
start_options=(
|
||||
'--watch[Watch folder for changes]'
|
||||
'--fresh[Rebuild Dockerfile]'
|
||||
'--daemon[Run container in Daemon mode (debug purposes)]'
|
||||
'--container[Start application in container mode]'
|
||||
'--dist[with --container; change local Dockerfile to containerize all files in current directory]'
|
||||
'--image-name[with --dist; set the exported image name]'
|
||||
'--node-version[with --container, set a specific major Node.js version]'
|
||||
'--dockerdaemon[for debugging purpose]'
|
||||
'(-h --help)'{-h,--help}'[output usage information]'
|
||||
$id_all_files_comp
|
||||
)
|
||||
logs_options=(
|
||||
'--json[json log output]'
|
||||
'--format[formatted log output]'
|
||||
'--raw[raw output]'
|
||||
'--err[only shows error output]'
|
||||
'--out[only shows standard output]'
|
||||
'--lines[output the last N lines, instead of the last 15 by default]'
|
||||
'--timestamp[add timestamps (default format YYYY-MM-DD-HH:mm:ss)]'
|
||||
'--nostream[print logs without launching the log stream]'
|
||||
'(-h --help)'{-h,--help}'[output usage information]'
|
||||
$id_all_comp
|
||||
)
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
|
||||
case "$words[1]" in
|
||||
start)
|
||||
_arguments $start_options && return 0
|
||||
;;
|
||||
logs)
|
||||
_arguments $logs_options && return 0
|
||||
;;
|
||||
stop|restart|delete|reload|reset)
|
||||
_arguments $id_all_comp && return 0
|
||||
;;
|
||||
env|inspect|monitor|unmonitor|describe)
|
||||
_arguments $id_comp && return 0
|
||||
;;
|
||||
deploy|startOrRestart|startOrReload)
|
||||
_files ;;
|
||||
esac
|
||||
|
||||
case "$state" in
|
||||
id_comp)
|
||||
_id_names
|
||||
_alternative \
|
||||
'args:app args:(($id_names))'
|
||||
;;
|
||||
id_all_comp)
|
||||
_id_names
|
||||
id_names+=(all)
|
||||
_alternative \
|
||||
'args:app args:(($id_names))'
|
||||
;;
|
||||
id_all_files_comp)
|
||||
_id_names
|
||||
id_names+=(all)
|
||||
_alternative \
|
||||
'args:app args:(($id_names))' \
|
||||
'files:filename:_files'
|
||||
;;
|
||||
esac
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
|
@ -6,8 +6,7 @@ _togglePoetryShell() {
|
||||
fi
|
||||
|
||||
# Deactivate the current environment if moving out of a Poetry directory or into a different Poetry directory
|
||||
if [[ $poetry_active -eq 1 ]] && [[ $in_poetry_dir -eq 0 ]] \
|
||||
&& [[ "$PWD" != "$poetry_dir"* ]]; then
|
||||
if [[ $poetry_active -eq 1 ]] && { [[ $in_poetry_dir -eq 0 ]] || [[ "$PWD" != "$poetry_dir"* ]]; }; then
|
||||
export poetry_active=0
|
||||
unset poetry_dir
|
||||
(( $+functions[deactivate] )) && deactivate
|
||||
|
@ -26,6 +26,14 @@ eval "$(pyenv init --path)"
|
||||
- `ZSH_PYENV_VIRTUALENV`: if set to `false`, the plugin will not load pyenv-virtualenv
|
||||
when it finds it.
|
||||
|
||||
- `ZSH_THEME_PYENV_NO_SYSTEM`: if set to `true`, the plugin will not show the system or
|
||||
default Python version when it finds it.
|
||||
- `ZSH_THEME_PYENV_PREFIX`: the prefix to display before the Python version in
|
||||
the prompt.
|
||||
|
||||
- `ZSH_THEME_PYENV_SUFFIX`: the prefix to display after the Python version in
|
||||
the prompt.
|
||||
|
||||
## Functions
|
||||
|
||||
- `pyenv_prompt_info`: displays the Python version in use by pyenv; or the global Python
|
||||
|
@ -88,13 +88,19 @@ if [[ $FOUND_PYENV -eq 1 ]]; then
|
||||
|
||||
function pyenv_prompt_info() {
|
||||
local version="$(pyenv version-name)"
|
||||
echo "${version:gs/%/%%}"
|
||||
if [[ "$ZSH_THEME_PYENV_NO_SYSTEM" == "true" ]] && [[ "${version}" == "system" ]]; then
|
||||
return
|
||||
fi
|
||||
echo "${ZSH_THEME_PYENV_PREFIX=}${version:gs/%/%%}${ZSH_THEME_PYENV_SUFFIX=}"
|
||||
}
|
||||
else
|
||||
# Fall back to system python
|
||||
function pyenv_prompt_info() {
|
||||
if [[ "$ZSH_THEME_PYENV_NO_SYSTEM" == "true" ]]; then
|
||||
return
|
||||
fi
|
||||
local version="$(python3 -V 2>&1 | cut -d' ' -f2)"
|
||||
echo "system: ${version:gs/%/%%}"
|
||||
echo "${ZSH_THEME_PYENV_PREFIX=}system: ${version:gs/%/%%}${ZSH_THEME_PYENV_SUFFIX=}"
|
||||
}
|
||||
fi
|
||||
|
||||
|
@ -24,16 +24,45 @@ plugins=(... python)
|
||||
The plugin provides three utilities to manage Python 3.3+ [venv](https://docs.python.org/3/library/venv.html)
|
||||
virtual environments:
|
||||
|
||||
- `mkv [name]`: make a new virtual environment called `name` (default: if set `$PYTHON_VENV_NAME`, else
|
||||
`venv`) in the current directory.
|
||||
- `mkv [name]`: make a new virtual environment called `name` in the current directory.
|
||||
**Default**: `$PYTHON_VENV_NAME` if set, otherwise `venv`.
|
||||
|
||||
- `vrun [name]`: Activate the virtual environment called `name` (default: if set `$PYTHON_VENV_NAME`, else
|
||||
`venv`) in the current directory.
|
||||
- `vrun [name]`: activate the virtual environment called `name` in the current directory.
|
||||
**Default**: the first existing in `$PYTHON_VENV_NAMES`.
|
||||
|
||||
- `auto_vrun`: Automatically activate the venv virtual environment when entering a directory containing
|
||||
- `auto_vrun`: automatically activate the venv virtual environment when entering a directory containing
|
||||
`<venv-name>/bin/activate`, and automatically deactivate it when navigating out of it (keeps venv activated
|
||||
in subdirectories).
|
||||
- To enable the feature, set `export PYTHON_AUTO_VRUN=true` before sourcing oh-my-zsh.
|
||||
- Plugin activates first virtual environment in lexicographic order whose name begins with `<venv-name>`.
|
||||
- To enable the feature, set `PYTHON_AUTO_VRUN=true` before sourcing oh-my-zsh.
|
||||
- The plugin activates the first existing virtual environment, in order, appearing in `$PYTON_VENV_NAMES`.
|
||||
The default virtual environment name is `venv`. To use a different name, set
|
||||
`export PYTHON_VENV_NAME=<venv-name>`. For example: `export PYTHON_VENV_NAME=".venv"`
|
||||
`PYTHON_VENV_NAME=<venv-name>`. For example: `PYTHON_VENV_NAME=".venv"`
|
||||
|
||||
### Settings
|
||||
|
||||
You can set these variables in your `.zshrc` file, before Oh My Zsh is sourced.
|
||||
For example:
|
||||
|
||||
```sh
|
||||
PYTHON_VENV_NAME=".venv"
|
||||
PYTHON_VENV_NAMES=($PYTHON_VENV_NAME venv)
|
||||
...
|
||||
plugins=(... python)
|
||||
source "$ZSH/oh-my-zsh.sh"
|
||||
```
|
||||
|
||||
|
||||
## `$PYTHON_VENV_NAME`
|
||||
|
||||
**Default**: `venv`.
|
||||
|
||||
Preferred name for virtual environments, for example when creating via `mkv`.
|
||||
|
||||
## `$PYTHON_VENV_NAMES`
|
||||
|
||||
**Default**: `$PYTHON_VENV_NAME venv .venv`.
|
||||
|
||||
Array of virtual environment names to be checked, in order, by `vrun` and `auto_vrun`.
|
||||
This means these functions will load the first existing virtual environment in this list.
|
||||
Duplicate names are ignored.
|
||||
|
||||
|
@ -47,12 +47,29 @@ alias pygrep='grep -nr --include="*.py"'
|
||||
alias pyserver="python3 -m http.server"
|
||||
|
||||
|
||||
## venv utilities
|
||||
## venv settings
|
||||
: ${PYTHON_VENV_NAME:=venv}
|
||||
|
||||
# Array of possible virtual environment names to look for, in order
|
||||
# -U for removing duplicates
|
||||
typeset -gaU PYTHON_VENV_NAMES
|
||||
[[ -n "$PYTHON_VENV_NAMES" ]] || PYTHON_VENV_NAMES=($PYTHON_VENV_NAME venv .venv)
|
||||
|
||||
# Activate a the python virtual environment specified.
|
||||
# If none specified, use $PYTHON_VENV_NAME, else 'venv'.
|
||||
# If none specified, use the first existing in $PYTHON_VENV_NAMES.
|
||||
function vrun() {
|
||||
if [[ -z "$1" ]]; then
|
||||
local name
|
||||
for name in $PYTHON_VENV_NAMES; do
|
||||
local venvpath="${name:P}"
|
||||
if [[ -d "$venvpath" ]]; then
|
||||
vrun "$name"
|
||||
return $?
|
||||
fi
|
||||
done
|
||||
echo >&2 "Error: no virtual environment found in current directory"
|
||||
fi
|
||||
|
||||
local name="${1:-$PYTHON_VENV_NAME}"
|
||||
local venvpath="${name:P}"
|
||||
|
||||
@ -91,10 +108,11 @@ if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then
|
||||
fi
|
||||
|
||||
if [[ $PWD != ${VIRTUAL_ENV:h} ]]; then
|
||||
for _file in "${PYTHON_VENV_NAME}"*/bin/activate(N.); do
|
||||
local file
|
||||
for file in "${^PYTHON_VENV_NAMES[@]}"/bin/activate(N.); do
|
||||
# make sure we're not in a venv already
|
||||
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
|
||||
source $_file > /dev/null 2>&1
|
||||
source $file > /dev/null 2>&1
|
||||
break
|
||||
done
|
||||
fi
|
||||
|
9
plugins/rclone/README.md
Normal file
9
plugins/rclone/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Rclone plugin
|
||||
|
||||
This plugin adds completion for [Rclone](https://rclone.org/), the command-line program to manage files on cloud storage.
|
||||
|
||||
To use it, add `rclone` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... rclone)
|
||||
```
|
14
plugins/rclone/rclone.plugin.zsh
Normal file
14
plugins/rclone/rclone.plugin.zsh
Normal file
@ -0,0 +1,14 @@
|
||||
# Completion
|
||||
if (( ! $+commands[rclone] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `rclone`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_rclone" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _rclone
|
||||
_comps[rclone]=_rclone
|
||||
fi
|
||||
|
||||
rclone completion zsh - >| "$ZSH_CACHE_DIR/completions/_rclone" &|
|
@ -22,5 +22,5 @@ fi
|
||||
rustup completions zsh >| "$ZSH_CACHE_DIR/completions/_rustup" &|
|
||||
cat >| "$ZSH_CACHE_DIR/completions/_cargo" <<'EOF'
|
||||
#compdef cargo
|
||||
source "$(rustc +${${(z)$(rustup default)}[1]} --print sysroot)"/share/zsh/site-functions/_cargo
|
||||
source "$(rustup run ${${(z)$(rustup default)}[1]} rustc --print sysroot)"/share/zsh/site-functions/_cargo
|
||||
EOF
|
||||
|
@ -1,7 +1,9 @@
|
||||
## Scaleway CLI autocomplete plugin
|
||||
## Scaleway CLI plugin
|
||||
|
||||
[scw](https://github.com/scaleway/scaleway-cli): Manage Bare Metal servers from Command Line (as easily as with Docker)
|
||||
This plugin adds completion for [scw](https://github.com/scaleway/scaleway-cli), the command line interface for Scaleway.
|
||||
|
||||
- Adds autocomplete options for all `scw` commands.
|
||||
To use it, add `scw` to the plugins array in your zshrc file:
|
||||
|
||||
Maintainer : Manfred Touron ([@moul](https://github.com/moul))
|
||||
```zsh
|
||||
plugins=(... scw)
|
||||
```
|
||||
|
333
plugins/scw/_scw
333
plugins/scw/_scw
@ -1,333 +0,0 @@
|
||||
#compdef scw
|
||||
#
|
||||
# zsh completion for scw (https://www.scaleway.com)
|
||||
#
|
||||
# Inspired by https://github.com/felixr/docker-zsh-completion
|
||||
|
||||
__scw_get_servers() {
|
||||
local expl
|
||||
declare -a servers
|
||||
servers=(${(f)"$(_call_program commands scw _completion servers-names)"})
|
||||
_describe -t servers "servers" servers
|
||||
}
|
||||
|
||||
__scw_stoppedservers() {
|
||||
__scw_get_servers
|
||||
}
|
||||
|
||||
__scw_runningservers() {
|
||||
__scw_get_servers
|
||||
}
|
||||
|
||||
__scw_servers () {
|
||||
__scw_get_servers
|
||||
}
|
||||
|
||||
__scw_images () {
|
||||
local expl
|
||||
declare -a images
|
||||
images=(${(f)"$(_call_program commands scw _completion images-names)"})
|
||||
_describe -t images "images" images
|
||||
}
|
||||
|
||||
__scw_images_and_snapshots () {
|
||||
__scw_images
|
||||
__scw_snapshots
|
||||
}
|
||||
|
||||
__scw_snapshots () {
|
||||
local expl
|
||||
declare -a snapshots
|
||||
snapshots=(${(f)"$(_call_program commands scw _completion --prefix snapshots-names)"})
|
||||
_describe -t snapshots "snapshots" snapshots
|
||||
}
|
||||
|
||||
__scw_bootscripts () {
|
||||
local expl
|
||||
declare -a bootscripts
|
||||
bootscripts=(${(f)"$(_call_program commands scw _completion bootscripts-names)"})
|
||||
_describe -t bootscripts "bootscripts" bootscripts
|
||||
}
|
||||
|
||||
__scw_tags() {
|
||||
__scw_images
|
||||
}
|
||||
|
||||
__scw_repositories_with_tags() {
|
||||
__scw_images
|
||||
}
|
||||
|
||||
__scw_search() {
|
||||
# declare -a scwsearch
|
||||
local cache_policy
|
||||
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
|
||||
if [[ -z "$cache_policy" ]]; then
|
||||
zstyle ":completion:${curcontext}:" cache-policy __scw_caching_policy
|
||||
fi
|
||||
|
||||
local searchterm cachename
|
||||
searchterm="${words[$CURRENT]%/}"
|
||||
cachename=_scw-search-$searchterm
|
||||
|
||||
local expl
|
||||
local -a result
|
||||
if ( [[ ${(P)+cachename} -eq 0 ]] || _cache_invalid ${cachename#_} ) \
|
||||
&& ! _retrieve_cache ${cachename#_}; then
|
||||
_message "Searching for ${searchterm}..."
|
||||
result=(${${${(f)"$(_call_program commands scw search ${searchterm})"}%% *}[2,-1]})
|
||||
_store_cache ${cachename#_} result
|
||||
fi
|
||||
_wanted scwsearch expl 'available images' compadd -a result
|
||||
}
|
||||
|
||||
__scw_caching_policy()
|
||||
{
|
||||
oldp=( "$1"(Nmh+1) ) # 1 hour
|
||||
(( $#oldp ))
|
||||
}
|
||||
|
||||
|
||||
__scw_repositories () {
|
||||
__scw_images
|
||||
}
|
||||
|
||||
__scw_commands () {
|
||||
# local -a _scw_subcommands
|
||||
local cache_policy
|
||||
|
||||
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
|
||||
if [[ -z "$cache_policy" ]]; then
|
||||
zstyle ":completion:${curcontext}:" cache-policy __scw_caching_policy
|
||||
fi
|
||||
|
||||
if ( [[ ${+_scw_subcommands} -eq 0 ]] || _cache_invalid scw_subcommands) \
|
||||
&& ! _retrieve_cache scw_subcommands;
|
||||
then
|
||||
local -a lines
|
||||
lines=(${(f)"$(_call_program commands scw 2>&1)"})
|
||||
_scw_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:})
|
||||
_scw_subcommands=($_scw_subcommands 'help:Show help for a command')
|
||||
_store_cache scw_subcommands _scw_subcommands
|
||||
fi
|
||||
_describe -t scw-commands "scw command" _scw_subcommands
|
||||
}
|
||||
|
||||
__scw_subcommand () {
|
||||
local -a _command_args
|
||||
case "$words[1]" in
|
||||
(attach)
|
||||
_arguments \
|
||||
'--no-stdin[Do not attach stdin]' \
|
||||
':servers:__scw_runningservers'
|
||||
;;
|
||||
(commit)
|
||||
_arguments \
|
||||
{-v,--volume=0}'[Volume slot]:volume: ' \
|
||||
':server:__scw_servers' \
|
||||
':repository:__scw_repositories_with_tags'
|
||||
;;
|
||||
(cp)
|
||||
_arguments \
|
||||
':server:->server' \
|
||||
':hostpath:_files'
|
||||
case $state in
|
||||
(server)
|
||||
if compset -P '*:'; then
|
||||
_files
|
||||
else
|
||||
__scw_servers -qS ":"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(exec)
|
||||
local state ret
|
||||
_arguments \
|
||||
{-T,--timeout=0}'[Set timeout values to seconds]' \
|
||||
{-w,--wait}'[Wait for SSH to be ready]' \
|
||||
':servers:__scw_runningservers' \
|
||||
'*::command:->anycommand' && ret=0
|
||||
|
||||
case $state in
|
||||
(anycommand)
|
||||
shift 1 words
|
||||
(( CURRENT-- ))
|
||||
_normal
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
;;
|
||||
(history)
|
||||
_arguments \
|
||||
'--no-trunc[Do not truncate output]' \
|
||||
{-q,--quiet}'[Only show numeric IDs]' \
|
||||
'*:images:__scw_images'
|
||||
;;
|
||||
(images)
|
||||
_arguments \
|
||||
{-a,--all}'[Show all images]' \
|
||||
'--no-trunc[Do not truncate output]' \
|
||||
{-q,--quiet}'[Only show numeric IDs]' \
|
||||
':repository:__scw_repositories'
|
||||
;;
|
||||
(info)
|
||||
;;
|
||||
(inspect)
|
||||
_arguments \
|
||||
{-f,--format=-}'[Format the output using the given go template]:template: ' \
|
||||
'*:servers:__scw_servers'
|
||||
;;
|
||||
(kill)
|
||||
_arguments \
|
||||
'*:servers:__scw_runningservers'
|
||||
;;
|
||||
(login)
|
||||
_arguments \
|
||||
{-o,--organization=-}'[Organization]:organization: ' \
|
||||
{-t,--token=-}'[Token]:token: ' \
|
||||
':server: '
|
||||
;;
|
||||
(logout)
|
||||
_arguments \
|
||||
':server: '
|
||||
;;
|
||||
(logs)
|
||||
_arguments \
|
||||
'*:servers:__scw_servers'
|
||||
;;
|
||||
(port)
|
||||
_arguments \
|
||||
'1:servers:__scw_runningservers' \
|
||||
'2:port:_ports'
|
||||
;;
|
||||
(start)
|
||||
_arguments \
|
||||
{-T,--timeout=0}'[Set timeout values to seconds]' \
|
||||
{-w,--wait}'[Wait for SSH to be ready]' \
|
||||
'*:servers:__scw_stoppedservers'
|
||||
;;
|
||||
(rm)
|
||||
_arguments \
|
||||
'*:servers:__scw_stoppedservers'
|
||||
;;
|
||||
(rmi)
|
||||
_arguments \
|
||||
'*:images:__scw_images'
|
||||
;;
|
||||
(restart)
|
||||
_arguments \
|
||||
'*:servers:__scw_runningservers'
|
||||
;;
|
||||
(stop)
|
||||
_arguments \
|
||||
{-t,--terminate}'[Stop and trash a server with its volumes]' \
|
||||
{-w,--wait}'[Synchronous stop. Wait for server to be stopped]' \
|
||||
'*:servers:__scw_runningservers'
|
||||
;;
|
||||
(top)
|
||||
_arguments \
|
||||
'1:servers:__scw_runningservers' \
|
||||
'(-)*:: :->ps-arguments'
|
||||
case $state in
|
||||
(ps-arguments)
|
||||
_ps
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(ps)
|
||||
_arguments \
|
||||
{-a,--all}'[Show all servers. Only running servers are shown by default]' \
|
||||
{-l,--latest}'[Show only the latest created server]' \
|
||||
'-n[Show n last created servers, include non-running one]:n:(1 5 10 25 50)' \
|
||||
'--no-trunc[Do not truncate output]' \
|
||||
{-q,--quiet}'[Only show numeric IDs]'
|
||||
;;
|
||||
(tag)
|
||||
_arguments \
|
||||
{-f,--force}'[force]'\
|
||||
':image:__scw_images'\
|
||||
':repository:__scw_repositories_with_tags'
|
||||
;;
|
||||
(create|run)
|
||||
_arguments \
|
||||
{-a,--attach}'[Attach to stdin, stdout or stderr]' \
|
||||
'*'{-e,--environment=-}'[Set environment variables]:environment variable: ' \
|
||||
'--name=-[Server name]:name: ' \
|
||||
'--bootscript=-[Assign a bootscript]:bootscript:__scw_bootscripts ' \
|
||||
'*-v[Bind mount a volume]:volume: '\
|
||||
'(-):images:__scw_images_and_snapshots' \
|
||||
'(-):command: _command_names -e' \
|
||||
'*::arguments: _normal'
|
||||
|
||||
case $state in
|
||||
(link)
|
||||
if compset -P '*:'; then
|
||||
_wanted alias expl 'Alias' compadd -E ""
|
||||
else
|
||||
__scw_runningservers -qS ":"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(rename)
|
||||
_arguments \
|
||||
':old name:__scw_servers' \
|
||||
':new name: '
|
||||
;;
|
||||
(search)
|
||||
_arguments \
|
||||
'--no-trunc[Do not truncate output]' \
|
||||
':term: '
|
||||
;;
|
||||
(wait)
|
||||
_arguments '*:servers:__scw_runningservers'
|
||||
;;
|
||||
(help)
|
||||
_arguments ':subcommand:__scw_commands'
|
||||
;;
|
||||
(*)
|
||||
_message 'Unknown sub command'
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
_scw () {
|
||||
# Support for subservices, which allows for `compdef _scw scw-shell=_scw_servers`.
|
||||
# Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`.
|
||||
if [[ $service != scw ]]; then
|
||||
_call_function - _$service
|
||||
return
|
||||
fi
|
||||
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
'-H[tcp://host:port to bind/connect to]:socket: ' \
|
||||
'(-): :->command' \
|
||||
'(-)*:: :->option-or-argument'
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
|
||||
fi
|
||||
case $state in
|
||||
(command)
|
||||
__scw_commands
|
||||
;;
|
||||
(option-or-argument)
|
||||
curcontext=${curcontext%:*:*}:scw-$words[1]:
|
||||
__scw_subcommand
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_scw "$@"
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 4
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 4
|
||||
# End:
|
||||
# vim: ft=zsh sw=4 ts=4 et
|
14
plugins/scw/scw.plugin.zsh
Normal file
14
plugins/scw/scw.plugin.zsh
Normal file
@ -0,0 +1,14 @@
|
||||
if (( ! $+commands[scw] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
_scw () {
|
||||
output=($(scw autocomplete complete zsh -- ${CURRENT} ${words}))
|
||||
opts=('-S' ' ')
|
||||
if [[ $output == *= ]]; then
|
||||
opts=('-S' '')
|
||||
fi
|
||||
compadd "${opts[@]}" -- "${output[@]}"
|
||||
}
|
||||
|
||||
compdef _scw scw
|
@ -1,4 +1,4 @@
|
||||
if (( ! $+commands[tailscale] )); then
|
||||
if (( ! $+commands[tailscale] && ! $+aliases[tailscale] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
@ -7,7 +7,19 @@ fi
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_tailscale" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _tailscale
|
||||
_comps[tailscale]=_tailscale
|
||||
|
||||
if (( $+commands[tailscale] )); then
|
||||
_comps[tailscale]=_tailscale
|
||||
elif (( $+aliases[tailscale] )); then
|
||||
_comps[${aliases[tailscale]:t}]=_tailscale
|
||||
fi
|
||||
fi
|
||||
|
||||
# If using the alias, let's make sure that the aliased executable is also bound
|
||||
# in case the alias points to "Tailscale" instead of "tailscale".
|
||||
# See https://github.com/ohmyzsh/ohmyzsh/discussions/12928
|
||||
if (( $+aliases[tailscale] )); then
|
||||
_comps[${aliases[tailscale]:t}]=_tailscale
|
||||
fi
|
||||
|
||||
tailscale completion zsh >| "$ZSH_CACHE_DIR/completions/_tailscale" &|
|
||||
|
@ -2,9 +2,9 @@ function tf_prompt_info() {
|
||||
# dont show 'default' workspace in home dir
|
||||
[[ "$PWD" != ~ ]] || return
|
||||
# check if in terraform dir and file exists
|
||||
[[ -d .terraform && -r .terraform/environment ]] || return
|
||||
[[ -d "${TF_DATA_DIR:-.terraform}" && -r "${TF_DATA_DIR:-.terraform}/environment" ]] || return
|
||||
|
||||
local workspace="$(< .terraform/environment)"
|
||||
local workspace="$(< "${TF_DATA_DIR:-.terraform}/environment")"
|
||||
echo "${ZSH_THEME_TF_PROMPT_PREFIX-[}${workspace:gs/%/%%}${ZSH_THEME_TF_PROMPT_SUFFIX-]}"
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ __timer_current_time() {
|
||||
}
|
||||
|
||||
__timer_format_duration() {
|
||||
local mins=$(printf '%.0f' $(($1 / 60)))
|
||||
local mins=$(printf '%.0f' $(($(IFS='.' read int dec <<< "$1"; echo $int) / 60)))
|
||||
local secs=$(printf "%.${TIMER_PRECISION:-1}f" $(($1 - 60 * mins)))
|
||||
local duration_str=$(echo "${mins}m${secs}s")
|
||||
local format="${TIMER_FORMAT:-/%d}"
|
||||
|
9
plugins/timoni/README.md
Normal file
9
plugins/timoni/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Timoni plugin
|
||||
|
||||
This plugin adds completion for [Timoni](https://timoni.sh), a package manager for Kubernetes, powered by CUE and inspired by Helm.
|
||||
|
||||
To use it, add `timoni` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... timoni)
|
||||
```
|
14
plugins/timoni/timoni.plugin.zsh
Normal file
14
plugins/timoni/timoni.plugin.zsh
Normal file
@ -0,0 +1,14 @@
|
||||
# Autocompletion for the Timoni CLI (timoni).
|
||||
if (( ! $+commands[timoni] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `timoni`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_timoni" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _timoni
|
||||
_comps[timoni]=_timoni
|
||||
fi
|
||||
|
||||
timoni completion zsh >| "$ZSH_CACHE_DIR/completions/_timoni" &|
|
@ -17,11 +17,15 @@ To display Vagrant info on your prompt add the `vagrant_prompt_info` to the
|
||||
`$PROMPT` or `$RPROMPT` variable in your theme. Example:
|
||||
|
||||
```zsh
|
||||
PROMPT='%{$fg[$NCOLOR]%}%B%n%b%{$reset_color%}:%{$fg[blue]%}%B%c/%b%{$reset_color%} $(vagrant_prompt_info)$(svn_prompt_info)$(git_prompt_info)%(!.#.$) '
|
||||
PROMPT="$PROMPT"' $(vagrant_prompt_info)'
|
||||
# or
|
||||
RPROMPT='$(vagrant_prompt_info)'
|
||||
```
|
||||
|
||||
`vagrant_prompt_info` makes use of some custom variables. This is an example
|
||||
definition:
|
||||
### Customization
|
||||
|
||||
`vagrant_prompt_info` makes use of the following custom variables, which can be set in your
|
||||
`.zshrc` file:
|
||||
|
||||
```zsh
|
||||
ZSH_THEME_VAGRANT_PROMPT_PREFIX="%{$fg_bold[blue]%}["
|
||||
@ -31,3 +35,18 @@ ZSH_THEME_VAGRANT_PROMPT_POWEROFF="%{$fg_no_bold[red]%}●"
|
||||
ZSH_THEME_VAGRANT_PROMPT_SUSPENDED="%{$fg_no_bold[yellow]%}●"
|
||||
ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED="%{$fg_no_bold[white]%}○"
|
||||
```
|
||||
|
||||
### State to variable mapping
|
||||
|
||||
The plugin uses the output reported by `vagrant status` to print whichever symbol matches,
|
||||
according to the following table:
|
||||
|
||||
| State | Symbol |
|
||||
| ----------- | -------------------------------------- |
|
||||
| running | `ZSH_THEME_VAGRANT_PROMPT_RUNNING` |
|
||||
| not running | `ZSH_THEME_VAGRANT_PROMPT_POWEROFF` |
|
||||
| poweroff | `ZSH_THEME_VAGRANT_PROMPT_POWEROFF` |
|
||||
| paused | `ZSH_THEME_VAGRANT_PROMPT_SUSPENDED` |
|
||||
| saved | `ZSH_THEME_VAGRANT_PROMPT_SUSPENDED` |
|
||||
| suspended | `ZSH_THEME_VAGRANT_PROMPT_SUSPENDED` |
|
||||
| not created | `ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED` |
|
||||
|
@ -1,16 +1,18 @@
|
||||
function vagrant_prompt_info() {
|
||||
local vm_states vm_state
|
||||
if [[ -d .vagrant && -f Vagrantfile ]]; then
|
||||
vm_states=(${(f)"$(vagrant status 2> /dev/null | sed -nE 's/^.*(saved|poweroff|running|not created) \([[:alnum:]_]+\)$/\1/p')"})
|
||||
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_PREFIX
|
||||
for vm_state in $vm_states; do
|
||||
case "$vm_state" in
|
||||
saved) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED ;;
|
||||
running) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING ;;
|
||||
poweroff) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF ;;
|
||||
"not created") printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED ;;
|
||||
esac
|
||||
done
|
||||
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUFFIX
|
||||
if [[ ! -d .vagrant || ! -f Vagrantfile ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
local vm_states vm_state
|
||||
vm_states=(${(f)"$(vagrant status 2> /dev/null | sed -nE 's/^[^ ]* *([[:alnum:] ]*) \([[:alnum:]_]+\)$/\1/p')"})
|
||||
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_PREFIX
|
||||
for vm_state in $vm_states; do
|
||||
case "$vm_state" in
|
||||
running) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING ;;
|
||||
"not running"|poweroff) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF ;;
|
||||
paused|saved|suspended) printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED ;;
|
||||
"not created") printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED ;;
|
||||
esac
|
||||
done
|
||||
printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUFFIX
|
||||
}
|
||||
|
9
plugins/vault/README.md
Normal file
9
plugins/vault/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Vault plugin
|
||||
|
||||
This plugin adds completion for [Vault](https://www.vaultproject.io/), the secrets and sensitive data manager.
|
||||
|
||||
To use it, add `vault` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... vault)
|
||||
```
|
7
plugins/vault/vault.plugin.zsh
Normal file
7
plugins/vault/vault.plugin.zsh
Normal file
@ -0,0 +1,7 @@
|
||||
# Completion
|
||||
if (( ! $+commands[vault] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
autoload -Uz bashcompinit && bashcompinit
|
||||
complete -o nospace -C vault vault
|
@ -4,7 +4,7 @@ if (( ! $+commands[volta] )); then
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `deno`. Otherwise, compinit will have already done that.
|
||||
# bind it to `volta`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_volta" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _volta
|
||||
|
100
plugins/wd/wd.sh
100
plugins/wd/wd.sh
@ -8,7 +8,7 @@
|
||||
# @github.com/mfaerevaag/wd
|
||||
|
||||
# version
|
||||
readonly WD_VERSION=0.9.0
|
||||
readonly WD_VERSION=0.9.3
|
||||
|
||||
# colors
|
||||
readonly WD_BLUE="\033[96m"
|
||||
@ -59,7 +59,7 @@ wd_print_msg()
|
||||
then
|
||||
local color="${1:-$WD_BLUE}" # Default to blue if no color is provided
|
||||
local msg="$2"
|
||||
|
||||
|
||||
if [[ -z "$msg" ]]; then
|
||||
print "${WD_RED}*${WD_NOC} Could not print message. Sorry!"
|
||||
else
|
||||
@ -145,14 +145,17 @@ wd_warp()
|
||||
else
|
||||
(( n = $#1 - 1 ))
|
||||
cd -$n > /dev/null
|
||||
WD_EXIT_CODE=$?
|
||||
fi
|
||||
elif [[ ${points[$point]} != "" ]]
|
||||
then
|
||||
if [[ $sub != "" ]]
|
||||
then
|
||||
cd ${points[$point]/#\~/$HOME}/$sub
|
||||
WD_EXIT_CODE=$?
|
||||
else
|
||||
cd ${points[$point]/#\~/$HOME}
|
||||
WD_EXIT_CODE=$?
|
||||
fi
|
||||
else
|
||||
wd_exit_fail "Unknown warp point '${point}'"
|
||||
@ -185,11 +188,11 @@ wd_add()
|
||||
elif [[ ${points[$point]} == "" ]] || [ ! -z "$force" ]
|
||||
then
|
||||
wd_remove "$point" > /dev/null
|
||||
printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> "$WD_CONFIG"
|
||||
printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> "$wd_config_file"
|
||||
if (whence sort >/dev/null); then
|
||||
local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
|
||||
# use 'cat' below to ensure we respect $WD_CONFIG as a symlink
|
||||
command sort -o "${config_tmp}" "$WD_CONFIG" && command cat "${config_tmp}" >| "$WD_CONFIG" && command rm "${config_tmp}"
|
||||
# use 'cat' below to ensure we respect $wd_config_file as a symlink
|
||||
command sort -o "${config_tmp}" "$wd_config_file" && command cat "${config_tmp}" >| "$wd_config_file" && command rm "${config_tmp}"
|
||||
fi
|
||||
|
||||
wd_export_static_named_directories
|
||||
@ -240,7 +243,7 @@ wd_remove()
|
||||
then
|
||||
local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
|
||||
# Copy and delete in two steps in order to preserve symlinks
|
||||
if sed -n "/^${point_name}:.*$/!p" "$WD_CONFIG" >| "$config_tmp" && command cp "$config_tmp" "$WD_CONFIG" && command rm "$config_tmp"
|
||||
if sed -n "/^${point_name}:.*$/!p" "$wd_config_file" >| "$config_tmp" && command cp "$config_tmp" "$wd_config_file" && command rm "$config_tmp"
|
||||
then
|
||||
wd_print_msg "$WD_GREEN" "Warp point removed"
|
||||
else
|
||||
@ -253,20 +256,47 @@ wd_remove()
|
||||
}
|
||||
|
||||
wd_browse() {
|
||||
# Check if fzf is installed
|
||||
if ! command -v fzf >/dev/null; then
|
||||
echo "This functionality requires fzf. Please install fzf first."
|
||||
wd_print_msg "$WD_RED" "This functionality requires fzf. Please install fzf first."
|
||||
return 1
|
||||
fi
|
||||
local entries=("${(@f)$(sed "s:${HOME}:~:g" "$WD_CONFIG" | awk -F ':' '{print $1 " -> " $2}')}")
|
||||
|
||||
# Ensure wd_config_file is properly set
|
||||
if [[ -z $wd_config_file ]]; then
|
||||
wd_config_file="${WD_CONFIG:-$HOME/.warprc}"
|
||||
fi
|
||||
|
||||
# Check if config file exists
|
||||
if [[ ! -f $wd_config_file ]]; then
|
||||
wd_print_msg "$WD_RED" "Config file $wd_config_file does not exist. Please create it first."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Read entries from the config file
|
||||
local entries=("${(@f)$(sed "s:${HOME}:~:g" "$wd_config_file" | awk -F ':' '{print $1 " -> " $2}')}")
|
||||
if [[ -z $entries ]]; then
|
||||
wd_print_msg "$WD_YELLOW" "You don't have any warp points to browse"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Temp file for remove operations
|
||||
local script_path="${${(%):-%x}:h}"
|
||||
local wd_remove_output=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
|
||||
|
||||
# Create fzf bindings
|
||||
entries=("All warp points:" "Press enter to select. Press delete to remove" "${entries[@]}")
|
||||
local fzf_bind="delete:execute(echo {} | awk -F ' -> ' '{print \$1}' | xargs -I {} "$script_path/wd.sh" rm {} > "$wd_remove_output")+abort"
|
||||
local fzf_bind="delete:execute(echo {} | awk -F ' -> ' '{print \$1}' | xargs -I {} \"$script_path/wd.sh\" rm {} > \"$wd_remove_output\")+abort"
|
||||
|
||||
# Run fzf
|
||||
local selected_entry=$(printf '%s\n' "${entries[@]}" | fzf --height 100% --reverse --header-lines=2 --bind="$fzf_bind")
|
||||
|
||||
# Handle selection
|
||||
if [[ -e $wd_remove_output ]]; then
|
||||
cat "$wd_remove_output"
|
||||
rm "$wd_remove_output"
|
||||
rm -f "$wd_remove_output"
|
||||
fi
|
||||
|
||||
if [[ -n $selected_entry ]]; then
|
||||
local selected_point="${selected_entry%% ->*}"
|
||||
selected_point=$(echo "$selected_point" | xargs)
|
||||
@ -275,14 +305,26 @@ wd_browse() {
|
||||
}
|
||||
|
||||
wd_browse_widget() {
|
||||
if [[ -e $WD_CONFIG ]]; then
|
||||
# Ensure wd_config_file is properly set
|
||||
if [[ -z $wd_config_file ]]; then
|
||||
wd_config_file="${WD_CONFIG:-$HOME/.warprc}"
|
||||
fi
|
||||
|
||||
# Check if config file exists
|
||||
if [[ ! -f $wd_config_file ]]; then
|
||||
wd_print_msg "$WD_RED" "Config file $wd_config_file does not exist. Please create it first."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Call wd_browse to handle the selection
|
||||
wd_browse
|
||||
|
||||
# Restore the zsh buffer and cursor after running wd_browse
|
||||
saved_buffer=$BUFFER
|
||||
saved_cursor=$CURSOR
|
||||
BUFFER=
|
||||
zle redisplay
|
||||
zle accept-line
|
||||
fi
|
||||
}
|
||||
|
||||
wd_restore_buffer() {
|
||||
@ -298,7 +340,7 @@ wd_list_all()
|
||||
{
|
||||
wd_print_msg "$WD_BLUE" "All warp points:"
|
||||
|
||||
entries=$(sed "s:${HOME}:~:g" "$WD_CONFIG")
|
||||
entries=$(sed "s:${HOME}:~:g" "$wd_config_file")
|
||||
|
||||
max_warp_point_length=0
|
||||
while IFS= read -r line
|
||||
@ -344,6 +386,7 @@ wd_path()
|
||||
wd_show()
|
||||
{
|
||||
local name_arg=$1
|
||||
local show_pwd
|
||||
# if there's an argument we look up the value
|
||||
if [[ -n $name_arg ]]
|
||||
then
|
||||
@ -358,12 +401,12 @@ wd_show()
|
||||
local wd_matches
|
||||
wd_matches=()
|
||||
# do a reverse lookup to check whether PWD is in $points
|
||||
PWD="${PWD/$HOME/~}"
|
||||
if [[ ${points[(r)$PWD]} == "$PWD" ]]
|
||||
show_pwd="${PWD/$HOME/~}"
|
||||
if [[ ${points[(r)$show_pwd]} == "$show_pwd" ]]
|
||||
then
|
||||
for name in ${(k)points}
|
||||
do
|
||||
if [[ $points[$name] == "$PWD" ]]
|
||||
if [[ $points[$name] == "$show_pwd" ]]
|
||||
then
|
||||
wd_matches[$(($#wd_matches+1))]=$name
|
||||
fi
|
||||
@ -371,7 +414,7 @@ wd_show()
|
||||
|
||||
wd_print_msg "$WD_BLUE" "$#wd_matches warp point(s) to current directory: ${WD_GREEN}$wd_matches${WD_NOC}"
|
||||
else
|
||||
wd_print_msg "$WD_YELLOW" "No warp point to $(echo "$PWD" | sed "s:$HOME:~:")"
|
||||
wd_print_msg "$WD_YELLOW" "No warp point to $show_pwd"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -397,7 +440,7 @@ wd_clean() {
|
||||
count=$((count+1))
|
||||
fi
|
||||
fi
|
||||
done < "$WD_CONFIG"
|
||||
done < "$wd_config_file"
|
||||
|
||||
if [[ $count -eq 0 ]]
|
||||
then
|
||||
@ -405,7 +448,7 @@ wd_clean() {
|
||||
else
|
||||
if [ ! -z "$force" ] || wd_yesorno "Removing ${count} warp points. Continue? (y/n)"
|
||||
then
|
||||
echo "$wd_tmp" >! "$WD_CONFIG"
|
||||
echo "$wd_tmp" >! "$wd_config_file"
|
||||
wd_print_msg "$WD_GREEN" "Cleanup complete. ${count} warp point(s) removed"
|
||||
else
|
||||
wd_print_msg "$WD_BLUE" "Cleanup aborted"
|
||||
@ -416,7 +459,7 @@ wd_clean() {
|
||||
wd_export_static_named_directories() {
|
||||
if [[ ! -z $WD_EXPORT ]]
|
||||
then
|
||||
command grep '^[0-9a-zA-Z_-]\+:' "$WD_CONFIG" | sed -e "s,~,$HOME," -e 's/:/=/' | while read -r warpdir ; do
|
||||
command grep '^[0-9a-zA-Z_-]\+:' "$wd_config_file" | sed -e "s,~,$HOME," -e 's/:/=/' | while read -r warpdir ; do
|
||||
hash -d "$warpdir"
|
||||
done
|
||||
fi
|
||||
@ -441,16 +484,19 @@ then
|
||||
echo "wd version $WD_VERSION"
|
||||
fi
|
||||
|
||||
# set the config file from variable or default
|
||||
typeset wd_config_file=${WD_CONFIG:-$HOME/.warprc}
|
||||
if [[ ! -z $wd_alt_config ]]
|
||||
then
|
||||
WD_CONFIG=$wd_alt_config[2]
|
||||
# prefer the flag if provided
|
||||
wd_config_file=$wd_alt_config[2]
|
||||
fi
|
||||
|
||||
# check if config file exists
|
||||
if [ ! -e "$WD_CONFIG" ]
|
||||
if [ ! -e "$wd_config_file" ]
|
||||
then
|
||||
# if not, create config file
|
||||
touch "$WD_CONFIG"
|
||||
touch "$wd_config_file"
|
||||
else
|
||||
wd_export_static_named_directories
|
||||
fi
|
||||
@ -472,7 +518,7 @@ do
|
||||
val=${(j,:,)arr[2,-1]}
|
||||
|
||||
points[$key]=$val
|
||||
done < "$WD_CONFIG"
|
||||
done < "$wd_config_file"
|
||||
|
||||
# get opts
|
||||
args=$(getopt -o a:r:c:lhs -l add:,rm:,clean,list,ls:,path:,help,show -- $*)
|
||||
@ -483,11 +529,11 @@ then
|
||||
wd_print_usage
|
||||
|
||||
# check if config file is writeable
|
||||
elif [ ! -w "$WD_CONFIG" ]
|
||||
elif [ ! -w "$wd_config_file" ]
|
||||
then
|
||||
# do nothing
|
||||
# can't run `exit`, as this would exit the executing shell
|
||||
wd_exit_fail "\'$WD_CONFIG\' is not writeable."
|
||||
wd_exit_fail "\'$wd_config_file\' is not writeable."
|
||||
|
||||
else
|
||||
# parse rest of options
|
||||
@ -571,8 +617,10 @@ unset wd_print_msg
|
||||
unset wd_yesorno
|
||||
unset wd_print_usage
|
||||
unset wd_alt_config
|
||||
#unset wd_config_file do not unset this - breaks keybind
|
||||
unset wd_quiet_mode
|
||||
unset wd_print_version
|
||||
unset wd_force_mode
|
||||
unset wd_export_static_named_directories
|
||||
unset wd_o
|
||||
|
||||
|
@ -52,6 +52,7 @@ Available search contexts are:
|
||||
| `gopkg` | `https://pkg.go.dev/search?m=package&q=` |
|
||||
| `chatgpt` | `https://chatgpt.com/?q=` |
|
||||
| `reddit` | `https://www.reddit.com/search/?q=` |
|
||||
| `ppai` | `https://www.perplexity.ai/search/new?q=` |
|
||||
|
||||
Also there are aliases for bang-searching DuckDuckGo:
|
||||
|
||||
|
@ -32,6 +32,8 @@ function web_search() {
|
||||
packagist "https://packagist.org/?query="
|
||||
gopkg "https://pkg.go.dev/search?m=package&q="
|
||||
chatgpt "https://chatgpt.com/?q="
|
||||
# for the new reddit search go below at row 67
|
||||
ppai "https://www.perplexity.ai/search/new?q="
|
||||
)
|
||||
|
||||
# check whether the search engine is supported
|
||||
@ -49,7 +51,7 @@ function web_search() {
|
||||
|
||||
# build search url:
|
||||
# join arguments passed with '+', then append to search engine URL
|
||||
url="${urls[$1]}$(omz_urlencode $param ${@[2,-1]})"
|
||||
url="${urls[$1]}$(omz_urlencode $param ${(s: :)@[2,-1]})"
|
||||
else
|
||||
# build main page url:
|
||||
# split by '/', then rejoin protocol (1) and domain (2) parts with '//'
|
||||
@ -130,6 +132,7 @@ alias packagist='web_search packagist'
|
||||
alias gopkg='web_search gopkg'
|
||||
alias chatgpt='web_search chatgpt'
|
||||
alias reddit='reddit_search'
|
||||
alias ppai='web_search ppai'
|
||||
|
||||
#add your own !bang searches here
|
||||
alias wiki='web_search duckduckgo \!w'
|
||||
|
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018-2023 Alexandros Kozak
|
||||
Copyright (c) 2018-2024 Alexandros Kozak
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -6,15 +6,15 @@
|
||||
|
||||

|
||||
|
||||
Zsh-z is a command line tool that allows you to jump quickly to directories that you have visited frequently in the past, or recently -- but most often a combination of the two (a concept known as ["frecency"](https://en.wikipedia.org/wiki/Frecency)). It works by keeping track of when you go to directories and how much time you spend in them. It is then in the position to guess where you want to go when you type a partial string, e.g., `z src` might take you to `~/src/zsh`. `z zsh` might also get you there, and `z c/z` might prove to be even more specific -- it all depends on your habits and how much time you have been using Zsh-z to build up a database. After using Zsh-z for a little while, you will get to where you want to be by typing considerably less than you would need if you were using `cd`.
|
||||
Zsh-z is a command-line tool that allows you to jump quickly to directories that you have visited frequently or recently -- but most often a combination of the two (a concept known as ["frecency"](https://en.wikipedia.org/wiki/Frecency)). It works by keeping track of when you go to directories and how much time you spend in them. Based on this data, it predicts where you want to go when you type a partial string. For example, `z src` might take you to `~/src/zsh`. `z zsh` might also get you there, and `z c/z` might prove to be even more specific -- it all depends on your habits and how long you have been using Zsh-z to build up a database. After using Zsh-z for a little while, you will get to where you want to be by typing considerably less than you would need to if you were using `cd`.
|
||||
|
||||
Zsh-z is a native Zsh port of [rupa/z](https://github.com/rupa/z), a tool written for `bash` and Zsh that uses embedded `awk` scripts to do the heavy lifting. It was quite possibly my most used command line tool for a couple of years. I decided to translate it, `awk` parts and all, into pure Zsh script, to see if by eliminating calls to external tools (`awk`, `sort`, `date`, `sed`, `mv`, `rm`, and `chown`) and reducing forking through subshells I could make it faster. The performance increase is impressive, particularly on systems where forking is slow, such as Cygwin, MSYS2, and WSL. I have found that, in those environments, switching directories using Zsh-z can be over 100% faster than it is using `rupa/z`.
|
||||
Zsh-z is a native Zsh port of [`rupa/z`](https://github.com/rupa/z), a tool written for `bash` and Zsh that uses embedded `awk` scripts to do the heavy lifting. `rupa/z` was my most used command-line tool for a couple of years. I decided to translate it, `awk` parts and all, into pure Zsh script, to see if by eliminating calls to external tools (`awk`, `sort`, `date`, `sed`, `mv`, `rm`, and `chown`) and reducing forking through subshells I could make it faster. The performance increase is impressive, particularly on systems where forking is slow, such as Cygwin, MSYS2, and WSL. I have found that in those environments, switching directories using Zsh-z can be over 100% faster than it is using `rupa/z`.
|
||||
|
||||
There is a noteworthy stability increase as well. Race conditions have always been a problem with `rupa/z`, and users of that utility will occasionally lose their `.z` databases. By having Zsh-z only use Zsh (`rupa/z` uses a hybrid shell code that works on `bash` as well), I have been able to implement a `zsh/system`-based file-locking mechanism similar to [the one @mafredri once proposed for `rupa/z`](https://github.com/rupa/z/pull/199). It is now nearly impossible to crash the database, even through extreme testing.
|
||||
There is also a significant stability improvement. Race conditions have always been a problem with `rupa/z`, and users of that utility occasionally lose their `~/.z` databases. By having Zsh-z only use Zsh (`rupa/z` uses a hybrid shell code standard that works on `bash` as well), I have been able to implement a `zsh/system`-based file-locking mechanism similar to [the one @mafredri once proposed for `rupa/z`](https://github.com/rupa/z/pull/199). It is now nearly impossible to crash the database.
|
||||
|
||||
There are other, smaller improvements which I try to document in [Improvements and Fixes](#improvements-and-fixes). These include the new default behavior of sorting your tab completions by frecency rather than just letting Zsh sort the raw results alphabetically (a behavior which can be restored if you like it -- [see below](#settings)).
|
||||
There are other, smaller improvements which I document below in [Improvements and Fixes](#improvements-and-fixes). For instance, tab completions are now sorted by frecency by default rather than alphabetically (the latter behavior can be restored if you like it -- [see below](#settings)).
|
||||
|
||||
Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same database (`~/.z`), so you can go on using `rupa/z` when you launch `bash`.
|
||||
Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same database (`~/.z`, or whatever database file you specify), so you can go on using `rupa/z` when you launch `bash`.
|
||||
|
||||
## Table of Contents
|
||||
- [News](#news)
|
||||
@ -37,13 +37,13 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
|
||||
- August 24, 2023
|
||||
+ Zsh-z will now run when `setopt NO_UNSET` has been enabled (props @ntninja).
|
||||
- August 23, 2023
|
||||
+ Better logic for loading `zsh/files` (props @z0rc)
|
||||
+ Better logic for loading `zsh/files` (props @z0rc).
|
||||
- August 2, 2023
|
||||
+ Zsh-z still uses the `zsh/files` module when possible, but will fall back on the standard `chown`, `mv`, and `rm` commands in its absence.
|
||||
+ Zsh-z still uses the `zsh/files` module when possible but will fall back on the standard `chown`, `mv`, and `rm` commands in its absence.
|
||||
- April 27, 2023
|
||||
+ Zsh-z now allows the user to specify the directory-changing command using the `ZSHZ_CD` environment variable (default: `builtin cd`; props @basnijholt).
|
||||
- January 27, 2023
|
||||
+ If the datafile directory specified by `ZSHZ_DATA` or `_Z_DATA` does not already exist, create it (props @mattmc3).
|
||||
+ If the database file directory specified by `ZSHZ_DATA` or `_Z_DATA` does not already exist, create it (props @mattmc3).
|
||||
- June 29, 2022
|
||||
+ Zsh-z is less likely to leave temporary files sitting around (props @mafredri).
|
||||
- June 27, 2022
|
||||
@ -69,7 +69,7 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
|
||||
+ Fixed the explanation string printed during completion so that it may be formatted with `zstyle`.
|
||||
+ Zsh-z now declares `ZSHZ_EXCLUDE_DIRS` as an array with unique elements so that you do not have to.
|
||||
- July 29, 2021
|
||||
+ Temporarily disabling use of `print -v`, which seems to be mangling CJK multibyte strings.
|
||||
+ Temporarily disabling the use of `print -v`, which was mangling CJK multibyte strings.
|
||||
- July 27, 2021
|
||||
+ Internal escaping of path names now works with older versions of ZSH.
|
||||
+ Zsh-z now detects and discards any incomplete or incorrectly formatted database entries.
|
||||
@ -102,7 +102,7 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
|
||||
- December 22, 2020
|
||||
+ `ZSHZ_CASE`: when set to `ignore`, pattern matching is case-insensitive; when set to `smart`, patterns are matched case-insensitively when they are all lowercase and case-sensitively when they have uppercase characters in them (a behavior very much like Vim's `smartcase` setting).
|
||||
+ `ZSHZ_KEEP_DIRS` is an array of directory names that should not be removed from the database, even if they are not currently available (useful when a drive is not always mounted).
|
||||
+ Symlinked datafiles were having their symlinks overwritten; this bug has been fixed.
|
||||
+ Symlinked database files were having their symlinks overwritten; this bug has been fixed.
|
||||
|
||||
</details>
|
||||
|
||||
@ -118,7 +118,7 @@ For tab completion to work, `_zshz` *must* be in the same directory as `zsh-z.pl
|
||||
|
||||
autoload -U compinit; compinit
|
||||
|
||||
in your .zshrc somewhere below where you source `zsh-z.plugin.zsh`.
|
||||
in your `.zshrc` somewhere below where you source `zsh-z.plugin.zsh`.
|
||||
|
||||
If you add
|
||||
|
||||
@ -188,7 +188,7 @@ Add a backslash to the end of the last line add `'zsh-z'` to the list, e.g.,
|
||||
Then relaunch `zsh`.
|
||||
|
||||
### For [zcomet](https://github.com/agkozak/zcomet) users
|
||||
|
||||
|
||||
Simply add
|
||||
|
||||
zcomet load agkozak/zsh-z
|
||||
@ -228,7 +228,7 @@ Add the line
|
||||
|
||||
to your `.zshrc`.
|
||||
|
||||
`zsh-z` supports `zinit`'s `unload` feature; just run `zinit unload agkozak/zshz` to restore the shell to its state before `zsh-z` was loaded.
|
||||
Zsh-z supports `zinit`'s `unload` feature; just run `zinit unload agkozak/zsh-z` to restore the shell to its state before Zsh-z was loaded.
|
||||
|
||||
### For [Znap](https://github.com/marlonrichert/zsh-snap) users
|
||||
|
||||
@ -249,7 +249,7 @@ somewhere above the line that says `zplug load`. Then run
|
||||
zplug install
|
||||
zplug load
|
||||
|
||||
to install `zsh-z`.
|
||||
to install Zsh-z.
|
||||
|
||||
## Command Line Options
|
||||
|
||||
@ -263,9 +263,9 @@ to install `zsh-z`.
|
||||
- `-x` Remove a directory (by default, the current directory) from the database
|
||||
- `-xR` Remove a directory (by default, the current directory) and its subdirectories from the database
|
||||
|
||||
# Settings
|
||||
## Settings
|
||||
|
||||
Zsh-z has environment variables (they all begin with `ZSHZ_`) that change its behavior if you set them; you can also keep your old ones if you have been using `rupa/z` (they begin with `_Z_`).
|
||||
Zsh-z has environment variables (they all begin with `ZSHZ_`) that change its behavior if you set them. You can also keep your old ones if you have been using `rupa/z` (whose environment variables begin with `_Z_`).
|
||||
|
||||
* `ZSHZ_CMD` changes the command name (default: `z`)
|
||||
* `ZSHZ_CD` specifies the default directory-changing command (default: `builtin cd`)
|
||||
@ -324,19 +324,18 @@ A good example might involve a directory tree that has Git repositories within i
|
||||
|
||||
(As a Zsh user, I tend to use `**` instead of `find`, but it is good to see how deep your directory trees go before doing that.)
|
||||
|
||||
|
||||
## Other Improvements and Fixes
|
||||
|
||||
* `z -x` works, with the help of `chpwd_functions`.
|
||||
* Zsh-z works on Solaris.
|
||||
* Zsh-z is compatible with Solaris.
|
||||
* Zsh-z uses the "new" `zshcompsys` completion system instead of the old `compctl` one.
|
||||
* There is no error message when the database file has not yet been created.
|
||||
* There is support for special characters (e.g., `[`) in directory names.
|
||||
* If `z -l` only returns one match, a common root is not printed.
|
||||
* Exit status codes increasingly make sense.
|
||||
* Completions work with options `-c`, `-r`, and `-t`.
|
||||
* If `~/foo` and `~/foob` are matches, `~/foo` is *not* the common root. Only a common parent directory can be a common root.
|
||||
* `z -x` and the new, recursive `z -xR` can take an argument so that you can remove directories other than `PWD` from the database.
|
||||
* No error message is displayed when the database file has not yet been created.
|
||||
* Special characters (e.g., `[`) in directory names are now supported.
|
||||
* If `z -l` returns only one match, a common root is not printed.
|
||||
* Exit status codes are more logical.
|
||||
* Completions now work with options `-c`, `-r`, and `-t`.
|
||||
* If `~/foo` and `~/foob` are matches, `~/foo` is no longer considered the common root. Only a common parent directory can be a common root.
|
||||
* `z -x` and the new, recursive `z -xR` can now accept an argument so that you can remove directories other than `PWD` from the database.
|
||||
|
||||
## Migrating from Other Tools
|
||||
|
||||
@ -358,7 +357,7 @@ the line
|
||||
|
||||
That will re-bind `z` or the command of your choice to the underlying Zsh-z function.
|
||||
|
||||
## Known Bugs
|
||||
## Known Bug
|
||||
It is possible to run a completion on a string with spaces in it, e.g., `z us bi<TAB>` might take you to `/usr/local/bin`. This works, but as things stand, after the completion the command line reads
|
||||
|
||||
z us /usr/local/bin.
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# https://github.com/agkozak/zsh-z
|
||||
#
|
||||
# Copyright (c) 2018-2023 Alexandros Kozak
|
||||
# Copyright (c) 2018-2024 Alexandros Kozak
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
@ -120,7 +120,6 @@ fi
|
||||
[[ ${builtins[zf_mv]-} == 'defined' ]] && ZSHZ[MV]='zf_mv'
|
||||
[[ ${builtins[zf_rm]-} == 'defined' ]] && ZSHZ[RM]='zf_rm'
|
||||
|
||||
|
||||
# Load zsh/system, if necessary
|
||||
[[ ${modules[zsh/system]-} == 'loaded' ]] || zmodload zsh/system &> /dev/null
|
||||
|
||||
|
5
templates/minimal.zshrc
Normal file
5
templates/minimal.zshrc
Normal file
@ -0,0 +1,5 @@
|
||||
export ZSH="$HOME/.oh-my-zsh"
|
||||
ZSH_THEME="robbyrussell"
|
||||
plugins=(git)
|
||||
|
||||
source $ZSH/oh-my-zsh.sh
|
@ -2,7 +2,7 @@
|
||||
# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH
|
||||
|
||||
# Path to your Oh My Zsh installation.
|
||||
export ZSH=$HOME/.oh-my-zsh
|
||||
export ZSH="$HOME/.oh-my-zsh"
|
||||
|
||||
# Set name of the theme to load --- if set to "random", it will
|
||||
# load a random theme each time Oh My Zsh is loaded, in which case,
|
||||
|
@ -13,6 +13,8 @@ function afmagic_dashes {
|
||||
# the prompt, account for it when returning the number of dashes
|
||||
if [[ -n "$python_env" && "$PS1" = *\(${python_env}\)* ]]; then
|
||||
echo $(( COLUMNS - ${#python_env} - 3 ))
|
||||
elif [[ -n "$VIRTUAL_ENV_PROMPT" && "$PS1" = *${VIRTUAL_ENV_PROMPT}* ]]; then
|
||||
echo $(( COLUMNS - ${#VIRTUAL_ENV_PROMPT} ))
|
||||
else
|
||||
echo $COLUMNS
|
||||
fi
|
||||
|
@ -35,10 +35,74 @@
|
||||
CURRENT_BG='NONE'
|
||||
|
||||
case ${SOLARIZED_THEME:-dark} in
|
||||
light) CURRENT_FG='white';;
|
||||
*) CURRENT_FG='black';;
|
||||
light)
|
||||
CURRENT_FG='white'
|
||||
CURRENT_DEFAULT_FG='white'
|
||||
;;
|
||||
*)
|
||||
CURRENT_FG='black'
|
||||
CURRENT_DEFAULT_FG='default'
|
||||
;;
|
||||
esac
|
||||
|
||||
### Theme Configuration Initialization
|
||||
#
|
||||
# Override these settings in your ~/.zshrc
|
||||
|
||||
# Current working directory
|
||||
: ${AGNOSTER_DIR_FG:=${CURRENT_FG}}
|
||||
: ${AGNOSTER_DIR_BG:=blue}
|
||||
|
||||
# user@host
|
||||
: ${AGNOSTER_CONTEXT_FG:=${CURRENT_DEFAULT_FG}}
|
||||
: ${AGNOSTER_CONTEXT_BG:=black}
|
||||
|
||||
# Git related
|
||||
: ${AGNOSTER_GIT_CLEAN_FG:=${CURRENT_FG}}
|
||||
: ${AGNOSTER_GIT_CLEAN_BG:=green}
|
||||
: ${AGNOSTER_GIT_DIRTY_FG:=black}
|
||||
: ${AGNOSTER_GIT_DIRTY_BG:=yellow}
|
||||
|
||||
# Bazaar related
|
||||
: ${AGNOSTER_BZR_CLEAN_FG:=${CURRENT_FG}}
|
||||
: ${AGNOSTER_BZR_CLEAN_BG:=green}
|
||||
: ${AGNOSTER_BZR_DIRTY_FG:=black}
|
||||
: ${AGNOSTER_BZR_DIRTY_BG:=yellow}
|
||||
|
||||
# Mercurial related
|
||||
: ${AGNOSTER_HG_NEWFILE_FG:=white}
|
||||
: ${AGNOSTER_HG_NEWFILE_BG:=red}
|
||||
: ${AGNOSTER_HG_CHANGED_FG:=black}
|
||||
: ${AGNOSTER_HG_CHANGED_BG:=yellow}
|
||||
: ${AGNOSTER_HG_CLEAN_FG:=${CURRENT_FG}}
|
||||
: ${AGNOSTER_HG_CLEAN_BG:=green}
|
||||
|
||||
# VirtualEnv colors
|
||||
: ${AGNOSTER_VENV_FG:=black}
|
||||
: ${AGNOSTER_VENV_BG:=blue}
|
||||
|
||||
# AWS Profile colors
|
||||
: ${AGNOSTER_AWS_PROD_FG:=yellow}
|
||||
: ${AGNOSTER_AWS_PROD_BG:=red}
|
||||
: ${AGNOSTER_AWS_FG:=black}
|
||||
: ${AGNOSTER_AWS_BG:=green}
|
||||
|
||||
# Status symbols
|
||||
: ${AGNOSTER_STATUS_RETVAL_FG:=red}
|
||||
: ${AGNOSTER_STATUS_ROOT_FG:=yellow}
|
||||
: ${AGNOSTER_STATUS_JOB_FG:=cyan}
|
||||
: ${AGNOSTER_STATUS_FG:=${CURRENT_DEFAULT_FG}}
|
||||
: ${AGNOSTER_STATUS_BG:=black}
|
||||
|
||||
## Non-Color settings - set to 'true' to enable
|
||||
# Show the actual numeric return value rather than a cross symbol.
|
||||
: ${AGNOSTER_STATUS_RETVAL_NUMERIC:=false}
|
||||
# Show git working dir in the style "/git/root master relative/dir" instead of "/git/root/relative/dir master"
|
||||
: ${AGNOSTER_GIT_INLINE:=false}
|
||||
# Show the git branch status in the prompt rather than the generic branch symbol
|
||||
: ${AGNOSTER_GIT_BRANCH_STATUS:=true}
|
||||
|
||||
|
||||
# Special Powerline characters
|
||||
|
||||
() {
|
||||
@ -83,16 +147,36 @@ prompt_end() {
|
||||
CURRENT_BG=''
|
||||
}
|
||||
|
||||
git_toplevel() {
|
||||
local repo_root=$(git rev-parse --show-toplevel)
|
||||
if [[ $repo_root = '' ]]; then
|
||||
# We are in a bare repo. Use git dir as root
|
||||
repo_root=$(git rev-parse --git-dir)
|
||||
if [[ $repo_root = '.' ]]; then
|
||||
repo_root=$PWD
|
||||
fi
|
||||
fi
|
||||
echo -n $repo_root
|
||||
}
|
||||
|
||||
### Prompt components
|
||||
# Each component will draw itself, and hide itself if no information needs to be shown
|
||||
|
||||
# Context: user@hostname (who am I and where am I)
|
||||
prompt_context() {
|
||||
if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
|
||||
prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m"
|
||||
prompt_segment "$AGNOSTER_CONTEXT_BG" "$AGNOSTER_CONTEXT_FG" "%(!.%{%F{$AGNOSTER_STATUS_ROOT_FG}%}.)%n@%m"
|
||||
fi
|
||||
}
|
||||
|
||||
prompt_git_relative() {
|
||||
local repo_root=$(git_toplevel)
|
||||
local path_in_repo=$(pwd | sed "s/^$(echo "$repo_root" | sed 's:/:\\/:g;s/\$/\\$/g')//;s:^/::;s:/$::;")
|
||||
if [[ $path_in_repo != '' ]]; then
|
||||
prompt_segment "$AGNOSTER_DIR_BG" "$AGNOSTER_DIR_FG" "$path_in_repo"
|
||||
fi;
|
||||
}
|
||||
|
||||
# Git: branch/detached head, dirty status
|
||||
prompt_git() {
|
||||
(( $+commands[git] )) || return
|
||||
@ -113,20 +197,22 @@ prompt_git() {
|
||||
ref="◈ $(command git describe --exact-match --tags HEAD 2> /dev/null)" || \
|
||||
ref="➦ $(command git rev-parse --short HEAD 2> /dev/null)"
|
||||
if [[ -n $dirty ]]; then
|
||||
prompt_segment yellow black
|
||||
prompt_segment "$AGNOSTER_GIT_DIRTY_BG" "$AGNOSTER_GIT_DIRTY_FG"
|
||||
else
|
||||
prompt_segment green $CURRENT_FG
|
||||
prompt_segment "$AGNOSTER_GIT_CLEAN_BG" "$AGNOSTER_GIT_CLEAN_FG"
|
||||
fi
|
||||
|
||||
local ahead behind
|
||||
ahead=$(command git log --oneline @{upstream}.. 2>/dev/null)
|
||||
behind=$(command git log --oneline ..@{upstream} 2>/dev/null)
|
||||
if [[ -n "$ahead" ]] && [[ -n "$behind" ]]; then
|
||||
PL_BRANCH_CHAR=$'\u21c5'
|
||||
elif [[ -n "$ahead" ]]; then
|
||||
PL_BRANCH_CHAR=$'\u21b1'
|
||||
elif [[ -n "$behind" ]]; then
|
||||
PL_BRANCH_CHAR=$'\u21b0'
|
||||
if [[ $AGNOSTER_GIT_BRANCH_STATUS == 'true' ]]; then
|
||||
local ahead behind
|
||||
ahead=$(command git log --oneline @{upstream}.. 2>/dev/null)
|
||||
behind=$(command git log --oneline ..@{upstream} 2>/dev/null)
|
||||
if [[ -n "$ahead" ]] && [[ -n "$behind" ]]; then
|
||||
PL_BRANCH_CHAR=$'\u21c5'
|
||||
elif [[ -n "$ahead" ]]; then
|
||||
PL_BRANCH_CHAR=$'\u21b1'
|
||||
elif [[ -n "$behind" ]]; then
|
||||
PL_BRANCH_CHAR=$'\u21b0'
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -e "${repo_path}/BISECT_LOG" ]]; then
|
||||
@ -149,6 +235,7 @@ prompt_git() {
|
||||
zstyle ':vcs_info:*' actionformats ' %u%c'
|
||||
vcs_info
|
||||
echo -n "${${ref:gs/%/%%}/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
|
||||
[[ $AGNOSTER_GIT_INLINE == 'true' ]] && prompt_git_relative
|
||||
fi
|
||||
}
|
||||
|
||||
@ -168,12 +255,12 @@ prompt_bzr() {
|
||||
status_all=$(echo -n "$bzr_status" | head -n1 | wc -m)
|
||||
revision=${$(command bzr log -r-1 --log-format line | cut -d: -f1):gs/%/%%}
|
||||
if [[ $status_mod -gt 0 ]] ; then
|
||||
prompt_segment yellow black "bzr@$revision ✚"
|
||||
prompt_segment "$AGNOSTER_BZR_DIRTY_BG" "$AGNOSTER_BZR_DIRTY_FG" "bzr@$revision ✚"
|
||||
else
|
||||
if [[ $status_all -gt 0 ]] ; then
|
||||
prompt_segment yellow black "bzr@$revision"
|
||||
prompt_segment "$AGNOSTER_BZR_DIRTY_BG" "$AGNOSTER_BZR_DIRTY_FG" "bzr@$revision"
|
||||
else
|
||||
prompt_segment green black "bzr@$revision"
|
||||
prompt_segment "$AGNOSTER_BZR_CLEAN_BG" "$AGNOSTER_BZR_CLEAN_FG" "bzr@$revision"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@ -186,15 +273,15 @@ prompt_hg() {
|
||||
if $(command hg prompt >/dev/null 2>&1); then
|
||||
if [[ $(command hg prompt "{status|unknown}") = "?" ]]; then
|
||||
# if files are not added
|
||||
prompt_segment red white
|
||||
prompt_segment "$AGNOSTER_HG_NEWFILE_BG" "$AGNOSTER_HG_NEWFILE_FG"
|
||||
st='±'
|
||||
elif [[ -n $(command hg prompt "{status|modified}") ]]; then
|
||||
# if any modification
|
||||
prompt_segment yellow black
|
||||
prompt_segment "$AGNOSTER_HG_CHANGED_BG" "$AGNOSTER_HG_CHANGED_FG"
|
||||
st='±'
|
||||
else
|
||||
# if working copy is clean
|
||||
prompt_segment green $CURRENT_FG
|
||||
prompt_segment "$AGNOSTER_HG_CLEAN_BG" "$AGNOSTER_HG_CLEAN_FG"
|
||||
fi
|
||||
echo -n ${$(command hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st
|
||||
else
|
||||
@ -202,13 +289,13 @@ prompt_hg() {
|
||||
rev=$(command hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
|
||||
branch=$(command hg id -b 2>/dev/null)
|
||||
if command hg st | command grep -q "^\?"; then
|
||||
prompt_segment red black
|
||||
prompt_segment "$AGNOSTER_HG_NEWFILE_BG" "$AGNOSTER_HG_NEWFILE_FG"
|
||||
st='±'
|
||||
elif command hg st | command grep -q "^[MA]"; then
|
||||
prompt_segment yellow black
|
||||
prompt_segment "$AGNOSTER_HG_CHANGED_BG" "$AGNOSTER_HG_CHANGED_FG"
|
||||
st='±'
|
||||
else
|
||||
prompt_segment green $CURRENT_FG
|
||||
prompt_segment "$AGNOSTER_HG_CLEAN_BG" "$AGNOSTER_HG_CLEAN_FG"
|
||||
fi
|
||||
echo -n "☿ ${rev:gs/%/%%}@${branch:gs/%/%%}" $st
|
||||
fi
|
||||
@ -217,13 +304,18 @@ prompt_hg() {
|
||||
|
||||
# Dir: current working directory
|
||||
prompt_dir() {
|
||||
prompt_segment blue $CURRENT_FG '%~'
|
||||
if [[ $AGNOSTER_GIT_INLINE == 'true' ]] && $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
|
||||
# Git repo and inline path enabled, hence only show the git root
|
||||
prompt_segment "$AGNOSTER_DIR_BG" "$AGNOSTER_DIR_FG" "$(git_toplevel | sed "s:^$HOME:~:")"
|
||||
else
|
||||
prompt_segment "$AGNOSTER_DIR_BG" "$AGNOSTER_DIR_FG" '%~'
|
||||
fi
|
||||
}
|
||||
|
||||
# Virtualenv: current working virtualenv
|
||||
prompt_virtualenv() {
|
||||
if [[ -n "$VIRTUAL_ENV" && -n "$VIRTUAL_ENV_DISABLE_PROMPT" ]]; then
|
||||
prompt_segment blue black "(${VIRTUAL_ENV:t:gs/%/%%})"
|
||||
prompt_segment "$AGNOSTER_VENV_BG" "$AGNOSTER_VENV_FG" "(${VIRTUAL_ENV:t:gs/%/%%})"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -234,11 +326,15 @@ prompt_virtualenv() {
|
||||
prompt_status() {
|
||||
local -a symbols
|
||||
|
||||
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘"
|
||||
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡"
|
||||
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙"
|
||||
if [[ $AGNOSTER_STATUS_RETVAL_NUMERIC == 'true' ]]; then
|
||||
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{$AGNOSTER_STATUS_RETVAL_FG}%}$RETVAL"
|
||||
else
|
||||
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{$AGNOSTER_STATUS_RETVAL_FG}%}✘"
|
||||
fi
|
||||
[[ $UID -eq 0 ]] && symbols+="%{%F{$AGNOSTER_STATUS_ROOT_FG}%}⚡"
|
||||
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{$AGNOSTER_STATUS_JOB_FG}%}⚙"
|
||||
|
||||
[[ -n "$symbols" ]] && prompt_segment black default "$symbols"
|
||||
[[ -n "$symbols" ]] && prompt_segment "$AGNOSTER_STATUS_BG" "$AGNOSTER_STATUS_FG" "$symbols"
|
||||
}
|
||||
|
||||
#AWS Profile:
|
||||
@ -249,8 +345,8 @@ prompt_status() {
|
||||
prompt_aws() {
|
||||
[[ -z "$AWS_PROFILE" || "$SHOW_AWS_PROMPT" = false ]] && return
|
||||
case "$AWS_PROFILE" in
|
||||
*-prod|*production*) prompt_segment red yellow "AWS: ${AWS_PROFILE:gs/%/%%}" ;;
|
||||
*) prompt_segment green black "AWS: ${AWS_PROFILE:gs/%/%%}" ;;
|
||||
*-prod|*production*) prompt_segment "$AGNOSTER_AWS_PROD_BG" "$AGNOSTER_AWS_PROD_FG" "AWS: ${AWS_PROFILE:gs/%/%%}" ;;
|
||||
*) prompt_segment "$AGNOSTER_AWS_BG" "$AGNOSTER_AWS_FG" "AWS: ${AWS_PROFILE:gs/%/%%}" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ ZSH_THEME_GIT_PROMPT_SUFFIX="%{$GIT_PROMPT_INFO%} :"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$GIT_DIRTY_COLOR%}✘"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$GIT_CLEAN_COLOR%}✔"
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_ADDED="%{$FG[103]%}✚%{$rset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_ADDED="%{$FG[103]%}✚%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$FG[103]%}✹%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_DELETED="%{$FG[103]%}✖%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_RENAMED="%{$FG[103]%}➜%{$reset_color%}"
|
||||
|
@ -400,6 +400,9 @@ function display-release {
|
||||
function display:breaking {
|
||||
(( $#breaking != 0 )) || return 0
|
||||
|
||||
# If we reach here we have shown commits, set flag
|
||||
shown_commits=1
|
||||
|
||||
case "$output" in
|
||||
text) printf '\e[31m'; fmt:header "BREAKING CHANGES" 3 ;;
|
||||
raw) fmt:header "BREAKING CHANGES" 3 ;;
|
||||
@ -427,6 +430,9 @@ function display-release {
|
||||
# If no commits found of type $type, go to next type
|
||||
(( $#hashes != 0 )) || return 0
|
||||
|
||||
# If we reach here we have shown commits, set flag
|
||||
shown_commits=1
|
||||
|
||||
fmt:header "${TYPES[$type]}" 3
|
||||
for hash in $hashes; do
|
||||
echo " - $(fmt:hash) $(fmt:scope)$(fmt:subject)"
|
||||
@ -444,6 +450,9 @@ function display-release {
|
||||
# If no commits found under "other" types, don't display anything
|
||||
(( $#changes != 0 )) || return 0
|
||||
|
||||
# If we reach here we have shown commits, set flag
|
||||
shown_commits=1
|
||||
|
||||
fmt:header "Other changes" 3
|
||||
for hash type in ${(kv)changes}; do
|
||||
case "$type" in
|
||||
@ -498,7 +507,7 @@ function main {
|
||||
|
||||
# Commit classification arrays
|
||||
local -A types subjects scopes breaking reverts
|
||||
local truncate=0 read_commits=0
|
||||
local truncate=0 read_commits=0 shown_commits=0
|
||||
local version tag
|
||||
local hash refs subject body
|
||||
|
||||
@ -569,6 +578,10 @@ function main {
|
||||
echo " ...more commits omitted"
|
||||
echo
|
||||
fi
|
||||
|
||||
if (( ! shown_commits )); then
|
||||
echo "No changes to mention."
|
||||
fi
|
||||
}
|
||||
|
||||
# Use raw output if stdout is not a tty
|
||||
|
@ -27,7 +27,7 @@ zstyle -s ':omz:update' mode update_mode || {
|
||||
# - $ZSH is not a git repository
|
||||
if [[ "$update_mode" = disabled ]] \
|
||||
|| [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \
|
||||
|| [[ ! -t 1 ]] \
|
||||
|| [[ ! -t 1 && ${POWERLEVEL9K_INSTANT_PROMPT:-off} == off ]] \
|
||||
|| ! command git --version 2>&1 >/dev/null \
|
||||
|| (builtin cd -q "$ZSH"; ! command git rev-parse --is-inside-work-tree &>/dev/null); then
|
||||
unset update_mode
|
||||
@ -112,6 +112,11 @@ function update_ohmyzsh() {
|
||||
local verbose_mode
|
||||
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
||||
|
||||
# Force verbose mode to silent if p10k instant prompt is enabled
|
||||
if [[ ${POWERLEVEL9K_INSTANT_PROMPT:-off} != "off" ]]; then
|
||||
verbose_mode=silent
|
||||
fi
|
||||
|
||||
if [[ "$update_mode" != background-alpha ]] \
|
||||
&& LANG= ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode; then
|
||||
update_last_updated_file
|
||||
|
Loading…
Reference in New Issue
Block a user