Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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`%# "'

Result:

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

 
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.