]> git.madduck.net Git - etc/zsh.git/blob - .zsh/zshrc/80-zle

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

re-enable direnv
[etc/zsh.git] / .zsh / zshrc / 80-zle
1 #
2 # Configure the zsh line editor
3 #
4 # Copyright © 1994–2017 martin f. krafft <madduck@madduck.net>
5 # Released under the terms of the Artistic Licence 2.0
6 #
7 # Source repository: http://git.madduck.net/v/etc/zsh.git
8 #
9
10 # allow 700ms between esc and subsequent character
11 KEYTIMEOUT=70
12
13 # do not consider '/' to be part of a word, i.e. delete-word
14 # iterates through URL components
15 WORDCHARS="${WORDCHARS//\/}"
16
17 # esc-= :: Repeat the previous shell-word ($WORDCHARS)
18 bindkey '\e=' copy-prev-shell-word
19
20 # esc-q :: allow for better ad-hoc multiline editing
21 bindkey '\eq' push-line-or-edit
22
23 # Perform history expansion and insert a space into the buffer.
24 bindkey ' ' magic-space
25
26 # Automatically escape URLs
27 autoload -U url-quote-magic
28 zle -N self-insert url-quote-magic
29 # … even when pasted
30 autoload -U bracketed-paste-magic
31 zle -N bracketed-paste bracketed-paste-magic
32
33 # Change defaults and remove {} from the meta characters, as we often use them
34 # in the shell to create multiple URLs, e.g. http://example.org/{1,2,3}.txt
35 zstyle ':url-quote-magic:*' url-metas '*?[]^(|)~#='
36
37 # Allow editing of the command line using $EDITOR with esc-e
38 autoload -U edit-command-line
39 zle -N edit-command-line
40 bindkey '\ee' edit-command-line
41
42 # Bind esc-u/-U to insert date-/timestamp based on shell timezones
43 # (esc-t/-T does it from urxvt in the local timezone
44 _insert_datestamp() { LBUFFER+=${(%):-'%D{%Y-%m-%d}'}; }
45 zle -N insert-datestamp _insert_datestamp
46 bindkey '\eu' insert-datestamp
47 _insert_timestamp() { LBUFFER+=${(%):-'%D{%Y-%m-%d-%H%M%S}'}; }
48 zle -N insert-timestamp _insert_timestamp
49 bindkey '\eU' insert-timestamp
50
51 # Jump behind the first word (and the space) on the cmdline to add options
52 function _jump_after_first_word() {
53   emulate -L zsh
54   local words
55   words=(${(z)BUFFER})
56
57   if (( ${#words} <= 1 )) ; then
58     CURSOR=${#BUFFER}
59   else
60     CURSOR=$((${#${words[1]}}+1))
61   fi
62 }
63 zle -N _jump_after_first_word
64 bindkey '\e1' _jump_after_first_word
65
66 # ^k :: kill through the end of the line
67 bindkey '^k' kill-line
68
69 # ^? :: borrow backspace behaviour from emacs-mode, rather than stilly limited
70 # viins
71 bindkey $terminfo[kbs] backward-delete-char
72
73 # ^a/^e :: move to beginning and end of line, like emacs
74 bindkey '^a' beginning-of-line
75 bindkey '^e' end-of-line
76
77 # \ew :: print pwd to status line
78 function _whereami() {
79   zle -M "${(%):-"%m:%~"}"
80 }
81 zle -N _whereami
82 bindkey '\ew' _whereami
83
84 # ^x^x :: execute widgets directory
85 bindkey '^x^x' execute-named-cmd
86
87 # vim:ft=zsh