Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

.bashrcに環境変数PS1を記載して、ターミナルを見やすくしよう

はじめに

ターミナルが単色だったりすると見づらく、作業効率が落ちるため、.bashrcに環境変数PS1を追記して、色を変更します。

サンプル

1. .bashrcを直接編集する

.bashrc
SERVERNAME=aws-akane
export PS1='\[\e[1;36m\][\e[1;33m\]\u@\[\e[1;32m\]${SERVERNAME} \w\[\e[1;36m\]]$\[\e[00m\] '

2. EC2のユーザーデータを利用する

EC2のユーザーデータ
#!/bin/bash
yum update -y
cat <<EOS | sudo tee -a /home/ec2-user/.bashrc
SERVERNAME=aws-akane
export PS1='\[\e[1;36m\][\e[1;33m\]\u@\[\e[1;32m\]${SERVERNAME} \w\[\e[1;36m\]]$\[\e[00m\] '
EOS
miyabiz
AWS・GCPのクラウド・ビッグデータ・インフラ・アーキテクト、元CTO。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away