dotfiles/zsh/zshrc.org
2020-06-17 20:43:48 -07:00

3 KiB

ZSH

Autoload any ZSH function from $HOME/.zsh/functions.

  fpath=($HOME/.zsh/functions $fpath)
  autoload -U $HOME/.zsh/functions/*(:t)

Aliases

Use rlwrap on some less-than-pleasant REPLs that don't have GNU Readline-like features themselves.

  alias csi="rlwrap csi"
  alias scsh="rlwrap scsh"
  alias sbcl="rlwrap sbcl"

This alias is useful for when I'm trying something new with herbstluftwm.

  alias hc=herbstclient

History

Store ZSH history in a non-intrusive place.

  HISTFILE=$HOME/.zsh/histfile

Keep at most 1000 previous commands in memory.

  HISTSIZE=1000

Save at most 1000 previous commands to disk.

  SAVEHIST=1000

Allow multiple shell instances to share the same history.

  setopt SHARE_HISTORY

Don't remember duplicated commands.

  setopt HIST_IGNORE_ALL_DUPS

Plug-ins

Load zplug, a next generation zsh plugin manager.

  source /usr/share/zsh/scripts/zplug/init.zsh

Add zsh-syntax-highlighting.

  zplug "zsh-users/zsh-syntax-highlighting", defer:3

Add zsh-autosuggestions.

  zplug "zsh-users/zsh-autosuggestions"

Add bgnotify from oh-my-zsh to show when long-running commands finish.

  zplug "plugins/bgnotify", from:oh-my-zsh

Make sure all plugins are installed.

  if ! zplug check --verbose; then
      printf "Install? [y/N]: "
      if read -q; then
          echo; zplug install
      fi
  fi

Load all plugins.

  zplug load --verbose

X Interaction

Make some widgets for interacting with the clipboard.

  zle -N x-copy-region-as-kill
  zle -N x-kill-region
  zle -N x-yank

Bind them to keyboard shortcuts.

  bindkey -e '^[w' x-copy-region-as-kill
  bindkey -e '^W' x-kill-region
  bindkey -e '^Y' x-yank

Completion

Initialize completion. This triggers loading of zsh-syntax-highlighting as well.

  autoload -Uz compinit
  compinit

Less

I use a terminal that's always 80 columns wide. This means that a lot of output doesn't fit on a single line. I use the less command a lot to look at output that's too big and wide to view in my terminal. The default doesn't make this any better though, so I use these switches. Most of these I originally got from what git uses.

  export LESS="FXRSi"

This causes less to immediately quit if there is no need to use a pager (everything fits in a single screen) (-F). Doesn't clear the screen when less is closed (-X). Handles ANSI colors (-R). Stops long lines from wraping (-S). And makes searches case-insensitive (-i).