Created
August 18, 2011 10:00
-
-
Save levity/1153771 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# america's funniest home ruby tricks: | |
# barebones textmate shell REPL | |
# paste this into a textmate window | |
# type a command at the prompt, then type Cmd-a Ctrl-r | |
prompt = "> " | |
history = DATA.read.split("\n") | |
cmd = history.last.gsub(/^#{prompt}/, '') | |
print "\n#{`#{cmd}`}#{prompt}" | |
__END__ | |
> echo "hello world" | |
hello world | |
> ping -c1 google.com | |
PING google.com (74.125.224.115): 56 data bytes | |
64 bytes from 74.125.224.115: icmp_seq=0 ttl=53 time=18.156 ms | |
--- google.com ping statistics --- | |
1 packets transmitted, 1 packets received, 0.0% packet loss | |
round-trip min/avg/max/stddev = 18.156/18.156/18.156/0.000 ms | |
> ruby -e 'puts "#{RUBY_DESCRIPTION} #metalol"' | |
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0] #metalol | |
> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment