Skip to content

Instantly share code, notes, and snippets.

@zxexz
Last active October 18, 2018 20:21
Show Gist options
  • Save zxexz/43a73d368c72aa3cb64c1f5057b86360 to your computer and use it in GitHub Desktop.
Save zxexz/43a73d368c72aa3cb64c1f5057b86360 to your computer and use it in GitHub Desktop.
#
# /etc/bash.bashrc
#
#color definitions
#reset
NC='\[\e[0m\]'
BLINK='\[\e[5m\]'
# Normal Colors
Black='\[\e[0;30m\]' # Black
Red='\[\e[0;31m\]' # Red
Green='\[\e[0;32m\]' # Green
Yellow='\[\e[0;33m\]' # Yellow
Blue='\[\e[0;34m\]' # Blue
Purple='\[\e[0;35m\]' # Purple
Cyan='\[\e[0;36m\]' # Cyan
White='\[\e[0;37m\]' # White
# Light
LGreen='\[\e[0,92,m\]'
# Bold
BBlack='\[\e[1;30m\]' # Black
BRed='\[\e[1;31m\]' # Red
BGreen='\[\e[1;32m\]' # Green
BYellow='\[\e[1;33m\]' # Yellow
BBlue='\[\e[1;34m\]' # Blue
BPurple='\[\e[1;35m\]' # Purple
BCyan='\[\e[1;36m\]' # Cyan
BWhite='\[\e[1;37m\]' # White
# Background
On_Black='\[\e[40m\]' # Black
On_Red='\[\e[41m\]' # Red
On_Green='\[\e[42m\]' # Green
On_Yellow='\[\e[43m\]' # Yellow
On_Blue='\[\e[44m\]' # Blue
On_Purple='\[\e[45m\]' # Purple
On_Cyan='\[\e[46m\]' # Cyan
On_White='\[\e[47m\]' # White
# Non-escaped
NEBRed='\e[1;31m'
NEBBlue='\e[1;34m'
NENC='\e[0m'
NEBLINK='\e[5m'
#
[ -z "$PS1" ] && return
#history
HISTCONTROL=ignoredups:ignorespace
#in-shell size (lines)
HISTSIZE=9999999
#in-file size (lines)
HISTFILESIZE=9999999
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
prev=0
_getdate()
{
out=$(date +%Y:%m:%d:%H:%M:%S)
echo "$out"
}
case ${TERM} in
rxvt-unicode-256color*|xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
PROMPT_COMMAND='prev=$?; printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD}"'
;;
screen)
PROMPT_COMMAND='prev=$?;printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD}"'
;;
esac
#add a home directory path
PATH=$PATH:~/.bin
export EDITOR=vim
#so resizing doesn't screw everything up
shopt -s checkwinsize
#
shopt -s promptvars
#enable bash-completion
[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
#help less out with non-text files
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
#vim is preferred to VI
alias vi="vim"
#ctrl-left and ctrl-right should move forward and backword, word-for-word
bind '"\[\eOC":forward-word'
bind '"\[\eOD":backward-word'
#clipboard!
alias "c=xclip"
alias "v=xclip -o"
#Colors!
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias ls='ls --color=auto'
export PYTHONSTARTUP=$HOME/.pythonstartup
#Now, the PS1
[ -n "$SSH_CLIENT" ] && ps1_informer="[${Blue}[ssh]${NC}]:"
[ -n "$RANGER_LEVEL" ] && ps1_informer="[(in ranger)]:"
_colourprev()
{
if [ $prev -eq 0 ]; then
_colourswitch=${NEBBlue}
else
_colourswitch=${NEBRed}
fi
printf "%b${prev}%b" "$_colourswitch" "${NENC}"
}
if [ $(id -u) -eq 0 ]; then
_user="${BRed}${BLINK}$(whoami)${NC}"
_prompt="${Red}#${NC}"
_ucol=${Red}
else
_user="${Green}$(whoami)${NC}"
_prompt="${Green}\$${NC}"
_ucol=${Green}
fi
PS1="${NC}┌[\$(_colourprev)]:[${BBlue}\$(_getdate)${NC}]:[${Blue}$(uname -r)${NC}]\n├[${Green}${_user}${NC}${Cyan}@${NC}${Yellow}\h${NC}]:$ps1_informer[${Purple}\$(pwd)${NC}]\n${White}╘═[${NC}${_prompt}] ${_ucol}${NC}"
PS1='$(printf "%$((COLUMNS-1))s\r")'$PS1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment