How can I customize the appearance of my command line prompt in Ubuntu?

  • Thread starter Thread starter J77
  • Start date Start date
  • Tags Tags
    Line
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
5 replies · 5K views
J77
Messages
1,092
Reaction score
1
How do I set my system so that the entire pathname doesn't appear on the command line -- just the directory I'm in?

eg. at the moment:

me@me:/~$dir1/dir2/dir3

What I want is:

:dir3/

(I know I'm me :biggrin:)
 
Physics news on Phys.org
On what system?
In Ubuntu I know you would edit the $1 variable in the bash config file (~/bashrc or ~/.bashrc or something like that). It determines what shows up on the command line. I'm on a Windows system now thought, so I can't test it.
 
Sorry -- yes, ubuntu

.bashrc worked, thanks :)
 
Last edited:
The prompt appearance is set by PS1[/color] environment variable. You can play with it in the current terminal window to get it to behave as you would like, and then write it for good into ~/.bashrc. The explanation of all elements and a few examples are given at http://tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html

However...

J77 said:
(I know I'm me :)
...this is a bold claim :)

Experience in Unix shell usage is decades long, and the default settings reflect that. They are best left untouched unless one really knows what he is doing. Several years ago, I had the exact same "hey, it's too long" urge to change the shell prompt, and guess what, these days I am using the default prompt (note that in the final example on the link above, the user set yet even longer prompt).

--
Chusslove Illich (Часлав Илић)
 
Thanks Chusslove.

Indeed, I played with the PS1 = ... and got it as I wanted: just a $ on the command line with the full path in the xterm title :smile:
 
CompuChip said:
On what system?
In Ubuntu I know you would edit the $1 variable
caslav.ilic said:
The prompt appearance is set by PS1[/color] environment variable.
Err, that's what I meant :blushing: