export SHORTHOST=$(echo $HOSTNAME | awk -F"." '{ print $1 }'}
export PS1="($SHORTHOST:$parent/$this) "

should do it.

E


On Mon, 8 Oct 2001, Justin H. wrote:

> Im trying to set up my shell prompt so that it shows
> the hostname followed by some directory info.  I
> usually do it as follows -
>
>
> where $parent and $this are previously set to be the parent
> dir and working dir.  THis works good, except on systems
> where the $HOSTNAME is set to be the fully qualified
> name, eg host.domain1.domain2.com ... because on these
> systems the prompt is just too long (i dont have permission
> to change the hostname definition).  For example, on one
> of these systems, the above prompt definition will expand
> to be something like ...
>
> (host.domain1.domain2.com:/parent_dir/this_dir)
>
> But, I really want it to be just ...
>
> (host:/parent_dir/this_dir)
>
> SO, does anyone know how I could set up the prompt on
> these systems so that it uses *only* the hostname?
> In other words, if Im on a system where the hostname
> is set to be the fully qualified dns name, how can I extract
> *just* the hostname itself and assign it to the PS1?  (so
> it looks like the second example above)
>
> I hope this makes sense.
>
> --Justin.
>
>
>

-- 

Erik Curiel
Sometime Web Engineer/Almost Philosopher

"O, little rose-tree, bloom!
Summer is nearly over.
The dahlias bleed,
The phlox is seed,
Nothing is left of the clover.
And the path of the poppy no one knows---
I would blossom if I were a rose."

   ---Edna St. Vincent Millay
      "Three Songs from 'The Lamp and the Bell'"


Reply via email to