lf
lf copied to clipboard
Wrong number of column
problem
I use this setting to set ratio of lf automatically.
%{{
w=$(tput cols)
if [ $w -le 80 ]; then
lf -remote "send $id set ratios 1:2"
elif [ $w -le 160 ]; then
lf -remote "send $id set ratios 1:2:3"
else
lf -remote "send $id set ratios 1:2:3:5"
fi
}}
But after upgrading my system yesterday, the column always be 80.
The command I type in lf %tput cols
always get 80. No matter how I resize my terminal.
System version
OS: 5.15.2-arch1-1 bash: 5.1.8
I believe the relevant change in your system is the latest ncurses
version (also happened in mine after such update), which is v6.3-1
@gokcehan I'm still experiencing this issue, can you reproduce the fact that %tput cols
always returns 80
from lf
?
@BachoSeven Sorry I thought your previous response was a solution. I didn't read it carefully. I can reproduce this on my machine as well. I'm marking this as a bug. An easy workaround is to use $
command instead:
${{
w=$(tput cols)
if [ $w -le 80 ]; then
lf -remote "send $id set ratios 1:2"
elif [ $w -le 160 ]; then
lf -remote "send $id set ratios 1:2:3"
else
lf -remote "send $id set ratios 1:2:3:5"
fi
}}
It might also be possible to export a variable with the number of columns before launching lf
and use that variable in the command instead of running tput cols
.
@gokcehan Thanks very much for the workaround; will update the wiki example for now since it might be an issue or change of behaviour with ncurses
and not with lf
.
If I got your final comment correctly, what you're saying is that since we don't use the async %
we could export a variable before launching lf
in order to speed things up; however I just realised that, at least in bash
and zsh
, that is already being done by the shell, and was able to do %echo $COLUMNS
successfully from within lf
. So an alternative (for those using zsh/bash
at least, so will not put this in wiki for now) could be:
%{{
w=$COLUMNS
if [ $w -le 80 ]; then
lf -remote "send $id set ratios 1:2"
elif [ $w -le 160 ]; then
lf -remote "send $id set ratios 1:2:3"
else
lf -remote "send $id set ratios 1:2:3:5"
fi
}}
I have now added $lf_width
and $lf_height
variables so the following should work now:
cmd recol %{{
if [ $lf_width -le 80 ]; then
lf -remote "send $id set ratios 1:2"
elif [ $lf_width -le 160 ]; then
lf -remote "send $id set ratios 1:2:3"
else
lf -remote "send $id set ratios 1:2:3:5"
fi
}}
Closing this issue now. Feel free to report if there's an issue.