Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I do. Usually it shows my username, the current directory and a green smiley (or red sad smiley, dependent if the last command returned an error code). When I SSH into one of my other machines it also shows the hostname.
Thats what i have been using for a few years. Shows the working dir and i adjust for different colors for different machines and have "root" appear in red. I never use the default prompt.
I also echo the host and working dir in term window title bars.
I use the default as long as it is short. Using the current directory is useful if your terminal doesn't already tell you, however it's too long for me.
I use the default as long as it is short. Using the current directory is useful if your terminal doesn't already tell you, however it's too long for me.
I have configured it in that way that the full path is only displayed if it is not more than 3 subdirectories long, if it is longer only the name of the current directory is displayed.
My PS1 only shows the current working directory because I hate long paths. However you can control how deep into the directory you want display using the system variable PROMPT_DIRTRIM. I will demonstrate with a example
Code:
export PROMPT_DIRTRIM=3
cd TEST/dir1/dir2/dir3/dir4/dir5
[~/.../dir3/dir4/dir5] %
As you can see, it trim the path to just 3 directories. If you want two directories, then
Code:
export PROMPT_DIRTRIM=2
[~/.../dir4/dir5] %
This is not permanentm it will expire when you close the terminal. To make it permanent add it to your .bashrc file
Last edited by CrackerPunk; 08-26-2013 at 10:08 AM.
My PS1 only shows the current working directory because I hate long paths. However you can control how deep into the directory you want display using the system variable PROMPT_DIRTRIM. I will demonstrate with a example
Code:
export PROMPT_DIRTRIM=3
cd TEST/dir1/dir2/dir3/dir4/dir5
[~/.../dir3/dir4/dir5] %
As you can see, it trim the path to just 3 directories. If you want two directories, then
Code:
export PROMPT_DIRTRIM=2
[~/.../dir4/dir5] %
This is not permanentm it will expire when you close the terminal. To make it permanent add it to your .bashrc file
Does not work on Zsh. Keep in mind that not all people use Bash.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.