0
2

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.

いつも忘れる.bash_profile

Last updated at Posted at 2020-03-12

はじめに

新しい環境だといつも忘れるプロンプトの設定。。
箇条書きでメモです。

以下の記事を参考にさせていただきました、この場を借りてお礼申し上げます。捗るぜ!

.bash_profileと.bashrcについて
本当に正しい .bashrc と .bash_profile の使ひ分け
.bash_profile ? .bashrc ? いろいろあるけどこいつらなにもの?

結論

Homeディレクトリに.bash_profileをviとかtouchで作成。
export PS1="[\u@\h]$ "を追記して、source .bash_profileで再読み込みしてあげる。

追記

zshになったので手順が変わりました。

/etczshrcファイルが存在し、デフォルトのプロンプトはここで定義しています。
以下はzshrc抜粋。書き換えちゃった後ですが。。

# Default prompt
PS1="%n$ "

記法はbashとちょっと違いますが、そんなに乖離がある訳でもないので大丈夫だと思います。
ここをいじくってターミナルを再起動すれば反映されます。たぶんsource ./zshrcとかでも大丈夫です。

また、bash同様ファイル毎の違いがありますね。
全ユーザーに反映されるとか、ログインユーザーのみとか、シェルプロンプト起動時のみとか。

ちょっとだけ調べたので以下にリンクを貼っておきます!

おわりに

ユーザ名@ホスト名にしつつ、装飾で大かっこと権限の後に半角スペースを入れています。
3ブロック目にカレントディレクトリを追加しようかと思ったのですが、
別にいらない気がするので今回はやめておきました。

簡単ですが以上です。

0
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?