1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-11 08:20:09 +00:00
ohmyzsh/plugins/python/python.plugin.zsh
Petr Bělohlávek 6b54302b90 python: add alias to run the proper IPython based on virtualenv
Current state: a user invokes `ipython` and is provided with the IPython
instance regarding the `$PATH`.

Proposed state: a user invokes `ipython` (which is a new alias in the
*python plugin*) and is provided with the proper IPython instance regarding
the currently activated virtualenv.

Example: the user's default Python is 2.7 with installed IPython 2.7. User
activates Python 3.5 virtualenv where he installs IPython 3.5. After
activating the environment, one expects `ipython` to run the version 3.5,
which does not happen by default. Instead, IPython 2.7 is used, which in
counter-intuitive and often causes problem.

Closes #5797
2020-02-27 17:17:01 +01:00

18 lines
785 B
Bash

# Find python file
alias pyfind='find . -name "*.py"'
# Remove python compiled byte-code and mypy/pytest cache in either the current
# directory or in a list of specified directories (including sub directories).
function pyclean() {
ZSH_PYCLEAN_PLACES=${*:-'.'}
find ${ZSH_PYCLEAN_PLACES} -type f -name "*.py[co]" -delete
find ${ZSH_PYCLEAN_PLACES} -type d -name "__pycache__" -delete
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 "{}" +
}
# Grep among .py files
alias pygrep='grep -r --include="*.py"'
# Run proper IPython regarding current virtualenv (if any)
alias ipython="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"