0

I have set the prompt on my machine using the following code:

set prompt = " %B%{\033[34m%}`hostname`: %c %D/%w %p :) %b" 

It outputs my preferred customized display . It looks like :

Custom Prompt

However when I issue a echo $prompt command, it returns missing ]. I belive I did properly refer to the Customization Manual .

1 Answer 1

3

You've run into one of tcsh's parsing quirks. From the tcsh manual:

Variable substitution Unless enclosed in ' " ' or given the ':q' modifier the results of variable substitution may eventually be command and filename substituted.

You have a variable that expands to something syntactically incorrect for filename substitution. You can prevent that substitution by typing echo "$prompt" or echo $prompt:q .

Example:

% set prompt = " %B%{\033[34m%}`hostname`: %c %D/%w %p :) %b" host.example.com: ~ 12/Dec 9:46:12am :) echo $prompt:q | cat -v %B%{^[[34m%}host.example.com: %c %D/%w %p :) %b 
2
  • well echo "$prompt" and echo $prompt:q does give me half answer. it returns the evaluated value of hostname and also color. Commented Dec 12, 2014 at 8:49
  • You can pipe the echo command through cat -v if you want the \033 character not to show up literally in the output; I've added that to the answer. The hostname command is evaluated and substituted (by command substitution) when the set command is executed; after that, the characters `hostname` do not exist in the prompt variable. You can put %M in the prompt variable if you want the current hostname to be retrieved and printed every time a prompt is printed. Commented Dec 12, 2014 at 15:08

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.