Posted By

nerdfiles on 12/29/12


Tagged

Bash python alias workflow


Versions (?)

Py Alias (for bash)


 / Published in: Bash
 

Python Bash aliases, workflows.

  1. alias py="python"
  2. alias py_?='which python'
  3.  
  4. function py_start_project() {
  5.  
  6. # @extends FUNC_GITIN
  7. # $ gitin "USER" "$1" "github.com"
  8. # $ git branch dev
  9. # $ git checkout dev
  10. # $ git push origin dev
  11.  
  12. #prep python
  13. pbrew switch 2.7.1
  14.  
  15. #make bare essentials
  16. mkdir $1
  17. cd $1
  18.  
  19. #assume readme.markdown
  20. #assume .gitignore
  21. #assume .requirements
  22. #ignore .downloads @note since we won't assume we're using publicly available tools (gitin
  23. # assumes this).
  24.  
  25. #init python
  26. touch __init__.py
  27. echo "# -*- coding: utf-8 -*- #" >> __init__.py
  28.  
  29. #add project name (likely will shared name schema with workon; e.g. django_project_name)
  30. touch readme.markdown
  31. echo "#$1" >> readme.markdown
  32.  
  33. #iggy compiled python, others, ad hoc, etc.
  34. touch .gitignore
  35. echo "*.pyc" >> .gitignore
  36. echo "*.py~" >> .gitignore
  37. echo "settings.py" >> .gitignore
  38. echo "*.gitignore~" >> .gitignore
  39. echo "*.markdown~" >> .gitignore
  40. echo "LICENSE~" >> .gitignore
  41. echo "*.swp" >> .gitignore
  42.  
  43. #reqs
  44. touch .requirements
  45. # $ pip freeze >> .requirements
  46.  
  47. mkdir lib
  48. touch lib/.empty
  49. mkdir bin
  50. touch bin/.emtpy
  51. mkdir tests
  52. touch tests/.emtpy
  53. mkdir docs
  54. touch docs/.empty
  55.  
  56. mkvirtualenv --no-site-packages $1
  57. }
  58.  
  59. function py_init() {
  60. git s
  61.  
  62. # @see FUNC_WORK
  63. # Chooses from shared name schema with $ workon.
  64. work
  65. }
  66.  
  67. function py_e() {
  68. # @assuming URI schema: pip://[email protected]:USER/PROJECT_NAME.git#PROJECT_NAME
  69. repo="$1"
  70. echo "Installing: ${repo:6}"
  71. pip install -e ${repo:6}
  72. }

Report this snippet  

You need to login to post a comment.