Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 am using vcprompt to provide me with the git branch and dirtiness status. It returns it as a string.

How can I catch this string in my tcsh prompt setting? I guess I need to put the call to vcprompt somehow in the prompt definition, but I can't find the syntax for that.

Edit: Solution is:

alias precmd "echo -n `vcprompt`"
share|improve this question
up vote 1 down vote accepted

In the original C shell, you could simply embed command substitution directly into the prompt variable, which I always thought made more sense. Under tcsh, you have to set up the precmd alias to do it. I'm not familiar with vcprompt but I assume it generates a newline at the end, so you'll probably want to use echo -n to throw away that newline, putting the prompt on the same line as the command, not the line before. Set prompt to whatever you want following; here I'm assuming you'll want a space.

alias precmd echo -n `vcprompt`
set prompt = ' '
share|improve this answer
    
Almost. Had to put quotes around everything after precmd. (And there seems to be no frickin' way to write that command line in a comment here without some markup happening... :( – K.-Michael Aye Oct 26 '12 at 22:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .