# update Bash version
# apt-get install bash bash-completion
# brew install bash; echo /usr/local/bin/bash|sudo tee -a /etc/shells; chsh -s /usr/local/bin/bash
# for mac osx remember to add the following to your ~/.bash_profile
#
# if [ -f $HOME/.bashrc ]; then
# source ~/.bashrc
# cd .
# fi
#
# if [ -f $(brew --prefix)/etc/bash_completion ]; then
# source $(brew --prefix)/etc/bash_completion
# fi
# tells Readline to perform filename completion in a case-insensitive fashion
bind "set completion-ignore-case on"
# filename matching during completion will treat hyphens and underscores as equivalent
bind "set completion-map-case on"
# will get Readline to display all possible matches for an ambiguous pattern at the first <Tab> press instead of at the second
bind "set show-all-if-ambiguous on"
# enable vi like bindings (http://blog.sanctum.geek.nz/vi-mode-in-bash/)
set -o vi
# append to the history file, don't overwrite it
shopt -s histappend
# save multi-line commands as one command
shopt -s cmdhist
# record each line as it gets issued
PROMPT_COMMAND='history -a'
# set a larger history
HISTSIZE=500000
HISTFILESIZE=100000
# avoid duplicate entries
HISTCONTROL="erasedups:ignoreboth"
# don't record some commands
export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history"
# useful timestamp format
HISTTIMEFORMAT='%F %T '
# no need to type cd (works for .. but not -, although alias -- -='cd -' fixes it)
shopt -s autocd
# autocorrect minor spelling errors
shopt -s dirspell
shopt -s cdspell
# specify other paths to look inside of when autocompleting
CDPATH=".:~/Projects"
# use cd command for variable paths
shopt -s cdable_vars
export dropbox="$HOME/Dropbox"
export bbc="$HOME/Projects/BBC"
export GITHUB_USER="integralist"
export DEV_CERT_PATH="$HOME/.pki/bbc"
export DEV_CERT_PEM="$HOME/.pki/bbc/Certificate.pem"
export DEV_CERT_P12="$HOME/.pki/bbc/Certificate.p12"
export CLOUD_CERT_PEM="$HOME/.pki/bbc/cloud-ca.pem"
export GREP_OPTIONS="--color=auto"
export GREP_COLOR="1;32"
export MANPAGER="less -X" # Don't clear the screen after quitting a manual page
export DOCKER_TLS_VERIFY=1
export BBC_COSMOS_TOOLS_CERT=$DEV_CERT_PEM
export GOPATH=$HOME/Projects/golang
export PATH=$HOME/Projects/golang/bin:$PATH
# force colours
force_color_prompt=yes
# use colour prompt
color_prompt=yes
# \e indicates escape sequence (sometimes you'll see \033)
# the m indicates you've provided a colour sequence
#
# 30: Black
# 31: Red
# 32: Green
# 33: Yellow
# 34: Blue
# 35: Purple
# 36: Cyan
# 37: White
#
# a semicolon allows additional attributes:
#
# 0: Normal text
# 1: Bold or light, depending on terminal
# 4: Underline text
#
# there are also background colours (put before additional attributes with ; separator):
#
# 40: Black background
# 41: Red background
# 42: Green background
# 43: Yellow background
# 44: Blue background
# 45: Purple background
# 46: Cyan background
# 47: White background
# simple left prompt example:
# PS1='\e[01;33m\]\u:\[\e[31m\]\w\[\e[00m\] (\j) (\A)\$ '
# Much more complex left AND right solution (http://superuser.com/a/517110)
# Which also dynamically displays the number of background jobs \j in the current terminal
# As well as dynamically displays git branch if available
num_jobs=$(jobs | wc -l)
if [ $num_jobs -eq 0 ]; then
num_jobs=""
else
num_jobs=" (\j)"
fi
function prompt_right() {
# need the correct number of spaces after \A to allow for 00:00 time display
echo -e "\e[0;36m\A \e[0m"
}
function prompt_left() {
echo -e "\e[33m\]\u. \[\e[31m\]\w\[\e[00m\]$num_jobs\e[32m\]$git_branch\e[00m\]\$ "
}
function prompt() {
compensate=11
PS1=$(printf "%*s\r%s\n\$ " "$(($(tput cols)+${compensate}))" "$(prompt_right)" "$(prompt_left)")
}
# override builtin cd so it also checks current directory for git branch
function cd {
builtin cd "$@"
RET=$?
# check if we're inside a git repository (hide any errors)
$(git rev-parse --is-inside-work-tree >& /dev/null)
if [ "$?" -eq "128" ]; then
git_branch=""
else
git_branch=" ($(git branch | grep '^*' | cut -d ' ' -f 2))"
fi
PROMPT_COMMAND=prompt
return $RET
}
function rubo() {
docker run \
--cpu-shares 1024 \
--rm=true \
--volume $(pwd):/app \
bbcnews/rubocop-config --format simple --fail-level F | grep '^F:\|=='
}
alias dotfiles="ls -a | grep '^\.' | grep --invert-match '\.DS_Store\|\.$'"
alias getcommit="git log -1 | cut -d ' ' -f 2 | head -n 1 | pbcopy"
alias vp="vim +PluginInstall! +qall"
alias sshkey="ssh-keygen -t rsa -b 4096 -C 'mark.mcdx@gmail.com'"
alias irc="irssi"
alias r="source ~/.bashrc"
eval "$(rbenv init -)"
eval "$(docker-machine env dev)"