1 | #!/bin/bash |
2 |
|
3 | HELPTEXT="./install.sh <desktop|laptop|headless>" |
4 | case $1 in |
5 | h|help|\?|-h|-help|-\?|--h|--help|--\?) |
6 | echo -e $HELPTEXT |
7 | exit 0 |
8 | ;; |
9 | desktop) |
10 | UNIT=DESKTOP |
11 | ;; |
12 | laptop) |
13 | UNIT=LAPTOP |
14 | ;; |
15 | headless) |
16 | UNIT=HEADLESS |
17 | ;; |
18 | *) |
19 | echo -e $HELPTEXT |
20 | exit 0 |
21 | ;; |
22 | esac |
23 |
|
24 | category(){ |
25 | echo -e " \e[1;37m$1\e[0m" |
26 | } |
27 |
|
28 | item(){ |
29 | echo -e " \e[0m$1\e[0m" |
30 | } |
31 |
|
32 | echo -e " \e[1;33mInstall type \e[1;35m$UNIT\e[0m" |
33 |
|
34 | SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" |
35 |
|
36 | # Bash config |
37 | category "Bash config" |
38 | item "~/.bash_aliases" |
39 | install $SCRIPT_DIR/.bash_aliases $HOME/.bash_aliases |
40 | item "~/.bashrc" |
41 | install $SCRIPT_DIR/.bashrc $HOME/.bashrc |
42 | item "~/.profile" |
43 | install $SCRIPT_DIR/.profile $HOME/.profile |
44 |
|
45 | # Misc config |
46 | category "Misc config" |
47 | item "~/.todo.cfg" |
48 | install $SCRIPT_DIR/.todo.cfg $HOME/.todo.cfg |
49 | if [ $UNIT == "LAPTOP" ]; then |
50 | item "~/.xprofile" |
51 | install $SCRIPT_DIR/.xprofile $HOME/.xprofile |
52 | fi |
53 | item "~/.xonshrc" |
54 | install $SCRIPT_DIR/.xonshrc $HOME/.xonshrc |
55 | item "~/.xonsh_aliases" |
56 | install $SCRIPT_DIR/.xonsh_aliases $HOME/.xonsh_aliases |
57 |
|
58 | category "Common folders" |
59 | item "~/src/" |
60 | SRCFOLDER=$HOME/src |
61 | mkdir -p $SRCFOLDER |
62 | item "~/.local/bin/" |
63 | LOCALBIN=$HOME/.local/bin |
64 | mkdir -p $LOCALBIN |
65 | item "~/.local/share/" |
66 | mkdir -p $HOME/.local/share |
67 |
|
68 | # Local scripts |
69 | category "Local scripts" |
70 | if [ $UNIT == "DESKTOP" ] && [ $(whoami) != "root" ]; then |
71 | item "~/.local/bin/middle-mouse-scroll" |
72 | install $SCRIPT_DIR/middle-mouse-scroll $LOCALBIN/middle-mouse-scroll |
73 | fi |
74 |
|
75 | if ! command -v minesweeper &> /dev/null |
76 | then |
77 | if [ $(whoami) == "root" ]; then |
78 | item "/usr/local/bin/minesweeper" |
79 | else |
80 | item "~/.local/bin/minesweeper" |
81 | fi |
82 | git clone --depth=1 git://joshstock.in/ncurses-minesweeper.git $SRCFOLDER/ncurses-minesweeper |
83 | cd $SRCFOLDER/ncurses-minesweeper |
84 | make compile build |
85 | if [ $(whoami) == "root" ]; then |
86 | install bin/minesweeper /usr/local/bin/minesweeper |
87 | else |
88 | install bin/minesweeper $LOCALBIN/minesweeper |
89 | fi |
90 | rm -rf $SRCFOLDER/ncurses-minesweeper |
91 | cd $SCRIPT_DIR |
92 | fi |
93 |
|
94 | if [ $UNIT == "DESKTOP" ] || [ $UNIT == "LAPTOP" ]; then |
95 | # GTK config |
96 | category "GTK config" |
97 |
|
98 | GTKDIR=$HOME/.config/gtk-3.0 |
99 | item "~/.config/gtk-3.0/" |
100 | mkdir -p $GTKDIR |
101 |
|
102 | item "~/.config/gtk-3.0/gtk.css" |
103 | install $SCRIPT_DIR/gtk.css $GTKDIR/gtk.css |
104 |
|
105 | item "Terminal theme 'Oceanic Next'" |
106 | $SCRIPT_DIR/terminal_theme.sh $1 &>/dev/null |
107 |
|
108 | if [ $(whoami) == "root" ]; then |
109 | # Fonts |
110 | category "Fonts" |
111 | FONTDIR=/usr/share/fonts |
112 |
|
113 | item "Fira Sans pack" |
114 | if [ ! -f $FONTDIR/FiraSans-Regular.ttf ]; then |
115 | curl -fLso /tmp/Fira.zip https://fonts.google.com/download?family=Fira%20Sans |
116 | unzip -q /tmp/Fira.zip -d $FONTDIR |
117 | fi |
118 |
|
119 | item "Fira Mono (Nerd Fonts) pack" |
120 | if [ ! -f $FONTDIR/FiraMono-Regular.otf ]; then |
121 | curl -fLso $FONTDIR/FiraMono-Regular.otf https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/FiraMono/Regular/complete/Fura%20Mono%20Regular%20Nerd%20Font%20Complete%20Mono.otf |
122 | fi |
123 | if [ ! -f $FONTDIR/FiraMono-Medium.otf ]; then |
124 | curl -fLso $FONTDIR/FiraMono-Medium.otf https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/FiraMono/Medium/complete/Fura%20Mono%20Medium%20Nerd%20Font%20Complete%20Mono.otf |
125 | fi |
126 | if [ ! -f $FONTDIR/FiraMono-Bold.otf ]; then |
127 | curl -fLso $FONTDIR/FiraMono-Bold.otf https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/FiraMono/Bold/complete/Fura%20Mono%20Bold%20Nerd%20Font%20Complete%20Mono.otf |
128 | fi |
129 |
|
130 | item "Refreshing font cache" |
131 | fc-cache |
132 | fi |
133 | fi |
134 |
|
135 | # Global git config |
136 | category "Global git config" |
137 |
|
138 | if [ $(whoami) == "root" ]; then |
139 | item "/etc/gitconfig" |
140 | install $SCRIPT_DIR/.gitconfig /etc/gitconfig |
141 | else |
142 | item "~/.gitconfig" |
143 | install $SCRIPT_DIR/.gitconfig $HOME/.gitconfig |
144 | fi |
145 |
|
146 | # Vim |
147 | category "Vim config" |
148 |
|
149 | if [ $UNIT == "HEADLESS" ]; then |
150 | if [ $(whoami) == "root" ]; then |
151 | item "/usr/share/vim/" |
152 | VIMDIR=/usr/share/vim |
153 | mkdir -p $VIMDIR |
154 | item "/usr/share/vim/vimrc" |
155 | grep -v "RMHEADLESS" vimrc > $SCRIPT_DIR/.vimrc_headless |
156 | install $SCRIPT_DIR/.vimrc_headless $VIMDIR/vimrc |
157 | VIMRUNTIME=`vim -e -T dumb --cmd 'exe "set t_cm=\<C-M>"|echo $VIMRUNTIME|quit' | tr -d '\015' ` |
158 | item "$VIMRUNTIME/autoload/plug.vim" |
159 | if [ ! -f $VIMRUNTIME/autoload/plug.vim ]; then |
160 | curl -fLso $VIMRUNTIME/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |
161 | fi |
162 | fi |
163 | else |
164 | item "~/.vim/" |
165 | VIMDIR=$HOME/.vim |
166 | mkdir -p $VIMDIR |
167 | item "~/.vim/vimrc" |
168 | install $SCRIPT_DIR/vimrc $VIMDIR/vimrc |
169 | item "~/.vim/autoload/plug.vim" |
170 | if [ ! -f $VIMDIR/autoload/plug.vim ]; then |
171 | curl -fLso $VIMDIR/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |
172 | fi |
173 | fi |
174 |
|
175 | # Done |
176 | echo -e " \e[1;33mDONE\e[0m" |
177 |
|