When editor commands throw the error above, you can fix by exporting TERM:
export TERM=xterm
Credits to slowbro