Zshの256色のヒント

Zshの256色のヒント

プロンプトを256色に設定するにはどうすればよいですか? bashプロンプトと同等のものを探しています。

  local DEFAULT="\[\033[0;39m\]"
  local ROOK="\[\033[38;5;24m\]"
  PS1="${ROOK}\$${DEFAULT} "

ベストアンサー1

export PS1='%F{214}%K{123}%m%k%f'

からman zshmisc

   %F (%f)
          Start (stop) using a different foreground colour, if supported by the terminal.  The colour may be specified two ways: either as a numeric argument, as normal, or by a sequence in braces following the %F, for example %F{red}.  In the latter case the values allowed are as described for the fg zle_highlight attribute; see  Char‐
          acter Highlighting in zshzle(1).  This means that numeric colours are allowed in the second format also.

   %K (%k)
          Start (stop) using a different bacKground colour.  The syntax is identical to that for %F and %f.

また、次のように使用できるかどうかを試してください。

$> print -P '%F{214}%K{123}%m%k%f'

おすすめ記事