Files
dotfiles/runBackup.sh
2023-10-08 16:13:41 -03:00

58 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
only_backup=false
only_commit=false
show_help() {
echo "Usage: $0 [--help|-h show help] [--only-commit]"
echo "Options:"
echo " --only-commit Makes the script only create a commit"
echo " --help|h Display this message"
}
while [[ $# -gt 0 ]]; do
case "$1" in
--help|-h)
show_help
exit 0
;;
--only-backup)
only_backup=true
shift
;;
--only-commit)
only_commit=true
shift
;;
*)
echo "Error: Unknown option '$1'"
show_help
exit 1
;;
esac
done
if [ "$only_backup" = true ] && [ "$only_commit" = true ]; then
echo "Error: Cannot use both --only-backup and --only-commit together."
exit 1
fi
if [ "$only_commit" = false ]; then
mkdir --parents dot-conf
mkdir --parents dot-conf/.config/lvim
mkdir --parents dot-conf/.tmuxifier/layouts
mkdir --parents dot-conf/zellij
cp ${HOME}/.zshrc ./dot-conf/
cp ${HOME}/.tmux.conf ./dot-conf/
cp --recursive ${HOME}/.config/lvim/ ./dot-conf/.config/
cp --recursive ${HOME}/.tmuxifier/layouts/ ./dot-conf/.tmuxifier/layouts/
cp --recursive ${HOME}/.config/zellij/ ./dot-conf/zellij/
fi
if [ "$only_backup" = false ]; then
fulltime=$(date +%y-%m-%d-%H-%M-%S)
git add .
git commit -m "Devboot update: ${fulltime}"
fi