Comprehesive and portable environment configuration in a single file.
The goal of this script to safely(1) and predictably(2) store and update CLI and other app configurations from a single source, without using symlinks, Git or other more complex tools.
A single source ~/.shellrc
should configure the shell environment and any supported (and installed) tools.
(1) Safely:
Configuration values coming from .shellrc
are either appended or prepended to existing config files, in such a way that pre-existing user settings are preserved.
.shellrc
's main()
runs only under interactive shells and with set -euf
for additional safety. These values are restored to set +euf
on success.
(2) Predictably:
Configurations are only written for the tools that are already present in the system to minimise clobbering the ~/
and ~/.config
dirs.
curl -fsSL https://raw.githubusercontent.com/tmslnz/shellrc/main/shellrc -o ~/.shellrc
. ~/.shellrc
.shellrc
automatically checks for updates.
The last snapshot can be restored using:
shellrc revert
Updates can be manually requested using:
shellrc update
The updater saves previous versions in ~/.config/shellrc/snapshots
All code in the script is wrapped in funsctions.
There are two classes of functions in the script:
_shellrc_*
: persistent in the session. These are utilities called throughout the script.configure_*
: called once, thenunset -f
to remove them from the symbols list.
The execution flow is controlled in main()
.
The script writes all configurations conditionally (i.e: x in PATH
, OS == Darwin
) and only within "fenced" sections (e.g. BEGIN_SHELLRC [...] END_SHELLRC
).
Local changes outside of a fenced section are never over-written.
Local changes within a fenced section are also not overwritten if the edits are more recent than the ~/.shellrc
file's last updated timestamp.
https://www.gnu.org/software/bash/
https://github.com/scop/bash-completion
https://en.wikipedia.org/wiki/Grep
https://www.gnu.org/software/emacs/
https://www.gnu.org/software/wget/
https://github.com/junegunn/fzf
https://github.com/ajeetdsouza/zoxide
https://github.com/pyenv/pyenv
https://kislyuk.github.io/argcomplete/