Skip to content

Instantly share code, notes, and snippets.

@josh-works
Created March 27, 2017 02:32
Show Gist options
  • Save josh-works/78ac76e49878bd8a4dd7ddd79a5644c1 to your computer and use it in GitHub Desktop.
Save josh-works/78ac76e49878bd8a4dd7ddd79a5644c1 to your computer and use it in GitHub Desktop.

TL;DR

I'd like to alias awesome_print + the _ command in rails console to pp. In other words, I'd like pp[return] to function the same as ap _[return].

Context

As I'm spending more and more time in a rails console session, I'd like to be able to use awesome print to regularly evaluate objects.

I know I can enter ap _ at any time to return the prior object in awesome_print's sweet formatting, but I want to map ap _ to pp.

it takes six keystrokes (including return) to hit ap _, but only three for pp. The problem is, I couldn't figure out a way to alias this inside of my .irbrc.

What I've tried

alias pp="ap _"

causes rails console to "blow up" on load:

/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:241:in `load': /Users/joshthompson/.irbrc:33: syntax error, unexpected tSTRING_BEG (SyntaxError)
alias pp="ap _"
          ^

I tried the instructions here to make aliases via functions in IRB, but no luck.

Do you have any suggestions on where to google next? I've looked all over, but cannot figure out a way to aliase that simple command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment