SudoEsc is a PowerShell module that allows you to quickly prepend 'sudo' to your last command by double-pressing the Escape key. This is particularly useful for Windows users who frequently need to elevate their commands using gsudo or similar tools.
- Double-press Escape to prepend 'sudo' to the last command
- Easy to enable and disable
- Automatic update checks
You can install SudoEsc directly from the PowerShell Gallery:
Install-Module -Name SudoEsc -Scope CurrentUser
SudoEsc is designed to work with Windows PowerShell and PowerShell Core on Windows systems.
IMPORTANT: For SudoEsc to function correctly, you must have a sudo-equivalent tool installed and available in your system path. We recommend using gsudo, a sudo equivalent for Windows.
To install gsudo, you can use the following command in PowerShell:
winget install gerardog.gsudo
-
Import the module:
Import-Module SudoEsc
-
Enable the SudoEsc functionality:
Enable-SudoEsc
-
Use your PowerShell session as normal. When you need to elevate a command, simply double-press the Escape key. For example:
Get-Content C:\Windows\System32\drivers\etc\hosts # Double-press Esc sudo Get-Content C:\Windows\System32\drivers\etc\hosts
-
If you didn't choose to add SudoEsc to your profile during the initial setup, you can do it later by running:
Add-SudoEscToProfile
-
To disable the functionality:
Disable-SudoEsc
When enabled, SudoEsc sets up a key handler for the Escape key. If you press Escape twice within 300 milliseconds, it will take your last command (either from the current line or from history), prepend 'sudo' to it, and execute it.
SudoEsc will automatically check for updates when the module is imported. You can update the module using:
Update-Module SudoEsc
- PowerShell 5.1 or later
- Windows PowerShell or PowerShell Core
- gsudo or similar sudo-equivalent tool for Windows
If you encounter any issues:
- Ensure you have the latest version of SudoEsc installed.
- Check that gsudo or your preferred sudo-equivalent tool is installed and available in your system path.
- If the double-Esc doesn't work, try disabling and re-enabling the functionality:
Disable-SudoEsc Enable-SudoEsc
Contributions are welcome! Please feel free to submit a Pull Request. Here's how you can contribute:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by the sudo plugin for Oh My Zsh
- Thanks to all contributors and users of SudoEsc