Nix shells¶
These are instructions for setting up ZSH, dotfiles, etc. These documents reference it:
Install Oh My Zsh¶
You’ll thank me later. (You’ll need ZSH installed for this to work.)
Run
You should be prompted to change your shell. If you are not, run
Make sure it is set by running
You may need to reboot for the change to your login shell to take effect. You should now have a colorful shell, complete with a plugin for Git.
.commonrc file¶
About .bash_profile, .zshenv, etc.
| File | Shell | Read if shell is | My advice |
|---|---|---|---|
.profile | sh † | login | delete |
.bash_profile | Bash ‡ | login | source .common-profile |
.zprofile | ZSH | login | source .common-profile |
.bashrc | Bash | interactive and non-login | source .commonrc |
.zshrc | ZSH | interactive | source .commonrc; set up ZSH |
.zshenv | ZSH | non-interactive | delete |
.zlogout | ZSH | logging out | use if needed |
.common-profile | multi | N/A (sourced) | set env vars |
.commonrc | multi | N/A (sourced) | add aliases, etc. |
Table 1. *.bashrc and similar files.
- † .profile is the original Bourne shell config file, but Bash will also read it if .bash_profile doesn’t exist. - ‡ The default .zprofile sources .bash_profile if it exists.
Further reading:
Create a new file, ~/.commonrc, and have ~/.bashrc, ~/.zshrc, and any other Bash-compatible ~/.*rc files source it. Use ~/.commonrc to set up your environment variables, aliases, etc. This is a solid but extremely simple way to keep the shell configurations in sync.
I wrote a little script called commonrc-config.sh, which manages this nicely. It does nothing on its own; it just provides some functions. Run these commands:
mkdir -p ~/bin
curl https://dmyersturnbull.github.io/guide/commonrc-config.sh -O ~/bin/commonrc-config.sh
source ~/bin/commonrc-config.sh
commonrc::init
commonrc::source_from bashrc # adds 'source $HOME/.commonrc'
commonrc::source_from zshrc
Fish shell
If you want to include the Fish shell, run
Info
commonrc-config.sh’s functions are just idempotent, so you won’t end up with multiple source lines, etc. Otherwise, it’s mostly equivalent to this:
Sudoers (Linux only)¶
The easiest way is to run
- This will require you to enter the root password.
See this sudoers guide for more info.
Dotfiles¶
First, make sure ~/bin exists and is in your PATH. (If you used commonrc-config.sh, it already did this).
Consider using a dotfile manager like chezmoi. You can let chezmoi manage your ~/.commonrc file, too.
Grab useful Bash scripts from awesome-dotfiles: Also see this simplified version of my .commonrc, which contains some useful functions and aliases.