From f4d79aaec773be9020270a6f8466e2be82847efe Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Fri, 30 May 2025 15:04:16 -0700 Subject: [PATCH] ted: better git commits & variable names --- .config/shell/bin/ted | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.config/shell/bin/ted b/.config/shell/bin/ted index 4b248d2..d801ce0 100755 --- a/.config/shell/bin/ted +++ b/.config/shell/bin/ted @@ -14,13 +14,13 @@ ed() { } backup_git() { - cd "${1:-}" + cd "$1" if command -v git > /dev/null; then # 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 git add "$1" - git commit -m "ted-backup: add $dirname" + git commit -m "ted-backup($dirname): add files" || true git push fi } @@ -64,20 +64,20 @@ case "${1:-}" in esac tests_dir="${XDG_DOCUMENTS_DIR:-"$HOME"/Documents}/code-tests" -tempdir="$tests_dir" -mkdir -p "$tempdir" +code_dir="$tests_dir" ed_args=() if [ "$1" != -- ]; then filename="$1"; shift dirname="${filename%%.*}" date="$(date +%F)" - tempdir_arr=("$tests_dir/"*"$dirname") - tempdir="${tempdir_arr[0]:-"$tests_dir/$date-$dirname"}" + code_dir_arr=("$tests_dir/"*"$dirname") + code_dir="${code_dir_arr[0]:-"$tests_dir/$date-$dirname"}" # build an argument list for the editor ed_args=("$filename") fi +mkdir -p "$code_dir" cmds=("$SHELL") for a;do @@ -90,7 +90,7 @@ for a;do ed_args+=("$a") done -cd "$tempdir" +cd "$code_dir" if [ "${#ed_args[@]}" != 0 ]; then # launch editor @@ -110,7 +110,7 @@ fi # check if directory is empty. If it is, remove it. filecount="$(find . -maxdepth 1 -print | wc -l)" if [ "$filecount" = 0 ]; then - rmdir "$tempdir" + rmdir "$code_dir" else backup_git . fi