This repository has been archived by the owner on Jul 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.sh
executable file
·62 lines (54 loc) · 2.44 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
#!/bin/bash
script_dir() {
if [ -z "${SCRIPT_DIR}" ]; then
# even resolves symlinks, see
# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
local SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
fi
echo "${SCRIPT_DIR}"
}
CODE_HOME=$(script_dir)
setup_file_link() {
local source="$1"
local destination="$2"
if [ ! -e "${destination}" ]; then
ln -s "${source}" "${destination}" && echo "Linked file ${source} to ${destination}"
else
echo "ERROR: File ${source} already exists"
fi
}
setup_dir_link() {
local source="$1"
local destination="$2"
if [ ! -d "${destination}" ]; then
ln -s "${source}" "${destination}" && echo "Linked directory ${source} to ${destination}"
else
echo "ERROR: Directory ${source} already exists"
fi
}
# create backup dir if it doesn't exist
if [ ! -d "${HOME}/.backup" ]; then
echo "Creating ~/.backup directory"
mkdir "${HOME}/.backup"
fi
# setup links
setup_file_link "${CODE_HOME}/bashrc" "${HOME}/.bashrc"
setup_file_link "${CODE_HOME}/bash_profile" "${HOME}/.bash_profile"
setup_file_link "${CODE_HOME}/gitconfig" "${HOME}/.gitconfig"
#setup_file_link "${CODE_HOME}/screenrc" "${HOME}/.screenrc"
#setup_dir_link "${CODE_HOME}/dotemacs.d" "${HOME}/.emacs.d"
setup_dir_link "${CODE_HOME}/bash_completion.d" "${HOME}/.bash_completion.d"
setup_dir_link "${CODE_HOME}/bin" "${HOME}/bin"
#setup_dir_link "${CODE_HOME}/atom" "${HOME}/.atom"
setup_dir_link "${CODE_HOME}/dotvim" "${HOME}/.vim"
setup_file_link "${HOME}/.vim/.vimrc" "${HOME}/.vimrc"
setup_file_link "${CODE_HOME}/tmux.conf" "${HOME}/.tmux.conf"
setup_file_link "${CODE_HOME}/dircolors" "${HOME}/.dircolors"
echo "Read the bashrc file you are setting up on Mac to get Emacs running"
# to remove everything, run the following. Not going to automate this, because it is too destructive
# rm "${HOME}/.bashrc" "${HOME}/.bash_profile" "${HOME}/.gitconfig" "${HOME}/.screenrc" "${HOME}/.vim" "${HOME}/.emacs.d" "${HOME}/bin" "${HOME}/.bash_completion.d" "${HOME}/.vimrc" "${HOME}/.tmux.conf"
# see https://github.com/syl20bnr/spacemacs/wiki/Terminal for how to setup 24 bit colors,
# /usr/bin/tic -x -o ~/.terminfo xterm-24bit.terminfo
# export TERM=xterm-24bit into the ~/.bashrc-custom