Skip to content

Instantly share code, notes, and snippets.

@bcgraham
Created March 30, 2021 15:56
Show Gist options
  • Save bcgraham/f88e7e500e1b933bed1c7077f8682b0e to your computer and use it in GitHub Desktop.
Save bcgraham/f88e7e500e1b933bed1c7077f8682b0e to your computer and use it in GitHub Desktop.
PryKeybind.register(:FRAMES, "\c_") do |pry_instance|
backt = Byebug.current_context.backtrace
result = Fzf(
delimiter: ":",
preview: 'bat --color=always --style=header, numbers -r ( range {3} $LINES) -H {3} ../{2}',
expect: 'ctrl-v'
) do
backt
.map(&:first)
.map(&:to_s)
.map { |l| l.split(":")[0..1] }
.map
.with_index { |(l, r), i| ["% 3d" % i, Pathname(l), r] }
.select { |(i, l, r)| l.exist? }
.map do |a|
[a[0], a[1].relative_path_from(Pathname.pwd.dirname), a[2]].join(":")
end
.join("\n")
end
next if result.nil? || result.empty?
rlines = result.lines
if rlines.first =~ /ctrl-v/
rlines.drop(1).each do |r|
frame, path, line = r.split(":")
path = Pathname(path)
.each_filename
.drop(1)
.reduce(Pathname.pwd, &:join)
.to_s
[path, line].join(?:).to_frame.vim
end
else
frame, path, line = rlines.drop(1).first.split(?:)
pry_instance.run_command("frame #{frame}")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment