Skip to content

Instantly share code, notes, and snippets.

@sdkks
Last active September 22, 2018 05:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdkks/d79dcfc439c94caa22cc08f6257926b9 to your computer and use it in GitHub Desktop.
Save sdkks/d79dcfc439c94caa22cc08f6257926b9 to your computer and use it in GitHub Desktop.
Windows how to copy paste like Mac OSX terminal using Alt instead of CMD in Linux Terminal Emulators with AHK AutoHotKey

HOW TO

Why

Copy Paste (CTRL+C) command doesn't work for Linux terminals as CTRL+C is used for SIGINT signal to stop/interrupt works on Linux shell.

Prerequisites

You are on Windows but need to have Linux shell like bash or zsh and using one of popular terminal emulators

Steps

  1. Download and Install AHK (AutoHotKey) // https://autohotkey.com/
  2. Put copy-paste.ahk anywhere in your machine and double click after saving it.
  3. Voila, now Alt + C (same position as CMD + C) will work just like Macbook on most of Linux Terminal emulators on Windows (tested with Cmder, MinTTY, Hyper.JS)

How to add to Windows startup?

  1. Simply open folder below %appdata%\Microsoft\Windows\Start Menu\Programs\Startup
  2. Right click on empty space in File Explorer, right click then 'create new shortcut'
  3. Point the new shortcut to your *.ahk script

Additional info

If your terminal emulator doesn't use Shift + Insert and Ctrl + Insert for copy/paste, modify copy-paste.ahk accordingly: https://autohotkey.com/docs/commands/Send.htm

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance Force
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; copy
<!c::
Send, ^{Insert}
Return
;paste
<!v::
Send, +{Insert}
Return
;cut
<!x::
Send, ^{x}
Return
; CMD + T
<!t::
Send, ^{t}
Return
; CMD + N
<!n::
Send, ^{n}
Return
; CMD + W
<!w::
Send, ^{w}
Return
; CMD + A
<!a::
Send, ^{a}
Return
; CMD + R
<!r::
Send, ^{r}
Return
; CMD + K
<!k::
Send, ^{k}
Return
; HOME
#IfWinNotActive ahk_class CabinetWClass
<!Left::
Send, {Home}
Return
; END
#IfWinNotActive ahk_class CabinetWClass
<!Right::
Send, {End}
Return
; PAGEUP
#IfWinNotActive ahk_class CabinetWClass
<!Up::
Send, {PgUp}
Return
; PAGEDOWN
#IfWinNotActive ahk_class CabinetWClass
<!Down::
Send, {PgDn}
Return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment