ps1gen generates a command prompt for ksh93 or bash with the following features:
- colorized current working directory.
- current git branch, if in a git repo.
- exit status in red of last executerd command, if non-zero.
Setup
- You need to source ps1gen.sh to install the function 'ps1gen'.
- Add this to .profile, .bashrc and/or .kshrc:
- . ps1gen.sh # install functions
- export PS1="`ps1gen`" # use ps1gen function to generate prompt
Customize:
- Set any of these variables in .profile before ps1gen.sh to customize:
- PS1GEN_EXIT_STATUS_COLOR=196 # red
- PS1GEN_GIT_BRANCH_COLOR=10 # green
- PS1GEN_GIT_TAG_COLOR=11 # yellow
- PS1GEN_GIT_INCLUDE_HOME=0 # 1=show git branch in $HOME directory
- PS1GEN_CWD_COLOR=7 # white
- PS1GEN_TEXT_COLOR=208 # amber
- PS1GEN_PROMPT="$ " # default prompt, $
Sample output:
- Git repo branch:
- ~/src/vim{master}$
- Non-zero exit status:
- ~$ xyz
- -bash: xyz: command not found
- ~127$
Source
- git@github.com:lampert/ps1gen.git
Enjoy.
- -Paul Lampert