Repository navigation
Expand file tree
/
Copy path.bash_profile
More file actions
106 lines (90 loc) · 3.24 KB
/
Copy path.bash_profile
File metadata and controls
106 lines (90 loc) · 3.24 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
98
99
100
101
102
103
104
105
106
#!/bin/bash
export UID="$(id -u)" GID="$(id -g)"
# If not running interactively, don't do anything.
if [ -z "${PS1}" ]; then
return
fi
# Usage: pathremove /path/to/bin [PATH]
# e.g. to remove ~/bin from $PATH: pathremove ~/bin PATH
function pathremove {
local IFS=':'
local NEWPATH
local DIR
local PATHVARIABLE=${2:-PATH}
for DIR in ${!PATHVARIABLE} ; do
if [[ "${DIR}" != "${1}" ]] ; then
NEWPATH="${NEWPATH:+${NEWPATH}:}${DIR}"
fi
done
export ${PATHVARIABLE}="${NEWPATH}"
}
# Usage: pathprepend /path/to/bin [PATH]
# e.g. to prepend ~/bin to $PATH: pathprepend ~/bin PATH
function pathprepend {
pathremove "${1}" "${2}"
[ -d "${1}" ] || return
local PATHVARIABLE="${2:-PATH}"
export ${PATHVARIABLE}="${1}${!PATHVARIABLE:+:${!PATHVARIABLE}}"
}
# Usage: pathappend /path/to/bin [PATH]
# e.g. to append ~/bin to $PATH: pathappend ~/bin PATH
function pathappend {
pathremove "${1}" "${2}"
[ -d "${1}" ] || return
local PATHVARIABLE=${2:-PATH}
export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}${1}"
}
# =============================================================================
# =============================================================================
# Add additional paths to PATH.
for p in /usr/local/bin /usr/local/sbin /usr/local/share/npm/bin ${HOME}/bin /usr/local/texlive/2014/bin/x86_64-darwin ${HOME}/.rvm/bin ${HOME}/repos/llvm/tools/clang/tools/scan-build ${HOME}/repos/llvm/tools/clang/tools/scan-view; do
[ -r ${p} ] && pathprepend ${p} PATH
done
# Function to execute to construct the value of PS1.
function prompt_command {
local here="${PWD}"
local ve=""
local host_colour="1;33m"
[[ "$(uname)" == "Darwin" ]] && host_colour="1;34m"
[[ "${PWD:0:${#HOME}}" == "${HOME}" ]] && here="~${PWD:${#HOME}}"
[ ! -z "${VIRTUAL_ENV}" ] && ve="($(basename ${VIRTUAL_ENV}))"
PS1="${ve}\[\033[1;30m\]\t\[\033[0m\] \[\033[${host_colour}\]\u@\h\[\033[0m\] \[\033[1;35m\]\W\[\033[0m\]\$ "
}
PROMPT_COMMAND=prompt_command
# OS specific settings.
case "$(uname)" in
Darwin)
alias ls='ls -pG'
alias top='top -ocpu -Otime'
export JAVA_HOME="$(/usr/libexec/java_home -v 12.0)"
pathprepend "${JAVA_HOME}/bin" PATH
export LSCOLORS="exFxcxdxbxegedabagacad"
export ARCHFLAGS="-arch x86_64"
;;
*)
alias ls='ls -p --color'
mkdir -p /tmp/tim
;;
esac
# Aliases.
alias egrep='egrep --color'
alias grep='grep --color'
alias l='ll'
alias less='less -R'
alias ll='ls -lahF'
alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
alias chrome-canary="/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary"
# Environment veriables.
export EDITOR='vim'
export HISTCONTROL='ignoredups'
export PAGER='less'
export PYTHONSTARTUP="${HOME}/.pythonrc.py"
export TEXINPUTS=".:${HOME}/repos/tex//:"
# gpg
export GPG_TTY=$(tty)
# Bash completion.
[ -r /etc/bash_completion ] && source /etc/bash_completion
$(which brew > /dev/null) && [ -r $(brew --prefix)/etc/bash_completion ] && source $(brew --prefix)/etc/bash_completion
$(which brew > /dev/null) && [ -r $(brew --prefix)/etc/bash_completion.d/git-completion.bash ] && source $(brew --prefix)/etc/bash_completion.d/git-completion.bash
# Load RVM bash functions.
[ -s ${HOME}/.rvm/scripts/rvm ] && source ${HOME}/.rvm/scripts/rvm