DEV Community

Cover image for Tip 2: History Forgets Common Commands
David McKay
David McKay

Posted on

1 1

Tip 2: History Forgets Common Commands

With Tip 1, we looked at how we can switch our history between local directory and global.

Regardless of which you're using, some stuff just doesn't belong there; right?

Do you really use to Control + r or Up to find ls, cd, or rm?

No. The answer is no.

Keeping History Clean

Here are 3 short and sweet options you can configure in your zshrc file to keep your history lean, mean, and clean.

Forget Duplicate Commands

Zsh can de-duplicate your command history 😄

Enable this behaviour with setopt HIST_IGNORE_DUPS

Forget Common Commands

The next approach to keeping our history clean is using HISTIGNORE.

HISTIGNORE="&:ls:[bf]g:exit:reset:clear:cd:cd ..:cd..:zh"
Enter fullscreen mode Exit fullscreen mode

This is a global list of commands and patterns that you don't want to keep.

Use this for all your trivial commands that don't warrant searching later.

Forget Space Commands

Another great feature of Zsh is hiding commands preceding with a Space

Enable this behaviour with setopt HIST_IGNORE_SPACE

# Not stored in history
 ls

# Stored in history
ls
Enter fullscreen mode Exit fullscreen mode

You can find more examples of tweaking your history here

👋 While you are here

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (0)

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay