My .bashrc
Bash Initialization File
How I Customize my Bash Command-Line Environment
Remember that the simple version of the
bash shell initialization sequence is:
At initial login, system-wide:
/etc/profile
(from the distro)
/etc/profile.d/*
(local customizations)
Then, at initial login,
user-specific customizations:
$HOME/.bash_profile
And then, for each interactive shell,
further user-specific customizations:
$HOME/.bashrc
It actually can be more complicated yet, and with many
distributions it is.
But...
Start by making small customizations to your
personal .bashrc
file.
Here is my .bashrc
file:
# .bashrc # User specific aliases and functions # Read first /etc/inputrc if the variable is not defined, and after the /etc/inputrc # include the ~/.inputrc [ -z $INPUTRC ] && export INPUTRC=/etc/inputrc # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi ############################################################################### # Above this is what was installed when the account was created. # It was automatically copied in from /etc/skel/.bashrc, which was # created by the people who built the distribution. # # Below here are my customizations. ############################################################################### # I have some scripts and compiled programs in ~/bin: export PATH=${PATH}:/home/cromwell/bin # vi style command-history editing, with Ctrl-L clearing the screen: set -o vi bind -m vi-insert "\C-l":clear-screen # Make readline append '/' to directories without pressing <Tab> twice. bind 'set mark-directories on' bind 'set mark-symlinked-directories on' # US English with good multi-language character support, so I can paste # non-ASCII strings (like содержание, "content") from something like a # web page into a vim session: export LANG=en_US.UTF-8 export LOCALE=en_US.UTF-8 export XTERM_LOCALE=en_US.utf8 export PYTHONIOENCODING=utf8 # To get pure Unix ASCII ordering in "ls" output, set LC_ALL to C. # However, that breaks UTF-8 encoding in xterm. So, alias that: export LC_ALL=C alias xterm='/usr/bin/xterm -en UTF-8 -fg gold -bg grey30' # And another xterm quirk needed to get color support in ls & grep: echo $TERM | grep -qi xterm if [ $? == 0 ] then export TERM=xterm-color fi # Slight modification to /bin/ls, use the standard colors plus # ones for "*.iso" and "*.tex" files. eval $( dircolors ) export LS_COLORS=${LS_COLORS}:'*.iso=00;33:*.tex=00;33' # The "ls" default output format changed, now quotes are automatically # inserted around names containing special characters. I prefer the # classic version, so disable that quoting: export QUOTING_STYLE=literal alias ls='/bin/ls -F --color --quoting-style=literal' # Slight modification to grep family. alias grep='/bin/grep --color' alias egrep='/bin/egrep --color' alias fgrep='/bin/fgrep --color' # Cautious file manipulation, avoid accidental overwriting. alias mv='mv -i' alias cp='cp -i' set -o noclobber # Tell me as soon as a background job ends, rather than # waiting for the next prompt: set -o notify # Make "less" behave better # -M = display a percentage (like more) # -X = keep text on screen at exit # -F = exit when the file (or stream) fits on one screen # -e = exit at EOF plus another page export LESS='-MXFe' # My preferred spell check method function spell() { # Start by converting my commonly used Unicode # strings to simplified ASCII. sed 's/*#x00[ce][89];/e/g' $1 | sed 's/[01];/a/g' | sed 's/[cd];/o/g' | sed 's/[ab];/u/g' | /usr/bin/spell | sort -iu | less } # Decimal/hex/octal/binary conversion. "d2h" is decimal to hexadecimal, # and so on. Use as: # $ d2h 123456 # 1E240 # $ h2d fe800a # 16678922 # $ d2b 12345 # 11000000111001 # and so on. function d2h() { echo 16 o $1 p | dc } function d2o() { echo 8 o $1 p | dc } function d2b() { echo 2 o $1 p | dc } function h2d() { echo 16 i $(echo $1 | tr a-z A-Z) p | dc } function h2b() { echo 16 i 2 o $(echo $1 | tr a-z A-Z) p | dc } function b2d() { echo 2 i $1 p | dc } function b2h() { echo 16 o 2 i $1 p | dc } function b2o() { echo 8 o 2 i $1 p | dc } # Update PATH for the Google Cloud SDK. if [ -f $HOME/bin/google-cloud-sdk/path.bash.inc ] then source $HOME/bin/google-cloud-sdk/path.bash.inc fi # The next line enables shell command completion for gcloud. if [ -f $HOME/bin/google-cloud-sdk/completion.bash.inc ] then source $HOME/bin/google-cloud-sdk/completion.bash.inc fi