Skip to content

Instantly share code, notes, and snippets.

@mludvig
Last active June 16, 2021 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mludvig/3840d8030bac5e7db95921baff87989a to your computer and use it in GitHub Desktop.
Save mludvig/3840d8030bac5e7db95921baff87989a to your computer and use it in GitHub Desktop.
#!/bin/bash
# Save as /etc/profile.d/local.sh or as your local ~/.bash_profile
# By Michael Ludvig <mludvig@logix.net.nz>
umask 022
if [ $(id -u) = "0" ]; then
# Prompt is RED for root
_PS1COLOUR=31
else
# And blue for non-root
_PS1COLOUR=36
fi
# If __git_ps1 is available use it
# Symlink /usr/share/git-core/contrib/completion/git-prompt.sh to /etc/profile.d to enable it
if [ "$(type -t __git_ps1)" != "" ]; then
export GIT_PS1_SHOWDIRTYSTATE=1
PS1="\[\e[0;${_PS1COLOUR}m\]\u@\h \[\e[1;32m\]\w \[\e[0m\]\$(__git_ps1 '(%s) ')\[\e[1;${_PS1COLOUR}m\]\\$\[\e[0m\] "
else
PS1="\[\e[0;${_PS1COLOUR}m\]\u@\h \[\e[1;32m\]\w \[\e[1;${_PS1COLOUR}m\]\\$\[\e[0m\] "
fi
export PS1
unset _PS1COLOUR
# Display IPv6 address - just out of interest :)
if /usr/bin/tty -s; then
if [ "$SHLVL" = "1" ]; then
if echo "${SSH_CLIENT}" | grep ":" > /dev/null; then
echo -e "\e[1;32mIPv6 connection from: \e[1;33m${SSH_CLIENT/ */}\e[0m"
fi
fi
fi
# Some handy aliases
alias l='/bin/ls -lFA --color=auto'
# Make Python read its init file
export PYTHONSTARTUP=${PYTHONSTARTUP:-/etc/pythonstart.py}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment