From f532737ed916467d679348e698171e8ac923f669 Mon Sep 17 00:00:00 2001 From: gwbeip Date: Sat, 24 Jan 2026 21:45:48 +0800 Subject: [PATCH] python alias --- zsh/alias/python_alias.sh | 17 ++++++++++++++++- zsh/zshrc | 4 +++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/zsh/alias/python_alias.sh b/zsh/alias/python_alias.sh index 43d8e47..295022d 100644 --- a/zsh/alias/python_alias.sh +++ b/zsh/alias/python_alias.sh @@ -1 +1,16 @@ -alias py='python3' +if (( $+commands[python3] )); then + alias py='python3' +fi + +function pyclean() { + find "${@:-.}" -type f -name "*.py[co]" -delete + find "${@:-.}" -type d -name "__pycache__" -delete + find "${@:-.}" -depth -type d -name ".mypy_cache" -exec rm -r "{}" + + find "${@:-.}" -depth -type d -name ".pytest_cache" -exec rm -r "{}" + +} + +# Grep among .py files +alias pygrep='grep -nr --include="*.py"' + +# Share local directory as a HTTP server +alias pyserver="python3 -m http.server" diff --git a/zsh/zshrc b/zsh/zshrc index 11b46a0..c93fbcc 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -50,7 +50,9 @@ source $ZSH_POLYJUICE_PLUGINS_PATH/zsh-syntax-highlighting/zsh-syntax-highlighti source $ZSH_POLYJUICE_PLUGINS_PATH/fzf-tab/fzf-tab.plugin.zsh # relies on fzf itself and zsh-autosuggestions plugin source $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh/plugins/fzf/fzf.plugin.zsh source $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh/plugins/zoxide/zoxide.plugin.zsh -source $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh/plugins/python/python.plugin.zsh + +# PYTHON_AUTO_VRUN=true +# source $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh/plugins/python/python.plugin.zsh # using starship as prompt