From f3ba6e1e3328a4649916eb2b3f42b861d4f71ee5 Mon Sep 17 00:00:00 2001 From: Marissa Staib Date: Wed, 25 Sep 2019 22:51:57 +0000 Subject: [PATCH] Add automatic committing/pulling, gitignore .swp files --- .gitignore | 1 + bash_aliases.sh | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/bash_aliases.sh b/bash_aliases.sh index d9d8ed9..40106c8 100644 --- a/bash_aliases.sh +++ b/bash_aliases.sh @@ -40,7 +40,7 @@ function bell_after() { } # Reload aliases -function bashreload() +function reload_scripts_only() { source "$HOME"/.bashrc } @@ -48,19 +48,27 @@ function bashreload() # from https://stackoverflow.com/a/1203628 # Useful for overriding functions defined in these common scripts # Usage: copy_func from to -function copy_func() +function copy_func() { declare -F $1 > /dev/null || return 1 eval "$(echo "${2}()"; declare -f ${1} | tail -n +2)" } -function scriptupdate() +function bashreload() { ( cd "$( dirname "$(realpath -e "${BASH_SOURCE[0]}")" )" - git pull + needs_push=false + if git add .; git diff-index --cached --quiet HEAD; then + git commit -am "Autocommitted updated scripts from ${hostname}" + needs_push=true + fi + git pull --rebase + if [[ "$needs_push" == "true" ]]; then + git push + fi ) - bashreload + reload_scripts_only } function man ()