I just installed arch, and I am trying to configure my shell,
zsh
.
I am currently using zinit
as my plugin manager with powerlevel10k
.
I was trying to automate the activation of the ssh-agent
and the addition of keys to it.
This is my current .zshrc
file:
neofetch
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.config/zsh/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Set the directory to store zinit and plugins
# --- Defined in the .zshenv file
# Download Zinit if it's not there yet
if [ ! -d "$ZINIT_HOME" ]; then
mkdir -p -- $ZINIT_HOME:h
git clone https://github.com/zdharma-continuum/zinit "$ZINIT_HOME"
fi
# Source/Load zinit
source "${ZINIT_HOME}/zinit.zsh"
# Add in Powerlevel10k
zinit ice depth=1; zinit light romkatv/powerlevel10k
# Add in zsh plugins
zinit light zsh-users/zsh-syntax-highlighting
zinit light zsh-users/zsh-completions
zinit light zsh-users/zsh-autosuggestions
zinit light Aloxaf/fzf-tab
# Add in snippet
zinit snippet OMZP::git
zinit snippet OMZP::sudo
zinit snippet OMZP::archlinux
zinit snippet OMZP::command-not-found
zinit snippet OMZP::ssh-agent
# Load completions
autoload -U compinit && compinit
# Replay all cached completions ( recommended by documentation )
zinit cdreplay -q
# To customize prompt, run p10k configure
or edit ~/.config/zsh/.p10k.zsh.
[[ ! -f ~/.config/zsh/.p10k.zsh ]] || source ~/.config/zsh/.p10k.zsh
# Keybind - emacs style, enables ^f ^b ^a ^e ...
bindkey -e
bindkey '^p' history-search-backward
bindkey '^n' history-search-forward
# History
# -- some changes already in .zshenv file
setopt appendhistory # append to history file instead of overwritting
setopt sharehistory # share command history between sessions
setopt hist_ignore_space # ignore commands starting with space
setopt hist_ignore_dups
setopt hist_ignore_all_dups
setopt hist_save_no_dups
setopt hist_find_no_dups # Don't show duplicates in history search
# Completion styling
zstyle ':completion:*' matcher-list 'm:{a-zj}={A-Za-z}'
# Set the default colors to LS_COLORS
eval "$(dircolors -b)"
zstyle ':completion:*' list-colors $LS_COLORS
zstyle ':completion:*' menu no
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls --color $realpath'
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'ls --color $realpath'
# ssh-agent configurations
zstyle :omz:plugins:ssh-agent quiet yes
zstyle :omz:plugins:ssh-agent lazy yes
zstyle :omz:plugins:ssh-agent agent-forwarding yes
zstyle :omz:plugins:ssh-agent identities ~/.ssh/github_rsa
# Aliases
alias ls='ls --color'
alias c='clear'
alias b='cd ..'
# Shell integrations
eval "$(fzf --zsh)" # Fuzzy finding
eval "$(zoxide init --cmd cd zsh)"
As you can see, for ssh-keys I am using:
zinit snippet OMZP::ssh-agent
and the following settings:
zstyle :omz:plugins:ssh-agent quiet yes
zstyle :omz:plugins:ssh-agent lazy yes
zstyle :omz:plugins:ssh-agent agent-forwarding yes
zstyle :omz:plugins:ssh-agent identities ~/.ssh/github_rsa
~/.ssh/github_rsa
is the location of a valid key and has no password associated with it.
My ~/.ssh/config
file is super simple. It only contains the line AddKeysToAgent yes
.
----
Initially the problem I was facing was that no key was added to the agent.
Now, after some testing I found that the key only gets added to the agent if it has the default name id_ed25519
, otherwise nothing happens ( at least with the values I tested for ) .
I couldn't test the loading of more than one key since they need to have different names, which means, different from the default which by my tests, doesn't work.
As suggested, I tried removing the setting zstyle :omz:plugins:ssh-agent lazy yes
even if not recommended when using powerlevel10k
. Weirdly enough, if the key has the default name it gets loaded anyways
Asked by Educpf
(53 rep)
Oct 7, 2024, 09:24 PM
Last activity: Oct 10, 2024, 09:31 PM
Last activity: Oct 10, 2024, 09:31 PM