-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·83 lines (70 loc) · 2.99 KB
/
install.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# find directory of this script
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )"
. ${DIR}/helpers.sh
. ${DIR}/bashcolor
graceful_ln ${DIR}/bashrc_user ~/.bashrc_user
graceful_ln ${DIR}/bash_aliases ~/.bash_aliases
graceful_ln ${DIR}/vimrc ~/.vimrc
graceful_ln ${DIR}/profile ~/.profile
graceful_ln ${DIR}/bash_env ~/.bash_env
# make sure bashrc sources bashrc_user
# all bashrc customization is done in ~/.bashrc_user
if ! grep -q "START_SOURCE_BASHRC_USER" $HOME/.bashrc
then
# part doesn't exist, add
echo "" >> $HOME/.bashrc
echo "# START_SOURCE_BASHRC_USER" >> $HOME/.bashrc
echo "# END_SOURCE_BASHRC_USER" >> $HOME/.bashrc
echo "added sourceing of ~/.bashrc_user to ~/.bashrc"
fi
# part exists, replace with current version in case sth changed here
sed -i.sav '/START_SOURCE_BASHRC_USER/,/END_SOURCE_BASHRC_USER/c\
# START_SOURCE_BASHRC_USER\
if [ -f "$HOME/.bashrc_user" ]; then\
. "$HOME/.bashrc_user"\
fi\
# END_SOURCE_BASHRC_USER' $HOME/.bashrc
echo "updated sourcing of ~/.bashrc_user in ~/.bashrc"
# slightly more logic needed for git-completion since dependant on git version
GIT_VERSION=`git version | grep -oE "[0-9]*\.[0-9]*\.[0-9]*"`
echo "current git version: $GIT_VERSION"
if [ ! \( -e "${DIR}/git/git-completion/$GIT_VERSION/git-completion.bash" \) ]; then
echo "git-completion.bash doesn't exist for installed git version $GIT_VERSION"
echo "installing first... "
curl -fLo ${DIR}/git/git-completion/$GIT_VERSION/git-completion.bash --create-dirs https://github.com/git/git/blob/v$GIT_VERSION/contrib/completion/git-completion.bash
fi
graceful_ln ${DIR}/git/git-completion/$GIT_VERSION/git-completion.bash ~/.git-completion.bash
# setup ssh
#----------
graceful_ln ${DIR}/ssh/rc ~/.ssh/rc
# setup vim
#----------
# setup vim-plug, the simple plugin manager for vim, for more details
# check ~/.vimrc
if [ ! \( -e "${HOME}/.vim/autoload/plug.vim" \) ]; then
echo "installing vim plugin manager"
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
# ensure folder is present
mkdir -p ~/.vim/plugin
graceful_ln ${DIR}/vim/plugin/vagrantfile.vim ~/.vim/plugin/vagrantfile.vim
# setup tmux
#-----------
graceful_ln ${DIR}/tmux.conf ~/.tmux.conf
graceful_ln ${DIR}/tmux ~/.tmux
# setup tmux plugin manager
# check ~/.tmux.conf
if [ ! \( -e "${HOME}/.tmux/plugins/tpm" \) ]; then
echo "installing tmux plugin manager"
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
else
echo "tmux plugin manager already installed, skipping"
fi