-
Notifications
You must be signed in to change notification settings - Fork 4
Overwritten Methods
Albert Álef edited this page Feb 3, 2026
·
2 revisions
Some methods have special behavior in RubyShell to provide better Ruby integration.
Unlike the shell cd, RubyShell's cd supports block syntax:
sh do
cd "/var/log" do
# Commands run in /var/log
puts tail("-n", "5", "syslog")
end
# Automatically returns to original directory
endChanges directory permanently for the session:
sh do
cd "/tmp"
pwd # /tmp
endsh do
cd "/var" do
cd "log" do
# Now in /var/log
end
# Back to /var
end
# Back to original directory
endRubyShell's ls overrides IRB's default ls command to provide actual directory listing:
sh do
files = ls.lines
files.each { |f| puts f }
endThis is particularly useful in interactive Ruby sessions (IRB/Pry) where ls would normally show object methods.
Clears the terminal screen:
sh do
clear
endThe implementation can be found in lib/rubyshell/overwrited_commands.rb in the repository.
Next: Debugging