Spend less time CD’ing around directories with the PowerShell Z shortcut

Dev Tips


Everyone has a trick for moving around their computer faster. It might be a favorite shell, a series of aliases or shortcuts. I like using popd and pushd to quickly go deep into a directory structure and return exactly where I was.

Another fantastic utility is simply called “Z.” There is a shell script for Z at https://github.com/rupa/z that’s for *nix, and there’s a PowerShell Z command (a fork of the original) at https://github.com/vincpa/z.

As you move around your machine at the command line, Z is adding the directories you usually visit to a file, then using that file to give you instant autocomplete so you can get back there FAST.

If you have Windows 10, you can install Z in seconds like this:

C:> Install-Module z -AllowClobber

Then just add “Import-Module z” to the end of your Profile, usually at $env:USERPROFILEDocumentsWindowsPowerShellMicrosoft.PowerShell_profile.ps1

Even better, Z works with pushd, cd, or just “z c:usersscott” if you like. All those directory changes and moves will be recorded it the Z datafile that is stored in ~.cdHistory.

What do you think? Do you have a favorite way to move around your file system at the command line?


Sponsor: Get the latest JetBrains Rider preview for .NET Core 2.0 support, Value Tracking and Call Tracking, MSTest runner, new code inspections and refactorings, and the Parallel Stacks view in debugger.
















Source link

Leave a Reply