Date: Sat, 6 Jul 1996 02:22:48 -0700 (PDT) From: Jim Dennis <jim@starshine.org> To: gif@loop.com (Gifka Sovereign) Cc: rcutter@ctgusa.com, questions@FreeBSD.org, jadestar@rahul.net Subject: Re: Changing prompt Message-ID: <199607060922.CAA06354@starshine> In-Reply-To: <Pine.BSI.3.94.960705233358.588A-100000@loop.com> from "Gifka Sovereign" at Jul 5, 96 11:43:08 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> > On Fri, 5 Jul 1996, Ryan Cutter wrote: > > How can I change my prompt in FreeBSD to reflect the current > > directory I'm in? > Seeing that someone has already shown you how to do it in CSH, I'll give > you the BASH answer: > In $HOME/.profile type: PS1='$PWD ' > You can do a: PS1='$PWD> ' You could but bash offers much better options. BASH Prompt Mini-HOWTO You could use PS1='\w' or PS1='\w>' or PS1='\W' etc (depends on whether you want a full path or just the tail of the working path). Here's my favorite: PS1='\! \h:\w\$' Which translates to: Current history number (handy for !-xxx subsititions) Current hostname Current working path "Proper" prompt = '#' for root or '$' for any other user If you wanted to go overboard you could use: PS1='\# \d \t\n\! \u@\h:\w\$' Which uses all but a couple of the bash "PROMPTING" meta characters. It produces output like: 112 Sat Jul 6 02:32:55 1502 jim@starhome:~/Mail$ (The number of this command within this session, the date, the time, my current user name, host, and directory, and the tradition '$'|'#' depending on my user status). The only ones I left out are the \s (shell's base name) and \[\] (non-printing character, for terminal control sequences) \xxx (octal? -- arbitrary ASCII character) and \\ (for a literal 'backslash' If you *really* want to have fun look at the man page entry for bash and read about the $PROMPT_COMMAND variable -- you can set that to a custom program to be executed prior to each issuance of your prompt. (One practical application for that might be to set the EXINIT variable depending on whether you're in a "safe" directory or not -- to prevent the old .exrc exploit but still allowing you to have custom .exrc files for some directories).
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199607060922.CAA06354>