Skip to content

Instantly share code, notes, and snippets.

@lebeerman
Created November 17, 2023 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lebeerman/0295380b2328a20276b3425e6f689117 to your computer and use it in GitHub Desktop.
Save lebeerman/0295380b2328a20276b3425e6f689117 to your computer and use it in GitHub Desktop.
Pry Help
# Pry Help
## Help
help Show a list of commands or information about a specific command.
## Context
cd Move into a new context (object or scope).
find-method Recursively search for a method within a class/module or the current namespace.
ls Show the list of vars and methods in the current scope.
pry-backtrace Show the backtrace for the pry session.
raise-up Raise an exception out of the current pry instance.
reset Reset the repl to a clean state.
watch Watch the value of an expression and print a notification whenever it changes.
whereami Show code surrounding the current context.
wtf? Show the backtrace of the most recent exception.
## Editing
! Clear the input buffer.
amend-line Amend a line of input in multi-line mode.
edit Invoke the default editor on a file.
hist Show and replay readline history.
play Playback a string variable, method, line, or file as input.
show-input Show the contents of the input buffer for the current multi-line expression.
## Introspection
ri View ri documentation.
show-doc Show the documentation for a method or class.
show-source Show the source for a method or class.
stat View method information and set _file_ and _dir_ locals.
## Commands
import-set Import a pry command set.
## Aliases
!!! Alias for `exit-program`
!!@ Alias for `exit-all`
$ Alias for `show-source`
/whereami[!?]+/ Alias for `whereami`
? Alias for `show-doc`
@ Alias for `whereami`
file-mode Alias for `shell-mode`
find-routes Alias for `find-route`
history Alias for `hist`
quit Alias for `exit`
quit-program Alias for `exit-program`
reload-method Alias for `reload-code`
show-method Alias for `show-source`
show-stack Alias for `stack`
## Byebug
backtrace Display the current stack.
break Set or edit a breakpoint.
continue Continue program execution and end the pry session.
finish Execute until current stack frame returns.
next Execute the next line within the current stack frame.
step Step execution into the next line or method.
## Input and output
.<shell command> All text following a '.' is forwarded to the shell.
cat Show code from a file, pry's input buffer, or the last exception.
change-inspector Change the current inspector proc.
change-prompt Change the current prompt.
clear-screen Clear the contents of the screen/window pry is running in.
fix-indent Correct the indentation for contents of the input buffer
list-inspectors List the inspector procs available for use.
save-file Export to a file using content from the repl.
shell-mode Toggle shell mode. bring in pwd prompt and file completion.
## Misc
pry-version Show pry version.
reload-code Reload the source file that contains the specified code object.
toggle-color Toggle syntax highlighting.
## Navigating pry
!pry Start a pry session on current self.
disable-pry Stops all future calls to pry and exits the current session.
exit Pop the previous binding.
exit-program End the current program.
jump-to Jump to a binding further up the stack.
nesting Show nesting information.
switch-to Start a new subsession on a binding in the current stack.
## Rails
find-route See which urls match a given controller.
recognize-path See which route matches a url.
show-middleware Show all middleware (that rails knows about).
show-model Show the given model.
show-models Show all models.
show-routes Show all routes in match order.
## Pry-byebug (v3.9.0)
exit-all End the current pry session.
# Pry-rescue (v1.5.2)
cd-cause Move to the exception that caused this exception to happen
try-again Re-try the code that caused this exception
# Pry-stack_explorer (v0.6.1)
down Go down to the callee's context.
frame Switch to a particular frame.
stack Show all frames
up Go up to the caller's context.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment