python.plugin.zsh 785 B

123456789101112131415161718
  1. # Find python file
  2. alias pyfind='find . -name "*.py"'
  3. # Remove python compiled byte-code and mypy/pytest cache in either the current
  4. # directory or in a list of specified directories (including sub directories).
  5. function pyclean() {
  6. ZSH_PYCLEAN_PLACES=${*:-'.'}
  7. find ${ZSH_PYCLEAN_PLACES} -type f -name "*.py[co]" -delete
  8. find ${ZSH_PYCLEAN_PLACES} -type d -name "__pycache__" -delete
  9. find ${ZSH_PYCLEAN_PLACES} -depth -type d -name ".mypy_cache" -exec rm -r "{}" +
  10. find ${ZSH_PYCLEAN_PLACES} -depth -type d -name ".pytest_cache" -exec rm -r "{}" +
  11. }
  12. # Grep among .py files
  13. alias pygrep='grep -r --include="*.py"'
  14. # Run proper IPython regarding current virtualenv (if any)
  15. alias ipython="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"