~cyplo/dotfiles

ref: 88207f1d3672730a3533a0e886d2441411d98f1b dotfiles/common/configure_fresh_system.sh -rwxr-xr-x 6.0 KiB
88207f1d — Cyryl Płotnicki Make sure Vim is installed on Fedora when installing everythin from scratch 2 years ago
                                                                                
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#!/bin/bash
set -e
set -o pipefail

SUDO=""
if [[ -z $NOSUDO ]]; then
    SUDO="sudo"
fi

echo
echo "configuring settings common among OSes"
echo "using '$SUDO' as sudo"
$SUDO true

echo "linking and sourcing env"
ln -vfs "$DIR/.setenv.sh" ~/.setenv
source ~/.setenv

#zsh
if [[ -z $DONT_CHANGE_SHELL ]]; then
    echo "changing shell to zsh"
    chsh -s `which zsh` $USER
fi

CURL="curl -sSfL"

if [[ -z $DIR ]]; then
    echo "please set DIR"
    exit 1
fi

DIR=`realpath $DIR`
echo "using $DIR as the top level directory"
cd $DIR
git submodule update --init --recursive

#configs
ln -vfs "$DIR/.vim" ~/.
ln -vfs "$DIR/.ideavimrc" ~/.
ln -vfs "$DIR/.vimrc" ~/.vimrc
ln -vfs "$DIR/rvmrc" ~/.rvmrc
ln -vfs "$DIR/.tmux.conf" ~/.
ln -vfs "$DIR/.tmux.macosx" ~/.
rm -f "~/.zshrc"
ln -vfs "$DIR/.zprezto" ~/.
ln -vfs "$DIR/.zpreztorc" ~/.zpreztorc
ln -vfs "$DIR/.zprofile" ~/.zprofile
ln -vfs "$DIR/.zprezto/runcoms/zshenv" ~/.zshenv
ln -vfs "$DIR/.zshrc" ~/.zshrc
ln -vfs "$DIR/.hyper.js" ~/.hyper.js
ln -vfs "$DIR/.hyper_plugins" ~/.hyper_plugins

ln -vfs "$DIR/.Slic3r" ~/.
ln -vfs "$DIR/.ghci" ~/.
ln -vfs "$DIR/.conkyrc" ~/.
mkdir -p ~/.kde/share/config/
ln -vfs "$DIR/.kdiff3rc" ~/.kde/share/config/kdiff3rc
ln -vfs "$DIR/.gitconfig.linux.private" ~/.gitconfig
mkdir -p ~/.config/autostart/
# autostart apps
mkdir -p ~/.config/vdirsyncer/
ln -vfs "$DIR/.config/vdirsyncer/config" ~/.config/vdirsyncer/
mkdir -p ~/.config/Code/User
ln -vfs "$DIR/.config/Code/User/settings.json" ~/.config/Code/User/settings.json
ln -vfs "$DIR/.config/Code/User/keybindings.json" ~/.config/Code/User/keybindings.json
mkdir -p ~/.local/share/applications
cp -v "$DIR/keeweb.desktop" ~/.local/share/applications/
ln -vfs "$DIR/tools" ~/
mkdir -vp ~/.config/terminator
rm -f ~/.config/terminator/config
ln "$DIR/.config/terminator/config" ~/.config/terminator/config
mkdir -p ~/.cargo/
echo "all links done"

echo "adding GDB dashboard"
wget -P ~ git.io/.gdbinit

echo "adding NVM"
mkdir -p "$NVM_DIR"
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash

echo "using NVM"
set +e
\. "$NVM_DIR/nvm.sh"
set -e
nvm install node
nvm use node

#install fonts
echo "installing fonts"
mkdir -p ~/.fonts
cp -rv "$DIR/fonts" ~/.fonts
set +e
fc-cache -rv
$SUDO fc-cache -rv
set -e

if [[ -z $NOVIM ]]; then
    source "$DIR/common/install_vim_from_sources.sh"
fi

if [[ -z $NORUST ]]; then
    #rust
    echo "installing rust"
    RUSTUP_TEMP="/tmp/blastoff.sh"
    $CURL https://sh.rustup.rs > "$RUSTUP_TEMP"
    chmod a+x "$RUSTUP_TEMP"
    "$RUSTUP_TEMP" -y
    rm -f "$RUSTUP_TEMP"

    set +e
    rustup update
    set -e
    rustup install stable
    set +e
    rustup install nightly
    set -e
    rustup default stable

    rustup component add rls --toolchain stable
    rustup component add clippy --toolchain stable
    rustup component add rustfmt --toolchain stable
    rustup component add rust-analysis --toolchain stable
    rustup component add rust-src --toolchain stable

    set +e
    rustup component add rls --toolchain nightly
    rustup component add clippy --toolchain nightly
    rustup component add rustfmt --toolchain nightly
    rustup component add rust-analysis --toolchain nightly
    rustup component add rust-src --toolchain nightly
    set -e

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

    (test -x "${HOME}/.cargo/bin/cargo-install-update" || cargo install cargo-update)
    (test -x "${HOME}/.cargo/bin/rg" || cargo install ripgrep)
    (test -x "${HOME}/.cargo/bin/fd" || cargo install fd-find)
    (test -x "${HOME}/.cargo/bin/genpass" || cargo install genpass)

    set +e
    cargo install-update -a
    set -e
    rustup run nightly cargo install-update -a
fi

set +e
echo "Querying for gpg2 path"
gpg2_path=`which gpg2`
echo "Got $gpg2_path for gpg2 path"
set -e
if [[ -x "$gpg2_path" ]]; then
    echo "Using gpg2"
    GPG=gpg2
else
    echo "WARNING using gpg instead of gpg2"
    GPG=gpg
fi

echo "Getting GPG keys.."
for key in \
    409B6B1796C275462A1703113804BB82D39DC0E3 \
    7D2BAF1CF37B13E2069D6956105BD0E739499BDB
do 
    $GPG --keyserver hkp://keys.gnupg.net --recv-keys "$key" || \
    $GPG --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \
    $GPG --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
    $GPG --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" \
    ;
done

if [[ -z $NORUBY ]]; then
    echo "Downloading RVM..."
    $CURL https://get.rvm.io | bash
    set +e
    echo "Sourcing RVM..."
    source /usr/local/rvm/scripts/rvm
    source ~/.rvm/scripts/rvm
    set -e
    echo "Installing Ruby..."
    rvm install ruby --disable-binary
fi

if [[ -z $NOVIM ]]; then
    if [[ ! -d ~/.fzf ]]; then
        git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
    else
        cd ~/.fzf
        git pull
        git submodule update --init --recursive
    fi
    if [[ -z $NO_GO ]]; then
        echo "Installing fzf"
        ~/.fzf/install --64 --all
    fi
    echo "Installing Vim plugins"
    echo "\n" | vim +PlugClean! +qa
    echo "\n" | vim +PlugInstall! +qa
fi

if [[ -z $NO_GO ]]; then
    GOPATH="$HOME/go"
    export GOPATH=`realpath "$GOPATH"`
    mkdir -p "$GOPATH"

    # excercism
    go get -u github.com/exercism/cli/exercism
fi

nvm use node
npm install -g reveal-md
npm install -g diff-so-fancy
npm install -g cssnano

if [[ -z $NOPYTHON3 ]]; then
    set +e
    pip3_path=`which pip3`
    set -e
    echo "pip3 path is $pip3_path"
    if [[ -x "$pip3_path" ]]; then
        echo "Choosing pip3 for pip"
        PIP=pip3
    else
        echo "Choosing pip"
        PIP=pip
    fi
    echo "Upgrading pip"
    set +e
    $SUDO $PIP install --upgrade pip setuptools
    $SUDO $PIP install --upgrade packaging
    set -e
    echo "Installing Nikola"
    $SUDO $PIP install --upgrade pygments-style-solarized ws4py watchdog webassets Nikola aiohttp
    echo "Installing vim dependencies"
    $SUDO $PIP install neovim
fi

if [[ -z $USER ]]; then
    USER=`whoami`
fi

# normalize npm permissions
mkdir -p $HOME/.npm
$SUDO chown -R $USER $HOME/.npm

echo
echo "now go ahead and restart"
echo