summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorPetr Bělohlávek <petrbel@users.noreply.github.com>2017-01-20 11:05:01 +0100
committerMarc Cornellà <marc.cornella@live.com>2020-02-27 17:17:01 +0100
commit6b54302b90720437300967b3506bffe00a3e243c (patch)
tree1665bce753ddcbeafd6361436f8a24040b864ec9 /plugins
parentbccfe1389c97379388a148b3a48a63d7272ec017 (diff)
downloadzsh-6b54302b90720437300967b3506bffe00a3e243c.tar.gz
zsh-6b54302b90720437300967b3506bffe00a3e243c.tar.bz2
zsh-6b54302b90720437300967b3506bffe00a3e243c.zip
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
Diffstat (limited to 'plugins')
-rw-r--r--plugins/python/README.md1
-rw-r--r--plugins/python/python.plugin.zsh2
2 files changed, 3 insertions, 0 deletions
diff --git a/plugins/python/README.md b/plugins/python/README.md
index 2d955c5cb..e391bcfd4 100644
--- a/plugins/python/README.md
+++ b/plugins/python/README.md
@@ -14,3 +14,4 @@ plugins=(... python)
| `pyfind` | Finds .py files recursively in the current directory |
| `pyclean [dirs]` | Deletes byte-code and cache files from a list of directories or the current one |
| `pygrep <text>` | Looks for `text` in .py files |
+| `ipython` | Runs the appropriate `ipython` version according to the activated virtualenv |
diff --git a/plugins/python/python.plugin.zsh b/plugins/python/python.plugin.zsh
index f39cd80b7..62855fca2 100644
--- a/plugins/python/python.plugin.zsh
+++ b/plugins/python/python.plugin.zsh
@@ -14,3 +14,5 @@ function pyclean() {
# 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()'"