Skip to content

Instantly share code, notes, and snippets.

@kevincolten
Last active July 22, 2025 16:21
Show Gist options
  • Save kevincolten/9cf524f5022f0d5aa838a0bcb85274b5 to your computer and use it in GitHub Desktop.
Save kevincolten/9cf524f5022f0d5aa838a0bcb85274b5 to your computer and use it in GitHub Desktop.
GH Copilot on zsh command line
function ghc() {
local output=$(printf '\n\n' | gh copilot suggest -t shell "$*" 2>&1)
local suggested_command=$(echo "$output" | awk '/# Suggestion:/{getline; getline; gsub(/^[ \t]+/, ""); gsub(/[ \t]+$/, ""); if(NF>0) {printf "%s", $0; exit}}')
[ -n "$suggested_command" ] && print -z "$suggested_command"
}
@kevincolten
Copy link
Author

example:

~ ❯❯❯ ghc please tell me how to get the status of a git repo
~ ❯❯❯ git status

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment