tldr-c-client icon indicating copy to clipboard operation
tldr-c-client copied to clipboard

Improve complete.bash

Open lakshayrohila opened this issue 1 year ago • 1 comments
trafficstars

What does it do?

Improves complete.bash by:

  • removing the redundant loop in _tldr_get_files(), which does nothing but re-echoes the same output.
  • removing the redundant | sort | uniq calls.
  • the _tldr_get_files() now only returns the matching results, instead of returning thousands of lines each time.
  • applies fix similar to #105 for bash.
  • earlier version could not actually autocomplete on cases such as --vers, which it should autocomplete. This version would autocomplete in that case to tldr --version.
  • earlier not all command line options were present in this file (such as --verbose); this version adds them.

Why the change?

The autocomplete function almost freezes (on my system) for almost 20 secs (I am using it in bash). This is due to the above reasons. This version reduces that time to almost instantaneous.

How can this be tested?

Install the autocomplete file just as is described in this repo's README.md, and try to use completion (with tab key press) in bash.

Where to start code review?

I've already mentioned the major changes in the What does it do? section.

Questions?

N/A

Checklist

  • [x] I have checked there aren't any existing PRs open to fix this issue/add this feature.
  • [ ] I have compiled the code with make and tested the change in an active installation with sudo make install.

Notes for (2) : Since this is not a change in the code for the actual tldr program, I have not run (2); but rather tested the change with the steps I mentioned in How can this be tested? section.

lakshayrohila avatar Feb 15 '24 15:02 lakshayrohila

Thanks for the quick fix @lakshayrohila !

elliotfontaine avatar May 05 '24 22:05 elliotfontaine