-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.bashrc
101 lines (71 loc) · 2.14 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
97
98
99
100
101
#!/usr/bin/env bash
# shellcheck disable=SC1091
# shell configuration
export PS1="[\u@\h \W]\\$ "
## force dircolors.
export CLICOLOR=1
## asdf
source "$HOME"/.asdf/asdf.sh
source "$HOME"/.asdf/completions/asdf.bash
## docker
export DOCKER_CLI_HINTS=false
## macos.
if [[ $(uname) == "Darwin" ]]; then
# disable homebrew analytics.
export HOMEBREW_NO_ANALYTICS=1
# put homebrew's sbin in the path.
PATH="$(brew --prefix)/sbin:$PATH"
# git bash completion
source "$(brew --prefix)"/etc/bash_completion.d/git-completion.bash
# homebrew changed default path to /opt/homebrew,
# and other tools (docker in particular) still
# symlink cli binaries in /usr/local/bin by default.
PATH="/usr/local/bin:$PATH"
# TeX binaries for pandoc.
PATH="/Library/TeX/Root/bin/universal-darwin/:$PATH"
fi
## final path export.
export PATH
# utility functions
## sync local branches with remote after pruning.
git-prune-sync() {
if [ $# -eq 0 ]; then
local remote=origin
else
local remote=$1
fi
if [ "$(type -P git)" ]; then
git remote prune "$remote"
echo "pruned $remote branch references."
if git rev-parse --git-dir > /dev/null 2>&1; then
gone_remote_branches=$(git branch -vv | grep "gone" | awk "{print \$1}")
if [[ -z "$gone_remote_branches" ]]; then
echo "no local branches track a gone $remote branch."
else
for gone_remote_branch in $gone_remote_branches; do
echo "$gone_remote_branch" | xargs git branch -D
done
fi
else
echo "not a git repository."
fi
else
echo "'git' command not available. check your installation."
fi
}
## Makefile tab completion.
_make_completion() {
local cur prev targets
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Parse Makefile targets
targets=$(make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {split($1,A,/ /);print A[1]}' | sort -u)
COMPREPLY=( $(compgen -W "${targets}" -- ${cur}) )
return 0
}
complete -F _make_completion make
# host-specific configuration
if [ -f "$HOME"/.this_machine ]; then
source "$HOME"/.this_machine
fi