Last Updated: February 25, 2016
·
1.7K
· mkzero

Search your bash history

You can enable searching your bash history via arrow keys(or other keys) via the following commands(best served via .bashrc):

if [ -n "$PS1" ]; then
    bind '"\C-[[A": history-search-backward'
    bind '"\C-[[B": history-search-forward'
fi

So next time when typed half-way through your command, just hit your up-key. As an example:

$> ssh yo↑

This will search your bash history for commands starting with "ssh yo" on every up-keypress. So you might see:

$> ssh yo↑
$> ssh your-server↑
$> ssh your-other-server

2 Responses
Add your response

I have this on my system and I have no idea where it came from, but my instincts tell me it came with zsh.

over 1 year ago ·

@koddsson I'm not using zsh but I heard it brings this feature with it(or I guess at least oh-my-zsh does)

over 1 year ago ·