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

View file

@ -42,7 +42,7 @@ hash ssh-add ssh-agent >/dev/null 2>&1 && {
echo echo
alias ssh='ssh-add -l >/dev/null 2>&1 && unalias ssh || { ssh-add && unalias ssh; }; ssh' alias ssh='ssh-add -l >/dev/null 2>&1 && unalias ssh || { ssh-add && unalias ssh; }; ssh'
else else
echo -e '\033[1;31mProblem connecting to forwarded ssh-agent!\033[0m' echo -e '$(tput setaf 1 || tput AF 1)Problem connecting to forwarded ssh-agent!$(tput op)'
echo echo
fi fi
else else
@ -61,11 +61,11 @@ hash ssh-add ssh-agent >/dev/null 2>&1 && {
echo echo
alias ssh='ssh-add -l >/dev/null 2>&1 && unalias ssh || { ssh-add && unalias ssh; }; ssh' alias ssh='ssh-add -l >/dev/null 2>&1 && unalias ssh || { ssh-add && unalias ssh; }; ssh'
else else
echo "Problem connecting to local ssh-agent!" echo "$(tput setaf 1 || tput AF 1)Problem connecting to local ssh-agent!$(tput op)"
echo echo
fi fi
else else
echo "Failed to start local ssh-agent!" echo "$(tput setaf 1 || tput AF 1)Failed to start local ssh-agent!$(tput op)"
echo echo
fi fi
fi fi

54
.bashrc
View file

@ -1,5 +1,5 @@
# Make bash a little more pleasent. # Make bash a little more pleasent - these are valid for all versions.
shopt -s cdspell checkhash checkjobs checkwinsize cmdhist dirspell histappend no_empty_cmd_completion shopt -s cdspell checkhash checkwinsize cmdhist histappend no_empty_cmd_completion
# Exit the shell on a Ctl+D. # Exit the shell on a Ctl+D.
IGNOREEOF=0 IGNOREEOF=0
@ -12,22 +12,44 @@ HISTSIZE=-1
HISTTIMEFORMAT="%d/%m/%y %H:%M:%S " HISTTIMEFORMAT="%d/%m/%y %H:%M:%S "
history -r history -r
# Set the prompts. # Determine the colour of the username in the prompt.
if (( ${BASH_VERSINFO[0]} >= 4 )); then if (( $(id -u) == 0 )); then
export PROMPT_DIRTRIM=2 _COLOUR=1 # Red
if (( $(id -u) == 0 )); then
PS1="[\[\033[1;31m\]\u\[\033[0m\]@\h] \w ->"
else
PS1="[\u@\h] \w ->"
fi
else else
if (( $(id -u) == 0 )); then _COLOUR=2 # Green
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 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 specific set up.
_PLATFORM="$(uname -s)" _PLATFORM="$(uname -s)"