Powershell functions to navigate faster in the terminal

I’d like to share 3 Powershell functions that I’ve wrote this week to navigate a bit faster in the Powershell.

I’m having a lot of different folders to organize my files and projects and it’s kinda exhausting to tab through the folders with the command, which looks something like this:

What would be cool instead is

since I know the folder structure of paths I often visit.

(I did use the name ccd because the finger is on the c anyway when you want to type c)

With that goal in mind I wrote three functions which will achieve this beheaviour.
The source can be found on github.

Function gdp

The function gdp returns the path matching the abbreviations you give it as an argument.

If the folder is found, the output will be the following:

It is possible to use special characters for home (~), root (\ or /) and another partition, e.g. d:.

If the argument is ambiguous, you will get a list of matching folders to sharpen your argument:

If the path is not found, it will just throw an error.

Function ccd

The function ccd is just a wraper around the gdp function, which means if the gdp function returns a valid path, it will change to the directory.

Function gfp

I liked the idea to use it with folders so I wrote another functions which does the same thing for files.

The function is called gfp (get file path) and it works the same way:

I can also use it to give the path as a argument to another program or script:

What happens is that vim will start and open the file „~\vimfiles\vimrc“.

This function also behaves like the gdp function in that it will list ambiguous filenames and throw an error if no file is found.

I hope you enjoy it!

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.