183 lines
3.4 KiB
HTML
183 lines
3.4 KiB
HTML
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>What to Put in Your Prompt</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
|
|
REL="HOME"
|
|
TITLE="Bash Prompt HOWTO"
|
|
HREF="index.html"><LINK
|
|
REL="UP"
|
|
TITLE="External Commands"
|
|
HREF="c262.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="External Commands in the Prompt"
|
|
HREF="x279.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Saving Complex Prompts"
|
|
HREF="saving-complex-prompts.html"></HEAD
|
|
><BODY
|
|
CLASS="SECT1"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
SUMMARY="Header navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>Bash Prompt HOWTO: </TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x279.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
>Chapter 4. External Commands</TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="saving-complex-prompts.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="SECT1"
|
|
><H1
|
|
CLASS="SECT1"
|
|
><A
|
|
NAME="AEN295"
|
|
></A
|
|
>4.3. What to Put in Your Prompt</H1
|
|
><P
|
|
>You'll find I put username, machine name, time, and current directory name
|
|
in most of my prompts. With the exception of the time, these are very
|
|
standard items to find in a prompt, and time is probably the next most
|
|
common addition. But what you include is entirely a matter of personal
|
|
taste. Here is an interesting example to help give you ideas. </P
|
|
><P
|
|
>Dan's prompt is minimal but very effective, particularly for the way he
|
|
works. </P
|
|
><TABLE
|
|
BORDER="1"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
>[giles@nikola:~]$ PS1="\!,\l,\$?\$ "
|
|
1095,4,0$ non-command
|
|
bash: non-command: command not found
|
|
1096,4,127$ </PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
>Dan doesn't like that having the current working directory can resize the
|
|
prompt drastically as you move through the directory tree, so he keeps
|
|
track of that in his head (or types "pwd"). He learned Unix with csh and
|
|
tcsh, so he uses his command history extensively (something many of us
|
|
weaned on Bash do not do), so the first item in the prompt is the history
|
|
number. The second item is the tty number, an item that can be useful to
|
|
"screen" users. The third item is the exit value of the last
|
|
command/pipeline (note that this is rendered useless by any command
|
|
executed within the prompt - you can work around that by capturing it to
|
|
a variable and playing it back, though). Finally, the "\$" is a dollar
|
|
sign for a regular user, and switches to a hash mark ("#") if the user is
|
|
root. </P
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
SUMMARY="Footer navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x279.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
ACCESSKEY="H"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="saving-complex-prompts.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>External Commands in the Prompt</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="c262.html"
|
|
ACCESSKEY="U"
|
|
>Up</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Saving Complex Prompts</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |