cwd in promt (summary)
Brandon Jason Svec
bjsvec at cats.ucsc.edu
Wed Jun 19 08:21:55 AEST 1991
Thanks for all the prompt responses to my prompt question. Here is a short
summary of the first three responses I got.
I personally recommend the second one since it short and sweet.
----------------
alias pwd 'echo $cwd'
alias cd 'cd \!*; set prompt="`hostname`:$cwd>"'
alias popd 'popd \!*; set prompt="`hostname`:$cwd>"'
alias pushd 'popd \!*; set prompt="`hostname`:$cwd>"'
Thanks to: Kees denHartigh
----------------
alias cd 'cd \!*;set prompt = "$HOST [$cwd] % "'
Thanks to: James Cameron
----------------
alias cd 'cd \!*;set prompt="`whoami`@`hostname`:`truncdir.$ARCH` [\\!] "'
cd .
which gives me something like this:
steve at orchid:.../tina/modules/sd [7]
I have a little program called "truncdir", which prints out a string containing the last three components
of the path. Here's what it looks like:
main()
{
register int pos,num_dirs;
register char directory[100];
getwd(directory);
pos = strlen( directory );
num_dirs = 1;
while( num_dirs <= 3 && --pos > 0 )
if( directory[pos] == '/' )
num_dirs++;
if( pos > 0 )
printf( "..." );
printf( &directory[pos] );
}
Install this program with the sticky bit set so it stays resident, and it works great!
Thanks to: Steve Sandke
------------------
brandon at cats.ucsc.edu
More information about the Comp.unix.questions
mailing list