-
Notifications
You must be signed in to change notification settings - Fork 2
/
deploy.sh
executable file
·160 lines (137 loc) · 7.07 KB
/
deploy.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
clone_repo() {
base=$1
url=$2
repo_name=$(echo $url | perl -pe 's/.*\/(.*)$/\1/')
dir_name=$(echo $repo_name | perl -pe 's/\.git$//')
if [ ! -d $base/$dir_name ]; then
echo "Cloning $repo_name to $base/$dir_name"
git clone https://github.com/sidcha/$repo_name $base/$dir_name > /dev/null
if [ $? -ne 0 ]; then
echo "Could not find a fork; tracking upstream master"
git clone $line $base/$dir_name > /dev/null
fi
git -C $base/$dir_name remote add upstream $line
else
echo "Processing $repo_name to $base/$dir_name"
git -C $base/$dir_name pull upstream master
# when we have a ssh clone of .files, also update the forks :)
if [[ ! -z "$(git remote get-url origin | grep -o -e '^[email protected]')" ]]; then
git -C $base/$dir_name remote set-url origin "$(echo https://github.com/sidcha/$repo_name | perl -pe 's|^https://([^/]+)/(.*)(\.git)?|git@\1:\2.git|')"
git -C $base/$dir_name push origin master
fi
fi
}
foreach_line() {
list=$1; shift;
while IFS='' read -r line || [[ -n "$line" ]]; do
"$@" $line
done < $list
}
#
# Note: This script should be re-runnable. ie., don't do any
# appends to files here.
#
DIR=$(realpath "$(dirname "$0")")
pushd ${DIR} 2>&1 > /dev/null
if [[ -z "$(git diff --quiet --exit-code || echo +)" ]]; then
git pull origin master --rebase
else
echo "Working tree is dirty! Will not git pull"
fi
mkdir -p ~/.vim ~/.vim/autoload ~/.vim/bundle ~/.vim/spell ~/.vim/syntax
if [ ! -f ~/.vim/autoload/pathogen.vim ]; then
echo "Downloading pathogen for vim"
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
fi
echo "Fectching new vim plugins.."
rm -rf ~/.vim/bundle/file-line/
foreach_line $DIR/runcon/vim/plugin.list clone_repo ~/.vim/bundle
touch ~/.vim/spell/en.utf-8.add
rm -rf ~/.vim/syntax ~/.vim/ftplugin
echo -n "Adding simlinks for dotFiles... "
ln -f -s $DIR/runcon/vim/vimrc ~/.vimrc
ln -f -s $DIR/runcon/vim/ftplugin ~/.vim/ftplugin
ln -f -s $DIR/runcon/vim/syntax ~/.vim/syntax
ln -f -s $DIR/runcon/bashrc ~/.bashrc
ln -f -s $DIR/runcon/screenrc ~/.screenrc
ln -f -s $DIR/runcon/Xresources ~/.Xresources
ln -f -s $DIR/runcon/Xinitrc ~/.Xinitrc
ln -f -s $DIR/runcon/Xmodmap ~/.Xmodmap
ln -f -s $DIR/runcon/minttyrc ~/.minttyrc
ln -f -s $DIR/runcon/mbsyncrc ~/.mbsyncrc
ln -f -s $DIR/runcon/msmtprc ~/.msmtprc
ln -f -s $DIR/runcon/zshrc ~/.zshrc
ln -f -s $DIR/runcon/nvim ~/.config/nvim
ln -f -s $DIR/runcon/tmux ~/.config/tmux
ln -f -s $DIR/runcon/mutt ~/.config/mutt
ln -f -s $DIR/runcon/zshrc ~/.zshrc
echo "Done."
git config --global include.path $DIR/config/gitconfig
git config --global user.name "Siddharth Chandrasekaran"
git config --global init.templatedir "$DIR/git_template"
git config --global rebase.autoSquash true
git config --global sendemail.confirm always
git config --global am.threeWay true
git config --global color.ui auto
git config --global core.excludesfile ~/.gitignore
git config --global core.pager "less -FMRiX"
# Git alias
git config --global alias.ctags '!.git/hooks/ctags'
git config --global alias.last 'diff HEAD^ HEAD'
git config --global alias.su 'submodule update --recursive'
git config --global alias.ll 'log --format=%h --abbrev=12 --oneline'
# The patchset workflow:
# All of the below git aliases operate on patch numbers (like the one git-format-patch
# would give your patch). Some of them can take any git-ref too;
#
# To see the all the patches made on current branch over beyond $base, run `git l`.
# $base is set to origin/master by default. It can overridden by setting it in shell.
#
# Aliases:
# * git l - lists commits made on this branch with patch numbers
# * git sh - show commit with patch number (or ref)
# * git fixip - fixup commit with patch number
# * git rb - rebase interactively autosquashing commits made on this branch
# * git reword - reowrd the commit message of patch number
# * git amend-to - merge the staged changes into the given patch number (or ref)
#
git config --global alias.l '!f() { base=${base:-$(git config repo.upstream)}; git log --format=%h --abbrev=12 --oneline ${base}..HEAD | tac | nl | tac | perl -pe "s/([0-9a-f]{12})/\\e[1;31m\\1\\e[m/" | less -XFR; }; f'
git config --global alias.sh '!f() { base=${base:-$(git config repo.upstream)}; if [ ${#1} -gt 5 ]; then sha="${1}"; else sha="$(git rev-list --reverse ${base}..HEAD | sed -n -e ${1}p)"; fi; git show $sha; }; f'
git config --global alias.fixup '!f() { base=${base:-$(git config repo.upstream)}; if [ ${#1} -gt 5 ]; then sha="${1}"; else sha="$(git rev-list --reverse ${base}..HEAD | sed -n -e ${1}p)"; fi; git commit --fixup=$sha; }; f'
git config --global alias.reword '!f() { base=${base:-$(git config repo.upstream)}; if [ ${#1} -gt 5 ]; then sha="${1}"; else sha="$(git rev-list --reverse ${base}..HEAD | sed -n -e ${1}p)"; fi; git commit --fixup reword:${sha}; GIT_EDITOR=true git rebase -i --autosquash ${sha}^; }; f'
git config --global alias.amend-to '!f() { base=${base:-$(git config repo.upstream)}; if [ ${#1} -gt 5 ]; then sha="${1}"; else sha="$(git rev-list --reverse ${base}..HEAD | sed -n -e ${1}p)"; fi; git commit --fixup=${sha} && GIT_EDITOR=true git rebase -i --autosquash ${sha}^; }; f'
git config --global alias.rb '!f() { base=${base:-$(git config repo.upstream)}; count=${1:-"$(git rev-list --reverse ${base}..HEAD | wc -l | xargs)"}; git rebase -i --autosquash HEAD~${count}; }; f'
git config --global alias.pref '!f() { base=${base:-$(git config repo.upstream)}; sha="$(git rev-list --reverse ${base}..HEAD | sed -n -e ${1}p)"; echo ${sha} }; f'
# A Perl Compatible RE find and replace
git config --global alias.rp '!f() { find=${1}; shift; replace=${1}; shift; files="$*"; if test -z "${files}"; then files="$(git grep --perl-regexp -n "${find}" | perl -pe "s/:\d+:.*//" | uniq | tr "\n" " ")"; fi; if test -n "${files}"; then perl -i -pe "s/${find}/${replace}/g" $files; fi; }; f'
# For github PRs
git config --global alias.pr '!f() { git fetch -fu ${2:-$(git remote |grep ^upstream || echo origin)} refs/pull/$1/head:pr-$1 && git checkout pr-$1; }; f'
git config --global alias.pr-clean '!git for-each-ref refs/heads/pr-* --format="%(refname)" | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done'
# For stash/bitbucket
git config --global alias.spr '!f() { git fetch -fu ${2:-$(git remote |grep ^upstream || echo origin)} refs/pull-requests/$1/from:pr/$1 && git checkout pr/$1; }; f'
touch ~/.ssh/config
if ! grep -qe 'Include .*/\.files/config/ssh_config' ~/.ssh/config; then
echo "Adding default ssh_config."
echo -e "Include $DIR/config/ssh_config\n" | cat - ~/.ssh/config > ~/.ssh/config.tmp && \
mv ~/.ssh/config.tmp ~/.ssh/config
fi
if [[ ! -d "$HOME/.fzf" ]]; then
echo "Setting up fzf..."
git clone --depth 1 https://github.com/junegunn/fzf.git $HOME/.fzf
~/.fzf/install
fi
if [ ! -f ~/.env ]; then
echo "export CFG_SCRIPT_DIR=$DIR" > ~/.env
fi
echo -n "Resourcing bashrc... "
source ~/.bashrc
echo "Done."
cat <<----
Following are your favorite tools make sure you install them!"
$(cat $DIR/other/software.list)
Also install parcellite and set the following:
- Use copy (Ctrl-C)
- Use Primary (Selection)
- Sync clipboards
---