Skip to content

✅ Are you sure? No? Confirm Before - Sanity check for your shell commands

License

Notifications You must be signed in to change notification settings

marceloboeira/confirm-before

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

No? Confirm Before

Sanity check for your shell commands

Installing

brew tap marceloboeira/formulas
brew install marceloboeira/formulas/confirm-before

Motivation

I have recently started working with a lot of DevOps CLIs that interact with staging and production servers.

My shell setup includes aliases like:

alias ks=`kubectl --context staging`
alias kp=`kubectl --context production`

However, I frequently find myself almost running something wrong by not paying attention if its production/staging. Therefore, I decided to create this small 'command wrapper' for me to make sure if I really want to run that command against production. e.g.:

alias kp=`confirm-before kubectl --context production`

Then, ...

$ kp apply -F *
Are you sure? (y/n)

Future

I might create other sanity check levels/modes:

$ alias dangerous=`confirm-before --math dangerous --production`
$ dangerous get foo
How much is 19 - 3?

Conditionals, because it can become very annoying to confirm read-only commands...

$ alias dangerous=`confirm-before --matching delete|d|rm|apply dangerous --production`
$ dangerous delete foo
Are you sure? (y/n)
...
$ dangerous get foo -> doesn't match the regexp