Skip to content
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

[FEAT]: Replace confirmation request with explicit execution. #87

Open
seivan opened this issue Jul 5, 2024 · 1 comment
Open

[FEAT]: Replace confirmation request with explicit execution. #87

seivan opened this issue Jul 5, 2024 · 1 comment
Labels
enhancement New feature or request needs-triage needs to be reviewed

Comments

@seivan
Copy link

seivan commented Jul 5, 2024

By submitting this issue, you agree to follow our Code of Conduct.

Describe the need

The confirmation and print for history with use of --shell-out (default in ghcs) is unnecessary if the confirmation can just be execution.

Version

gh-copilot version 1.0.3 (2024-05-08)

Code

    TMPFILE="$(mktemp -t gh-copilotXXXXXX)"
    cleanup() {
      rm -f "$TMPFILE"
      unset TMPFILE FIXED_CMD

    }
    TMPFILE="$(mktemp -t gh-copilotXXXXXX)"
    trap cleanup EXIT
    if GH_DEBUG="$GH_DEBUG" GH_HOST="$GH_HOST" gh copilot suggest -t "$TARGET" "$@" --shell-out "$TMPFILE"; then
      if [ -s "$TMPFILE" ]; then
        FIXED_CMD="$(cat $TMPFILE)"
        print -z "$FIXED_CMD"
      fi
    else
      return 1
    fi

By using print -z we inline the command in the prompt and the user can confirm by executing it via enter.
This also removes print -s for storing it in history, as executing it should be enough.
Also removes the echo for a new line.

Also not sure why, but shouldn't TARGET, TMPFILE and FIXED_CMD be locals so they are unset after?

@seivan
Copy link
Author

seivan commented Jul 5, 2024

Fixes: #83

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-triage needs to be reviewed
Projects
None yet
Development

No branches or pull requests

1 participant