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

How to make wstart use linux path #62

Closed
alankritjoshi opened this issue Nov 20, 2017 · 9 comments
Closed

How to make wstart use linux path #62

alankritjoshi opened this issue Nov 20, 2017 · 9 comments

Comments

@alankritjoshi
Copy link

alankritjoshi commented Nov 20, 2017

I want to use cmdtool wstart $filename where $filename represents the relative/absolute linux path of file in pwd. However, it seems to want the absolute Windows path of the file. How do I make it work like I want to? I can only think of making a bash function to handle that.

@goreliu
Copy link
Collaborator

goreliu commented Nov 21, 2017

I added a wstartex subcommand fd9ca6c

Examples:

# Open ./etc/themes directory with explorer.exe
$ ./cmdtool wstartex etc/themes

# Open /mnt/c/Windows/win.ini with notepad.exe
$ ./cmdtool wstartex /mnt/c/Windows/win.ini

# Open www.google.com with the default browser
$ ./cmdtool wstartex www.google.com

Or use a standlone wstart script:

#!/bin/bash

wstart_run='setsid /init /mnt/c/Windows/System32/cmd.exe /c start'

if [[ "$1" == http* || "$1" == www* ]]; then
    exec $wstart_run "" "$@"
fi

dir_name="$(dirname $1)"
file_name="$(basename $1)"

if [[ "$dir_name" == / ]]; then
    cd /; $wstart_run .; cd - >/dev/null
elif [[ "$dir_name" == /mnt ]]; then
    cd /; $wstart_run "" "$file_name":; cd - >/dev/null
else
    shift 2>/dev/null
    cd "$dir_name" && $wstart_run "" "$file_name" "$@"; cd - >/dev/null
fi 

@alankritjoshi
Copy link
Author

alankritjoshi commented Nov 21, 2017

@goreliu awesome! Thank you for this feature. Ability to open websites is a neat touch!

Can we see this in the next release so that ./cmdtool update works?

@goreliu
Copy link
Collaborator

goreliu commented Nov 21, 2017

Yes, I released v0.8.7 just now.

@alankritjoshi
Copy link
Author

@goreliu that was fast! Thanks! It works except for relative paths or when the absolute path has spaces in them.

For example,

cmdtool wstartex .
cmdtool wstartex /mnt/d/files/a\ directory\ with\ space/a\ file\ with\ space.py

I can manage this in my zsh though but as an inbuilt feature of wstartex would be great.

@goreliu
Copy link
Collaborator

goreliu commented Nov 21, 2017

I will fix it, and I am using this zsh script, it works.

#!/bin/zsh

alias run='setsid /init /mnt/c/Windows/System32/cmd.exe /c start'

if [[ $1 == http* || $1 == www* ]] {
    run "" $*
    return
}

dir_name=${1:h}
file_name=${1:t}

if [[ $dir_name == / ]] {
    cd /; run .; cd - >/dev/null
} elif [[ $dir_name == /mnt ]] {
    cd /; run "" $file_name:; cd - >/dev/null
} else {
    shift 2>/dev/null
    cd $dir_name && run "" $file_name $*; cd - >/dev/null
}

@alankritjoshi
Copy link
Author

@goreliu thanks for the fix. It solves my issue :)

@goreliu
Copy link
Collaborator

goreliu commented Nov 21, 2017

I fixed it (234e3bb).

@alankritjoshi
Copy link
Author

@goreliu Great! Will pull from the next release

@alankritjoshi
Copy link
Author

@goreliu did the last change make it into the release?

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

No branches or pull requests

2 participants