I would like to have all the information about working environment: git branch, name of virtualenv, current folder on the first line of the terminal window, always. In my idea it should look something like this:

[git branch](virtualenv)user@host:<pwd> # this part shouldn't move
here is standard terminal output
$ # last line for writing commands

Is it possible? If so, how can I accomplish that?

  • Should this be only shown when the shell is waiting for input or all of the time, so even during output of an program or when an application like vim or less is open?
    – Adaephon
    Feb 12, 2017 at 10:57
  • @Adaephon Only when shell is waiting for input. But, if it is easier to show it all the time - I will try this approach.
    – gasabr
    Feb 12, 2017 at 11:24

1 Answer 1


For zsh, just add this to your .zshrc file:

zmodload zsh/terminfo
autoload -Uz add-zsh-hook
statusbar () {
  echoti sc                   # Save cursor position.
  echoti home                 # Move cursor to top left of window.

  # -n: Don't append a newline.
  # -P: Expand prompt escape codes.
  print -nP -- "[$( git branch --show-current 2> /dev/null )]($VIRTUAL_ENV)%n@%M:%~"

  echoti el                   # Clear to end of line
  echoti rc                   # Restore cursor position.
add-zsh-hook precmd statusbar # Call before each new prompt.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.