I work on various projects and always forget what should I type to run a server, do a deploy etc. So, how I dealt with this problem and have a single shell command for that?
Add to your global .gitignore:
.execAdd the following function to your .zshrc/.bashrc:
function e {
$(git rev-parse --show-toplevel)/.exec $1
}Now for each project, in a root directory, you need to create .exec file with the execute permission (chmod +x ./.exec). I use this template as a starter-kit:
#!/usr/bin/env ruby
def server
exec('')
end
def deploy
exec('')
end
case ARGV[0]
when "s", "server" then server
when "d", "deploy" then deploy
endFor example, for Jekyll website it'd look like this:
#!/usr/bin/env ruby
def server
exec('jekyll serve')
end
def deploy
exec('git checkout gh-pages && git rebase master && git push && git checkout master')
end
case ARGV[0]
when "s", "server" then server
when "d", "deploy" then deploy
endFor JS project that utilize gulp:
#!/usr/bin/env ruby
def server
exec('gulp server')
end
def deploy
exec('gulp publish')
end
case ARGV[0]
when "s", "server" then server
when "d", "deploy" then deploy
endetc.
That's all. No matter what I'm working on I can just type e s and it always run a local server.