dotfiles/.bashrc

76 lines
3.1 KiB
Bash
Raw Normal View History

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
#--------------------------------------------------------------------------------
2014-11-11 21:01:06 +00:00
export EDITOR=vi
2014-11-11 21:13:52 +00:00
#--------------------------------------------------------------------------------
2014-11-11 21:01:06 +00:00
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
#--------------------------------------------------------------------------------
2014-11-11 21:01:06 +00:00
export PATH=/usr/local/bin:/usr/local/sbin:${PATH}
2014-11-11 21:13:52 +00:00
#--------------------------------------------------------------------------------
2014-11-11 21:01:06 +00:00
2014-11-11 21:13:52 +00:00
#--------------------------------------------------------------------------------
# A useful prompt
#--------------------------------------------------------------------------------
2014-11-12 20:41:47 +00:00
export PS1="[\u@\h \W]\\$ "
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
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"
2014-11-11 21:13:52 +00:00
#--------------------------------------------------------------------------------
2014-11-11 21:01:06 +00:00
2014-11-11 21:13:52 +00:00
#--------------------------------------------------------------------------------
2014-11-11 21:01:06 +00:00
# Make OS X's 'top' behave like the GNU one
2014-11-11 21:13:52 +00:00
#--------------------------------------------------------------------------------
2014-11-11 21:01:06 +00:00
alias top='top -u'
2014-11-11 21:13:52 +00:00
#--------------------------------------------------------------------------------
2014-11-11 21:01:06 +00:00
2014-11-11 21:13:52 +00:00
#--------------------------------------------------------------------------------
2014-11-11 21:01:06 +00:00
# Git aliases
2014-11-11 21:13:52 +00:00
#--------------------------------------------------------------------------------
2014-11-11 21:01:06 +00:00
alias githistory='git log --oneline --abbrev-commit --all --graph --decorate'
alias gitx='open -a GitX .'
2014-11-11 21:13:52 +00:00
#--------------------------------------------------------------------------------
2014-11-11 21:01:06 +00:00
2014-11-11 21:13:52 +00:00
#--------------------------------------------------------------------------------
2014-11-11 21:01:06 +00:00
# Add bash completion for ssh: it tries to complete the host to which you
# want to connect from the list of the ones contained in ~/.ssh/known_hosts
2014-11-11 21:13:52 +00:00
#--------------------------------------------------------------------------------
2014-11-11 21:01:06 +00:00
__ssh_known_hosts() {
if [[ -f ~/.ssh/known_hosts ]]; then
cut -d " " -f1 ~/.ssh/known_hosts | cut -d "," -f1
fi
}
_ssh() {
local cur known_hosts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
known_hosts="$(__ssh_known_hosts)"
if [[ ! ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${known_hosts}" -- ${cur}) )
return 0
fi
}
complete -o bashdefault -o default -o nospace -F _ssh ssh 2>/dev/null \
|| complete -o default -o nospace -F _ssh ssh
2014-11-11 21:13:52 +00:00
#--------------------------------------------------------------------------------
[ -f ~/.bashrc_local ] && source ~/.bashrc_local