-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·84 lines (67 loc) · 2.5 KB
/
setup.sh
File metadata and controls
executable file
·84 lines (67 loc) · 2.5 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
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
84
#!/bin/bash
# Make a backup of the original directory/file:
backup ()
{
old=$1
if [ -e "$old" ]; then
shopt -s nullglob
tmp=(${old}*)
shopt -u nullglob
( set -x; mv ${old} ${old}.bk.${#tmp[@]} )
fi
}
mk_link ()
{
new=$1
old=$2
# Test if NEW exists and NEW and OLD point to different things.
if [ -e "$new" ] && [ ! "$new" -ef "$old" ]; then
backup $old
( set -x; ln -s $new $old)
fi
}
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
#-- Vim Setup --------------------------------------------------------
vim_version=$(vim --version | head -1 | cut -d ' ' -f 5)
mk_link ${DIR}/vim ${HOME}/.vim
## Vim 7.4 allows the rc file to located within the .vim directory.
##
## We make use of this feature if it's supported by moving any existing .vimrc
## to a backup file.
if [ $(bc <<< "${vim_version} < 7.4") = 1 ]; then
mk_link ${DIR}/vimrc ${HOME}/.vimrc
else
backup ${HOME}/.vimrc
fi
## Install Vundle (Vim's package manager):
if [ ! -d ${DIR}/vim/bundle/Vundle.vim ]; then
git clone https://github.com/VundleVim/Vundle.vim.git \
${DIR}/vim/bundle/Vundle.vim
fi
## Install Vim bundles:
vim +BundleInstall +qall
#-- Bash Setup ---------------------------------------------------------
mk_link ${DIR}/inputrc ${HOME}/.inputrc
if [ -e ${HOME}/.bashrc ] && ! grep -q bashrc_common.sh ${HOME}/.bashrc; then
printf "\n#Commonly used aliases and commands\n" >> ${HOME}/.bashrc
printf "source ${DIR}/bashrc_common.sh\n" >> ${HOME}/.bashrc
fi
#-- Git/Ctags ----------------------------------------------------------
# Rebuild ctags and cscope every time a git repo is modified via a checkout,
# merge, rebase or commit.
#
git config --global init.templatedir ${DIR}/git_template
git config --global alias.ctags '!`git rev-parse --git-dir`/hooks/ctags'
git config --global alias.ctags-enable '!`git rev-parse --git-dir`/hooks/ctags-enable'
git config --global alias.ctags-disable '!`git rev-parse --git-dir`/hooks/ctags-disable'
git config --global alias.cscope '!.git/hooks/cscope'
# Add the 'rclean' alias to recursively clean a repo:
git config --global alias.rclean '!git clean -ffdx && git submodule foreach --recursive git clean -ffdx'
# Add the 'su' alias to do a submodule update:
git config --global alias.su 'submodule update --init --recursive'
# Enable 'Reuse Recorded Resolution' globally:
git config --global rerere.enabled true
# Get sub-module status in `git status`:
git config --global status.submoduleSummary true
# Git diff to show a bit more details for submodules:
git config --global diff.submodule log