Minimal vim inspired .zshrc
13 Sep 2021 in Odds and Ends
I realised when I got a new machine that my dotfiles are in pretty poor shape and that I'd like to rebuild them. I need to use the new machine before I'll have time to do so.
In order to carry on working, I put together a minimal .zshrc
config file that captures 90% of my muscle memory when working on the terminal.
Here's the file, with added comments in case you're interested:
zsh
autoload -Uz compinit && compinit # Loads completion modulessetopt AUTO_MENU # Show completion menu on tab presssetopt ALWAYS_TO_END # Move cursor after completionsetopt COMPLETE_ALIASES # Allow autocompletion for aliasessetopt COMPLETE_IN_WORD # Allow completion from middle of wordsetopt LIST_PACKED # Smallest completion menusetopt AUTO_PARAM_KEYS # Intelligent handling of characterssetopt AUTO_PARAM_SLASH # after a completionsetopt AUTO_REMOVE_SLASH # Remove trailing slash when neededautoload edit-command-line; zle -N edit-command-line# brew install zsh-history-substring-search. /usr/local/share/zsh-history-substring-search/zsh-history-substring-search.zsh# brew install z. /usr/local/etc/profile.d/z.shbindkey -vbindkey -M viins 'jj' vi-cmd-mode # jj = <esc>bindkey -M vicmd "v" edit-command-line # Press v in command mode to edit in vimbindkey -M vicmd 'k' history-substring-search-up # Search backwards in historybindkey -M vicmd 'j' history-substring-search-down # Search forwards in historybindkey '^?' backward-delete-char # Enable backspace after vicmdbindkey '^h' backward-delete-chareval "$(starship init zsh)" # Bootstrap starship shell
The biggest thing I missed was bindkey -v
to switch to vim
key bindings and zsh-history-substring-search
(I don't like to type things more than once).