找回密码

碧海潮声大学生网

查看: 991|回复: 3
打印 上一主题 下一主题

〖分享〗Windows Command Line Auto Completion

[复制链接]
跳转到指定楼层
1#
发表于 2007-2-15 15:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Windows Command Line Auto Completion
Having explained this to a number of people in as many days, I thought I'd share this tip for working with long paths on the command line.  The easist way to expalin this is to jump in feet first:

Open a command line (<Windows Key>-R, CMD<Enter> is engrained in my hands at this point in my career)
At the prompt, repeatedly hit tab
You will be cycling through all of the files and directories in your current directory.  Now try this:

At a clean command prompt, type "dir \P" then start hitting tab.  
Now you&#39;ll be cycling through all the directories that start with "P" in the root of the current drive (in my case, it cycles through "Program Files" then Projects).  You&#39;ll also notice that for files with embedded spaces, quotes are automatically added.  This works for as many characters as you wish to type. After you cycle to the directory you want, type a backslash, then hit tab again and you&#39;ll cycle through the files and sub-directories in that directory, and so on.  On my current machine, I can type the following to open my machine.config:

notepad \win<tab>\mic<tab>\<tab>\v1.1<tab>\con<tab>\m<tab><enter>

This results in the following command line, which would take considerably more keystrokes  or mouse clicks:

notepad \WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.config

This works at just about any point in a command, as long as you are starting from a space.  It will also work on UNC paths staring at the share name (Assuming you can authenticate to that particular share):

dir \\fileserver\share\<tab>

There may be a delay as CMD goes an enumerates the items on the share, but if you are trying to get to something deep down in some huge directory structure with really long path names, this helps a ton.

Though this has been in CMD for some time, I don&#39;t think it was enabled by default untill Windows XP which may explain why it isn&#39;t well known. If you&#39;re stuck on a Windows 2000 box (or, gasp! NT4), you can edit the registry to enable this (Standard registry disclaimer applies - don&#39;t do this unless you know what you&#39;re doing since you can render a box un-bootable with sufficient registry tweaking.):

Set HKCU\Software\Microsoft\Command Processor\CompetionChar to 9

KB244407 covers this in detail.

I used to hate the command line becuase I&#39;m lazy and didn&#39;t want to type out huge paths (which I would end up misspelling).  No longer!



http://codebetter.com/blogs/stev ... 6/01/13/136475.aspx

NT(默认5.1以上,xp&2003)系统的命令提示符的自动补全等功能.很方便现实操作.
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 顶 踩
2#
发表于 2007-2-15 17:39 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

3#
 楼主| 发表于 2007-2-15 20:30 | 只看该作者
对,tab键自动补全.有点借鉴linux等.
回复 支持 反对

使用道具 举报

4#
发表于 2007-2-17 13:41 | 只看该作者
[s:43] 本来想要用软件翻译一下,有点累了。
[s:70]
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋| 碧海潮声大学生网  

Copyright © 2001-2013 Comsenz Inc.   All Rights Reserved.

Powered by Discuz! X3.2( 浙ICP备11026473号 )

快速回复 返回顶部 返回列表