-
Notifications
You must be signed in to change notification settings - Fork 1
/
.bashrc
86 lines (70 loc) · 2.29 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
# .bashrc
# Use custom aliases, if file exists
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
if [ -f ~/.bash_aliases.git ]; then
. ~/.bash_aliases.git
fi
# For rvm
if [ -f ~/.profile ]; then
source ~/.profile
fi
# Increase scrollback
HISTSIZE=10000
HISTFILESIZE=20000
# User specific aliases and functions
# Don't add commands that start with a space to the bash history
export HISTCONTROL=ignoreboth
# Set vim as default editor
export EDITOR=vim
# Use colors
export CLICOLOR=1
# allow current tty to receive gpg password
export GPG_TTY=$(tty)
# Check if directory exists, and add to path (if it isn't already in the path)
pathadd() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
if [ -n "$2" ]; then
# Add to front
PATH="${1}${PATH:+":$PATH"}"
else
# Add to end
PATH="${PATH:+"$PATH:"}$1"
fi
fi
}
pathadd $HOME/bin front=true
pathadd $HOME/.rvm/bin
pathadd $HOME/.local/bin
# Disable auto renaming terminal
PROMPT_COMMAND=""
export PROMPT_COMMAND
git_branch() {
# display [@<git-branch>] if in a git repo
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[@\1]/'
}
parse_git_status() {
# display '*' if files changed, '+' if files uncommitted, '-' if not a git repo
if [[ $(git status 2> /dev/null | tail -n1) == "nothing to commit, working tree clean" ]]; then
echo -n ""
elif [[ $(git status 2> /dev/null | tail -n1) == 'nothing added to commit but untracked files present (use "git add" to track)' ]]; then
echo -n "+"
elif [[ $(git status 2>&1 | tail -n1) == "fatal: not a git repository (or any of the parent directories): .git" ]]; then
echo -n "-"
else
echo -n "*"
fi
}
# original
#export PS1="\h:\W \u\$ "
# Display the following, with colors- `<user>@<host> : <dir> [@<branch>]<git-status> \n└─ $`
export PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u@\h\[\033[0;36m\] : \w\[\033[0;32m\] $(git_branch)$(parse_git_status)\n\[\033[0;32m\]└─\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\]\[\033[0m\] '
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
# for pylint/flake8 checkers, encoding has to be set here for some reason
export LC_CTYPE=en_US.UTF-8
# Terminal grep colors support
#export GREP_OPTIONS="--color=always"; #deprecated
alias grep='grep --color'