Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change drive letter before cd in case of cmd.exe #11

Merged
merged 1 commit into from
Jan 3, 2018

Conversation

saaketp
Copy link
Contributor

@saaketp saaketp commented Jan 3, 2018

Fixes #4

This checks if the windows shell is cmd.exe similar to wsl bash check in pull request #10.

I modified the "isWslBash" function and made a "kindOfShell" that returns string "wslbash" or "cmd".
This was to avoid creating a new function isCmd and duplicating most of the code from isWslBash.
So now instead of an if condition we have a switch case.

In cmd.exe cd works only for paths within the current drive letter (which is C: usually when cmd is started).
To change the drive letter we need to send the drive letter and a colon to the terminal.

Screen cap:

capture

src/extension.ts Outdated
dir = dir.replace(/(\w):/, '/mnt/$1').replace(/\\/g, '/')
break;
case "cmd":
terminal.sendText(dir.slice(0,2));
Copy link
Owner

@Tyriar Tyriar Jan 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment here explaining what it's doing would be good, also do you know if we need to do this for powershell?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I amended the commit to add comments before the line.

This was not required for powershell, it handles different drive letters on its own.

Fixes Tyriar#4

Check for cmd.exe in config, similar to wsl bash check
and send 1st two characters of the path before doing cd to change drive letter.
@Tyriar
Copy link
Owner

Tyriar commented Jan 3, 2018

Thanks @saaketp!

@Tyriar Tyriar merged commit 9c3dfe4 into Tyriar:master Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants