The problem
In the development work, terminals are often used to carry out various command operations. As time goes by, some familiar operations have developed muscle memory (don’t ask me what happened 🙄). In order to prevent some relatively unsafe commands from being incorrectly input and executed (when the original command does not add the confirmation function), I think I need a tool to help me add a step of confirmation to some commands.
rusure
Resure is a very simple scripting tool that works as a ZSH plug-in for now (more adaptations will be added in the future), so how do you use it?
The installation
-
Please install it in your ZSH plugin directory first, if your ZSH is installed using oh-my-zsh:
git clone <https://github.com/xuzhongping/rusure.git> ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/rusure Copy the code
-
Modify.zshrc files to open plugins:
The plugins = (... rusure)Copy the code
use
-
Configuration file located in: ${ZSH_CUSTOM: = ~ /. Oh – my – ZSH/custom} / plugins/rusure/ZSH/config. Yml, you are free to add more commands and custom tip copy:
cmds: - rm -rf ~ # - other cmd # You can customize your prompt text. ask: Are you sure? yes: Y no: N Copy the code
-
When you type a command and press Enter, if you press Settings, it automatically adds a leading command to your command:
> rm -rf ~ Copy the code
Press Enter to automatically convert to:
> rusure_exec rm -rf ~ are you sure? (Y/N):Copy the code
-
If you enter any combination of Y or YES, the original command will be executed, otherwise it will be cancelled.
> rusure_exec rm -rf ~ are you sure? (Y/N):N canced!Copy the code
-
Of course, you can also execute it by explicitly typing a lead command:
> rusure rm -rf ~ Copy the code
The statement
- Currently only ZSH is supported, and we hope to add more support environments in the future. If you find any problems or have good ideas to help, welcome!