Bash config snippets

The shell program /bin/bash (hereafter referred to as just “the shell“) uses a collection of startup files to help create an environment. Each file has a specific use and may affect login and interactive environments differently. The files in the /etc directory generally provide global settings. If an equivalent file exists in your home directory it may override the global settings.

An interactive login shell is started after a successful login, using /bin/login, by reading the /etc/passwd file. This shell invocation normally reads /etc/profile and its private equivalent ~/.bash_profile upon startup.

An interactive non-login shell is normally started at the command-line using a shell program (e.g., [prompt]$/bin/bash) or by the /bin/su command. An interactive non-login shell is also started with a terminal program such as xterm or konsole from within a graphical environment. This type of shell invocation normally copies the parent environment and then reads the user’s ~/.bashrc file for additional startup configuration instructions.

A non-interactive shell is usually present when a shell script is running. It is non-interactive because it is processing a script and not waiting for user input between commands. For these shell invocations, only the environment inherited from the parent shell is used.

The file ~/.bash_logout is not used for an invocation of the shell. It is read and executed when a user exits from an interactive login shell.

Many distributions use /etc/bashrc for system wide initialisation of non-login shells. This file is usually called from the user’s ~/.bashrc file and is not built directly intobash  itself. This convention is followed in this section.

Anyway, enough with the presentation of the configuration instruction. The next snippets can be safely added in ~/.bashrc file:

Big, big history. Very useful when you have a lot of tabs opened and you can’t find something that you typed 3 minutes ago in another tab.


Welcome screen. Well, why not? Let’s stay classy.

Here’s some work in progress. To be updated
Easy extract archives


Human readable directory size. Finds directory sizes and lists them for the current directory


Up on directory. Goes up many dirs as the number passed as argument