-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc_prompt
44 lines (34 loc) · 1.98 KB
/
.bashrc_prompt
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
#
# The prompt module for posted .bashrc.
#
# This module will help configure the shell prompt and try not to hurt the original PS1 whatever it is.
#
# For my desktop (>>'Linux zb 4.8.0-53-generic #56~16.04.1-Ubuntu SMP Tue May 16 01:18:56 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux'<< from `uname --all`), line 18, 19 in /etc/bash.bashrc give the following.
#
# Line18: set a fancy prompt (non-color, overwrite the one in /etc/profile)
# Line19: export PS1='${debian_chroot:+($debian_chroot)}\u@\h \w \$ '
#
# Where in ~/.bashrc, PS1 is set as the following:
#
# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \$\[\033[00m\] '
# PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h \w\a\]$PS1"
#
# Backing up the current PS1 and providing reset cmd in case for need.
export PS1BACKUP=$PS1
alias reset-ps1-to-origin="export PS1=\$PS1BACKUP"
# Removing the >>'$'<< sign and spaces around from original PS1. Substring matches the pattern >>' \$*'<< will be removed.
export PS1=${PS1/' \$'*/''}
# Removing any characters following with the last occurrence of ' \$*' in $PS1.
# export PS1=`echo $PS1 | sed 's/\(.*\)\\\$.*/\1/'`
# Posted .bashrc for shell prompt for git.
# Display git branch in bash prompt.
# It may be displayed unexpectedly or cause some error, so try it out by yourself; (it's fun :).
# @see https://gist.github.com/justintv/168835
# Appending >>'(GIT_BRANCH_NAME)'<< (Git branch name wrapped in parentheses/round-brackets) with a color of blue.
export PS1=$PS1'\[\033[01;31m\]$(__git_ps1 '"'"'(%s)'"'"')'
# Appending >>' $ '<< (a dollar sign with spaces around) with color being set as red.
export PS1=$PS1'\[\033[01;34m\] \$'
# Appending >>' '<< (a space) and set prompt color to white.
export PS1=$PS1'\[\033[00m\] '
# And finally the PS1 probably will be something like >>\[\e]0;\u@\h \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w\[\033[01;31m\]$(__git_ps1 '(%s)')\[\033[01;34m\] \$\[\033[00m\]<<