macos - 在 Ubuntu 的远程 ssh session 上(本地是 Mac OS 计算机),为什么当我输入 "bash"时颜色会出现?

标签 macos ubuntu iterm

关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。












我们不允许在 Stack Overflow 上提出有关通用计算硬件和软件的问题。您可以编辑问题,使其成为 on-topic对于堆栈溢出。


1年前关闭。







Improve this question




在我的 Mac 上,使用 iTerm 进入 ubuntu 18.04 计算机后,输入

bash
我看到 ls颜色打开。为什么是这样?

最佳答案

因为 bash 在其输出中支持颜色。
写作 bash将您的终端更改为 bash来自(我假设)sh ?
它加载了一堆文件:

FILES
       /bin/bash
              The bash executable
       /etc/profile
              The systemwide initialization file, executed for login shells
       /etc/bash.bashrc
              The systemwide per-interactive-shell startup file
       /etc/bash.bash.logout
              The systemwide login shell cleanup file, executed when a login shell exits
       ~/.bash_profile
              The personal initialization file, executed for login shells
       ~/.bashrc
              The individual per-interactive-shell startup file
       ~/.bash_logout
              The individual login shell cleanup file, executed when a login shell exits
       ~/.inputrc
              Individual readline initialization file

如果您写 man bash,您可以找到此信息在终端中,靠近手册的最后。
其中一个文件具有颜色支持。
通常是文件~/.bashrc其中有这个:
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
  test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  alias ls='ls --color=auto'
  #alias dir='dir --color=auto'
  #alias vdir='vdir --color=auto'

  alias grep='grep --color=auto'
  alias fgrep='fgrep --color=auto'
  alias egrep='egrep --color=auto'
fi

# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

关于macos - 在 Ubuntu 的远程 ssh session 上(本地是 Mac OS 计算机),为什么当我输入 "bash"时颜色会出现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63404791/

相关文章:

linux - 如何使用 Bash 脚本安装 Puppet 并立即运行模块?

macos - 如何将 iterm2 选项卡标题设置为正在运行的 tmux session 名称的标题?

bash - 具有特定名称的目录的权限被拒绝

macos - iTerm Mac/如何导出/导入书签

git - 为什么在 iTerm2 中不显示 git 颜色

macos - 如何在 Mac 上将 PNG 剪贴板内容保存到文件

macos - 如何解锁我的电脑并通过 applescript 显示屏幕?

swift - Mac OS Xcode Swift 2.2 控制拖动标签和按钮到 appdelegate.swift 文件的问题

macos - bower 安装失败给我 EACCES : permission denied error

ubuntu - 使用 nfs 共享作为主目录时如何使用 ldap?