-
Notifications
You must be signed in to change notification settings - Fork 29
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: Bash alias for ghcs
doesn't maniuplate history correctly
#65
Comments
@bewuethr : thank you for opening this issue, this makes sense! 🙇 🤔 I see what you mean as I was able to reproduce this on Mac OS with Bash 5.2; in my version below the command's history ID is captured: bash-5.2$ eval "$(gh copilot alias -- bash)"
bash-5.2$ ghcs print "hello world"
Welcome to GitHub Copilot in the CLI!
version 1.0.1 (2024-03-22)
I'm powered by AI, so surprises and mistakes are possible. Make sure to verify any generated code or suggestions, and share feedback so that we can learn and improve. For more information, see https://gh.io/gh-copilot-transparency
Suggestion:
echo "Hello, world!"
? Select an option
> Execute command
? Are you sure you want to execute the suggested command?
> Yes
Hello, world!
bash-5.2$ history 5
8 gh copilot alias --help
9 eval "$(gh copilot alias -- bash)"
10 10 ghcs print "hello world"
11 echo "Hello, world!"
12 history 5
bash-5.2$ export HISTTIMEFORMAT="%F %T "
bash-5.2$ history 5
10 2024-04-10 21:27:31 10 ghcs print "hello world"
11 2024-04-10 21:27:31 echo "Hello, world!"
12 2024-04-10 21:27:34 history 5
13 2024-04-10 21:27:44 export HISTTIMEFORMAT="%F %T "
14 2024-04-10 21:27:47 history 5
bash-5.2$ 10 ghcs print "hello world" Reviewing the logic within the if [ -s "$TMPFILE" ]; then
FIXED_CMD="$(cat $TMPFILE)"
history -s $(history 1 | cut -d' ' -f4-); history -s "$FIXED_CMD"
echo
eval "$FIXED_CMD"
fi Since GA, we've discussed a different approach to executing commands through interactive shells, which hopefully works around th need to preserve the history this way. |
What happened?
When looking at the shell history after using
ghcs
, theghcs
command itself seems to contain one extra field from history: the command number, or ifHISTTIMEFORMAT
is set, some timestamp.My history related shell settings:
Versions
Relevant terminal output
Running a command and looking at the three most recent commands in history:
Notice how the third most recent command incorrectly includes the timestamp:
13:52:20 ghcs 'print "Hi"'
The text was updated successfully, but these errors were encountered: