Add module "please"
This adds the command `please` and the key binding `Ctrl+Shift+S`. Both of them are for executing the previous command with super user privileges.
This commit is contained in:
parent
9539341e1e
commit
06c6f1eb60
2 changed files with 32 additions and 0 deletions
27
modules/please/Readme.md
Normal file
27
modules/please/Readme.md
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Please
|
||||
This adds utilities for runnning the previous command with super powers.
|
||||
|
||||
## Usage
|
||||
|
||||
### Please command
|
||||
The `please` command simply repeats the previous command preceded by sudo.
|
||||
|
||||
Warning: You should be aware of the fact that this is also done in a shell that you just opened and you don't see what you execute with root privileges.
|
||||
```shell
|
||||
❯ id
|
||||
uid=501(eugenk) gid=20(staff)
|
||||
|
||||
❯ please
|
||||
uid=0(root) gid=0(wheel)
|
||||
```
|
||||
|
||||
### Key binding
|
||||
There is also a keybinding (`Ctrl+Shift+S`) that puts your previous command to the commandline and prepends `sudo ` to it.
|
||||
This is useful when you want so see or edit your previous command before executing it.
|
||||
```shell
|
||||
❯ id
|
||||
uid=501(eugenk) gid=20(staff)
|
||||
|
||||
[Ctrl+Shift+S yields:]
|
||||
❯ sudo id
|
||||
```
|
5
modules/please/init.zsh
Normal file
5
modules/please/init.zsh
Normal file
|
@ -0,0 +1,5 @@
|
|||
alias please='sudo $(fc -ln -1)'
|
||||
|
||||
previous_command_with_sudo() { zle beginning-of-line; zle -U "sudo $(fc -ln -1)" }
|
||||
zle -N previous-command-with-sudo previous_command_with_sudo
|
||||
bindkey "^S" previous-command-with-sudo # Ctrl+Shift+S
|
Loading…
Add table
Reference in a new issue