聊聊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

相关推荐

  • 聊聊debian中怎么安装ifconfig命令。

    在Debian系统中,要安装ifconfig命令,可以按照以下步骤操作: (图片来源网络,侵删) 1、更新软件包列表: 打开终端。 输入命令 sudo apt update 并执行,以更新软件包列表。 2、安装 nettools 包: 在终端中输入…

    2024年7月28日
    00
  • 我来说说linux中如何创建静态库。

    在Linux中,创建静态库的过程可以分为以下几个步骤: (图片来源网络,侵删) 1、编写源代码文件 2、将源代码文件编译为目标文件 3、将目标文件打包成静态库 4、使用静态库 下面是详细的操作步骤: 1. 编写源代码文…

    2024年6月28日
    00
  • 我来分享linux更改ip地址。

    在Linux系统中,我们可以使用ifconfig或ip命令来更改IP地址,这些命令允许我们配置网络接口的IP地址、子网掩码、广播地址等参数,下面是一个简单的步骤说明: 1. 我们需要找到要更改IP地址的网络接口名称,可以使用…

    2024年6月19日
    00
  • linux用户列表信息怎么查看。

    在Linux系统中,我们可以使用多种方法来查看用户列表信息,以下是一些常见的方法: (图片来源网络,侵删) 1. 使用/etc/passwd文件查看用户列表 /etc/passwd文件是Linux系统中存储用户信息的文本文件,我们可以通…

    2024年7月20日
    00
  • 教你linux怎么关闭防火墙。

    一、什么是防火墙 防火墙,又称网络防火墙,是位于两个或多个网络之间的硬件或软件系统,用于监控和控制数据包在网络中的传输,它可以阻止未经授权的访问,允许特定的通信通过,以及过滤有害信息,在家庭和企业环境…

    2024年6月19日
    00
  • 经验分享ssh登陆linux服务器。

    在Linux服务器上设置SSH登录后发送email提醒,可以通过以下步骤实现: 1、安装邮件发送工具 首先需要在服务器上安装一个邮件发送工具,这里以sendmail为例,在Debian/Ubuntu系统上,可以使用以下命令安装: sudo ap…

    2024年7月3日
    00
  • 说说ubuntu中怎么使用mv命令移动多个文件。

    在Ubuntu中,我们可以使用mv命令来移动一个或多个文件。mv命令是Linux系统中的一个基本命令,用于移动文件或目录,也可以用于重命名文件或目录。 (图片来源网络,侵删) 基本使用方法 mv命令的基本格式如下: mv […

    2024年7月28日
    00
  • 我来教你linux中ulimit命令怎么用「linux ulimit命令」。

    ulimit命令是Linux系统中一个重要的shell内置命令,它可以用来查看和设置各种资源限制,这些资源包括打开文件的最大数量、进程的最大数量、虚拟内存的大小等,通过使用ulimit命令,我们可以在系统运行时对这些资源…

    2024年6月14日
    00

联系我们

QQ:951076433

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