forked from snwh/ubuntu-post-install
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash
More file actions
126 lines (116 loc) · 4.36 KB
/
Copy pathbash
File metadata and controls
126 lines (116 loc) · 4.36 KB
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
#!/bin/bash
function extend_aliases {
cp "${SCRIPT_DIR}/data/config/bash_aliases.in" ~/.bash_aliases_extended
if ! grep -q '\. ~/\.bash_aliases_extended' ~/.bashrc; then
cat >>~/.bashrc <<EOF
if [ -f ~/.bash_aliases_extended ]; then
. ~/.bash_aliases_extended
fi
EOF
fi
}
function configure_aliases {
echo_message header "Setting .bash_aliases"
keep_aliases="k"
replace_aliases="r"
extend_aliases="e"
# Draw window
CONFIG=$(eval `resize` && whiptail \
--notags \
--title "i3" \
--menu "\nWhich configuration would you like to install?" \
$LINES $COLUMNS $(( $LINES - 12 )) \
"${keep_aliases}" "keep existing aliases" \
"${replace_aliases}" "replace .bash_aliases" \
"${extend_aliases}" "extend .bash_aliases" \
3>&1 1>&2 2>&3)
case "${CONFIG}" in
"${keep_aliases}") echo_message info "Not modifying .bash_aliases"
;;
"${replace_aliases}") echo_message info "Replacing .bash_aliases"
cp "${SCRIPT_DIR}/data/config/bash_aliases.in" ~/.bash_aliases
;;
"${extend_aliases}") echo_message info "Extending .bash_aliases"
extend_aliases
;;
esac
}
function extend_bashrc {
cp "${SCRIPT_DIR}/data/config/bashrc_extended.in" ~/.bashrc_extended
if ! grep -q '\. ~/\.bashrc_extended' ~/.bashrc; then
cat >>~/.bashrc <<EOF
if [ -f ~/.bashrc_extended ]; then
. ~/.bashrc_extended
fi
EOF
fi
}
function configure_bashrc {
echo_message header "Setting .bashrc"
keep_bashrc="k"
replace_bashrc="r"
extend_bashrc="e"
# Draw window
CONFIG=$(eval `resize` && whiptail \
--notags \
--title "i3" \
--menu "\nWhich configuration would you like to install?" \
$LINES $COLUMNS $(( $LINES - 12 )) \
"${keep_bashrc}" "keep existing bashrc" \
"${replace_bashrc}" "replace .bashrc" \
"${extend_bashrc}" "extend .bashrc" \
3>&1 1>&2 2>&3)
case "${CONFIG}" in
"${keep_bashrc}") echo_message info "Not modifying .bashrc"
;;
"${replace_bashrc}") echo_message info "Replacing .bashrc"
cp "${SCRIPT_DIR}/data/config/bashrc_basic.in" ~/.bashrc
extend_bashrc
;;
"${extend_bashrc}") echo_message info "Extending .bashrc without copying basic configurations"
extend_bashrc
;;
esac
}
function extend_profile {
cp "${SCRIPT_DIR}/data/config/profile_extended.in" ~/.profile_extended
if ! grep -q '\. ~/\.profile_extended' ~/.profile; then
cat >>~/.profile <<EOF
if [ -f ~/.profile_extended ]; then
. ~/.profile_extended
fi
EOF
fi
}
function configure_profile {
echo_message header "Setting .profile"
keep_profile="k"
replace_profile="r"
extend_aliases="e"
# Draw window
CONFIG=$(eval `resize` && whiptail \
--notags \
--title "i3" \
--menu "\nWhich configuration would you like to install?" \
$LINES $COLUMNS $(( $LINES - 12 )) \
"${keep_profile}" "keep existing profile" \
"${replace_profile}" "replace .profile" \
"${extend_profile}" "extend .profile" \
3>&1 1>&2 2>&3)
case "${CONFIG}" in
"${keep_profile}") echo_message info "Not modifying .profile"
;;
"${replace_profile}") echo_message info "Replacing .profile"
cp "${SCRIPT_DIR}/data/config/profile_basic.in" ~/.profile
extend_profile
;;
"${extend_profile}") echo_message info "Extending .profile without copying basic configurations"
extend_profile
;;
esac
}
function configure_bash {
configure_bashrc
configure_aliases
configure_profile
}