If you want to use autocomplete also for history, you can make it like this:
readline_completion_function(function($input, $index) {
$matches = [];
foreach(readline_list_history() as $match)
if (mb_strpos($match, readline_info("line_buffer")) !== false)
$matches[] = mb_substr($match, $index);
return (count($matches) > 1 && $index) ? [] : $matches;
});