forked from weikinhuang/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.bashrc
More file actions
97 lines (80 loc) · 2.76 KB
/
.bashrc
File metadata and controls
97 lines (80 loc) · 2.76 KB
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
# ~/.bashrc: executed by bash(1) for non-login shells.
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# Force usage of 256 color terminal
case "$TERM" in
xterm*)
export TERM="xterm-256color"
;;
rxvt*)
export TERM="rxvt-256color"
;;
screen*)
export TERM="screen-256color"
;;
*)
;;
esac
# Check out which env this bash is running in
DOTENV="linux"
case "$(uname -s)" in
CYGWIN* )
DOTENV="cygwin"
;;
MINGW32_NT* )
# we'll just pretend to use the cygwin functions
DOTENV="cygwin"
# we can only have monochrome prompts
_PS1_MONOCHROME=1
# force the usage of /bin/bash instead of /bin/sh
if [ $BASH == '/bin/sh' ]; then
BASH='/bin/bash'
fi
;;
Darwin )
DOTENV="darwin"
;;
esac
export DOTENV
# load a local specific sources before the scripts
[[ -r "${HOME}/.bash_local_exports" ]] && source "${HOME}/.bash_local_exports"
# Completion options
[[ -f "/etc/bash_completion" ]] && source "/etc/bash_completion"
# Source ~/.exports, ~/.functions, ~/.aliases, ~/.completion, ~/.prompt, ~/.extra, ~/.env if they exist
for file in {exports,functions,aliases,completion,prompt,extra,env}; do
[[ -r "${HOME}/.dotenv/.${file}" ]] && source "${HOME}/.dotenv/.${file}"
[[ -r "${HOME}/.dotenv/${DOTENV}/.${file}" ]] && source "${HOME}/.dotenv/${DOTENV}/.${file}"
done
unset file
# load a local specific sources before the scripts
[[ -r "${HOME}/.bash_local" ]] && source "${HOME}/.bash_local"
# modify path to include useful scripts
[[ -d "${HOME}/.dotenv/${DOTENV}/bin" ]] && PATH="$PATH:${HOME}/.dotenv/${DOTENV}/bin"
[[ -d "${HOME}/.dotenv/bin" ]] && PATH="$PATH:${HOME}/.dotenv/bin"
[[ -d "${HOME}/bin" ]] && PATH="$PATH:${HOME}/bin"
# Remove duplicate entries from PATH and retain the original order
if type nl &> /dev/null; then
export PATH=$(echo "$PATH" | tr : '\n' | nl | sort -u -k 2,2 | sort -n | cut -f 2- | tr '\n' : | sed -e 's/:$//' -e 's/^://')
fi
# include utility settings file (git PS1, solarized, mysql, etc...)
[[ -r "${HOME}/.dotenv/.utility" ]] && source "${HOME}/.dotenv/.utility"
# write to .bash_history after each command
__push_prompt_command 'history -a'
# Shell Options
# Use case-insensitive filename globbing
shopt -s nocaseglob
# Include . files when globing (ie. mv, cp, etc.)
shopt -s dotglob
# When changing directory small typos can be ignored by bash
shopt -s cdspell
# Append to the Bash history file, rather than overwriting it
shopt -s histappend
# Try to enable some bash 4 functionality
# Attempt to auto cd to a directory
shopt -s autocd 2> /dev/null
# Recursive globbing, e.g. `echo **/*.txt`
shopt -s globstar 2> /dev/null
# If any jobs are running, this causes the exit to be deferred until a second exit is attempted
shopt -s checkjobs 2> /dev/null
# exit with a success status code
return 0