Reset bash history search position

亡梦爱人 提交于 2019-12-23 08:45:23

问题


In a terminal the Bash history can be searched easily with Ctrl+r. But what if I cannot find what I am looking for? I am stuck in the middle of my history. What if a want to search again from the beginning?

Is there another shortcut to reset the history search?


回答1:


There is Meta + >, which is bound to end-of-history and useful if you're in the middle of your history. The meta key is usually the Alt key.

If you see that your incremental history search isn't successful, you can use Ctrl + G, which is bound to abort and restores the previous line and history position.

Check the manual for more commands like these.




回答2:


This may be a somewhat indirect answer, but I usually use Ctrl+c to exit the history search. This cancels your entire line entry, leaving you on a fresh prompt with no input on the line, and back at the end of the history list.



来源:https://stackoverflow.com/questions/34793704/reset-bash-history-search-position

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!