mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-06 00:57:14 -04:00
Properly escape special characters for WSL clipboard
Former-commit-id: 6872560fa651713dd7fd31dacd8e872d1059013d Former-commit-id: dc8901231a753531a19b43bb72e95b29949955e8
This commit is contained in:
+1
-1
@@ -735,7 +735,7 @@ def copy_data():
|
|||||||
# PORT START CLIPBOARD
|
# PORT START CLIPBOARD
|
||||||
# WSL clipboard detection
|
# WSL clipboard detection
|
||||||
if 'WSL_DISTRO_NAME' in environ:
|
if 'WSL_DISTRO_NAME' in environ:
|
||||||
run(['pwsh.exe', '-c', 'Set-Clipboard', _copy_line[_index].rstrip()])
|
run(['powershell.exe', '-c', "Set-Clipboard '" + _copy_line[_index].rstrip().replace("'", "''") + "'"])
|
||||||
Popen("sleep 30; pwsh.exe -c 'echo \"\" | Set-Clipboard'", shell=True)
|
Popen("sleep 30; pwsh.exe -c 'echo \"\" | Set-Clipboard'", shell=True)
|
||||||
# Wayland clipboard detection
|
# Wayland clipboard detection
|
||||||
elif 'WAYLAND_DISPLAY' in environ:
|
elif 'WAYLAND_DISPLAY' in environ:
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ arguments = argv[1:]
|
|||||||
# define replacement text depending on arguments
|
# define replacement text depending on arguments
|
||||||
if len(arguments) > 0:
|
if len(arguments) > 0:
|
||||||
if arguments[0] == 'WSL':
|
if arguments[0] == 'WSL':
|
||||||
replacement = """run(['pwsh.exe', '-c', 'Set-Clipboard', _copy_line[_index].rstrip()])
|
replacement = """run(['powershell.exe', '-c', "Set-Clipboard '" + _copy_line[_index].rstrip().replace("'", "''") + "'"])
|
||||||
Popen("sleep 30; pwsh.exe -c 'echo \\"\\" | Set-Clipboard'", shell=True)"""
|
Popen("sleep 30; pwsh.exe -c 'echo \\"\\" | Set-Clipboard'", shell=True)"""
|
||||||
elif arguments[0] == 'MAC':
|
elif arguments[0] == 'MAC':
|
||||||
replacement = """run(['pbcopy'], stdin=Popen(['printf', _copy_line[_index].rstrip().replace('\\\\\\', '\\\\\\\\\\\\\\').replace('%', '%%')],
|
replacement = """run(['pbcopy'], stdin=Popen(['printf', _copy_line[_index].rstrip().replace('\\\\\\', '\\\\\\\\\\\\\\').replace('%', '%%')],
|
||||||
|
|||||||
Reference in New Issue
Block a user