-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·86 lines (69 loc) · 1.9 KB
/
install
File metadata and controls
executable file
·86 lines (69 loc) · 1.9 KB
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
#!/usr/bin/env zsh
info() {
printf "\e[39m$1\e[0m"
}
error() {
printf "\e[1;31m$1\e[0m"
}
warning() {
printf "\e[1;33m$1\e[0m"
}
path() {
printf "\e[4m$1\e[24m"
}
make_symlink() {
declare -r dir=$(cd $(dirname $0) && pwd)/config
declare -r source=$dir/$1
declare -r target=$2
if [[ ! -L $target && -d $target ]]; then
error "$(path $target) is directory.\n"
return
fi
if [[ -L $target || -f $target ]]; then
warning "$(path $target) already exists. overwrite? (y/N): "
if ! read -q; then
info "\n"
return
fi
info "\n"
unlink $target
fi
ln -s $source $target && info "Create symblic link: $(path $source) -> $(path $target)\n"
}
install_dotfiels() {
make_symlink zsh/.zshenv $HOME/.zshenv
source $HOME/.zshenv
mkdir -p $XDG_CONFIG_HOME
mkdir -p $XDG_CACHE_HOME
mkdir -p $XDG_CONFIG_HOME
make_symlink zsh $ZDOTDIR
make_symlink git $XDG_CONFIG_HOME/git
make_symlink gh $XDG_CONFIG_HOME/gh
make_symlink nvim $XDG_CONFIG_HOME/nvim
make_symlink fd $XDG_CONFIG_HOME/fd
make_symlink ripgrep $XDG_CONFIG_HOME/ripgrep
make_symlink bat $XDG_CONFIG_HOME/bat
make_symlink tmux $XDG_CONFIG_HOME/tmux
make_symlink npm $XDG_CONFIG_HOME/npm
make_symlink alacritty $XDG_CONFIG_HOME/alacritty
make_symlink lsyncd $XDG_CONFIG_HOME/lsyncd
make_symlink autohotkey $XDG_CONFIG_HOME/autohotkey
make_symlink systemd/user $XDG_CONFIG_HOME/systemd/user
make_symlink srcurl $XDG_CONFIG_HOME/srcurl
}
install_plugin_managers() {
declare -r github_repo=$1
declare -r install_dir=$2
if [[ -d $2 ]]; then
error "$(path $install_dir) already exists.\n"
return
fi
info "Installing $github_repo\n"
git clone --depth=1 https://github.com/$github_repo $install_dir
info "Done\n"
}
info ">>> Installing dotfiles\n"
install_dotfiels
info "\n"
info ">>> Installing plugin managers\n"
install_plugin_managers agkozak/zcomet $XDG_DATA_HOME/zcomet/bin