From owner-freebsd-questions Sat Jul 6 04:05:05 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id EAA18094 for questions-outgoing; Sat, 6 Jul 1996 04:05:05 -0700 (PDT) Received: from hustle.rahul.net (hustle.rahul.net [192.160.13.2]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id EAA18074 for ; Sat, 6 Jul 1996 04:04:59 -0700 (PDT) Received: by hustle.rahul.net with UUCP id AA00367 (5.67b8/IDA-1.5 for questions@FreeBSD.org); Sat, 6 Jul 1996 04:04:20 -0700 Received: (from jim@localhost) by starshine (8.6.11/8.6.9) id CAA06354; Sat, 6 Jul 1996 02:22:49 -0700 From: Jim Dennis Message-Id: <199607060922.CAA06354@starshine> Subject: Re: Changing prompt To: gif@loop.com (Gifka Sovereign) Date: Sat, 6 Jul 1996 02:22:48 -0700 (PDT) Cc: rcutter@ctgusa.com, questions@FreeBSD.org, jadestar@rahul.net In-Reply-To: from "Gifka Sovereign" at Jul 5, 96 11:43:08 pm X-Mailer: ELM [version 2.4 PL24] Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-questions@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk > > 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).