Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to customize my prompt to include the output of an arbitrary command, like you can do in bash (e.g., I'd like to cat a file and have its (one-word) contents appear in the prompt, or show the last-modified-date of a file).

Is there a way to do this?

share|improve this question
up vote 1 down vote accepted

The precmd alias is run just before the prompt is printed. You could use this alias to modify the prompt. For example, this will cause the date to be printed in the prompt:

alias precmd 'set prompt="%m:%c:`date`%# "'


localhost:~:Mon 13 May 13:44:20 BST 2013> 

Modify `date` in the above to be whatever command you want to run.

share|improve this answer

Your Answer


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.