Bashrc for root

On Gentoo (and perhaps other distributions), root doesn’t have the normal bash startup configuration files. If you want to use a ~/.bashrc file to load e.g. ~/.bash_aliases and ~/.bash_functions, then you’ll need a ~/.bash_profile file to kick everything into action.

Here are mine…


# Copied from /etc/skel/.bash_profile and modified

# This file is sourced by bash for login shells.  The following line
# runs your .bashrc and is recommended by the bash info pages.
[[ -f ~/.bashrc ]] && . ~/.bashrc


# Copied from /etc/skel/.bashrc and modified
# 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 [[ $- != *i* ]] ; then
	# Shell is non-interactive.  Be done now!

# Put your fun stuff here.
MAILPATH=~/.maildir/new?"You have a new mail. Read it with mutt."

# Aliases and functions
source ~/.bash_aliases
source ~/.bash_functions

You should now be able to add your aliases to ~/.bash_aliases and functions to ~/.bash_functions (though there’s no need to use these particular files - you could simply put the aliases/functions into ~/.bashrc, in which case you’d remove the lines that source them).

Last modified: 28/06/2012 Tags:

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top