This repository has been archived by the owner on Mar 24, 2022. It is now read-only.
forked from gregz67/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bash_profile
58 lines (46 loc) · 1.7 KB
/
bash_profile
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#==========================================================================
# Source bashrc and aliases if present
#==========================================================================
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
if [ -f ~/.aliases ]; then
source ~/.aliases
fi
#==========================================================================
# Basic settings
#==========================================================================
# set default editor
export EDITOR=vim
# Make `ls` use colors
export CLICOLOR=1
#==========================================================================
# History
#==========================================================================
export HISTSIZE=10000 # increase the size
shopt -s histappend # append session commands to .bash_history
#==========================================================================
# Prompt
#==========================================================================
# Outputs the current branch name in parentheses, e.g., (master)
# If the current directory is not managed by git, there is no output.
function current_branch_name {
[[ $(git status 2> /dev/null) ]] && \
echo " ($(git branch 2> /dev/null | sed -n '/\* /s///p'))"
}
# Outputs an asterix if the working directory is dirty.
# Otherwise, there is no output.
function dirty_state {
[[ $(git status --porcelain 2> /dev/null) ]] && \
echo "*"
}
USERNAME='\u'
HOSTNAME='\h'
CURRENT_WORKING_DIR='\W'
GIT_BRANCH_NAME='$(current_branch_name)'
DIRTY_STATE='$(dirty_state)'
RED='\[\e[1;31m\]'
NO_COLOR='\[\e[0m\]'
YELLOW='\[\e[0;33m\]'
# assign new colorized prompt
export PS1="$YELLOW[$CURRENT_WORKING_DIR$GIT_BRANCH_NAME$RED$DIRTY_STATE$YELLOW]\$$NO_COLOR "