From 7de43b89a52ae84cfcb2f79eba33662548e9616c Mon Sep 17 00:00:00 2001 From: Yuan Chiu Date: Wed, 7 May 2025 04:30:17 +0800 Subject: [PATCH] =?UTF-8?q?feat=20.gitconfig:=20signingkey=20GPG=E7=B0=BD?= =?UTF-8?q?=E5=90=8D=E7=B6=81=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .chezmoi.toml.tmpl | 2 ++ dot_bashrc.tmpl | 3 +++ dot_gitconfig.tmpl | 11 +++++++++-- dot_zshrc.tmpl | 4 ++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.chezmoi.toml.tmpl b/.chezmoi.toml.tmpl index 212c9d4..f0ab0d6 100644 --- a/.chezmoi.toml.tmpl +++ b/.chezmoi.toml.tmpl @@ -1,5 +1,6 @@ {{- $name := promptStringOnce . "name" "請輸入您的姓名" -}} {{- $email := promptStringOnce . "email" "輸入您的Email地址" -}} +{{- $signingkey := promptStringOnce . "signingkey" "輸入您的GPG金鑰ID (可從 gpg --list-secret-keys --keyid-format=long 去找)" -}} {{- $hosttype_choices := list "desktop" "server" "unroot_server" "manual" -}} {{- $hosttype := promptChoice "What type of host are you on" $hosttype_choices -}} @@ -32,6 +33,7 @@ sourceDir = "~/.local/share/chezmoi" [data] name = {{ $name | quote }} email = {{ $email | quote }} + signingkey = {{ $signingkey | quote }} serverStyle = {{ $isServer }} unRootMode = {{ $unRootMode }} enableSixel = {{ $enableSixel }} {{/* TODO: packages.toml還沒處理 */}} diff --git a/dot_bashrc.tmpl b/dot_bashrc.tmpl index 6904748..8625e44 100644 --- a/dot_bashrc.tmpl +++ b/dot_bashrc.tmpl @@ -220,6 +220,9 @@ function __pb10k_bottom { # ----以下是我的自訂內容 ------------------------------------------------------ export LANG=zh_TW.UTF-8 #macOS要手動指定,不然被ssh連入使用時會變亂碼 +{{ if .signingkey }} +export GPG_TTY=$(tty){{ end }} + # overwrite ls if command -v eza &> /dev/null; then alias ls='eza --color=always --icons=always' diff --git a/dot_gitconfig.tmpl b/dot_gitconfig.tmpl index 7964457..5689dbd 100644 --- a/dot_gitconfig.tmpl +++ b/dot_gitconfig.tmpl @@ -3,9 +3,16 @@ smudge = git-media-smudge %f [user] name = {{ .name | quote }} - email = {{ .email | quote }} + email = {{ .email | quote }}{{ if .signingkey }} + signingkey = {{ .signingkey | quote }}{{ end }} +{{ if .signingkey }} +[commit] + gpgsign = true + +[tag] + gpgSign = true +{{ end }} [core] - editor = vim excludesfile = {{ joinPath .chezmoi.homeDir ".gitignore_global" }} [difftool "sourcetree"] cmd = opendiff \"$LOCAL\" \"$REMOTE\" diff --git a/dot_zshrc.tmpl b/dot_zshrc.tmpl index 3eb3d63..7805d6d 100644 --- a/dot_zshrc.tmpl +++ b/dot_zshrc.tmpl @@ -189,6 +189,10 @@ test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell export PATH="$PATH:$HOME/bin" zinit light mass8326/zsh-chezmoi +{{ if .signingkey }} +export GPG_TTY=$TTY{{ end }} +gpgconf --launch gpg-agent + # 自動補上 noglob 並禁用 Zsh 的 globbing 解析 function git_pushmulti() { # 手動處理方括號或括號內容,並進行推送