pry-fkeys 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gemspec +16 -0
- data/.gitignore +2 -0
- data/Gemfile +2 -0
- data/Guardfile +2 -0
- data/LICENSE.txt +1 -0
- data/README.rdoc +24 -0
- data/Rakefile +1 -0
- data/lib/pry-fkeys.rb +148 -0
- data/lib/pry-fkeys/version.rb +3 -0
- data/test/test_helper.rb +2 -0
- metadata +78 -0
data/.gemspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'working/gemspec'
|
3
|
+
$:.unshift 'lib'
|
4
|
+
require 'pry-fkeys'
|
5
|
+
require 'pry-fkeys/version'
|
6
|
+
|
7
|
+
Working.gemspec(
|
8
|
+
:name => 'pry-fkeys',
|
9
|
+
:summary => Working.third_line_of_readme,
|
10
|
+
:description => Working.third_line_of_readme,
|
11
|
+
:version => PryFkeys::VERSION,
|
12
|
+
:authors => %w(☈king),
|
13
|
+
:email => 'pry-fkeys@sharpsaw.org',
|
14
|
+
:github => 'rking/pry-fkeys',
|
15
|
+
:deps => %w(pry),
|
16
|
+
)
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Copyleft (ↄ) 2013 ☈king — Absolutely CC0 / Public Domain.
|
data/README.rdoc
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
= pry-fkeys
|
2
|
+
|
3
|
+
Help the user get to a place where the speedy F8/F10/F11/etc keys work.
|
4
|
+
|
5
|
+
At some point, it might be fully automated. For now, it just warns when:
|
6
|
+
|
7
|
+
- The weaksauce 'EditLine' Readline is used instead of the GNU Readline one,
|
8
|
+
- The F-key bindings are not in ~/.inputrc
|
9
|
+
|
10
|
+
== The Shortcuts
|
11
|
+
|
12
|
+
[+F4+] ls -l (show all locally-defined variables and values)
|
13
|
+
[+F5+] whereami (show the code context)
|
14
|
+
[+F6+] up (a frame, depends on pry-stack_explorer, as does the next one)
|
15
|
+
[+F7+] down
|
16
|
+
[+F8+] continue (depends on pry-debugger, as do step/next/finish)
|
17
|
+
[+Shift-F8+] try-again (restart from last 'raise', depends on pry-rescue)
|
18
|
+
[+F10+] next (run the current statement)
|
19
|
+
[+F11+] step (step into the next method call)
|
20
|
+
[+Shift-F11+] finish (get back out of the last 'step')
|
21
|
+
|
22
|
+
== Why It's Ugly
|
23
|
+
|
24
|
+
Because it supports vi *and* emacs keys, in a few different terminal mappings.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'working/rake_tasks'
|
data/lib/pry-fkeys.rb
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'pry'
|
2
|
+
|
3
|
+
module PryFkeys
|
4
|
+
class << self
|
5
|
+
def inputrc_path; File.expand_path '~/.inputrc' end
|
6
|
+
|
7
|
+
def on_clunky_readline?
|
8
|
+
Readline::VERSION[/edit/i]
|
9
|
+
end
|
10
|
+
|
11
|
+
def inputrc_customized_for_ruby?
|
12
|
+
File.exists? inputrc_path and File.read(inputrc_path)[/\$if\s*Ruby/]
|
13
|
+
end
|
14
|
+
|
15
|
+
def install_comma_debugging_aliases
|
16
|
+
psuedo_alias ',s', 'step'
|
17
|
+
psuedo_alias ',n', 'next'
|
18
|
+
psuedo_alias ',c', 'continue'
|
19
|
+
psuedo_alias ',f', 'finish'
|
20
|
+
|
21
|
+
psuedo_alias ',w', 'whereami'
|
22
|
+
|
23
|
+
# ,, aliases all the ",cmd"s to "cmd". Undo with a second ",,"
|
24
|
+
command ',,',
|
25
|
+
'toggle ,-prefixes off/on commands, for terse input' do
|
26
|
+
abbreviations = []
|
27
|
+
commands.keys.reject do |cmd|
|
28
|
+
cmd.class != String or cmd[0] != ',' or cmd == ',,'
|
29
|
+
end.each do |e|
|
30
|
+
terse = e[1..-1]
|
31
|
+
# TODO: check to see if you're stomping on something, first.
|
32
|
+
Pry.commands.alias_command terse, e
|
33
|
+
abbreviations << terse
|
34
|
+
end
|
35
|
+
Pry.commands.command ',,', 'unsplat all ,-commands' do
|
36
|
+
abbreviations.each do |too_terse|
|
37
|
+
Pry.commands.delete too_terse
|
38
|
+
end
|
39
|
+
end
|
40
|
+
Pry.output.puts "Added commands: #{abbreviations.join ' '}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def explain
|
45
|
+
Pry.output.puts <<-EOT
|
46
|
+
\e[32mThese are the current bindings:\e[0m
|
47
|
+
|
48
|
+
#{THE_WHOLE_POINT}
|
49
|
+
|
50
|
+
If you:
|
51
|
+
- Paste that into ~/.inputrc (or run inputrc! from Pry)
|
52
|
+
- Restart pry
|
53
|
+
Then it should be fully functional; if it isn't, please file an issue:
|
54
|
+
https://github.com/rking/pry-fkeys/issues
|
55
|
+
|
56
|
+
Or, if you just want to suppress the warning, you can put '$if Ruby' anywhere in
|
57
|
+
~/.inputrc and it'll stop bothering you.
|
58
|
+
EOT
|
59
|
+
'Almost there...'
|
60
|
+
end
|
61
|
+
|
62
|
+
def append!
|
63
|
+
warning = "\e[31mFound '$if Ruby' block, but running anyway...\e[0m\n" \
|
64
|
+
if inputrc_customized_for_ruby?
|
65
|
+
Pry.output.puts "#{warning}Saving F-keys bindings to #{inputrc_path}"
|
66
|
+
File.open inputrc_path, 'a' do |f|
|
67
|
+
f.write THE_WHOLE_POINT
|
68
|
+
end
|
69
|
+
'Done - Restart pry to see the effects'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
if on_clunky_readline?
|
74
|
+
warn <<-EOT
|
75
|
+
\e[31mPry-de found EditLine's Readline wrapper.\e[0m
|
76
|
+
For the full keyboard experience, install GNU Readline:
|
77
|
+
|
78
|
+
# For RVM:
|
79
|
+
#
|
80
|
+
brew install readline
|
81
|
+
brew link readline
|
82
|
+
echo ruby_configure_flags=--with-readline-dir=/usr/local/opt/readline >> \
|
83
|
+
~/.rvm/user/db
|
84
|
+
rvm reinstall #{RUBY_VERSION}
|
85
|
+
|
86
|
+
# For rbenv:
|
87
|
+
brew install readline ruby-build
|
88
|
+
export CONFIGURE_OPTS=--with-readline-dir=`brew --prefix readline`
|
89
|
+
rbenv install #{RUBY_VERSION} # or #{RUBY_VERSION}-pNNN
|
90
|
+
EOT
|
91
|
+
install_comma_debugging_aliases
|
92
|
+
end
|
93
|
+
|
94
|
+
unless inputrc_customized_for_ruby?
|
95
|
+
warn <<-EOT
|
96
|
+
Pry-de found no Ruby customization in ~/.inputrc. Run 'inputrc?' to learn more.
|
97
|
+
EOT
|
98
|
+
end
|
99
|
+
|
100
|
+
THE_WHOLE_POINT = <<-EOT
|
101
|
+
$if Ruby
|
102
|
+
$if mode=vi
|
103
|
+
set keymap vi-command
|
104
|
+
"[14~": "Ils -l\\n" # <F4>
|
105
|
+
"[15~": "\\C-lIwhereami\\n" # <F5>
|
106
|
+
"[28~": "Iedit -c\\n" # <Shift+F5>
|
107
|
+
"[17~": "Iup\\n" # <F6>
|
108
|
+
"[18~": "Idown\\n" # <F7>
|
109
|
+
"[19~": "Icontinue\\n" # <F8>
|
110
|
+
"[32~": "Itry-again\\n" # <Shift-F8>
|
111
|
+
"[21~": "Inext\\n" # <F10>
|
112
|
+
"[23~": "Istep\\n" # <F11>
|
113
|
+
"[23$": "Ifinish\\n" # Shift+<F11>
|
114
|
+
# Cross-terminal compatibility:
|
115
|
+
"[19;2~": "Itry-again\\n" # <Shift-F8> (xterm/gnome-terminal)
|
116
|
+
"[23;2~": "Ifinish\\n" # Shift+<F11> (xterm/gnome-terminal)
|
117
|
+
"OS": "Ils -l\\n" # <F4>
|
118
|
+
"OA": previous-history
|
119
|
+
"[A": previous-history
|
120
|
+
"OB": next-history
|
121
|
+
"[B": next-history
|
122
|
+
$else
|
123
|
+
# Emacs Bindings:
|
124
|
+
"\\e[14~": "ls -l\\n"
|
125
|
+
"\\e[OS": "ls -l\\n"
|
126
|
+
"\\e[15~": "\\C-lwhereami\\n"
|
127
|
+
"\\e[28~": "edit -c\\n"
|
128
|
+
"\\e[17~": "up\\n"
|
129
|
+
"\\e[18~": "down\\n"
|
130
|
+
"\\e[19~": "continue\\n"
|
131
|
+
"\\e[32~": "try-again\\n"
|
132
|
+
"\\e[19;2~": "try-again\\n"
|
133
|
+
"\\e[21~": "next\\n"
|
134
|
+
"\\e[23~": "step\\n"
|
135
|
+
"\\e[23$": "finish\\n"
|
136
|
+
"\\e[23;2~": "finish\\n"
|
137
|
+
$endif
|
138
|
+
$endif
|
139
|
+
EOT
|
140
|
+
end
|
141
|
+
|
142
|
+
def inputrc?
|
143
|
+
PryFkeys.explain
|
144
|
+
end
|
145
|
+
|
146
|
+
def inputrc!
|
147
|
+
PryFkeys.append!
|
148
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pry-fkeys
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- ☈king
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: pry
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: ! 'Help the user get to a place where the speedy F8/F10/F11/etc keys
|
31
|
+
work.
|
32
|
+
|
33
|
+
|
34
|
+
Help the user get to a place where the speedy F8/F10/F11/etc keys work.
|
35
|
+
|
36
|
+
'
|
37
|
+
email: pry-fkeys@sharpsaw.org
|
38
|
+
executables: []
|
39
|
+
extensions: []
|
40
|
+
extra_rdoc_files: []
|
41
|
+
files:
|
42
|
+
- .gemspec
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- Guardfile
|
46
|
+
- LICENSE.txt
|
47
|
+
- README.rdoc
|
48
|
+
- Rakefile
|
49
|
+
- lib/pry-fkeys.rb
|
50
|
+
- lib/pry-fkeys/version.rb
|
51
|
+
- test/test_helper.rb
|
52
|
+
homepage: https://github.com/rking/pry-fkeys
|
53
|
+
licenses: []
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 1.8.23
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Help the user get to a place where the speedy F8/F10/F11/etc keys work.
|
76
|
+
test_files:
|
77
|
+
- test/test_helper.rb
|
78
|
+
has_rdoc:
|