Unix Power ToolsUnix Power ToolsSearch this book

4.11. Right-Side Prompts

Both zsh and tcsh have an optional prompt at the right side of the screen. Unlike the normal left-side prompt, the cursor doesn't sit next to the right-side prompt (though the right prompt disappears if you type a long command line and the cursor passes over it). It's stored in the zsh RPROMPT variable and in tcsh rprompt.

What can you do with a right-hand prompt? Anything you want to! (You'll probably want to keep it fairly short, though.) Put the time of day on the right-hand side, for instance; on tcsh, it's this easy:

[jpeek@ruby ~]% set rprompt='%t'
[jpeek@ruby ~]% users                                         3:44pm
jpeek ollie
[jpeek@ruby ~]%                                               3:45pm

As another idea, you could use sched to remind you of an important meeting by setting the right-hand prompt. Here's a shell function for zsh that sets the right prompt to "LEAVE NOW" at a particular time. You can give it one argument to set the time to remind you. Or, with no argument, it removes the right-hand prompt:

leave( ) {
    case "$#" in
    0) unset RPROMPT ;;
    1) sched "$1" "RPROMPT='LEAVE NOW'" ;;
    *) echo "Usage: leave [time]" 1>&2 ;;
    esac
}

Here's an example:

jpeek$ date
Fri May 12 15:48:49 MST 2000
jpeek$ leave 15:55
   ...do some work...
jpeek$ pwd
/u/jpeek/pt
jpeek$ date                                        LEAVE NOW
Fri May 12 15:55:22 MST 2000
jpeek$ lpr report                                  LEAVE NOW
jpeek$ leave                                       LEAVE NOW
jpeek$

--JP and SJC



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.