Created
November 14, 2010 23:06
-
-
Save nu7hatch/676193 to your computer and use it in GitHub Desktop.
The smallest workflow initializer!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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