Files
dotfiles/zsh/.zshrc
T
Fabian Ising 327ce21440 [ZSH] Alias ln to safeln
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 93400d68ab)
2026-10-19 08:38:57 +02:00

93 lines
3.2 KiB
Bash

export PATH="/snap/bin:$HOME/.local/bin:$PATH"
export XDG_CONFIG_HOME="$HOME/.config"
[[ -z $SSH_AUTH_SOCK ]] || export FORWARD_SOCK=$SSH_AUTH_SOCK
[[ -f ~/.zsh/.powerline_config ]] && source ~/.zsh/.powerline_config
if [[ -f ~/.zsh/.shared_config && "$SUDO_USER" != (fabian|ising|fi545621) ]]; then
shared_config=1
else
shared_config=0
fi
# Work around snap's HOME handling for root.
if [[ "$USER" == "root" ]]; then
if [[ ! -e /home/root ]]; then
ln -s /root/ /home/root
elif [[ ! -e /home/root/.config ]]; then
ln -s /root/.config /home/root/.config
fi
fi
[[ -f ~/.zsh/.shared_config ]] && touch ~/.config/nvim/.shared_config
source "${ZDOTDIR:-$HOME}/.zsh/lib/updates.zsh"
if (( ! shared_config )); then
export GIT_AUTHOR_NAME="Fabian Ising"
export GIT_AUTHOR_EMAIL="f.ising@fh-muenster.de"
export GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
fi
# Completions for tools installed under ~/.local (e.g. tools-repo's safe*
# wrappers). Must precede antidote, whose completion plugin runs compinit.
fpath=("$HOME/.local/share/zsh/site-functions" $fpath)
static_file=${ZDOTDIR:-$HOME}/.cache/zsh/.zsh_plugins.zsh
if (( ! shared_config )); then
plugins_txt=${ZDOTDIR:-$HOME}/.zsh/.zsh_plugins.txt
bindkey -v
VI_MODE_SET_CURSOR=true
else
plugins_txt=${ZDOTDIR:-$HOME}/.zsh/.zsh_plugins_shared.txt
static_file=${ZDOTDIR:-$HOME}/.cache/zsh/.zsh_shared_plugins.zsh
fi
source "${ZDOTDIR:-$HOME}/.zsh/lib/antidote.zsh"
export SSH_REAL_SOCK=$SSH_AUTH_SOCK
[[ -z $FORWARD_SOCK ]] || export SSH_AUTH_SOCK=$FORWARD_SOCK
source "${ZDOTDIR:-$HOME}/.zsh/lib/interactive.zsh"
# fzf keys (Ctrl-R/Ctrl-T/Alt-C, **<Tab>); after antidote, whose vi-mode rebinds ^R.
# --zsh needs fzf >= 0.48; older apt builds ship the scripts instead.
if (( $+commands[fzf] && ! shared_config )); then
if _fzf_init=$(fzf --zsh 2>/dev/null); then
eval "$_fzf_init"
else
for _fzf_init in /usr/share/doc/fzf/examples/{key-bindings,completion}.zsh; do
[[ -r $_fzf_init ]] && source $_fzf_init
done
fi
unset _fzf_init
fi
export LIBVIRT_DEFAULT_URI="qemu:///system"
if (( ! shared_config )); then
# Agent shells: </dev/null makes the prompt decline (exit 1) instead of blocking.
if [[ -n ${CLAUDECODE:-} || -n ${CODEX_SHELL:-} ]]; then
_safe_redir=' </dev/null'
fi
(( $+commands[safecp] )) && alias cp="safecp${_safe_redir:-}"
(( $+commands[safemv] )) && alias mv="safemv${_safe_redir:-}"
(( $+commands[safeln] )) && alias ln="safeln${_safe_redir:-}"
(( $+commands[safescp] )) && alias scp="safescp${_safe_redir:-}"
unset _safe_redir
fi
[[ -f ~/.zsh/.mac_config ]] && source ~/.zsh/.mac_config
if zmodload zsh/terminfo && (( terminfo[colors] >= 256 )) && (( ! shared_config )); then
p10k_config=~/dotfiles/zsh/.p10k.zsh
else
p10k_config=~/dotfiles/zsh/.p10k_shared.zsh
fi
source "${ZDOTDIR:-$HOME}/.zsh/lib/prompt.zsh"
[[ -f ~/.zsh/.user_config ]] && source ~/.zsh/.user_config
[[ -f ~/.zsh/.virtual_env_config.zsh ]] && source ~/.zsh/.virtual_env_config.zsh
[[ -f ~/.zsh/.local_config ]] && source ~/.zsh/.local_config
[[ -f ~/.zsh/.os_config.zsh ]] && source ~/.zsh/.os_config.zsh
typeset -U path PATH