Created
January 26, 2026 09:56
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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