feat(fish): add GitHub Copilot CLI

This commit is contained in:
Stefan Imhoff
2023-03-07 17:56:58 +01:00
parent a0ecbf4710
commit 2e20ec1d36
4 changed files with 52 additions and 1 deletions

View File

@@ -156,7 +156,7 @@ if type nvim >/dev/null 2>&1
end
# TMUX
alias tx tmux
alias t tmux
alias mux tmuxinator
alias ms 'mux start'
alias ta 'tmux attach'
@@ -176,5 +176,11 @@ alias icloud "cd ~/Library/Mobile\ Documents/com~apple~CloudDocs"
# Clear the screen
alias c clear
# GitHub Copilot CLI
alias cpw copilot_what-the-shell
alias cpg copilot_git-assist
alias cpgh copilot_github-assist
alias wts copilot_what-the-shell
# Prompt
starship init fish | source

View File

@@ -0,0 +1,15 @@
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)
echo -s "$FIXED_CMD"
eval "$FIXED_CMD"
else
echo "Apologies! Extracting command failed"
end
else
return 1
end
end

View File

@@ -0,0 +1,15 @@
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)
echo -s "$FIXED_CMD"
eval "$FIXED_CMD"
else
echo "Apologies! Extracting command failed"
end
else
return 1
end
end

View File

@@ -0,0 +1,15 @@
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)
echo -s "$FIXED_CMD"
eval "$FIXED_CMD"
else
echo "Apologies! Extracting command failed"
end
else
return 1
end
end