Skip to content

Instantly share code, notes, and snippets.

@nu7hatch
Created November 14, 2010 23:06
Show Gist options
  • Save nu7hatch/676193 to your computer and use it in GitHub Desktop.
Save nu7hatch/676193 to your computer and use it in GitHub Desktop.
The smallest workflow initializer!
#!/usr/bin/env python
# Probably the smallest script to initialize workflow of your projects. Usage:
#
# * copy script to your bin
# * make the $HOME/.workflow directory
# * write plain bash/sh bootstraper, eg:
#
# #!/bin/bash
# path=/path/to/your/project
# sudo /etc/rc.d/redis start
# sudo /etc/rc.d/mongodb start
# emacs "$path" &
# cd "$path"
#
# ... place it in $HOME/.workflow/project-name and make it executable (chmod u+x ...)
#
# * now you can easy switch to work on this project using single command:
#
# workon project-name
#
# Enjoy!
import sys
import os
def main(argv):
if len(argv) <= 1:
print("You have to specify project name")
exit(2)
else:
name = argv[1]
initializer = '%s/.workon/%s' % (os.getenv('HOME'), name)
if os.path.isfile(initializer):
os.system(initializer)
else:
print("Project %s doesn't exist" % name)
exit(1)
if __name__ == '__main__':
main(sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment