Skip to content

Instantly share code, notes, and snippets.

@do-me
Created October 9, 2025 09:19
Show Gist options
  • Save do-me/c9db917d80c64c25e024fdcbd98cae71 to your computer and use it in GitHub Desktop.
Save do-me/c9db917d80c64c25e024fdcbd98cae71 to your computer and use it in GitHub Desktop.
A shell scirpt cloning a github repo, running yek to copy all text files to clipboard, then deleting the repo for easy pasting in Gemini or other long context models
#!/bin/bash
# Usage: clone_yek_copy <github_repo_url>
# Description: Clones a GitHub repo, runs `yek | pbcopy`, then deletes the repo.
set -e
# --- 1️⃣ Check for URL argument ---
if [ -z "$1" ]; then
echo "Usage: $0 <github_repo_url>"
exit 1
fi
repo_url="$1"
repo_name=$(basename -s .git "$repo_url")
# --- 2️⃣ Detect OS and set clipboard command ---
if command -v pbcopy &> /dev/null; then
CLIP_CMD="pbcopy"
elif command -v xclip &> /dev/null; then
CLIP_CMD="xclip -selection clipboard"
elif command -v wl-copy &> /dev/null; then
CLIP_CMD="wl-copy"
else
echo "❌ No clipboard command found! Install pbcopy (macOS), xclip or wl-clipboard (Linux)."
exit 1
fi
# --- 3️⃣ Clone the repo ---
echo "📥 Cloning $repo_url..."
git clone "$repo_url"
cd "$repo_name"
# --- 4️⃣ Run yek and copy output ---
if ! command -v yek &> /dev/null; then
echo "❌ 'yek' not found! Please install it first."
cd ..
rm -rf "$repo_name"
exit 1
fi
echo "⚙️ Running yek and copying output..."
yek | $CLIP_CMD
# --- 5️⃣ Clean up ---
cd ..
rm -rf "$repo_name"
echo "🧹 Deleted cloned repo."
echo "✅ Done! Output copied to clipboard."
@do-me
Copy link
Author

do-me commented Oct 9, 2025

  1. create the file copygit.sh locally
  2. make it executable with chmod +x copygit.sh
  3. move to local bin with `sudo mv copygit.sh /usr/local/bin/copygit
  4. run with copygit https://github.com/do-me/SemanticFinder

Output:

(base) ➜  Downloads copygit https://github.com/edjnet/quotefinder
📥 Cloning https://github.com/edjnet/quotefinder...
Cloning into 'quotefinder'...
remote: Enumerating objects: 866, done.
remote: Counting objects: 100% (231/231), done.
remote: Compressing objects: 100% (162/162), done.
remote: Total 866 (delta 133), reused 147 (delta 66), pack-reused 635 (from 1)
Receiving objects: 100% (866/866), 1.55 MiB | 15.86 MiB/s, done.
Resolving deltas: 100% (524/524), done.
⚙️  Running yek and copying output...
🧹 Deleted cloned repo.
✅ Done! Output copied to clipboard.

This one takes less than 1 sec on my system 0.10s user 0.11s system 28% cpu 0.735 total

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment