Skip to content

Commit

Permalink
extract bash prompt from dotfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
koffeinfrei committed May 10, 2019
0 parents commit 286c1ae
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vendor/bash-git-prompt"]
path = vendor/bash-git-prompt
url = git@github.com:koffeinfrei/bash-git-prompt.git
36 changes: 36 additions & 0 deletions bash-prompt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

source "${BASH_SOURCE%/*}/vendor/bash-git-prompt/bash-git-prompt"

# parameters:
# $1: chroot
set_bash_prompt() {
local chroot=$1

local color_path="\[\033[0;37m\033[01;2m\]"
local color_git="\[\033[01;22m\033[34m\]"
local color_space="\[\033[37m\]"
local color_icon="\[\033[1m\033[01;32m\]"
local color_reset="\[\033[00m\]"

case "$TERM" in
xterm-color|xterm|screen-256color) color_prompt=yes;;
esac

if [ "$color_prompt" = yes ] || [ "$COLORTERM" = truecolor ]; then
PS1="${chroot:+($chroot)}$color_path \w $color_git$(__git_ps1_improved)$color_space $color_icon$color_reset "
else
PS1="${chroot:+($chroot)} \w $(__git_ps1_improved)"
fi

unset color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${chroot:+($chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
}
1 change: 1 addition & 0 deletions vendor/bash-git-prompt
Submodule bash-git-prompt added at 45e449

0 comments on commit 286c1ae

Please sign in to comment.