This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 285
/
setup_dotfiles
113 lines (107 loc) · 3.76 KB
/
setup_dotfiles
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
#!/bin/bash
# Set preferred bash aliased by copying the 'bash_aliases.in' file to ~/.bash_aliases
function write_bash_aliases {
# Check list
INPUT=$(dirname "$0")'/data/config/bash_aliases.in'
# Draw window
if (eval `resize` && whiptail \
--title "Preferred Bash Aliases" \
--yesno "Current list of preferred bash aliases: \n\n$(while read LINE; do echo " "$LINE; done < $INPUT) \n\nProceed?" \
$LINES $COLUMNS $(( $LINES - 12 )) \
--scrolltext) then
echo_message info "Setting bash aliases..."
# simply copy the list file to the aliases file
cp $INPUT ~/.bash_aliases
echo_message success "Bash aliases set successfully."
whiptail --title "Finished" --msgbox "Bash aliases set successfully." 8 56
setup_dotfiles
else
setup_dotfiles
fi
}
# Configure environment variables by copying the 'profile.in' file to ~/.profile
function write_profile {
# Check list
INPUT=$(dirname "$0")'/data/config/profile.in'
# Draw window
if (eval `resize` && whiptail \
--title "Configure Environment Variables" \
--yesno "Custom config file contains the following: \n\n$(while read LINE; do echo " "$LINE; done < $INPUT) \n\nOverwrite existing config?" \
$LINES $COLUMNS $(( $LINES - 12 )) \
--scrolltext) then
echo_message info "Overwriting ~/.profile..."
# simply copy the list file to the aliases file
cp $INPUT ~/.profile
echo_message success "Environment variables successfully configured."
whiptail --title "Finished" --msgbox "Environment variables successfully configured." 8 56
setup_dotfiles
else
setup_dotfiles
fi
}
# Configure bash profile by copying the 'bashrc.in' file to ~/.bashrc
function write_bashrc {
# Check list
INPUT=$(dirname "$0")'/data/config/bashrc.in'
# Draw window
if (eval `resize` && whiptail \
--title "Configure Bash" \
--yesno "Custom config file contains the following: \n\n$(while read LINE; do echo " "$LINE; done < $INPUT) \n\nOverwrite existing config?" \
$LINES $COLUMNS $(( $LINES - 12 )) \
--scrolltext) then
echo_message info "Overwriting ~/.bashrc..."
# simply copy the list file to the aliases file
cp $INPUT ~/.bashrc
echo_message success "Bash successfully configured."
whiptail --title "Finished" --msgbox "Bash successfully configured." 8 56
setup_dotfiles
else
setup_dotfiles
fi
}
# Configure text editors by copying the 'editorconfig.in' file to ~/.editorconfig
function write_editorconfig {
# Check list
INPUT=$(dirname "$0")'/data/config/editorconfig.in'
# Draw window
if (eval `resize` && whiptail \
--title "Configure Text editors" \
--yesno "Custom config file contains the following: \n\n$(while read LINE; do echo " "$LINE; done < $INPUT) \n\nOverwrite existing config?" \
$LINES $COLUMNS $(( $LINES - 12 )) \
--scrolltext) then
echo_message info "Overwriting ~/.editorconfig..."
# simply copy the list file to the aliases file
cp $INPUT ~/.editorconfig
echo_message success "Text editors successfully configured."
whiptail --title "Finished" --msgbox "Text editors successfully configured." 8 56
setup_dotfiles
else
setup_dotfiles
fi
}
# Install custom dotfiles
function setup_dotfiles {
NAME="System Configuration"
echo_message title "Starting ${NAME,,}..."
# Draw window
CONFIGURE=$(eval `resize` && whiptail \
--notags \
--title "$NAME" \
--menu "\nWhat would you like to do?" \
--cancel-button "Go Back" \
$LINES $COLUMNS $(( $LINES - 12 )) \
'write_profile' 'Configure environment variables' \
'write_bash_aliases' 'Set custom Bash aliases' \
'write_bashrc' 'Set custom Bash preferences' \
'write_editorconfig' 'Set custom editor config' \
3>&1 1>&2 2>&3)
# check exit status
if [ $? = 0 ]; then
echo_message header "Starting '$CONFIGURE' function"
$CONFIGURE
else
# Cancelled
echo_message info "$NAME cancelled."
main
fi
}