gokcehan / lf

Terminal file manager
MIT License
7.62k stars 324 forks source link

nicer rendering of previews for bindings #363

Open mohkale opened 4 years ago

mohkale commented 4 years ago

at the moment lf just seems to specify the name of the command for a binding, and then a list of the arguments that're passed to it. At the very least for complicated push commands, this results in some really unreadable text.

For eg.

20200528-39-16

Would it be possible to substitute keys into the help string where possible, for example <space> in my binding for

map ,x push !echo<space>"${fs:-$f}"<space>|<space>tr<space>'\n'<space>'\0'<space>|<space>xargs<space>-r0<space>-I%<space>

or is there intention to add a command to set the help string shown on a binding.

map ,x push !some long obnoxious command
doc ,x short-and-simple
gokcehan commented 4 years ago

@mohkale For shell command bindings, only the first line is shown so users can add a comment line as the first line to be shown as the documentation. For : command bindings, this does not work since I think we parse the command beforehand and strip the comments in the lexer. It may be nice to make it work like shell commands but I'm not sure if it's possible.

mohkale commented 4 years ago

For shell command bindings, only the first line is shown so users can add a comment line as the first line to be shown as the documentation

@gokcehan I'm not sure what you mean by this, could you share an example?

gokcehan commented 4 years ago

@mohkale Sure, for example the following keybinding:

map aa ${{
    # create a new git repo
    git init
    host='https://github.com'
    printf "host [https://github.com]: "
    read host
    host=${host:-https://github.com}
    printf "path (user/repo): "
    read path
    git remote add origin ${host}/${path}.git
    touch README.md
    git add README.md
    git commit -m 'initial commit'
}}

shows up as:

aa      ${{ # create a new git repo ... }}

We should probably add such an example to our tips wiki.