wslでopen
イントロ
wslでもmacみたくopenを使いたい.
実装(bash)
bashでのopenです..bashrcに追加して読み込むようにしています.
open() {
local browser='/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'
for arg; do
if [ -e "${arg}" ]; then
readlink -f ${arg} |xargs wslpath -w |powershell.exe start
elif [[ ${arg} =~ http ]]; then
echo "${arg}" | xargs "${browser}"
fi
done
}
実装(ruby)
rubyでの実装です.ほんとうはfishのfunctionにしたかったのですが,あんまり情報なくて.しかたがないので,~/bin/openとして置いて,これをfishのPATHに入れてうごかしています.openというのがubuntuの/sbinにあるようですが,それとは違うようです.
#!/usr/bin/env ruby
require 'open3'
target = ARGV[0] || '.'
case
when target == '.'
out, err, status = Open3.capture3("explorer.exe .")
when target.match(/^http/)
system "cmd.exe /c start #{target}"
else
puts "no command for #{target}"
end
- source ~/Desktop/lecture_20f/semi_lattice/bash_script/wsl_open.org
Author And Source
この問題について(wslでopen), 我々は、より多くの情報をここで見つけました https://qiita.com/daddygongon/items/3d30443d80bde5c74f8d著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .