-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_new_home.zsh
executable file
·164 lines (147 loc) · 4.26 KB
/
setup_new_home.zsh
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
#!/bin/zsh
#
cd $HOME
IS_UPDATE=
if [ -d .local/_scripts ]; then
IS_UPDATE=1
fi
if [ -z "$IS_UPDATE" ]; then
echo
echo "This script will initialize your home directory $HOME according to my preferences."
echo
echo "That is:"
echo " * .local/ is heavily used. Especially, .local/bin is used as a per-user \$PATH."
echo " * .vim/ is initialized with my vim repository and .vimrc is placed in \$HOME"
echo " * .config/nvim is initialized with my nvim repository"
echo " * .zshrc is linked to the version from this repository. Local changes should go into"
echo " your .zsh directory, into an executable file in .zsh/scripts/"
echo " * The binaries from this repository will be placed into .local/bin/"
echo
echo "Continue? (C-c to stop, anything to continue)"
read YES
fi
if grep -q pberndt .ssh/id_rsa.pub >/dev/null 2>&1 && git ls-remote [email protected]:phillipberndt/scripts 2>&1 > /dev/null; then
echo "Cloning using r/w SSH connection ..."
[email protected]:phillipberndt/
else
echo "Cloning using read-only git connection ..."
CLONE_BASE=git://github.com/phillipberndt/
fi
# Clone scripts directory
[ -d .local ] || mkdir .local
cd .local
if [ -d _scripts ]; then
cd _scripts
git pull
cd ..
else
git clone ${CLONE_BASE}scripts.git _scripts
fi
# Initialize submodules
cd _scripts
git submodule init
git submodule update --init
cd ..
# Install fonts and colors
./_scripts/setup_gui_fontsandcolors.sh
# Link binaries
[ -d bin ] || mkdir bin
cd bin
for BINARY in gdo/gdo passwrd/passwrd.py unpack/unpack pydoce/pydoce on/on.py pskill/pskill.py sshproxy/sshp.py paxel/paxel.py emoji/emoji.py errno/errno cache/cache ipatch/ipatch; do
[ -e ${BINARY:t:r} ] || ln -s ../_scripts/$BINARY ${BINARY:t:r}
done
cd ..
# Initialize Python environment
pip3 install --user -U ipython requests flask jedi pexpect psutil "python-lsp-server[all]"
# Initialize zsh
cd $HOME
if [ -z "$IS_UPDATE" ]; then
[ -e .zshrc ] && mv .zshrc zshrc-old
[ -d .zsh ] && mv .zsh zsh-old
mkdir .zsh
cd .zsh
ln -s ../.local/_scripts/zshrc/{site,zshrc,zgen,p10k.zsh} .
mkdir scripts
ln -s ../.local/_scripts/zshrc/scripts/* scripts/
cd ..
ln -s .zsh/zshrc .zshrc
ln -s .zsh/p10k.zsh .p10k.zsh
source .zshrc
else
cd .zsh
for FILE in ../.local/_scripts/zshrc/scripts/*; do
[ -e scripts/${FILE:t} ] || ln -s $FILE scripts/
done
cd ..
fi
# Other dotfiles
for FILE in .local/_scripts/dotfiles/*; do
[ -e .${FILE:t} ] || ln -s $FILE .${FILE:t}
done
# Initialize vim
if [ -z "$IS_UPDATE" ]; then
[ -e .vimrc ] && mv .vimrc vimrc-old
git clone ${CLONE_BASE}vimconfig .vim
ln -s .vim/vimrc .vimrc
cd .vim
./init-after-clone.sh
cd ..
else
cd .vim
git pull
git submodule update --init
cd ..
fi
# Initialize neovim
if [ -d ~/.config/nvim ]; then
git -C ~/.config/nvim pull
else
git clone ${CLONE_BASE}nvimconfig ~/.config/nvim
fi
# Initialize or update fzf
cd .local
mkdir -p tmp
cd tmp
version=$(wget -qO - https://github.com/junegunn/fzf/releases | grep -oE 'fzf-[^"]+-linux_amd64.tar.gz' | cut -d- -f2 | head -n1)
wget -O fzf https://github.com/junegunn/fzf/releases/download/v$version/fzf-$version-linux_amd64.tar.gz
tar xzf fzf
mv -f fzf ../bin
cd ..
rm -rf tmp
cd ..
wget -O ~/.zsh/scripts/fzf.zsh https://raw.githubusercontent.com/junegunn/fzf/master/shell/key-bindings.zsh
# Initialize or update iwebd
cd .local
mkdir -p tmp
cd tmp
version=$(wget -qO - https://github.com/phillipberndt/iwebd/releases | grep -oE '/tag/v[0-9.]{5,}' | cut -d/ -f3 | head -n1)
wget -O iwebd https://github.com/phillipberndt/iwebd/releases/download/$version/iwebd-$version-linux-amd64.tar.gz
tar xzf iwebd
mv -f iwebd ../bin
cd ..
rm -rf tmp
cd ..
# Initialize or update lf
cd .local
mkdir -p tmp
cd tmp
version=$(wget -qO - https://github.com/gokcehan/lf/releases | grep -oE '/r[0-9]+/' | head -n1)
wget -O lf https://github.com/gokcehan/lf/releases/download/$version/lf-linux-amd64.tar.gz
tar xzf lf
mv -f lf ../bin
cd ..
rm -rf tmp
cd ..
# Initialize or update neovim
cd .local
mkdir -p tmp
cd tmp
version=$(wget -qO - https://github.com/neovim/neovim/releases | grep -oE '/v[0-9.]+/' | head -n1)
wget -O nvim https://github.com/neovim/neovim/releases/download/$version/nvim-linux64.tar.gz
tar xzf nvim
[ -d ../_apps ] || mkdir ../_apps
mv -f nvim-linux64 ../_apps/
cd ..
rm -rf tmp
ln -s ../_apps/nvim-linux64/bin/nvim bin/nvim
cd ..