【发布时间】:2015-03-21 17:06:03
【问题描述】:
我想在 BASH 中查询和存储当前终端颜色对例如:
#!/bin/bash
#some ANSI colour escape sequences
red="\033[0;31m"
grn="\033[0;32m"
blu="\033[0;34m"
def="\033[0;00m" # default
echo -e "Change to ${red} red to ${def} default to ${blu} blue."
# now store the current color (which happens to be blue) e.g.:
cur=????
echo -e "Change to ${grn} green and back to what I had before ${cur}"
echo -e "This would be in blue if variable cur contained e.g.: 0;34m."
echo -e "Back to default${def}"
exit 0
让我难以捉摸的答案是如何捕捉当前颜色
cur=????
【问题讨论】:
标签: bash ansi-colors