ruby / irb

interactive Ruby
BSD 2-Clause "Simplified" License
393 stars 119 forks source link

Feature Request: Equivalent to Pry’s !!! in IRB for Exiting Nested Contexts #915

Closed antonyr closed 8 months ago

antonyr commented 8 months ago

Description

What are your expected behavior and actual behavior of your environment?

Result of irb_info

irb(main):001:0> irb_info
=>
Ruby version: 3.3.0
IRB version: irb 1.12.0 (2024-03-06)
InputMethod: RelineInputMethod with Reline 0.4.3
Completion: Autocomplete, RegexpCompletor
RUBY_PLATFORM: arm64-darwin23
LANG env: en_US.UTF-8
LC_ALL env: en_US.UTF-8
East Asian Ambiguous Width: 1

Terminal Emulator

What's your terminal emulator? Alacritty

Setting Files

Are you using ~/.irbrc and ~/.inputrc? Nope

Feature Request

I propose the introduction of a similar feature in IRB. While IRB allows users to exit sessions with exit or quit, and to navigate out of nested contexts by repeatedly using these commands, an equivalent single command to Pry's !!! would enhance the user experience.

Expected Behavior

The implementation of this feature would provide a single command that, when executed, would immediately exit all nested contexts and return the user to the top-level binding. If executed at the top-level, it would exit the IRB session.

Actual Behavior

Currently, users must manually issue the exit or quit command multiple times to navigate out of nested contexts or end the session.

Steps to Reproduce

  1. Enter a nested context in IRB (e.g., by opening a class or module definition).
  2. Attempt to exit to the top-level binding or end the session with a single command (current behavior requires multiple exit or quit commands).

Additional Context

This feature would align IRB more closely with Pry in terms of usability and provide a smoother workflow for developers who frequently work with nested contexts.

Thank you for considering this feature request.

st0012 commented 8 months ago

IRB has a command called exit!, which should do exactly this. Can you give it a try?

antonyr commented 8 months ago

@st0012 Thank you so much. It works at best.