feat(user/malte): sync notes and add git
subcommand
This commit is contained in:
parent
f674f24bf4
commit
a9ad73bf6f
|
@ -23,6 +23,8 @@ if [ -z "${1+x}" ]; then
|
||||||
if ! git diff --quiet "$year.md"; then
|
if ! git diff --quiet "$year.md"; then
|
||||||
git add "$year.md"
|
git add "$year.md"
|
||||||
git commit -m "Auto Commit $(date +"%F %R")"
|
git commit -m "Auto Commit $(date +"%F %R")"
|
||||||
|
export GIT_SSH_COMMAND="ssh -o BatchMode=yes"
|
||||||
|
(git pull --rebase && git push) || (echo "Sync failed" && exit 4) &
|
||||||
fi
|
fi
|
||||||
# Exit
|
# Exit
|
||||||
popd || exit 2
|
popd || exit 2
|
||||||
|
@ -45,9 +47,21 @@ function print_help_and_exit() {
|
||||||
printf " Show only todays entry\n"
|
printf " Show only todays entry\n"
|
||||||
printf " -1 | -2 | -3\n"
|
printf " -1 | -2 | -3\n"
|
||||||
printf " Show only yesterday/the day before/etc\n"
|
printf " Show only yesterday/the day before/etc\n"
|
||||||
|
printf " git GIT_COMMAND\n"
|
||||||
|
printf " Execute a git command in the note repository\n"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function run_git_command_by_args_and_exit() {
|
||||||
|
# Switch directory
|
||||||
|
pushd "$XDG_DATA_HOME/life.md" || exit 1
|
||||||
|
# Run command
|
||||||
|
git "$@"
|
||||||
|
# Exit
|
||||||
|
popd || exit 2
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
ONLY_TODOS=
|
ONLY_TODOS=
|
||||||
ONLY_DONE=
|
ONLY_DONE=
|
||||||
ONLY_DAY=
|
ONLY_DAY=
|
||||||
|
@ -76,6 +90,10 @@ while [[ $# -gt 0 ]]; do
|
||||||
ONLY_DAY="$1days"
|
ONLY_DAY="$1days"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
git)
|
||||||
|
shift
|
||||||
|
run_git_command_by_args_and_exit "$@"
|
||||||
|
;;
|
||||||
-h | --help)
|
-h | --help)
|
||||||
print_help_and_exit
|
print_help_and_exit
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue