Rom*_*kov 4 ubuntu bash terminal
如果我在当前目录中有一个以“build”开头的长名称文件,我可以在控制台“build”中写入,按Tab并自动完成为我输入完整文件名。但是,如果我有多个以build
自动完成开头的文件,则自动完成功能不起作用 - 它只是为我提供了以build
.
相反,在 Windows 中,按Tab键会立即给出第一个文件的完整文件名,如果我Tab第二次按 键,它会给出第二个文件名。
如何在 Linux 中像在 Windows 中一样自动完成文件名?PS:如果我有几个仅扩展名不同的长文件名,那真的很糟糕。
对我来说,救命稻草就是让 bash 循环遍历各种可能性,而不是显示一个愚蠢的列表。
\n\n由于 bash 使用readline
自动完成功能,因此将以下行添加到~/.inputrc
一旦您满意并彻底测试了以下解决方案几天/几周,请剪切并粘贴(不要复制!)包含系统范围设置的相同设置~/.inputrc
,/etc/inputrc
使其可供所有用户使用你的系统。
# mappings to have up and down arrow searching through history:\n"\\e[A": history-search-backward\n"\\e[B": history-search-forward\n# mappings to have left and right arrow go left and right: \n"\\e[C": forward-char\n"\\e[D": backward-char\n\n# mapping to have [Tab] and [Shift]+[Tab] to cycle through all the possible completions:\n"\\t": menu-complete\n"\\e[Z": menu-complete-backward\n
Run Code Online (Sandbox Code Playgroud)\n\n然后exit
你的终端(或远程终端,如腻子)并再次打开它......
当您有 3 个文件时:file1
,file2
并且file3
您键入:
e fTabTabTab
Run Code Online (Sandbox Code Playgroud)\n\n它将向前循环:
\n\ne file1\ne file2\ne file3\n
Run Code Online (Sandbox Code Playgroud)\n\n当你想向后循环时,只需按Shift+Tab
当您输入:
\n\nvery-complicated-command with lots of command line parameters\n
Run Code Online (Sandbox Code Playgroud)\n\n下次您需要相同的命令时,只需键入:
\n\nvery\xe2\x86\x91
Run Code Online (Sandbox Code Playgroud) \n\n它会为你输入:
\n\nvery-complicated-command with lots of command line parameters\n
Run Code Online (Sandbox Code Playgroud) 归档时间: |
|
查看次数: |
29925 次 |
最近记录: |