Here is my public configuration for selected command line tools. I checkout this repository to computers I work with.
The dotfiles focus on GNU Bash with the goal of having the shell user-friendly enough to use, but without having extra functionality that would hinder either the shell's start-up or prompt displaying time. I do most of my programming and file editing in Emacs (see my .emacs.d, separate from this repository) or in IntelliJ IDEA; using rich IDEs is another reason for the rather bare-bones shell setup I prefer.
I mainly use macOS, so the tools are optimized for that environment. Rudimentary support for Linux is in place, however, since I occasionally work in a Linux environment for longer periods.
I have copied or adapted some contents from others. For small chunks of code, I have embedded the source URL in a comment inside the file. When copying has been extensive, I have retained the original copyright in the file. Thank you all!
Finally, my motivation for using Bash over more feature-rich shells is that I think tuning .bashrc helps keeping my shell programming skills in shape.
A screenshot from iTerm2, showing the Bash prompt:
The font in use is Input (customization).
I get frustrated if the shell feels sluggish to use. That's why I
optimize the start-up time of my .bashrc:
time bash --login -i -c true
# real 0m0.162sAnd especially, I want that the shell prompt gets re-displayed quickly. In a directory not belonging to a Git working tree:
time eval "$PROMPT_COMMAND"
# real 0m0.032sThe .bashrc-support.sh file defines tk_bm, a
tiny shell function to benchmark the execution time of a command within
the shell itself. Using that to benchmark shell prompt:
tk_bm 'eval "$PROMPT_COMMAND"'
# warmup for 1.150 secs (100 times)
# run command for 10.821 secs (1000 times): eval "$PROMPT_COMMAND"
# mean 10.821 msThese outputs are from an Apple M2 Pro laptop, using Bash v5 and bash-completion with completions enabled for around 30 different tools.
The Bash prompt shows the currently selected versions of
- Node.js, using chnode (
n:$versionat the top of the prompt), - Ruby, using chruby (
r:$version), and - Java Development Kit, using a tiny shell function called
chjavadefined in .bashrc-common.sh (j:$version).
For all these programming environments, I want that the environment switching tool (such as chnode) selects the environment version for a shell session. That allows using two different versions of Node.js in separate shells simultaneously.
The .macos.sh script configures macOS quite extensively,
considering what's possible with the defaults tool and plist files.
The script is originally based on Mathias Bynens' .macos script.
When you configure GNU Global to use Universal Ctags as a symbol parser, it's possible to extend the functionality of Global with the regex based parser definition language of Ctags. For instance, I've added extra support for Yaml, JavaScript, SCSS, and Less files. See .globalrc and custom.ctags.
The downside of regexes is that they're hard to maintain. That's why there's an extensive test suite in gtags-test.sh.
Installing Global with Homebrew:
brew install globalDid you know you can automate testing your shell's init scripts? See bash-test.sh.
Tests are implemented on top of a small custom framework, written in Bash. It was fun to write it. See the sources in the test/support directory.
Run make at the root of the project in order to learn how to run the
linters and tests.
Install the dotfiles with ./install.sh, which either symlinks or
copies each file to your home directory. Installation is safe by
default: if the target file exists in your home directory already, the
installer skips symlinking or copying. See ./install -h for more.
On macOS, install Homebrew to its default prefix directory:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Installing the latest version of Bash, using Homebrew on macOS:
brew install bash
sudo bash -c "echo $(brew --prefix)/bin/bash >> /etc/shells"
chsh -s "$(brew --prefix)/bin/bash"