「Windowsでエクスプローラーからフォルダを各種ターミナルで開く」の版間の差分

Notion-MW
タグ: 差し戻し済み
Notion-MW
タグ: 手動差し戻し
302行目: 302行目:
たとえば以下のようなvbsを用意する。
たとえば以下のようなvbsを用意する。


m_with_cap_m
<syntaxhighlight style="margin-bottom:0.2em;" lang="vb.net">Dim objShell
 
Set objShell = CreateObject("WScript.Shell")
<pre class="ccccc">vb.net
Dim objShell
Set objShell = CreateObject(&quot;WScript.Shell&quot;)
objShell.CurrentDirectory = WScript.Arguments(1)
objShell.CurrentDirectory = WScript.Arguments(1)
objShell.Run(WScript.Arguments(0)),,False</pre>
objShell.Run(WScript.Arguments(0)),,False</syntaxhighlight>
<div style='text-align: center;'>startatdir.vbs</div>
<div style='text-align: center;'>startatdir.vbs</div>


491行目: 488行目:
<li><p>vbsの例</p>
<li><p>vbsの例</p>
<p>次の節で解説する「(自分が起動された)カレントディレクトリでの起動」にも対応している(引数がない場合)。</p>
<p>次の節で解説する「(自分が起動された)カレントディレクトリでの起動」にも対応している(引数がない場合)。</p>
<pre class="ccccc">vb.net
<syntaxhighlight lang="vb.net">Dim objShell
Dim objShell
Dim curDir
Dim curDir


Set ws = CreateObject(&quot;Wscript.Shell&quot;)
Set ws = CreateObject("Wscript.Shell")
Dim dir
Dim dir
If WScript.Arguments.Count = 0 Then
If WScript.Arguments.Count = 0 Then
502行目: 498行目:
   dir = Wscript.Arguments(0)
   dir = Wscript.Arguments(0)
End If
End If
dir = Replace(dir,&quot;%&quot;,&quot;==%&quot;)
dir = Replace(dir,"%","==%")
ws.run &quot;powershell -Command &quot;&quot;&amp; {Start-Process -Verb Runas -Filepath wt -Argumentlist powershell, -noexit, -command, Set-Location, -LiteralPath, ('\&quot;&quot;'''+($args[1].Trim('\&quot;&quot;') -replace '''', '''''' -replace ';', '\;' )+'''.Replace(''==%'',''%'')\&quot;&quot;')}&quot;&quot; --% &quot;&quot;\&quot;&quot;&quot;&amp;dir&amp;&quot;\&quot;&quot;&quot;&quot;&quot;, vbHide
ws.run "powershell -Command ""& {Start-Process -Verb Runas -Filepath wt -Argumentlist powershell, -noexit, -command, Set-Location, -LiteralPath, ('\""'''+($args[1].Trim('\""') -replace '''', '''''' -replace ';', '\;' )+'''.Replace(''==%'',''%'')\""')}"" --% ""\"""&dir&"\""""", vbHide


Set objShell = Nothing</pre></li></ul>
Set objShell = Nothing</syntaxhighlight></li></ul>
</li>
</li>
<li><p>cmd</p>
<li><p>cmd</p>
515行目: 511行目:
<p><code>&quot;C&#58;\Program Files\Git\usr\bin\sh.exe&quot; &quot;C&#58;\path\to\gb&#45;wt&#45;admin.sh&quot; &quot;%V&quot;</code></p>
<p><code>&quot;C&#58;\Program Files\Git\usr\bin\sh.exe&quot; &quot;C&#58;\path\to\gb&#45;wt&#45;admin.sh&quot; &quot;%V&quot;</code></p>
<p>で、<code>gb&#45;wt&#45;admin.sh</code>の中身は以下。</p>
<p>で、<code>gb&#45;wt&#45;admin.sh</code>の中身は以下。</p>
<pre class="ccccc">bash
<syntaxhighlight lang="bash">#!/bin/sh
#!/bin/sh
IFS=
IFS=
LANG=en_US.UTF-8
LANG=en_US.UTF-8
echo $*|/bin/sed 's/\\/\\\\/'|/bin/cygpath -f -|printf %q $(/bin/cat) |/bin/sed &quot;s/'/''/g;s/%/==%/g;s/;/\\\\;/g&quot;|/bin/xargs -d '\n' -I {} powershell -Command Start-Process -Filepath wt -ArgumentList &quot;'&quot;'&quot;C:\Program Files\Git\usr\bin\env.exe&quot;'&quot;'&quot; , '&quot;MSYSTEM=MINGW64&quot;' , &quot;'&quot;'&quot;C:\Program Files\Git\usr\bin\sh.exe&quot;'&quot;'&quot; , &quot;'--login'&quot;, &quot;'-c'&quot;, &quot;'&quot;'&quot;IFS=\;cd $(echo {}| /bin/sed s/==%/%/g) \; exec bash&quot;'&quot;'&quot;</pre>
echo $*|/bin/sed 's/\\/\\\\/'|/bin/cygpath -f -|printf %q $(/bin/cat) |/bin/sed "s/'/''/g;s/%/==%/g;s/;/\\\\;/g"|/bin/xargs -d '\n' -I {} powershell -Command Start-Process -Filepath wt -ArgumentList "'"'"C:\Program Files\Git\usr\bin\env.exe"'"'" , '"MSYSTEM=MINGW64"' , "'"'"C:\Program Files\Git\usr\bin\sh.exe"'"'" , "'--login'", "'-c'", "'"'"IFS=\;cd $(echo {}| /bin/sed s/==%/%/g) \; exec bash"'"'"</syntaxhighlight>
<p>Cygwinも同様である。</p></li></ul>
<p>Cygwinも同様である。</p></li></ul>