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

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

Open
skotarek opened this issue Oct 29, 2024 · 4 comments
Open

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

skotarek opened this issue Oct 29, 2024 · 4 comments

Comments

@skotarek
Copy link

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
Copy link
Owner

moudey commented Oct 29, 2024

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
Copy link
Author

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
Copy link
Collaborator

RubicBG commented Nov 1, 2024

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

@skotarek
Copy link
Author

skotarek commented Nov 1, 2024

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

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

3 participants