.dotfiles/dot_zshrc
tombdf 04fd30ca73
feat!: Alter most of major config files
- Bash: config file
- Zsh: config file
- Fish: config file and fish plugins
- Nvim: config files
- Kitty: config files
2025-01-03 00:39:01 +01:00

219 lines
7.9 KiB
Plaintext

##########################################################################
#
# ███████╗███████╗██╗ ██╗██████╗ ██████╗
# ╚══███╔╝██╔════╝██║ ██║██╔══██╗██╔════╝
# ███╔╝ ███████╗███████║██████╔╝██║
# ███╔╝ ╚════██║██╔══██║██╔══██╗██║
# ███████╗███████║██║ ██║██║ ██║╚██████╗
# ╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝
#
##########################################################################
# Zsh and Zinit configuration ---------------------------------------------------------------- {{{
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$HOME/.local/bin/:$HOME/.cargo/bin/:$HOME/.atuin/bin/:$PATH
# Path to your Zinit installation.
export ZSH="${XDG_DATE_HOME:-${HOME}/.local/share}/zinit/zinit.git"
# Download and install Zinit if it's not already installed
if [ ! -d $ZSH ]; then
git clone https://github.com/zdharma-continuum/zinit.git $ZSH
fi
source $ZSH/zinit.zsh
# General options ---------------------------------------------------------------- {{{
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
HIST_STAMPS="dd.mm.yyyy"
# }}}
# Plugins and snippets ---------------------------------------------------------------- {{{
zinit light zsh-users/zsh-syntax-highlighting
zinit light zsh-users/zsh-autosuggestions
zinit light zsh-users/zsh-completions
zinit ice from'gh-r' as'program'
zinit light sei40kr/fast-alias-tips-bin
zinit light sei40kr/zsh-fast-alias-tips
zinit snippet OMZP::git
zinit snippet OMZP::zoxide
# }}}
# History ---------------------------------------------------------------- {{{
HISTSIZE=5000 # The number of commands to remember in the command history
HISTFILE=~/.zsh_history # The file to save the command history to
SAVEHIST=$HISTSIZE # The number of commands to save in the history file
HISTDUP=erase # Erase duplicates in the history file
setopt appendhistory # Append history to the history file
setopt sharehistory # Share history between all sessions
setopt hist_ignore_space # Ignore commands that start with a space
setopt hist_ignore_dups # Ignore duplicate commands
setopt hist_ignore_all_dups # Ignore all duplicate commands
setopt hist_save_no_dups # Do not save duplicate commands
setopt hist_find_no_dups # Do not display duplicate commands
# }}}
# Completion ---------------------------------------------------------------- {{{
# Zsh allows command completion.
# The completion is very modifiable, here are some options
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
zstyle ':completion:*:warnings' format '%BSorry, no results'
zstyle ':completion:*' menu select=2
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' list-colors '${(s.:.)LS_COLORS}'
# Load bash completion functions
autoload -Uz +X compinit && compinit
autoload -Uz +X bashcompinit && bashcompinit
# Setup custom completions
mkdir -p "$HOME/.completions"
# Check if the command exists and if the completion file does not exist, generate it
generate_completion() {
local cmd=$1
local out_file="$HOME/.completions/$2"
local gen_cmd=$3
if command -v "$cmd" > /dev/null 2>&1 && [ ! -f "$out_file" ]; then
eval "$gen_cmd"
echo "Generated completion for $cmd"
fi
}
generate_completion "atuin" "atuin.zsh" "atuin gen-completions --shell zsh --out-dir \$HOME/.completions/"
generate_completion "chezmoi" "chezmoi.zsh" "chezmoi completion zsh --output=\$HOME/.completions/chezmoi.zsh"
generate_completion "rip" "rip.zsh" "rip completions zsh > \$HOME/.completions/rip.zsh"
# The default name of the completion file for atuin is `_atuin`
# as it follows the convention of zsh_completions files
# Rename it to `atuin.zsh` to be consistent with the other custom completion files
if [ -f "$HOME/.completions/_atuin" ]; then mv "$HOME/.completions/_atuin" "$HOME/.completions/atuin.zsh"; fi
source "$HOME/.completions/atuin.zsh"
source "$HOME/.completions/chezmoi.zsh"
source "$HOME/.completions/rip.zsh"
# -q is for quiet; actually run all the `compdef's saved before `compinit` call
# (`compinit' declares the `compdef' function, so it cannot be used until
# `compinit' is ran; Zinit solves this via intercepting the `compdef'-calls and
# storing them for later use with `zinit cdreplay')
zinit cdreplay -q
# }}}
# }}}
# User configuration ---------------------------------------------------------------- {{{
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# SSH Configuration ---------------------------------------------------------------- {{{
# Preferred editor for local and remote sessions
if [[ ! -n $SSH_CONNECTION ]]; then
export EDITOR='nvim'
else
export EDITOR='vim'
fi
# Set the ssh-agent if it is not already running
if ! pgrep -u "$USER" ssh-agent > /dev/null; then
eval "$(ssh-agent -s)" > /dev/null
fi
# Add the keys to the agent
add_ssh_key() {
local key_path=$1
local key_name=$(basename "$key_path")
if [ -f "$key_path" ] && ! ssh-add -l | grep -q "$key_name"; then
ssh-add "$key_path" > /dev/null 2>&1
fi
}
# Personal SSH keys
add_ssh_key ~/.ssh/id_ed25519
add_ssh_key ~/.ssh/hexasec
# }}}
# Aliases ---------------------------------------------------------------- {{{
# Set personal aliases
# For a full list of active aliases, run `alias`.
alias ls='lsd'
alias ll='ls -alF'
alias rm='rip'
alias cat='bat'
alias grep='rg'
alias find='fd -H'
alias sed='sd'
alias c='clear'
alias prolog='~/.config/scryer-prolog/target/release/scryer-prolog' # À remplacer par prolog='scryer-prolog'
alias csc='sudo cytech-site-change'
alias quit='exit'
alias compresse='echo "tar -cv [nomDuFichieràCompresser] -f [nomArchive].tar"'
alias maj='~/./miseajour.sh'
alias vi=$(which vim)
alias vim='nvim'
# }}}
# }}}
# Shell enhancements initialization ---------------------------------------------------------------- {{{
# Allow zoxide to work and to replace cd
eval "$(zoxide init --cmd cd zsh)"
# Initialize atuin
# eval "$(atuin init zsh --disable-up-arrow)"
# Set the theme to use with Oh My Posh
eval "$(oh-my-posh init zsh --config $HOME/.config/ohmyposh/prompt.json)"
# Or Starship
eval "$(starship init zsh)"
# }}}