Skip to content

Instantly share code, notes, and snippets.

@omaclaren
Created January 26, 2026 09:56
Show Gist options
  • Select an option

  • Save omaclaren/e14ac367e18360f47bf47f2adab8a360 to your computer and use it in GitHub Desktop.

Select an option

Save omaclaren/e14ac367e18360f47bf47f2adab8a360 to your computer and use it in GitHub Desktop.
Minimal bash function (add to .bashrc) to generate executable shell commands from natural language. Uses claude code in non-interactive mode (with -p). Can be adapted to other clis easily
# uses claude code and haiku but can be adpated easily
ccc() {
local r=$(claude -p "Output a bash one-liner between <cmd> and </cmd> tags to: $*" --model haiku)
local cmd=$(echo "$r" | sed -n '/<cmd>/,/<\/cmd>/p' | sed 's/<cmd>//;s/<\/cmd>//' | tr -d '\n')
echo "> $cmd"
read -p "[e]xecute | [c]opy | [q]uit: " c
[[ $c == e ]] && eval "$cmd"
[[ $c == c ]] && echo -n "$cmd" | pbcopy && echo "Copied."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment