用转义码魔术来改变你的shell输出!
swag的Python项目详细描述
用转义码魔法给外壳输出上色。
演示
安装
pip install swag
用法
usage: swag [-h] {print,install} ... positional arguments: {print,install} [command] help install install the colors to the folder of choice print prints the text with the specified color and type to the console optional arguments: -h, --help show this help message and exit
原始使用量
使用源代码
from swag import colors print colors.COLORS["red"], "This will be red" # Or use the swagprinter helpers: from swag import swagprinter from swag.swagprinter import INTENSE swagprinter.print_green("Blah", INTENSE) # Prints an intense green # Prints an intense green, to the end of the output: swagprinter.print_green("Blah", INTENSE, true)
安装到文件夹
从命令行do
swag install -d <path/to/folder> # default is ~/.colors
这将把所有转义码安装到~/.colors或文件夹中。
现在您可以通过:
echo $(cat ~/.colors/blue) This will be blue