You can customize filename completion for any internal or external command or alias. This allows TCC to display filenames intelligently based on the command you are entering. For example, you might want to see only .TXT files when you use filename completion in the EDIT command. When you press the Tab (or F9) key, TCC will display a matching argument.
Programmable filename ("tab") completion is supported using any scripting language supported by TCC (i.e., BTM/CMD, Lua, Python, REXX, Tcl, etc.). See TABCOMPLETE for details.
To customize filename completion you can use the Filename Completion configuration options. You can also use the FILECOMPLETION environment variable. If you use both, the environment variable will override the configuration option. You may find it useful to use the environment variable for experimenting, then create permanent settings with the configuration dialog.
The format for both the environment variable and the directive is:
cmd1 [cmd2 ...]:[!]ext1 ext2 ...; cmd2: ...
cmd1 etc. are command names
ext1 etc. are file extensions (which may include wildcards) or one of the following file types:
|ARCHIVE||Files modified since the last backup|
|FILES||Everything that's not a directory|
|NORMAL||No attributes are set|
There are four types that can be used instead of an extension:
|functions||User-defined variable functions|
|libraries||Library function names|
Filename completion also supports a position syntax:
[n] Only match the following extensions if the argument number is equal to n
[*n] Only match the following extensions if the argument number is less than or equal to n
[n*] Only match the following extensions if the argument number is greater than than or equal to n
[/x] Only match the specified switch. A matching switch argument will not increase the argument value.
For example, the default ZIP filename completion looks like this:
zip: dirs zip [2*] *
This means that the first argument to a ZIP command will only match subdirectories or files with a .zip extension. Subsequent arguments will match any file or directory.
Note that if a file uses one of the reserved file type names shown above as its extension (e.g. xyz.hidden) , that file will be treated as if it were of that type.
Filename completion will be done in the order the extensions are specified. For example:
set filecompletion=myeditor:htm html css
will first try to match .htm files, then .html, and finally .css.
Setting options in OPTION / Filename Completion, or with the FILECOMPLETION environment variable, will override the default filename completion settings such as "complete hidden files / directories" options for that command. If you want to customize filename completion and search for hidden / system files, you will need to add the HIDDEN and/or SYSTEM extensions to that command's filename completion options.
You can exclude an extension by prefixing it with a !.
The command name is the internal command, alias, or executable file name (without a path). For example, to have file completion return only directories for the CD, CDD, and RD commands and only .C and .ASM files for a Windows editor called WinEdit, you would use this setting for filename completion in the configuration dialog:
cd cdd rd:dirs; winedit:c asm
To set the same results using the FILECOMPLETION environment variable:
set filecompletion=cd cdd rd:dirs; winedit:c asm
With this setting in effect, if you type "CD " and then pressed Tab, TCC returns only directories, not files. If you type WINEDIT and press Tab, you will see only names of .C and .ASM files.
When testing for a customized filename match, TCC checks the actual command line you type (but without expanding any aliases). For example, if you use the definition above and have "W" aliased to "WINEDIT" and then enter a "W" command, filename completion -- which refers only to "WINEDIT" -- will be ignored. To use customized filename completion for aliases you must enter the alias name:
FileCompletion=cd cdd rd:dirs; winedit:c asm; w:c asm