From owner-freebsd-questions Fri May 8 10:19:06 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA26120 for freebsd-questions-outgoing; Fri, 8 May 1998 10:19:06 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from garnet.dgms.com (pc-algier-p.dgms.com [206.67.30.153]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA26098 for ; Fri, 8 May 1998 10:18:43 -0700 (PDT) (envelope-from gaa@dgms.com) Received: from dgms.com (localhost [127.0.0.1]) by garnet.dgms.com (8.8.8/8.8.8) with ESMTP id MAA01194; Fri, 8 May 1998 12:17:18 -0400 (EDT) (envelope-from gaa@dgms.com) Message-ID: <3553300E.8072A332@dgms.com> Date: Fri, 08 May 1998 12:17:18 -0400 From: Gary Algier X-Mailer: Mozilla 4.04 [en] (X11; I; FreeBSD 2.2.6-RELEASE i386) MIME-Version: 1.0 To: freebsd-questions@FreeBSD.ORG, matt@zigg.com Subject: Re: parsable promptstring in sh? References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG owner-freebsd-questions@FreeBSD.ORG wrote: > > Can I somehow do this: > > set -o promptexpn > PS1=\`pwd\`$; export PS1 > > or some such to have a prompt that is expanded by sh? (I know there is no > promptexpn option, per se, but there's got to be something, right?) > > Matt Behrens | From an actual Linux machine, in > http://www.zigg.com/ | production use: > Chanop Script Coordinator | $ w > World-Wide FreeNet IRC Network | Segmentation fault > I use ksh (in the ports collection is shells/pdksh) and I use: -------------------------------------------------------------------- # simple prompt: export PS1="${USER:-${LOGNAME}}@${HOSTNAME%%.*} !% " # complex "prompt": if [[ -t 1 && $TERM = *xterm* ]] then # this will place: # the full path, less the home directory in the title bar # the last dir part in the icon name # the user@hostname and sequence in the prompt # the \$ sequences here are for defered expansion bell=$(print -n "\007") cr=$(print -n "\015") esc=$(print -n "\033") PS1="$esc]2; \${PWD#$HOME/}$bell" PS1="$PS1$esc]1; \${PWD##*/}$bell" PS1="$PS1$cr${USER:-${LOGNAME}}@${HOSTNAME%%.*} !% " unset bell cr esc fi -------------------------------------------------------------------- Notes: The $cr is used because the shell otherwise miscalculates the space left to the right of the prompt and will not show much at all. I put the path in the window title to keep it out of the way of my typing. I don't know how people can use a prompt that is 40 characters or more long (yes, I have even seen where someone was so deep down that the prompt wrapped!) Also, with ksh you get good command line editting: set -o vi # for vi style set -o emacs # for emacs style And much better shell functions, local variables, integer data types, etc. -- Gary Algier, WB2FWZ gary.algier@dgms.com +1 609 608 2758 DGM&S Telecom, 1025 Briggs Rd, Mt. Laurel, NJ 08054 Fax:+1 609 866 8850 Paul Petzoldt on the renaming of Mount Washington: "I Call it the New England Booby Trap. We see Ph.D.'s from private schools taking kids up there in shorts. People die like flies up there!" To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message