聊聊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查看所有服务命令。

    在Linux系统中,有多种方法可以查看所有服务,这里我们将介绍两种常用的方法:使用`systemctl`命令和使用`lsof`命令,这两种方法都可以帮助你查看当前运行的服务及其状态。 方法一:使用`systemctl`命令 `systemctl…

    2024年6月20日
    00
  • 我来分享怎么在linux安装wps。

    在Linux系统中安装使用WPS WPS Office是一款功能强大的办公软件,支持多种操作系统,包括Windows、Mac和Linux,在Linux系统中安装和使用WPS Office,可以提高工作效率,满足各种办公需求,本文将详细介绍如何在Linu…

    2024年7月6日
    00
  • 我来教你linux怎么修改。

    在Linux系统中,修改文件或目录的权限、所有权等属性是非常常见的操作,本文将介绍如何在Linux中修改文件和目录的权限、所有权等属性。 1. 使用`chmod`命令修改文件或目录的权限 `chmod`命令用于修改文件或目录的权…

    2024年6月15日
    00
  • 关于在Linux中如何安装Darkstat。

    在Linux中安装Darkstat的方法如下:,,1. 在Fedora/RHEL和CentOS中安装,运行下面的命令:sudo yum install darkstat。,2. 在Ubuntu/Debian中安装,运行下面的命令:sudo apt-get install darkstat。 在Linux中如…

    2024年7月28日
    00
  • 分享Linux中如何使用命令行别名。

    在Linux中,您可以使用别名来简化命令行输入。别名是一组关联的命令和文本字符串,它们可以让您使用一个简短的名称来代替长长的命令。要创建别名,请在终端中输入“alias [别名]=[指令名称]”,alias ll=’ls -l…

    2024年7月10日
    00
  • 小编教你linux虚拟地址空间怎么弄出来。

    Linux虚拟地址空间可以通过内存管理单元(MMU)和分页机制实现。 Linux虚拟地址空间是操作系统为了实现内存管理而引入的抽象概念,它允许每个进程拥有自己的独立地址空间,从而避免不同进程之间的地址冲突,本文将…

    2024年7月6日
    00
  • 我来说说linux文件传送。

    Linux文件传输简介 在Linux系统中,文件传输可以通过多种方式进行,如FTP、SSH、SCP等,本文将重点介绍Linux文件传输的备份系统,包括其原理、使用方法以及一些常见问题与解答。 Linux文件传输备份系统原理 Linux文…

    2024年7月28日
    00
  • 我来说说Linux 下提高工作效率的文件处理技巧有哪些。

    以下是一些 Linux 下提高工作效率的文件处理技巧:,,1. 使用命令行工具,如 ls、grep、find 等,可以快速查找和处理文件。,2. 使用命令行工具的管道符(|)和重定向符(>、>>),可以将一个命令的结果作为另…

    2024年7月6日
    00

联系我们

QQ:951076433

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