ted: better git commits & variable names
This commit is contained in:
parent
a6bc524f54
commit
f4d79aaec7
1 changed files with 9 additions and 9 deletions
|
@ -14,13 +14,13 @@ ed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
backup_git() {
|
backup_git() {
|
||||||
cd "${1:-}"
|
cd "$1"
|
||||||
if command -v git > /dev/null; then
|
if command -v git > /dev/null; then
|
||||||
# Commit all existing files
|
# Commit all existing files
|
||||||
git commit -am "ted-backup: update $dirname"
|
git commit -am "ted-backup($dirname): update files" || true
|
||||||
# Add new files and commit them
|
# Add new files and commit them
|
||||||
git add "$1"
|
git add "$1"
|
||||||
git commit -m "ted-backup: add $dirname"
|
git commit -m "ted-backup($dirname): add files" || true
|
||||||
git push
|
git push
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -64,20 +64,20 @@ case "${1:-}" in
|
||||||
esac
|
esac
|
||||||
|
|
||||||
tests_dir="${XDG_DOCUMENTS_DIR:-"$HOME"/Documents}/code-tests"
|
tests_dir="${XDG_DOCUMENTS_DIR:-"$HOME"/Documents}/code-tests"
|
||||||
tempdir="$tests_dir"
|
code_dir="$tests_dir"
|
||||||
mkdir -p "$tempdir"
|
|
||||||
ed_args=()
|
ed_args=()
|
||||||
if [ "$1" != -- ]; then
|
if [ "$1" != -- ]; then
|
||||||
filename="$1"; shift
|
filename="$1"; shift
|
||||||
dirname="${filename%%.*}"
|
dirname="${filename%%.*}"
|
||||||
date="$(date +%F)"
|
date="$(date +%F)"
|
||||||
|
|
||||||
tempdir_arr=("$tests_dir/"*"$dirname")
|
code_dir_arr=("$tests_dir/"*"$dirname")
|
||||||
tempdir="${tempdir_arr[0]:-"$tests_dir/$date-$dirname"}"
|
code_dir="${code_dir_arr[0]:-"$tests_dir/$date-$dirname"}"
|
||||||
|
|
||||||
# build an argument list for the editor
|
# build an argument list for the editor
|
||||||
ed_args=("$filename")
|
ed_args=("$filename")
|
||||||
fi
|
fi
|
||||||
|
mkdir -p "$code_dir"
|
||||||
|
|
||||||
cmds=("$SHELL")
|
cmds=("$SHELL")
|
||||||
for a;do
|
for a;do
|
||||||
|
@ -90,7 +90,7 @@ for a;do
|
||||||
ed_args+=("$a")
|
ed_args+=("$a")
|
||||||
done
|
done
|
||||||
|
|
||||||
cd "$tempdir"
|
cd "$code_dir"
|
||||||
|
|
||||||
if [ "${#ed_args[@]}" != 0 ]; then
|
if [ "${#ed_args[@]}" != 0 ]; then
|
||||||
# launch editor
|
# launch editor
|
||||||
|
@ -110,7 +110,7 @@ fi
|
||||||
# check if directory is empty. If it is, remove it.
|
# check if directory is empty. If it is, remove it.
|
||||||
filecount="$(find . -maxdepth 1 -print | wc -l)"
|
filecount="$(find . -maxdepth 1 -print | wc -l)"
|
||||||
if [ "$filecount" = 0 ]; then
|
if [ "$filecount" = 0 ]; then
|
||||||
rmdir "$tempdir"
|
rmdir "$code_dir"
|
||||||
else
|
else
|
||||||
backup_git .
|
backup_git .
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue