Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
考虑到我已经按此顺序成功运行了这两个命令(但可能是很多命令之前):
~% ssh localhost echo ~% sshfs localhost:/ /media/copy-of-root
现在我想重新运行该ssh命令。我的第一直觉是使用!ssh,但这将与sshfs命令匹配。
ssh
!ssh
sshfs
是否有历史扩展版本将匹配整个第一个单词而不是命令的前缀?如果没有,是否有其他可靠的方法来选择ssh命令而不是命令sshfs?
好吧,如果您搜索ssh(带有尾随空格)它会找到它。IMO 最好的选择是绑定up和down到up-line-or-search和down-line-or-search。
up
down
up-line-or-search
down-line-or-search
bindkey '^[[A' up-line-or-search # check the exact code for your UP key...
然后你只需使用:
% SSH [上]
ssh这将在您的历史记录中搜索。如果那不是您想要的历史实例,请继续搜索(即点击“UP”)。