From 4c8ae68027e6ce913d7151ac920dfef28a04be53 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Fri, 8 May 2020 14:18:56 -0500 Subject: [PATCH] - Adds some optional ST3 keymaps to VS Code on Windows (#159) * - Added commented out sublime text keymaps for VS Code under Windows * - Added cmd.exe to kinto.ahk for Windows * - Added support for Fluent Terminal on Windows * - Firefox paste fix for Windows * - Added Sublime hotkeys to VS Code to setup for windows * - Added refresh of environment variables after possible package installs on Windows --- setup.py | 8 +++++++- windows/autohotkey.ps1 | 3 +++ windows/kinto.ahk | 26 +++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 39abe07..020eb45 100755 --- a/setup.py +++ b/setup.py @@ -25,14 +25,20 @@ def windows_setup(): os.system("regedit " + path + "\\windows\\standard_ctrlalt_capsesc_swap.reg") elif default == 5: os.system("regedit " + path + "\\windows\\remove_keyswap.reg") + stvscode = yn_choice(bcolors.CYELLOW2 + "Would you like to use Sublime Text 3 keymaps in VS Code?\n" + bcolors.ENDC) if default > 0 and default < 5: print("Will now install chocolatey and autohotkey with elevated privileges...") print("This install will fail if you are not running with elevated privileges") os.system('powershell -executionpolicy bypass ".\\windows\\autohotkey.ps1"') + os.system('refreshenv') print("\nWill now install Ubuntu Terminal Theme as default...") os.system("regedit " + path + "\\windows\\theme_ubuntu.reg") print("Copying autohotkey combinations for Terminals & Editors...") - os.system("copy /Y " + path + "\\windows\\kinto.ahk \"C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\kinto.ahk\"") + os.system("copy /Y " + path + "\\windows\\kinto.ahk " + path + "\\windows\\kinto-new.ahk") + if(stvscode): + os.system('perl -pi -e "s/(; )(.*)(; ST2CODE)/$2$3/g" ./windows/kinto-new.ahk') + os.system("copy /Y " + path + "\\windows\\kinto-new.ahk \"C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\kinto.ahk\"") + os.system("del /f .\\windows\\kinto-new.ahk") print("\nPlease log off and back on for changes to take full effect.") print("If using WSL then please remember to right click on title bar -> Properties -> Edit Options -> Use Ctrl+Shift+C/V as Copy/Paste and enable it.") else: diff --git a/windows/autohotkey.ps1 b/windows/autohotkey.ps1 index 5dd7305..af83f93 100644 --- a/windows/autohotkey.ps1 +++ b/windows/autohotkey.ps1 @@ -10,3 +10,6 @@ else{ if(-not(test-path "C:\Program Files\AutoHotkey\AutoHotkey.exe")){ choco install autohotkey.install } +if(-not(test-path "C:\Strawberry\")){ + choco install strawberryperl +} diff --git a/windows/kinto.ahk b/windows/kinto.ahk index 6680d2a..54a403e 100644 --- a/windows/kinto.ahk +++ b/windows/kinto.ahk @@ -1,9 +1,13 @@ +SetTitleMatchMode, 2 + GroupAdd, terminals, ahk_exe ubuntu.exe GroupAdd, terminals, ahk_exe ConEmu.exe GroupAdd, terminals, ahk_exe ConEmu64.exe GroupAdd, terminals, ahk_exe powershell.exe GroupAdd, terminals, ahk_exe WindowsTerminal.exe GroupAdd, terminals, ahk_exe Hyper.exe +GroupAdd, terminals, ahk_exe Cmd.exe +GroupAdd, terminals, Fluent Terminal ahk_class ApplicationFrameWindow GroupAdd, posix, ahk_exe ubuntu.exe GroupAdd, posix, ahk_exe ConEmu.exe @@ -15,6 +19,11 @@ GroupAdd, ConEmu, ahk_exe ConEmu64.exe GroupAdd, ConEmu, ahk_exe WindowsTerminal.exe GroupAdd, editors, ahk_exe sublime_text.exe +GroupAdd, editors, ahk_exe VSCodium.exe +GroupAdd, editors, ahk_exe Code.exe + +GroupAdd, vscode, ahk_exe VSCodium.exe +GroupAdd, vscode, ahk_exe Code.exe ; Cmd+Space Alternative LWin & vk07::return @@ -56,7 +65,17 @@ $^+Right::Send +{End} !Right::Send ^{Right} !+Right::Send ^+{Right} -#IfWinActive ahk_group editors +; ; Sublime Text Remaps for VS Code ; ST2CODE +; #IfWinActive ahk_group vscode ; ST2CODE +; ; Remap Ctrl+Shift to behave like macOS Sublimetext ; ST2CODE +; ; Will extend cursor to multiple lines ; ST2CODE +; #+Up::send ^!{Up} ; ST2CODE +; #+Down::send ^!{Down} ; ST2CODE +; ; Remap Ctrl+Cmd+G to select all matches ; ST2CODE +; #^g::send ^+{L} ; ST2CODE +; #If ; ST2CODE + +#IfWinActive ahk_exe sublime_text.exe ; Remap Ctrl+Shift to behave like macOS Sublimetext ; Will extend cursor to multiple lines #+Up::send {shift up}^!{Up} @@ -66,6 +85,11 @@ $^+Right::Send +{End} #^g::send !{F3} #If +; Not sure why this fix is needed +#IfWinActive ahk_exe Firefox.exe + ^v::send ^v +#If + #IfWinActive ahk_group terminals ; Copy ^c::Send {LCtrl down}{LShift down}c{LCtrl Up}{LShift Up}