From f8ed994dd526a43175339ea7682207bd68824e53 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 4 Feb 2024 00:11:48 +0100 Subject: [PATCH] feat(bin): add ffc helper CLI tool --- bin/ffc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 bin/ffc diff --git a/bin/ffc b/bin/ffc new file mode 100755 index 0000000..5b6acbb --- /dev/null +++ b/bin/ffc @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -e + +# ffc - Files for ChatGPT + +# Check if any arguments are provided +if [ $# -eq 0 ]; then + echo "Usage: $0 ... " >&2 + exit 1 +fi + +shopt -s globstar nullglob + +# Iterate over provided arguments +for file_pattern in "$@"; do + # Use shell expansion to find matching files + for file in ./$file_pattern; do + if [ -f "$file" ]; then + rel_file="${file#./}" + echo '`'"$rel_file"'`:' + echo '```' + cat "$file" + echo '```' + echo + fi + done +done