docs > shell > Prompt

Prompt

bash

simple

export PS1='\$ '

with current directory

export PS1='\w\$ '

with full path

export PS1='\W\$ '

colorful

export PS1='\[\e[32m\]\u\[\e[m\]@\[\e[36m\]\h \[\e[33m\]\w\[\e[m\]\$ '

PS1を変更するとプロンプトが変わります。

シーケンス 説明
\w カレントディレクトリ(ホームは ~ 表記) ~/projects/test
\W カレントディレクトリのベース名のみ test
\~ ホームディレクトリ /home/ユーザー名
\d 日付(例: Mon Jun 07 Fri Jun 07
\t 時刻(24時間: HH:MM:SS 14:03:21
\h hostname machine-name