The default prompt will be
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="44362b2b3004292b2a31">[email protected]</a> dev]#
Can we change the “[email protected]” part and give it a desired name?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
This is changed by changing the environment variable PS1.
You can see the current value of PS1 by:
[email protected] dev# echo $PS1
You can see the value to be equal to [email protected]h w$, where:
u: usernameh: hostnamew: current working directory$: a#symbol for the root user, a$symbol for other users
If you want the change to be permanent, you have to add the script changing the value of PS1 in ~/.bashrc, since that it gets executed every time a user logs in.
Method 2
This depends on your shell. As an important side note, you should never use the root account as a personal account. Create a normal user and set up access to sudo. Please check your distribution manual as to how to do this.
In zsh, you need to set the PROMPT variable like so:
PROMPT='%{ESC[38;5;24m%};%{ESC[0m%} '
zshell offers a lot of other options and this is really a minimal prompt.
In bash, you can set it this way:
local ROOK="[33[38;5;24m]"
local DEFAULT="[33[0;39m]"
PS1="${ROOK}$${DEFAULT} "
Note that in both cases, I have a 256 colour enabled terminal. The man page will help a lot (man bash or man zsh).
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0