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
.
@alias
as well?