Bash

Bash Prompt

You can find my bash-prompt ('trexprompt') in my dotfiles repository on github.

Features

  • Shows the current path, trimmed in the middle for very long paths.
  • Shows the current load and time when last command finished on very wide terminals, right aligned.
  • When inside a Git repository, shows the current branch and state
  • Shows the exit code of the previous command when non-zero
  • Configurable colors (left and right)
  • When no colors are configured, colors will be calculated based on the hostname. So every host will automatically display other colors.

Installation and configuration

To install the prompt take the following steps:

  1. Clone the repository somewhere on your system: git clone git://github.com/teranex/dotfiles.git
  2. Source the trexprompt file from your .bashrc: source ~/path/to/dotfiles/bash/trexprompt
  3. Optionally configure colors:
    1
    2
    
    PROMPT_COLOR_1="\[\033[48;5;172m\]"
    PROMPT_COLOR_2="\[\033[48;5;23m\]"

    This uses color codes for a 256-color terminal. You can use the xterm-colortest script from my dotfiles repository to find colors.

Screenshot

Screenshot