Skip to content

Instantly share code, notes, and snippets.

@Fire-Dragon-DoL
Last active August 29, 2015 14:04
Show Gist options
  • Save Fire-Dragon-DoL/69e29206cc5239d910b7 to your computer and use it in GitHub Desktop.
Save Fire-Dragon-DoL/69e29206cc5239d910b7 to your computer and use it in GitHub Desktop.
Yakuake-like Mintty console for Windows with Autohotkey and Cygwin
start D:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -e /usr/bin/bash -l -c "cd \"$0\" ; clear; exec bash" -
; Change your hotkey here
OpenShellIfNotRunning()
{
Opening := False
DetectHiddenWindows, on
IfWinNotExist ahk_class mintty
{
ConsolePath := "D:\Users\Francesco\Google Drive\OS\Tools\cygwin_on_path.bat"
EnvGet UserProfile, UserProfile
Run %ConsolePath%, %UserProfile%
Opening := True
WinWaitActive ahk_class mintty
}
DetectHiddenWindows, off
Return Opening
}
ShowShell()
{
WinShow ahk_class mintty
; Make it topmost
WinSet AlwaysOnTop, on, ahk_class mintty
; Delete Border
WinSet Style, -0xC00000, ahk_class mintty
; Disable resizing
WinSet Style, -0x40000, ahk_class mintty
WinMove ahk_class mintty,, 2, 0, 1915, 472
WinActivate ahk_class mintty
ControlFocus ahk_class mintty, ahk_class mintty
}
HideShell()
{
; Because hiding the window won't deactivate it, activate the window
; beneath this one (if any). I tried other ways, but they wound up
; activating the task bar. This way sends the active window (which is
; about to be hidden) to the back of the stack, which seems best:
; Send, !{esc}
WinHide ahk_class mintty
}
; http://www.autohotkey.com/board/topic/32487-simple-minimize-to-tray/
; RestoreFromTrayMenu:
; Menu Tray, delete, %A_ThisMenuItem%
; ShowShell()
; Return
; Menu, Tray, Add, Toggle Window, GuiToggle
; Menu, Tray, Default, Toggle Window
#\::
If (OpenShellIfNotRunning())
{
ShowShell()
}
Else
{
; If Window Visible
IfWinExist ahk_class mintty
{
HideShell()
}
Else
{
ShowShell()
}
}
Return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment