initial dotfiles

This commit is contained in:
Mats Ricardo Nomedal 2026-04-23 23:48:01 +02:00
commit a11473e308
20 changed files with 2831 additions and 0 deletions

1720
zsh/.p10k.zsh Normal file

File diff suppressed because it is too large Load diff

130
zsh/.zshrc Normal file
View file

@ -0,0 +1,130 @@
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# =========================
# Zsh base / Oh My Zsh
# =========================
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME_NEWLINE_BEFORE_PROMPT=false
ZSH_THEME="bira-nerd"
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
zsh-completions
)
source $ZSH/oh-my-zsh.sh
# =========================
# General environment
# =========================
export EDITOR="nvim"
export VISUAL="nvim"
# Better history
HISTSIZE=50000
SAVEHIST=50000
HISTFILE="$HOME/.zsh_history"
setopt SHARE_HISTORY
setopt INC_APPEND_HISTORY
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_FIND_NO_DUPS
setopt HIST_REDUCE_BLANKS
# =========================
# Completion tuning
# =========================
autoload -Uz compinit
# Speed up compinit by caching, but rebuild if needed
if [[ -n $ZDOTDIR && -f $ZDOTDIR/.zcompdump || -f ~/.zcompdump ]]; then
compinit
else
compinit -C
fi
zstyle ':completion:*' menu select
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' 'r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' group-name ''
zstyle ':completion:*:descriptions' format '%F{yellow}-- %d --%f'
# =========================
# Prompt / colors / quality of life
# =========================
# Use modern ls colors
export LS_COLORS="$LS_COLORS:di=1;34:ln=36:so=35:pi=33:ex=1;32:bd=34;46:cd=34;43:su=37;41:sg=30;43:tw=30;42:ow=34;42"
# Aliases
alias ls='eza --icons --group-directories-first'
alias ll='eza -lh --icons --group-directories-first --git'
alias la='eza -lha --icons --group-directories-first --git'
alias tree='eza --tree --icons'
alias ..='cd ..'
alias ...='cd ../..'
alias grep='grep --color=auto'
alias c='clear'
alias please='sudo $(fc -ln -1)'
# Pacman helpers (EndeavourOS / Arch)
alias pacs='sudo pacman -S'
alias pacr='sudo pacman -Rns'
alias pacu='sudo pacman -Syu'
alias yayu='yay -Syu --noconfirm'
# Git shortcuts
alias gs='git status -sb'
alias gl='git log --oneline --graph --decorate'
alias gc='git commit'
alias gco='git checkout'
alias gp='git push'
alias gpl='git pull'
# =========================
# Keybindings / history search
# =========================
bindkey -e # emacs-style
# Up/down search by history based on current input
autoload -Uz up-line-or-history down-line-or-history
zle -N up-line-or-history
zle -N down-line-or-history
bindkey '^[[A' up-line-or-history
bindkey '^[[B' down-line-or-history
# =========================
# Autosuggestions & highlighting tweaks
# =========================
# Make autosuggestions subtle
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'
# Ensure syntax highlighting is loaded last (safety net)
if [ -f "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]; then
source "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
fi
# =========================
# Path fixes (non-invasive)
# =========================
# Add user-local bin dirs if they exist
[[ -d "$HOME/.local/bin" ]] && path=("$HOME/.local/bin" $path)
[[ -d "$HOME/bin" ]] && path=("$HOME/bin" $path)
export PATH
source ~/.powerlevel10k/powerlevel10k.zsh-theme
[[ -f ~/.p10k.zsh ]] && source ~/.p10k.zsh
# opencode
export PATH=/home/user/.opencode/bin:$PATH

View file

@ -0,0 +1,38 @@
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
local user_host="%B%(!.%{$fg[red]%}.%{$fg[green]%})%n@%m%{$reset_color%} "
local user_symbol='%(!.#.$)'
local current_dir="%B%{$fg[blue]%}%~ %{$reset_color%}"
local conda_prompt='$(conda_prompt_info)'
local vcs_branch='$(git_prompt_info)$(hg_prompt_info)'
local rvm_ruby='$(ruby_prompt_info)'
local venv_prompt='$(virtualenv_prompt_info)'
if [[ "${plugins[@]}" =~ 'kube-ps1' ]]; then
local kube_prompt='$(kube_ps1)'
else
local kube_prompt=''
fi
ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
PROMPT="╭─${conda_prompt}${user_host}${current_dir}${rvm_ruby}${vcs_branch}${venv_prompt}${kube_prompt}
╰─%B${user_symbol}%b "
RPROMPT="%B${return_code}%b"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX=" %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}●%{$fg[yellow]%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[yellow]%}"
ZSH_THEME_HG_PROMPT_PREFIX="$ZSH_THEME_GIT_PROMPT_PREFIX"
ZSH_THEME_HG_PROMPT_SUFFIX="$ZSH_THEME_GIT_PROMPT_SUFFIX"
ZSH_THEME_HG_PROMPT_DIRTY="$ZSH_THEME_GIT_PROMPT_DIRTY"
ZSH_THEME_HG_PROMPT_CLEAN="$ZSH_THEME_GIT_PROMPT_CLEAN"
ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}"
ZSH_THEME_RUBY_PROMPT_SUFFIX=" %{$reset_color%}"
ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX="%{$fg[green]%}"
ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX=" %{$reset_color%}"
ZSH_THEME_VIRTUALENV_PREFIX="$ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX"
ZSH_THEME_VIRTUALENV_SUFFIX="$ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX"

View file

@ -0,0 +1,87 @@
# =======================================================
# bira-nerd.zsh-theme — custom prompt for JetBrainsMono Nerd Font
# =======================================================
# --- Git / VCS styling ---
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%} %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%} %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%} %{$reset_color%}"
ZSH_THEME_HG_PROMPT_PREFIX="$ZSH_THEME_GIT_PROMPT_PREFIX"
ZSH_THEME_HG_PROMPT_SUFFIX="$ZSH_THEME_GIT_PROMPT_SUFFIX"
ZSH_THEME_HG_PROMPT_DIRTY="$ZSH_THEME_GIT_PROMPT_DIRTY"
ZSH_THEME_HG_PROMPT_CLEAN="$ZSH_THEME_GIT_PROMPT_CLEAN"
# --- Timer hooks ---
preexec() {
CMD_START=$EPOCHREALTIME
}
precmd() {
# ---------------- LEFT SIDE ----------------
local user_host="%B%(!.%{$fg[red]%}.%{$fg[green]%}) %n@%m%{$reset_color%} "
local current_dir="%B%{$fg[blue]%} %~%{$reset_color%}"
local vcs_branch='$(git_prompt_info)$(hg_prompt_info)'
local left="╭─${user_host}${current_dir}${vcs_branch}"
# ---------------- RIGHT SIDE ----------------
# Python venv name
local venv_right=""
if [[ -n "$VIRTUAL_ENV" ]]; then
venv_right="%F{magenta}(${VIRTUAL_ENV:t})%f "
fi
# Time
local time_str="%F{242}%D{%H:%M:%S}%f"
# Duration (time taken for last command)
local dur_str=""
if [[ -n "$CMD_START" ]]; then
local diff=$(( EPOCHREALTIME - CMD_START ))
local secs=${diff%.*}
local ms=${diff#*.}
if (( secs > 0 )); then
dur_str="%F{33}${secs}s%f"
else
dur_str="%F{33}${ms:0:2}ms%f"
fi
else
dur_str="%F{33}0ms%f"
fi
# Exit code (only visible if non-zero)
local rc_str="%(?..%F{red}%?↵%f)"
local right="${venv_right}${time_str} ${dur_str} ${rc_str}"
# --- Manual right alignment on FIRST line ---
local plain_left=${left//\%\{*%\}/}
local plain_right=${right//\%\{*%\}/}
local pad=$(( COLUMNS - ${#plain_left} - ${#plain_right} ))
(( pad < 1 )) && pad=1
local spaces="${(l:${pad}:: :)}"
# Two-line layout:
# Line 1 = left + right
# Line 2 = command symbol
PROMPT="${left}${spaces}${right}\n
╰─>%B%(!.#.$)%b "
RPROMPT="FITTE"
CMD_START=""
}
__RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
if [[ -z $RPROMPT ]]; then
RPROMPT=$__RPROMPT
else
RPROMPT="${RPROMPT} ${__RPROMPT}"
fi
# --- Optional stylistic bits ---
ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}"
ZSH_THEME_RUBY_PROMPT_SUFFIX=" %{$reset_color%}"
ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX="%{$fg[green]%}"
ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX=" %{$reset_color%}"

View file

@ -0,0 +1,131 @@
# bira-nerd: Clean Bira-style 2-line prompt with Nerd icons
# Line 1 (left): user@host, cwd, git, pyenv, venv
# Line 1 (right): (venv) time duration exit code
# Line 2: ╰─$ (root gets #)
# No extra blank lines. No column-width hacks.
setopt prompt_subst
########################################
# Helpers
########################################
# Git: branch + dirty/clean
_bira_nerd_git() {
command git rev-parse --is-inside-work-tree &>/dev/null || return
local branch dirty
branch=$(
command git symbolic-ref --quiet --short HEAD 2>/dev/null ||
command git rev-parse --short HEAD 2>/dev/null
) || return
if ! command git diff --quiet --ignore-submodules --cached 2>/dev/null ||
! command git diff --quiet --ignore-submodules 2>/dev/null; then
dirty="%F{red}%f"
else
dirty="%F{green}%f"
fi
echo "%F{yellow}%f ${branch} ${dirty}"
}
# pyenv: show active version if not "system"
_bira_nerd_pyenv() {
command -v pyenv &>/dev/null || return
local v
v=$(pyenv version-name 2>/dev/null) || return
[[ -n "$v" && "$v" != "system" ]] || return
echo " ${v}"
}
########################################
# Timing
########################################
preexec() {
BIRA_NERD_START=$EPOCHREALTIME
}
########################################
# precmd: build first line (no printing)
########################################
precmd() {
local left git_info pyenv_info vp
# Start with top-left glyph
left="╭─"
# conda (if available)
if (( $+functions[conda_prompt_info] )); then
left+="$(conda_prompt_info)"
fi
# user@host with icon (includes trailing space)
local user_host="%B%(!.%F{red}.%F{green}) %n@%m%f%b "
# cwd with folder icon (no trailing space)
local current_dir="%B%F{blue} %~%f%b"
left+="${user_host}${current_dir}"
# git info
git_info="$(_bira_nerd_git)"
[[ -n "$git_info" ]] && left+=" ${git_info}"
# pyenv info
pyenv_info="$(_bira_nerd_pyenv)"
[[ -n "$pyenv_info" ]] && left+=" %F{magenta}${pyenv_info}%f"
# left-side venv (oh-my-zsh virtualenv plugin, if present)
if (( $+functions[virtualenv_prompt_info] )); then
vp="$(virtualenv_prompt_info)"
[[ -n "$vp" ]] && left+=" ${vp}"
fi
# ---------- RIGHT SIDE SEGMENTS ----------
local -a right_parts
# (venv) from raw $VIRTUAL_ENV on the right
if [[ -n "$VIRTUAL_ENV" ]]; then
right_parts+=( "%F{magenta}(${VIRTUAL_ENV:t})%f" )
fi
# time
right_parts+=( "%F{242}%D{%H:%M:%S}%f" )
# duration of last command
if [[ -n "$BIRA_NERD_START" ]]; then
local diff secs ms
diff=$(( EPOCHREALTIME - BIRA_NERD_START ))
secs=${diff%.*}
ms=${diff#*.}
if (( secs > 0 )); then
right_parts+=( "%F{33}${secs}s%f" )
else
right_parts+=( "%F{33}${ms:0:2}ms%f" )
fi
fi
# exit code (only when non-zero)
right_parts+=( "%(?..%F{red}%?↵%f)" )
# Join right segments with single spaces
local right="${(j: :)right_parts}"
# Final first line: left + ONE space + right
BIRA_NERD_LINE1="${left} ${right}"
# reset timer
BIRA_NERD_START=""
}
########################################
# Two-line prompt
########################################
PROMPT='${BIRA_NERD_LINE1}
╰─%B%(!.#.$)%b '
RPROMPT=''