dotfiles/.config/fish/conf.d/github-copilot-cli.fish
2023-11-13 21:17:35 +01:00

47 lines
1.2 KiB
Fish

function __copilot_what-the-shell
set TMPFILE (mktemp)
trap 'rm -f $TMPFILE' EXIT
if github-copilot-cli what-the-shell $argv --shellout $TMPFILE
if test -e $TMPFILE
set FIXED_CMD (cat $TMPFILE)
eval $FIXED_CMD
else
echo "Apologies! Extracting command failed"
end
else
return 1
end
end
alias '!!'='__copilot_what-the-shell'
function __copilot_git-assist
set TMPFILE (mktemp)
trap 'rm -f $TMPFILE' EXIT
if github-copilot-cli git-assist $argv --shellout $TMPFILE
if test -e $TMPFILE
set FIXED_CMD (cat $TMPFILE)
eval $FIXED_CMD
else
echo "Apologies! Extracting command failed"
end
else
return 1
end
end
alias 'git!'='__copilot_git-assist'
function __copilot_gh-assist
set TMPFILE (mktemp)
trap 'rm -f $TMPFILE' EXIT
if github-copilot-cli gh-assist $argv --shellout $TMPFILE
if test -e $TMPFILE
set FIXED_CMD (cat $TMPFILE)
eval $FIXED_CMD
else
echo "Apologies! Extracting command failed"
end
else
return 1
end
end
alias 'gh!'='__copilot_gh-assist'