-
Notifications
You must be signed in to change notification settings - Fork 19
/
.bashrc
52 lines (43 loc) · 1.07 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
#!/bin/bash
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export SHELL=/bin/bash
export TERM=xterm
function get_hostname {
export SHORTNAME=${HOSTNAME%%.*}
}
function git_branch() {
gitbranch=$(git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/');
}
function user_color {
id | grep "root" > /dev/null
RETVAL=$?
if [[ $RETVAL == 0 ]]; then
usercolor="[0;31m";
else
usercolor="[0;32m";
fi
}
function settitle() {
u=${USERNAME}
h="$u@${HOSTNAME}"
echo -ne "\e]2;$h\a\e]1;$h\a";
}
# Set directory colors
eval `dircolors ~/.dir_colors`
# Set prompt and window title
inputcolor='[0;37m'
cwdcolor='[0;34m'
host_name='[1;31m'
branchcolor='[0;36m'
user_color
PROMPT_COMMAND='settitle; git_branch; get_hostname; history -a;'
PS1='\n\[\e${cwdcolor}\][${PWD}]\[\e${branchcolor}\]${gitbranch}\n\[\e${usercolor}\][\u]\[\e${host_name}\][${SHORTNAME}]\[\e${inputcolor}\] $ '
export PS1
# Aliases
alias ls='ls -l --color'
alias grep='grep -n --color'