From edc449275b6c04445f58b108ca0937a87c1e8430 Mon Sep 17 00:00:00 2001 From: Aditya Date: Mon, 27 Feb 2023 20:04:56 +0530 Subject: add zsh --- oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh (limited to 'oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh') diff --git a/oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh b/oh-my-zsh/plugins/pipenv/pipenv.plugin.zsh new file mode 100644 index 0000000..4be61a9 --- /dev/null +++ b/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" -- cgit v1.2.3