-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathgithub-copilot-cli-aliases.inc
52 lines (49 loc) · 1.32 KB
/
github-copilot-cli-aliases.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
copilot_what-the-shell () {
TMPFILE=$(mktemp);
trap 'rm -f $TMPFILE' EXIT;
if /opt/homebrew/bin/github-copilot-cli what-the-shell "$@" --shellout $TMPFILE; then
if [ -e "$TMPFILE" ]; then
FIXED_CMD=$(cat $TMPFILE);
print -s "$FIXED_CMD";
eval "$FIXED_CMD"
else
echo "Apologies! Extracting command failed"
fi
else
return 1
fi
};
alias '??'='copilot_what-the-shell';
copilot_git-assist () {
TMPFILE=$(mktemp);
trap 'rm -f $TMPFILE' EXIT;
if /opt/homebrew/bin/github-copilot-cli git-assist "$@" --shellout $TMPFILE; then
if [ -e "$TMPFILE" ]; then
FIXED_CMD=$(cat $TMPFILE);
print -s "$FIXED_CMD";
eval "$FIXED_CMD"
else
echo "Apologies! Extracting command failed"
fi
else
return 1
fi
};
alias 'git?'='copilot_git-assist';
copilot_gh-assist () {
TMPFILE=$(mktemp);
trap 'rm -f $TMPFILE' EXIT;
if /opt/homebrew/bin/github-copilot-cli gh-assist "$@" --shellout $TMPFILE; then
if [ -e "$TMPFILE" ]; then
FIXED_CMD=$(cat $TMPFILE);
print -s "$FIXED_CMD";
eval "$FIXED_CMD"
else
echo "Apologies! Extracting command failed"
fi
else
return 1
fi
};
alias 'gh?'='copilot_gh-assist';
alias 'wts'='copilot_what-the-shell';