Copy All Files from Current Directory for Quick Context Sharing

A small bash script that copies all files in a directory to your clipboard. Perfect for quickly sharing Kubernetes manifests or config files without the hassle of opening them one by one.

The Problem

All the apps I host in my HomeLab are deployed using Kubernetes manifests stored in my GitHub repository. While it's possible to combine multiple manifests into a single YAML file with document separators, I prefer to keep each manifest in its own file for better organization and readability.

The downside of this approach is that, when I want to share my entire configuration with an LLM, manually opening and copying each file becomes tedious.

So, I added to my workflow a tiny bash script to solve this.

The Solution

#!/bin/bash

(
  cd .
  for file in $(find . -type f); do
    echo "===== $file ====="
    cat "$file"
    echo
  done
) | xclip -selection clipboard

echo "All file contents were copied to the clipboard"

I saved this script to my /local/bin/ directory and created a simple alias in my .bashrc so I can run it from anywhere using the caf command (short for "Copy All Files"). It's a small addition to my workflow, but it saves time and helps me get more effective assistance when using LLMs.

If you're interested in more utility scripts like this one, check out my CodeLab repository where I share other tools and coding experiments.