added oh-my-ssh back as raw code, not as a submodule.
This commit is contained in:
parent
23fe3ee6d5
commit
f663947bfc
1195 changed files with 126994 additions and 0 deletions
52
.zsh/oh-my-zsh/plugins/pipenv/README.md
Normal file
52
.zsh/oh-my-zsh/plugins/pipenv/README.md
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
# Pipenv
|
||||
|
||||
This plugin provides some features to simplify the use of [Pipenv](https://pipenv.pypa.io/) while working on ZSH.
|
||||
|
||||
In your `.zshrc` file, add `pipenv` to the plugins section
|
||||
|
||||
```
|
||||
plugins=(... pipenv ...)
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- Adds completion for pipenv ([install the `argcomplete` package to get it working with pipenv >= 2026.5.0](https://pipenv.pypa.io/en/latest/shell.html#shell-completion))
|
||||
- Auto activates and deactivates pipenv shell
|
||||
- Adds short aliases for common pipenv commands
|
||||
- `pch` is aliased to `pipenv check`
|
||||
- `pcl` is aliased to `pipenv clean`
|
||||
- `pgr` is aliased to `pipenv graph`
|
||||
- `pi` is aliased to `pipenv install`
|
||||
- `pidev` is aliased to `pipenv install --dev`
|
||||
- `pl` is aliased to `pipenv lock`
|
||||
- `po` is aliased to `pipenv open`
|
||||
- `prun` is aliased to `pipenv run`
|
||||
- `psh` is aliased to `pipenv shell`
|
||||
- `psy` is aliased to `pipenv sync`
|
||||
- `pu` is aliased to `pipenv uninstall`
|
||||
- `pupd` is aliased to `pipenv update`
|
||||
- `pwh` is aliased to `pipenv --where`
|
||||
- `pvenv` is aliased to `pipenv --venv`
|
||||
- `ppy` is aliased to `pipenv --py`
|
||||
|
||||
## Cache
|
||||
|
||||
This plugin caches the Pipenv version to avoid running `pipenv --version` on every shell startup. The cache is automatically refreshed asynchronously when the plugin is loaded, which is usually when you start a new terminal session.
|
||||
|
||||
For legacy Pipenv versions, the generated completion script is also cached.
|
||||
|
||||
The cache is stored at:
|
||||
|
||||
- `$ZSH_CACHE_DIR/pipenv_version` version of Pipenv, used to choose between argcomplete-based completion and legacy Click-based completion.
|
||||
|
||||
- `$ZSH_CACHE_DIR/completions/_pipenv` legacy Click-based completion script.
|
||||
|
||||
## Configuration
|
||||
|
||||
### Shell activation
|
||||
|
||||
If you want to disable the shell activation and deactivation feature, add the following style to your `.zshrc` before sourcing `oh-my-zsh.sh`:
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:pipenv' auto-shell no
|
||||
```
|
||||
103
.zsh/oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh
Normal file
103
.zsh/oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
if (( ! $+commands[pipenv] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# Compatibility note:
|
||||
# pipenv < 2026.5.0 used Click-based shell completion driven by the
|
||||
# _PIPENV_COMPLETE environment variable.
|
||||
#
|
||||
# pipenv >= 2026.5.0 removed this mechanism and switched to argcomplete-based
|
||||
# completion using register-python-argcomplete instead.
|
||||
|
||||
autoload -Uz is-at-least
|
||||
|
||||
_pipenv_version_cache="$ZSH_CACHE_DIR/pipenv_version"
|
||||
|
||||
if [[ -f "$_pipenv_version_cache" ]]; then
|
||||
_pipenv_version="$(< "$_pipenv_version_cache" 2>/dev/null)"
|
||||
else
|
||||
_pipenv_version="${$(pipenv --version 2>/dev/null)#pipenv, version }"
|
||||
fi
|
||||
|
||||
{
|
||||
_pipenv_fresh_version="${$(pipenv --version 2>/dev/null)#pipenv, version }"
|
||||
[[ -n "$_pipenv_fresh_version" ]] && print -r -- "$_pipenv_fresh_version" >| "$_pipenv_version_cache"
|
||||
} &|
|
||||
|
||||
if is-at-least 2026.5.0 "$_pipenv_version"; then
|
||||
# pipenv >= 2026.5.0: argcomplete-based completion (no legacy fallback)
|
||||
if (( $+commands[register-python-argcomplete] )); then
|
||||
autoload -Uz bashcompinit
|
||||
bashcompinit
|
||||
|
||||
eval "$(register-python-argcomplete pipenv)"
|
||||
fi
|
||||
else
|
||||
# legacy Click-based completion via _PIPENV_COMPLETE
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `pipenv`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_pipenv" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _pipenv
|
||||
_comps[pipenv]=_pipenv
|
||||
fi
|
||||
|
||||
zmodload -F zsh/files b:zf_mv
|
||||
() {
|
||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._pipenv"
|
||||
zf_mv -f -- =( _PIPENV_COMPLETE=zsh_source pipenv ) "$ZSH_CACHE_DIR/completions/_pipenv"
|
||||
} &|
|
||||
fi
|
||||
|
||||
if zstyle -T ':omz:plugins:pipenv' auto-shell; then
|
||||
# Automatic pipenv shell activation/deactivation
|
||||
_togglePipenvShell() {
|
||||
# deactivate shell if Pipfile doesn't exist and not in a subdir
|
||||
if [[ ! -f "$PWD/Pipfile" ]]; then
|
||||
if [[ "$PIPENV_ACTIVE" == 1 ]]; then
|
||||
# Compare whole path components: `$pipfile_dir"*` also matches unrelated
|
||||
# siblings that merely start with the same text (…/proj -> …/proj-docs),
|
||||
# which would keep the virtualenv active outside the project.
|
||||
local project_dir="${pipfile_dir%/}"
|
||||
if [[ "$PWD" != "$project_dir" && "$PWD" != "$project_dir"/* ]]; then
|
||||
unset PIPENV_ACTIVE pipfile_dir
|
||||
deactivate
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# activate the shell if Pipfile exists and its virtualenv is usable
|
||||
if [[ "$PIPENV_ACTIVE" != 1 ]]; then
|
||||
if [[ -f "$PWD/Pipfile" ]]; then
|
||||
local venv_path
|
||||
if venv_path="$(pipenv --venv 2>/dev/null)" && [[ -n "$venv_path" && -f "$venv_path/bin/activate" ]]; then
|
||||
export pipfile_dir="$PWD"
|
||||
source "$venv_path/bin/activate"
|
||||
export PIPENV_ACTIVE=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook chpwd _togglePipenvShell
|
||||
_togglePipenvShell
|
||||
fi
|
||||
|
||||
# Aliases
|
||||
alias pch="pipenv check"
|
||||
alias pcl="pipenv clean"
|
||||
alias pgr="pipenv graph"
|
||||
alias pi="pipenv install"
|
||||
alias pidev="pipenv install --dev"
|
||||
alias pl="pipenv lock"
|
||||
alias po="pipenv open"
|
||||
alias prun="pipenv run"
|
||||
alias psh="pipenv shell"
|
||||
alias psy="pipenv sync"
|
||||
alias pu="pipenv uninstall"
|
||||
alias pupd="pipenv update"
|
||||
alias pwh="pipenv --where"
|
||||
alias pvenv="pipenv --venv"
|
||||
alias ppy="pipenv --py"
|
||||
Loading…
Add table
Add a link
Reference in a new issue