diff options
author | 2025-02-13 14:13:49 +0530 | |
---|---|---|
committer | 2025-02-13 14:13:49 +0530 | |
commit | 8a2e1006b3b272126332aa064f3ad95387129544 (patch) | |
tree | 944c80ac612a65980d94a54ba11b6c7102037ecf /.config/zsh/oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh | |
parent | dcbb16d8b08ff5956abef5e6478b59df2e93ad35 (diff) | |
download | dotfiles-master.tar.gz dotfiles-master.tar.bz2 dotfiles-master.zip |
Diffstat (limited to '.config/zsh/oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh')
-rw-r--r-- | .config/zsh/oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/.config/zsh/oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh b/.config/zsh/oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh new file mode 100644 index 0000000..4be61a9 --- /dev/null +++ b/.config/zsh/oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh @@ -0,0 +1,44 @@ +# Pipenv completion +_pipenv() { + eval $(env COMMANDLINE="${words[1,$CURRENT]}" _PIPENV_COMPLETE=complete-zsh pipenv) +} +compdef _pipenv pipenv + +# 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 + if [[ "$PWD" != "$pipfile_dir"* ]]; then + exit + fi + fi + fi + + # activate the shell if Pipfile exists + if [[ "$PIPENV_ACTIVE" != 1 ]]; then + if [[ -f "$PWD/Pipfile" ]]; then + export pipfile_dir="$PWD" + pipenv shell + fi + fi +} +autoload -U add-zsh-hook +add-zsh-hook chpwd _togglePipenvShell +_togglePipenvShell + +# 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 pwh="pipenv --where" +alias pvenv="pipenv --venv" +alias ppy="pipenv --py" |