2. Editting prompt

$PS1 is set like below by default in MAC OS.

In MAC OS, PS1 is quickly reflected after changing PS1.
Takaharus-MacBook-Pro:~ tkurokawa$ echo $PS1
\h:\W \u\$
Takaharus-MacBook-Pro:~ tkurokawa$ PS1=[TK:\W]$

[TK:W]$

Login shell executes the following files:
1.       /etc/profile
2.       ~/.bash_profile
3.       ~/.bash_login
4.       ~/.profile

~/.bashrc  is not listed but in most of  ~/.bash_profile  seems to call ~/.bashrc.

.basshrc can be pushed from echo with "echo 'export PS1="[\w]$"' > .bashrc ".
[TK:W]$echo 'export PS1="[\w]$"' > .bashrc
[TK:W]$more .bashrc
export PS1="[\w]$"

[TK:W]$echo "export PS1="[\w]$"" > .bashrc
[TK:W]$more .bashrc
export PS1=[w]
#\w is removed. This doesn't work.

 [TK:W]$echo 'export PS1='[\w]$'' > .bashrc
[TK:W]$more .bashrc
export PS1=[w]
#\w is removed. This doesn't work.

[TK:W]$echo `export PS1="[\w]$"` > .bashrc
[TK:W]$more .bashrc

[TK:W]$
#\w is removed. This doesn't work.

After modifying .bashrc, it can be applied by source command.
[TK:~]$echo 'export PS1="[\w]$"' > .bashrc
[TK:~]$more .bashrc
export PS1="[\w]$"
[TK:~]$source .bashrc
[~]$

If the .bashrc doesn't work(at least my MAC not), use ".bash_profile" as typical examples.
[~]$echo 'export PS1="[\w]$"' >> ~/.bash_profile
[~]$more .bash_profile
export PATH=$HOME/.nodebrew/current/bin:$PATH

export PS1="[\w]$"


Reference:
ログインシェルとインタラクティブシェルと~/.bashrc達の関係
https://qiita.com/incep/items/7e5760de0c2c748296aa
Bashプロンプトの変更
https://qiita.com/zaburo/items/9194cd9eb841dea897a0
bashのプロンプトを変更するには
http://www.atmarkit.co.jp/flinux/rensai/linuxtips/002cngprmpt.html

http://pocketstudio.jp/linux/?%A5%D7%A5%ED%A5%F3%A5%D7%A5%C8%A4%CE%B3%CE%C7%A7%A4%E4%C0%DF%C4%EA

https://qiita.com/katsukii/items/da37d1fdf974bd0e4c2f


コメント

このブログの人気の投稿

4. Installing Node.js for Node-Red

ATOM package install