My .zshrc file on Mac (adapted from .bashrc and .inputrc)

Startup

##### STARTUP
echo "hello mlim"
RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}"
RPS2=$RPS1

Bindings

##### BINDINGS
bindkey "^R" history-incremental-search-backward
bindkey "\e[A" history-beginning-search-backward
bindkey "\e[B" history-beginning-search-forward
131  cat abcc
132 cat abc
133 cat abcd
134 cat abcde
135 cat wut
136 cat yo
137 cat hello

Vim

##### VIM STUFF
bindkey '\e' vi-cmd-mode
# Make Vi mode transitions faster (KEYTIMEOUT is in hundredths of a second)
export KEYTIMEOUT=1
function zle-line-init zle-keymap-select {
RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}"
RPS2=$RPS1
zle reset-prompt
}
zle -N zle-line-init
zle -N zle-keymap-select
  1. Make it so that pressing Esc switches to Vim’s command mode.
  2. Make it so that Vim’s mode is displayed on the right-hand side of every line.
Displaying Vim’s mode
  • The “function” line defines two functions with the same implementation. These functions update the right-hand side prompt.
  • The zle -N lines bind those two functions to certain zsh events (see here for a list).

History

##### HISTORY
HISTFILE=~/.zsh_history
HISTSIZE=100000000
SAVEHIST=100000000
setopt INC_APPEND_HISTORY
setopt HIST_FIND_NO_DUPS
setopt HIST_IGNORE_DUPS
  • INC_APPEND_HISTORY makes it so that 1) zsh sessions append to the history rather than replacing it, e.g. when I restart my terminal I still have my history and 2) new commands get added to the history greedily instead of when the shell exits, e.g. when I enter a command in one tab I have it in the history of my other tabs.
  • HIST_FIND_NO_DUPS makes it so that Up Arrow and Down Arrow ignore duplicates.
  • HIST_IGNORE_DUPS makes it so that consecutive duplicates don’t get added to my history.

.bashrc and .inputrc

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Matt Lim

Matt Lim

Software Engineer. Tweeting @pencilflip. Mediocre boulderer, amateur tennis player, terrible at Avalon. https://www.mattlim.me/