Skip to content

Instantly share code, notes, and snippets.

@apeiros
Created May 7, 2013 17:25
Show Gist options
  • Save apeiros/5534417 to your computer and use it in GitHub Desktop.
Save apeiros/5534417 to your computer and use it in GitHub Desktop.
Enter passwords in pry/irb without echo
require 'io/console' # requires ruby 1.9.3
module PasswordString
def inspect; "[PASSWORD]"; end
def to_s; "[PASSWORD]"; end
def dup; obj=super;obj.extend PasswordString; obj; end
def clone; obj=super;obj.extend PasswordString; obj; end
end
def password
r = $stdin.noecho { gets.chomp }
r.extend PasswordString
r
end
alias secret password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment