Menu

gitpiper

Pry Cheat Sheet in March 2024

Last Updated: 23 March 2024

README.md

cd

> cd Array
> ls
  Array.methods: [] try_convert
  Array#methods: & * + abbrev assoc at ...
> show-source

Code

> show-method Array#select

Docs

> ri Array
> ri Array#each

> cd Gem
> show-doc try_activate

Finding

> find-method each
  Array#each
  Array#each_index
  Enumerable#each_slice
  ...

Editing

> edit Pry#repl

Gems

> gem-cd foo      # Switch to gem's dir
> gem-install foo
> gem-list

Misc commands

> hist          # History
> wtf?          # Trace of recent exception

Rails

Rails console

Also consider pry-rails.

$ pry -r ./config/environment

Rails

> show-models
> show-routes
> show-middleware

ls

> ls         # All

> ls -m      # Methods
> ls -M      # Instance methods

> ls -g      # Globals
> ls -l      # Local vars
> ls -c      # Constants

> ls -i      # Instance vars

> ls -G xx   # Grey by regex

Shell integration

shell-mode adds dir to the prompt.

pry(main)> shell-mode
pry(main):/home/x $

Commands with . are shell commands.

pry(main)> .cat hello.txt

hirb

Add the hirb gem.

> table User.all
> view User.all
> view User.all, fields: %w[id name email]

pry-rescue

Add the pry-rescue gem.

Pry::rescue {
  # raise exceptions here
}

Or run:

bundle exec rescue rspec

Additional commands:

pry(main)> cd-cause
pry(main)> try-again

pry-remote

Add the pry-remote gem.

# In your code:
binding.remote_pry

# In the shell:
bundle exec pry-remote

338+ more cheat sheets for you in March 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️