-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_symlinks.sh
executable file
·59 lines (48 loc) · 1.65 KB
/
setup_symlinks.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
#!/bin/bash
# sets `-euo pipefail`
# Adds scripts dir to PATH
# Adds error handling
# Globals:
# $SCRIPTS_DIR
# $SHELL_SETTINGS_DIR
# $(.SCRIPT_DIR)
# $(.SCRIPT_NAME)
[ ! "$_INIT_COMPLETE" ] && source $HOME/github/shell-settings/scripts/.INIT && export _INIT_COMPLETE=1
THIS_VIM_FOLDER="$SHELL_SETTINGS_DIR/.vim"
createsymlink() {
local s="$1"
local d="$2"
if [ ! -L "$d" ]; then
log "linking \"$s\" to \"$d\""
ln -sf "$s" "$d"
fi
}
log -d "Checking for symlink update..."
createsymlink ${SHELL_SETTINGS_DIR}/.zshrc $HOME/.zshrc
createsymlink ${SHELL_SETTINGS_DIR}/.aliasrc-shell-settings $HOME/.aliasrc-shell-settings
createsymlink ${SHELL_SETTINGS_DIR}/.zsh_completions $HOME/.zsh_completions
createsymlink ${SHELL_SETTINGS_DIR}/.vimrc $HOME/.vimrc
createsymlink ${SHELL_SETTINGS_DIR}/.direnvrc $HOME/.direnvrc
createsymlink ${SHELL_SETTINGS_DIR}/jens-disagrees.zsh-theme $HOME/.oh-my-zsh/themes/jens-disagrees.zsh-theme
for d in `find ${THIS_VIM_FOLDER} -type d`; do
vimfolder=`basename ${d}`
symlink="${HOME}/.vim/${vimfolder}"
if [ ! -L "$symlink" ]; then
createsymlink "${d}" "${symlink}"
fi
done
for f in `find "${SHELL_SETTINGS_DIR}/configurations" -type f`; do
MAP_HOME="${SHELL_SETTINGS_DIR}/configurations/*/HOME/*"
if [[ $f == $MAP_HOME ]]; then
prefix=${f#"${SHELL_SETTINGS_DIR}/configurations/"}
_filepath=`echo ${prefix} | sed -E 's#.*/HOME/(.*)#\1#'`
_filename=`basename $_filepath`
_filedirectory="$HOME/`dirname $_filepath`"
_symlink="${_filedirectory}/${_filename}"
if [ ! -L "${_symlink}" ]; then
log -e
mkdir -p "${_filedirectory}"
createsymlink "${f}" "${_symlink}"
fi
fi
done