Xref: utzoo comp.unix.misc:955 comp.windows.misc:1814 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!agate!usenet.ins.cwru.edu!ncoast!allbery From: allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) Newsgroups: comp.unix.misc,comp.windows.misc Subject: Re: prompt question Message-ID: <1991Feb12.023428.16031@NCoast.ORG> Date: 12 Feb 91 02:34:28 GMT References: <1991Jan23.083259.16296@daimi.aau.dk> <51331@sequent.UUCP> Reply-To: allbery@ncoast.ORG (Brandon S. Allbery KB8JRR) Followup-To: comp.unix.misc Organization: North Coast Public Access Un*x (ncoast) Lines: 92 As quoted from by dfs@doe.carleton.ca (David F. Skoll): +--------------- | In <51331@sequent.UUCP> edw@sequent.UUCP (Ed Wright) writes: | | >You can take that to a silly extreme | >alias cd 'cd \!* ;set prompt=`hostname`" "`whoami`" "`pwd`" {\!} "' | | I have taken my prompt to an even SILLIER extreme (but I like it.) Here's | an extract from my .cshrc: > (deleted for brevity) | This is what is looks like right now: | | --> /enterprise/transporter/dfs <-- | 2: dfs@riker(ttyp4)% +--------------- If you don't mind some ksh injected into this discussion: case "$-" in *i*) typeset -i Level Level=${LEVEL:-0} Level=$Level+1 LEVEL=$Level unset Level export LEVEL case $LEVEL in 1) level="" ;; *) level="${LEVEL}@" ;; esac UID="`id|sed -n 's/^uid=\([0-9][0-9]*\)(.*$/\1/p'`" case "$UID" in 0) prompt='K#' ;; 204) prompt='K$' ;; *) prompt="`awk -F: '$3 == '$UID' { print \"{\" $1 \"}\" exit }' /etc/passwd` K$" ;; esac PS1="${level}`uname -n`:! ${prompt} " unset prompt level ;; esac This is actually an older version; my current version is driven off the login name, but it's on a different machine. The prompt, in both versions, looks like: 2@ncoast:141 K$ _ ("_" is the prompt, a convention of mine in messages which include interactive shell stuff.) "2@": 2nd level login; 141: command number; "K" to remind me it's Korn shell; "$" because it's non-root. Root gets "K#"; if I su to anyone else, I get: 2@ncoast:142 {news} K$ _ The newer version also indicates the (compressed) tty and directory stack depth, if it's not 1: 2@telotech[con/0]:143 (test) K$ pwd /u/allbery 2@ncoast[con/0]:144 (test) K$ pushd /tmp /tmp /u/allbery 2+2@ncoast[con/0]:145 (test) K$ _ The console is "con"; MultiView windows (a sort of "screen" which emulates the real terminal instead of a VT102) are indicated as real-tty/windo-number ("con/0"); there is no [] if it's not running on a terminal-like fd (i.e. a pipe). The () is a project ID; it's omitted if I haven't set a project. This is usually a handier method of identifying a window than the window number. (The directory stack is implemented via ksh functions, and includes most, if not all, of the csh directory stack facilities.) I tried including the current directory in the prompt, but it got too big too fast; it's big enough as it is, and paths are generally a lot longer than the other stuff I include. And I detest two-line prompts. Moreover, the project ID is usually sufficient for my needs, since a project usually has a specific directory associated with it. ++Brandon -- Me: Brandon S. Allbery VHF/UHF: KB8JRR on 220, 2m, 440 Internet: allbery@NCoast.ORG Packet: KB8JRR @ WA8BXN America OnLine: KB8JRR AMPR: KB8JRR.AmPR.ORG [44.70.4.88] uunet!usenet.ins.cwru.edu!ncoast!allbery Delphi: ALLBERY