Created
November 25, 2012 18:32
-
-
Save yonchu/4144711 to your computer and use it in GitHub Desktop.
pythonのsite-packagesディレクトリへ移動(cd)
This file contains 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
# Add the following function to ~/.bashrc or ~/.zshrc | |
function cdsite() { | |
local py_cmd | |
py_cmd=`cat << 'EOF' | |
from __future__ import print_function | |
import sys | |
import os | |
import site | |
site_prefix = site.PREFIXES[0] | |
version = str(sys.version_info[0]) + '.' + str(sys.version_info[1]) | |
site_path = os.path.join(site_prefix, 'lib/python' + version, 'site-packages') | |
print(site_path) | |
EOF` | |
local site_path=$(python -c "$py_cmd") | |
[ -d "$site_path" ] || return 1 | |
echo "$site_path" | |
cd "$site_path" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment