Bash 補全有效,但我不明白為什麼。似乎沒有按照通常的方式配置

Bash 補全有效,但我不明白為什麼。似乎沒有按照通常的方式配置

我剛剛在我的 rpi3 上安裝了經過測試的樹莓派 debian 映像(https://raspi.debian.net/tested-images/arm64 圖像)。

當我以 root 身分透過 ssh 登入系統時,bash 補全似乎是開箱即用的。到目前為止,一切都很好。但我不明白它為什麼會起作用。

我看了一些典型的地方:

少~/.bashrc

# ~/.bashrc: executed by bash(1) for non-login shells.
# Note: PS1 and umask are already set in /etc/profile. You should not
# need this unless you want different defaults for root.
# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
# umask 022

# You may uncomment the following lines if you want `ls' to be colorized:
# export LS_OPTIONS='--color=auto'
# eval "$(dircolors)"
# alias ls='ls $LS_OPTIONS'
# alias ll='ls $LS_OPTIONS -l'
# alias l='ls $LS_OPTIONS -lA'
#
# Some more alias to avoid making mistakes:
# alias rm='rm -i'
# alias cp='cp -i'
# alias mv='mv -i'

少~/.profile

if [ "$BASH" ]; then\
          if [ -f ~/.bashrc ]; then\
            . ~/.bashrc\
          fi\
        fi

少/etc/profile

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
        # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
        
        if [ "$(id -u)" -eq 0 ]; then
          PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
        else
          PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
        fi
        export PATH
        
        if [ "${PS1-}" ]; then
          if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
            # The file bash.bashrc already sets the default PS1.
            # PS1='\h:\w\$ '
            if [ -f /etc/bash.bashrc ]; then
              . /etc/bash.bashrc
            fi
          else
            if [ "$(id -u)" -eq 0 ]; then
              PS1='# '
            else
              PS1='$ '
            fi
          fi
        fi
        
        if [ -d /etc/profile.d ]; then
          for i in /etc/profile.d/*.sh; do
            if [ -r $i ]; then
              . $i
            fi
          done
          unset i
        fi

/etc/bash/bash.bashrc(僅摘錄)

# enable bash completion in interactive shells
#if ! shopt -oq posix; then
#  if [ -f /usr/share/bash-completion/bash_completion ]; then
#    . /usr/share/bash-completion/bash_completion
#  elif [ -f /etc/bash_completion ]; then
#    . /etc/bash_completion
#  fi
#fi

/etc/profile.d

empty

內核 5.10.0 arm64
bash 5.1.4

問題:

  1. bash-completion 在哪裡配置?
  2. 在此 bash 版本中安裝 bash-completion 套件是否就足夠了?

相關內容