Bash dotfiles¶
.bashrc¶
At the top of .bashrc, the following files are sourced if they’re present.
This keeps things a little more organized and modular:
for file in ~/.{path,exports,bash_prompt,functions,aliases,extra}; do
[ -r "$file" ] && [ -f "$file" ] && source "$file";
done;
unset file;
These files are described in the sections below, but a quick summary:
.path: all
export PATH=...can go here..aliases: store your aliases here.
.functions: store your bash functions here.
.bash_prompt: edit your bash prompt here.
.exports: add your various env var exports here.
.extra: any machine-specific config goes here.
The modular organization for bash configuration is inspired by this repo.
Other notable parts of the .bashrc:
Update terminal size after commands
Enables autocd if available. When enabled, just the name of a directory will be sufficient to cd to it.
Enables globstar if available. When enabled, the pattern
**used in a filename expansion context will match all files and zero or more directories and subdirectories. If the pattern is followed by a ‘/’, only directories and subdirectories match.Enables bash completion and git completion
Enables color support for
lsIf running under tmux, always deactivate environments when creating a new bash shell (see conda for more details on this)
.bash_profile¶
.bash_profile does only one thing: it sources .bashrc.
.path¶
This file ends up being lots of export PATH="$PATH:/some/other/path"
lines. It is initially populated to put ~/opt/bin and
~/mambaforge/condabin on the path. As you install more software in other
locations, this is a tidy place to put the various exports.
.aliases¶
This file keeps aliase separate for easier maintenance. See .aliases
for the commands set for each alias.
.functions¶
Separate file for bash functions. This is also where fzf and autojump are set up. Some notable functions defined here:
function |
description |
|---|---|
|
Use this to start the ssh agent so you don’t need to keep entering your ssh key during a session |
|
Nicer |
|
Open |
|
When run in a clone of a repo with a pull request from a fork, get set up to push changes back to the contributor’s branch |
|
Equivalent to |
|
Deactivate all conda environments. Useful when running under tmux; see conda for more details. |
|
Print out a nice table of hostnames and aliases from your
|
.bash_prompt¶
This file changes the prompt color for Biowulf or Helix (NIH HPC), but here you can add any other hosts or colors. See https://misc.flogisoft.com/bash/tip_colors_and_formatting for color options.
.extra¶
Nothing is in here by default. This is a good place to store host-specific details.
.exports¶
Exported environment variables.
env var |
value and description |
|---|---|
|
set |
|
|
|
|
|
|
|
Set a large history size |
|
Same for history file |
|
In tmux, default is to italicize identified search terms. This highlights instead. |
|
Uses |
|
Exports shell as |