-
Notifications
You must be signed in to change notification settings - Fork 3
/
install
executable file
·184 lines (120 loc) · 4.71 KB
/
install
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/bin/bash
clear
if [ `id -u` != 0 ]; then
echo -e '\033[1;31mYou need to be root to perform this action.\033[0m\n'
exit 1
fi
if [ ! `which dialog` ]; then
apt-get install -y dialog
fi
TITLE="Magno's dotfiles"
USER_NAME=$SUDO_USER
USER_HOME=/home/$USER_NAME
FILES=".bash_aliases .bash_functions .editorconfig .gitconfig .gitignore .gitmessage .iftoprc .htoprc .vimrc .npmrc diff.py"
source utils
function fixPrivacy {
gsettings set com.canonical.Unity.Lenses remote-content-search none
gsettings set com.canonical.Unity.Lenses disabled-scopes "['more_suggestions-amazon.scope', 'more_suggestions-u1ms.scope', 'more_suggestions-populartracks.scope', 'music-musicstore.scope', 'more_suggestions-ebay.scope', 'more_suggestions-ubuntushop.scope', 'more_suggestions-skimlinks.scope']"
if ! grep -q productsearch.ubuntu.com /etc/hosts; then
echo -e "\n127.0.0.1 productsearch.ubuntu.com" | tee -a /etc/hosts >/dev/null
fi
}
function clearHistory {
history -c && history -w
cat /dev/null > $USER_HOME/.bash_history
}
function resetBashrc {
cp $USER_HOME/.bashrc $USER_HOME/bashrc.bak
cp /etc/skel/.bashrc $USER_HOME/.bashrc
}
function defaultPS1WithGit {
uncomment $USER_HOME/.bashrc 46
comment $USER_HOME/.bashrc 60
addline $USER_HOME/.bashrc 61 ' PS1="\${debian_chroot:+(\$debian_chroot)}\\\[\\\033[01;32m\\\]\\\u@\\\h\\\[\\\033[00m\\\]:\\\[\\\033[01;34m\\\]\\\w\\\[\\\033[00m\\\]\\\[\\\033[31m\\\]\\\$(__git_ps1 [%s])\\\[\\\033[0m\\\]\\\$ "'
}
function alternativePS1WithGit {
uncomment $USER_HOME/.bashrc 46
comment $USER_HOME/.bashrc 60
addline $USER_HOME/.bashrc 61 ' PS1="\${debian_chroot:+(\$debian_chroot)}\\\[\\\e[1;36m\\\]\\\u \\\[\\\e[1;37m\\\]at \\\[\\\e[1;33m\\\]\\\h \\\[\\\e[1;37m\\\]in \\\[\\\e[1;32m\\\]\\\w \\\$(prompt_git \\\"\\\[\\\e[1;37m\\\]on \\\[\\\e[1;35m\\\]\\\" \\\"\\\[\\\e[1;34m\\\]\\\")\\\[\\\e[0m\\\]\\n\\\$ "'
}
function addBashFunctions {
echo "
# Functions definitions.
if [ -f ~/.bash_functions ]; then
. ~/.bash_functions
fi" >> $USER_HOME/.bashrc
}
function completionIgnoreCase {
if [ ! -a $USER_HOME/.inputrc ]; then
echo "\$include /etc/inputrc" > $USER_HOME/.inputrc
fi
echo "set completion-ignore-case On" >> $USER_HOME/.inputrc
}
function copyDotfiles {
mkdir -p $USER_HOME/.config/terminator/
cp .config/terminator/config $USER_HOME/.config/terminator/config
chown $USER_NAME:$USER_NAME $USER_HOME/.config/terminator/config
for f in $FILES; do
cp $f $USER_HOME/$f
chown $USER_NAME:$USER_NAME $USER_HOME/$f
done
addBashFunctions
}
function updateSystem {
clear
apt-get update
apt-get upgrade -y
apt-get -f install -y
}
function configTimeZone {
dpkg-reconfigure tzdata
}
function blacklistedMediaPlayers {
if [ ! `which dconf-editor` ]; then
apt-get install -y dconf-editor
fi
gsettings set com.canonical.indicator.sound blacklisted-media-players "['rhythmbox']"
gsettings set com.canonical.indicator.sound interested-media-players "['spotify.desktop', 'vlc']"
}
function generateSSHKey {
su -c "ssh-keygen -t rsa -b 4096" -s /bin/sh $USER_NAME
}
function hostsBlacklist {
if ! grep -q "# Block " /etc/hosts; then
curl -L https://git.io/fhhIX | tee -a /etc/hosts >/dev/null
fi
}
# DIALOG #######################################################################
cmd=(dialog --backtitle "$TITLE" --separate-output --checklist "Select" 16 46 9)
options=(
01 "Fix Privacy" on
02 "Reset .bashrc" on
03 "Default PS1 with Git" off
04 "Alternative PS1 with Git extras" on
05 "Copy dotfiles" on
06 "Set completion ignore case" on
07 "Configure TimeZone" off
08 "Generate SSH key" on
09 "Fix media players indicator" off
10 "Block Microsoft Telemetry, Skype advertising, and Facebook" on
11 "Update system" off
)
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
for choice in $choices; do
case $choice in
01) fixPrivacy ;;
02) resetBashrc ;;
03) defaultPS1WithGit ;;
04) alternativePS1WithGit ;;
05) copyDotfiles ;;
06) completionIgnoreCase ;;
07) configTimeZone ;;
08) generateSSHKey ;;
09) blacklistedMediaPlayers ;;
10) hostsBlacklist ;;
11) updateSystem ;;
esac
done
clearHistory
dialog --backtitle "$TITLE" --msgbox "Your dotfiles were installed o/" 15 46
clear