diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-07-13 22:06:01 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-07-13 22:06:01 +0300 |
commit | 5e2ebda430569624c5f34115ca8e45a1633dd3cf (patch) | |
tree | c050162fa4913dde4ab3cad8f0ed1a99b8dea178 /.bashrc_git | |
parent | add ensure_symlinks_enabled (diff) | |
download | linux-home-5e2ebda430569624c5f34115ca8e45a1633dd3cf.tar.gz linux-home-5e2ebda430569624c5f34115ca8e45a1633dd3cf.zip |
split .bashrc into multiple files
Diffstat (limited to '')
-rw-r--r-- | .bashrc_git | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/.bashrc_git b/.bashrc_git new file mode 100644 index 0000000..dc51b40 --- /dev/null +++ b/.bashrc_git @@ -0,0 +1,50 @@ +alias list_repo_files='git ls-files -z' + +list_repo_dirs() ( + set -o errexit + + { printf '.\0' ; list_repo_files ; } \ + | xargs -0 dirname -z \ + | sort -z \ + | uniq -z \ + | tail -z -n +2 +) + +tighten_repo_security() ( + set -o errexit + + list_repo_files | xargs -0 chmod 0600 + list_repo_dirs | xargs -0 chmod 0700 + chmod 0700 .git +) + +backup_repo() ( + set -o errexit + + local repo_dir="$( realpath . )" + local repo_name="$( basename "$repo_dir" )" + local backup_dir="$repo_dir" + + if [ $# -eq 1 ]; then + backup_dir="$1" + elif [ $# -gt 1 ]; then + echo "$FUNCNAME: usage: $FUNCNAME [BACKUP_DIR]" >&2 + exit 1 + fi + + local zip_name="${repo_name}_$( date -u +'%Y%m%dT%H%M%S' ).zip" + + git archive \ + --format=zip -9 \ + --output="$backup_dir/$zip_name" \ + --remote="$repo_dir" \ + HEAD +) + +backup_repo_dropbox() { + backup_repo "$USERPROFILE/Dropbox/backups" +} + +backup_repo_nwx() { + backup_repo '//spbfs02/P/Personal/Egor Tensin' +} |