I would like to make my terminal's command prompt shorter. Currently I am using Python 's virtualenv and virtualenvwrapper so that is causing lots of extra text to be displayed in my command prompt. I need to shorten that up to the bare minimum so I'd like to take this:

(pytutorial)sez@sez-laptop:~/.virtualenvs/nettuts/firstblog$

and ideally turn it into

(pyt)sez:~/.virtualenvs/nettuts/firstblog$

or maybe something shorter perhaps. Right now I am using Gnome Terminal 2 & bash.

Any suggestions?

link|improve this question

50% accept rate
feedback

migrated from stackoverflow.com Dec 21 '11 at 9:35

This question came from our site for professional and enthusiast programmers.

5 Answers

up vote 3 down vote accepted

Your prompt can be set utilizing the PS1 envvar. For example to have a minimalist command prompt of '$" simply set PS1='$' in your .bashrc. Here are some good examples of setting a customized prompt

link|improve this answer
thanks ennuikiller – max Dec 20 '11 at 14:37
feedback

Edit your .bashrc and change the PS1 definition. See your own /etc/bashrc for an example, or see bash documentation.

link|improve this answer
feedback

I guess \u:\w\$ is what you need, where \u is your username and \w is the current working directory (\W is shorter). Modify your ~/.bashrc to change the prompt.

link|improve this answer
+1 ... in the middle of typing pretty much the same thing. – Chris J Dec 20 '11 at 14:04
feedback

I like to have my prompt in a separate line so I don't miss the info and I always have the whole line to type:

PS1=\\u@\\h\ \\w\\n\\$\ 
link|improve this answer
feedback

Simply type in your terminal nano .bash_profile. Copy:

export PS1="\u@\h\w: "

Save.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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