I don't know the term of the initial text before the command prompt of the console or the terminal, but the screen shot below should demonstrate well what I mean:
I want to reduce the highlighted text in the image: said@said-Satellite-L850-A700:
to something like: said@pc
or even to be only $
without any modification for the computer's name. Does it possible?
You can control the prompt in Bash (and Zsh) by setting the
PS1
environment variable.You may do this in your
$HOME/.bashrc
file, for example.Example:
or for
your-user@pc
useor go simple
Here's some of the magic tokens you can use.
You can apply colour codes too, should you wish.
EDIT: colour, bold etc.
ANSI escape sequences can be specified like
\033[
then some numbers for bold and colours joined with;
thenm
and can be reset with\033[0m;
e.g.
PS1='\033[31mxxx\033[0m '
would give you a redxxx
as a prompt.Very mini cheatsheet, replace
31
(Red) in the above with..1;31
for bold red1
for bold default colour31;43
for red text (31) on yellow background (43). The second, background colour uses the same code as the foreground but +1038;2;r;g;b
where you replacer
g
andb
with a value 0-255 for red green blue, e.g.38;2;255;180;0
would set it to a nice orangePS1='\033[31mxxx\033[0m '
would give you a redxxx
as a prompt.Please see an excellent answer at stackoverflow for a fuller list.