首页 资讯 Mac iterm2设置终端颜色

Mac iterm2设置终端颜色

来源:泰然健康网 时间:2026年03月06日 04:10

本文使用最简单的方法配置iterm2终端颜色,仅需修改~/.bash_profile文件

切换为bash

安装iterm2后默认是bash,注意bash才能设置颜色,mac自带的zsh不行。

切换bash命令:

chsh -s /bin/bash

如果你想看看自己的机子上装了哪些shell,可以使用如下命令:

cat /etc/shells

/bin/bash /bin/csh /bin/ksh /bin/sh /bin/tcsh /bin/zsh

配置bash_profile

修改文件:

vi ~/.bash_profile

alias cls='tput reset' alias egrep='egrep -G' alias fgrep='fgrep -G' alias grep='grep -G' alias l.='ls -d .* -G' alias ll='ls -la -G' alias la='ls -a -G' alias ls='ls -G' alias vi='vim' #alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' export CLICOLOR=1 export LSCOLORS=gxfxaxdxcxegedabagacad find_git_branch () { local dir=. head until [ "$dir" -ef / ]; do if [ -f "$dir/.git/HEAD" ]; then head=$(< "$dir/.git/HEAD") if [[ $head = ref: refs/heads/* ]]; then git_branch=" → ${head#*/*/}" elif [[ $head != '' ]]; then git_branch=" → (detached)" else git_branch=" → (unknow)" fi return fi dir="../$dir" done git_branch='' } PROMPT_COMMAND="find_git_branch; $PROMPT_COMMAND" black=$'[e[1;30m]' red=$'[e[1;31m]' green=$'[e[1;32m]' yellow=$'[e[1;33m]' blue=$'[e[1;34m]' magenta=$'[e[1;35m]' cyan=$'[e[1;36m]' white=$'[e[1;37m]' normal=$'[e[m]' PS1="$white[$magentau$white@$greenh$white:$cyanw$yellow$git_branch$white]$ $normal" export GOPATH=/Users/your_dir/go export PATH=$GOPATH/bin:$PATH

重新打开终端即可看到颜色。

颜色自定义

参考文章修改颜色:MAC+iTerm定制目录显示颜色和提示符

标签:

相关知识

iTerm2
Mac iTerm2快速删除整行命令的方法
iTerm2 会话管理以及其他常用设置
ITerm2 · Wiki
iTerm2如何查看历史输入的命令记录
5个设置,让你的Mac电池更耐用!
设定 Mac 的睡眠和唤醒设置
mac篇
在 Mac 笔记本电脑上更改“电池”设置
苹果Mac怎么设置不休眠?Mac自动休眠怎么取消?

网址: Mac iterm2设置终端颜色 https://www.trfsz.com/newsview1910049.html

推荐资讯