Skip to content

Instantly share code, notes, and snippets.

@egwspiti
egwspiti / .pryrc
Last active August 29, 2015 14:28
preserve local variables across 'cd' in pry
class Pry::Command::Cd
def _binding
_pry_.binding_stack.last
end
def save_local_variables(key, b)
state.locals ||= {}
builtin_locals = [:__, :_, :_dir_, :_file_, :_ex_, :_pry_, :_out_, :_in_]
_local_variables = b.eval('local_variables')
@egwspiti
egwspiti / get_pos.rb
Last active October 6, 2024 08:06
pure ruby get terminal cursor position
require 'io/console'
class Cursor
class << self
def pos
res = ''
$stdin.raw do |stdin|
$stdout << "\e[6n"
$stdout.flush
while (c = stdin.getc) != 'R'