.homedir-setup.rb

Sun, 19 Oct 2014 03:36:29 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 19 Oct 2014 03:36:29 -0400
changeset 156
0a58a576e95e
parent 152
69896d410e89
child 160
3b873456c2b3
permissions
-rwxr-xr-x

always show the break mark in the left column

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
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
14 opts = GetoptLong.new(
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
15 [ '--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
16 [ '--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
17 [ '--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
18 );
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
19
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
20 case opts.get.shift
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
21 when '--help'
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
22 puts <<-ENDHELP.sub(/^\s+/,'')
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
23 #{$0} usage:
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
24 -h --help This help message
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
25 -s --setup Perform home directory setup (git clone)
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
26 -u --update Update git stuff (git pull)
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
27 ENDHELP
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
28 exit 1
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
29 when '--setup'
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
30 setup
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
31 when '--update'
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
32 update
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
33 end
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
34 end
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
35
136
b634c40e658b Update, got omz files in right place
Meredith Howard <mhoward@roomag.org>
parents: 96
diff changeset
36 # just checks and bails after each call, output already in STDERR
96
f4808ae73ead clean up
Meredith Howard <mhoward@roomag.org>
parents: 94
diff changeset
37 def do_cmds (*cmds)
f4808ae73ead clean up
Meredith Howard <mhoward@roomag.org>
parents: 94
diff changeset
38 cmds.each do |cmd|
f4808ae73ead clean up
Meredith Howard <mhoward@roomag.org>
parents: 94
diff changeset
39 puts "$ #{cmd}"
f4808ae73ead clean up
Meredith Howard <mhoward@roomag.org>
parents: 94
diff changeset
40 system( cmd ) or exit $?
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
41 end
96
f4808ae73ead clean up
Meredith Howard <mhoward@roomag.org>
parents: 94
diff changeset
42 end
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
43
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
44
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
45 def setup
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
46
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
47 # oh-my-zsh {{{
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
48 # 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
49
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
50 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
51 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
52 else
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
53 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
54
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
55 do_cmds \
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
56 '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
57
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
58 end
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
59
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
60 # }}}
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
61
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
62
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
63 # plenv {{{
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
64
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
65 if Dir.exists?('.plenv')
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
66 puts "plenv already installed"
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
67 else
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
68 puts "Installing plenv..."
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 do_cmds \
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
71 '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
72 '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
73
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
74 end
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
75
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
76 # }}}
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
77
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
78
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
79 # rbenv {{{
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
80 if Dir.exists?('.rbenv')
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
81 puts "rbenv already installed"
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
82 else
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
83 puts "Installing rbenv..."
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
84
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
85 do_cmds \
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
86 '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
87 '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
88
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
89 end
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
90 # }}}
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
91
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
92 end
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
93
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
94 def update
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
95
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
96 [
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
97 '.oh-my-zsh',
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
98 '.plenv',
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
99 '.plenv/plugins/perl-build',
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
100 '.rbenv',
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
101 '.rbenv/plugins/ruby-build',
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
102 ].each do |dir|
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
103 do_cmds \
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
104 "chdir ~/#{dir} && git pull origin master"
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
105 end
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
106
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
107
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
108 end
94
51ca19919894 Try to make setup easier, unify shell environments
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
109
152
69896d410e89 add easy update option for stuff that's git-based
Meredith Howard <mhoward@roomag.org>
parents: 136
diff changeset
110 main
136
b634c40e658b Update, got omz files in right place
Meredith Howard <mhoward@roomag.org>
parents: 96
diff changeset
111

mercurial