Skip to content

Instantly share code, notes, and snippets.

@chmouel
Last active November 6, 2025 09:29
Show Gist options
  • Select an option

  • Save chmouel/d2dd4ebea0782ce61d93e1d22a9995cf to your computer and use it in GitHub Desktop.

Select an option

Save chmouel/d2dd4ebea0782ce61d93e1d22a9995cf to your computer and use it in GitHub Desktop.
paste image from clipboard

Work with Claude Code / Gemini / Codex CLI

make claude code ctrl+v works on linux to let claude see your current image (or any other ai cli really)

assuming you have tmp/ in the root of your repository added to your gitgnore

put that shell function to your .zshrc or .bashrc. make sure you have wl-paste, wtype and notify-send packages installed (should be std in any standard distro).

and add this to kitty

map ctrl+alt+v            launch --type=background --cwd=current -- zsh -ic "pasteimage -g"

or when using bash

map ctrl+alt+v            launch --type=background --cwd=current -- bash -ilc "pasteimage -g"

just press ctrl+alt+v when you are in claude code and it would show the [Image #1] thing:


 ▐▛███▜▌   Claude Code v2.0.33
▝▜█████▛▘  Sonnet 4.5 · API Usage Billing
  ▘▘ ▝▝    /home/chmouel/git/perso/stuff

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
> [Image #1] 
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ⏵⏵ accept edits on (shift+tab to cycle)       
function pasteimage(){
local gui= msg=
[[ -n ${1} && ${1} == -g ]] && gui=yes
(
cd "$(git rev-parse --show-toplevel)" || {
msg="Could not find git root"
[[ -n ${gui} ]] && notify-send -u critical "pasteimage" "${msg}" || echo "${msg}" >&2
return 1
}
mkdir -p tmp/s/ || {
msg="Could not create tmp/s/ directory"
[[ -n ${gui} ]] && notify-send -u critical "pasteimage" "${msg}" || echo "${msg}" >&2
return 1
}
random="tmp/s/$(mktemp -u pasted-image-XXXXXX).png"
if wl-paste > "${random}";then
frandom=$(readlink -f "${random}")
if [[ -n ${gui} ]];then
notify-send -u normal "pasteimage" "Image saved to $(realpath --relative-to="$(groot)" "${random}") and path copied to clipboard"
echo -n "${frandom}" | wl-copy
wtype -M ctrl -M shift v
fi
else
rm -f "${random}"
msg="Could not find image in clipboard"
[[ -n ${gui} ]] && notify-send -u critical "pasteimage" "${msg}" || echo "${msg}" >&2
return 1
fi
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment