-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·75 lines (63 loc) · 1.74 KB
/
setup.sh
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
#!/bin/bash
err() {
echo >&2 "ERROR :: $1"
}
warn() {
echo "WARN :: $1"
}
log() {
echo "> $1"
}
ensure_installed() {
if ! command -v brew &> /dev/null; then
err "Requires brew to be installed"
exit 1
fi
log "checking installation for '$1'"
brew list $1 &>/dev/null || brew install $1
}
link() {
local from=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/$1
local to=$2
# issues with from/to
if [ ! -f "$from" ] && [ ! -d "$from" ]; then
err "File/directory '$from' does not exist ... aborting"
exit
fi
[ -f "$to" ] && [ ! -L "$to" ] && err "'$to' already exist and is file ... aborting" && exit
# link already present
[ -L "$to" ] && warn "link for '$to' already exist ... skpping" && return
# ensure parent directory exists
[ ! -d "$(dirname $to)" ] && warn "Missing parent directory ... creating " && mkdir -p "$(dirname $to)"
# perform linking
ln -v -s $from $to
}
# Linking of diffenrent files
if [ -L "${HOME}/.dotfiles" ]; then
warn "'${HOME}/.dotfiles' already exist, relinking"
rm "${HOME}/.dotfiles"
ln -s $PWD ${HOME}/.dotfiles
else
ln -s $PWD ${HOME}/.dotfiles
fi
link zshrc ${HOME}/.zshrc
link gitconfig ${HOME}/.gitconfig
link gitignore ${HOME}/.gitignore
link vimrc ${HOME}/.vimrc
link nvim ${HOME}/.config/nvim
# handy packages
# installed by brew, apt, snap or other package managers
ensure_installed bat
ensure_installed exa
ensure_installed dust
ensure_installed fd
ensure_installed ripgrep
ensure_installed git
ensure_installed neovim
# fzf installation
if [ ! -d $HOME/.fzf ]; then
git clone https://github.com/junegunn/fzf.git $HOME/.fzf
fi
if ! command -v fzf &> /dev/null; then
$HOME/.fzf/install --key-bindings --completion --no-update-rc --no-bash --no-fish
fi