{"id":662,"date":"2015-03-04T00:18:49","date_gmt":"2015-03-04T06:18:49","guid":{"rendered":"http:\/\/www.crccheck.com\/blog\/?p=662"},"modified":"2015-10-11T22:21:50","modified_gmt":"2015-10-12T04:21:50","slug":"patterns-bootstrapping-pythonsublimetext-projects","status":"publish","type":"post","link":"https:\/\/www.crccheck.com\/blog\/patterns-bootstrapping-pythonsublimetext-projects\/","title":{"rendered":"Patterns: bootstrapping Python\/SublimeText projects"},"content":{"rendered":"<p>I consider myself really lazy. So here&#8217;s my basic workflow of home-grown commands I go through whenever I work on a Python project.<\/p>\n<p>Some notes before I dive in:<\/p>\n<ul>\n<li>replace\u00c2\u00a0 <code>$PROJECT<\/code> with the name of your project. I keep a consistent name between projects so I can use the directory name for other things.<\/li>\n<li>some tedious things I alias, some I don&#8217;t<\/li>\n<\/ul>\n<pre># everything has to live somewhere\r\nmd $PROJECT\r\n# equivalent to: mdkdir $PROJECT &amp;&amp; cd $PROJECT\r\n# my alias: md () { mkdir -p \"$@\" &amp;&amp; cd \"$@\"; }\r\n\r\n# Using virtualenvwrapper, make a virtualenv the same name as the project\r\nmkvirtualenv $PROJECT\r\n\r\n# These next steps happen automatically in my global <a href=\"https:\/\/github.com\/crccheck\/dotfiles\/blob\/master\/virtualenv\/postactivate\" target=\"_blank\">postactivate<\/a>\r\n# Give this virtualenv its own ipython configuration so it has its own ipython history\r\nmkipythonconfig\r\n# change my tab title to the name of this virtualenv so I can tell my tabs apart\r\necho -e \"\\033];$(basename $VIRTUAL_ENV)\\007\"\r\n# my alias: tit() { echo -e \"\\033];$@\\007\" }\r\n\r\n# This makes it so when I `workon $PROJECT`, I automatically cd to it.\r\n# Sometimes, this is undesirable, but `cd -` will take you back.\r\nsetvirtualenvproject\r\n# likewise I have a function named `work` that activates or creates the virtualenv:\r\nfunction work {\r\n  # assumes `mkvirtualenv` exists\r\n  local env_name=$(basename $PWD)\r\n  workon $env_name\r\n  if [ $? -ne 0 ]; then\r\n    echo \"Shall I create $env_name it for you? [Yn]\"\r\n    read -n 1 sure\r\n    if [ -z \"$sure\" ] || [ \"$sure\" = 'y' ] || [ \"$sure\" = 'Y' ]; then\r\n      mkvirtualenv $env_name\r\n      setvirtualenvproject\r\n    fi\r\n  fi\r\n}\r\n\r\n# create a sublime text 2 project with a <a href=\"https:\/\/github.com\/srusskih\/SublimeJEDI\" target=\"_blank\">SublimeJEDI<\/a> configuration\r\nmksublconfig &gt; ~\/Documents\/$PROJECT.sublime-project\r\n# source: https:\/\/github.com\/crccheck\/dotfiles\/blob\/master\/bin\/mksublconfig\r\n\r\n# Create an .env file to store configuration like DJANGO_SETTINGS_MODULE\r\n# Works in conjunction with <a href=\"https:\/\/github.com\/crccheck\/autoenv\">autoenv<\/a>.\r\ntouch .env\r\n\r\n# If I'm creating a new project, I create an empty initial commit so I can\r\n# squash and rebase things from the beginning.\r\ngit init\r\ngit initempty\r\n#\u00c2\u00a0 initempty = !git init &amp;&amp; git commit -m 'initial commit (empty)' --allow-empty\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I consider myself really lazy. So here&#8217;s my basic workflow of home-grown commands I go through whenever I work on a Python project. Some notes before I dive in: replace\u00c2\u00a0 $PROJECT with the name of your project. I keep a consistent name between projects so I can use the directory name for other things. some&hellip;<\/p>\n <a href=\"https:\/\/www.crccheck.com\/blog\/patterns-bootstrapping-pythonsublimetext-projects\/\" title=\"Patterns: bootstrapping Python\/SublimeText projects\" class=\"entry-more-link\"><span>Read More<\/span> <span class=\"screen-reader-text\">Patterns: bootstrapping Python\/SublimeText projects<\/span><\/a>","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[1],"tags":[],"class_list":["entry","author-showmewhatyougot","post-662","post","type-post","status-publish","format-standard","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/posts\/662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/comments?post=662"}],"version-history":[{"count":6,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/posts\/662\/revisions"}],"predecessor-version":[{"id":682,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/posts\/662\/revisions\/682"}],"wp:attachment":[{"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/media?parent=662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/categories?post=662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/tags?post=662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}