From 8bb8a44dbdb923745b8ce266db2af63ff14476d3 Mon Sep 17 00:00:00 2001 From: mk Date: Tue, 28 Jul 2026 04:32:38 +0300 Subject: [PATCH] zsh config: zshrc, path, aliases (ported from fish), extras, functions, plugins --- config/zsh/aliases-extras.zsh | 11 ++++++ config/zsh/aliases.zsh | 67 +++++++++++++++++++++++++++++++++++ config/zsh/functions.zsh | 28 +++++++++++++++ config/zsh/path.zsh | 35 ++++++++++++++++++ config/zsh/plugins.zsh | 23 ++++++++++++ config/zsh/zshrc | 59 ++++++++++++++++++++++++++++++ 6 files changed, 223 insertions(+) create mode 100644 config/zsh/aliases-extras.zsh create mode 100644 config/zsh/aliases.zsh create mode 100644 config/zsh/functions.zsh create mode 100644 config/zsh/path.zsh create mode 100644 config/zsh/plugins.zsh create mode 100644 config/zsh/zshrc diff --git a/config/zsh/aliases-extras.zsh b/config/zsh/aliases-extras.zsh new file mode 100644 index 0000000..93d10aa --- /dev/null +++ b/config/zsh/aliases-extras.zsh @@ -0,0 +1,11 @@ +# aliases-extras.zsh — YOUR personal additions go here. +# This file is preserved across re-runs of the shell-zsh step (not overwritten +# from the repo). Add your taskwarrior / neomutt / cargo / eso aliases here. + +# Examples (uncomment + edit): +# alias tw='taskwarrior-tui' +# alias ta='task add' +# alias tl='task list' +# alias neomutt='neomutt -f ~/.local/share/mail/you/All\ Mail/' +# alias carwash="cargo-watch -x run" +# alias wttr="curl v2.wttr.in/59.95,30.35?FQM" # your city coords \ No newline at end of file diff --git a/config/zsh/aliases.zsh b/config/zsh/aliases.zsh new file mode 100644 index 0000000..46d6d91 --- /dev/null +++ b/config/zsh/aliases.zsh @@ -0,0 +1,67 @@ +# aliases.zsh — ported from ~/.config/fish/config.fish (server-relevant subset) +# Plus curated defaults. Edit aliases-extras.zsh for personal additions. + +# ── editor ────────────────────────────────────────────────────────────────── +alias v="$EDITOR" +alias vi="$EDITOR" +alias vim="$EDITOR" + +# ── ls / eza ─────────────────────────────────────────────────────────────── +alias lso="/bin/ls" # plain ls escape hatch +if command -v eza >/dev/null 2>&1; then + alias ls="eza -l --group-directories-first --icons" + alias ll="eza -la --group-directories-first --icons" + alias la="eza -a --group-directories-first --icons" + alias lt="eza --tree --level=2 --icons" +else + alias ls="ls --color=auto -l" + alias ll="ls -la --color=auto" + alias la="ls -a --color=auto" +fi + +# ── cat / bat ─────────────────────────────────────────────────────────────── +if command -v bat >/dev/null 2>&1; then + alias cat="bat --paging=never" +fi +alias catn="/bin/cat" + +# ── file ops (verbose + interactive safety) ──────────────────────────────── +alias cp="cp -iv" +alias mv="mv -iv" +alias rm="rm -iv" +alias ln="ln -sv" +alias mkdir="mkdir -pv" +alias md="mkdir" + +# ── git ───────────────────────────────────────────────────────────────────── +alias g="git" +alias gcl="git clone" +alias gst="git status" +alias gd="git diff" +alias gco="git checkout" + +# ── systemd ────────────────────────────────────────────────────────────────── +alias sy="sudo systemctl" +alias srv="sudo systemctl" + +# ── sudo / misc ────────────────────────────────────────────────────────────── +alias sudoo="sudo -E -s" +alias chmox="chmod +x" + +# ── network ───────────────────────────────────────────────────────────────── +alias whoamip="curl --silent https://ipinfo.io" +alias wttr="curl v2.wttr.in" +alias wtr="wttr" + +# ── byobu ──────────────────────────────────────────────────────────────────── +alias byb="byobu" +alias bybou="byobu" + +# ── pacman (Arch only) ────────────────────────────────────────────────────── +if command -v pacman >/dev/null 2>&1; then + alias pac="sudo pacman" + alias pacs="sudo pacman -Sy" + alias pacu="sudo pacman -Syyu" + alias pacy="sudo pacman -Sy" + alias pa="sudo pacman" +fi \ No newline at end of file diff --git a/config/zsh/functions.zsh b/config/zsh/functions.zsh new file mode 100644 index 0000000..b4dc52d --- /dev/null +++ b/config/zsh/functions.zsh @@ -0,0 +1,28 @@ +# functions.zsh — ported from fish functions (server-relevant subset) + +# make dir + cd into it +mcd() { mkdir -p "$1" && cd "$1"; } + +# reload zsh config +so() { source "${ZDOTDIR:-$HOME/.config/zsh}/zshrc" 2>/dev/null || source "$HOME/.zshrc"; } + +# cd into ~/.config, edit/open the named file/dir (interactive) +conf() { + local base="${XDG_CONFIG_HOME:-$HOME/.config}" + cd "$base" || return + if [[ -f "$1" ]]; then + echo "Editing $1"; $EDITOR "$1" + elif [[ -d "$1" ]]; then + echo "Opening config dir $1"; cd "$1" && ls -al + else + read "confirm?Can't find $1, open in \$EDITOR? (Y/n) " + if [[ -z "$confirm" || "$confirm" =~ ^[Yy]$ ]]; then + $EDITOR "$1" + else + echo "Exiting…" + fi + fi +} + +# ssh onward with a sane TERM (avoids terminfo breakage on older boxes) +ssh() { TERM=xterm command ssh "$@"; } \ No newline at end of file diff --git a/config/zsh/path.zsh b/config/zsh/path.zsh new file mode 100644 index 0000000..5d6cade --- /dev/null +++ b/config/zsh/path.zsh @@ -0,0 +1,35 @@ +# path.zsh — PATH + environment (ported from ~/.config/fish/config.fish, server subset) + +# XDG +export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" +export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" +export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" +export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}" + +export EDITOR="nvim" +export LANG="en_US.UTF-8" +export LC_COLLATE="C" +export PAGER="less" +export LESS="-R" # render ANSI colors in less +export BAT_THEME="base16" +export LESSHISTFILE="$XDG_STATE_HOME/less/history" +[[ -d "$XDG_STATE_HOME/less" ]] || mkdir -p "$XDG_STATE_HOME/less" + +# user-local binaries (fd/bat shims, gh-release binaries, pip installs, ...) +case ":$PATH:" in + *":$HOME/.local/bin:"*) ;; + *) export PATH="$HOME/.local/bin:$PATH" ;; +esac +case ":$PATH:" in + *":/usr/local/bin:"*) ;; + *) export PATH="/usr/local/bin:$PATH" ;; +esac + +# nvm (installed by the nvm step) — loaded lazily via its init snippet below +export NVM_DIR="${NVM_DIR:-$HOME/.nvm}" +[[ -s "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh" + +# pnpm (if present) +if [[ -d "$HOME/.local/share/pnpm" ]] && ! [[ ":$PATH:" == *":$HOME/.local/share/pnpm:"* ]]; then + export PATH="$HOME/.local/share/pnpm:$PATH" +fi \ No newline at end of file diff --git a/config/zsh/plugins.zsh b/config/zsh/plugins.zsh new file mode 100644 index 0000000..ee03852 --- /dev/null +++ b/config/zsh/plugins.zsh @@ -0,0 +1,23 @@ +# plugins.zsh — enable oh-my-zsh builtins + external plugins (cloned by the +# shell-zsh module into $ZSH_CUSTOM/plugins). + +plugins=( + git + sudo + command-not-found + colored-man-pages + extract + copypath + dirhistory + zsh-autosuggestions + zsh-syntax-highlighting # must be last among syntax plugins + history-substring-search + fzf-tab + zsh-completions +) + +source "$ZSH/oh-my-zsh.sh" + +# history-substring-search keybindings (after omz is loaded) +bindkey '^[[A' history-substring-search-up +bindkey '^[[B' history-substring-search-down \ No newline at end of file diff --git a/config/zsh/zshrc b/config/zsh/zshrc new file mode 100644 index 0000000..13ec6b0 --- /dev/null +++ b/config/zsh/zshrc @@ -0,0 +1,59 @@ +# ~/.zshrc shim (managed by bootstrap) sources this file via ZDOTDIR. +# Edit freely; re-run the shell-zsh step to re-sync from the repo if needed. + +# ── oh-my-zsh bootstrap ──────────────────────────────────────────────────── +export ZSH="${ZSH:-$HOME/.oh-my-zsh}" +export ZSH_CUSTOM="${ZSH_CUSTOM:-$ZSH/custom}" + +# theme disabled — we use starship (init at the bottom) +ZSH_THEME="" + +# casewise history +HISTFILE="$HOME/.local/state/zsh/history" +HISTSIZE=100000 +SAVEHIST=100000 +setopt EXTENDED_HISTORY SHARE_HISTORY HIST_IGNORE_DUPS HIST_IGNORE_SPACE HIST_VERIFY +setopt AUTO_CD PUSHD_IGNORE_DUPS PROMPT_SUBST +setopt INTERACTIVE_COMMENTS + +# load the modular pieces (order matters) +[[ -f "$ZDOTDIR/path.zsh" ]] && source "$ZDOTDIR/path.zsh" +[[ -f "$ZDOTDIR/aliases.zsh" ]] && source "$ZDOTDIR/aliases.zsh" +[[ -f "$ZDOTDIR/aliases-extras.zsh" ]] && source "$ZDOTDIR/aliases-extras.zsh" +[[ -f "$ZDOTDIR/functions.zsh" ]] && source "$ZDOTDIR/functions.zsh" + +# ── completion styling (set before omz runs compinit) ─────────────── +autoload -Uz compinit +zstyle ':completion:*' menu select +zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' +zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} + +# oh-my-zsh + plugins (omz runs compinit internally; lists our plugins) +[[ -f "$ZDOTDIR/plugins.zsh" ]] && source "$ZDOTDIR/plugins.zsh" + +# ── standard zsh niceties ───────────────────────────────────────────── +autoload -U edit-command-line +zle -N edit-command-line +bindkey '^X^E' edit-command-line + + +# ... -> ../.. expansion (ported from fish) +rationalise-dot() { + if [[ $LBUFFER = *.. ]]; then LBUFFER+=/; else LBUFFER+=.; fi +} +zle -N rationalise-dot +bindkey . rationalise-dot + +# ── keychain (commented) — fill in the key labels you use on this box ──── +# if command -v keychain >/dev/null 2>&1; then +# keychain --quiet --nogui id_ed25519 # <- your server-relevant key(s) here +# [[ -f "$HOME/.keychain/$(hostname)-sh" ]] && source "$HOME/.keychain/$(hostname)-sh" +# fi + +# ── integrations ──────────────────────────────────────────────────────────── +command -v zoxide >/dev/null 2>&1 && eval "$(zoxide init zsh)" +command -v fzf >/dev/null 2>&1 && [[ -f "$HOME/.fzf.zsh" ]] && source "$HOME/.fzf.zsh" +# ── starship prompt ───────────────────────────────────────────────────────── +if command -v starship >/dev/null 2>&1; then + eval "$(starship init zsh)" +fi \ No newline at end of file