Customizing Filename Completion

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.


Programmable 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:


RDONLYRead-only files
HIDDENHidden files
SYSTEMSystem files
ARCHIVEFiles modified since the last backup
FILESEverything that's not a directory
NORMALNo attributes are set


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