4

when i open the terminal, it looks like this (without the *'s)

montenrgro@montenrgro-GE620-*******-*******-*****:~/Desktop$ 

the code thing and montenrgro@montenrgro takes up a lot of space, on my laptop. Any way I can decrease it to just: /home/Desktop. I'm sure there is some kinda of specialization to the terminal, but i can't find it. I've tried changing profile but that doesn't seems to work either

4

Don't forget to put the following line in your ~/.bashrc file, if you want the PS1 (stands for First Prompt String) to be permanent:

export PS1="\\w$ "

Similarly you can also change PS2 or PS3.

4

You can use the variable PS1. So you would do:

$ PS1=\\w$

to get what you want. You can read the manual page

$ man bash

and see under "PROMPTING" to read about the different options. Remember that you need to escape a backslash into a double backslash for the codes like \w.

  • when i write PS1 in the terminal, it gives me command not found – John Deer Aug 13 '12 at 11:22
  • The command is sensitive to spaces - PS1=\\w$ should work. (In the shell foo=bar sets variable foo to bar, foo = bar calls the program foo (if it exists) with arguments ` = bar`). – chronitis Aug 13 '12 at 11:46
  • edited the answer per chronitis' correction – John S Gruber Aug 13 '12 at 16:16
4

You should write:

export PS1=\\w$

in the end of the file ".bashrc" in your home directory.

Or use the command echo 'export PS1=\\w$' >> ~/.bashrc, that will do it without needing to open the file with a text editor.

  • It doesn't seem necessary to export this to the environment, just setting the PS1 variable seems to suffice. – John S Gruber Aug 13 '12 at 16:16
0

Using parse_git_branch, the following works as well.

if [ "$color_prompt" = yes ]; then
 PS1='NAME\w$(parse_git_branch)\[\033[00m\]\$ '
else
 PS1='NAME\w$(parse_git_branch)\$ '
fi

where you replace NAME with whatever you want displayed.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.