/gcd

Windows utility to serve arguments to a "cd" command alias

Primary LanguageGoApache License 2.0Apache-2.0

gcd Build status

Windows utility written in Go to serve arguments to a "cd" command alias.

In particular this switch:

Use the /D switch to change current drive in addition to changing current
directory for a drive.

I want it to be set automatically.

Install

go install github.com/tischda/gcd@latest

Usage

gcd <path>

Examples:

c:\> gcd.exe c:\temp
"c:\temp"

c:\> gcd.exe e:\temp
/d "e:\temp"

c:\> gcd.exe c:\program files
"c:\program files"

To actually change the working directory, define an alias to the cd command:

ncd=FOR /F "delims=" %G IN ('gcd $*') do @cd %G

(I am using cmder)

Known issues

This fails:

c:\> gcd.exe tips & tricks
"tips"
'tricks' is not recognized as an internal or external command,
operable program or batch file.

Workarounds:

c:\> gcd.exe "tips & tricks"
c:\> gcd.exe tips ? tricks

Using the ncd alias, this will fail:

c:\> ncd (test)
') was unexpected at this time.

c:\> ncd music ^& videos
The system cannot find the path specified.
'videos' is not recognized as an internal or external command,
operable program or batch file.

Workarounds:

c:\> ncd "(test)"
c:\> ncd (test?

c:\> ncd "music ^& videos"

As a general rule, if it fails, you want to use quoted paths.

References