bobthecow/psysh

All output is paged with `less` and pager must be manually quit after every command

Closed this issue Β· 6 comments

Thanks so much for Psysh, it's a fantastic tool! πŸ™πŸ»

Since v0.11.3 all output in a console session is paged, even when it doesn't take up the whole screen. It looks like this was intentional, but I initially thought it was a bug in Psysh or an issue with my shell.

Using the pager seems to me like a much worse user experience for a couple reasons:

  • paged output isn't wrapped, so now all output wider than the width of the terminal is cut off and must be scrolled/navigated to
  • the pager is a separate program and has to be exited manually by the user, so every single command entered in a Psysh console/session now requires the extra step of quitting the pager, which slows down working in the console considerably

Would you consider reverting 6794814 or putting it behind a config option? Happy to submit a PR for that myself. Thanks!

All output should always run through the pager. But with the default PsySH settings, it should do the "right thing" with short output, i.e. pass it straight through (that's the -F in the less args). If you're not seeing that behavior, there might be an issue with your pager settings, or with your less implementation, or with my assumptions :)

Can you share the output of \psy\info(), your cli.pager ini setting, and the output of which less?

Looks like I was hasty in my description of what's happening here, sorry about thatβ€”very short output is not paged, you're right.

What was confusing me is that output that is only a few lines but where any of those lines is quite long is paged, horizontally, instead of wrapping. Navigating through it also clears the screen, moving the content, which is annoying if you're in the middle of reading it, and then requires scrolling back up to see earlier output.

Here's a video of what I mean:

Kapture.2022-05-30.at.10.53.52.mp4

I'm not very familiar with pagers and I don't like them, and if that's just me and I'm wrong, or I'm using them wrong, fine πŸ˜‚ for example, it took several steps to get this output because it was paged so I can't select it all at once and had to copy and paste it in multiple smaller chunks.

Is there a way to restore the old behaviour of not paging everything? Would you consider adding an easy way to do that?

Thanks!

\psy\info()

[
  "PsySH version" => "v0.11.5"
  "PHP version" => "8.1.5"
  "OS" => "Darwin"
  "default includes" => []
  "require semicolons" => false
  "error logging level" => 32767
  "config file" => array:3 [
    "default config file" => null
    "local config file" => null
    "PSYSH_CONFIG env" => false
  ]
  "loop listeners" => array:1 [
    0 => "Psy\ExecutionLoop\ProcessForker"
  ]
  "commands" => array:33 [
    "help" => "Psy\Command\HelpCommand"
    "?" => "Psy\Command\HelpCommand"
    "ls" => "Psy\Command\ListCommand"
    "dir" => "Psy\Command\ListCommand"
    "dump" => "Psy\Command\DumpCommand"
    "doc" => "Psy\Command\DocCommand"
    "rtfm" => "Psy\Command\DocCommand"
    "man" => "Psy\Command\DocCommand"
    "show" => "Psy\Command\ShowCommand"
    "wtf" => "Psy\Command\WtfCommand"
    "last-exception" => "Psy\Command\WtfCommand"
    "wtf?" => "Psy\Command\WtfCommand"
    "whereami" => "Psy\Command\WhereamiCommand"
    "throw-up" => "Psy\Command\ThrowUpCommand"
    "timeit" => "Psy\Command\TimeitCommand"
    "trace" => "Psy\Command\TraceCommand"
    "buffer" => "Psy\Command\BufferCommand"
    "buf" => "Psy\Command\BufferCommand"
    "clear" => "Psy\Command\ClearCommand"
    "edit" => "Psy\Command\EditCommand"
    "sudo" => "Psy\Command\SudoCommand"
    "history" => "Psy\Command\HistoryCommand"
    "hist" => "Psy\Command\HistoryCommand"
    "exit" => "Psy\Command\ExitCommand"
    "quit" => "Psy\Command\ExitCommand"
    "q" => "Psy\Command\ExitCommand"
    "migrate" => "Illuminate\Database\Console\Migrations\MigrateCommand"
    "migrate:install" => "Illuminate\Database\Console\Migrations\InstallCommand"
    "clear-compiled" => "Illuminate\Foundation\Console\ClearCompiledCommand"
    "down" => "Illuminate\Foundation\Console\DownCommand"
    "env" => "Illuminate\Foundation\Console\EnvironmentCommand"
    "optimize" => "Illuminate\Foundation\Console\OptimizeCommand"
    "up" => "Illuminate\Foundation\Console\UpCommand"
  ]
  "updates" => array:4 [
    "update available" => false
    "latest release version" => "v0.11.5"
    "update check interval" => "never"
    "update cache file" => "~/.config/psysh/update_check.json"
  ]
  "pcntl" => array:3 [
    "pcntl available" => true
    "posix available" => true
    "use pcntl" => true
  ]
  "input" => array:3 [
    "interactive mode" => "auto"
    "input interactive" => true
    "yolo" => false
  ]
  "readline" => array:5 [
    "readline available" => true
    "readline enabled" => true
    "readline service" => "Psy\Readline\Libedit"
    "readline library" => "EditLine wrapper"
    "readline name" => "psysh"
  ]
  "output" => array:4 [
    "color mode" => "auto"
    "output decorated" => null
    "output verbosity" => "normal"
    "output pager" => "/usr/bin/less -R -F -X"
  ]
  "history" => array:3 [
    "history file" => "~/.config/psysh/psysh_history"
    "history size" => null
    "erase duplicates" => null
  ]
  "docs" => array:2 [
    "manual db file" => null
    "sqlite available" => true
  ]
  "autocomplete" => array:3 [
    "tab completion enabled" => true
    "bracketed paste" => false
    "custom matchers" => []
  ]
]

ini_get('cli.pager')

""

which less

/usr/bin/less

First, there are a couple of ways to disable output paging, but none of them are super intuitive. I've just added support for setting 'pager' => false in your PsySH config to completely disable output paging. You can try that out by installing the @dev version via Composer.

Second, the pager isn't supposed to be breaking wrapping. Per the options we set for less by default, it should look like this:

Screen Shot 2022-05-30 at 10 09 34 PM

Yours is super obnoxious, and I don't blame you for disliking it :)

… but there does seem to be something goofy about your setup. Are you using it inside screen, maybe?

That new config option works great, thanks so much! Gonna go set that globally.

There could definitely be something weird with my setup, I'll keep digging into it. I'm not using it inside screen, it's via Laravel Tinker but other than that completely vanilla, I haven't intentionally changed any Tinker/PsySH/less configs. I'm using Zsh and iTerm, not sure if that would matter.

I'm curious, is the reasoning for paging output by default now that that was the intention all along? And you consider not paging to have been a bug? Otherwise, feels like a big (breaking?) change to switch the default behaviour.

Okay, I'm done hating on paging πŸ˜… thanks a lot for everything, really appreciate your detailed responses and all your help, and adding that config support!

Yes, paging used to work but at some point it broke for two types of output (return values and stdout). It still worked for everything else. And yes, I do consider that a bug.

I'm open to the idea that people prefer not to have paging by default. If that's the case, making it opt-in is reasonable too. But I do think that it should be consistently applied, which it wasn't before πŸ™‚

Gotcha, definitely a bug. Sorry, didn't mean to imply that you just 'decided' it was buggy and changed itβ€”I thought this was new, didn't know it used to be applied everywhere and had been broken.

Totally agree it should be consistent either way. I may PR a change to the default but I'd want to make sure that's really a widespread preference and not just me πŸ˜