-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathmklinks.sh
More file actions
executable file
·45 lines (38 loc) · 1.06 KB
/
mklinks.sh
File metadata and controls
executable file
·45 lines (38 loc) · 1.06 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
#!/bin/bash
set -e # exit on fail
# Symlink from ~/.dotfiles to ~/
# Can handle nested links, e.g. symlink only .emacs.d/config
# but not all of .emacs.d
function error_msg { echo "[ EXISTS ] $@"; }
function success_msg { echo "[ CREATE ] $@"; }
function checkedlink {
# Check if exists then link if not
fname="$destdir/$1"
# Create intermediate directories as needed
dname=$(dirname $fname)
if [[ ! -d $dname ]]
then
echo "$1: Making dirs: $dname"
mkdir -p $dname;
fi
# Attempt to create symlink, fail if a file / directory exists
if [ -e "$fname" ]
then
error_msg "$fname"
return
else
success_msg "$fname"
ln -s "$srcdir/$1" "$destdir/$1"
fi
}
srcdir=~/.dotfiles
destdir=~
checkedlink .bash_profile
checkedlink .inputrc
checkedlink .tmux.conf
checkedlink .vimrc
checkedlink .config/nvim/init.vim
checkedlink .config/nvim/custom/functions.vim
checkedlink .config/nvim/custom/customairline.vim
checkedlink .config/nvim/syntax/todo.vim
checkedlink .config/nvim/colors/nnkd.vim