How to? Limiting Autocompletion to Directory Names (on-the-fly)

Feb 23, 2012
240
3
In the page on Customizing Filename Completion, there is a very useful option which allows specifying that autocompletion for a given command (e.g. cdd) should be limited to folder names only (the "dirs" file extension).
I'm wondering whether how this can be done on-the-fly, while typing out a mask on the command line.
That is: as we know, if we want to cycle through all of the *.txt files in a given place, we can type a space plus the mask:
[C:\] *.txt
And then hit TAB.
But how can I specify a mask that will limit the auto-completion to directory names only?
I've tried two possibilities that occurred to me:
[C:\] \
and
[C:\] dirs
But neither of these worked as a dynamic completion mask.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
If you want a "normal" filecompletion mask as well as a dynamic one, use the OPTION dialog to create a FileCompletion directive in your .INI file. When you want to change it dynamically, just use "SET FILECOMPLETION=..." to override it. Of course you must remember to UNSET it to restore your customized default. Unfortunately there is no method to make changes to the TCMD operating environment (by which I mean the totality of environment variables, aliases, etc.) which affect only the next command.

Regardless, why would you want to change the filecompletion mask to directories only when there is no command on the line? The only reason I can think of is "automatic directory change" - which is nothing but an implied CD (of CDD) command. My suggestion is to use the FileCompletion directive or the FILECOMPLETION variable to restrict completion to directories when the command is one to change directories as I do (you can also add any aliases and batch file names you use for the purpose, as are cdx and cdz below):
filecompletion=cd cdd cdx cdz chdir pushd:dirs
and type in the two or three letters CD or CDD - just as quick as your typing "dirs".
 
Jan 15, 2009
16
0
Using the OPTION command, go to "Command Line" tab, the "Filename Completion" area and type

cd:dirs

in the "Options:" box. Click the "Apply" button.

Then at the command line type cd <space> then hit the tab key to cycle through directories.
 

rconn

Administrator
Staff member
May 14, 2008
12,367
150
In the page on Customizing Filename Completion, there is a very useful option which allows specifying that autocompletion for a given command (e.g. cdd) should be limited to folder names only (the "dirs" file extension).
I'm wondering whether how this can be done on-the-fly, while typing out a mask on the command line.

There is no built-in way to do this (though it could be done with a plugin).
 
Feb 23, 2012
240
3
Hi Rex,
Thanks for your reply. I'm willing to take this on as my first TCC plugin project, but I'd first like to clarify what you're envisioning. Is there a mechanism in place to allow the plugin to interface with, and slightly modify, the auto-completion functionality, or would the plug in have to reimplement the auto-completion functionality?
That is: I'll write a plug in that traps every keystroke, and if the keystroke is one of the autocompletion keystrokes (tab, shift-tab, etc.), then the plugin will check if the word "dirs" immediately precedes the cursor to the left. If this is the case, then I'll want the plugin to invoke the autocompletion module to only show directory names (as if it had been preconfigured with "dirs"). Can this be done directly? Or, alternatively, can the plug-in traverse the auto-completion results one-by-one, checking for directories? Or would the plug-in have to reimplement the autocompletion itself?
Thanks for your help,
Avi

There is no built-in way to do this (though it could be done with a plugin).
 
Feb 23, 2012
240
3
Oh, I see; that makes it into a much more formidable task; TCC's auto-completion really shines in its strong flexibility, but that would take a very significant effort to recode.
Would it make sense to suggest a feature as follows: to add a hotkey that would toggle TCC's auto-completion between regular mode (all files and directories) and between a mode in which it would cycle only through directories? That way, as someone types at the command line, the auto-completion feature could be toggled as necessary to function this way or that.

You'll have to reimplement the auto completion; there aren't any hooks into the middle of the TCC completion code.
 
Similar threads
Thread starter Title Forum Replies Date
A How to? PhraseExpress autotext/autocompletion printing unexpected characters Support 4
fishman@panix.com HELP!! I just updated to Version 28 and as usual I cannot make extended directory search work. Support 2
D How to use multi-line DO to loop through first level directory names Support 5
D ParentDirectory does not update directory history Support 6
samintz CDD to non-existent directory hangs Support 2
gworley rd (Remove Directory) gives interesting error: Support 2
D Directory History Window with wildcard search Support 3
D How to? Skip removing directory (RMDIR) without error message Support 2
gentzel Directory stack empty when running TCEXIT? Support 9
vefatica Disable extended directory searches (completely)? Support 8
M WAD "Pictures" directory is empty in TCC but not in CMD or Explorer Support 4
G Local Directory Corruption Support 11
Jay Sage Directory Alias Access to FTP Servers Support 2
Joe Caverly DIRectory Colorization in v25 Help File Support 0
K copy changing destination current directory Support 1
thorntonpg option /u not working The directory name is invalid Support 5
J built in file explorer - how do i go back "up" the directory? Support 2
vefatica Extended directory searches? Support 6
Joe Caverly Using a Directory Alias with @iniwrite fails Support 14
A Installer /extract: extracts into current directory if target not exists Support 12
Charles Dye Ctrl-Shift-Up doesn't update directory history Support 1
G Extended directory search not working Support 4
CWBillow Editing in the root directory of windows 10 Support 6
D Directory stack empty Support 1
J directory or folder to start in Support 2
M How to unlock a directory Support 1
Alpengreis Fixed TCMD FileExplorer Start-Directory problem Support 4
R V19 - At startup, TCC save directory in the directory history list Support 2
C Touch command — I Need to touch matching files in another directory. Support 5
nickles Move takecommand.18.0.key location to installation directory Support 4
fishman@panix.com Extended Directory Searches are not working for me in CDD Support 9
vefatica TCMD's current directory? Support 4
J How to set working directory Support 10
nickles How to? Follow a JUNCTION type directory link Support 9
Steve Pitts WAD Strange output from DEL of a non-existent directory Support 7
I tab completion with directory commands Support 7
vefatica Start-up directory for new tabs? Support 7
cgunhouse Problem with CALL and Directory Aliases in V17 Support 9
vefatica FFIND /S, find directory with specified name? Support 7
David Wilbanks How to make new tab open in same directory as previous tab? Support 4
H WAD Wild Card in Directory @shfolder[25] acting differently Support 3
M How to? List path getting short file and directory names... Support 10
A How to? Can't change directory ("cd") into system hidden files Support 13
mfarah How to? So I want a custom directory for the plugins... Support 16
D Why doesn't ffind find directory? Support 3
T dir /h error in empty directory Support 22
S directory history locks up TCC Support 3
B Why Does @GETDIR Repeat Selected Directory Name In Returned Value Support 7
ed neff How to? exit TCC/Take Command to a new directory Support 10
Jake Default directory Support 3

Similar threads