有没有办法为 git(或任何命令)的输出着色?
考虑:
baller@Laptop:~/rails/spunky-monkey$ git status
# On branch new-message-types
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: app/models/message_type.rb
#
no changes added to commit (use "git add" and/or "git commit -a")
baller@Laptop:~/rails/spunky-monkey$ git add app/models
Run Code Online (Sandbox Code Playgroud)
和
baller@Laptop:~/rails/spunky-monkey$ git status
# On branch new-message-types
# Changes to be committed:
# (use "git reset HEAD <file>..." to …
Run Code Online (Sandbox Code Playgroud) 我知道使用回声打印彩色文本,例如红色,代码是:echo -e "\e[1;31m This is red text \e[0m"
我知道在这个例子中,31 是红色的代码,其他颜色的数量是:
Black 0;30 Dark Gray 1;30
Blue 0;34 Light Blue 1;34
Green 0;32 Light Green 1;32
Cyan 0;36 Light Cyan 1;36
Red 0;31 Light Red 1;31
Purple 0;35 Light Purple 1;35
Brown 0;33 Yellow 1;33
Light Gray 0;37 White 1;37
Run Code Online (Sandbox Code Playgroud)
对于背景颜色,数字是 40 到 47
我的问题是:\e
and[
和m
(after 31) 在这里到底是什么意思?
我在手册页中读到 \e 是转义,但我不明白这是什么意思。