Last active
December 18, 2015 00:28
-
-
Save tkanmae/5696513 to your computer and use it in GitHub Desktop.
Call ipython with a per-project profile. It assumes that .ipython directory is in the top level directory managed by git.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Call ipython with a per-project profile. It assumes that .ipython directory | |
# is in the top level directory of a project managed by git. | |
function ipython() { | |
local project_root_dir | |
# If the user specifies `IPYTHONDIR` either by giving --ipython-dir | |
# option or by an environmental variable IPYTHONDIR, then the specified | |
# directory should have precedence over per-project `IPYTHONDIR`. | |
if [[ $* =~ --ipython-dir || -n $IPYTHONDIR ]]; then | |
command ipython $* | |
else | |
project_root_dir=$(git rev-parse --show-toplevel 2>/dev/null) | |
if [[ -d "$project_root_dir/.ipython" ]]; then | |
command ipython $* --ipython-dir="$project_root_dir/.ipython" | |
else | |
command ipython $* | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment