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've just started using tmux. Some workflows I have at the moment work very well with a vertically-split, 1/3rd-2/3rd screen (or 1/4-3/4).

Unfortunately, the zsh prompt I currently have, when I'm working on this particular task, gets too long (thanks to long prompts).

Is there a way that I can choose the prompt I want to use per-session, to allow me to use a shorter, more task-specific prompt in the smaller window, and a larger prompt in the second window?

share|improve this question
add comment

1 Answer

  • to specifically truncate one shell and not another, you should have i. some way to tell one from the other and a shell function call inside your prompt definition such as

    setopt PROMPT_SUBST
    function my_local_function() { ... }
    PROMPT='%B%m%~%b$(my_local_function) %# '
    

See this for a real life example of mucking with the prompt using functions (<-- disclaimer: notice that the lame git prompt code project there is my own...)

Alternatives are:

  • You can place a ternary expression inside your prompt %(x.true-text.false-text) (see the shell manual). Can be used to truncate the number of displayed dirs.

  • You can also restrict the length of the prompt truncating it with %8<..<%/.

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.