-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
96 lines (80 loc) · 2.45 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
96
alias mv='mv -i'
alias cp='cp -i'
alias l='ls'
# On linux, --color exists, but on macs it does not
if ls --color > /dev/null 2>&1; then
alias ls='ls --color=auto'
else
alias ls='ls -G'
fi
alias delete_merged_local_branches='git branch -d $(git branch --merged | grep -v "^\*" | grep -v master)'
alias gg='git grep --line-number'
alias apush='git commit -a --amend --no-edit && git push -f origin HEAD'
alias groot='cd "$(git rev-parse --show-toplevel)"'
# Prefer neovim if it is installed
if hash nvim 2>/dev/null; then
alias vim='nvim'
fi
gv() {
# Open the search files in vim
if command -v rg &> /dev/null; then
vim $(rg -l "$@" | sort)
else
vim $(git grep -l "$@")
fi
}
gbranch() {
git fetch origin
git checkout origin/master -b "$1"
}
remove_python_imports() {
files=$(git diff HEAD --name-only | grep '\.py$')
if [ -z "$files" ]; then
exit 0
fi
for file in $files; do
flake8_output=$(flake8 "$file" | grep 'imported but unused')
if [ ! -z "$flake8_output" ]; then
sed -i $(echo "$flake8_output" | cut -d: -f2 | xargs -n1 -I {} echo {}d | tr '\n' ';') "$file"
fi
done
}
run_in_docker() {
docker run --init --workdir /foo --volume "$(pwd):/foo/" busybox $@
}
merge_master() {(
set -e
branch="$(git rev-parse --abbrev-ref HEAD)"
reviewnumber=$(git config "branch.$branch.reviewnumber") || true
git checkout master
git pull
git merge --no-ff "$branch" --no-edit
git push origin HEAD
)}
if [ -z "$SSH_AUTH_SOCK" ]; then
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
fi
set -o vi
export PYTHONSTARTUP=~/.pythonrc.py
alias fix_ssh_auth='export $(tmux show-environment | grep \^SSH_AUTH_SOCK=)'
if test -n "$BASH_VERSION"; then
export HISTCONTROL=ignorespace:ignoredups
export HISTIGNORE='fg'
export HISTSIZE=50000
if [ -f ~/dotfiles/git-completion.bash ]; then
. ~/dotfiles/git-completion.bash
fi
if [ -f ~/dotfiles/git-prompt.sh ]; then
. ~/dotfiles/git-prompt.sh
PS1='\h:\W$(__git_ps1 " (%s)")\$ '
fi
elif test -n "$ZSH_VERSION"; then
setopt HIST_IGNORE_SPACE
export HISTORY_IGNORE='(fg)'
fi
#Put stuff in .bashrc_local that varies based on particular machines
if [ -f ~/.bashrc_local ]; then
. ~/.bashrc_local
fi
# Add RVM and golang to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/bin:$HOME/.rvm/bin:$HOME/.cargo/bin:$HOME/go/bin"