Fix gpg-agent startup via keychain
This commit is contained in:
@@ -1,28 +1,16 @@
|
|||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
# This script sets up ssh-agent and gpg-agent differently for WSL and Linux Mint.
|
# This script sets up ssh-agent and gpg-agent differently for WSL and non-WSL.
|
||||||
# On WSL, it uses keychain to start agents.
|
|
||||||
# On Linux Mint (or other Linux), it assumes gnome-keyring manages agents automatically.
|
|
||||||
|
|
||||||
# Detect if running inside WSL by checking /proc/version for "Microsoft"
|
|
||||||
if grep -qi microsoft /proc/version; then
|
|
||||||
IS_WSL=true
|
|
||||||
else
|
|
||||||
IS_WSL=false
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$IS_WSL" = true ]; then
|
|
||||||
# We are in WSL - start keychain for ssh and gpg agents
|
|
||||||
# Adjust these variables to your actual SSH and GPG key names
|
|
||||||
SSH_KEY="$HOME/.ssh/id_rsa_deadalus"
|
|
||||||
#GPG_KEY=9DDD59AD62494FB2
|
|
||||||
|
|
||||||
|
start_keychain() {
|
||||||
|
local ssh_key="$1"
|
||||||
|
local gpg_key="$2"
|
||||||
# Check if keychain is installed
|
# Check if keychain is installed
|
||||||
if command -v keychain >/dev/null 2>&1; then
|
if command -v keychain >/dev/null 2>&1; then
|
||||||
SHORT_HOST=${SHORT_HOST:-${(%):-%m}}
|
SHORT_HOST=${SHORT_HOST:-${(%):-%m}}
|
||||||
|
|
||||||
# Start keychain quietly with no GUI prompts for ssh agents
|
# Start keychain quietly with no GUI prompts for ssh agents
|
||||||
eval "$(keychain --quiet --nogui --agents ssh $SSH_KEY)"
|
eval "$(keychain --quiet --nogui $ssh_key $gpg_key)"
|
||||||
|
|
||||||
# Get the filenames to store/lookup the environment from
|
# Get the filenames to store/lookup the environment from
|
||||||
_keychain_env_sh="$HOME/.keychain/$SHORT_HOST-sh"
|
_keychain_env_sh="$HOME/.keychain/$SHORT_HOST-sh"
|
||||||
@@ -34,8 +22,18 @@ if [ "$IS_WSL" = true ]; then
|
|||||||
else
|
else
|
||||||
echo "Warning: keychain is not installed. Please install keychain to manage ssh/gpg agents."
|
echo "Warning: keychain is not installed. Please install keychain to manage ssh/gpg agents."
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Detect if running inside WSL by checking /proc/version for "Microsoft"
|
||||||
|
if grep -qi microsoft /proc/version; then
|
||||||
|
IS_WSL=true
|
||||||
else
|
else
|
||||||
# Not WSL - assume gnome-keyring handles ssh-agent and gpg-agent
|
IS_WSL=false
|
||||||
# Do nothing here to avoid conflicts with gnome-keyring
|
fi
|
||||||
|
|
||||||
|
if [ "$IS_WSL" = true ]; then
|
||||||
|
start_keychain "$HOME/.ssh/id_rsa_deadalus" "9DDD59AD62494FB2"
|
||||||
|
else
|
||||||
|
start_keychain "$HOME/.ssh/id_ed25519_nymph" "9DDD59AD62494FB2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ plugins=(
|
|||||||
command-not-found
|
command-not-found
|
||||||
fzf
|
fzf
|
||||||
gitignore
|
gitignore
|
||||||
keychain
|
|
||||||
mise
|
mise
|
||||||
zoxide
|
zoxide
|
||||||
zsh-autosuggestions
|
zsh-autosuggestions
|
||||||
@@ -127,3 +126,4 @@ export FZF_HOME=$HOME/.oh-my-zsh/custom/plugins/fzf
|
|||||||
source <(fzf --zsh)
|
source <(fzf --zsh)
|
||||||
source "$FZF_HOME/shell/key-bindings.zsh"
|
source "$FZF_HOME/shell/key-bindings.zsh"
|
||||||
source "$FZF_HOME/shell/completion.zsh"
|
source "$FZF_HOME/shell/completion.zsh"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user