-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
executable file
·68 lines (55 loc) · 1.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
#!/bin/sh
SELF=$(realpath "$0")
DOTFILES=$(dirname "$SELF")
DEBUG=
FORCE=
debug () { test -n "$DEBUG" && echo "[D] $*"; }
warn () { echo "[W] $*"; }
abspath () {
if [ "${2#/}" = "$2" ]; then
echo "$1/$2"
else
echo "$2"
fi
}
do_install () {
SRC=$(abspath "$DOTFILES" "$1")
DST=$(abspath "$HOME" "$2")
debug "Installing $SRC to ~${DST##"$HOME"}"
if [ -L "$DST" ] || [ -e "$DST" ]; then
warn "Target file ~${DST##"$HOME"} already exists"
test -z "$FORCE" && return
rm -f "$DST"
fi
DESTDIR=$(dirname "$DST")
test -d "$DESTDIR" || mkdir -p "$DESTDIR"
ln -sf "$SRC" "$DST"
}
while [ $# -gt 0 ]; do
case $1 in
-f|--force)
FORCE=1
;;
-v|--verbose)
DEBUG=1
;;
*)
warn "Unknown argument: $1"
;;
esac
shift
done
debug "Running from $DOTFILES"
XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
mkdir -p "$XDG_CONFIG_HOME"
do_install tmux.conf .tmux.conf
do_install zprofile .zprofile
do_install zshrc .zshrc
# VIM/Neovim
if [ ! -f ~/.vim/autoload/plug.vim ]; then
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
do_install vimrc .vimrc
do_install vimrc .vim/init.vim
ln -sf ~/.vim "$XDG_CONFIG_HOME/nvim"