Created
March 25, 2023 13:26
-
-
Save ryoppippi/96970e9a295cf13beb07180016eab1bd to your computer and use it in GitHub Desktop.
Copilot CLI for fish
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
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