如何撤消windows上的最后一个cd命令?

如何撤消windows上的最后一个cd命令?,windows,batch-file,cmd,Windows,Batch File,Cmd,我想回到以前的位置,就像大多数unix shell上的cd-一样 在windows上是如何做到这一点的?您在windows上没有本机的cd-(cmd,powershell) 您可以: 1) 在windows上安装cygwin并使用bash 2) 在Win10上安装Linux子系统,并在那里使用bash 3) 在要保存的目录上使用pushd。然后换个你想换的地方。 要返回您,只需popd 第一次和第二次编辑 Powershell有一个我自己的解决方案(MIT许可证,但有我的所谓“尼克”) 其工作方

我想回到以前的位置,就像大多数unix shell上的
cd-
一样


在windows上是如何做到这一点的?

您在windows上没有本机的
cd-
(cmd,powershell)

您可以:

1) 在windows上安装cygwin并使用bash

2) 在Win10上安装Linux子系统,并在那里使用bash

3) 在要保存的目录上使用
pushd
。然后换个你想换的地方。 要返回您,只需
popd

第一次和第二次编辑 Powershell有一个我自己的解决方案(MIT许可证,但有我的所谓“尼克”)

其工作方式如下:

`cd` ... to list stack of saved directories
`cd -` ... return to previous directory (putting another `cd -` goes further to the history)
`cd +` ... add current directory to the top of the stack
`cd <path>` ... changes the path and puts the previous to the stack
有关命令的详细信息:

根据问题下方的评论,我将添加此信息。仅显示部分信息

使用
pushd
popd
时,在使用cmdshell或powershell

在powershell中-这两个命令是不同命令的别名

PS C:\Users> get-alias -name pushd

CommandType     Name                                               ModuleName
-----------     ----                                               ----------
Alias           pushd -> Push-Location

PS C:\Users> get-help pushd

NAME
    Push-Location

SYNTAX
    Push-Location [[-Path] <string>] [-PassThru] [-StackName <string>] [-UseTransaction]  [<CommonParameters>]

    Push-Location [-LiteralPath <string>] [-PassThru] [-StackName <string>] [-UseTransaction]  [<CommonParameters>]


ALIASES
    pushd


REMARKS
    Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help.
        -- To download and install Help files for the module that includes this cmdlet, use Update-Help.
        -- To view the Help topic for this cmdlet online, type: "Get-Help Push-Location -Online" or
           go to http://go.microsoft.com/fwlink/?LinkID=113370.


PS C:\Users> get-alias -name popd

CommandType     Name                                               ModuleName
-----------     ----                                               ----------
Alias           popd -> Pop-Location

PS C:\Users> get-help  popd

NAME
    Pop-Location

SYNTAX
    Pop-Location [-PassThru] [-StackName <string>] [-UseTransaction]  [<CommonParameters>]


ALIASES
    popd


REMARKS
    Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help.
        -- To download and install Help files for the module that includes this cmdlet, use Update-Help.
        -- To view the Help topic for this cmdlet online, type: "Get-Help Pop-Location -Online" or
           go to http://go.microsoft.com/fwlink/?LinkID=113369.

确实,Windows上没有本机的
cd-
。 但是您可以使用
cd..
返回一个目录

C:\Users\Acer\cd..
将把您送回
C:Users\
目录

C:\Users\Acer\cd..
我知道这个答案已经晚了,但可能对其他人也有帮助。
谢谢

请参见
pushd/?
popd/?
@elzoologico,这样它将在cmd.exe中而不是在powershell中(在powershell中会生成错误消息)。有关详细信息,请参阅我的答案编辑。如果您正在显示命令,我认为您打算使用
中的
C:\Users\Acer>cd..
,但问题要求返回到上一个目录,而不是父目录。
C:\Users\Acer\cd..