Skip to content

Instantly share code, notes, and snippets.

@meganlkm
Last active August 29, 2015 14:24
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 meganlkm/016691823eedc3c923f2 to your computer and use it in GitHub Desktop.
Save meganlkm/016691823eedc3c923f2 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Source this from .bash_profile
#
# TODO py-ify and ansible-fy this
# append source .mypystuff to .bash_profile
#
# Usage: mkpy projectname
function get_st3_prj_file() {
printf "${ST3_PROJECTS}/${@}.sublime-project"
}
function mkst3prj() {
prj=$@
st3prj=$(get_st3_prj_file ${prj})
# what if project file exists?
if [[ -f ${st3prj} ]]; then
echo "project file already exists: [${st3prj}]";
return 0;
fi
# TODO convert this to a template
cat > $st3prj <<EOL
{
"build_systems":
[
{
"name": "Anaconda Python Builder",
"selector": "source.python",
"shell_cmd": "${WORKON_HOME}/${prj}/bin/python -u \"$file\""
}
],
"folders":
[
{
"name": "${prj} - source",
"follow_symlinks": true,
"path": "${PROJECT_HOME}/${prj}"
},
{
"name": "${prj} - env",
"follow_symlinks": true,
"path": "${WORKON_HOME}/${prj}"
}
],
"settings":
{
"anaconda_debug": true,
"anaconda_linter_underlines": true,
"python_interpreter": "${WORKON_HOME}/${prj}/bin/python",
"pep257_ignore":
[
"D209",
"D200",
"D400",
"D401",
"D205"
],
"pep8_ignore":
[
"E261",
"E265",
"E501"
],
"AdvancedNewFile": {
"base": "${PROJECT_HOME}/${prj}",
"main": "${PROJECT_HOME}/${prj}/${prj}"
}
}
}
EOL
echo "cat ${st3prj}"
}
function mkpy() {
myprj=$@
if [[ $(mkst3prj $myprj) ]]; then
mkproject $myprj
subl --project "$(get_st3_prj_file $myprj)"
fi
}
function mknode() {
myprj=$@
if [[ $(mkst3prj $myprj) ]]; then
mkproject $myprj
source ${WORKON_HOME}/${myprj}/bin/activate
pip install nodeenv
nodeenv -p
pip list
subl --project "$(get_st3_prj_file $myprj)"
fi
}
function mknodeenv() {
myprj=$@
mkproject $myprj
source ${WORKON_HOME}/${myprj}/bin/activate
pip install nodeenv
nodeenv -p
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment