Skip to content

Instantly share code, notes, and snippets.

@samrolken
samrolken / get_context.sh
Created November 26, 2023 19:36
This is a little script I wrote for my own use. It gets source code files from the current directory and includes them in the output, filtering out huge source code files and sorting them by last modified. The idea is that this should grab the source code content for the code I'm working on up to a certain amount, so I can paste it into ChatGPT.
#!/bin/bash
# Parameters with default values
max_size=${1:-25} # Max size in kilobytes
output_size=${2:-50} # Max output size in kilobytes
# Extensions array - easy to add more extensions
declare -a extensions=("*.c" "*.cpp" "*.rb" "*.js")
# Temporary file to store intermediate results
#!/usr/bin/env bash
osascript -e 'tell application "System Preferences" to quit'
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

Keybase proof

I hereby claim:

  • I am samrolken on github.
  • I am samrolken (https://keybase.io/samrolken) on keybase.
  • I have a public key ASAKUhAe7piOd-99_fDP58Rk8r7dZk4g8-0LDt5Iig_gTwo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am samrolken on github.
  • I am samrolken (https://keybase.io/samrolken) on keybase.
  • I have a public key ASB0I2HEN5NyTj4FZj4xkqIrDte6XPSndm9AmGe5sFeHXgo

To claim this, I am signing this object:

#!/bin/sh
xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew list