LoginSignup
17
26

More than 5 years have passed since last update.

【mac】ターミナルのプロンプトの変更

Posted at

デフォルトの指定

/etc/bashrc内のPS1に設定がある。

/etc/bashrcの設定
export PS1='\h:\W \u\$ '

項目設定:

\h ホスト名(最初の.まで)
\H ホスト名
\W ディレクトリ
\w ディレクトリ(フルパス)
\u ユーザ名
\t 時間
\$ 一般ユーザの時は"$"、rootだと"#"になる

色の設定:

\[\e[0;30m\]色をつけたい部分\[\e[0;0m\]
\[\e[0;31m\]色をつけたい部分\[\e[0;0m\]
\[\e[0;32m\]色をつけたい部分\[\e[0;0m\]
\[\e[0;33m\]色をつけたい部分\[\e[0;0m\]
\[\e[0;34m\]色をつけたい部分\[\e[0;0m\]
\[\e[0;35m\]色をつけたい部分\[\e[0;0m\]
\[\e[0;36m\]色をつけたい部分\[\e[0;0m\]
\[\e[0;37m\]色をつけたい部分\[\e[0;0m\]

設定箇所:

ホームディレクトリ内の.bash_profileに設定する。

例:.bash_profile
#赤色になる
export PS1='\[\e[0;31m\][\h@\w]\$\[\e[0;0m\] '
17
26
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
17
26