Add Gentoo support: per-distro sysup, gitconfig, conditional zshenv
- dot_zshrc.tmpl: add Gentoo sysup() with live tracker (emerge + flatpak) - dot_gitconfig.tmpl: per-distro user/email (Gentoo: joshii-h) - dot_zshenv → dot_zshenv.tmpl: source cargo env only if present - kitty.conf: set shell explicitly to /bin/zsh - README.md: add Gentoo prerequisites and install instructions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a1ecd7bd50
commit
b365b26880
6 changed files with 96 additions and 6 deletions
34
README.md
34
README.md
|
|
@ -6,9 +6,9 @@ chezmoi-managed dotfiles for **Fedora** (primary) and **Gentoo**.
|
|||
|
||||
| File | Template | Notes |
|
||||
|---|---|---|
|
||||
| `~/.zshrc` | Yes | `sysup()` only on Fedora |
|
||||
| `~/.zshenv` | No | Cargo env — portable |
|
||||
| `~/.gitconfig` | Yes | delta pager, `[safe]` dirs excluded (machine-specific) |
|
||||
| `~/.zshrc` | Yes | `sysup()` per distro (dnf on Fedora, emerge on Gentoo) |
|
||||
| `~/.zshenv` | Yes | Cargo env — sourced only if `~/.cargo/env` exists |
|
||||
| `~/.gitconfig` | Yes | delta pager, user/email per distro |
|
||||
| `~/.config/git/ignore` | No | Global gitignore |
|
||||
| `~/.config/gh/config.yml` | No | GitHub CLI config |
|
||||
| `~/.config/kitty/kitty.conf` | No | Portable |
|
||||
|
|
@ -25,16 +25,40 @@ chezmoi init --apply joshii-h/dotfiles
|
|||
|
||||
## Prerequisites
|
||||
|
||||
### Common
|
||||
|
||||
- [oh-my-zsh](https://ohmyz.sh/)
|
||||
- [starship](https://starship.rs/)
|
||||
- [zoxide](https://github.com/ajeetdsouza/zoxide)
|
||||
- [FiraCode Nerd Font](https://www.nerdfonts.com/)
|
||||
|
||||
### Fedora
|
||||
|
||||
```bash
|
||||
sudo dnf install zsh zsh-completions starship kitty git-delta zoxide
|
||||
```
|
||||
|
||||
### Gentoo
|
||||
|
||||
```bash
|
||||
# Keyword unmask for zoxide
|
||||
echo 'app-shells/zoxide ~amd64' | sudo tee /etc/portage/package.accept_keywords/zoxide
|
||||
|
||||
sudo emerge app-shells/zsh app-shells/zsh-completions app-shells/starship \
|
||||
x11-terms/kitty dev-util/git-delta app-shells/zoxide
|
||||
```
|
||||
|
||||
Then install chezmoi (not in Portage):
|
||||
|
||||
```bash
|
||||
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b ~/.local/bin
|
||||
```
|
||||
|
||||
## Distro Detection
|
||||
|
||||
chezmoi reads `/etc/os-release` to set a `distro` variable (`fedora` or `gentoo`), used in `.zshrc` template conditionals.
|
||||
chezmoi reads `/etc/os-release` to set a `distro` variable (`fedora` or `gentoo`), used in template conditionals.
|
||||
|
||||
```bash
|
||||
chezmoi data | grep distro
|
||||
# "distro": "fedora"
|
||||
# "distro": "gentoo"
|
||||
```
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ active_tab_foreground #282c34
|
|||
inactive_tab_background #1d1f21
|
||||
inactive_tab_foreground #c5c8c6
|
||||
|
||||
# Shell
|
||||
shell /bin/zsh
|
||||
|
||||
# Window
|
||||
window_padding_width 4
|
||||
confirm_os_window_close 0
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
[user]
|
||||
{{- if eq .distro "gentoo" }}
|
||||
email = joshuahirsig@gmail.com
|
||||
name = joshii-h
|
||||
{{- else }}
|
||||
email = joshua.hirsig@immeditech.ch
|
||||
name = Joshua Hirsig
|
||||
{{- end }}
|
||||
[http]
|
||||
sslVerify = false
|
||||
[core]
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
. "$HOME/.cargo/env"
|
||||
3
dot_zshenv.tmpl
Normal file
3
dot_zshenv.tmpl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{{- if stat (joinPath .chezmoi.homeDir ".cargo/env") }}
|
||||
. "$HOME/.cargo/env"
|
||||
{{- end }}
|
||||
|
|
@ -54,6 +54,62 @@ sysup() {
|
|||
printf "\n\033[1;32m✓ Done in %ds\033[0m\n" "$((SECONDS - start))"
|
||||
}
|
||||
{{- end }}
|
||||
{{- if eq .distro "gentoo" }}
|
||||
|
||||
sysup() {
|
||||
command sudo -v || return 1
|
||||
setopt LOCAL_OPTIONS NO_NOTIFY NO_MONITOR
|
||||
local emlog=$(mktemp) fplog=$(mktemp)
|
||||
local start=$SECONDS
|
||||
command sudo emerge --sync &>"$emlog" && command sudo emerge -uDN @world &>>"$emlog" &
|
||||
local empid=$!
|
||||
setsid flatpak upgrade -y &>"$fplog" &
|
||||
local fppid=$!
|
||||
local spin='⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏' i=0 drawn=0
|
||||
tput civis 2>/dev/null
|
||||
trap 'tput cnorm 2>/dev/null' INT TERM
|
||||
while true; do
|
||||
local em_up=0 fp_up=0
|
||||
kill -0 $empid 2>/dev/null && em_up=1
|
||||
kill -0 $fppid 2>/dev/null && fp_up=1
|
||||
(( !em_up && !fp_up )) && break
|
||||
(( drawn )) && printf "\033[5A"
|
||||
local elapsed=$((SECONDS - start))
|
||||
local maxw=$(( COLUMNS - 16 ))
|
||||
local s=${spin:$((i%${#spin})):1}
|
||||
printf "\033[K\n"
|
||||
printf "\033[K \033[1;33m%s\033[0m \033[1msysup\033[0m \033[2m%dm%02ds\033[0m\n" \
|
||||
"$s" $((elapsed/60)) $((elapsed%60))
|
||||
# emerge
|
||||
local em_last=$(tail -1 "$emlog" 2>/dev/null | sed 's/\x1b\[[0-9;]*m//g' | tr -d '\r')
|
||||
if (( em_up )); then
|
||||
printf "\033[K \033[33m●\033[0m emerge \033[2m%s\033[0m\n" "${${em_last:-(starting...)}:0:$maxw}"
|
||||
else
|
||||
printf "\033[K \033[32m✓\033[0m emerge \033[2mdone\033[0m\n"
|
||||
fi
|
||||
# flatpak
|
||||
local fp_last=$(tail -1 "$fplog" 2>/dev/null | sed 's/\x1b\[[0-9;]*m//g' | tr -d '\r')
|
||||
if (( fp_up )); then
|
||||
printf "\033[K \033[33m●\033[0m flatpak \033[2m%s\033[0m\n" "${${fp_last:-(starting...)}:0:$maxw}"
|
||||
else
|
||||
printf "\033[K \033[32m✓\033[0m flatpak \033[2mdone\033[0m\n"
|
||||
fi
|
||||
printf "\033[K"
|
||||
drawn=1; ((i++)); sleep 0.5
|
||||
done
|
||||
tput cnorm 2>/dev/null
|
||||
trap - INT TERM
|
||||
(( drawn )) && printf "\033[5A"
|
||||
for _ in {1..5}; do printf "\033[K\n"; done
|
||||
printf "\033[5A"
|
||||
wait
|
||||
for label log in emerge "$emlog" flatpak "$fplog"; do
|
||||
printf "\n\033[1;36m--- %s ---\033[0m\n" "$label"; cat "$log"
|
||||
done
|
||||
rm -f "$emlog" "$fplog"
|
||||
printf "\n\033[1;32m✓ Done in %ds\033[0m\n" "$((SECONDS - start))"
|
||||
}
|
||||
{{- end }}
|
||||
|
||||
# Tools (cached init for faster startup)
|
||||
if [[ ! -f ~/.cache/zsh/zoxide.zsh ]] || (( $(date +%s) - $(stat -c %Y ~/.cache/zsh/zoxide.zsh 2>/dev/null || echo 0) > 86400 )); then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue