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
|
# File 'lib/pry-editline.rb', line 11
def self.hijack_inputrc
inputrc = [
ENV['INPUTRC'],
(File.expand_path('~/.inputrc') rescue nil),
'/etc/inputrc'
].compact.detect { |x| File.exist?(x) }
require 'tempfile'
@file = Tempfile.new('inputrc')
@file.puts <<-'EOF'
set keymap vi-insert
"\C-a": beginning-of-line
"\C-b": backward-char
"\C-d": delete-char
"\C-e": end-of-line
"\C-f": forward-char
"\C-k": kill-line
"\C-n": next-history
"\C-p": previous-history
"\C-x\C-l": redraw-current-line
"\C-x\C-e": "\C-e \C-a\t\C-k\C-x\C-l"
"\C-o": "\C-e \C-a\t\C-k\C-x\C-l"
set keymap vi-command
"o": "A \C-a\t\C-k\C-x\C-l\e"
"v": "A \C-a\t\C-k\C-x\C-l\e"
set keymap emacs
"\C-x\C-l": redraw-current-line
"\C-x\C-e": "\C-e \C-a\t\C-k\C-x\C-l"
"\C-o": "\C-e \C-a\t\C-k\C-x\C-l"
$if mode=vi
set keymap vi
$endif
EOF
@file.puts "$include #{inputrc}" if inputrc
@file.close
ENV['INPUTRC'] = @file.path
end
|