-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_profile
140 lines (104 loc) · 2.97 KB
/
bash_profile
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# prevent accidantally closing shells
# ignores n consecutive EOF
export IGNOREEOF=2
### bash history
# Erase duplicates
export HISTCONTROL=erasedups
# resize history size
export HISTFILESIZE=1000000
export HISTSIZE=1000000
# append to bash_history if Terminal.app quits
shopt -s histappend
export HISTIGNORE='ls:bg:fg:history'
# i never freeze my terminal, but i would like forward search
stty stop 'undef'
# C-x C-e drops into $EDITOR to edit the current command before executing
if [[ $(which nvim) ]]
then
export EDITOR=nvim
alias vim=nvim
else
export EDITOR=vim
fi
# for python readline support
export PYTHONSTARTUP=~/.pystartup.py
export GREP_OPTIONS='--color=auto'
# export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow --glob "!.git/*"'
export FZF_DEFAULT_COMMAND='rg --files --hidden --follow --glob "!.git/*"'
### aliases
alias ls='ls -G'
alias clean_pyc='find . -name "*.pyc" -delete'
alias figlet='figlet -f colossal -m 1'
alias conflictack='rg "^(<|>|=){7}($| )"'
alias watch='watch '
# git_open_conflicts git ls-files -m|sort -u|xargs mvim
# hack to set a default user. another -U overrides this
alias psql="psql -U postgres"
# force tmux to use 256 colours
alias tmux="tmux -2"
# homebrew where available
if [[ $(which brew) ]]
then
BREW=$
PATH=$(brew --prefix)/bin:$(brew --prefix)/sbin:$PATH
if [ -f $(brew --prefix)/etc/bash_completion ]
then
. $(brew --prefix)/etc/bash_completion
fi
fi
export PATH=$PATH:$HOME/dotfiles/bin:$HOME/bin:$HOME/.local/bin
_jobs_running() {
local jobs_running=$(jobs -rp| wc -l| tr -d ' ')
local jobs_stopped=$(jobs -sp| wc -l| tr -d ' ')
local total_jobs=$(($jobs_running + $jobs_stopped))
if [[ "$total_jobs" != "0" ]]
then
echo "($total_jobs)"
fi
}
function __prompt_command() {
local EXIT="$?" # This needs to be first
# write bash history immediately
history -a
PS1=""
# prompt
GRAY="\[\033[0;30m\]"
PINK="\[\033[0;35m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
RESET="\[\033[0m\]"
ITERM_TAB_RESET="\[\033]0;\007\]"
GIT_PS1_SHOWDIRTYSTATE=1
if [ -n "$VIRTUAL_ENV" ]
then
VIRTUAL_ENV_NAME=$(basename "$VIRTUAL_ENV")
PS1+="($VIRTUAL_ENV_NAME)"
fi
PS1+="$GRAY\u@\h:${PINK}\W"
PS1+="$GREEN\$(type -t __git_ps1 > /dev/null && __git_ps1 \" (%s)\")"
PS1+="$BLUE\$(_jobs_running)"
if [ $EXIT != 0 ]
then
PS1+="$PINK\$ $RESET" # Add red if exit code non 0
else
PS1+="$RESET\$ "
fi
PS1+="$ITERM_TAB_RESET"
}
export PROMPT_COMMAND=__prompt_command
export PIP_REQUIRE_VIRTUALENV=true
syspip() {
PIP_REQUIRE_VIRTUALENV="" pip "$@"
}
# complete for hub pull-request
_hub_complete() {
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "pull-request" -- $cur) )
}
complete -F _hub_complete hub
# local settings
local_bashrc="$HOME/.bash_profile.local"
if [ -e "$local_bashrc" ]
then
source "$local_bashrc"
fi