Feature Request: try detecting common arguments and set up completions (e.g. filenames).
cho-m opened this issue · comments
It would be nice to detect arguments like '<filename>' and automatically add support for completing files on local filesystem.
Could also be considered for main repo's navi --tldr
command.
Examples
{{path/to/directory}}
= show available directories{{path/to/file}}
= show available files{{path/to/file_or_directory}}
= show available files & directories
I'm not sure I'm following. Do you want autocomplete for what kind of files? .cheat
files?
Sorry, I should have said suggestions rather than completions.
This is a feature in the interactive client TLDR++, which has some logic to detect certain common arguments used in TLDR pages (like the ones I referred to along with filtering on .<extension>
).
In terms of Navi features, this would be generating $
options.
Not too sure what is best command to use though.
Using {{path/to/directory}}
as example, some options include:
$ path_to_directory: ls -d */
- will only show directories inside current directory.$ path_to_directory: find . -type d
or$ path_to_directory: fd . --type d
or whatever the FZF/Skim default command is - will suggest quite a number of directories depending on location, though fzf should make it usable. Cannot do absolute path suggestions.
Looking at the top 10 arguments in TLDR pages:
❯ rg -oNI --no-heading '\{\{([^}]*)\}\}' "$TEALDEER_CACHE_DIR/tldr-master/pages" | sort | uniq -c | sort -nrk1 | head -10
371 {{path/to/file}}
287 {{path/to/directory}}
205 {{filename}}
180 {{file}}
172 {{command}}
152 {{username}}
121 {{package_name}}
115 {{name}}
108 {{path/to/file_or_directory}}
99 {{package}}
5 of them are related to files/directories, so having the suggestion would be nice.
Some of these may be new files, so need to make sure that manual input is still an available option.