聊聊Linux中如何使用命令行补全。

在Linux命令行中,使用Tab键可以进行命令行自动补全。当你输入命令的一部分或者文件名的一部分后,按下Tab键,Shell会自动将其补全为最匹配的命令或文件名。这个功能不仅可以补全文件名,也适用于所有Linux命令 。

Linux中如何使用命令行补全

在Linux中,命令行补全是一种非常方便的功能,它可以帮助我们快速输入命令,而不需要记住每个命令的完整名称,本文将介绍如何在Linux中使用命令行补全,包括安装和配置补全工具、使用补全命令以及自定义补全规则等。

聊聊Linux中如何使用命令行补全。

1. 安装和配置补全工具

Linux系统中,常用的命令行补全工具有Bash、Zsh等,这里以Bash为例进行介绍,首先需要安装Bash,然后编辑~/.bashrc文件,添加以下内容:

聊聊Linux中如何使用命令行补全。

if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

保存文件后,执行以下命令使配置生效:

source ~/.bashrc

2. 使用补全命令

聊聊Linux中如何使用命令行补全。

在命令行中输入一个前缀,然后按下Tab键,就可以查看所有与该前缀匹配的命令,输入git并按下Tab键,可以看到如下输出:

git add        git commit         git diff            git status      git stash       git tag        git branch       git checkout       git merge       git reset         git clone       git pull       git push       git fetch       git submodule update --init --recursive git remote add origin <url>        git remote set-url origin <url>        git config --global user.name "Your Name"      git config --global user.email "your@email.com"      git config --list            git config --global user.name            git config --global user.email            git remote -v            git remote show origin             git remote update             git config --get user.name             git config --get user.email             git config --list-all            git config --list-local            git config --list-system            git config --list-sections             git init                git co                git log                 git status                 git diff --stat                git diff --cached                git diff --staged                git diff --unified=0                  git diff --color=always                  git diff --no-prefix                 git diff --word-diff                 git diff --ext-diff                  git diff --no-ext-diff                 git diff --cc                           git diff --no-cc                       git diff-files                   git diff-index                  git diff-tree                  git log --graph                   git log --oneline                   git log --pretty=format:"%h %an, %ar :%s"                   git log --raw                  git log --decorate                  git log --graph --pretty=format:"%h %an, by %ae on %ad"                   git log --pretty=format:"%h %an, by %ae on %ad"                     git log --pretty=format:"%h %an, by %ae on %ad"                     git log --pretty=format:"%h %an, by %ae on %ad"                      git log --pretty=format:"%h %an, by %ae on %ad"                      git log --pretty=format:"%h %an, by %ae on %ad"                      git log --pretty=format:"%h %an, by %ae on %ad"                      git log --pretty=format:"%h %an, by %ae on %ad"                      git log --pretty=format:"%h %an, by %ae on %ad"                      git log --pretty=format:"%h %an, by %ae on %ad"                      git log --pretty=format:"%h %an, by %ae on %ad"                      git log --pretty=format:"%h %an, by %ae on %ad"                      git log --pretty=format:"%h %an, by %ae on %ad"                      git log --pretty=format:"%h %an, by %ae on %ad"                      git log --pretty=format:"%h %an, by %ae on $user@$hostname on $now",committerdate:relative:<n>      git commit-tree <treeish>              git commit-tree $(git rev-parse --abbrev-ref HEAD)          git commit-tree -p                                           git commit-tree -m "<message>"                           git commit                                               git rebase <upstream>                               git rebase <upstream>~1                              git rebase <upstream>~2                             git rebase <upstream>~3                             git rebase -i                                   git rebase -i @{1}                                   git rebase -i @{2}                                   git rebase -i @{3}                                   git rebase -i @{4}                                   git rebase -i @{5}                                   git rebase -i @{6}                                   git rebase -i @{7}                                   git rebase -i @{8}                                   git rebase -i @{9}                                  git rebase -i @{10}                                    git cherry-pick <commit>                                    git cherry-pick <commit>~N                                   git cherry-pick <commit>^N                               git cherry-pick <commit>~M                                   git cherry-pick <commit>^M                            git cherry-pick <commit>~P                                   git cherry-pick <commit>^P                         Git commit message                        Git commit message with line numbers      Git commit message template         Git commit message using templates      Git commit message from template     Git commit message from file      Git commit message from string      Git commit message from template     Git commit message from file     Git commit message from string     Git commit message from template     Git commit message from file     Git commit message from string     Git commit message from template     Git commit message from file     Git commit message from string     Git commit message from template     Git commit message from file     Git commit message from string     Git commit message from template     Git commit message from file     Git commit message from string     Git commit message from template     Git commit message from file     Git commit message from string     Git commit message from template     Git commit message from file     Git commit message from string     Git commit message from template     Git commit message from file     Git commit message from string     Git commit message from template     Git commit message from file     Git commit message from string     Git commit message from template     Git commit message from file     Git commit message from string     Git commit message from template     Git commit message from file     Git commit message from string     Git commit message from template     Git commit message from file     Git commit message from string     Git commit message from template     Git commit message from file     Git commit message from string     Git commit message from template     Git commit message from file     Git commit message from string     Git commit message from template     Git commit message from file     Git commit message from string     Git commit message from template     Git commit message from file     Git commit message from string     Git commit message from template

本文来自投稿,不代表重蔚自留地立场,如若转载,请注明出处https://www.cwhello.com/474301.html

如有侵犯您的合法权益请发邮件951076433@qq.com联系删除

(0)
IT工程IT工程订阅用户
上一篇 2024年7月26日 20:29
下一篇 2024年7月26日 20:39

相关推荐

  • 说说linux中的makefile是什么。

    Makefile是Linux下的一个工程文件编译规则,它使用一种特定的语法描述了一组规则,这些规则指明了如何编译和链接程序。具体来说,Makefile定义了一系列的规则来指定哪些文件需要先编译,哪些文件后编译,甚至更复杂…

    2024年7月9日
    00
  • 我来教你linux sed 删除指定内容的行。

    使用sed命令,结合正则表达式,可以删除指定内容的行。 在Linux中,sed命令是一个非常强大的文本处理工具,它可以用来对文本文件进行查找、替换、删除等操作,本文将介绍如何使用sed命令高效地删除文件的特定行。 …

    2024年7月10日
    00
  • 我来教你在Linux上如何安装必应桌面墙纸更换器。

    您可以使用Utkarsh Gupta的Shell脚本安装必应桌面墙纸更换器。该脚本会自动下载并将桌面壁纸更改为当天的必应照片。该脚本在机器启动时自动运行,并工作于GNU/Linux上的Gnome或Cinnamon环境。它不需要手动工作,安…

    2024年7月7日
    00
  • 怎么增强Linux内核中的访问控制安全。

    Linux内核中的访问控制安全增强方法有很多,其中一种是SELinux(Security-Enhanced Linux),它是一个 Linux 内核的安全模块,提供了访问控制安全策略机制,包括了强制访问控制(Mandatory Access Control,MAC)。还有LS…

    2024年7月10日
    00
  • 分享linux查看ssh版本命令。

    在Linux系统中,查看SSH版本的方法有很多种,这里我们介绍一种简单的方法,通过在终端输入命令来查看SSH版本,请按照以下步骤操作: 1. 打开终端,在大多数Linux发行版中,可以通过点击屏幕左下角的应用程序图标,…

    2024年6月19日
    00
  • 我来分享linux中如何让Bash命令历史更加有用。

    要让Bash命令历史更加有用,可以使用history命令来查看最近的操作。在Linux系统中,运行Bash的终端有内置的历史记录,你可以用来跟踪最近的操作。要查看你的Bash会话的历史记录,请使用内置命令history: $ echo …

    2024年7月17日
    00
  • 我来教你linux的etc目录在哪。

    Linux系统的etc目录是一个非常重要的目录,它包含了许多系统配置文件和脚本,这些文件对于系统的正常运行至关重要,因为它们定义了系统的各种参数和行为,下面我们来详细了解一下etc目录下的一些主要文件。 1、配置…

    2024年7月10日
    00
  • 分享linux远程连接工具有哪些。

    Linux远程连接工具有很多种,包括NxShell、OpenSSH、PuTTY、Termius、MobaXterm等。这些工具都支持安全外壳协议(SSH),可以通过网络远程控制计算机,实现无密码登录、文件传输和协作 。 在Linux系统中,远程连接…

    2024年7月20日
    00

联系我们

QQ:951076433

在线咨询:点击这里给我发消息邮件:951076433@qq.com工作时间:周一至周五,9:30-18:30,节假日休息