zsh config: zshrc, path, aliases (ported from fish), extras, functions, plugins
This commit is contained in:
parent
5e0e96e8e2
commit
8bb8a44dbd
11
config/zsh/aliases-extras.zsh
Normal file
11
config/zsh/aliases-extras.zsh
Normal file
@ -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
|
||||
67
config/zsh/aliases.zsh
Normal file
67
config/zsh/aliases.zsh
Normal file
@ -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
|
||||
28
config/zsh/functions.zsh
Normal file
28
config/zsh/functions.zsh
Normal file
@ -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 "$@"; }
|
||||
35
config/zsh/path.zsh
Normal file
35
config/zsh/path.zsh
Normal file
@ -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
|
||||
23
config/zsh/plugins.zsh
Normal file
23
config/zsh/plugins.zsh
Normal file
@ -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
|
||||
59
config/zsh/zshrc
Normal file
59
config/zsh/zshrc
Normal file
@ -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
|
||||
Loading…
Reference in New Issue
Block a user