关闭。这个问题不符合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/