My Bash Configuration
-
Optimized and error checked using ShellCheck.
-
Formatted using shfmt.
-
The interactive shell configuration file
~/.bashrc
will also source the global cofiguration at/etc/bashrc
. -
The login shell configuration file
~/.bash_profile
will also source the interactive shell configuration file~/.bashrc
. -
If installed, automatic
PATH
management & initialization for - -
Automatic
PATH
management for user compiled binaries & scripts located at~/bin
&~/.local/bin
. -
Enabled changing directories when entering just a path i.e. executing
$ /path/to/some/directory
is equivalent to$ cd /path/to/some/directory
. -
Dynamic resizing of content within the window when the terminal emulator is resized.
-
Unlimited history.
-
Immediately save commands to history upon execution. This ensures that when running multiple Bash sessions (eg: using tmux, etc.), all commands from all sessions are written to the history.
-
Write history to a custom file
~/.my_bash_history
for better retention. -
Improve readability by combining multi-line commands into a single command when writing to history.
-
Entries in history will be timestamped in this format -
894 [Wed-20-Dec-2023-04-12-21-AM-+0530] ==> ls -Alh
.
The following requirements must be met in order to use this configuration.
The supported operating systems and the location of the respective configurations are shown below.
OS | Configuration Path(s) | Remarks |
---|---|---|
GNU/Linux | ~/.bashrc.d , ~/.bashrc , ~/.bash_profile |
None |
MacOS | ~/.bashrc.d , ~/.bashrc , ~/.bash_profile |
None |
BSDs | ~/.bashrc.d , ~/.bashrc , ~/.bash_profile |
Untested |
The following packages are required in order to use this configuration.
Dependency | Type | Version |
---|---|---|
GNU Bash | Mandatory | 4.x & Above |
Git | Mandatory | Any |
GNU Stow | Optional (Recommended) |
Any |
The following additional requirements must be met in otder to use this configuration.
- None.
-
Create a new backup directory.
$ mkdir "${HOME}"/.bash_backup
-
Backup existing configuration files (see supported operating systems) to the backup directory.
$ mv "${HOME}/.bash_profile" "${HOME}"/.bash_backup/.bash_profile-"$(date +%a-%d-%b-%Y-%I-%M-%S-%p-%z)".backup $ mv "${HOME}/.bashrc" "${HOME}"/.bash_backup/.bashrc-"$(date +%a-%d-%b-%Y-%I-%M-%S-%p-%z)".backup $ mv "${HOME}/.bashrc.d" "${HOME}"/.bash_backup/.bashrc.d-"$(date +%a-%d-%b-%Y-%I-%M-%S-%p-%z)".backup
-
Clone this repository into your home directory.
$ cd "${HOME}" $ git clone https://github.com/ameyng/config-bash
-
Navigate to the cloned repository.
$ cd config-bash
-
Installation can be done using GNU Stow or
ln
.-
Using GNU Stow
$ stow bash -t "${HOME}"
-
Using
ln
$ cd bash $ ln -sf "$(pwd)"/.bashrc "${HOME}"/.bashrc $ ln -sf "$(pwd)"/.bash_profile "${HOME}"/.bash_profile $ ln -sf "$(pwd)"/.bashrc.d "${HOME}"/.bashrc.d
-
-
Verify the operation by executing
$ ls -Alh ~/
. You will see entries for.bashrc
,.bash_profile
&.bashrc.d
with arrows pointing to the actual files i.e. to the files within this cloned repository. -
Close and reopen your terminal emulator program or open a new session of Bash.
-
Backup existing configuration files (see supported operating systems) to the backup directory.
$ mv "${HOME}/.bash_profile" "${HOME}"/.bash_backup/.bash_profile-"$(date +%a-%d-%b-%Y-%I-%M-%S-%p-%z)".backup $ mv "${HOME}/.bashrc" "${HOME}"/.bash_backup/.bashrc-"$(date +%a-%d-%b-%Y-%I-%M-%S-%p-%z)".backup $ mv "${HOME}/.bashrc.d" "${HOME}"/.bash_backup/.bashrc.d-"$(date +%a-%d-%b-%Y-%I-%M-%S-%p-%z)".backup
-
Update the cloned repository.
$ cd "${HOME}" $ cd config-bash $ git pull --all
-
The configuration can be updated using GNU Stow or
ln
.-
Using GNU Stow
$ stow bash -t "${HOME}"
-
Using
ln
$ cd bash $ ln -sf "$(pwd)"/.bashrc "${HOME}"/.bashrc $ ln -sf "$(pwd)"/.bash_profile "${HOME}"/.bash_profile $ ln -sf "$(pwd)"/.bashrc.d "${HOME}"/.bashrc.d
-
-
Verify the operation by executing
$ ls -Alh ~/
. You will see entries for.bashrc
,.bash_profile
&.bashrc.d
with arrows pointing to the actual files i.e. to the files within this cloned repository. -
Close and reopen your terminal emulator program or open a new session of Bash.