1
0
Files
chezmoi/home/dot_zshrc
2025-11-09 23:55:22 +01:00

200 lines
4.8 KiB
Plaintext

# Start configuration added by Zim install {{{
#
# User configuration sourced by interactive shells
#
# -----------------
# Zsh configuration
# -----------------
#
# History
#
# Remove older command from the history if a duplicate is to be added.
setopt HIST_IGNORE_ALL_DUPS
#
# Input/output
#
# Set editor default keymap to emacs (`-e`) or vi (`-v`)
bindkey -v
# Prompt for spelling correction of commands.
setopt CORRECT
# Customize spelling correction prompt.
SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
# Remove path separator from WORDCHARS.
WORDCHARS=${WORDCHARS//[\/]}
# Zoxide configuration
ZOXIDE_CMD_OVERRIDE=cd
SPACESHIP_PROMPT_ASYNC=false
# --------------------
# Module configuration
# --------------------
zstyle ':zim:module' skip 'prompt'
# Set a custom path for the completion dump file.
# If none is provided, the default ${ZDOTDIR:-${HOME}}/.zcompdump is used.
#zstyle ':zim:completion' dumpfile "${ZDOTDIR:-${HOME}}/.zcompdump-${ZSH_VERSION}"
# Set a custom prefix for the generated aliases. The default prefix is 'G'.
#zstyle ':zim:git' aliases-prefix 'g'
# Append `../` to your input for each `.` you type after an initial `..`
zstyle ':zim:input' double-dot-expand yes
# Set a custom terminal title format using prompt expansion escape sequences.
# See http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Simple-Prompt-Escapes
# If none is provided, the default '%n@%m: %~' is used.
#zstyle ':zim:termtitle' format '%1~'
# Customize the style that the suggestions are shown with.
# See https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md#suggestion-highlight-style
#ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=10'
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
# Customize the main highlighter styles.
# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/main.md#how-to-tweak-it
#typeset -A ZSH_HIGHLIGHT_STYLES
#ZSH_HIGHLIGHT_STYLES[comment]='fg=10'
# ------------------
# Initialize modules
# ------------------
if [[ ${ZIM_HOME}/init.zsh -ot ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
# Update static initialization script if it's outdated, before sourcing it
source ${ZIM_HOME}/zimfw.zsh init -q
fi
source ${ZIM_HOME}/init.zsh
# autoload -Uz compinit && compinit -C
# ------------------------------
# Post-init module configuration
# ------------------------------
#
# zsh-history-substring-search
#
# Bind ^[[A/^[[B manually so up/down works both before and after zle-line-init
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
# Bind up and down keys
zmodload -F zsh/terminfo +p:terminfo
if [[ -n ${terminfo[kcuu1]} && -n ${terminfo[kcud1]} ]]; then
bindkey ${terminfo[kcuu1]} history-substring-search-up
bindkey ${terminfo[kcud1]} history-substring-search-down
fi
bindkey '^P' history-substring-search-up
bindkey '^N' history-substring-search-down
bindkey -M vicmd 'k' history-substring-search-up
bindkey -M vicmd 'j' history-substring-search-down
# Bind ctrl+a and ctrl+e
bindkey '^A' vi-beginning-of-line
bindkey '^E' vi-end-of-line
# }}} End configuration added by Zim install
# #
# # zoxide
# #
# if (( $+commands[zoxide] )); then
# eval "$(zoxide init --cmd ${ZOXIDE_CMD_OVERRIDE:-z} zsh)"
# else
# echo '[zshrc] zoxide not found, please install it from https://github.com/ajeetdsouza/zoxide'
# fi
# #
# # direnv
# #
# [[ -x $(command -v direnv) ]] && eval "$(direnv hook zsh)"
# setopt PROMPT_SUBST
#
# show_virtual_env() {
# if [[ -n "$CONDA_DEFAULT_ENV" && -n "$DIRENV_DIR" ]]; then
# echo "($(basename $CONDA_DEFAULT_ENV))"
# fi
# }
# PS1='$(show_virtual_env)'$PS1
#
# tmux
#
if [ -z "$TMUX" ]; then
# we're not in a tmux session
if [ ! -z "$SSH_TTY" ]; then
# We logged in via SSH
# if ssh auth variable is missing
if [ -z "$SSH_AUTH_SOCK" ]; then
export SSH_AUTH_SOCK="$HOME/.ssh/.auth_socket"
fi
# if socket is available create the new auth session
if [ ! -S "$SSH_AUTH_SOCK" ]; then
`ssh-agent -a $SSH_AUTH_SOCK` > /dev/null 2>&1
echo $SSH_AGENT_PID > $HOME/.ssh/.auth_pid
fi
# if agent isn't defined, recreate it from pid file
if [ -z $SSH_AGENT_PID ]; then
export SSH_AGENT_PID=`cat $HOME/.ssh/.auth_pid`
fi
# Add all default keys to ssh auth
ssh-add 2>/dev/null
# start tmux
tmux attach
fi
fi
# #
# # passwordstore
# #
# if [[ $(curl -s -w "%{http_code}\n" -L "https://git.jefflance.me/" -o /dev/null) = "200" ]]; then
# echo -ne "\npasswordstore: " && pass git pull
# else
# echo -ne "\npasswordstore: serveur hors ligne"
# fi
# tmux attach
# fi
# fi
#
# gpg-agent
#
export GPG_TTY="$(tty)"
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent