Skip to content

Instantly share code, notes, and snippets.

@LaptopDev
Created April 1, 2025 19:00
Show Gist options
  • Save LaptopDev/5e4310e4b76f333df05aa0cf059a2b1e to your computer and use it in GitHub Desktop.
Save LaptopDev/5e4310e4b76f333df05aa0cf059a2b1e to your computer and use it in GitHub Desktop.
shell function for kitty to dump the pane screen content to new file to prevent overwrite
dump ()
{
local id="$1";
local dir="/tmp/pane_dump";
local base="pane";
local index=1;
local file;
if [ -z "$id" ]; then
echo "Usage: dump <pane-id>" 1>&2;
return 1;
fi;
mkdir -p "$dir";
while [ -e "$dir/${base}${index}" ]; do
index=$((index + 1));
done;
file="$dir/${base}${index}";
kitty @ get-text --match id:"$id" --extent=all > "$file";
echo "Dumped to $file";
cat "$file"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment