-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
History sub search in Bash #1506
Comments
I'm not familiar with these features in Fish and Zsh, but there has been a similar discussion here in #894. There are some great suggestions in that ticket. Personally, I use fzf with the Bash-it Please let me know if that helps. |
I've found that GNU Readline has a feature called history-substring-search-backward which is what I'm looking for: you can type any part of a previously entered command and press Up Arrow, it will complete it for you. Since Bash 4+ this feature is available.
Then, Ctrl+x Ctrl+r to reload configs from This is faster than using Ctrl + r 😄 The only thing is missing is the highlighting what has been matched. But I can live without that. Thanks |
Interesting - is there the concept of a configurable Would it be possible to include this as a plugin / feature so someone could use bash-it instead of manually adding a line to their |
@jpmcb It's also possible to active it in ~/.bashrc like this: bind '"\e[A": history-substring-search-backward'
bind '"\e[B": history-substring-search-forward' So we don't need the ~/.inputrc anymore. It's possible to create a plugin to activate this. |
Exactly - these two lines would need to be defined in a plugin, e.g. |
OK, looks like we already have that: https://github.com/Bash-it/bash-it/blob/master/plugins/available/history.plugin.bash You can enable that with |
@nwinkler Thanks so much for making bash-it. I had tried out fish shell before and was looking for something like this for bash. I'm not clear what I need to change to make the history plugin use the substring part as you described above. Please could you describe how to do it for a bash-it newbie! |
@mcarans You just need to enable the plugin and reload your shell (or start a new one): $ bash-it enable plugin history
$ bash-it reload You may also enjoy our new documentation at https://bash-it.readthedocs.io/en/latest/ |
@cornfeedhobo The problem is that the current history plugin uses history-search-backward not history-substring-search-backward (https://github.com/Bash-it/bash-it/blob/master/plugins/available/history.plugin.bash). Is there a way to modify the installed history plugin to use history-substring-search-backward? |
@mcarans The original post asked:
That is exactly what the history plugin does. When I type Are you looking for something different? |
@cornfeedhobo That works for me! Out of interest what would the addition of substring do if anything? |
@cornfeedhobo I found the answer here history-search-backward: The search string must match at the beginning of a history line It seems to me like history-substring-search-backward is more useful. Is there any way I can change the installed plugin to use history-substring-search-backward? |
@mcarans Sorry got pulled away. Looks like you figured it out - substring means that if you type in I definitely think we can work something in to address this option, just need to think of the most elegant way to expose that option to users. I'm not sure if I'd prefer breaking up history into different plugins, or using an environment variable to toggle the functionality. @tbhaxor @nwinkler @NoahGorny @davidpfarrell any thoughts? |
@cornfeedhobo I'd go with an environment variable to change which command is being used. Adding a second plugin will lead to further complexity, e.g. when people enable both plugins. Using an environment variable, we can have a defined default behavior and also an easy option for overriding things. A couple of items to address:
|
Since I was waiting around and ended up coming to the opposite conclusion, I'm going to continue that discussion in #1764, at least until we decide if we want to go with that route or another one. Thanks everyone! |
Does anybody know a history sub search plugin for Bash?
In Fish and Zsh there is a plugin called history-substring-search that you can type part of a sentence and press Up Arrow, it will complete the sentence according to history and highlight the matching words.
I miss it in Bash. I already use Ctrl+R but it not the same, I don't feel productive.
The text was updated successfully, but these errors were encountered: