Skip to content

Instantly share code, notes, and snippets.

@ryoppippi
Created March 25, 2023 13:26
Show Gist options
  • Save ryoppippi/96970e9a295cf13beb07180016eab1bd to your computer and use it in GitHub Desktop.
Save ryoppippi/96970e9a295cf13beb07180016eab1bd to your computer and use it in GitHub Desktop.
Copilot CLI for fish
function github-copilot_helper
set -l TMPFILE (mktemp)
trap 'rm -f $TMPFILE' EXIT
if github-copilot-cli $argv[1] "$argv[2..]" --shellout $TMPFILE
if [ -e "$TMPFILE" ]
set -l FIXED_CMD (cat $TMPFILE)
eval "$FIXED_CMD"
else
echo "Apologies! Extracting command failed"
end
else
return 1
end
end
function qf
set -l prev_cmd (history | head -n 1)
echo "Previous command: $prev_cmd"
github-copilot_helper what-the-shell "correct the following commands {$prev_cmd}"
end
alias q 'github-copilot_helper what-the-shell'
alias qgit 'github-copilot_helper git-assist'
alias qgh 'github-copilot_helper gh-assist'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment