-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
59 lines (47 loc) · 1.91 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
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
. ~/.git-completion.bash
# Git prompt components
function minutes_since_last_commit {
now=`date +%s`
last_commit=`git log --pretty=format:'%at' -1`
seconds_since_last_commit=$((now-last_commit))
minutes_since_last_commit=$((seconds_since_last_commit/60))
echo $minutes_since_last_commit
}
grb_git_prompt() {
# Set Colors
local NORMAL="\e[m"
local RED="\e[1;41m"
local YELLOW="\e[2;43m"
local GREEN="\e[2;42m"
local g="$(__gitdir)"
if [ -n "$g" ]; then
local MINUTES_SINCE_LAST_COMMIT=`minutes_since_last_commit`
if [ "$MINUTES_SINCE_LAST_COMMIT" -gt 30 ]; then
local COLOR=${RED}
elif [ "$MINUTES_SINCE_LAST_COMMIT" -gt 10 ]; then
local COLOR=${YELLOW}
else
local COLOR=${GREEN}
fi
local SINCE_LAST_COMMIT="${COLOR}$(minutes_since_last_commit)m${NORMAL}"
# The __git_ps1 function inserts the current git branch where %s is
local GIT_PROMPT=`__git_ps1 "(%s|${SINCE_LAST_COMMIT})"`
echo ${GIT_PROMPT}
fi
}
#PS1="[\u@\h \W]\$" # OLD Promp
PS1="[\u@\h \W]\$(grb_git_prompt)$"
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGE
# User specific aliases and functions
alias start-apache='systemctl start httpd'
alias stop-apache='systemctl stop httpd'
alias start-mariadb='systemctl start mariadb'
alias stop-mariadb='systemctl stop mariadb'
alias start-server='start-apache && start-mariadb'
alias stop-server='stop-apache && stop-mariadb'