-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_bashrc_prompt
More file actions
27 lines (21 loc) · 1.13 KB
/
dot_bashrc_prompt
File metadata and controls
27 lines (21 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Show git branch in prompt if one exists
# https://askubuntu.com/questions/730754/how-do-i-show-the-git-branch-with-colours-in-bash-prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
# Color prompt!
# https://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/
#export PS1="\[$(tput setaf 4)\]\[$(tput bold)\]\u@\h:\w $(tput setaf 7)$(parse_git_branch)$ \[$(tput sgr0)\]"
# The above prompt results in a failure to line wrap. This is supposed to be better
# https://stackoverflow.com/questions/1133031/shell-prompt-line-wrapping-issue
green=$(tput setaf 2)
blue=$(tput setaf 4)
white=$(tput setaf 7)
bold=$(tput bold)
reset=$(tput sgr0)
branch=$(parse_git_branch)
# Doesn't update when cd-ing in/out of a repo
#export PS1="\[$green$bold\]\u@\h\[$reset\]:\[$blue$bold\]\w \[$white$bold\]\[$branch\]\[$reset\]\$ "
# https://gist.github.com/justintv/168835
export PS1="\[$green$bold\]\u@\h\[$reset\]:\[$blue$bold\]\w \t \[$white$bold\]\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\[\$reset\]\$ "