DEV Community

Richard
Richard

Posted on

3 4

So you made a typo in the console...

So here is a cool thing you can do in #bash or in any #cli or #commandline that I am aware of.

Here is an example, lets create an arbitrary BASH command with a nice obvious typo in it. I'll create some generic files:

touch cyan-swatch.txt maagenta-swatch.txt yellow-swatch.txt black-swatch.txt
Enter fullscreen mode Exit fullscreen mode

Oops, I made a boo-boo, see it? I mis-spelled the word magenta.

So, most people know you can press the ↑ up-arrow and it will show your last-typed command. But then you have to scroll alllll the way over to where you made the typo and manually remove the extra letter or whatever it is you have to do. But there is a better way!

Wouldn't it be cool if there was a way to tell the CLI, "Hey, I need you to replace this thing with this thing in my last command."

Here it is:

^maagenta^magenta
Enter fullscreen mode Exit fullscreen mode

This command will take the last command, substitute the first string maagenta with magenta, and run the command again.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay