'cd' command increases size of shell propmt
Hi LQ,
When i change the directory using 'cd', the length of my shell prompt keeps on increasing. To make it more clear kindly see below Code:
$> cd MyWorks |
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). |
How come you are putting > cd?
you should just do it like this $cd MyWorks $cd Shell and so on. |
Sorry, I thought from your previous post that your prompt included a ">", but now I see you don't.
I am not typing the ">", I had it displayed on the end of the prompt. Without this, the commands I wrote should be: $ ~/Desktop echo $PS1 $ \w export PS1="\$ " |
$ ~/Desktop echo $PS1
$ \w $ ~/Desktop export PS1="\$ " $ echo $PS1 $ $ cd $ cd /var/log/ $ As you can see, the prompt is always the same size. To know here you are, you should use the "pwd" command: $ pwd /var/log |
Quote:
|
@ thelink123
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. % I saw this prompt from a unix or sun terminal - Cheers |
@dv502
Thanks :) I found out the same solution you provided in net. I was just about to add that for this thread, when i saw your post. Thanks, thelink123 |
You're Welcome...
|
All times are GMT -5. The time now is 09:12 PM. |