'Generic Commit'
Some checks failed
Build-Test-Publish / build (push) Failing after 26s

This commit is contained in:
Your Name
2025-06-15 19:24:39 +12:00
parent 25aff1baab
commit 1362f03462
2 changed files with 182 additions and 4 deletions

View File

@ -8,11 +8,48 @@
# for each git repo print the name of the repo, the datestamp of the last commit,
# the nubmer of changes since then, and whether it's clean or not.
# if no argument is provided, use the current directory
DIR="${1:-.}"
# Configuration file path
CONFIG_FILE="$HOME/.config/whatsdirty.conf"
# make directory canonical
DIR=$(cd "$DIR" 2>/dev/null && pwd) || { echo "Error: Directory '$1' not found"; exit 1; }
# Function to save directory to config
save_directory() {
local dir="$1"
mkdir -p "$(dirname "$CONFIG_FILE")"
echo "$dir" > "$CONFIG_FILE"
}
# Function to load directory from config
load_directory() {
if [ -f "$CONFIG_FILE" ]; then
cat "$CONFIG_FILE"
fi
}
# Determine which directory to use
if [ $# -eq 0 ]; then
# No argument provided - try to load from config
SAVED_DIR=$(load_directory)
if [ -z "$SAVED_DIR" ]; then
echo "Error: No directory specified and no saved directory found."
echo "Usage: $0 <directory>"
echo "The specified directory will be saved for future use."
exit 1
fi
DIR="$SAVED_DIR"
else
# Argument provided - use it and save to config
DIR="$1"
# Validate and canonicalize the directory first
DIR=$(cd "$DIR" 2>/dev/null && pwd) || { echo "Error: Directory '$1' not found"; exit 1; }
save_directory "$DIR"
fi
# Make sure directory is canonical (in case loaded from config)
DIR=$(cd "$DIR" 2>/dev/null && pwd) || {
echo "Error: Saved directory '$DIR' no longer exists";
rm -f "$CONFIG_FILE"
exit 1;
}
# Color codes
RED='\033[0;31m'