From 7f859e74aae7953cce9ef4b4e2a6e5961b87f434 Mon Sep 17 00:00:00 2001 From: publicmatt Date: Mon, 11 May 2026 11:53:19 -0700 Subject: [PATCH] move .userrc to .mattrc. fix .zshrc to macos and clean. --- Makefile | 14 +++- README.md | 2 +- shell/.allenairc.example | 16 +++++ shell/.mattrc | 80 +++++++++++++++++++++++ shell/.stow-local-ignore | 1 + shell/.userrc | 53 --------------- shell/.zshrc | 135 ++++++--------------------------------- 7 files changed, 130 insertions(+), 171 deletions(-) create mode 100644 shell/.allenairc.example create mode 100644 shell/.mattrc create mode 100644 shell/.stow-local-ignore delete mode 100644 shell/.userrc diff --git a/Makefile b/Makefile index a487d70..059f831 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -.PHONY: all nvim git shell tmux submodules +.PHONY: all nvim git shell tmux submodules p10k + +ZSH_CUSTOM ?= ${HOME}/.oh-my-zsh/custom all: submodules nvim git shell tmux @@ -11,8 +13,16 @@ git: nvim: stow nvim -t ${HOME}/.config/ -shell: +shell: p10k stow shell -t ${HOME} tmux: submodules stow tmux -t ${HOME} + +p10k: + @if [ ! -d ${ZSH_CUSTOM}/themes/powerlevel10k ]; then \ + echo "installing powerlevel10k -> ${ZSH_CUSTOM}/themes/powerlevel10k"; \ + git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM}/themes/powerlevel10k; \ + else \ + echo "powerlevel10k already installed"; \ + fi diff --git a/README.md b/README.md index ad65ef6..a45e803 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Personal config, deployed with [GNU Stow](https://www.gnu.org/software/stow/). . ├── git/ -> $HOME (.gitconfig) ├── nvim/ -> $HOME/.config/ (nvim/) -├── shell/ -> $HOME (.zshrc, .userrc, .musicrc) +├── shell/ -> $HOME (.zshrc, .mattrc, .musicrc) └── tmux/ -> $HOME (.config/tmux/{tmux.conf,tmux.conf.local,oh-my-tmux/}) ``` diff --git a/shell/.allenairc.example b/shell/.allenairc.example new file mode 100644 index 0000000..6219160 --- /dev/null +++ b/shell/.allenairc.example @@ -0,0 +1,16 @@ +# Copy to ~/.allenairc. Never commit. Prefer SSO/keychain over plaintext. + +# AWS +export AWS_REGION=us-west-2 +# export AWS_ACCESS_KEY_ID=... +# export AWS_SECRET_ACCESS_KEY=... +# export AWS_PROFILE=... + +# Repos +# export HF_TOKEN=... +# export GITHUB_TOKEN=... + +# Services +# export CORPUS_DATABASE_URL=.. +# export FIRS2_DATABASE_URL=.. +# export S2_PUBLIC_KEY=... diff --git a/shell/.mattrc b/shell/.mattrc new file mode 100644 index 0000000..7d7a615 --- /dev/null +++ b/shell/.mattrc @@ -0,0 +1,80 @@ +######################################################################## +# +# Personal sh stuff +# +######################################################################## + +bt() { + echo "powering on" + bluetoothctl power on + device=$1 + echo "connecting to $device"; + bluetoothctl devices | awk -v device="$device" '$0 ~ device {print $2}' | xargs -I{} bluetoothctl connect {} +} + +grab() { + out=$1 + echo "pasting clipboard to $out" + xclip -sel clipboard -t image/png -o > $out +} + +# save a youtube video as audio file +yt() { + youtube-dl $1 -x --audio-format mp3 +} + +# tm - create new tmux session, or switch to existing one. Works from within tmux too. +# `tm` lists sessions via fzf, or prompts for a new session name when none exist. +# `tm irc` attaches to the irc session (creating it if needed). +tm() { + local change session sessions + [[ -n "$TMUX" ]] && change="switch-client" || change="attach-session" + + if [[ -n "$1" ]]; then + tmux $change -t "$1" 2>/dev/null || { tmux new-session -d -s "$1" && tmux $change -t "$1"; } + return + fi + + sessions=$(tmux list-sessions -F "#{session_name}" 2>/dev/null) + if [[ -n "$sessions" ]]; then + session=$(echo "$sessions" | fzf --prompt="Select tmux session: " --height=40% --reverse --exit-0) + [[ -n "$session" ]] && tmux $change -t "$session" + else + read "session?Enter new session name: " + [[ -n "$session" ]] && tmux new-session -s "$session" + fi +} + + +######################################################################## +# +# PATH additions +# +######################################################################## +alias vi=nvim +export VISUAL=nvim +export EDITOR="$VISUAL" +export PLAN_BASE_PATH="$HOME/.plan" + +# prepend: tools that should win over system equivalents +[[ -d /opt/homebrew/bin ]] && export PATH="/opt/homebrew/bin:$PATH" +[[ -d /opt/homebrew/opt/libpq/bin ]] && export PATH="/opt/homebrew/opt/libpq/bin:$PATH" + +# append: user-installed binaries +[[ -d "$HOME/.local/bin" ]] && export PATH="$PATH:$HOME/.local/bin" +[[ -d "$HOME/go/bin" ]] && export PATH="$PATH:$HOME/go/bin" +[[ -d "$HOME/.claude/local" ]] && export PATH="$PATH:$HOME/.claude/local" +[[ -d /usr/local/lib/nodejs/bin ]] && export PATH="$PATH:/usr/local/lib/nodejs/bin" +[[ -d /opt/nvim/bin ]] && export PATH="$PATH:/opt/nvim/bin" + +# env sourcers +[[ -f "$HOME/.cargo/env" ]] && source "$HOME/.cargo/env" +[[ -f "$HOME/.local/bin/env" ]] && source "$HOME/.local/bin/env" + +# mise (runtime version manager) — must run after PATH so its shim wins +command -v mise >/dev/null && eval "$(mise activate zsh)" + +# personal aliases (separate file) +[[ -f "$HOME/.aliases" ]] && source "$HOME/.aliases" + +alias d="sudo docker" diff --git a/shell/.stow-local-ignore b/shell/.stow-local-ignore new file mode 100644 index 0000000..280595d --- /dev/null +++ b/shell/.stow-local-ignore @@ -0,0 +1 @@ +.+\.example$ diff --git a/shell/.userrc b/shell/.userrc deleted file mode 100644 index 175ffc9..0000000 --- a/shell/.userrc +++ /dev/null @@ -1,53 +0,0 @@ -######################################################################## -# -# PERSONAL sh stuff -# -######################################################################## - -bt() { - echo "powering on" - bluetoothctl power on - device=$1 - echo "connecting to $device"; - bluetoothctl devices | awk -v device="$device" '$0 ~ device {print $2}' | xargs -I{} bluetoothctl connect {} -} - -grab() { - out=$1 - echo "pasting clipboard to $out" - xclip -sel clipboard -t image/png -o > $out -} - -# tm - create new tmux session, or switch to existing one. Works from within tmux too. (@bag-man) -# `tm` will allow you to select your tmux session via fzf. -# `tm irc` will attach to the irc session (if it exists), else it will create it. - -tm() { - [[ -n "$TMUX" ]] && change="switch-client" || change="attach-session" - if [ $1 ]; then - tmux $change -t "$1" 2>/dev/null || (tmux new-session -d -s $1 && tmux $change -t "$1"); return - fi - session=$(tmux list-sessions -F "#{session_name}" 2>/dev/null | fzf --exit-0) && tmux $change -t "$session" || echo "No sessions found." -} - -# save a youtube video as audio file -yt() { - youtube-dl $1 -x --audio-format mp3 -} - - -######################################################################## -# -# PATH additions -# -######################################################################## -alias vi=nvim -export VISUAL=nvim -export EDITOR="$VISUAL" - -source "$HOME/.cargo/env" -export PATH="$PATH:$HOME/.local/bin" -export PATH="$PATH:/usr/local/lib/nodejs/bin" -export PATH="$PATH:/opt/nvim/bin" - -alias d="sudo docker" diff --git a/shell/.zshrc b/shell/.zshrc index c57cdbd..ecb5344 100644 --- a/shell/.zshrc +++ b/shell/.zshrc @@ -1,125 +1,30 @@ -# 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 +# p10k instant prompt — keep near top +[[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]] \ + && source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" -# If you come from bash you might have to change your $PATH. -# export PATH=$HOME/bin:/usr/local/bin:$PATH - -# Path to your oh-my-zsh installation. +# oh-my-zsh export ZSH="$HOME/.oh-my-zsh" - -# Set name of the theme to load --- if set to "random", it will -# load a random theme each time oh-my-zsh is loaded, in which case, -# to know which specific one was loaded, run: echo $RANDOM_THEME -# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes ZSH_THEME="powerlevel10k/powerlevel10k" - -# Set list of themes to pick from when loading at random -# Setting this variable when ZSH_THEME=random will cause zsh to load -# a theme from this variable instead of looking in $ZSH/themes/ -# If set to an empty array, this variable will have no effect. -# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) - -# Uncomment the following line to use case-sensitive completion. -# CASE_SENSITIVE="true" - -# Uncomment the following line to use hyphen-insensitive completion. -# Case-sensitive completion must be off. _ and - will be interchangeable. -# HYPHEN_INSENSITIVE="true" - -# Uncomment one of the following lines to change the auto-update behavior -# zstyle ':omz:update' mode disabled # disable automatic updates -# zstyle ':omz:update' mode auto # update automatically without asking -# zstyle ':omz:update' mode reminder # just remind me to update when it's time - -# Uncomment the following line to change how often to auto-update (in days). -# zstyle ':omz:update' frequency 13 - -# Uncomment the following line if pasting URLs and other text is messed up. -# DISABLE_MAGIC_FUNCTIONS="true" - -# Uncomment the following line to disable colors in ls. -# DISABLE_LS_COLORS="true" - -# Uncomment the following line to disable auto-setting terminal title. -# DISABLE_AUTO_TITLE="true" - -# Uncomment the following line to enable command auto-correction. -# ENABLE_CORRECTION="true" - -# Uncomment the following line to display red dots whilst waiting for completion. -# You can also set it to another string to have that shown instead of the default red dots. -# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f" -# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765) -# COMPLETION_WAITING_DOTS="true" - -# Uncomment the following line if you want to disable marking untracked files -# under VCS as dirty. This makes repository status check for large repositories -# much, much faster. -# DISABLE_UNTRACKED_FILES_DIRTY="true" - -# Uncomment the following line if you want to change the command execution time -# stamp shown in the history command output. -# You can set one of the optional three formats: -# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" -# or set a custom format using the strftime function format specifications, -# see 'man strftime' for details. -# HIST_STAMPS="mm/dd/yyyy" - -# Would you like to use another custom folder than $ZSH/custom? -# ZSH_CUSTOM=/path/to/new-custom-folder - -# Which plugins would you like to load? -# Standard plugins can be found in $ZSH/plugins/ -# Custom plugins may be added to $ZSH_CUSTOM/plugins/ -# Example format: plugins=(rails git textmate ruby lighthouse) -# Add wisely, as too many plugins slow down shell startup. plugins=(git) +[[ -f "$ZSH/oh-my-zsh.sh" ]] && source "$ZSH/oh-my-zsh.sh" -source $ZSH/oh-my-zsh.sh +# p10k config +[[ -f ~/.p10k.zsh ]] && source ~/.p10k.zsh -# User configuration +# personal rc files +[[ -f ~/.mattrc ]] && source ~/.mattrc +[[ -f ~/.musicrc ]] && source ~/.musicrc -# export MANPATH="/usr/local/man:$MANPATH" +# work / sensitive overrides (gitignored, not in repo) +[[ -f ~/.allenairc ]] && source ~/.allenairc +[[ -f ~/.wwurc ]] && source ~/.wwurc -# You may need to manually set your language environment -# export LANG=en_US.UTF-8 - -# Preferred editor for local and remote sessions -# if [[ -n $SSH_CONNECTION ]]; then -# export EDITOR='vim' -# else -# export EDITOR='mvim' -# fi - -# Compilation flags -# export ARCHFLAGS="-arch x86_64" - -# Set personal aliases, overriding those provided by oh-my-zsh libs, -# plugins, and themes. Aliases can be placed here, though oh-my-zsh -# users are encouraged to define aliases within the ZSH_CUSTOM folder. -# For a full list of active aliases, run `alias`. -# -# Example aliases -# alias zshconfig="mate ~/.zshrc" -# alias ohmyzsh="mate ~/.oh-my-zsh" - -# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. -[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh - -source ~/.userrc -source ~/.musicrc -source ~/.wwurc - - -[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh - -# bun completions -[ -s "/home/user/.bun/_bun" ] && source "/home/user/.bun/_bun" +# fzf +[[ -f ~/.fzf.zsh ]] && source ~/.fzf.zsh # bun -export BUN_INSTALL="$HOME/.bun" -export PATH="$BUN_INSTALL/bin:$PATH" +[[ -d "$HOME/.bun" ]] && { + export BUN_INSTALL="$HOME/.bun" + export PATH="$BUN_INSTALL/bin:$PATH" + [[ -s "$BUN_INSTALL/_bun" ]] && source "$BUN_INSTALL/_bun" +}