benjaminoakes / homesick-vi-everywhere

A Homesick castle to use vi keybindings everywhere
GNU General Public License v2.0
6 stars 2 forks source link

Add support for Heroku console #1

Open benjaminoakes opened 11 years ago

benjaminoakes commented 11 years ago

heroku run console needs vi mode. (Didn't it used to work on Bamboo?)

ericboehs commented 11 years ago

Anyone had any luck here?

benjaminoakes commented 11 years ago

It hasn't come up often enough for me to fix it yet, but pull requests are always welcome!

ericboehs commented 11 years ago

I'd love to do a pull request, if I had a clue how to get it working.

I guess I could start by diving into heroku's source code.

On Mon, Aug 19, 2013 at 10:00 PM, Ben Oakes notifications@github.com wrote:

It hasn't come up often enough for me to fix it yet, but pull requests are always welcome!

Reply to this email directly or view it on GitHub: https://github.com/benjaminoakes/homesick-vi-everywhere/issues/1#issuecomment-22919620

benjaminoakes commented 11 years ago

At some level, Heroku console's readlines isn't picking up that vi mode should be used. Maybe some configuration could be injected for editrc or inputrc? It might be something rlwrap can help with too (example).

hjdivad commented 10 years ago

script/heroku-console

#!/bin/bash
exec heroku run bash "-i -c 'echo " '"set editing-mode vi"' " > ~/.inputrc; rails console'"
benjaminoakes commented 10 years ago

Sweet, any way to make this an alias or similar so it can be part of this homesick castle?

hjdivad commented 10 years ago

@benjaminoakes unsure. I don't know anything about homesick, I just stumbled on this issue when trying to see if anybody had found a way to get heroku console to run in vi mode and posted my solution in case it might help.

I tried converting the above to an alias, as follows:

$ alias heroku-console='heroku run bash'"-i -c 'echo "'"set editing-mode vi"'" > ~/.inputrc; rails console"

The trouble is bash converts this to a single quoted string with escapes

$ alias heroku-console
alias heroku-console='heroku run bash-i -c '\''echo "set editing-mode vi" > ~/.inputrc; rails console'

Which doesn't work properly when run. I don't understand bash's escaping well enough to quite know why but '\'' isn't escaped the way one might hope.

benjaminoakes commented 10 years ago

Interesting... In any case, I'm having a hard time testing because I'm mostly using Sinatra on Heroku at the moment. It would be nice to have a general solution that doesn't require rails console. I'm not sure how heroku run console knows what to run, but that's a starting point.

hjdivad commented 10 years ago

@benjaminoakes what i posted doesn't really depend on rails console. The general approach is to run heroku run bash with a command that first writes to ~/.inputrc and then runs some arbitrary command. It would be easy to replace "rails console" with "$@". Doing this with an alias might be harder.

Maybe the approach for homesick-vi-everywhere should be to make a bash function and then have an alias that just calls the function?

It's true that I don't know that this is quite the same as running heroku run console. I haven't noticed any differences the last couple of days I've been using the script.

ericboehs commented 9 years ago

When bash alias escaping escapes you, just use a function:

hc() { heroku run bash "-i -c 'echo set editing-mode vi > ~/.inputrc'; rails c" }
ericboehs commented 9 years ago

After further review, I wouldn't recommend adding editing-mode vi this way. It ignores the system inputrc (/etc/inputrc) and also loses standard bindings like Ctrl-A, Ctrl-E, Ctrl-H, Ctrl-T, etc. You also lose word wise movements (Alt-Left/Right).

Instead I'd recommend bringing in your own inputrc using curl. Here's how I have mine set up in my dotfiles:

hc() { heroku run bash "-i -c 'curl -s https://raw.github.com/ericboehs/dotfiles/master/config/inputrc > ~/.inputrc; rails c'" }
benjaminoakes commented 9 years ago

All the key bindings you mention (e.g. Ctrl-A) are Emacs key bindings, so it makes sense that they'd go away. There's nothing wrong with redefining some key bindings like that in personal dotfiles, but I think the simpler inputrc makes more sense for Heroku in the context of these shared dotfiles.

With that in mind, a pull request with this function would be welcome.

ericboehs commented 9 years ago

Indeed but they are also system bindings that many Mac and Linux users find standard in their OS. The word wise movements aren't emacs though. Also when pairing, emacs bindings are usually expected as vi-mode isn't the norm.

hjdivad commented 9 years ago

@ericboehs It's not quite clear to me how your suggestion avoids the complaints you raise. Whether echoing a string literal or retrieving via curl, the problems you raise all stem from writing anything to inputrc, no?

ericboehs commented 9 years ago

That's correct. My inputrc adds back the functionality that creating an inputrc removes. I'm recommending creating a similar inputrc as echoing all of it proved difficult.

If one's aware of the shortcomings and is adverse to hosting their own inputrc online or curling it, then echoing set editing-mode vi may be the preferred solution.

glittershark commented 9 years ago

I wrote a buildpack that uses heroku-buildpack-multi to accomplish this.

benlieb commented 7 years ago

This seems to work for me:

.bash_profile


function hc { 
  heroku run "bash -i -c 'echo set editing-mode vi > ~/.inputrc'; rails c" 
}