blob: a1302852b28fd53328fe37e7d771e53cf7d5343c (
plain) (
blame)
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
|
pull() {
url=""
file=""
while [ $# -gt 0 ] ; do
case $1 in
-f)
file="$2"
shift; shift; ;;
-u)
url="$2"
shift; shift; ;;
esac
done
CMD="$(which curl wget fetch 2>/dev/null | tail -n1)"
case $CMD in
*curl) "$CMD" "$url" > "$file" ;;
*wget) "$CMD" "$url" -O "$file" ;;
*fetch) "$CMD" "$url" -o "$file" ;;
esac
}
pulldotfile() {
file="$1"
destfile="$(basename "${file}")"
pull -u "${UPDATE_URL}${file}" -f "$HOME/.${destfile}"
}
_make_ssh_dir_if_not_exists() {
auth_keys="$HOME/.ssh/authorized_keys"
if ! [ -d $HOME/.ssh ] ; then mkdir $HOME/.ssh ; fi
chmod 700 $HOME/.ssh
chmod 600 $auth_keys
}
_pullkeys() {
url="$1"; shift
_timestamp="$(timestamp)"
_make_ssh_dir_if_not_exists
auth_keys="$HOME/.ssh/authorized_keys"
mv "$auth_keys" "${auth_keys}.${_timestamp}" || \
echo "Authorized Keys do not currently exist"
pull -u "$url" -f "$auth_keys" || \
mv "${auth_keys}.${_timestamp}" "$auth_keys"
ssh-keygen -lf "$auth_keys" || \
mv "${auth_keys}.${_timestamp}" "$auth_keys"
chmod 600 $auth_keys
}
pullkeys() {
file="keys/$1"; shift;
url="${UPDATE_URL}${file}"
_pullkeys "$url"
}
pullkeys_github() {
_username="$1"; shift;
url="https://github.com/${_username}.keys"
_pullkeys "$url"
}
pulltermcolors() {
file="$HOME/bin/terminal-colors"
if ! [ -d $HOME/bin ] ; then
mkdir $HOME/bin
fi
pull -u ${UPDATE_URL}/util/terminal-colors -f $file
chmod +x $file
}
updatetmuxconf() {
pulldotfile "tmux/tmux.conf"
pulldotfile "tmux/tmux_helper.sh"
if ! [ -e $HOME/.tmux.conf.local ] && [ `id -u` -eq 0 ] ; then
# If I ever change the color from green this will have to be updated I guess
grep 'green' $HOME/.tmux.conf | sed -e's/green/red/g' > $HOME/.tmux.conf.local
elif ! [ -e $HOME/.tmux.conf.local ] ; then
touch $HOME/.tmux.conf.local
fi
}
updategitconf() {
file="gitconfig/$1"
pull -u "${UPDATE_URL}${file}" -f "$HOME/.gitconfig"
}
updateshell() {
pulldotfile "mkshrc"
. $HOME/.mkshrc
}
updatevimrc() {
OLDWD="$(pwd)"
cd "$HOME"
git clone --recurse-submodules "$VIM_GIT_URL" .vim
exit="$?"
cd $HOME/.vim || { echo "Cannot cd to .vim dir" ; return; }
if [ "$exit" -gt 0 ] ; then
git pull origin master
git submodule update
fi
./link-vimrc.sh
cd $OLDWD
}
updatevimrc_basic() {
pull -u "$VIM_BASIC_URL" -f ~/.vimrc
}
|