Skip to content

Instantly share code, notes, and snippets.

@ergatea
Created January 19, 2013 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ergatea/4573300 to your computer and use it in GitHub Desktop.
Save ergatea/4573300 to your computer and use it in GitHub Desktop.
Sublime Text SublimeCodeIntel plugin auto
#!/bin/bash
# This hook is run after a new virtualenv is activated.
# setup python interpretor and sitepackages
# for Sublime Text's SublimeCodeIntel plugin.
# codeintel looks in the root of any folder opened via `subl foldername`
# for project/.codeintel/config
# put the project directory
wrapper=`type -P virtualenvwrapper.sh`
if [ "$wrapper" != "" ]; then
source $wrapper
workon "$1"
fi
projectdir=`pwd`
if [ ! -d "$projectdir" ]; then
echo 'project dir not found'
exit 1
fi
if [ ! -d "$projectdir"/.codeintel ]
then
mkdir "$projectdir"/.codeintel
fi
pythonbin=`which python`
site_packages=`"$pythonbin" -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())"`
if [ -e "$projectdir"/.codeintel/config ]
then
echo "Code intel file already exists. Bailing out. You can update it with:"
echo python binary: $pythonbin
echo site packages: $site_packages
exit 1
fi
echo creating $projectdir/.codeintel/config
echo python binary: $pythonbin
echo site packages: $site_packages
cat > $projectdir/.codeintel/config <<EOF
{
"Python": {
"python": '$pythonbin',
"pythonExtraPaths": ['$site_packages']
},
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment