「tput」を使用して次の行をどのように指定しますか?

「tput」を使用して次の行をどのように指定しますか?

Pythonを使用してテキストに色を追加する次の行をどのように再現できますかtput

print('\x1b[1;34m::\x1b[0;1m Do you want to remove all other packages from cache? [Y/n] \x1b[0m')

tput setaf 4tput boldの変形を試しましたが、tput sgr 0正しく動作しませんでした。

ベストアンサー1

同じ色を生成する同じコマンドは次のとおりです。

$ echo "\n$(tput bold)$(tput setaf 4)::$(tput sgr0)$(tput bold) Do you want to remove all other packages from cache? [Y/n] $(tput sgr0)"

しかし、問題と同じエスケープコードを出力するソリューションはtput非常に歓迎されています。

$(tput sgr0)$(tput bold)設定の白が必ずしも同じではありません$(tput setaf 7)

おすすめ記事