Files
dotfiles/dot_config/zsh/dot_zshrc
2025-04-28 17:48:35 -03:00

62 lines
2.3 KiB
Plaintext

# shellcheck shell=bash
# shellcheck disable=SC1090,SC1091,SC2034
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# Workaround for SSH/Login sessions
# https://github.com/systemd/systemd/issues/7641#issuecomment-680694017
set -a
if [[ -o login && -f /usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator ]]; then
eval "$(/usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator)"
# Fallback to to manually parsing environment.d
elif [[ -z "$XDG_DATA_HOME" && -z "$XDG_CONFIG_HOME" && -z "$XDG_STATE_HOME" && -z "$XDG_CACHE_HOME" ]]; then
eval "$(<"$HOME/.config/environment.d/xdg.conf")"
fi
set +a
autoload -Uz promptinit
autoload -Uz compinit
compinit -d "$XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION"
promptinit
# Some zsh plugins
[[ -f /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]] && source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
[[ -f /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh ]] && source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
bindkey '^[[H' beginning-of-line
bindkey '^[[F' end-of-line
bindkey "^[[3~" delete-char
# Zsh XDG history
HISTFILE="$XDG_STATE_HOME"/zsh/history
HISTSIZE=10000
SAVEHIST=10000
setopt HIST_EXPIRE_DUPS_FIRST
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt INC_APPEND_HISTORY_TIME
# Helpful tool: https://zsh-prompt-generator.site/
# On github: https://github.com/k-yokoishi/zsh-prompt-generator
PROMPT="[%n@%m %~]$ "
RPROMPT="%?:%h | %*"
[[ -f $XDG_CONFIG_HOME/bash/.bash_aliases ]] && source "$XDG_CONFIG_HOME/bash/.bash_aliases"
# Zsh specific alias
alias rc='source "$XDG_CONFIG_HOME"/zsh/.zshrc'
# https://github.com/pkasemir/find-the-command
[[ -f /usr/share/doc/find-the-command/ftc.zsh ]] && source /usr/share/doc/find-the-command/ftc.zsh noupdate quiet info
# https://wiki.archlinux.org/title/Pkgfile#Command_not_found
# [[ -f /usr/share/doc/pkgfile/command-not-found.zsh ]] && source /usr/share/doc/pkgfile/command-not-found.zsh
# Starship after defining custom prompt, easy to remove
hash starship 2>/dev/null && eval "$(starship init zsh)"
# Zoxide init has to be last
hash zoxide 2>/dev/null && eval "$(zoxide init zsh)"
# Return 0 to indicate success that the script has been sourced to completion
return 0