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
12 changes: 12 additions & 0 deletions .bashrc.d/envrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

[[ -n $(type -t nano) ]] && export EDITOR="nano"

# Use the user ssh-agent service (.config/systemd/user) when the inherited agent
# is missing or dead: a long-lived process such as herdr keeps a stale
# SSH_AUTH_SOCK. `ssh-add -l` exits 2 when it cannot reach an agent.
_ssh_agent_socket=${XDG_RUNTIME_DIR:-/run/user/$UID}/ssh-agent-user.socket
if [[ -S $_ssh_agent_socket && -n $(type -t ssh-add) ]]; then
_ssh_add_status=0
ssh-add -l &>/dev/null || _ssh_add_status=$?
[[ $_ssh_add_status -eq 2 ]] && export SSH_AUTH_SOCK=$_ssh_agent_socket
unset _ssh_add_status
fi
unset _ssh_agent_socket

# Disable __pycache__ / .pyc artifacts.
export PYTHONDONTWRITEBYTECODE=1

Expand Down
12 changes: 12 additions & 0 deletions .config/systemd/user/ssh-agent-user.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=SSH agent on a fixed socket (dotfiles)

[Service]
Type=simple
ExecStartPre=/bin/rm -f %t/ssh-agent-user.socket
ExecStart=/usr/bin/ssh-agent -D -a %t/ssh-agent-user.socket
ExecStartPost=/usr/bin/systemctl --user set-environment SSH_AUTH_SOCK=%t/ssh-agent-user.socket
Restart=always

[Install]
WantedBy=default.target
5 changes: 4 additions & 1 deletion .ssh/config
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Include ~/.ssh/config.d/*
Include ~/.ssh/config.d/*

Host *
AddKeysToAgent yes
10 changes: 10 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ ______________________________________________________________________
├── .config/herdr/config.toml # herdr settings (default shell bash: herdr can start sh, which prints the bash prompt escapes literally; keys for the worktrunk plugin actions; pane_history on)
├── .config/worktrunk/config.toml # worktrunk user config: worktrees in `<repo>/.worktrees/<branch>`, control_suite `pre-start` hook
├── .config/environment.d/999-pixi.conf # Puts ~/.pixi/bin on the graphical session PATH
├── .config/systemd/user/ssh-agent-user.service # User ssh-agent on `$XDG_RUNTIME_DIR/ssh-agent-user.socket` (not enabled by `--update`, see SSH agent)
├── .ssh/config # ssh client config: includes `config.d/*`, `AddKeysToAgent yes`
├── .config/git/ # Shared git config; work.gitconfig is included for work-org remotes
├── .copilot/settings.json # Copilot CLI user preferences (models, worktree location)
├── .copilot/copilot-instructions.md # Global Copilot CLI custom instructions (language, voice, honesty, plan mode, consent, commits)
Expand Down Expand Up @@ -399,6 +401,14 @@ One machine uses two GitHub accounts, so the identity (commit email and token) i
- `merge.conflictStyle = zdiff3` needs git >= 2.35.
- `~/.gitattributes` is not a global attributes file for git: in HOME it is only this repo's own `.gitattributes`.

## SSH agent

`.config/systemd/user/ssh-agent-user.service` runs one `ssh-agent` per user session on `$XDG_RUNTIME_DIR/ssh-agent-user.socket`, a fixed path that does not depend on the desktop (Ubuntu 22.04 has no `gcr-ssh-agent`, and gnome-keyring may run without its SSH component). Its name differs from the distro's `ssh-agent.service` on purpose: a user unit with the same name would shadow the packaged one. `ssh-agent` cannot take a socket from systemd, so the unit is a plain service started at login, not a socket-activated one.

- `--update` only deploys the files. Enable it once per machine with `systemctl --user enable --now ssh-agent-user.service`. Until then the files are inert: the unit itself exports `SSH_AUTH_SOCK` into the user manager (`ExecStartPost`), so the variable only exists while the agent answers. Do not export it from `environment.d`: the distro launchers (`gnome-keyring-ssh.service`, `agent-launch`) start only when `SSH_AUTH_SOCK` is unset, so a variable pointing at a missing socket would leave the session with no agent.
- `.bashrc.d/envrc` falls back to the socket when the inherited agent does not answer (`ssh-add -l` exits 2), so a long-lived process such as herdr that kept a stale `SSH_AUTH_SOCK` still gets a working agent in new shells. A live forwarded agent is left alone.
- `.ssh/config` sets `AddKeysToAgent yes`, so the first connection asks for the passphrase once.

## Worktrunk

`wt` comes from `TOOLS`. `.config/worktrunk/config.toml` sets a global `worktree-path` of `{{ repo_path }}/.worktrees/{{ branch | sanitize }}`, the same location as `worktreePathTemplate` in `.copilot/settings.json` and covered by the global ignore. Per-repository settings go under `[projects."github.com/<owner>/<repo>"]` in that file, which scopes a hook to one repository and needs no approval, unlike a committed `.config/wt.toml`. Never track `~/.config/worktrunk/approvals.toml`.
Expand Down
Loading