forked from velomash/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 9
/
.bash_profile
158 lines (101 loc) · 3.59 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
confirm() {
read -r -p "${1:-Are you sure? [y/N]} " response
case "$response" in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
#########################################
# DOCKER
#########################################
alias dlist="docker ps -a"
docker_ids() { docker ps -aq; }
docker_stop_all() { docker stop $(docker_ids); }
docker_remove_all() { docker rm $(docker_ids); }
# Shortcuts
alias g="git"
alias gs="git status"
alias gsl="git stash list"
alias gc="git checkout"
alias gcp="git cherry-pick"
alias gb="git branch"
alias guc="git reset HEAD~"
alias h="history"
alias ch='history | grep "git commit"'
alias home='cd ~/'
alias gp="git fetch origin --prune"
# clean up branches that no longer exist on origin off local
alias cb="git remote prune origin && git branch -vv | grep '\[[^]]* gone]' | awk '{ print $1 }' | xargs git branch -D"
alias startpost="pg_ctl -D ~/.asdf/installs/postgres/9.6.8/data -l logfile start"
alias stoppost="pg_ctl -D ~/.asdf/installs/postgres/9.6.8/data stop -s -m fast"
alias profile="open ~/.bash_profile"
alias containers="docker ps -a"
alias pgreload="pg_ctl reload"
alias reload="source ~/.bash_profile"
scon() {
docker stop `docker ps -aq`
}
rmcon() {
docker rm `docker ps -aq`
}
sig () {
declare -f "$1"
}
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ [\1]/'
}
export PS1="\u@\h \W\[\033[01;33m\]\$(parse_git_branch)\[\033[00m\] $ "
# Project helpers
alias ..='cd ../' # Go back 1 directory level
alias ...='cd ../../' # Go back 2 directory levels
alias .3='cd ../../../' # Go back 3 directory levels
alias .4='cd ../../../../' # Go back 4 directory levels
alias .5='cd ../../../../../' # Go back 5 directory levels
alias .6='cd ../../../../../../' # Go back 6 directory levels
alias c='clear' # Clear terminal display
alias path='echo -e ${PATH//:\\\n}' # Echo all executable Paths
alias edit='open -a TextEdit' # open using TextEdit
alias l='ls -altr' # list all in order
# List all files colorized in long format, including dot files
alias la="ls -lahF ${colorflag}"
# Show/hide hidden files in Finder
alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
searchAndDestroy() {
lsof -i TCP:$1 | grep LISTEN | awk '{print $2}' | xargs kill -9
echo "Port" $1 "found and killed."
}
searchProfile() {
cat ~/.bash_profile | grep $1
}
#Delete remote branch and local branch
gd() {
confirm "Force delete $(curbranch) on both your local machine AND origin?" && git push origin --delete $1 && gb -D $1
}
gsp() {
git stash push -u -m $1;
echo "Stash created with name" $1
}
#Delete local branch
gdl() {
gb -D $1
}
export GOPATH="$HOME/go"
export PATH="$PATH:$HOME/go/bin"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# ---------------------------
# FZF config for use with vim
# ---------------------------
# --files: List files that would be searched but do not search
# --no-ignore: Do not respect .gitignore, etc...
# --hidden: Search hidden files and folders
# --follow: Follow symlinks
# --glob: Additional conditions for search (in this case ignore everything in the .git/ folder)
export FZF_DEFAULT_COMMAND='rg --files --hidden --follow'