python.plugin.zsh 785 Bytes
Newer Older
1
2
3
# Find python file
alias pyfind='find . -name "*.py"'

4
5
# Remove python compiled byte-code and mypy/pytest cache in either the current
# directory or in a list of specified directories (including sub directories).
6
7
8
function pyclean() {
    ZSH_PYCLEAN_PLACES=${*:-'.'}
    find ${ZSH_PYCLEAN_PLACES} -type f -name "*.py[co]" -delete
Carlos Cardoso's avatar
Carlos Cardoso committed
9
    find ${ZSH_PYCLEAN_PLACES} -type d -name "__pycache__" -delete
10
11
    find ${ZSH_PYCLEAN_PLACES} -depth -type d -name ".mypy_cache" -exec rm -r "{}" +
    find ${ZSH_PYCLEAN_PLACES} -depth -type d -name ".pytest_cache" -exec rm -r "{}" +
12
}
13
14

# Grep among .py files
15
alias pygrep='grep -r --include="*.py"'
16

17
18
# Run proper IPython regarding current virtualenv (if any)
alias ipython="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"