自从我买了 Alfred powerpack,就不停地在想怎么充分利用这东西~ 每次新建 Rails 项目都要做一大堆工作,我实在不想手工做了~于是就有了下面这段代码~~ 不仅能帮你立即配置好 capistrano,还能初始化 git 并自动创建 bitbucket 的 git 仓库并提交~~真正一键完成
cd ~/rails/;
rails new {query};
#将capistrano代码复制过来
#capistrano代码请自行配置 http://railscasts.com/episodes/337-capistrano-recipes
cp -R ~/rails/ToolBox/capistrano/recipes ~/rails/{query}/config/;
cp ~/rails/ToolBox/capistrano/deploy.rb ~/rails/{query}/config/;
#在deploy.rb中设置应用名为APPLICATION_NAME
sed 's/APPLICATION_NAME/{query}/g' ~/rails/{query}/config/deploy.rb > ~/rails/{query}/config/deploy.rb;
#配置pow,如未使用可删除
cd ~/.pow;
ln -s ~/rails/{query};
cd ~/rails/{query}/;
#我使用bitbucket托管代码,用github自行修改
curl -u username:password -d "name={query}&scm=git&is_private=true&language=ruby" https://api.bitbucket.org/1.0/repositories
git init;
git remote add origin ssh://[email protected]/username/{query}.git;
git add .;
git commit -m "init project";
git push -u origin --all;
mate .;