Created
March 1, 2014 05:41
-
-
Save seveibar/9285767 to your computer and use it in GitHub Desktop.
Used on my system to create a new "fiddle" project, which is used for small web projects
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 ruby | |
mode = "workspace" | |
style = nil | |
markup = nil | |
if ARGV[0] then | |
mode = "nothing" | |
style = ARGV[0] | |
markup = ARGV[1] | |
else | |
puts "Style Type:" | |
style = gets.strip | |
puts "Markup Type:" | |
markup = gets.strip | |
end | |
puts mode | |
all_dirs = `cd ../workspace/fiddle && ls` | |
dir = all_dirs.split("\n").last() | |
dir_num = dir.to_i() + 1 | |
dir_num_name = "%02d" % dir_num | |
`mkdir ../workspace/fiddle/#{dir_num_name}` | |
to_dir = "cd ../workspace/fiddle/" + dir_num_name + "/ &&" | |
`#{to_dir} touch main.js` | |
`#{to_dir} cp ../.template/style.#{style} ./style.#{style}` | |
`#{to_dir} cp ../.template/index.#{markup} ./index.#{markup}` | |
`#{to_dir} cp ../.template/makefile ./makefile` | |
`#{to_dir} cp -a ../.template/build ./build` | |
`#{to_dir} ln -s ../.template/lib ./lib` | |
`#{to_dir} git init` | |
if mode == "workspace" then | |
# Start dev environment | |
make_args = [] | |
if markup == "haml" then | |
`#{to_dir} touch index.html` | |
make_args.push "haml" | |
end | |
if style == "less" then | |
make_args.push "less" | |
end | |
`#{to_dir} gnome-terminal -x sh -c "watch -n .5 'make #{make_args.join(" ")}'"` | |
`#{to_dir} subl .` | |
`firefox -new-window file:///home/seve/workspace/fiddle/#{dir_num_name}/index.html` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment