Single command to search bash history

In most of the commands that I wrote daily on my console,

# history | grep -i 'something' 

This and ctr+r are probably what I use the most :).

I thought something like

 # h something 

Or even better, a live search such as ctr + r, but which shows all the results at a glance, not just one. I know I can press ctrl+r again, but it would be better if I could see what all the elements that I ride a bicycle are.

So these are 2 questions:

1) Do you know any program that provides the best interface for bash history in the console?

2) What is the best way to accomplish my alias h something ?

+5
source share
4 answers

Want a team h . Just add an alias to .bashrc or .bash_profile or .bash_aliases (depending on your configuration).

 alias h="history | grep -i" 
+2
source

You might want to try https://github.com/dvorka/hstr , which is a "suggest box style" filtering bash history - you get hh 'something' - for example hh an :

enter image description here

It can be easily associated with Ctrl-r and / or Ctrl-s

+1
source

One way to do h something add to .bash_profile :

  alias h="history | grep -i " 

I actually use zsh, but I think it will work too.

0
source

In my .bash_profile the following is set:

set -o vi

then I have a vi function from the command line

Pressing the ESCape key followed by k will return the last line entered

Esc-k

keep pressing k to scroll up. The magic happens when you press the slash key (/). Then you can search your story

http://www.thegeekstuff.com/2009/10/do-you-like-to-perform-vi-style-editing-in-bash-command-line/

0
source

Source: https://habr.com/ru/post/1206268/


All Articles