Here’s something I keep forgetting to save and/or backup, my .bashrc. The last couple of times I reinstalled or switched to another distribution I did remember to backup my dotfiles but I figured I might as well just post it here in case I ever need it again.
Most of it comes from the Arch Linux Wiki, a great place for Linux information even if you don’t use Arch. I have then made a few tweaks from snippets I found on other websites. I can’t rememberĀ all of them since at the time I had no intention of posting this here. If you find anything that you think is yours please send me the article link so I can pingback to it. Keep in mind there are some Arch specific sections in there, feel free to edit and redistribute as you see fit.
Since it’s quite a wall of text, I’ll drop it after a break for the website proper. If you’re reading this through an RSS reader, sorry for the wall of text.
# /etc/bash.bashrc## This file is sourced by all *interactive* bash shells on startup,# including some apparently interactive shells such as scp and rcp# that can't tolerate any output. So make sure this doesn't display# anything or bad things will happen !# Test for an interactive shell. There is no need to set anything# past this point for scp and rcp, and it's important to refrain from# outputting anything in those cases.# If not running interactively, don't do anything![[$- != *i* ]]&&return# Bash won't get SIGWINCH if another process is in the foreground.# Enable checkwinsize so that bash will check the terminal size when# it regains control.# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)shopt -s checkwinsize
# Enable history appending instead of overwriting.shopt -s histappend
case${TERM} in
xterm*|rxvt*|Eterm|aterm|kterm|gnome*)PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"' ;;
screen)PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"' ;;
esac# Set colorful PS1 only on colorful terminals.# dircolors --print-database uses its own built-in database# instead of using /etc/DIR_COLORS. Try to use the external file# first to take advantage of user additions. Use internal bash# globbing instead of external grep binary.# sanitize TERM:safe_term=${TERM//[^[:alnum:]]/?}match_lhs=""[[ -f ~/.dir_colors ]]&&match_lhs="${match_lhs}$(<~/.dir_colors)"[[ -f /etc/DIR_COLORS ]]&&match_lhs="${match_lhs}$(</etc/DIR_COLORS)"[[ -z ${match_lhs}]]\&&type -P dircolors >/dev/null \&&match_lhs=$(dircolors --print-database)if[[$'\n'${match_lhs}== *$'\n'"TERM "${safe_term}* ]] ; then# we have colors :-)# Enable colors for ls, etc. Prefer ~/.dir_colorsif type -P dircolors >/dev/null ; then if[[ -f ~/.dir_colors ]] ; theneval$(dircolors -b ~/.dir_colors)elif[[ -f /etc/DIR_COLORS ]] ; theneval$(dircolors -b /etc/DIR_COLORS)fi fi# ResetColor_Off="\[\033[0m\]"# Text Reset# Regular ColorsBlack="\[\033[0;30m\]"# BlackRed="\[\033[0;31m\]"# RedGreen="\[\033[0;32m\]"# GreenYellow="\[\033[0;33m\]"# YellowBlue="\[\033[0;34m\]"# BluePurple="\[\033[0;35m\]"# PurpleCyan="\[\033[0;36m\]"# CyanWhite="\[\033[0;37m\]"# White# BoldBBlack="\[\033[1;30m\]"# BlackBRed="\[\033[1;31m\]"# RedBGreen="\[\033[1;32m\]"# GreenBYellow="\[\033[1;33m\]"# YellowBBlue="\[\033[1;34m\]"# BlueBPurple="\[\033[1;35m\]"# PurpleBCyan="\[\033[1;36m\]"# CyanBWhite="\[\033[1;37m\]"# White# UnderlineUBlack="\[\033[4;30m\]"# BlackURed="\[\033[4;31m\]"# RedUGreen="\[\033[4;32m\]"# GreenUYellow="\[\033[4;33m\]"# YellowUBlue="\[\033[4;34m\]"# BlueUPurple="\[\033[4;35m\]"# PurpleUCyan="\[\033[4;36m\]"# CyanUWhite="\[\033[4;37m\]"# White# BackgroundOn_Black="\[\033[40m\]"# BlackOn_Red="\[\033[41m\]"# RedOn_Green="\[\033[42m\]"# GreenOn_Yellow="\[\033[43m\]"# YellowOn_Blue="\[\033[44m\]"# BlueOn_Purple="\[\033[45m\]"# PurpleOn_Cyan="\[\033[46m\]"# CyanOn_White="\[\033[47m\]"# White# High IntenstyIBlack="\[\033[0;90m\]"# BlackIRed="\[\033[0;91m\]"# RedIGreen="\[\033[0;92m\]"# GreenIYellow="\[\033[0;93m\]"# YellowIBlue="\[\033[0;94m\]"# BlueIPurple="\[\033[0;95m\]"# PurpleICyan="\[\033[0;96m\]"# CyanIWhite="\[\033[0;97m\]"# White# Bold High IntenstyBIBlack="\[\033[1;90m\]"# BlackBIRed="\[\033[1;91m\]"# RedBIGreen="\[\033[1;92m\]"# GreenBIYellow="\[\033[1;93m\]"# YellowBIBlue="\[\033[1;94m\]"# BlueBIPurple="\[\033[1;95m\]"# PurpleBICyan="\[\033[1;96m\]"# CyanBIWhite="\[\033[1;97m\]"# White# High Intensty backgroundsOn_IBlack="\[\033[0;100m\]"# BlackOn_IRed="\[\033[0;101m\]"# RedOn_IGreen="\[\033[0;102m\]"# GreenOn_IYellow="\[\033[0;103m\]"# YellowOn_IBlue="\[\033[0;104m\]"# BlueOn_IPurple="\[\033[10;95m\]"# PurpleOn_ICyan="\[\033[0;106m\]"# CyanOn_IWhite="\[\033[0;107m\]"# White#Random PS1 EDITGIT_PS1_SHOWDIRTYSTATE=falseif[[${EUID}== 0 ]] ; thensq_color=$BRedelsesq_color=$BBluefiexport PS1="\n$sq_color\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[$BRed\342\234\227$sq_color]\342\224\200\")[$IBlack\t$sq_color]\342\224\200[\[\033[01;37m\]\u$sq_color]\342\224\200[$BGreen\w$sq_color]\n$sq_color\342\224\224\342\224\200\342\224\200> $BRed\$("") $sq_color\$ $Color_Off"alias ls="ls --color=auto"alias dir="dir --color=auto"alias grep="grep --color=auto"alias dmesg='dmesg --color' man(){ env LESS_TERMCAP_mb=$'\E[01;31m'\LESS_TERMCAP_md=$'\E[01;38;5;74m'\LESS_TERMCAP_me=$'\E[0m'\LESS_TERMCAP_se=$'\E[0m'\LESS_TERMCAP_so=$'\E[38;5;246m'\LESS_TERMCAP_ue=$'\E[0m'\LESS_TERMCAP_us=$'\E[04;38;5;146m'\ man "$@"}else# show root@ when we do not have colorsPS1="\u@\h \w \$([[ \$? != 0 ]] && echo \":( \")\$ "# Use this other PS1 string if you want \W for root and \w for all other users:# PS1="\u@\h $(if [[ ${EUID} == 0 ]]; then echo '\W'; else echo '\w'; fi) \$([[ \$? != 0 ]] && echo \":( \")\$ "fiPS2="> "PS3="> "PS4="+ "# Try to keep environment pollution down, EPA loves us.unset safe_term match_lhs
# Try to enable the auto-completion (type: "pacman -S bash-completion" to install it).[ -r /usr/share/bash-completion/bash_completion ]&& . /usr/share/bash-completion/bash_completion
# Try to enable the "Command not found" hook ("pacman -S pkgfile" to install it).# See also: https://wiki.archlinux.org/index.php/Bash#The_.22command_not_found.22_hook[ -r /usr/share/doc/pkgfile/command-not-found.bash ]&& . /usr/share/doc/pkgfile/command-not-found.bash
archey