diff --git a/README.md b/README.md new file mode 100644 index 0000000..adab1e7 --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Dotfiles + +Managed via Home Manager (`home.nix`). Applied using `./apply.sh`. + +## Packages + +**Shell & Core** +- `nushell` - Primary shell +- `zellij` - Terminal multiplexer (unlock-first mode) +- `starship` - Prompt +- `atuin` - History sync (local-only) +- `zoxide` - Directory jumper +- `carapace` - Multi-shell completions +- `television` - Fuzzy finder + +**CLI Utilities** +- `neovim` - Editor +- `git`, `lazygit` - Version control +- `ripgrep` (`rg`), `fd` - Fast search +- `pay-respects` - Command correction (`f`) +- `sops`, `age` - Secret management +- `curl`, `wget`, `unp`, `fastfetch` + +**Runtimes & Tooling** +- `mise` - Project tool/runtime manager +- `rustup`, `cargo-binstall` - Rust toolchain +- `python3`, `pipx`, `uv` - Python toolchain +- `nodejs`, `bun` - JS toolchain + +## Keymaps + +**Nushell** +- `Ctrl-T` : Fuzzy find / open via Television +- `Ctrl-R` : Search shell history via Atuin +- `f` : Auto-correct previous command (Pay Respects) +- `cd` : Overridden to resolve real paths first, then falls back to `zoxide` (also aliased to `z`) +- `lg` : Launch Lazygit + +**Zellij** (Defaults to locked mode) +- `Ctrl-Shift-F` : Keybind cheat sheet (zellij-forgot) +- `Ctrl-Shift-S` : Session manager (switch/create) +- `Ctrl-Shift-P` : Project launcher via Zoxide (zsm) +- `Alt-T` : Toggle scratchpad floating pane diff --git a/apply.sh b/apply.sh new file mode 100755 index 0000000..2569879 --- /dev/null +++ b/apply.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -e + +echo "=> Ensuring local config stubs exist..." +touch ~/.local_env.nu ~/.local.nu + +echo "=> Running smoke test on Nushell config..." +nu -c "source ~/.dotfiles/config/nushell/env.nu; source ~/.dotfiles/config/nushell/config.nu" || { + echo "Smoke test failed! Fix Nushell config errors before applying." + exit 1 +} + +echo "=> Smoke test passed. Applying home-manager configuration..." +home-manager switch --flake . -b backup +echo "=> Done." diff --git a/config/ghostty/config b/config/ghostty/config index 16170a8..b9e0f35 100644 --- a/config/ghostty/config +++ b/config/ghostty/config @@ -7,3 +7,6 @@ background-blur = true auto-update = check shell-integration = nushell shell-integration-features = ssh-env,ssh-terminfo + +[profile recovery] +command = nu --no-config-file diff --git a/config/nushell/autoload/secrets.nu b/config/nushell/autoload/secrets.nu new file mode 100644 index 0000000..bcd3ef2 --- /dev/null +++ b/config/nushell/autoload/secrets.nu @@ -0,0 +1,9 @@ +# Pattern for on-demand secrets +def with-secret [secret_name: string, block: closure] { + # Example: let val = (sops -d $"~/.secrets/($secret_name)") + # For now, placeholder: + let val = "REDACTED" + with-env { SECRET_VAL: $val } { + do $block + } +} diff --git a/config/nushell/config.nu b/config/nushell/config.nu index 6321d62..53fd42b 100644 --- a/config/nushell/config.nu +++ b/config/nushell/config.nu @@ -108,18 +108,19 @@ source $"($nu.cache-dir)/atuin.nu" # Scripts # ------- -overlay use ~/.config/nushell/scripts/git/mod.nu -overlay use ~/.config/nushell/scripts/alias-finder.nu +source autoload/secrets.nu +overlay use scripts/git/mod.nu +overlay use scripts/alias-finder.nu -source ~/.config/nushell/scripts/commands.nu +source scripts/commands.nu -#source ~/.config/nushell/vendor/autoload/wt.nu +#source vendor/autoload/wt.nu #----------------- # Completion files #----------------- -source ~/.config/nushell/completions/pm.nu +source completions/pm.nu #---------------- # Custom Banner @@ -175,3 +176,43 @@ def banner [] { print "" } banner + +#---------------- +# Custom Commands +#---------------- + +def reload-shell [] { exec nu } + +alias f = pay-respects +alias cd = z + +#---------------- +# Keybindings +#---------------- + +$env.config.keybindings = ( + $env.config.keybindings? | default [] | append [ + { + name: television + modifier: control + keycode: char_t + mode: [emacs, vi_insert, vi_normal] + event: { + send: executehostcommand + cmd: "commandline edit --insert (tv | str trim)" + } + } + ] +) + +# Load machine-local config if it exists +source "~/.local.nu" + +# Shadow warning for critical commands +let crit_cmds = ["git" "nu"] +for cmd in $crit_cmds { + let p = (which $cmd | get path | get 0? | default "") + if ($p | str contains ".local/share/mise/installs") { + print $"[Warning] Critical command '($cmd)' is shadowed by mise: ($p)" + } +} diff --git a/config/nushell/env.nu b/config/nushell/env.nu index aa54246..f7d9c0f 100644 --- a/config/nushell/env.nu +++ b/config/nushell/env.nu @@ -97,3 +97,9 @@ if $mise_bin != null { add-hook hooks.pre_prompt $mise_hook add-hook hooks.env_change.PWD $mise_hook } + +# Deduplicate PATH at the end +$env.PATH = ($env.PATH | uniq) + +# Load machine-local env if it exists +source "~/.local_env.nu" diff --git a/config/nushell/ssh-agent.nu b/config/nushell/ssh-agent.nu deleted file mode 100644 index 4cfd997..0000000 --- a/config/nushell/ssh-agent.nu +++ /dev/null @@ -1,8 +0,0 @@ -keychain --eval --quiet ...(ls ~/.ssh | where name !~ '.pub$' and name !~ 'known_hosts' and name !~ 'config' and name !~ 'sockets' | get name) - | lines - | where not ($it | is-empty) - | parse "{k}={v}; export {k2};" - | select k v - | transpose --header-row - | into record - | load-env diff --git a/config/zellij/config.kdl b/config/zellij/config.kdl index 6b93ea6..6880b0d 100644 --- a/config/zellij/config.kdl +++ b/config/zellij/config.kdl @@ -3,6 +3,8 @@ theme "catppuccin-mocha" theme_dark "catppuccin-mocha" theme_light "catppuccin-latte" +default_mode "locked" + // === KEYBINDINGS === keybinds { shared_except "locked" { diff --git a/home.nix b/home.nix index 4ad5ea0..d4c5a77 100644 --- a/home.nix +++ b/home.nix @@ -28,6 +28,11 @@ uv rustup cargo-binstall + mise + television + pay-respects + sops + age ]; home.file = {