mirror of
https://github.com/Xevion/dotfiles.git
synced 2025-12-08 12:06:55 -06:00
SSH startup eval: ssh-agent add key to keychain, use .shell dict for commonrc template
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# Detect chassis type (likely: laptop | desktop | container)
|
||||
# https://www.freedesktop.org/software/systemd/man/latest/hostnamectl.html#chassis%20%5BTYPE%5D
|
||||
{{- $chassisType := "desktop" }}
|
||||
{{- if eq .chezmoi.os "darwin" }}
|
||||
{{- if contains "MacBook" (output "sysctl" "-n" "hw.model") }}
|
||||
@@ -11,6 +13,7 @@
|
||||
{{- $chassisType = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "if ((Get-CimInstance -Class Win32_Battery | Measure-Object).Count -gt 0) { Write-Output 'laptop' } else { Write-Output 'desktop' }") | trim }}
|
||||
{{- end }}
|
||||
|
||||
# Detect number of CPU cores and threads
|
||||
{{- $cpuCores := 1 }}
|
||||
{{- $cpuThreads := 1 }}
|
||||
{{- if eq .chezmoi.os "darwin" }}
|
||||
@@ -24,6 +27,12 @@
|
||||
{{- $cpuThreads = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "(Get-CimInstance -ClassName 'Win32_Processor').NumberOfLogicalProcessors") | trim | atoi }}
|
||||
{{- end -}}
|
||||
|
||||
# Detect if running in WSL
|
||||
{{- $wsl := true -}}
|
||||
{{- if eq .chezmoi.os "linux" -}}
|
||||
{{- $wsl = (.chezmoi.kernel.osrelease | lower | contains "microsoft") -}}
|
||||
{{- end -}}
|
||||
|
||||
[merge]
|
||||
command = "bash"
|
||||
args = [
|
||||
@@ -33,6 +42,7 @@ args = [
|
||||
|
||||
[data]
|
||||
chassis = "{{ $chassisType }}"
|
||||
wsl = {{ $wsl }}
|
||||
|
||||
[data.cpu]
|
||||
cores = {{ $cpuCores }}
|
||||
|
||||
@@ -12,9 +12,9 @@ export OPENAI_API_KEY="{{ (rbw "OpenAI - chatgpt-cli Key").data.password }}"
|
||||
# hishtory
|
||||
export HISHTORY_SERVER="https://hsh.{{ template "keys.tmpl" "privateDomain" }}"
|
||||
export PATH="$PATH:$HOME/.hishtory"
|
||||
{{ if eq . "zsh" -}}
|
||||
{{ if eq .shell "zsh" -}}
|
||||
source $HOME/.hishtory/config.zsh
|
||||
{{ else if eq . "bash" -}}
|
||||
{{ else if eq .shell "bash" -}}
|
||||
source $HOME/.hishtory/config.sh
|
||||
{{- else -}}
|
||||
{{ fail "Unexpected shell." }}
|
||||
@@ -29,7 +29,11 @@ export PATH="$HOME/.local/share/bob/nvim-bin:$PATH" # Bob, the Neovim package m
|
||||
. "$HOME/.cargo/env" # Rustup + Cargo + Cargo-installed tools
|
||||
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" # Brew
|
||||
command -v rbenv &> /dev/null && eval "$(rbenv init -)" # rbenv for Ruby
|
||||
command -v chatgpt &> /dev/null && . <(chatgpt --set-completions {{ . -}}) # chatgpt completions
|
||||
command -v chatgpt &> /dev/null && . <(chatgpt --set-completions {{ .shell -}}) # chatgpt completions
|
||||
{{ if eq .shell "bash" -}}
|
||||
. "$HOME/.asdf/asdf.sh"
|
||||
. "$HOME/.asdf/completions/asdf.bash"
|
||||
{{- end }}
|
||||
|
||||
# pyenv, python version manager
|
||||
export PYENV_ROOT="$HOME/.pyenv"
|
||||
@@ -89,3 +93,8 @@ fi
|
||||
# else
|
||||
# export EDITOR='nvim'
|
||||
# fi
|
||||
|
||||
# If WSL, add SSH key on startup (once per WSL start)
|
||||
{{- if .data.wsl }}
|
||||
eval `keychain --quiet --eval --agents ssh ~/.ssh/id_rsa`
|
||||
{{ end }}
|
||||
@@ -98,5 +98,5 @@ if ! shopt -oq posix; then
|
||||
fi
|
||||
fi
|
||||
|
||||
{{ template "scripts/commonrc.sh.tmpl" "bash" }}
|
||||
{{ template "scripts/commonrc.sh.tmpl" dict "data" . "shell" "bash" }}
|
||||
{{ completion "bash" }}
|
||||
@@ -28,5 +28,5 @@ plugins=(git asdf yarn golang sudo zoxide bun node npm zsh-autosuggestions brew
|
||||
source $ZSH/oh-my-zsh.sh
|
||||
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh # configure with `p10k configure`
|
||||
|
||||
{{ template "scripts/commonrc.sh.tmpl" "zsh" }}
|
||||
{{ template "scripts/commonrc.sh.tmpl" dict "data" . "shell" "zsh" }}
|
||||
{{ completion "zsh" }}
|
||||
Reference in New Issue
Block a user