Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,22 @@

| Layer | Owns | Mechanism |
|----------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|
| **[omnishell](https://github.com/JtheGunner/omnishell)** | rc *lines*: plugin inits, history, completion, `fzf`, `zoxide`, `modern-aliases`, `colorized-man`, `direnv`, `broot`, `mise`, `starship` (prompt + its seeded config), `root-loops` (OSC palette push), `tmux` (installs it; auto-attach is off) | one marker block in `~/.zshrc` / `~/.bashrc`, sourcing a generated `init.<shell>` |
| **[omnishell](https://github.com/JtheGunner/omnishell)** | rc *lines*: plugin inits, history, completion, `zsh-completions`, `fzf`, `zoxide`, `modern-aliases`, `colorized-man`, `direnv`, `broot`, `mise`, `starship` (prompt + its seeded config), `root-loops` (OSC palette push), `tmux` (installs it; auto-attach is off) | one marker block in `~/.zshrc` / `~/.bashrc`, sourcing a generated `init.<shell>` |
| **this repo: stow packages** | standalone config *files*: `git`, `tmux` (`.tmux.conf` only), `bat`, `ghostty` (+ optional `nvim`) | [GNU Stow](https://www.gnu.org/software/stow/) symlinks into `$HOME` |
| **this repo: rc libraries** | the base `~/.zshrc` / `~/.bashrc` content: env, keybindings, zsh completion styling | `zsh/zshrc.zsh` + `bash/bashrc.bash`, **`source`d** from a generated real rc file (not stowed, see below) |
| **this repo: `shell.d/`** | personal rc lines not worth a public module: k8s / docker aliases, `linuxbrew`, helper functions | a second marker block, sourced *after* omnishell |
| **`~/.zshrc.local` / `~/.bashrc.local`** | machine-specific and secret: per-host `PATH`, tool completions, tokens. **Not version-controlled.** | sourced last by the same marker block |

omnishell is consumed as a released binary (Homebrew tap / curl installer); this
repo never modifies it. **omnishell 0.8.0 or newer is required**: older releases
repo never modifies it. **omnishell 0.9.0 or newer is required**: older releases
don't know all of the `starship`, `root-loops`, `tmux`, `broot`, `direnv`, `mise` and
`colorized-man` modules, and install `mise`, `starship` and `broot` with a long
source build where no distro package exists, 0.7.0 is the first with
`omnishell tui`, which `--interactive` uses, before 0.7.1 a tool installed
from a release binary or a source build is not on `PATH` at shell start (no
`starship` prompt), and before 0.8.0 `modern-aliases` is degraded where the
distro has no `eza` package. `bootstrap.sh` upgrades an older
`starship` prompt), before 0.8.0 `modern-aliases` is degraded where the
distro has no `eza` package, and before 0.9.0 there is no `zsh-completions`
module. `bootstrap.sh` upgrades an older
install, or stops with a message if it can't.

```text
Expand Down Expand Up @@ -78,11 +79,11 @@
`bootstrap.sh`:

1. checks that nothing points at another checkout (see [Multiple checkouts](#multiple-checkouts))
2. installs dependencies, omnishell (upgrading it below 0.8.0) and Ghostty (unless switched off), and zsh if you opted in, then offers to make zsh your login shell (see [Settings file](#-settings-file)); on apt systems with a CPU other than x86_64 / arm64 also a Rust toolchain
2. installs dependencies, omnishell (upgrading it below 0.9.0) and Ghostty (unless switched off), and zsh if you opted in, then offers to make zsh your login shell (see [Settings file](#-settings-file)); on apt systems with a CPU other than x86_64 / arm64 also a Rust toolchain
3. writes real `~/.zshrc` / `~/.bashrc`
4. stows the packages (unless skipped)
5. writes the git `delta` config and asks for your git identity (unless skipped) (see [Git identity](#-git-identity))
6. applies `omnishell/config.toml`, which also installs `starship`, `mise`, `tmux`, `direnv` and `broot`
6. on Homebrew, removes the group/other write bit from `share` and `share/zsh` so zsh's `compinit` accepts the `zsh-completions` directory (unless switched off), then applies `omnishell/config.toml`, which also installs `zsh-completions`, `starship`, `mise`, `tmux`, `direnv` and `broot`
7. appends the `shell.d` block to both rc files
8. renders the terminal colour themes

Expand Down Expand Up @@ -121,7 +122,7 @@
>
> Fix the cause (or install the packages yourself) and re-run `./bootstrap.sh`.

### Multiple checkouts

Check warning on line 125 in README.md

View workflow job for this annotation

GitHub Actions / docs-drift

doc-drift

Section "Multiple checkouts" may be outdated: linked code changed but the section did not (changed code: bootstrap.sh).

Several clones on one machine are fine, e.g. a working copy to hack on and a
second one to test the install end to end. Only one of them is live. Two things
Expand Down Expand Up @@ -180,6 +181,7 @@
| `[bootstrap]` `skip_packages` | `fzf` `zoxide` `ripgrep` `fd` `bat` `git-delta` (list) | `[]` | - | `DOTFILES_SKIP_PACKAGES` |
| `[bootstrap]` `skip_stow` | `git` `tmux` `bat` `ghostty` (list) | `[]` | - | `DOTFILES_SKIP_STOW` |
| `[bootstrap]` `terminal_app_profile` | `true` · `false` | `true` | - | `DOTFILES_TERMINAL_APP_PROFILE` |
| `[bootstrap]` `fix_completion_permissions` | `true` · `false` | `true` | - | `DOTFILES_FIX_COMPLETION_PERMISSIONS` |
| `[bootstrap]` `assume_yes` | `true` · `false` | `false` | `--yes` | `DOTFILES_ASSUME_YES` |
| `[bootstrap]` `terminals` | list of package names | `[]` | - | `DOTFILES_TERMINALS` |
| `[ghostty]` `keybinds` | `"auto"` · `"mac"` · `"linux"` | `"auto"`| - | `DOTFILES_GHOSTTY_KEYBINDS` |
Expand Down Expand Up @@ -221,6 +223,12 @@
> Ghostty installation. The `ghostty` config is still stowed, so installing Ghostty later needs no
> further setup. The environment variable accepts `1`/`0`, `true`/`false` or `yes`/`no`.
>
> `fix_completion_permissions = false` (or `DOTFILES_FIX_COMPLETION_PERMISSIONS=0`) stops
> `bootstrap.sh` from changing permissions under the Homebrew prefix. By default it runs
> `chmod go-w` on `share` and `share/zsh` (recursively, directories only) when they are group- or
> world-writable, they belong to you and the `zsh-completions` module is on; a directory that belongs
> to someone else is reported with the `sudo chmod go-w` command to run. Without Homebrew nothing happens.
>
> `skip_packages` leaves base packages out of the installation and `skip_stow` leaves stow
> packages unlinked and their generated config unrendered. Skipping only stops bootstrap from
> acting: a package that is already installed or linked stays that way (nothing is uninstalled or
Expand Down Expand Up @@ -264,7 +272,7 @@

---

## 🪪 Git identity

Check warning on line 275 in README.md

View workflow job for this annotation

GitHub Actions / docs-drift

doc-drift

Section "🪪 Git identity" may be outdated: linked code changed but the section did not (changed code: bootstrap.sh).

This repo ships **no** `user.name` / `user.email`. The git config sets
`user.useConfigOnly = true` instead, so git refuses to commit until you set an
Expand All @@ -280,7 +288,7 @@
git config --file ~/.gitconfig.local user.email "12345+you@users.noreply.github.com"
```

### ✍️ Signing commits with SSH (optional)

Check warning on line 291 in README.md

View workflow job for this annotation

GitHub Actions / docs-drift

doc-drift

Section "✍️ Signing commits with SSH (optional)" may be outdated: linked code changed but the section did not (changed code: bootstrap.sh).

`bootstrap.sh` also asks for the path to your **public** SSH key. Give just the
path and the rest of the signing setup is derived from it. Leave it empty to
Expand Down Expand Up @@ -308,7 +316,7 @@

---

## ⚙️ Configuring

Check warning on line 319 in README.md

View workflow job for this annotation

GitHub Actions / docs-drift

doc-drift

Section "⚙️ Configuring" may be outdated: linked code changed but the section did not (changed code: bootstrap.sh, omnishell/config.toml).

Every setting lives in **one** of five places. None of this needs `bootstrap.sh`
re-run (though re-running it is always safe); the "Apply with" column says how
Expand Down Expand Up @@ -372,6 +380,7 @@
| Module | What it does | Notable options |
|-------------------------------------------------------------------|-----------------------------------------------------------------------------|----------------------------------------------|
| `completion`, `history` | zsh/bash plugin baseline | `history.size = 50000` |
| `zsh-completions` | zsh only: extra completion definitions, on `fpath` before `compinit` | - |
| `autosuggestions`, `syntax-highlighting` | zsh only: grey inline suggestions, command colouring as you type | - |
| `fzf` | key bindings + defaults | `ctrl_r`, `ctrl_t`, `default_opts` |
| `zoxide` | smarter `cd` | `cmd = "z"` |
Expand Down Expand Up @@ -411,7 +420,7 @@
shells start outside it. Flip it to `true` to attach to (or create) the
`default` session on every shell start.

### 4. Stow packages: standalone config files

Check warning on line 423 in README.md

View workflow job for this annotation

GitHub Actions / docs-drift

doc-drift

Section "4. Stow packages: standalone config files" may be outdated: linked code changed but the section did not (changed code: bootstrap.sh).

`stow` symlinks these into `$HOME`, so **editing the file in the repo changes the
live config immediately** (you may still need to reload the target app). After
Expand Down Expand Up @@ -453,7 +462,7 @@

---

## 🎨 Colours: Root Loops

Check warning on line 465 in README.md

View workflow job for this annotation

GitHub Actions / docs-drift

doc-drift

Section "🎨 Colours: Root Loops" may be outdated: linked code changed but the section did not (changed code: bootstrap.sh, omnishell/config.toml).

Terminal colours are defined **once**; everything else inherits the 16 ANSI
colours. See [`rootloops`](rootloops):
Expand Down Expand Up @@ -521,7 +530,7 @@
tests/ test-*.sh (make test) + bootstrap-smoke.sh (CI)
```

### Notes

Check warning on line 533 in README.md

View workflow job for this annotation

GitHub Actions / docs-drift

doc-drift

Section "Notes" may be outdated: linked code changed but the section did not (changed code: bootstrap.sh).

- The git config lives at `~/.config/git/config` (not `~/.gitconfig`). The
`delta` paging config is `~/.gitconfig.delta`, which `bootstrap.sh` writes only
Expand Down
57 changes: 55 additions & 2 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ read_conf_values() {
CONF_SKIP_PACKAGES="$(settings_get bootstrap.skip_packages)"
CONF_SKIP_STOW="$(settings_get bootstrap.skip_stow)"
CONF_TERMINAL_APP_PROFILE="$(settings_get bootstrap.terminal_app_profile)"
CONF_FIX_COMPLETION_PERMISSIONS="$(settings_get bootstrap.fix_completion_permissions)"
CONF_ASSUME_YES="$(settings_get bootstrap.assume_yes)"
CONF_TERMINALS="$(settings_get bootstrap.terminals)"
CONF_GHOSTTY_KEYBINDS="$(settings_get ghostty.keybinds)"
Expand Down Expand Up @@ -215,11 +216,13 @@ reload_settings() {
# its vendor/bin on PATH, without which a release binary or source build is not
# found at shell start (no starship prompt, no mise / broot); 0.8.0 installs
# eza as a release binary where the distro has no package (Debian 12), instead
# of degrading modern-aliases. What has no
# of degrading modern-aliases; 0.9.0 adds the zsh-completions module (fpath before
# compinit) and the `omnishell doctor` check for writable completion directories.
# What has no
# binary (broot on 32-bit ARM, mise on armv6, everything on other CPUs) still
# builds from source, which needs Rust 1.95 for mise / starship (broot: 1.85) -
# newer than what Debian / Ubuntu LTS ship as `cargo`.
OMNISHELL_MIN_VERSION="0.8.0"
OMNISHELL_MIN_VERSION="0.9.0"
RUST_MIN_VERSION="1.95"

# What a cargo build of mise needs besides Rust: a C toolchain, cmake (libz-ng-sys),
Expand Down Expand Up @@ -1158,6 +1161,55 @@ warn_skipped_packages_needed_by_modules() {
done
}

# Whether fix_completion_permissions() changes anything, highest precedence first:
# DOTFILES_FIX_COMPLETION_PERMISSIONS (1, true, yes / 0, false, no),
# fix_completion_permissions in the settings file, default on.
_fix_completion_permissions_enabled() {
local mode=""
if [ -n "${DOTFILES_FIX_COMPLETION_PERMISSIONS:-}" ]; then
case "$DOTFILES_FIX_COMPLETION_PERMISSIONS" in
1 | true | yes) mode=yes ;;
0 | false | no) mode=no ;;
*) warn "invalid DOTFILES_FIX_COMPLETION_PERMISSIONS value '$DOTFILES_FIX_COMPLETION_PERMISSIONS' (use 1, true, yes, 0, false or no) - ignored" ;;
esac
fi
if [ -z "$mode" ]; then
case "$CONF_FIX_COMPLETION_PERMISSIONS" in false) mode=no ;; *) mode=yes ;; esac
fi
[ "$mode" = yes ]
}

_dir_is_mine() { [ -O "$1" ]; }

# zsh's compinit refuses to load completions from a directory that group or others
# can write to ("zsh compinit: insecure directories"). Homebrew's share/ and
# share/zsh/ are group-writable on some installs, so drop the group/other write bit
# there - but only when the omnishell zsh-completions module is on and the
# directory is yours; someone else's is reported with the command to run.
fix_completion_permissions() {
command -v brew >/dev/null 2>&1 || return 0
_is_in_list zsh-completions "$(_enabled_omnishell_modules)" || return 0
_fix_completion_permissions_enabled || { log "skipping completion directory permissions (fix_completion_permissions)"; return 0; }
local prefix dir fixed=0
prefix="$(brew --prefix 2>/dev/null)" || return 0
[ -n "$prefix" ] || return 0
while IFS= read -r dir; do
[ -n "$dir" ] || continue
if _dir_is_mine "$dir"; then
if chmod go-w "$dir"; then fixed=$((fixed + 1)); else warn "could not run chmod go-w on $dir"; fi
else
# %q: a directory name is data, so the suggested command must stay one safe line
warn "$dir can be written by group or others but belongs to someone else - run: sudo chmod go-w $(printf '%q' "$dir")"
fi
done < <(
find "$prefix/share" -maxdepth 0 -type d \( -perm -020 -o -perm -002 \) 2>/dev/null || true
find "$prefix/share/zsh" -type d \( -perm -020 -o -perm -002 \) 2>/dev/null || true
)
if [ "$fixed" -gt 0 ]; then
log "removed group/other write permission from $fixed directories under $prefix/share (zsh compinit rejects them)"
fi
}

apply_omnishell() {
prepare_omnishell_config
warn_skipped_packages_needed_by_modules
Expand Down Expand Up @@ -1500,6 +1552,7 @@ main() {
setup_git_identity
setup_git_signing_key
fi
fix_completion_permissions
apply_omnishell
wire_shell_d
log "rendering Root Loops colors"
Expand Down
7 changes: 7 additions & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@
# Environment: DOTFILES_TERMINAL_APP_PROFILE (1/0, true/false, yes/no)
#terminal_app_profile = true
#
# Drop the group/other write bit from Homebrew's share and share/zsh directories when the
# omnishell zsh-completions module is enabled: true or false. zsh's compinit rejects
# completions from writable directories ("insecure directories"). Only directories you
# own are changed; others are reported with the command to run. Only matters with Homebrew.
# Environment: DOTFILES_FIX_COMPLETION_PERMISSIONS (1/0, true/false, yes/no)
#fix_completion_permissions = true
#
# Answer "yes" to every prompt, e.g. switch rc files and stow links from another
# checkout to this one.
# Flag: --yes Environment: DOTFILES_ASSUME_YES (1 or 0)
Expand Down
1 change: 1 addition & 0 deletions lib/settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ bootstrap.install_ghostty bool
bootstrap.skip_packages list
bootstrap.skip_stow list
bootstrap.terminal_app_profile bool
bootstrap.fix_completion_permissions bool
ghostty.keybinds enum:auto,mac,linux
ghostty.font_family string
ghostty.font_size positive
Expand Down
6 changes: 6 additions & 0 deletions omnishell/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ shells = ["zsh", "bash"]
[modules.completion]
enabled = true

# Extra zsh completion definitions, put on fpath before the compinit of the module
# above (zsh only; omnishell >= 0.9.0). bootstrap.sh also drops the group/other write
# bit from Homebrew's share directories, which compinit would otherwise reject.
[modules.zsh-completions]
enabled = true

[modules.history]
enabled = true
[modules.history.options]
Expand Down
Loading
Loading