gokcehan / lf

Terminal file manager
MIT License
7.8k stars 330 forks source link

Add `on-init` hook command #1838

Closed joelim-work closed 2 weeks ago

joelim-work commented 2 weeks ago

See https://github.com/gokcehan/lf/discussions/1767#discussioncomment-9942888 for more details.

If autoquit is enabled, then running lf -remote commands immediately in the config file will fail as the server hasn't started yet. This change adds an on-init hook command, for anything that should run after lf has finished initializing and connecting to the server.

set autoquit true
set drawbox true

cmd on-redraw &{{
    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
}}

cmd on-init on-redraw

# the following will not work if used instead of `on-init`
# on-redraw