87 lines
2.2 KiB
Bash
87 lines
2.2 KiB
Bash
# Venomade's zshrc
|
|
|
|
# source global variables and aliases
|
|
[ -f "$HOME/.config/shell/alias" ] && source "$HOME/.config/shell/alias"
|
|
[ -f "$HOME/.config/shell/vars" ] && source "$HOME/.config/shell/vars"
|
|
|
|
# load modules
|
|
zmodload zsh/complist
|
|
autoload -U compinit && compinit
|
|
autoload -U colors && colors
|
|
|
|
# completion
|
|
zstyle ':completion:*' menu select
|
|
zstyle ':completion:*' special-dirs true
|
|
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} ma=0\;33
|
|
|
|
# options
|
|
setopt append_history inc_append_history share_history
|
|
setopt auto_menu menu_complete
|
|
setopt auto_param_slash
|
|
setopt no_case_glob no_case_match
|
|
setopt globdots
|
|
setopt extended_glob
|
|
|
|
# history
|
|
HISTCONTROL=ignoreboth
|
|
|
|
|
|
# prompt
|
|
USER_COLOR="%F{magenta}"
|
|
VENV_COLOR="%F{yellow}"
|
|
DIR_COLOR="%F{green}"
|
|
GIT_COLOR="%F{blue}"
|
|
GIT_DIRTY_COLOR="%F{red}"
|
|
PROMPT_SYMBOL_COLOR="%F{yellow}"
|
|
RESET_COLOR="%f"
|
|
|
|
shorten_path() {
|
|
local path="${PWD/#$HOME/~}"
|
|
local parts=("${(@s:/:)path}")
|
|
|
|
if (( ${#parts} > 3 )); then
|
|
echo "${parts[1]}/.../${parts[-2]}/${parts[-1]}"
|
|
else
|
|
echo "$path"
|
|
fi
|
|
}
|
|
|
|
git_branch() {
|
|
local branch
|
|
branch=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
|
|
[[ -n "$branch" ]] && echo "$branch"
|
|
}
|
|
|
|
git_dirty() {
|
|
[[ -n "$(git status --porcelain 2>/dev/null)" ]] && echo "✗" || echo "✓"
|
|
}
|
|
|
|
set_prompt() {
|
|
local user="${USER_COLOR}%n${RESET_COLOR}"
|
|
local venv=""
|
|
[[ -n "$VIRTUAL_ENV" ]] && venv="${VENV_COLOR}($(basename $VIRTUAL_ENV))${RESET_COLOR} "
|
|
|
|
local path="${DIR_COLOR}$(shorten_path)${RESET_COLOR}"
|
|
local git_info=""
|
|
local branch="$(git_branch)"
|
|
|
|
if [[ -n "$branch" ]]; then
|
|
git_info=" %F{white}on%f ${GIT_COLOR}${branch}${RESET_COLOR}${GIT_DIRTY_COLOR}$(git_dirty)${RESET_COLOR}"
|
|
fi
|
|
|
|
PROMPT="${user} %F{white}in%f ${venv}${path}${git_info}
|
|
${PROMPT_SYMBOL_COLOR}λ${RESET_COLOR} "
|
|
}
|
|
|
|
autoload -Uz add-zsh-hook
|
|
add-zsh-hook precmd set_prompt
|
|
|
|
# plugins
|
|
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
|
|
|
# GHCUP for Haskell
|
|
[ -f "/home/venomade/.ghcup/env" ] && . "/home/venomade/.ghcup/env" # ghcup-env
|
|
|
|
# OPAM for OCaml
|
|
[[ ! -r '/home/venomade/.opam/opam-init/init.zsh' ]] || source '/home/venomade/.opam/opam-init/init.zsh' > /dev/null 2> /dev/null
|