-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.inputrc
289 lines (254 loc) · 13.1 KB
/
shell.inputrc
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
set show-all-if-ambiguous on
set show-all-if-unmodified on
set mark-symlinked-directories on
set completion-prefix-display-length 8
set completion-ignore-case on
set completion-map-case on
set page-completions off
set colored-stats on
set colored-completion-prefix on
set visible-stats on
set input-meta on
set output-meta on
set convert-meta off
$if Bash
# commands
# helper
"\e[1~\eh": "\e[A\C-b\C-b \C-k\C-k" # go to prev. hist. item,
# -> remove all AFTER LAST blank
"\e[1~\em": "\e[A\e[H\C-b \C-u\e[3~\e[F" # go to prev. hist. item,
# -> remove all BEFORE FIRST blank
"\e[1~\e?": "\C-b\C-b?\e[3~\e." # go to prev. char '?', remove it
"\e[1~\el": "\e[1~\el\eh * \e[1~\el\eb" # for loop: full pattern
"\e[1~\el\eh": "for i in" # for loop: header, var $i
"\e[1~\el\eb": "; do echo $i? ; done" # for loop: body, var $i
"\e[2~\el\eh": "for j in" # for loop: header, var $j
"\e[2~\el\eb": "; do echo $j? ; done" # for loop: body, var $j
"\e[99~": "\e[C\e[D"
"\e[5C": "\e[C\e[C\e[C\e[C\e[C"
"\e[7C": "\e[5C\e[C\e[C"
# (h)elp - (l)ong, (s)hort, (m)anpage
"\eh\el": "\e[F --help\C-m\e[1~\eh" # --help
"\eh\es": "\e[F -h\C-m\e[1~\eh" # -h
"\eh\em": "\e[Hman \C-m\e[1~\em" # man {}
# (i)nsert - ($)ubshell, (l)oop, ...
"\eI\e$": "$(?)\e[1~\e? \e[D" # insert subshell $(...)
"\ei\el": "\e[1~\el\C-b\C-b*" # insert for-loop $i
"\ei\el\eb": "\C-b?\C-h\C-h\e[3~" # goto body after for-loop
"\eI\eI": "OLDIFS=$IFS; $IFS=$'\\n'; " # insert IFS backup and set $'\n'
"\eI\eI\eR": "IFS=$OLDIFS " # insert IFS restore
"\ei\eg": "grep '?'\e[1~\e?" # insert grep
"\ei\eg\ee": "grep -E '?' \e[1~\e?" # insert grep -E
"\ei\eg\ev": "grep -v '?' \e[1~\e?" # insert grep -v
"\ei\eg\ee\ev": "grep -Ev '?' \e[1~\e?" # insert grep -Ev
"\ei\es": "sed -re 's|?||'\e[1~\e?" # insert sed -re 's|<?>||'
"\ei\es\et": "sed -n '/^?/,/^/p'\e[1~\e?" # insert sed -n '/<?>/,//p'
"\ei\ed": "\e.\C-b ;\C-x\C-x" # insert cmd delimiter at next blank
"\ei\ep": "\e.\C-b |\C-x\C-x" # insert pipe at next blank
# (a)ppend, e.g. (l)oop - (b)ody
"\ea\es": " -e '/?/' \e[1~\e?" # append sed match //
"\ea\es\es": " -e 's/?//' \e[1~\e?" # append sed subst s///
"\ea\ea\es": "\e[F\ea\es" # append sed match //
"\ea\ea\es\es": "\e[F\ea\es\C-s" # append sed subst s///
# (p)ipe to (a)pp, e.g. (p)ipe to (g)rep
"\ep\eg": " | \ei\eg\e[99~" # pipe to grep
"\ep\eg\ee": " | \ei\eg\ee\e[99~" # pipe to grep -E
"\ep\eg\ev": " | \ei\eg\ev\e[99~" # pipe to grep -v
"\ep\eg\ee\ev": " | \ei\eg\ee\ev" # pipe to grep -Ev
"\ep\es": " | \ei\es\e[99~" # pipe to sed s///
"\ep\es\et": " | \ei\es\et" # pipe to sed token extractor
"\ep\ea": " | awk '{print ?}' \e[1~\e?" # pipe to awk
"\ep\ea\en": " | awk NF" # pipe to awk NF / remove empty lines
"\ep\ex": " | xargs " # pipe to xargs
"\ep\ex\en": " | xargs -n1 " # pipe to xargs -n1
"\ep\ex\en\ei": " | xargs -n1 -i " # pipe to xargs -n1 -i
"\ep\el": " | less " # pipe to less
"\ep\et": " | tail " # pipe to tail
"\ep\et\ef": " | tail -f " # pipe to tail -f
"\ep\er": " | read X\e[D" # pipe to read
"\ep\ep\ep": " | perl -pe '?'\e[1~\e?" # pipe to perl -pe
"\ep\ep": " | perl -ne '?'\e[1~\e?" # pipe to perl -ne
"\ep\ew": " | wc -l " # pipe to wc -l
"\ep\ew\ec": " | wc -c " # pipe to wc -c
"\ep\et": " | tee " # pipe to tee
"\ep\et\ea": " | tee -a " # pipe to tee -a
"\eP\eS": " | sort " # pipe to sort
"\eP\eS\eU": " | sort -u " # pipe to sort -u
# at (e)ol (p)ipe to (a)pp, e.g. (e)ol (p)ipe to (g)rep
"\ee\ep\eg": "\e[F\ep\eg\e[99~" # pipe at EOL to grep
"\ee\ep\eg\ee": "\e[F\ep\eg\ee\e[99~" # pipe at EOL to grep -E
"\ee\ep\eg\ev": "\e[F\ep\eg\ev\e[99~" # pipe at EOL to grep -v
"\ee\ep\eg\ee\ev": "\e[F\ep\eg\ee\ev\e[99~" # pipe at EOL to grep -Ev
"\ee\ep\es": "\e[F\ep\es\e[99~" # pipe at EOL to sed s///
"\ee\ep\es\et": "\e[F\ep\es\et\e[99~" # pipe at EOL to sed token extractor
"\ee\ep\ea": "\e[F\ep\ea\e[99~" # pipe at EOL to awk
"\ee\ep\ea\en": "\e[F\ep\ea\en\e[99~" # pipe at EOL to awk NF / remove empty lines
"\ee\ep\ex": "\e[F\ep\ex\e[99~" # pipe at EOL to xargs
"\ee\ep\ex\en": "\e[F\ep\ex\en\e[99~" # pipe at EOL to xargs -n1
"\ee\ep\ex\en\ei": "\e[F\ep\ex\en\ei\e[99~" # pipe at EOL to xargs -n1 -i
"\ee\ep\el": "\e[F\ep\el\e[99~" # pipe at EOL to less
"\ee\ep\et": "\e[F\ep\et\e[99~" # pipe at EOL to tail
"\ee\ep\et\ef": "\e[F\ep\et\ef\e[99~" # pipe at EOL to tail -f
"\ee\ep\er": "\e[F\ep\er\e[99~" # pipe at EOL to read
"\ee\ep\ep\ep": "\e[F\ep\ep\ep\e[99~" # pipe at EOL to perl -pe
"\ee\ep\ep": "\e[F\ep\ep\e[99~" # pipe at EOL to perl -ne
"\ee\ep\ew": "\e[F\ep\ew\e[99~" # pipe at EOL to wc -l
"\ee\ep\ew\ec": "\e[F\ep\ew\ec\e[99~" # pipe at EOL to wc -c
"\ee\ep\et": "\e[F\ep\et\e[99~" # pipe at EOL to tee
"\ee\ep\et\ea": "\e[F\ep\et\ea\e[99~" # pipe at EOL to tee -a
"\ee\eP\eS": "\e[F\eP\eS\e[99~" # pipe at EOL to sort
"\ee\eP\eS\eU": "\e[F\eP\eS\eU\e[99~" # pipe at EOL to sort -u
# (r)edirect std(o)ut, std(e)rr or (a)ll (to (n)ull)
"\er\eo": " 1> "
"\er\ee": " 2> "
"\er\ea": " >& "
"\er\eo\en": " 1> /dev/null"
"\er\ee\en": " 2> /dev/null"
"\er\ea\en": " >& /dev/null"
# pr(e)fix or e(x)ecute prefixed line: e.g. (e)xport, (s)udo, ...
"\ee\ee": "\e.\e[Hexport \C-x\C-x\e[7C"
"\ee\es": "\e.\e[Hsudo \C-x\C-x\e[5C"
"\ex\ee": "\ee\ee\C-m"
"\ex\es": "\ee\es\C-m"
# (g)it helpers
"\eg":''
"\eg\es": "git status -s -uno\n"
"\eg\es\ea": "git status\n"
"\eg\ea": "git add "
"\eg\ec": "git commit -m '?'\e[1~\e?"
"\eg\ec\ea": "git commit -am '?'\e[1~\e?"
"\eg\ed": "git difftool "
"\eg\ep": "git pull\n"
"\eg\ep\ep": "git push\n"
"\eG\eC": "git checkout\C-i"
# embrace line
"\e$": "\e[H$\(\e[F) " # subshell $(..)
"\e\"": "\e[H\"\e[F\" " # quote "..."
"\e'": "\e[H'\e[F' " # quote '...'
"\el": "\e[H\e[1~\el\eh \e[F\e[1~\el\eb\e[1~\e?\C-i\C-i" # for loop $i
"\el\ej": "\e[H\e[2~\el\eh \e[F\e[2~\el\eb\e[1~\e?\C-i\C-i" # for loop $j
"\eI" "\e[H\eI\eI\e[F; \eI\eI\eR" # IFS=$'\n' and reset
# comments
"\e+": "\e.\e[H\e[3~\C-x\C-x\e[D" # uncomment (see \e#)
"\e+\e+": "\e+\e[F" # uncomment, enforce cursor to end
# move cursor
"\e[1;7H": "\C-b\C-b " # backward to next blank
"\e[1;7F": "\C-b " # forward to next blank
# session
"\C-x\C-d": "history -r \er\C-D"
$endif
# admin helpers
"\C-v": quoted-insert
"\C-x\C-r": re-read-init-file
"\C-x\C-v": display-shell-version
# macro recording
"\e[1;5P": start-kbd-macro # Ctrl + F1
"\e[1;5Q": end-kbd-macro # Ctrl + F2
"\e[1;5R": call-last-kbd-macro # Ctrl + F3
"\e[1;5S": print-last-kbd-macro # Ctrl + F4
"\e[15;5~": dump-macros # Ctrl + F5
# (shell-)completion
"\ey": menu-complete
"\ex": menu-complete-backward
"\C-i": complete
# Actually most of the following completion looks useful
# when you don't use a state of the art competion system.
# But the first 3 (maybe 4) are really useful.
"\e(": complete-into-braces # :-)
"\ed": dabbrev-expand # :-)
"\eh": dynamic-complete-history # :-)
"\ep": possible-completions # :-)
"\e!\el": possible-command-completions
"\e/\el": possible-filename-completions
"\e@\el": possible-hostname-completions
"\e~\el": possible-username-completions
"\ev\el": possible-variable-completions
"\e!": complete-command
"\e/": complete-filename
"\e@": complete-hostname
"\e~": complete-username
"\ev": complete-variable
"\C-g\C-w": glob-complete-word
"\C-g\C-w\C-x": glob-expand-word
"\C-g\C-l\C-x": glob-list-expansions
"\ec": insert-completions
"\eH": history-expand-line
# # history: navigate and search
"\e[A": previous-history # <up>
"\e[B": next-history # <down>
"\e[1;3A": history-search-backward # Meta + <up>
"\ep": history-search-backward # Meta + p
"\e[1;3B": history-search-forward # Meta + <down>
"\en": history-search-forward # Meta + n
"\e[1;4A": history-substring-search-backward # Meta + Shift + <up>
"\e\C-p": history-substring-search-backward # Meta + Ctrl + b
"\e[1;4B": history-substring-search-forward # Meta + Shift + <down>
"\e\C-n": history-substring-search-forward # Meta + Ctrl + n
"\e[1;5A": beginning-of-history # Ctrl + <up>
"\e[1;5B": end-of-history # Ctrl + <down>
"\C-r": reverse-search-history
"\C-s": forward-search-history
# editor: overall
"\e[2~": overwrite-mode # Insert
"\C-l": clear-screen
"\e\C-l": clear-screen
"\e:": delete-horizontal-space
# editor: LINES: move, delete, modify
"\e[H": beginning-of-line # Home
"\e[F": end-of-line # End
"\e[1;3F": kill-line # Meta + Fn + =>
"\e[1;5F": kill-line # Ctrl + Fn + =>
"\e[1;3H": backward-kill-line # Meta + Fn + <=
"\e[1;5H": backward-kill-line # Ctrl + Fn + <=
"\C-x\e[4~": kill-line # Ctrl + x + End
"\C-x\e[1~": backward-kill-line # Ctrl + x + Home
"\C-x\C-r\C-l": redraw-current-line
"\C-u": unix-line-discard
"\C-k": kill-line
"\C-u\C-u": kill-whole-line
# editor: WORDS: move, delete, modify
"\e[1;3C": forward-word # Meta + =>
"\e[1;3D": backward-word # Meta + <=
"\e[1;5C": forward-word # Ctrl + =>
"\e[1;5D": backward-word # Ctrl + <=
"\e[1;4C": kill-word
"\e[3;5~": kill-word
"\e[1;4D": backward-kill-word # Meta + Shift + <=
"\e\C-?": backward-kill-word # Meta + Backspace
"\C-h": backward-kill-word # Ctrl + Backspace / Ctrl + H
"\ew\eu": upcase-word
"\ew\ed": downcase-word
"\ew\ec": capitalize-word
"\e\C-t": transpose-words
# editor: CHARS: move, delete, modify
"\e[C": forward-char # =>
"\e[D": backward-char # <=
"\e[3~": delete-char # Del
"\C-?": backward-delete-char # Backspace
"\C-b": character-search
"\C-b\C-b": character-search-backward
"\et": transpose-chars
# editor: MISC: insert, expand and query data
"\e#": insert-comment
"\ea": insert-last-argument
"\C-x\C-x": exchange-point-and-mark
"\C-@": set-mark
"\e.": set-mark
"\C-x\C-k": kill-region
# # dump-functions (not bound)
# # dump-variables (not bound)
# # alias-expand-line (not bound)
# editor: copy, paste, insert, undo, discard, accept
"\C-y\C-r": copy-region-as-kill
"\C-y\C-b": copy-backward-word
"\C-y\C-f": copy-forward-word
"\C-y": yank
"\e_": yank-last-arg
"\e=": yank-nth-arg
"\ev": yank-pop
"\ez": undo
"\eu": undo
"\er": revert-line
"\C-m": accept-line
"\C-o": operate-and-get-next
"\C-x\C-e": edit-and-execute-command