LoginSignup
1
1

More than 1 year has passed since last update.

AWS CloudShell がデフォルトだと時刻表示(JST)がなく見づらい

Last updated at Posted at 2023-01-31

課題

AWS Cloudshell のプロンプトがデフォルトだと時刻表示(JST)がなく見づらい

[cloudshell-user@ip-10-2-43-180 ~]$ ← このような表示

実装の流れ

  1. .bashrc の編集

手順1 .bashrc の編集

■バックアップ作成

[cloudshell-user@ip-10-2-43-180 ~]$ ls -la .bashrc*
-rw-r--r-- 1 cloudshell-user cloudshell-user 314 Jan 31 04:21 .bashrc
[cloudshell-user@ip-10-2-43-180 ~]$ 
[cloudshell-user@ip-10-2-43-180 ~]$ cp -ip .bashrc .bashrc.`date +%Y%m%d`
[cloudshell-user@ip-10-2-43-180 ~]$ 
[cloudshell-user@ip-10-2-43-180 ~]$ ls -la .bashrc*
-rw-r--r-- 1 cloudshell-user cloudshell-user 314 Jan 31 04:21 .bashrc
-rw-r--r-- 1 cloudshell-user cloudshell-user 314 Jan 31 04:21 .bashrc.20230131
[cloudshell-user@ip-10-2-43-180 ~]$ 

■編集

[cloudshell-user@ip-10-2-43-180 ~]$ vim .bashrc

(編集画面に遷移)
矢印キーで末尾まで移動。
o を押します。(挿入モードになります)
以下を追記する。

# add
PS1='[\t \[\e[36;40m\]$LOGNAME\[\e[0m\]@\h] \W \$ '
export TZ="Asia/Tokyo"

:qw を入力してvimから抜ける
もし間違えてしまっていたら :q! で抜けれます。(未更新状態に戻る)

■差分の確認

[cloudshell-user@ip-10-2-43-180 ~]$ diff .bashrc .bashrc.20230131 
14,17d13
< 
< # add
< PS1='[\t \[\e[36;40m\]$LOGNAME\[\e[0m\]@\h] \W \$ '
< export TZ="Asia/Tokyo"
[cloudshell-user@ip-10-2-43-180 ~]$ 

■反映

[cloudshell-user@ip-10-2-43-180 ~]$ source .bashrc
[13:42:28 cloudshell-user@ip-10-2-43-180] ~ $ 

実装後

[13:42:28 cloudshell-user@ip-10-2-43-180] ~ $ 

次回からもログイン時は時刻表示されている状態のプロンプトになります。
新規タブを立ち上げたりして確認してみてください。

1
1
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
1
1