diff --git a/cocopilot.sh b/cocopilot.sh index a7ab7a9..e59187e 100755 --- a/cocopilot.sh +++ b/cocopilot.sh @@ -9,6 +9,19 @@ else fi COPILOT_DIR="$CONFIG_DIR/github-copilot" + +# Check if the target file already exists +TARGET_FILE="$COPILOT_DIR/hosts.json" + +if [ -f "$TARGET_FILE" ]; then + read -p "The file $TARGET_FILE already exists. Do you want to overwrite it? [y/N] " -r + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo "Operation cancelled." + exit 1 + fi +fi + +# Create directory if [ ! -d "$COPILOT_DIR" ]; then mkdir -p "$COPILOT_DIR" fi