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'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
  • 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

You must log in to answer this question.

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