2016-02-16 20:19:31 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
# Function to prepend PATH only if it doesn't already exist
|
|
|
|
#--------------------------------------------------------------------------------
|
2016-02-16 19:20:07 +00:00
|
|
|
pathadd() {
|
|
|
|
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
|
|
|
|
PATH="$1${PATH:+":$PATH"}"
|
|
|
|
fi
|
|
|
|
}
|
2016-02-16 20:19:31 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
2016-02-16 19:20:07 +00:00
|
|
|
|
2014-11-11 21:13:52 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
2014-11-11 21:01:06 +00:00
|
|
|
# The best editor
|
2014-11-11 21:13:52 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
2015-03-06 17:40:44 +00:00
|
|
|
alias vi=vim
|
2014-11-15 17:05:36 +00:00
|
|
|
export EDITOR=vim
|
2014-11-11 21:13:52 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
2014-11-11 21:01:06 +00:00
|
|
|
|
2015-01-14 11:12:25 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
# Make less use visual bell
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
export LESS="-qr"
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
|
2016-01-26 15:38:37 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
# Default directories
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
mkdir -p ~/src ~/tmp ~/var/log
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
|
2014-11-11 21:13:52 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
2014-11-11 21:01:06 +00:00
|
|
|
# Update the path with local overrides
|
2014-11-11 21:13:52 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
2016-02-16 19:20:07 +00:00
|
|
|
pathadd /usr/local/sbin
|
|
|
|
pathadd /usr/local/bin
|
|
|
|
pathadd ~/bin
|
2014-11-11 21:13:52 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
2014-11-11 21:01:06 +00:00
|
|
|
|
2016-01-26 20:12:31 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
# Rebind CTRL-T to search forward in history
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
if [ -n "$PS1" ]; then
|
|
|
|
bind "\C-t":forward-search-history
|
|
|
|
fi
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
|
2016-01-27 15:51:13 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
# Add bash completion scripts
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
for FILE in ~/.bash/auto_complete.d/*; do source ${FILE}; done
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
|
2014-11-11 21:13:52 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
# A useful prompt
|
|
|
|
#--------------------------------------------------------------------------------
|
2015-09-14 18:26:36 +01:00
|
|
|
export PS1="[\u@\h \W \[\033[32m\]\$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ <\1>/')\[\033[00m\]]\\$ "
|
2014-12-05 18:33:16 +00:00
|
|
|
export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
|
2014-11-11 21:13:52 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
# Record history for longer and more dynamically
|
|
|
|
#--------------------------------------------------------------------------------
|
2014-11-11 21:01:06 +00:00
|
|
|
# Large history buffer
|
|
|
|
export HISTSIZE=9999
|
|
|
|
export HISTFILESIZE=9999
|
|
|
|
|
|
|
|
# Avoid duplicates in the history...
|
|
|
|
export HISTCONTROL=ignoredups:erasedups
|
|
|
|
|
|
|
|
# Append history entries...
|
|
|
|
shopt -s histappend
|
|
|
|
|
|
|
|
# After each command, save and reload history
|
2015-05-20 20:43:57 +01:00
|
|
|
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a"
|
2014-11-11 21:13:52 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
2014-11-11 21:01:06 +00:00
|
|
|
|
2014-11-11 21:13:52 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
2016-01-27 15:49:34 +00:00
|
|
|
# Command aliases
|
2014-11-11 21:13:52 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
2016-01-27 15:49:34 +00:00
|
|
|
alias ll='ls -l'
|
2016-01-27 15:57:19 +00:00
|
|
|
[[ -x $(which htop 2>/dev/null) ]] && alias top='htop'
|
2014-11-11 21:13:52 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
2014-11-15 17:05:36 +00:00
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
# Set up GOPATH for Go development
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
export GOPATH=${HOME}/src/go
|
|
|
|
#--------------------------------------------------------------------------------
|
2014-11-11 21:01:06 +00:00
|
|
|
|
2015-09-29 19:41:04 +01:00
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
# Run an SSH agent, if possible
|
|
|
|
#--------------------------------------------------------------------------------
|
2015-09-29 19:49:49 +01:00
|
|
|
# Check if we already have an agent running and sourced
|
2016-02-17 10:49:03 +00:00
|
|
|
if [ -z "${SSH_AUTH_SOCK}" ]; then
|
|
|
|
eval `ssh-agent -s`
|
|
|
|
ssh-add
|
2015-09-29 19:41:04 +01:00
|
|
|
fi
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
|
2016-01-26 15:39:41 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
2016-01-26 15:41:35 +00:00
|
|
|
# Update brew if it's older than one day
|
2016-01-26 15:39:41 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
if [ -x /usr/local/bin/brew ]; then
|
2016-01-26 19:27:57 +00:00
|
|
|
(
|
|
|
|
find /usr/local/.git -name FETCH_HEAD -mtime +0 -exec \
|
|
|
|
bash -c "echo \"--Start: $(date)\"; \
|
|
|
|
brew update; \
|
|
|
|
echo \"--End: $(date)\"" \
|
|
|
|
\; >> ~/var/log/brew-update.log 2>&1 &
|
|
|
|
)
|
2016-01-26 15:39:41 +00:00
|
|
|
fi
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
|
2016-01-26 15:49:00 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
# Run local .bashrc for any local-only commands
|
|
|
|
#--------------------------------------------------------------------------------
|
2014-11-12 16:58:37 +00:00
|
|
|
[ -f ~/.bashrc_local ] && source ~/.bashrc_local
|
2016-01-26 15:49:00 +00:00
|
|
|
#--------------------------------------------------------------------------------
|