-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin
executable file
·61 lines (50 loc) · 1.63 KB
/
plugin
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
#!/bin/bash
#
# Bash script to "plugin" to the dotfile repository. Turns normal dotfiles (e.g.
# .bashrc) into symlinks to this repository's versions of those files. It
# optionally moving old files so that they can be preserved. A cron job is also
# setup to automate pulling new changes from master.
shopt -s nocasematch # This makes pattern matching case-insensitive
POSTFIX="local"
PLUGIN_FILES=( .bash_profile .bashrc .gitconfig .gitignore .jobs.cron .nanorc .tmux.conf )
PULLURL="https://github.com/brcooley/.f.git"
PUSHURL="git@github.com:brcooley/.f.git"
overwrite=false
print_help () {
echo -e "\\nA script to keep dotfiles up to date\\n"
echo "Options:"
echo " -r, --remove-local Removes local copies of dotfiles instead of"
echo " appending \"$POSTFIX\" to them."
exit 0
}
for opt in "$@"; do
case $opt in
-r | --remove-local) overwrite=true;;
-h | --help) print_help;;
esac
done
if ! [ -f "./plugin" ]; then
echo "Must be run from .f directory!"
exit 1
fi
for f in "${PLUGIN_FILES[@]}"; do
if [ -f "$HOME/$f" ]; then
if [ $overwrite = false ]; then
mv "$HOME/$f" "$HOME/${f}_$POSTFIX"
echo "Moving ~/$f to $HOME/${f}_$POSTFIX"
else
rm "$HOME/$f"
fi
fi
ln -s "$PWD/$f" "$HOME/$f"
done
# Roll into above loop
if [ -d "$HOME/bin" ]; then
echo "$HOME/bin exists, not overwriting"
else
ln -s "$PWD/bin" "$HOME/bin"
fi
# Git versions prior to 1.7.? (1.7.1 confirmed) do not have a --local option
git config --local remote.origin.url "$PULLURL"
git config --local remote.origin.pushurl "$PUSHURL"
crontab .jobs.cron && source ~/.bashrc && echo "Plugin succesful"