.homedir-setup.rb

Fri, 06 Nov 2015 14:32:58 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Fri, 06 Nov 2015 14:32:58 -0500
changeset 225
5b91792c70ba
parent 213
859dd4b440d8
child 240
18f78b36f003
permissions
-rwxr-xr-x

Add elixir defs

94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1 #!/usr/bin/env ruby
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2 # vim: et sts=2 sw=2 fdm=marker
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
3
136
b634c40e658b Update, got omz files in right place
Meredith Howard <mhoward@roomag.org>
parents: 96
diff changeset
4 # we don't yet have rbenv so keep safe for ruby 1.9
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
5
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
6 require 'getoptlong'
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
7
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
8 if `which git` == ''
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
9 puts "please install git"
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
10 exit 1
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
11 end
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
12
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
13 def main
160
3b873456c2b3 default to --help
Meredith Howard <mhoward@roomag.org>
parents: 152
diff changeset
14 if ARGV.length == 0
3b873456c2b3 default to --help
Meredith Howard <mhoward@roomag.org>
parents: 152
diff changeset
15 ARGV << '--help'
3b873456c2b3 default to --help
Meredith Howard <mhoward@roomag.org>
parents: 152
diff changeset
16 end
3b873456c2b3 default to --help
Meredith Howard <mhoward@roomag.org>
parents: 152
diff changeset
17
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
18 opts = GetoptLong.new(
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
19 [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
20 [ '--update', '-u', GetoptLong::NO_ARGUMENT ],
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
21 [ '--setup', '-s', GetoptLong::NO_ARGUMENT ],
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
22 );
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
23
184
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
24 Dir.chdir(
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
25 File.dirname File.expand_path $0
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
26 )
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
27
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
28 opts.each do |opt, arg|
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
29 case opt
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
30 when '--help'
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
31 puts <<-ENDHELP.sub(/^\s+/,'')
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
32 #{$0} usage:
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
33 -h --help This help message
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
34 -s --setup Perform home directory setup (git clone)
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
35 -u --update Update git stuff (git pull)
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
36 ENDHELP
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
37 exit 1
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
38 when '--setup'
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
39 setup
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
40 when '--update'
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
41 update
ddb5e993a367 Handle all passed options, chdir to bindir
Meredith Howard <mhoward@roomag.org>
parents: 160
diff changeset
42 end
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
43 end
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
44 end
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
45
136
b634c40e658b Update, got omz files in right place
Meredith Howard <mhoward@roomag.org>
parents: 96
diff changeset
46 # just checks and bails after each call, output already in STDERR
96
f4808ae73ead clean up
Meredith Howard <mhoward@roomag.org>
parents: 94
diff changeset
47 def do_cmds (*cmds)
f4808ae73ead clean up
Meredith Howard <mhoward@roomag.org>
parents: 94
diff changeset
48 cmds.each do |cmd|
f4808ae73ead clean up
Meredith Howard <mhoward@roomag.org>
parents: 94
diff changeset
49 puts "$ #{cmd}"
f4808ae73ead clean up
Meredith Howard <mhoward@roomag.org>
parents: 94
diff changeset
50 system( cmd ) or exit $?
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
51 end
96
f4808ae73ead clean up
Meredith Howard <mhoward@roomag.org>
parents: 94
diff changeset
52 end
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
53
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
54
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
55 def setup
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
56
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
57 # oh-my-zsh {{{
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
58 # some custom zsh files are already in .oh-my-zsh.cust
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
59
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
60 if Dir.exists?('.oh-my-zsh/.git')
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
61 puts "oh-my-zsh already installed"
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
62 else
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
63 puts "Installing oh-my-zsh..."
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
64
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
65 do_cmds \
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
66 'git clone git://github.com/robbyrussell/oh-my-zsh.git .oh-my-zsh'
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
67
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
68 end
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
69
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
70 # }}}
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
71
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
72
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
73 # plenv {{{
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
74
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
75 if Dir.exists?('.plenv')
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
76 puts "plenv already installed"
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
77 else
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
78 puts "Installing plenv..."
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
79
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
80 do_cmds \
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
81 'git clone git://github.com/tokuhirom/plenv.git .plenv',
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
82 'git clone git://github.com/tokuhirom/Perl-Build.git .plenv/plugins/perl-build/'
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
83
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
84 end
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
85
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
86 # }}}
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
87
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
88
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
89 # rbenv {{{
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
90 if Dir.exists?('.rbenv')
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
91 puts "rbenv already installed"
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
92 else
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
93 puts "Installing rbenv..."
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
94
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
95 do_cmds \
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
96 'git clone https://github.com/sstephenson/rbenv.git .rbenv',
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
97 'git clone https://github.com/sstephenson/ruby-build.git .rbenv/plugins/ruby-build/'
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
98
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
99 end
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
100 # }}}
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
101
213
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
102
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
103 # ndenv {{{
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
104 if Dir.exists?('.ndenv')
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
105 puts "ndenv already installed"
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
106 else
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
107 puts "Installing ndenv..."
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
108
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
109 do_cmds \
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
110 'git clone https://github.com/riywo/ndenv.git .ndenv',
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
111 'git clone https://github.com/riywo/node-build.git .ndenv/plugins/node-build'
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
112
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
113 end
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
114 # }}}
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
115
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
116
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
117 end
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
118
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
119 def update
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
120
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
121 [
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
122 '.oh-my-zsh',
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
123 '.plenv',
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
124 '.plenv/plugins/perl-build',
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
125 '.rbenv',
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
126 '.rbenv/plugins/ruby-build',
213
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
127 '.ndenv',
859dd4b440d8 Add ndenv
Meredith Howard <mhoward@roomag.org>
parents: 185
diff changeset
128 '.ndenv/plugins/node-build',
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
129 ].each do |dir|
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
130 do_cmds \
185
4e227517a5cd chdir not actually available everywhere
Meredith Howard <mhoward@roomag.org>
parents: 184
diff changeset
131 "cd ~/#{dir} && git pull origin master"
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
132 end
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
133
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
134
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
135 end
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
136
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
137 main
136
b634c40e658b Update, got omz files in right place
Meredith Howard <mhoward@roomag.org>
parents: 96
diff changeset
138

mercurial