dotfiles/zsh/zshrc.org

149 lines
3 KiB
Org Mode
Raw Normal View History

2016-10-19 22:52:25 +02:00
#+TITLE: ZSH
2016-11-24 21:47:09 +01:00
#+STARTUP: showall
2016-10-19 22:52:25 +02:00
Autoload any ZSH function from =$HOME/.zsh/functions=.
#+BEGIN_SRC sh
fpath=($HOME/.zsh/functions $fpath)
autoload -U $HOME/.zsh/functions/*(:t)
#+END_SRC
2016-10-29 09:55:50 +02:00
* Aliases
2016-10-19 22:52:25 +02:00
2016-10-29 09:55:50 +02:00
Use rlwrap on some less-than-pleasant REPLs that don't have GNU
Readline-like features themselves.
2016-10-29 09:55:50 +02:00
#+BEGIN_SRC sh
alias csi="rlwrap csi"
alias scsh="rlwrap scsh"
2016-11-09 15:02:21 +01:00
alias sbcl="rlwrap sbcl"
2016-10-29 09:55:50 +02:00
#+END_SRC
2016-11-24 21:47:09 +01:00
This alias is useful for when I'm trying something new with
herbstluftwm.
#+BEGIN_SRC sh
alias hc=herbstclient
#+END_SRC
2016-10-29 11:00:18 +02:00
* History
Store ZSH history in a non-intrusive place.
#+BEGIN_SRC sh
HISTFILE=$HOME/.zsh/histfile
#+END_SRC
Keep at most 1000 previous commands in memory.
#+BEGIN_SRC sh
HISTSIZE=1000
#+END_SRC
Save at most 1000 previous commands to disk.
#+BEGIN_SRC sh
SAVEHIST=1000
#+END_SRC
Allow multiple shell instances to share the same history.
#+BEGIN_SRC sh
setopt SHARE_HISTORY
#+END_SRC
Don't remember duplicated commands.
#+BEGIN_SRC sh
setopt HIST_IGNORE_ALL_DUPS
#+END_SRC
2016-10-29 09:55:50 +02:00
* Plug-ins
2016-10-29 09:55:50 +02:00
Load zplug, a next generation zsh plugin manager.
2016-10-29 09:55:50 +02:00
#+BEGIN_SRC sh
source /usr/share/zsh/scripts/zplug/init.zsh
#+END_SRC
2016-10-29 09:55:50 +02:00
Add zsh-syntax-highlighting.
2016-10-29 09:55:50 +02:00
#+BEGIN_SRC sh
zplug "zsh-users/zsh-syntax-highlighting", nice:10
#+END_SRC
2016-10-29 09:55:50 +02:00
Add zsh-autosuggestions.
2016-10-21 14:41:21 +02:00
2016-10-29 09:55:50 +02:00
#+BEGIN_SRC sh
zplug "zsh-users/zsh-autosuggestions"
#+END_SRC
2016-10-21 14:41:21 +02:00
2016-10-29 09:55:50 +02:00
Add bgnotify from oh-my-zsh to show when long-running commands finish.
2016-10-29 09:55:50 +02:00
#+BEGIN_SRC sh
zplug "plugins/bgnotify", from:oh-my-zsh
#+END_SRC
2016-10-29 09:55:50 +02:00
Make sure all plugins are installed.
2016-10-29 09:55:50 +02:00
#+BEGIN_SRC sh
if ! zplug check --verbose; then
printf "Install? [y/N]: "
if read -q; then
echo; zplug install
fi
fi
#+END_SRC
2016-10-29 09:55:50 +02:00
Load all plugins.
2016-10-21 14:51:21 +02:00
2016-10-29 09:55:50 +02:00
#+BEGIN_SRC sh
zplug load --verbose
#+END_SRC
2016-10-21 14:51:21 +02:00
2016-10-29 09:55:50 +02:00
* X Interaction
2016-10-21 14:51:21 +02:00
2016-10-29 09:55:50 +02:00
Make some widgets for interacting with the clipboard.
2016-10-21 14:51:21 +02:00
2016-10-29 09:55:50 +02:00
#+BEGIN_SRC sh
zle -N x-copy-region-as-kill
zle -N x-kill-region
zle -N x-yank
#+END_SRC
2016-10-29 09:55:50 +02:00
Bind them to keyboard shortcuts.
#+BEGIN_SRC sh
bindkey -e '^[w' x-copy-region-as-kill
bindkey -e '^W' x-kill-region
bindkey -e '^Y' x-yank
#+END_SRC
* Completion
Initialize completion. This triggers loading of
zsh-syntax-highlighting as well.
#+BEGIN_SRC sh
autoload -Uz compinit
compinit
#+END_SRC
2016-11-24 21:47:18 +01:00
* 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.
#+BEGIN_SRC sh
export LESS="FXRSi"
#+END_SRC
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=).