-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathbashrc
115 lines (92 loc) · 2.34 KB
/
bashrc
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# ~/.bashrc
umask 072
##########################
# 1. Basic Configuration #
##########################
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# Platform detection
platform='linux'
if [[ `uname` == 'Darwin' ]]; then
platform='mac'
fi
# history settings
shopt -s histappend # append, no overwrite
HISTSIZE=10000
HISTFILESIZE=20000
# ulimits
ulimit -n 10240
# Clear environment variables in nested session
unset VIM
unset VIMRUNTIME
##############
# 2. Aliases #
##############
# ls color and with classfication
if [[ $platform == 'mac' ]]; then
alias ls='ls -F -G'
else
alias ls='ls -F --color=auto'
fi
alias ll='ls -alF'
# grep
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# alert for rm, cp, mv
alias rm='rm -iv'
alias cp='cp -ivp'
alias mv='mv -iv'
# screens
alias scr='screen -rD'
# inspect $PATH
path() {
printf "%s\n" $(echo $PATH | tr ":" "\n")
}
##################
# 3. Color & PS1 #
##################
COLOR_NONE="\e[0m"
BLACK="\033[0;30m"
RED="\033[0;31m"
GREEN="\033[0;32m"
YELLOW="\033[0;33m"
BLUE="\033[0;34m"
PURPLE="\033[0;35m"
CYAN="\033[0;36m"
GRAY="\033[0;37m"
BOLD_RED="\033[1;31m"
BOLD_GREEN="\033[1;32m"
BOLD_YELLOW="\033[1;33m"
BOLD_BLUE="\033[1;34m"
BOLD_PURPLE="\033[1;35m"
BOLD_CYAN="\033[1;36m"
WHITE="\033[1;37m"
git_branch() {
local git_branch=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'`
local git_stat="`git status -unormal 2>&1`"
local color_stat=''
if [[ "$git_stat" =~ "nothing to commit" ]]; then
color_stat="$GREEN"
elif [[ "$git_stat" =~ "nothing added to commit but untracked files present" ]]; then
color_stat="$LIGHT_GREEN"
elif [[ "$git_stat" =~ "# Untracked files:" ]]; then
color_stat="$YELLOW"
else
color_stat="$RED"
fi
echo -en "$color_stat$git_branch"
}
PS1="\[$BOLD_GREEN\][\[$BOLD_YELLOW\]\u\[$BOLD_GREEN\]@\[$BOLD_BLUE\]\h:\[$BOLD_RED\]"'`pwd`'"\[$BOLD_GREEN\]] "'`git_branch`'" \[$GRAY\]\t\n\[$BOLD_GREEN\]"'\$'"\[$COLOR_NONE\] "
# Terminal
export TERM="xterm-256color"
# PATH for local settings
if [[ ! "$PATH" == *~/.local/bin* ]]; then
export PATH="~/.local/bin:$PATH"
fi
# Additional Completion
if [ -f /usr/local/etc/bash_completion ]; then source /usr/local/etc/bash_completion; fi
# Local bashrc
if [ -f "$HOME/.bashrc.local" ]; then
source "$HOME/.bashrc.local"
fi