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 | item "~/.todo.cfg" |
45 | install $SCRIPT_DIR/.todo.cfg $HOME/.todo.cfg |
46 |
|
47 | category "Common folders" |
48 | item "~/src/" |
49 | SRCFOLDER=$HOME/src |
50 | mkdir -p $SRCFOLDER |
51 | item "~/.local/bin/" |
52 | LOCALBIN=$HOME/.local/bin |
53 | mkdir -p $LOCALBIN |
54 | item "~/.local/share/" |
55 | mkdir -p $HOME/.local/share |
56 |
|
57 | # Local scripts |
58 | category "Local scripts" |
59 | if [ $UNIT == "DESKTOP" ] && [ $(whoami) != "root" ]; then |
60 | item "~/.local/bin/middle-mouse-scroll" |
61 | install $SCRIPT_DIR/middle-mouse-scroll $LOCALBIN/middle-mouse-scroll |
62 | fi |
63 |
|
64 | if ! command -v minesweeper &> /dev/null |
65 | then |
66 | if [ $(whoami) == "root" ]; then |
67 | item "/usr/local/bin/minesweeper" |
68 | else |
69 | item "~/.local/bin/minesweeper" |
70 | fi |
71 | git clone --depth=1 git://joshstock.in/ncurses-minesweeper.git $SRCFOLDER/ncurses-minesweeper |
72 | cd $SRCFOLDER/ncurses-minesweeper |
73 | make compile build |
74 | if [ $(whoami) == "root" ]; then |
75 | install bin/minesweeper /usr/local/bin/minesweeper |
76 | else |
77 | install bin/minesweeper $LOCALBIN/minesweeper |
78 | fi |
79 | rm -rf $SRCFOLDER/ncurses-minesweeper |
80 | cd $SCRIPT_DIR |
81 | fi |
82 |
|
83 | if [ $UNIT == "DESKTOP" ] || [ $UNIT == "LAPTOP" ]; then |
84 | # GTK config |
85 | category "GTK config" |
86 |
|
87 | GTKDIR=$HOME/.config/gtk-3.0 |
88 | item "~/.config/gtk-3.0/" |
89 | mkdir -p $GTKDIR |
90 |
|
91 | item "~/.config/gtk-3.0/gtk.css" |
92 | install $SCRIPT_DIR/gtk.css $GTKDIR/gtk.css |
93 |
|
94 | item "Terminal theme 'Oceanic Next'" |
95 | $SCRIPT_DIR/terminal_theme.sh $1 &>/dev/null |
96 |
|
97 | if [ $(whoami) == "root" ]; then |
98 | # Fonts |
99 | category "Fonts" |
100 | FONTDIR=/usr/share/fonts |
101 |
|
102 | item "Fira Sans pack" |
103 | if [ ! -f $FONTDIR/FiraSans-Regular.ttf ]; then |
104 | curl -fLso /tmp/Fira.zip https://fonts.google.com/download?family=Fira%20Sans |
105 | unzip -q /tmp/Fira.zip -d $FONTDIR |
106 | fi |
107 |
|
108 | item "Fira Mono (Nerd Fonts) pack" |
109 | if [ ! -f $FONTDIR/FiraMono-Regular.otf ]; then |
110 | 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 |
111 | fi |
112 | if [ ! -f $FONTDIR/FiraMono-Medium.otf ]; then |
113 | 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 |
114 | fi |
115 | if [ ! -f $FONTDIR/FiraMono-Bold.otf ]; then |
116 | 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 |
117 | fi |
118 |
|
119 | item "Refreshing font cache" |
120 | fc-cache |
121 | fi |
122 | fi |
123 |
|
124 | # Global git config |
125 | category "Global git config" |
126 |
|
127 | if [ $(whoami) == "root" ]; then |
128 | item "/etc/gitconfig" |
129 | install $SCRIPT_DIR/.gitconfig /etc/gitconfig |
130 | else |
131 | item "~/.gitconfig" |
132 | install $SCRIPT_DIR/.gitconfig $HOME/.gitconfig |
133 | fi |
134 |
|
135 | # Vim |
136 | category "Vim config" |
137 |
|
138 | if [ $UNIT == "HEADLESS" ]; then |
139 | if [ $(whoami) == "root" ]; then |
140 | item "/usr/share/vim/" |
141 | VIMDIR=/usr/share/vim |
142 | mkdir -p $VIMDIR |
143 | item "/usr/share/vim/vimrc" |
144 | grep -v "RMHEADLESS" vimrc > $SCRIPT_DIR/.vimrc_headless |
145 | install $SCRIPT_DIR/.vimrc_headless $VIMDIR/vimrc |
146 | VIMRUNTIME=`vim -e -T dumb --cmd 'exe "set t_cm=\<C-M>"|echo $VIMRUNTIME|quit' | tr -d '\015' ` |
147 | item "$VIMRUNTIME/autoload/plug.vim" |
148 | if [ ! -f $VIMRUNTIME/autoload/plug.vim ]; then |
149 | curl -fLso $VIMRUNTIME/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |
150 | fi |
151 | fi |
152 | else |
153 | item "~/.vim/" |
154 | VIMDIR=$HOME/.vim |
155 | mkdir -p $VIMDIR |
156 | item "~/.vim/vimrc" |
157 | install $SCRIPT_DIR/vimrc $VIMDIR/vimrc |
158 | item "~/.vim/autoload/plug.vim" |
159 | if [ ! -f $VIMDIR/autoload/plug.vim ]; then |
160 | curl -fLso $VIMDIR/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |
161 | fi |
162 | fi |
163 |
|
164 | # Done |
165 | echo -e " \e[1;33mDONE\e[0m" |
166 |
|