[SOLVED] 'cd' command increases size of shell propmt
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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.
You may remove the part of the shell prompt related to your current directory.
I assume you're using bash. So your prompt is regulated by the PS1 variable. You can check your PS1 variable with the command:
echo $PS1
It should be similar to this:
$ ~/Desktop >echo $PS1
$ \w >
You can simplify your prompt to never show the working directory, by exporting the PS1 variable with a new value:
export PS1="\$>"
Now your prompt will always be "$>" no matter what.
If you want to have the working directory, but truncated to a specific number of letters, you'll have to find something more fancy. I suggest you start reading "man bash" on the section "PROMPTING", and post your findings here. (You can also read that to understand in more detail the instructions I wrote above).
You may remove the part of the shell prompt related to your current directory.
I assume you're using bash. So your prompt is regulated by the PS1 variable. You can check your PS1 variable with the command:
echo $PS1
It should be similar to this:
$ ~/Desktop >echo $PS1
$ \w >
You can simplify your prompt to never show the working directory, by exporting the PS1 variable with a new value:
export PS1="\$>"
Now your prompt will always be "$>" no matter what.
If you want to have the working directory, but truncated to a specific number of letters, you'll have to find something more fancy. I suggest you start reading "man bash" on the section "PROMPTING", and post your findings here. (You can also read that to understand in more detail the instructions I wrote above).
The changes to the PS1 variable is temporary. To make it permanent, you'll need to edit /etc/bashrc and look for the PS1 variable line. This change will affect everyone on the system when they open a terminal. But, if you're the only user on linux, it's no problem.
If you have others using linux, and you want the PS1 prompt to apply to you only and no one else, you'll need to edit or create a hidden file called .bashrc in your home directory and add the line you want. For example:
export PS1="$ "
I use this for my prompt, export PS1="% " in my bashrc file.
%
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.