LoginSignup
8
7

More than 5 years have passed since last update.

[Linux] プロンプト(PS1)に表示されるパスをフルパス表示へ変更する

Last updated at Posted at 2015-11-17

経緯

  • プロンプト(PS1(primary prompt string))で表示されるパスをフルパスで表示したい!

プロンプト(PS1(primary prompt string))ってなに?

  • ターミナルで表示される左側の部分
[root@centos6 ~]#
^^^^^^^^^^^^^^^^
この部分のこと

具体的には

  • これを、、、
[root@centos6 ~]# cd /etc/sysconfig/network-scripts/
[root@centos6 network-scripts]#
  • こう!
[root@centos6 ~]# cd /etc/sysconfig/network-scripts/
[root@centos6 /etc/sysconfig/network-scripts/]#

やり方

/etc/bashrc の36行目あたりを編集する

  • これを、、、
/etc/bashrc
# Turn on checkwinsize
shopt -s checkwinsize
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
  • こう\(^o^)/
/etc/bashrc
# Turn on checkwinsize
shopt -s checkwinsize
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \w]\\$ "

何処が変わったの?

  • 大文字 W を小文字 w へ変更しただけです!

設定の反映

  • 再度ログインすれば反映されるが即時反映したい場合は下記コマンドを実行
[root@centos6 ~]# source /etc/bashrc

or

[root@centos6 ~]# . /etc/bashrc

おしまい

8
7
1

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