我想在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
Run Code Online (Sandbox Code Playgroud)
我想到的答案是如何捕捉当前的颜色
cur=????
Run Code Online (Sandbox Code Playgroud)