How to change shell prompt in Unix?

2019-09-01 07:31发布

问题:

I want to disable the Unix shell prompt character ($, #, %) which usually we see in terminal. Is there any command or setting which can do this? I am using Solaris OS.

By shell prompt character I mean:

>$
>#

回答1:

You need to adjust your PS1 environment variable in your .profile file. I guess you could set it to "" to have it empty.

ex: export PS1=""

EDIT: it can also be in your .bashrc file, or any other shell you are using.



回答2:

You can get fancy and put the host name in there. But basically you change the PS1 environment variable:

export PS1=hello

You can add this command in your ~/.bashrc file. Or other startup file, if you use another shell.



回答3:

I suggest first check the man pages for the shell (whatever is yours? echo $SHELL) under shell variables. There are four types of prompt strings(PS) PS1, PS2, PS3, PS4, for your problem PS1 adjustment is sufficient. To check the current settings: echo $PS1

To change: PS1="" for the current session, to make it permanent export it in your ~/.bashrc or ~/.profile.

To make it permanent for the user: export PS1="whatever special characters you want"

for more special characters and examples you can visit here "http://linuxconfig.org/bash-prompt-basics"