What is the purpose of the command prompt PS1?

Question

What is the purpose of the command prompt PS1?

Answer

The command prompt (PS1) often plays the role of guide, as a default on a terminal window, we can commonly see that it is composed of usually three pieces of information, 1. the user, 2. the machine (computer name), and 3. the name of the current directory, all within brackets and followed by an iconic $ that lets us know that there is where we can start typing on the command line, for example, if I were to be the user, my computer’s name were to be sparky, and the currently directory were to be called bash_exercise, my prompt would look like so:

[AxelKaban@sparky bash_exercise]$

some prompts provide more or less information. In the case of the Codecademy prompt, it usually is simply $ which denotes that there is a normal user working, which again is a basic setting.

Using nano to open our .bash_profile we could adjust what we want to see on our PS1, maybe our interest is mainly aesthetic, and thus we could make it pretty with our name, the machine’s name, a heartfelt or positive quote, and even emojis, because its main purpose is to guide us and provide valuable information, so why not update it with a series of uplifting emojis! Or the birthdate of that special someone we keep on forgetting about.

18 Likes

Since the export PS1=">> " only changes the shell prompt from $ to >>. So can I make that change for all terminal sessions whenever I open any terminal session(e.g Permanent changes)? And yes how I can give emojis to it ?

5 Likes

I can’t seem to find the like button on a number of your posts. I want to like them but I can’t find like.

Is there a maximum to the number of likes one can get on CC?

1 Like

So this is more like you will customize your GUI and desktop wallpaper and so on, right?

Is PS1 an acronym? What does it stand for?

PS stand for prompt string i guess. There are various PS like PS1, PS2 etc. Here, PS1 means primary prompt string while PS2 mean secondary prompt string and so on. And yeah emojee can also be used as primary shell prompt. I guess this link would be useful regarding changing PS1
https://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html#:~:text=Prompt%20is%20control%20via%20a,as%20the%20primary%20prompt%20string.

1 Like