dotfiles/.bashrc

67 lines
2.5 KiB
Bash

# Make bash a little more pleasent.
shopt -s cdspell checkhash checkjobs checkwinsize cmdhist dirspell histappend no_empty_cmd_completion
# Exit the shell on a Ctl+D.
IGNOREEOF=0
# History control.
HISTCONTROL="ignoredups"
HISTFILESIZE=100000
HISTIGNORE="w:bg:bg *:fg:fg *:jobs:exit:pwd:clear:history"
HISTSIZE=-1
HISTTIMEFORMAT="%d/%m/%y %H:%M:%S "
history -r
# Set the prompts.
if (( ${BASH_VERSINFO[0]} == 4 )); then
export PROMPT_DIRTRIM=2
if (( $(id -u) == 0 )); then
PS1="[\[\033[1;31m\]\u\[\033[0m\]@\h] \w ->"
else
PS1="[\u@\h] \w ->"
fi
else
if (( $(id -u) == 0 )); then
PS1="[\[\033[1;31m\]\u\[\033[0m\]@\h] \$(echo \"\${PWD/#\$HOME/~}\" | awk -F/ '{if (NF>3) {printf \".../\" \$(NF-1) \"/\" \$NF} else {printf \$0}}') ->"
else
PS1="[\u@\h] \$(echo \"\${PWD/#\$HOME/~}\" | awk -F/ '{if (NF>3) {printf \".../\" \$(NF-1) \"/\" \$NF} else {printf \$0}}') ->"
fi
fi
PS4='+(\$?=$?) $BASH_SOURCE${FUNCNAME:+($FUNCNAME)}:$LINENO: '
# Platform specific set up.
_PLATFORM="$(uname -s)"
if [ "$_PLATFORM" = "Linux" ]; then
# Linux specific aliases.
hash ftpwho >/dev/null 2>&1 && alias ftpwho='ftpwho -v'
hash iftop >/dev/null 2>&1 && alias iftop='TERM=vt100 iftop'
hash last less >/dev/null 2>&1 && alias laston='last -a | less'
hash ls >/dev/null 2>&1 && alias ls='ls -bFv --color=auto'
hash lynx >/dev/null 2>&1 && alias lynx='lynx -cfg=~/.lynx.cfg -lss=~/.lynx.lss'
hash minicom >/dev/null 2>&1 && alias minicom='minicom -m -c on'
hash pine >/dev/null 2>&1 && alias pine='pine -p "{mail.open-source.co.uk/Service=IMAP/User=darren@afterdark.org.uk/TLS/NoValidate-Cert/NoRsh}.pinerc"'
hash pinfo >/dev/null 2>&1 && alias info='pinfo'
hash ping >/dev/null 2>&1 && alias ping='ping -b'
# Linux specific functions.
psgrep() {
ps -auwwx | egrep "(RSS|$1)"
}
elif [ "$_PLATFORM" = "Darwin" ]; then
# Darwin specific aliases.
hash df >/dev/null 2>&1 && alias df='df -P'
hash ls >/dev/null 2>&1 && alias ls='ls -bFG'
hash top >/dev/null 2>&1 && alias top='top -o cpu -S'
else
echo "${BASH_SOURCE##*/}: unsupported platform: $_PLATFORM" >&2
fi
unset _PLATFORM
# Common aliases.
hash bc >/dev/null 2>&1 && alias bc='bc -lq'
hash curl >/dev/null 2>&1 && alias pastebin="curl -F 'sprunge=<-' http://sprunge.us"
hash diff >/dev/null 2>&1 && alias diff='diff -u'
hash egrep >/dev/null 2>&1 && alias egrep='egrep --color=auto'
hash fgrep >/dev/null 2>&1 && alias fgrep='fgrep --color=auto'
hash grep >/dev/null 2>&1 && alias grep='grep --color=auto'
hash screen >/dev/null 2>&1 && alias screen='screen -Ua'