linux中制表符_在Linux终端中使用制表符完成时如何忽略大小写

linux中制表符

linux中制表符

00_lead_image_tab_completion_case_insensitive

The command line in Linux is case sensitive. When you use tab completion to quickly change or list directories on the command line, you must match the case of the directory names. However, there is a way to make tab completion case insensitive.

Linux中的命令行区分大小写。 当您使用制表符完成功能在命令行上快速更改或列出目录时,必须匹配目录名称的大小写。 但是,有一种方法可以使制表符完成不区分大小写。

Tab completion makes it quicker and easier to enter directories names on the command line. You can simply start typing the beginning of the directory name at the prompt and then press Tab to have the rest of the directory name automatically entered. For example, to change to the Documents directory, simply start typing cd Docu and then press Tab. It will autocomplete to cd Documents/ .

制表符补全使在命令行上输入目录名称更加快捷和容易。 您可以简单地在提示符处开始输入目录名称的开头,然后按Tab键以自动输入其余的目录名称。 例如,要更改到Documents目录,只需开始输入cd Docu ,然后按Tab。 它将自动完成到cd Documents/

You can make this feature case insensitive by adding a setting to Linux’s .inputrc file. This file handles keyboard mappings for specific situations on the command line (or bash shell), and lets you customize the behavior of the command line. It’s very easy to add this setting and we’ll show you how.

通过在Linux的.inputrc文件中添加设置,可以使此功能不区分大小写。 该文件处理命令行(或bash shell)上特定情况的键盘映射,并允许您自定义命令行的行为。 添加此设置非常容易,我们将向您展示如何进行。

There are two .inputrc files: a global one that applies to all users on the system ( /etc/.inputrc ), and a local one in the current user’s home directory that applies only to that user ( ~/.inputrc ). The ~ character represents the home directory, such as /home/lori/. The local .inputrc file overrides the global one, which means that any settings you add to the local file will be used despite what’s in the global file. We’re going to add the case insensitive setting to our local account in our example, but you can do it either way.

有两个.inputrc文件:一个全局文件,适用于系统上的所有用户( /etc/.inputrc ),以及一个当前用户主目录中的本地文件,仅适用于该用户( ~/.inputrc )。 〜字符表示主目录,例如/ home / lori /。 本地.inputrc文件将覆盖全局文件。这意味着,无论全局文件中有什么设置,都将使用您添加到本地文件中的所有设置。 在示例中,我们将不区分大小写的设置添加到我们的本地帐户中,但是您可以使用任何一种方式进行设置。

We’re going to use a text editor called gedit to add the setting to the .inputrc file. Press Ctrl+Alt+T to open the Terminal. Then, to change the local .inputrc file, type the following command at the prompt and press Enter.

我们将使用名为gedit的文本编辑器将设置添加到.inputrc文件。 按Ctrl + Alt + T打开终端。 然后,要更改本地.inputrc文件,请在提示符下键入以下命令,然后按Enter。

gksu gedit ~/.inputrc

If you want to change the global .inputrc file, type the following command instead.

如果要更改全局.inputrc文件,请键入以下命令。

gksu gedit /etc/.inputrc

If you don’t have an .inputrc file, this command will create one in your home directory or /etc directory automatically.

如果没有.inputrc文件,此命令将在您的主目录或/ etc目录中自动创建一个。

01_entering_command_to_edit_file

A dialog box displays asking for your password, so enter the password you use to log in to your account and click “OK”.

此时会显示一个对话框,要求您输入密码,因此输入用于登录帐户的密码,然后单击“确定”。

02_entering_password

The .inputrc file may be empty, and that’s fine. To have tab completion ignore case, add the following line to the file:

.inputrc文件可以为空,这很好。 要使制表符补全忽略大小写,请在文件中添加以下行:

set completion-ignore-case on

Click “Save”.

点击“保存”。

03_adding_command_to_inputrc_file

To close gedit, click the “X” button in the upper-left corner.

要关闭gedit,请点击左上角的“ X”按钮。

05_closing_gedit

The setting you just added to the .inputrc file will not affect the current Terminal window session. You must close the Terminal window and open it again for the change to take affect. So, type exit at the prompt and press Enter or click the “X” button in the upper-left corner of the window.

您刚刚添加到.inputrc文件的设置不会影响当前的“终端”窗口会话。 您必须关闭“终端”窗口,然后再次打开它才能使更改生效。 因此,在提示符下键入exit ,然后按Enter或单击窗口左上角的“ X”按钮。

NOTE: You may see some warnings display, as shown below, but they don’t affect what we’re doing with the file.

注意:您可能会看到一些警告,如下所示,但它们不会影响我们对文件的处理。

06_closing_terminal_window

Now, for example, when you type cd docu and press Tab…

现在,例如,当您键入cd docu并按Tab时…

07_typing_cd_command_for_documents_directory

…tab completion will work even though the case didn’t match the directory name.

…即使大小写与目录名称不匹配,也可以完成制表符补全。

08_after_pressing_tab_for_documents

If you want to go back to the default case sensitive setting for tab completion, simply open the same .inputrc file you added the setting to, delete the line you added, and save and close the file. Remember to close the Terminal window and reopen it after changing the .inputrc file.

如果要返回到默认的区分大小写设置以完成制表符,只需打开与添加设置相同的.inputrc文件,删除添加的行,然后保存并关闭文件即可。 记住在更改.inputrc文件后关闭“终端”窗口并重新打开它。

翻译自: https://www.howtogeek.com/267061/how-to-ignore-case-when-using-tab-completion-in-the-linux-terminal/

linux中制表符

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值