2015-10-08 09:14:30 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
DOTFILES_DIR="$HOME/Projects/config"
|
|
|
|
|
|
|
|
command_diff() {
|
|
|
|
cd $DOTFILES_DIR
|
|
|
|
git diff $@
|
|
|
|
}
|
|
|
|
|
|
|
|
command_commit() {
|
|
|
|
cd $DOTFILES_DIR
|
|
|
|
git add .
|
|
|
|
git commit -m $1
|
|
|
|
}
|
|
|
|
|
|
|
|
command_status() {
|
|
|
|
cd $DOTFILES_DIR
|
|
|
|
git status
|
|
|
|
}
|
|
|
|
|
|
|
|
command_add() {
|
|
|
|
file=$1
|
|
|
|
savepoint=$2
|
|
|
|
mkdir -p "$DOTFILES_DIR/$(dirname "$savepoint")"
|
|
|
|
mv "$file" "$DOTFILES_DIR/$savepoint"
|
|
|
|
ln -s "$DOTFILES_DIR/$savepoint" "$file"
|
|
|
|
cd $DOTFILES_DIR
|
|
|
|
git add "$savepoint"
|
2015-10-08 09:21:06 +02:00
|
|
|
git commit -m "Added $savepoint"
|
2015-10-08 09:14:30 +02:00
|
|
|
|
|
|
|
echo "$file added in $DOTFILES_DIR/$savepoint"
|
|
|
|
}
|
|
|
|
|
2015-10-08 09:22:17 +02:00
|
|
|
command_pull() {
|
2015-10-08 09:21:06 +02:00
|
|
|
cd $DOTFILES_DIR
|
2015-10-08 09:22:17 +02:00
|
|
|
git pull
|
|
|
|
}
|
|
|
|
|
|
|
|
command_push() {
|
|
|
|
cd $DOTFILES_DIR
|
|
|
|
git push
|
2015-10-08 09:21:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
command_help() {
|
|
|
|
echo "diff -- Show diffs"
|
|
|
|
echo "commit [message] -- Add all files and commit"
|
|
|
|
echo "status -- Show status"
|
|
|
|
echo "add [file] [savepoint] -- Add file to dotfiles at savepoint, create symlink and add"
|
2015-10-08 09:23:29 +02:00
|
|
|
echo "push -- git push"
|
|
|
|
echo "pull -- git pull"
|
2015-10-08 09:14:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CMD=$1
|
|
|
|
shift
|
|
|
|
case "$CMD" in
|
2015-10-08 09:23:29 +02:00
|
|
|
diff|commit|add|status|sync|help|push|pull)
|
2015-10-08 09:14:30 +02:00
|
|
|
command_$CMD $@
|
|
|
|
;;
|
|
|
|
*)
|
2015-10-08 09:21:06 +02:00
|
|
|
command_help
|
2015-10-08 09:14:30 +02:00
|
|
|
;;
|
|
|
|
esac
|