0

On macOS, when I do wp @alias post edit 1 I get nano. The same happens when I do EDITOR=emacs wp @alias post edit 1. I want emacs, My EDITOR is set to emacs. How do I get emacs?

Note that env|grep nano doesn't return anything. And most of the time the EDITOR var seems to work just fine.

I found this in the documentation:

To set an environment variable on demand, simply place the environment variable definition before the WP-CLI command you mean to run.

# Use vim to edit a post
$ EDITOR=vim wp post edit 1

To set the same environment variable value for every shell session, you’ll need to include the environment variable definition in your ~/.bashrc or ~/.zshrc file

# Always use vim to edit a post
export EDITOR=vim

So this looks like a bug to me. And someone else was having a very similar issue, but it wasn't deemed to be a bug, and I haven't found a solution so far.

When I run wp post edit 1 on my server it works fine. I'm guessing the problem is related to getenv and using wp-cli remotely. I tried settings EDITOR=emacs in various places (through this ServerFault answer), but no luck so far.

Even after adding a symlink from nano to emacs inside /usr/local/bin, wp-cli still insists on opening /usr/bin/nano despite my PATH preference for /usr/local/bin.

  • Does that happen without an @alias as well? – leymannx Jun 9 at 22:33
0

I thought the command must be typed like so:

$ export EDITOR=emacs; wp post edit 1

Which is exactly how it's working for me on my 10.14.5 macOS right now. And on Linux as well.


Maybe something is misconfigured on your Mac. Or @alias is interfering. Can you try to rerun that command without @alias or on a fresh macOS installation?

  • No it must not. It can be typed like this, but it's slightly different. And no, unfortunately this doesn't give me the desired result either. – guaka Jun 9 at 22:14
  • 1
    Yeah it's a good idea to run wp locally, I'm pursuing this now. First have to set up mysql locally (again). Will update here with my findings. – guaka Jun 10 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.