-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·105 lines (80 loc) · 2.32 KB
/
setup
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
#!/bin/bash
cd "$(dirname "$0")" || exit 1
### REQUIRED VARS
if [ -z "$XDG_CONFIG_HOME" ]; then
export XDG_CONFIG_HOME="$HOME/.config"
fi
if [ -z "$XDG_DATA_HOME" ]; then
export XDG_DATA_HOME="$HOME/.local/share"
fi
if [ -z "$XDG_CACHE_HOME" ]; then
export XDG_CACHE_HOME="$HOME/.cache"
fi
### HELPERS
# symlink $source $destination
function symlink {
local source
source="$(realpath "$1")"
if ! [[ -f "$source" || -d "$source" ]]; then
echo "could not find: $source" >&2
exit 1
fi
if [[ -d "$2" ]]; then
# remove destination folder
rm -rf "$2"
fi
ln -fs "$source" "$2"
}
# create a file if not already created
function seed_file {
local source
source="$(realpath "$1")"
if ! [[ -f "$source" || -d "$source" ]]; then
echo "could not find: $source" >&2
exit 1
fi
cp -n "$1" "$2"
}
### SCRIPTS
mkdir -p "$HOME/.local/bin"
for f in ./scripts/*; do
symlink "$(realpath "$f")" "$HOME/.local/bin/$(basename "$f")"
done
### GIT
seed_file "./git/gitconfig.local-example" "$(realpath "./git/gitconfig.local")"
symlink "./git/gitconfig" "$HOME/.gitconfig"
symlink "./git/gitconfig.local" "$HOME/.gitconfig.local"
symlink "./git/gitignore_global" "$HOME/.gitignore_global"
### SSH
symlink "./ssh/rc" "$HOME/.ssh/rc"
### VIM
symlink "./vim/vimrc" "$HOME/.vimrc"
### NEOVIM
symlink "./nvim" "$XDG_CONFIG_HOME/nvim"
### TMUX
symlink "./tmux" "$XDG_CONFIG_HOME/tmux"
if ! [ -d "tmux/plugins/tpm" ]; then
git clone https://github.com/tmux-plugins/tpm "tmux/plugins/tpm"
fi
### LAZYGIT
symlink "./lazygit" "$XDG_CONFIG_HOME/lazygit"
### ALACRITTY
symlink "./alacritty" "$XDG_CONFIG_HOME/alacritty"
### ZSH
mkdir -p "$XDG_DATA_HOME/zsh"
symlink "./zsh" "$XDG_CONFIG_HOME/zsh"
if ! [ -d "$XDG_CONFIG_HOME/zsh/plugins" ]; then
# install plugins
git clone https://github.com/hlissner/zsh-autopair "$XDG_CONFIG_HOME/zsh/plugins/zsh-autopair"
git clone https://github.com/zsh-users/zsh-autosuggestions "$XDG_CONFIG_HOME/zsh/plugins/zsh-autosuggestions"
git clone https://github.com/zsh-users/zsh-syntax-highlighting "$XDG_CONFIG_HOME/zsh/plugins/zsh-syntax-highlighting"
fi
symlink "./zsh/zshrc" "$HOME/.zshrc"
symlink "./zsh/zshenv" "$HOME/.zshenv"
symlink "./zsh/zprofile" "$HOME/.zprofile"
if [ "$(uname)" = "Darwin" ]; then
### YABAI
symlink "./yabai" "$XDG_CONFIG_HOME/yabai"
### SKHD
symlink "./skhd" "$XDG_CONFIG_HOME/skhd"
fi