leo-arch / clifm

The shell-like, command line terminal file manager: simple, fast, extensible, and lightweight as hell.
https://github.com/leo-arch/clifm/wiki
GNU General Public License v2.0
1.29k stars 41 forks source link

Clear Terminal only when changing directory #292

Closed theRoboxx closed 2 weeks ago

theRoboxx commented 2 weeks ago

Is your feature request related to a problem? Please describe. Sometimes there is a lot of output and overflow from an application output text that I want to read. But currently, the text will me cleared, if it overflows the window. Additionally I want to clear the screen automatic when switching the directory for better visibility.

Describe the solution you'd like There should be a new option to only clear the terminal window when switching the directory and NOT when the output of an application is too much to display in the current window. tl;dr: Only clear terminal when switching directory and never otherwise.

leo-arch commented 2 weeks ago

the text will me cleared, if it overflows the window

This is not intended behavior. When ClearScreen is set to true (default) the screen is cleared and the current list of files reprinted whenever some file has been added and/or removed/renamed, but not when the output of a command overflows the window. However, it might happen that sometimes your shell command does modify the files list (in which case the list of files is reprinted) and you still need to read the output (which at this point is lost).

Could you provide an example command?

leo-arch commented 2 weeks ago

With the latest commit, you can set ClearScreen to internal in the config file to prevent external commands, even if they create/remove/rename a file in the current directory, from refreshing the current list of files. For example:

echo "test" > myfile

Will not refresh the screen (since echo is an external command). But,

n myfile

will, because n is an internal command.

theRoboxx commented 2 weeks ago

Thanks, this behavior is much better but for my use case there is something missing.

Would it be possible to clear and refresh the screen only if switching the directory but if you add/remove files in the current directory and there is already some written output, the list of the current files/folders is refreshed AND the old terminal output is still present and not deleted?

For example if I run:

echo "test" > myfile

and

r myfile

I would like to get a refresh of the file list with myfile missing but still seeing the written command

<0> $ echo "test" > myfile
<0> r myfile

in the terminal.

theRoboxx commented 2 weeks ago

Maybe this is a more precise explanation: It would be like setting ClearScreen=false and AutoLs=true. but with the addition that the file/folder list gets refreshed on top and not in a new line and the commands from the past are still visible while in the directory.

leo-arch commented 2 weeks ago

I would like to get a refresh of the file list with myfile missing but still seeing the written command

This would be easier if we were using a curses environment, where you have multiple independent screens or panes. But don't use curses, and this means: we have only one screen. If we reprint the files list, previous output is lost.

However, we do keep a commands history, so that it is theoretically possible to keep those commands executed in the current directory in sight (though this does not include shell commands output) even if the files list is reprinted.

What we need is a good way (and a simple logic) to know what commands to keep in sight.

leo-arch commented 2 weeks ago

This is what I came up with: by setting PrintDirCmds to true in the config file, commands executed in the current directory will be printed before the prompt, but only while you are in the current directory: change the directory and this commands list will be lost.

Give it a shot and let me know what you think.

theRoboxx commented 2 weeks ago

Works great :100: . I will use it a bit and give feedback if somethings breaks.

Thanks again for implementing this feature ^_^.