-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·154 lines (141 loc) · 4.88 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
#!/usr/bin/env bash
# __ __ _ _ ____ _____ ____ ____ ____ __ ____ ___
# ( \/ )( \/ ) ( _ \( _ )(_ _)( ___)(_ _)( ) ( ___)/ __)
# ) ( \ / )(_) ))(_)( )( )__) _)(_ )(__ )__) \__ \
# (_/\/\_) (__) (____/(_____) (__) (__) (____)(____)(____)(___/
# linking and installation
# usage: ./install [folder-name]
# linking and download helper
ln_i() {
if [ $# -gt 2 ]; then
if [ ! -d "${*: -1}" ]; then
echo "${*: -1} is not a dictionary"
exit 1
fi
for i in "${@:1:(${#@})-1}"; do
o="${*: -1}/$(basename "$i")"
if [ ! "$i" -ef "$o" ]; then
[ -e "$o" ] && git diff --no-index "$o" "$i"
ln -i "$i" "$o"
fi
done
elif [ ! -d "$2" ] && [ ! "$1" -ef "$2" ]; then
[ -e "$2" ] && git diff --no-index "$2" "$1"
ln -i "$1" "$2"
elif [ -d "$2" ] && [ ! "$1" -ef "$2/$(basename "$1")" ]; then
if [ -e "$2/$(basename "$1")" ]; then
git diff --no-index "$2/$(basename "$1")" "$1"
fi
ln -i "$1" "$2"
fi
}
dl_e() {
if [ -d "$2" ]; then
out="$2/$(basename "$1")"
else
out="$2"
fi
if [ ! -e "$out" ]; then
curl -fLo "$out" "$1"
fi
}
base="$(dirname "$0")"
config="${XDG_CONFIG_HOME:-$HOME/.config}"
data="${XDG_DATA_HOME:-$HOME/.local/share}"
gh="https://raw.githubusercontent.com"
if [ -z "$1" ] || [ "$1" = "neovim" ]; then
mkdir -p "$config"/nvim "$data"/nvim/site/autoload
ln_i "$base"/neovim/* "$config"/nvim
# install vim-plug
dl_e $gh/junegunn/vim-plug/master/plug.vim "$data"/nvim/site/autoload
# install plugins
nvim -c "let g:plug_threads = 3|PlugInstall|qa!"
fi
if [ -z "$1" ] || [ "$1" = "zsh" ]; then
mkdir -p ~/.zsh/{functions,.zim}
ln_i "$base"/zsh/zlogin ~/.zlogin
ln_i "$base"/zsh/zshenv ~/.zshenv
ln_i "$base"/zsh/zimrc ~/.zsh/.zimrc
ln_i "$base"/zsh/zshrc ~/.zsh/.zshrc
ln_i "$base"/zsh/zprofile ~/.zsh/.zprofile
ln_i "$base"/zsh/{prompt,aliases}.zsh ~/.zsh
ln_i "$base"/zsh/functions/* ~/.zsh/functions
ln_i "$base"/zsh/theme-{dark,light}.ini ~/.zsh
# move zhistory to new zsh dotdir
if [ -e ~/.zhistory ] && [ ! -e ~/.zsh/.zhistory ]; then
mv ~/.zhistory ~/.zsh
fi
# install zim
dl_e https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh ~/.zsh/.zim
zsh ~/.zsh/.zim/zimfw.zsh install
zsh -i -c "fast-theme ~/.zsh/theme-light"
# make zsh the default shell
[ "$SHELL" = "/bin/zsh" ] || chsh -s /bin/zsh
fi
if [ -z "$1" ] || [ "$1" = "i3wm" ]; then
mkdir -p "$config"/i3/i3ipc
ln_i "$base"/i3wm/* "$config"/i3
# install i3ipc
dl_e $gh/acrisci/i3ipc-python/master/i3ipc/i3ipc.py "$config"/i3/i3ipc
dl_e $gh/acrisci/i3ipc-python/master/i3ipc/__init__.py "$config"/i3/i3ipc
# reload i3
i3-msg reload > /dev/null
fi
if [ -z "$1" ] || [ "$1" = "x11" ]; then
ln_i "$base"/x11/xinitrc ~/.xinitrc
ln_i "$base"/x11/Xmodmap ~/.Xmodmap
fi
if [ -z "$1" ] || [ "$1" = "ranger" ]; then
mkdir -p "$config"/ranger/plugins
ln_i "$base"/ranger/* "$config"/ranger
# install devicon plugin
repo=$gh/alexanderjeurissen/ranger_devicons
dl_e $repo/master/devicons.py "$config"/ranger
dl_e $repo/master/devicons_linemode.py "$config"/ranger/plugins
fi
if [ -z "$1" ] || [ "$1" = "urxvt" ]; then
mkdir -p ~/.urxvt/ext ~/.local/share/fonts
ln_i "$base"/urxvt/lightresources ~/.Xresources
# install font-size extention
dl_e $gh/majutsushi/urxvt-font-size/master/font-size ~/.urxvt/ext
repo="$gh/ryanoasis/nerd-fonts/master/patched-fonts/Hack"
# install fonts
dl_e $gh/kencrocken/FiraCodeiScript/master/FiraCodeiScript-Italic.ttf \
~/.local/share/fonts
dl_e $repo/Regular/complete/Hack%20Regular%20Nerd%20Font%20Complete%20Mono.ttf \
~/.local/share/fonts
dl_e $repo/Italic/complete/Hack%20Italic%20Nerd%20Font%20Complete%20Mono.ttf \
~/.local/share/fonts
dl_e $repo/Bold/complete/Hack%20Bold%20Nerd%20Font%20Complete%20Mono.ttf \
~/.local/share/fonts
dl_e $repo/BoldItalic/complete/Hack%20Bold%20Italic%20Nerd%20Font%20Complete%20Mono.ttf \
~/.local/share/fonts
# update font cache
fc-cache
# load xresources
xrdb ~/.Xresources
fi
if [ -z "$1" ] || [ "$1" = "mpv" ]; then
mkdir -p "$config"/mpv/{scripts,lua-settings}
ln_i "$base"/mpv/{mpv,input}.conf "$config"/mpv
ln_i "$base"/mpv/osc.conf "$config"/mpv/lua-settings
# install autoload script
dl_e $gh/4e6/mpv-reload/master/reload.lua "$config"/mpv/scripts
dl_e $gh/mpv-player/mpv/master/TOOLS/lua/autoload.lua "$config"/mpv/scripts
fi
if [ -z "$1" ] || [ "$1" = "dunst" ]; then
mkdir -p "$config"/dunst
ln_i "$base"/dunst/* "$config"/dunst
fi
if [ -z "$1" ] || [ "$1" = "tmux" ]; then
mkdir -p ~/
ln_i "$base"/tmux/tmux.conf ~/.tmux.conf
fi
if [ -z "$1" ] || [ "$1" = "git" ]; then
ln_i "$base"/git/gitconfig ~/.gitconfig
ln_i "$base"/git/gitconfig-work ~/.gitconfig-work
fi
if [ -z "$1" ] || [ "$1" = "mise" ]; then
mkdir -p ~/.config/mise
ln_i "$base"/mise/config.toml ~/.config/mise/config.toml
fi