0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CentOS7でbashのプロンプト設定

Posted at

ログインして作業しているサーバを取り違えないよう、bashプロンプトで視覚的にすぐ判別しやすい情報を表示したい。
プロンプトでは表示する文字だけでなく色付けやフォント体裁も調整が可能。
具体的には$PS1という環境変数に設定値は登録されている。

[prompt] echo $PS1

[\u@\h \W]\$

この設定値はbash設定ファイルbashrcで管理できる。
ユーザーごとのbasshrcもあるが、おおもとの「/etc/bashrc」で設定シテおくとよい。

/etc/bashrc
export PS1="値"

ちなみに色付け・フォント体裁は以下のような記法で指定する。

[\e[1;33m\]テキスト \[\e[m\]

この指定ではテキスト部が黄色の太字となる。
「1」は太字指定を意味し、標準は0になる。
「33」は黄色を示す。
その他の色は以下の通り。

Color code
30
31
32
33
34
35
水色 36
37
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?