Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I used to know this but I forgot: I want to execute a command or a couple of commands before every single prompt. When I am in our PROD box, I want a big fat reminder above every prompt that says * YOU ARE IN PROD * and maybe another thing or two. Currently, I think that is how mail is checked but I can't remember how that configuration is set.

Using ksh and Solaris 5.10

Any idea?

Thanks

share|improve this question
2  
Bash has PROMPT_COMMAND, but not ksh. Couldn't you just set your warning in your PS1? –  jordanm Oct 4 '12 at 16:37
    
yes but that is just a static variable. let's say i want to run a command before every prompt, e.g. display the current size of my home directory (this was an arbitrary example but you get the point). –  amphibient Oct 4 '12 at 16:49
    
e.g. where is it specified that mail should be checked before every prompt? –  amphibient Oct 4 '12 at 16:50
2  
I'm not a ksh user, so leaving this for someone else to answer. But this seems to work for me (updating each time the prompt is renewed): export PS1='$(date -u +%s) ${ME}:${PWD}# ' –  ire_and_curses Oct 4 '12 at 17:04
add comment

2 Answers

I'd simply put it into /etc/profile, or /etc/issue. Sometimes displaying the contents of the issue file is turned off, but I'd still think it's a good reminder.

Changing the contents of the $PS1 variable is ok, I guess, you might want to still print some warnings /etc/profile. Since it's a production system, It's ok to edit those files, since here, you want lasting changes in the system. (Normally, I'd advise against changing those files and using user files instead.)

share|improve this answer
add comment

In ksh, $PS1 is subject to command substitution and parameter expansion, so you can do things like:

function mywarning {
  tput setaf 1; tput bold
  date "+it's %T, please remember it's a production system"
  tput sgr0
}

PS1='$(mywarning)# '
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.