In the terminal, when I press Ctrl+R to do a backward-search using the zsh/bash history, it searches all commands sorted by most recently used.

Problem is some commands are completely irrelevant to my current directory.

Is there a zsh/bash plugin or a way to configure the backward-search to take into account the timestamp AND the relative directory path in order to display relevant commands that I've previously typed in this directory?

1 Answer 1


You can try https://github.com/larkery/zsh-histdb, which records the start and stop times of each history item and the working directory where it took place, but its implementation of CtrlR is rather shaky. You probably will have to roll your own.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .