aboutsummaryrefslogtreecommitdiffstats
path: root/zsh/zshrc.org
blob: 7f7bd000776dabc621950cf4de519838c8fd8b24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#+TITLE: ZSH
#+STARTUP: showall

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

#+BEGIN_SRC sh
  fpath=($HOME/.zsh/functions $fpath)
  autoload -U $HOME/.zsh/functions/*(:t)
#+END_SRC

* Aliases

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

  #+BEGIN_SRC sh
    alias csi="rlwrap csi"
    alias scsh="rlwrap scsh"
    alias sbcl="rlwrap sbcl"
  #+END_SRC

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

  #+BEGIN_SRC sh
    alias hc=herbstclient
  #+END_SRC

* 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

* Plug-ins

  Load zplug, a next generation zsh plugin manager.

  #+BEGIN_SRC sh
    source /usr/share/zsh/scripts/zplug/init.zsh
  #+END_SRC

  Add zsh-syntax-highlighting.

  #+BEGIN_SRC sh
    zplug "zsh-users/zsh-syntax-highlighting", nice:10
  #+END_SRC

  Add zsh-autosuggestions.

  #+BEGIN_SRC sh
    zplug "zsh-users/zsh-autosuggestions"
  #+END_SRC

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

  #+BEGIN_SRC sh
    zplug "plugins/bgnotify", from:oh-my-zsh
  #+END_SRC

  Make sure all plugins are installed.

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

  Load all plugins.

  #+BEGIN_SRC sh
    zplug load --verbose
  #+END_SRC

* X Interaction

  Make some widgets for interacting with the clipboard.

  #+BEGIN_SRC sh
    zle -N x-copy-region-as-kill
    zle -N x-kill-region
    zle -N x-yank
  #+END_SRC

  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