terminal icon indicating copy to clipboard operation
terminal copied to clipboard

"Close this terminal with Ctrl+D, press Enter to restart, OR CTRL+SHIFT+ENTER TO RESTART AS ADMIN."

Open e-t-l opened this issue 1 year ago • 2 comments

Description of the new feature/enhancement

When closeOnExit: "never", exiting a Terminal process outputs the message, "You can now close this terminal with Ctrl+D, or press Enter to restart." This enhancement is to suggest expanding this functionality with the self-explanatory, "or press Ctrl+Shift+Enter to restart as Administrator."

One example where this would be very helpful is when a user runs unelevated a CLI program, batch file, etc. that requires elevation to perform properly. This currently returns "Access is denied." and the user has to go relaunch the program with deliberate elevation (for example, by right-clicking the program shortcut and clicking "Run as administrator"). Instead, I propose that the user could simply press Ctrl+Shift+Enter to re-run the same command/program with elevation.

For a long time in Windows, users have been able to Ctrl+Shift+click on a batch file or shortcut to launch it elevated, or press Ctrl+Shift+Enter to run a command with elevation from the Win+R Run dialog. It would be consistent and intuitive UX to provide users a similar keyboard combination to elevate the command from within Terminal itself.

Proposed technical implementation details (optional)

I imagine this would involve something along the lines of replacing the current Terminal process/tab with one that is elevated to Administrator privileges but otherwise identical, and re-running the initial command that called it (if any).

Ideally it would also pass along any variables and such from the exited process. In this way, it would function similar to gsudo. (This bit, while more complex to implement, could partially address #146 as well.)

e-t-l avatar Jan 27 '24 04:01 e-t-l

Okay so jotting down some notes:

  • you've got a commandline that requires elevation to work right.
  • You stuck that in a profile.
  • you didn't set elevate: true on the profile with that commandline
  • when you opened a tab/pane with that profile, the command exited with an error (cause it wasn't elevated)
  • you want the error message to also give you a prompt to launch the profile as admin instead

I suppose the question I have is: why not just set elevate:true on the profile, if you've already got a command that you know requires admin permissions?

zadjii-msft avatar Feb 06 '24 22:02 zadjii-msft

Okay so jotting down some notes

...Did you, though? Because the 2nd and 3rd paragraphs of my post described multiple examples and use cases outside of the one specific scenario that your comment is about.

If I was unclear or if you'd like to discuss similar use cases in more detail, I'm more than happy to contribute to that discussion.

if you've already got a command that you know requires admin permissions?

To answer the question I'll assume you're asking in good faith: just like in the scenarios I described in my first post, this would be most useful for the typical user who runs a CLI app, batch file, or Win+R command without realizing it required elevation. The scenario you described, where a user deliberately launches Terminal.exe in a specific profile configuration, is not the focus of this issue.

e-t-l avatar Feb 07 '24 05:02 e-t-l