forked from anishathalye/dotfiles_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_profile
111 lines (91 loc) · 3.24 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
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
# Set git autocompletion and PS1 integration
if [[ "$OSTYPE" == "darwin"* ]]; then
if [ -f /usr/local/etc/bash_completion.d/git-completion.bash ]; then
. /usr/local/etc/bash_completion.d/git-completion.bash
fi
if [ -f /usr/local/etc/bash_completion.d/git-prompt.sh ]; then
. /usr/local/etc/bash_completion.d/git-prompt.sh
fi
if [ -f /opt/homebrew/etc/bash_completion.d/git-completion.bash ]; then
. /opt/homebrew/etc/bash_completion.d/git-completion.bash
fi
if [ -f /opt/homebrew/etc/bash_completion.d/git-prompt.sh ]; then
. /opt/homebrew/etc/bash_completion.d/git-prompt.sh
fi
else
if [ -f /etc/bash_completion.d/git-completion.bash ]; then
. /etc/bash_completion.d/git-completion.bash
fi
if [ -f /etc/bash_completion.d/git-prompt.sh ]; then
. /etc/bash_completion.d/git-prompt.sh
fi
fi
GIT_PS1_SHOWDIRTYSTATE=true
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\e[00;36m\]\W\[\e[0m\]$(__git_ps1)\[\033[00m\] \$ '
function rmb {
current_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
if [ "$current_branch" != "master" ]; then
echo "WARNING: You are on branch $current_branch, NOT master."
fi
echo "Fetching merged branches..."
git remote prune origin
local_branches=$(git branch --merged | grep -v 'master$' | grep -v "$current_branch$")
if [ -z "$remote_branches" ] && [ -z "$local_branches" ]; then
echo "No existing branches have been merged into $current_branch."
else
echo "This will remove the following branches:"
if [ -n "$local_branches" ]; then
echo "$local_branches"
fi
read -p "Continue? (y/n): " -n 1 choice
echo
if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then
# Remove local branches
git branch -d `git branch --merged | grep -v 'master$' | grep -v "$current_branch$" | sed 's/origin\///g' | tr -d '\n'`
else
echo "No branches removed."
fi
fi
}
# if [ -f "${HOME}/.gpg-agent-info" ]; then
# . "${HOME}/.gpg-agent-info"
# export GPG_AGENT_INFO
# export SSH_AUTH_SOCK
# export SSH_AGENT_PID
# fi
# export GPG_TTY=$(tty)
export HISTCONTROL=ignoreboth:erasedups
alias masterup="git checkout master && git up && rmb"
alias ghpr="gh pr create --web"
if [[ "$OSTYPE" == "darwin"* ]]; then
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
alias sublime="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
eval "$(thefuck --alias)"
fi
export BASH_SILENCE_DEPRECATION_WARNING=1
function _makefile_targets {
local curr_arg;
local targets;
# Find makefile targets available in the current directory
targets=''
if [[ -e "$(pwd)/Makefile" ]]; then
targets=$( \
grep -oE '^[a-zA-Z0-9_-]+:' Makefile \
| sed 's/://' \
| tr '\n' ' ' \
)
fi
# Filter targets based on user input to the bash completion
curr_arg=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "${targets[@]}" -- $curr_arg ) );
}
complete -F _makefile_targets make
alias k=kubectl
alias kt=kubetail
. "$HOME/.cargo/env"