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

[Feature Request] Add option to run a startup-command #53

Closed
freijon opened this issue Jan 15, 2020 · 16 comments
Closed

[Feature Request] Add option to run a startup-command #53

freijon opened this issue Jan 15, 2020 · 16 comments

Comments

@freijon
Copy link

freijon commented Jan 15, 2020

Today the 'run' parameter runs a command and exits WSL immediately.
It would be nice to have a similar option which runs a startup-command. This could be used for example to 'cd' directly into the current directory of the Windows CMD console.

@yuk7
Copy link
Owner

yuk7 commented Jan 15, 2020

If you run the run parameter without specifying any commands, you can use prompt in current directory.
Please try it.
{any}.exe run

@yuk7
Copy link
Owner

yuk7 commented Jan 15, 2020

We have received some feedback on the feature, but have yet to reach a conclusion.
You can do a similar thing with the settings inside the distro (eg bashrc).
I would like to hear if you have any opinions.

@freijon
Copy link
Author

freijon commented Jan 15, 2020

{any}.exe run works like you described, however it seems it only works on the C: drive and not on fstab mounted drives, so there is a small limitation...

I still think it could be beneficial to have startup-commands.
Example:

  • Create a vim.bat which runs Arch.exe exec vim <file>
  • Drag&Drop any file on the vim.bat file which edits the given file in vim
    For this to work we would need a script in WSL which converts Windows paths in the corresponding WSL path, but that shouldn't be a problem to setup.

@yuk7
Copy link
Owner

yuk7 commented Jan 15, 2020

hmm? I couldn't understand the meaning.
Is it a command to run at startup likes bashrc?
Or is it something like Arch.exe run script.sh vim <file>?

@freijon
Copy link
Author

freijon commented Jan 15, 2020

It's a command Arch.exe run vim <file>
But Windows would pass the parameter as "C:\myfile.txt", which is useless in WSL. What we would need is a conversion to "/mnt/c/myfile.txt". For this I would create a script.sh.
I would launch Arch.exe run vim `script.sh C:\myfile.txt` which internally would be converted to Arch.exe run vim /mnt/c/mytext.txt

But that's just brainstorming what would be possible ;) The request is just to be able to run a command without WSL being closed immediately.

@yuk7
Copy link
Owner

yuk7 commented Jan 29, 2020

runp

It's a bit different from your request, but I working for new runp command now.
It can convert Windows-style path in command line.

@freijon
Copy link
Author

freijon commented Jan 29, 2020

This looks great! I would say this is even better than what I asked for ;-)
Does it also work with relative paths? If I run Arch.exe from C:\Users\User and "runp vim test.txt", will it actually edit C:\Users\User\test.txt?
I hope I can give it a try soon.

@yuk7
Copy link
Owner

yuk7 commented Jan 29, 2020

Relative paths work too if the distribution is configured properly.
I'll release a new version soon.
i hope you like it...

runp2

@yuk7
Copy link
Owner

yuk7 commented Jan 30, 2020

I released new version.
Implemented runp command.
https://github.com/yuk7/wsldl/releases/latest

@freijon
Copy link
Author

freijon commented Jan 30, 2020

That was quick, thanks!

Maybe a stupid question... How do I get from the Launch.exe to the Arch.exe without reinstalling everything?

@yuk7
Copy link
Owner

yuk7 commented Jan 30, 2020

The executable file with icons is included in icons.zip.
Updates only replace executables.

wsldl connects to the instance by the executable file name. Change the file name.

@freijon
Copy link
Author

freijon commented Jan 30, 2020

The new command works fine! The only thing I noticed is that it only works on the C:\ drive. If I run the command from another drive it shows: ERROR: Path translation failed.

@yuk7
Copy link
Owner

yuk7 commented Feb 6, 2020

From what I confirmed, I was able to convert non-C hard drives.
Maybe you can't convert a manually mounted one.(external drives)

@yuk7
Copy link
Owner

yuk7 commented Mar 2, 2020

It is recommended that you replace the wslpath command.

@freijon
Copy link
Author

freijon commented Mar 2, 2020

I've looked for the newest wslpath binaries, but with no success. Can you point me to the newest version?

@yuk7
Copy link
Owner

yuk7 commented Nov 25, 2020

I decided not to implement this in wsldl.
Please devise command line parameters.
Alternatively, you can change the default shell with chsh.

@yuk7 yuk7 closed this as completed Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants