Sean Fraser Sean Fraser - 2 years ago 228
Bash Question

Arrow keys not working in shell

I'm getting started with a Laravel 5 project and trying to run some experiments using 'php artisan tinker' (psy shell), but I'm running into some weirdness. In the tinker/psy shell, pressing any of the arrow keys is printing character literals to the screen rather than performing the intended behaviour (move character for left and right, cycle recent commands for up and down).

Up is outputting

Down is outputting
Right is outputting
Left is outputting

This is probably an issue with my terminal and not a Laravel bug. I am getting the same buggy behaviour when running
php -a

I am running terminal on OSX, with an xterm emulation.

Answer Source

The PHP REPL does not implement readline's line editing and history capabilities. I don't know if there's a PHP module that implements it, but you can do:

rlwrap php artisan tinker

You may have to install rlwrap for your OS.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download