-
Notifications
You must be signed in to change notification settings - Fork 0
/
arpen
executable file
·150 lines (137 loc) · 4.36 KB
/
arpen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/zsh
## Gets $HOME usable in a hurry.
main() {
set -e
welcome
demand_git # note: One of ingy's goals is to undep from git. (TODO)
choose_remote_github_type
cd
get_base_dotdotdot_system
configure_dotdotdot_conf_file
.../... super_update_install </dev/null
}
configure_dotdotdot_conf_file() {
conf=~/.../conf
cyan_line Configuring the $conf file
echo
echo install_method: symlink > $conf
echo dots: >> $conf
no_biggie='Skipping this repo should cause no problems.'
sharpsaw loop \
'This one seems odd, but it is an important piece for plural *-dots to work' \
'Without it, only the first .zshrc/.bashrc/.vimrc/etc will work. "y" is smart.'
sharpsaw sane \
'These are basic settings that are kind of annoying when they are missing' \
'Without these, you will not have the "ll" alias, etc. No biggie, though.'
sharpsaw 1337 \
'Semi-aggressive configs for the adventurous.' \
'Skip this if you want, but it can be more fun with it in place.'
sharpsaw tmux \
'The ,t command (session create-or-attach), plus a tweaked ~/.tmux.conf' \
"Skip if you do not use tmux (but who doesn't use tmux?)"
sharpsaw vim \
'A wad of scripts and plugins for vim' "$no_biggie"
sharpsaw git \
'A pile of trs gt cmnds, plus a few config file tweaks.' \
'Decline if you do not want to enjoy a bunch of shortcuts.'
cyan_line OS-dots
sharpsaw posix 'Common *nix tools: ,i = install; ,s = search; etc' \
"$no_biggie"
sharpsaw x 'X11 config (good for OS X, too)' "$no_biggie"
if [ -d /Library ]; then
sharpsaw mac \
'A few spiffups for OS X. Needs more stuff, but should be OK' "$no_biggie"
elif [ Linux = "`uname`" ]; then
sharpsaw linux 'Linux-specific stuff' "$no_biggie"
fi
cyan_line Language-specific dots
sharpsaw ruby '~/.pryrc, terse aliases, etc.' "$no_biggie"
sharpsaw perl 'pmf/mi/mt/etc.' "$no_biggie"
sharpsaw acmeism 'uniscript .vim, more to come' "$no_biggie"
sharpsaw local 'Compile/install to $HOME, if without root' "$no_biggie"
sharpsaw unicode 'Input/search for Unicode chars' "$no_biggie"
ask_to_add_github_repo exad/zu 'Unarchive anything(?)' "$no_biggie"
cyan_line OK. Created the following in $conf
cat $conf
}
welcome() {
cat <<EOT
`cyan Welcome to the world of Sharpsaw.org!`
A few quick prompts and you are on your way.
EOT
}
demand_git() {
if ! type git 2>&1 >/dev/null; then
cat <<EOT
`red git not found`. This really won't work without it.
Try: apt-get install git
or: emerge git
or: Install XCode + Homebrew then brew
...etc.
EOT
exit 1
fi
}
choose_remote_github_type() {
binary_prompt \
h "Using https means you don't have to set up SSH keys." \
s "Using ssh means you can 'git push' without password prompts." \
" Github remotes are: `green h`ttps or `yellow s`sh (default):"
if [ 's' = "$got" ]; then
eval `ssh-agent`
ssh-add
gh_base='[email protected]:'
elif [ 'h' = "$got" ]; then
gh_base='https://github.com/'
else
red_line "Uh-oh. Unrecoginized '$got'. Please email [email protected]"
fi
echo $gh_base
}
get_base_dotdotdot_system() {
[ -e .../... ] && return
cyan_line Getting the ... base system
git clone ${gh_base}ingydotnet/... || exit 2
}
ask_to_add_github_repo() {
cyan_line "https://github.com/$1"
binary_prompt y "$2" n "$3" \
"Choose `green y` to add this repo (default), or `yellow n` to skip:"
if [ 'y' = "$got" ]; then
echo "- repo: $gh_base$1" >> $conf
fi
echo
}
sharpsaw() {
ask_to_add_github_repo sharpsaw/$1-dots "$2" "$3"
}
red() { printf "\033[31;1m%s\033[0m" "$*"; }
red_line() { echo `red "$@"`; }
yellow() { printf "\033[33m%s\033[0m" "$*"; }
yellow_line() { echo `yellow "$@"`; }
green() { printf "\033[32m%s\033[0m" "$*"; }
green_line() { echo `green "$@"`; }
cyan() { printf "\033[36;1m%s\033[0m" "$*"; }
cyan_line() { echo `cyan "$@"`; }
binary_prompt() {
a=$1
green_line $2
b=$3
yellow_line $4
prompt=$5
printf "$prompt "
unset got
until [ -n "$got" ]; do
read got
[ '' = "$got" ] && got=$a
case $got in
$a*) got=$a;;
$b*) got=$b;;
*)
red_line "'$got' was neither $a, nor $b, nor blank (implying $a)."
printf 'Please try again: '
unset got
esac
done
}
main