Promptly

jonasbn on 2008-10-17T06:51:39

I have for a long time used the following prompt in my bash shell:

S1="\h \w\n\r% "
hoarfrost /Users/jonasbn % I do however sometimes resort to wanting to copy a path and command to another terminal, where I would just write cd

The % would however give the following error message when pasted:

-bash: fg: %: no such job

So I changed it to:

PS1="\h \w\n\r; "
Warning gone, I could remove the hostname to make it easier to copy it.

PS1="\h\n\w\n\r; "


Suggestions welcome:

In addition to the bash prompt, I find the following to prompt useful:

For MySQL:
MYSQL_PS1="(\u@\h) [\d]> "
For PostgreSQL (from .psqlrc)
\set PROMPT1 '(%n@%m) [%/]>'


These show the user, hostname and database. Having the two database engine prompt being uniform, is quite nice.

I found the following tip however, which includes transactional state in the prompt. This could prove quite useful.

prompt suggestions and examples welcome


# Shell prompt

parv on 2008-10-17T11:53:47

I use '#' (comment marker) at the beginning of the 2-line prompt (when using X; space is at premium on console). That way even if you copy the whole thing, one can still edit the lines before executing. (BTW, vi-mode in zsh is really excellent, much better than ksh93 or bash3.)

I like it in color

Eric Wilhelm on 2008-10-18T08:07:09

\n\[\033[45m\]\u@\h${debian_chroot:+ \[\033[0m\]($debian_chroot)\[\033[45m\]}: \[\033[49m\]\[\033[31m\]\w\n\[\033[0m\]\[\033[45m\]#\[\033[0m\]\t \[\033[45m\]$\[\033[0m\]

Color as hint

cosimo on 2008-10-18T08:30:56

I use color on my .psqlrc on production machines, in particular, the red color, to remember to think twice before "TRUNCATE"-ing tables or deleting stuff... :-)

\timing
\set PROMPT1 '%[%033[1;31;40m%]%n::%/@%`hostname -s` %x%R%[%033[0m\n%#%]'
\set PROMPT2 '... %#%] '