-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_profile
65 lines (47 loc) · 1.51 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
# Extend $PATH for a local $HOME/bin directory
export PATH="$PATH:$HOME/bin"
# Append to the history file, don't overwrite it
shopt -s histappend
# Check the window size after each command and update LINES and COLUMNS
shopt -s checkwinsize
# Globstar pattern matching (e.g. **/*.foobar)
shopt -s globstar
# Extended globbing
shopt -s extglob
# Auto-cd to a directory without specifying 'cd' (e.g. foobar)
shopt -s autocd
# Don't have Z clobber the $PROMPT_COMMAND
export _Z_NO_PROMPT_COMMAND='1'
# Source Z (https://github.com/rupa/z)
source ~/.bash/z/z.sh
# Source Git Bash completion
source ~/.bash/git-completion.bash
# Load the shell dotfiles
for file in ~/.{exports,aliases,functions,bash_prompt,bash.local}; do
[ -r "$file" ] && source "$file"
done
unset file
# The next two functions are helpers that mimic zsh's preexec & precmd:
# 1. preexec runs before every command
# 2. the command runs
# 3. precmd runs before the prompt
# Ran before every command (before `precmd`)
preexec() {
# Don't cause a preexec if completing
[ -n "$COMP_LINE" ] && return
# Don't cause a preexec for $PROMPT_COMMAND
[ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] && return
# Update $DISPLAY to help avoid stale values within tmux
update-x11-forwarding
# echo ">>> preexec <<<"
}
# Ran before every prompt (after `preexec`)
precmd() {
# Write current/new lines to histfile
history -a
# Z
(_z --add "$(command pwd '$_Z_RESOLVE_SYMLINKS' 2>/dev/null)" 2>/dev/null &)
# echo "<<< precmd >>>"
}
trap 'preexec' DEBUG
export PROMPT_COMMAND=precmd