Closed alankritjoshi closed 6 years ago
I added a wstartex subcommand https://github.com/goreliu/wsl-terminal/commit/fd9ca6c833746b9f82d437a7f1c641b593da6dfd
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
@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 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.
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
}
@goreliu thanks for the fix. It solves my issue :)
@goreliu Great! Will pull from the next release
@goreliu did the last change make it into the release?
I want to use
cmdtool wstart $filename
where$filename
represents the relative/absolute linux path of file inpwd
. 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.