shell prompts

there are 4 variables that define the command line prompt:
  1. PS1
  2. PS2
  3. PS3
  4. PS4

Added information in our PS2 prompt

This prompt appears if you have not completed the command properly, it may appear to be "hung". A control C or break or delete command should release you. EXAMPLE: PS2="*--> additional input required: > "; export PS2

Wait, HOW do I set the prompt variable?

Depending on the version of your operating system you will have to do one of the following to allow the prompt to work, this is done at the command line or in the .profile or .kshrc files: 1) declare and export 2) export or 3) declare examples: 1) PS1="`hostname`.`whoami`--> " ; export PS1 2) export PS1="`hostname`.`whoami`--> " 3) PS1="`hostname`.`whoami`--> "

Added information in our PS1 prompt

Often times we wish to see certain information before we execute a command. For example: 1) where we're at in a directory. 2) who we're logged in as 3) which system we're on 4) even the date and time (although it won't be updated continously) We can view the entire path or just the current working directory. Below are prompts (PS1) that will provide that visibility. ( the C shell is not recommended, so emphasis is placed on Korn/Bourne and Posix shells)

Present Working Directory - Korn / Posix Shell only

a prompt that wraps the line:

This prompt displays: -------------------------------------- username@hostname [present directory] >--> the code is: PS1=" ----------------------------------------------------- $(/usr/bin/whoami)@$(/usr/bin/hostname) [\$PWD] >--> "; export PS1 ############################################################################# This prompt is useful for a DTTERM, as it places userid, hostname and pwd in the title bar: export WHMI=$(/usr/bin/whoami) export WHST=$(/usr/bin/hostname) export PS1="$(print '\001\015\001\0033]2; $WHMI ---> \"$WHST\" ---> $PWD \007 ----------------------------------------------------- $WHMI@$WHST [$PWD] >-->\001 ')"

How do I get the current directory into my prompt?

This prompt is to display ONLY the directory name, without the path information. ----------------------------------------------------------------------- ####################################################################### # # How do I get the current directory into my prompt? # ####################################################################### # # Korn Shell (ksh): # # Put this in your .profile file to display the full path: # PS1='$PWD $ ' # # If you just want ONLY the last component of the directory, use: # PS1='${PWD##*/} $ ' # ####################################################################### # # Bourne Shell (sh): # # If you have a newer version of the Bourne Shell (SVR2 or newer) # you can use a shell function to make your own command, "xcd" say: # # xcd() { cd $* ; PS1="`pwd` $ "; } # # If you have an older Bourne shell, it's complicated but not # impossible. Here's one way. Add this to your .profile file: # # LOGIN_SHELL=$$ export LOGIN_SHELL # CMDFILE=/tmp/cd.$$ export CMDFILE # # 16 is SIGURG, pick a signal that's not likely to be used # PROMPTSIG=16 export PROMPTSIG # trap '. $CMDFILE' $PROMPTSIG # # and then put this executable script (without the indentation!), # let's call it "xcd", somewhere in your PATH # # : xcd directory - change directory and set prompt # : by signalling the login shell to read a command file # cat #${CMDFILE?"not set"} <

ebook:
Full Size
Jeep Buyer's
Guide
ebook:
Practical Suggestions
for Microsoft
Windows
Linux Tackles Microsoft
12 hour Video Course by john:
The Art of Linux System Administration
published by O'Reilly Media
Study Guide for the LPIC-2 Certification Exams
search for:
on the internet, or:
JohnMeister.com-fotos
LinuxMeister-Linux
BibleTech-
Bible overview


An overview of Biblical history:
"Promises and Prophets"

Wagoneers

FULL SIZE JEEPS

JeepMeister
"Jeep is America's
only real sports car."
-Enzo Ferrari


MeisterTech
Diesels +

One Page Overview of Linux Commands

click for an image of the 5 essential Linux commands

An Intro to Linux
AMSOIL product guide,
or, AMSOIL web, or 1-800-956-5695,
use customer #283461

Amsoil dealer since 1983
purchase AMSOIL
at Midway Auto on SR9 in Snohomish,
or at Northland Diesel in Bellingham, WA


SJ - 1962-1991

XJ - 1984-2001

WJ - 1999-2004

KJ - 2002-2007

WK - 2005-2010

Find the recommended
AMSOIL synthetics
for your Jeep

CJ-10A - 1984-1986

Jeepsters

MJ - 1984-1992

Willys - 1946-1965

Other Jeeps (FC)