<commit_before># Dotfiles

These are my humble dotfiles.

I actively use and update the following files:

- sh: [.profile](.profile)
- bash: [.bash_profile](.bash_profile), [.bashrc](.bashrc)
- fish: [config.fish](.config/fish/config.fish), [fishfile](.config/fish/fishfile)
- vim: [.vimrc](.vimrc)
- nvim: [init.vim](.config/nvim/init.vim)
- kitty: [kitty.conf](.config/kitty/kitty.conf), [tmux.conf](.config/kitty/tmux.conf)
- tmux: [.tmux.conf](.tmux.conf)
- git: [.gitconfig](.gitconfig), [.gitignore](.gitignore)
- ledger: [.ledgerrc](.ledgerrc)
- hammerspoon: [init.lua](.hammerspoon/init.lua)

## Usage

Run `make install` to symlink dotfiles in `$HOME`. It will prompt `y/N` for confirmation for each file.

Run `make lint` to run lint shell scripts with [ShellCheck][].

## Shell

I use [fish][] as my primary shell, but I still like to have a usable bash environment. To that end, I have my shell config set up like this:

- [config.fish](.config/fish/config.fish): Fish configuration. Sources `.profile` using [fenv][]. If interactive, defines functions, aliases, etc. and sources `local.fish`.
- `local.fish`: Machine-specific extension to `config.fish`. Not checked in, but stored in the repository directory and symlinked like the rest.
- [fishfile](.config/fish/fishfile): Fish plugins installed by [fisher][].
- [.bash_profile](.bash_profile): Simply sources `.bashrc`.
- [.bashrc](.bashrc): Sources `.profile`. If interactive, sets bash-specific options.
- [.profile](.profile): Written in POSIX sh. This file only sets environment variables. It also sources `.profile.local`.
- `.profile.local`: Machine-specific extension to `.profile`. Not checked in, but stored in the repository directory and symlinked like the rest.

The end result:

- `.profile` is **always** sourced, except by a non-login `sh`. There is no way around that because a non-login `sh` only sources `$ENV`.
- `.profile` is never sourced multiple times (understanding this requires a careful reading of `man bash`).
- bash and fish are configured consistently in login and non-login shells.
- I can store machine-specific information (e.g. API keys) in local files not checked into the repository.

## Vim

I keep my Vim and Neovim config in sync.

To check the difference between them:

```sh
git diff --no-index .config/nvim/init.vim .vimrc
```

To copy changes from `init.vim` to `.vimrc`:

```sh
./patch_vimrc.sh
```
<commit_msg>Update README with table of shell config files<commit_after># Dotfiles

These are my humble dotfiles.

I actively use and update the following files:

- sh: [.profile](.profile)
- bash: [.bash_profile](.bash_profile), [.bashrc](.bashrc)
- fish: [config.fish](.config/fish/config.fish), [fishfile](.config/fish/fishfile)
- vim: [.vimrc](.vimrc)
- nvim: [init.vim](.config/nvim/init.vim)
- kitty: [kitty.conf](.config/kitty/kitty.conf), [tmux.conf](.config/kitty/tmux.conf)
- tmux: [.tmux.conf](.tmux.conf)
- git: [.gitconfig](.gitconfig), [.gitignore](.gitignore)
- ledger: [.ledgerrc](.ledgerrc)
- hammerspoon: [init.lua](.hammerspoon/init.lua)

## Usage

Run `make install` to symlink dotfiles in `$HOME`. It will prompt `y/N` for confirmation for each file.

Run `make lint` to run lint shell scripts with [ShellCheck][].

## Shell

I use [fish][] as my primary shell, but I still like to have a usable bash environment. To that end, I have my shell config set up like this:

- [config.fish](.config/fish/config.fish): Fish configuration. Sources `.profile` using [fenv][]. If interactive, defines functions, aliases, etc. and sources `local.fish`.
- `local.fish`: Machine-specific extension to `config.fish`. Not checked in, but stored in the repository directory and symlinked like the rest.
- [fishfile](.config/fish/fishfile): Fish plugins installed by [fisher][].
- [.bash_profile](.bash_profile): Simply sources `.bashrc`.
- [.bashrc](.bashrc): Sources `.profile`. If interactive, sets bash-specific options.
- [.profile](.profile): Written in POSIX sh. This file only sets environment variables. It also sources `.profile.local`.
- `.profile.local`: Machine-specific extension to `.profile`. Not checked in, but stored in the repository directory and symlinked like the rest.

Here are the files sourced  for (non)login and (non)interactive shells, assuming `sh` is `bash` invoked as `sh`, with parentheses for files that exit early because the shell is non-interactive:

| Shell | Neither | `-l`  | `-i` | `-il` |
| ----- | ------- | ----- | ---- | ----- |
| sh    |         | P     |      | P     |
| bash  |         | B(R)P | RP   | BRP   |
| fish  | (F)P    | (F)P  | FP   | FP    |

Legend:

| Letter | File            |
| ------ | --------------- |
| P      | `.profile`      |
| B      | `.bash_profile` |
| R      | `.bashrc`       |
| F      | `config.fish`   |

## Vim

I keep my Vim and Neovim config in sync.

To check the difference between them:

```sh
git diff --no-index .config/nvim/init.vim .vimrc
```

To copy changes from `init.vim` to `.vimrc`:

```sh
./patch_vimrc.sh
```

{'fraction_non_alphanumeric': 0.15585191082802546, 'fraction_numerical': 0.0, 'mean_word_length': 3.502688172043011, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '994530', 'n_tokens_mistral': 1720, 'n_tokens_neox': 1636, 'n_words': 561}