Update bash startup files.

This commit is contained in:
Darren 'Tadgy' Austin 2019-04-29 23:35:04 +01:00
commit f736543c61
2 changed files with 41 additions and 19 deletions

54
.bashrc
View file

@ -1,5 +1,5 @@
# Make bash a little more pleasent.
shopt -s cdspell checkhash checkjobs checkwinsize cmdhist dirspell histappend no_empty_cmd_completion
# Make bash a little more pleasent - these are valid for all versions.
shopt -s cdspell checkhash checkwinsize cmdhist histappend no_empty_cmd_completion
# Exit the shell on a Ctl+D.
IGNOREEOF=0
@ -12,22 +12,44 @@ 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
# Determine the colour of the username in the prompt.
if (( $(id -u) == 0 )); then
_COLOUR=1 # Red
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
_COLOUR=2 # Green
fi
PS4='+(\$?=$?) $BASH_SOURCE${FUNCNAME:+($FUNCNAME)}:$LINENO: '
# Version specific set up.
if (( ${BASH_VERSINFO[0]} >= 4 )); then
# Add to the shopts.
shopt -s checkjobs dirspell
# Set the prompts.
PROMPT_DIRTRIM=2
# No colour:
# PS1="[\u@\h] \w ->"
# Coloured username:
# PS1="[\[$(tput bold)$(tput setaf $_COLOUR)\]\u\[$(tput sgr0)\]@\h] \w ->"
# Coloured username + host:
# PS1="[\[$(tput bold)$(tput setaf $_COLOUR)\]\u\[$(tput sgr0)\]@\[$(tput bold)$(tput setaf 3)\]\h\[$(tput sgr0)\]] \w ->"
# Coloured username + host + directory:
PS1="[\[$(tput bold)$(tput setaf $_COLOUR)\]\u\[$(tput sgr0)\]@\[$(tput bold)$(tput setaf 3)\]\h\[$(tput sgr0)\]] \[$(tput bold)$(tput setaf 4)\]\w\[$(tput sgr0)\] ->"
else
# Set the prompts.
# No colour:
# PS1="[\u@\h] \$(echo \"\${PWD/#\$HOME/~}\" | awk -F/ '{if (NF>3) {printf \".../\" \$(NF-1) \"/\" \$NF} else {printf \$0}}') ->"
# Coloured username:
# PS1="[\[$(tput bold)$(tput setaf $_COLOUR)\]\u\[$(tput sgr0)\]@\h] \$(echo \"\${PWD/#\$HOME/~}\" | awk -F/ '{if (NF>3) {printf \".../\" \$(NF-1) \"/\" \$NF} else {printf \$0}}') ->"
# Coloured username + host:
# PS1="[\[$(tput bold)$(tput setaf $_COLOUR)\]\u\[$(tput sgr0)\]@\[$(tput bold)$(tput setaf 3)\]\h\[$(tput sgr0)\]] \$(echo \"\${PWD/#\$HOME/~}\" | awk -F/ '{if (NF>3) {printf \".../\" \$(NF-1) \"/\" \$NF} else {printf \$0}}') ->"
# Coloured username + host + directory:
PS1="[\[$(tput bold)$(tput setaf $_COLOUR)\]\u\[$(tput sgr0)\]@\[$(tput bold)$(tput setaf 3)\]\h\[$(tput sgr0)\]] \[$(tput bold)$(tput setaf 4)\]\$(echo \"\${PWD/#\$HOME/~}\" | awk -F/ '{if (NF>3) {printf \".../\" \$(NF-1) \"/\" \$NF} else {printf \$0}}')\[$(tput sgr0)\] ->"
fi
unset _COLOUR
# Set the debugger prompt.
# PS4="+(\\\$? = \$?) \${BASH_SOURCE##*/}\${FUNCNAME:+(\$FUNCNAME)}:\$LINENO: "
PS4="+(\[\e[33m\]\\\$? = \$?\[$(tput sgr0)\]) \[$(tput bold)$(tput setaf 4)\]\${BASH_SOURCE##*/}\[$(tput sgr0)\]\${FUNCNAME:+(\[$(tput bold)$(tput setaf 2)\]\$FUNCNAME\[$(tput sgr0)\])}:\[$(tput bold)$(tput setaf 1)\]\$LINENO\[$(tput sgr0)\]: "
# Platform specific set up.
_PLATFORM="$(uname -s)"