-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.sh
executable file
·59 lines (48 loc) · 1.27 KB
/
config.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
set -e
DIRNAME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)"
export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/2.5.0/bin:$PATH"
BIN=~/bin
SUDO_USER=$(who am i | awk '{print $1}')
FULL_PATH="$(cd "$(dirname "$0")" && pwd)/$(basename "$0")"
SOURCE="$(cd "$(dirname "$0")" && pwd)"
RED="\033[1;31m" # Red
NC="\033[0m" # No Color
abort() { echo -e "${RED}$* ${NC}" >&2 && exit 1; }
[[ $USER == "root" ]] && abort \
"Can't be run as root, must be run as $SUDO_USER."
# Update submodules when there are changes
if [[ -f .gitmodules ]]; then
# Load hooks
for i in $(ls ${SOURCE}/githooks)
do
if [[ ! -L ${SOURCE}/.git/hooks/${i} ]] &&
[[ ! -f ${SOURCE}/.git/hooks/${i} ]]
then
ln -s ${SOURCE}/githooks/${i} ${SOURCE}/.git/hooks/${i}
fi
done
# Load submodules
cd $SOURCE
git submodule update --init --recursive
cd $OLDPWD
fi
# setup ~/bin
if [[ ! -d $BIN ]];
then
mkdir $BIN
fi
cd ${SOURCE}/bin
# link binaries
for i in $(ls);
do
if [[ ! -L ${HOME}/bin/${i:0:${#i} -3} ]] && \
[[ ! -f ${HOME}/bin/${i:0:${#i} -3} ]];
then
echo linking $i
ln -s ${SOURCE}/bin/${i} ${HOME}/bin/${i:0:${#i} -3}
fi
done
cd $OLDPWD
# set vim as the git editor
#git config --global core.editor $(which vim)