Answers:
除了Get-Location
及其别名之外,您还可以使用自动变量$pwd
。
该$pwd
变量很不错,因为您可以直接访问PathInfo成员。例如
$pwd.Path.PadLeft(80)
$pwd.Drive
而且,如果您想知道成员是什么,只需将command \ alias传递给Get-Member
:
PS C:\Users\your-name-here\Desktop> pwd|Get-Member
TypeName: System.Management.Automation.PathInfo
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Drive Property System.Management.Automation.PSDriveInfo Drive {get;}
Path Property System.String Path {get;}
Provider Property System.Management.Automation.ProviderInfo Provider {get;}
ProviderPath Property System.String ProviderPath {get;}
cd
足够了。无需echo %cd%