-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
95 lines (74 loc) · 1.78 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
# ==================
# Bash configuration
# ==================
export PATH=/usr/local/bin:$HOME/Work/utilities/woff2:$PATH
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
eval "$(rbenv init -)"
# ---------
# Functions
# ---------
# Git: show branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# Git: branch tab completion
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
# Versions
# Node: check version
function node_version() {
if which node &> /dev/null; then
node -v | cut -d' ' -f2
else
echo none
fi
}
# Ruby: check version
function ruby_version() {
if which ruby &> /dev/null && ruby -v &> /dev/null; then
ruby -v | cut -d' ' -f2
elif which jruby &> /dev/null && jruby -v &> /dev/null; then
echo "jruby $(jruby -v | cut -d' ' -f2)"
else
echo none
fi
}
# Python: check version
function python_version() {
if which python &> /dev/null; then
python --version 2>&1 | cut -d' ' -f2
else
echo none
fi
}
function __version() {
echo "Python v$(python_version) || Ruby v$(ruby_version) || Node $(node_version)"
}
# --------------
# Command prompt
# --------------
export PS1="🦋 \w\[\033[32m\]\$(parse_git_branch) \[\033[00m\]\n ❥ "
# --------------------
# Environment settings
# --------------------
# Set ssh
eval $(ssh-agent -s) > /dev/null
# -------
# Aliases
# -------
# Bash aliases
alias l="ls -la" # List in long format, include dotfiles
alias ld="ls -ld */" # List in long format, only directories
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
# Ruby and related aliases
alias be="bundle exec"
alias serve="bundle exec jekyll serve"
# Git aliases found in .gitconfig_global
# --------
# Say shit
# --------
__version