Sunday, May 5, 2024
25
rated 0 times [  25] [ 0]  / answers: 1 / hits: 4074  / 2 Years ago, tue, june 28, 2022, 5:01:21

When you opens a terminal it displays the username and the machine name. As an example mine shows: romeo@romeo-Satellite-C660D:~$. It's really annoying because it's kinda big. Can i make this smaller, like, only show romeo?



I know it sounds stupid, but I'm new with Unix based OSes.


More From » command-line

 Answers
0

You need to alter PS1 variable in your environment. PS1 is responsible of how fancy your command prompt will look alike, and what information it will contain.



Permanent change



Following is the excerpt of default .bashrc file in Ubuntu 10.04 LTS:



if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}[033[01;32m]u@h[033[00m]:[033[01;34m]w[033[00m]$ '
else
PS1='${debian_chroot:+($debian_chroot)}u@h:w$ '
fi


This makes command prompt look like this: username@hostname:~/directory$



If you change this and delete @h part in PS1, you will get rid of hostname part in your command prompt:



if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}[033[01;32m]u[033[00m]:[033[01;34m]w[033[00m]$ '
else
PS1='${debian_chroot:+($debian_chroot)}u:w$ '
fi


Result: username:~/directory$



Temporary change



Override PS1 in your current bash session:



export PS1="u:w$ "


Resources:




[#32232] Wednesday, June 29, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
landarre

Total Points: 254
Total Questions: 96
Total Answers: 109

Location: Burundi
Member since Sun, Apr 16, 2023
1 Year ago
landarre questions
;