— dotfiles-expanded
This is a more expanded reflection on my dotfiles repo from my first post. The subject matter is possibly one of the more trope-ish and boring types of blogposts on a personal website, but I’ve always wanted to nerd out on this topic, so, here we are. With the advent of AI, I’ve been inspired to write more, which I guess is ironic. I don’t like using AI for generating any writing, specifically, but it’s been very useful for CLI tweaks because I can have an idea and just “make it so”, without trolling through bash or zsh docs. It’s more akin to a spellcheck and linter, with the added bonus that I get to learn and simultaneously implement incredibly fast. This doesn’t necessarily mean I add a lot of lines of unreadable slop. It means things are dialed in, honed, specific. They are a deliberate selection of interfaces to my computing environment(s).
My dotfiles (cfg) repo is hosted all over various servers, but I have a github mirror if you want pick through the canonical source.
Starting at the top, I use zsh. I use a lot of the auto-complete stuff. I like using fzf for whenever I need to pick through a list. That’s basically it. Those are the deps.
I sync these dotfiles with a --bare git repo aliased to a shortcut (usually cfg or dt depending what system I’m on).
~/.zshrc
I spend about equal time on Linux and MacOS, so I inevitably split my two dotfiles into two branches – and began realizing how much could co-habitat between the two paradigms. Things like tmux and vim confs stay exactly the same, while system specific stuff in various areas without contaminating the other paradigm.
So, at the top, I start with my ~/.zshrc, which splits platform and local settings. All other sub-sections of the config live inside ~/.zsh/
# platform entry
if [[ "$OSTYPE" == darwin* ]]; then
[[ -r "$HOME/.zsh/macos.zsh" ]] && source "$HOME/.zsh/macos.zsh"
elif [[ "$OSTYPE" == linux* ]]; then
[[ -r "$HOME/.zsh/linux.zsh" ]] && source "$HOME/.zsh/linux.zsh"
else
# use shared config for unrecognized platform
source "$HOME/.zsh/common.zsh"
fi
That’s all it is. I keep it as clean as possible.
~/.zsh/common.zsh
Starting with common.zsh, it’s a shared pool of stuff that works across “any” system, more or less, including the config for setting up this repo across other systems.
In includes the prompt layout, git/branch info. zsh autocomplete settings, various global paths, and fzf settings.
~/.zsh/macos.zsh
macos.zsh. This contains all the annoying brew config, and I try avoid repeat calls to brew --prefix which initializes a subprocess every time the shell is opening, so I just check if the directories exist before calling it. Keeps things as snappy as possible.
I use Fast node manager fnm for Node.
alias x86='arch -x86_64 zsh'
Alias for x86 emulation on Apple Silicon. When this is enabled, my prompt prefixes [x86], reminding me we’re in emu-mode. Come to think of it, I haven’t had to use this in a long time, most things I used have been ported to ARM.
~/.zsh/linux.zsh
linux.zsh. Basic zsh plugins and settings with different paths than MacOS. Not exciting.
~/.zsh/fzf-tab.zsh
Zsh has a built-in tab complete, but I hooked up fzf to it. It basically improves what is already great. So, instead of pressing tab and seeing a static list, I can filter it. I also set up ctrl-/ for file preview, which is nice – because sometimes when I’m cat‘ing something, I end up not having to cat it at all – I can just glance at its contents. Like MacOS quicklook, but in the terminal. For git-related commands, it will auto complete as well. git add <Tab>, git diff <Tab>, will preview various files I select via fzf. Env vars get previewed, too.
~/.zsh/cd-smart.zsh
cd-smart is a small, inspect-able wrapper for cd I wrote that makes cd learn your directory habits. It’s inspired by zoxide, which I think is great, but I just couldn’t get down with typing z. So I just tied in what I considered functionally successful about z directly into cd. It works basically the same, but I have aliases, too. It’s also only about 250 lines.
In a nutshell it overrides cd without breaking standard behavior, and falls back gracefully. It learns visited directories automatically and ranks their paths by visitation frequency. Then, you can use multi-word queries in path order to quickly jump to paths, has aliases, and integrates learned locations into Tab completion. I wanted smart directory navigation that is tiny, understandable, editable, and native to Zsh completion. Philosophically I think shell enhancements should be invisible and fallback should be clean, so in that vein, I like improving the shell’s existing verbs over creating new shortcuts.
~/.tmux.conf
Windows should start with “1”. Reaching for ctrl-b 0 feel so wrong for window 1. I also added ctrl-shift <left/right arrow keys> for fast tab switching. A philosophy I have about tmux is I don’t really like replacing various esoteric key bindings with custom keys – besides windows. For example, I have grown to love ctrl-b " for horiz split and ctrl-b % for vertical. Tmux’s key bindings are completely nuts. I’ve committed to memorizing it for the culture. I prefer just memorizing standard key commands for most TUI programs because I frankly DON’T like creating custom configs all the time. (Irony is palpable as you read this post about dotfiles). But the less custom config I have specifically for key bindings, the less foreign a new system feels. I like configuring visuals tho. Most of my tmux config is visual and layout. Oh and ctrl-b r for reloading the config is priceless.
~/.vimrc
I used emacs exlusively for years as my main editor, but I haven’t opened it since I moved to Vim. I made a cheatsheet to help my transition, which is a legacy document at this point. There’s nothing super special about my VIM setup – it’s deliberately close to stock. I highlight my searches, and I like the search highlight to be persistent, that’s added. Mouse is enabled. Centralized backups, swap and undo data. F8 opens :Vexplore.