moudey / Shell

Powerful context menu manager for Windows File Explorer
https://nilesoft.org
MIT License
3.52k stars 120 forks source link

passing @sel.path with escaped characters to powershell #547

Open skotarek opened 3 days ago

skotarek commented 3 days ago

item(title="Command Prompt" tip=tip_run_admin admin=has_admin image='@package.path("WindowsTerminal")\WindowsTerminal.exe' cmd="wt.exe" arg=`-d "@sel.path\." -p "Command Prompt"`)

item(title="Git Bash" tip=tip_run_admin admin=has_admin image='@package.path("WindowsTerminal")\WindowsTerminal.exe' cmd="wt.exe" arg=`-d "@sel.path\." -p "Git Bash"`)

item(title="Windows PowerShell" tip=tip_run_admin admin=has_admin image='@package.path("WindowsTerminal")\WindowsTerminal.exe' cmd="wt.exe" arg=`-d "@sel.path\." -p "Windows PowerShell"`)

this is my config for running windows terminal instances of cmd, git, and powershell until recently I thought it worked well however after some trial and error I noticed that powershell instance does not open the locations with some specific characters (in my case: the square brackets), these characters need to be escaped with a backtick before them, how can I achieve this?

moudey commented 3 days ago

To change the path separator, use the path.sep function.

// C:\Windows\System32\
path.sep(sel.path,"\\\\")
// C:\\Windows\\System32\\

Or use the str.replace function in general.

str.replace(sel.path,'\','\\')
skotarek commented 1 day ago

To change the path separator, use the path.sep function.

// C:\Windows\System32\
path.sep(sel.path,"\\\\")
// C:\\Windows\\System32\\

Or use the str.replace function in general.

str.replace(sel.path,'\','\\')

tried both, same results

RubicBG commented 6 hours ago

Passing a path with square brackets to wt.exe is not possible. (... to PowerShell is possible)

skotarek commented 5 hours ago

Passing a path with square brackets to wt.exe is not possible. (... to PowerShell is possible)

yeah but if I do that then it opens as a new window of wt.exe instead of a new tab