terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Feature request: hot key drop down ala quake/guake/tilda

Open NOFUNEVER opened this issue 7 years ago • 147 comments

The petty thing I miss most when I pop into Windows is having a separate hot key terminal for each of my three monitors. The closest i've ever been to believing in god was when I realized that was obtainable and if you could make that happen in Windows I just might have to kiss you.

NOFUNEVER avatar May 10 '19 05:05 NOFUNEVER

the tool provided by flyingpie is much better: doesn't require pinning and hides taskbar button completely, tbh I'm using it with other app (since Terminal misses few other things too)

zakius avatar Oct 12 '19 23:10 zakius

Taking the AutoHotKey solution a bit further:

#SC29::ToggleTerminal()

ShowAndPositionTerminal()
{
    WinShow ahk_class CASCADIA_HOSTING_WINDOW_CLASS
    WinActivate ahk_class CASCADIA_HOSTING_WINDOW_CLASS

    WinMove, ahk_class CASCADIA_HOSTING_WINDOW_CLASS,, -5, -10, A_ScreenWidth + 10, A_ScreenHeight * 0.7,
}

ToggleTerminal()
{
    WinMatcher := "ahk_class CASCADIA_HOSTING_WINDOW_CLASS"

    DetectHiddenWindows, On

    if WinExist(WinMatcher)
    ; Window Exists
    {
        DetectHiddenWindows, Off

        ; Check if its hidden
        if !WinExist(WinMatcher) || !WinActive(WinMatcher)
        {
            ShowAndPositionTerminal()
        }
        else if WinExist(WinMatcher)
        {
            ; Script sees it without detecting hidden windows, so..
            WinHide ahk_class CASCADIA_HOSTING_WINDOW_CLASS
            Send !{Esc}
        }
    }
    else
    {
        Run "c:\Users\kim\AppData\Local\Microsoft\WindowsApps\wt.exe"
        Sleep, 1000
        ShowAndPositionTerminal()
    }
}

This script binds win+½ (on Danish keyboard, the top left button below escape) to a function that brings a running terminal instance into focus, or starts a new instance if non is running, and resizes and positions it "correctly". If terminal is already in focus it hides the window (so it doesn't show up in alt+tab).

kimbirkelund avatar Oct 13 '19 11:10 kimbirkelund

I updated @kimbirkelund solution a bit, so to fix the window size error in case you don't have the taskbar docked at the bottom as same as I do.

You can find the code at my gist here, or copy it directly from below:

; How much height of screen size the terminal window takes.
VRatio := 0.8
; The path to the Windows Terminal exe file.
WtPath = "%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe"

#SC29::ToggleTerminal()

ShowAndPositionTerminal()
{
    ScreenX := GetScreenLeft()
    ScreenY := GetScreenTop()
    ScreenWidth := GetScreenWidth()
    ScreenHeight := GetScreenHeight()
    global VRatio

    WinShow ahk_class CASCADIA_HOSTING_WINDOW_CLASS
    WinActivate ahk_class CASCADIA_HOSTING_WINDOW_CLASS

    WinMove, ahk_class CASCADIA_HOSTING_WINDOW_CLASS,, ScreenX-5, ScreenY-10, ScreenWidth+10, ScreenHeight * VRatio,
}

ToggleTerminal()
{
    WinMatcher := "ahk_class CASCADIA_HOSTING_WINDOW_CLASS"

    DetectHiddenWindows, On

    if WinExist(WinMatcher)
    ; Window Exists
    {
        DetectHiddenWindows, Off

        ; Check if its hidden
        if !WinExist(WinMatcher) || !WinActive(WinMatcher)
        {
            ShowAndPositionTerminal()
        }
        else if WinExist(WinMatcher)
        {
            ; Script sees it without detecting hidden windows, so..
            WinHide ahk_class CASCADIA_HOSTING_WINDOW_CLASS
            Send !{Esc}
        }
    }
    else
    {
        global WtPath
        Run %WtPath%
        Sleep, 1000
        ShowAndPositionTerminal()
    }
}

; Gets the edge that the taskbar is docked to.  Returns:
;   "top"
;   "right"
;   "bottom"
;   "left"
GetTaskbarEdge() {
  WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,,

  if (TW = A_ScreenWidth) { ; Vertical Taskbar
    if (TY = 0) {
      return "top"
    } else {
      return "bottom"
    }
  } else { ; Horizontal Taskbar
    if (TX = 0) {
      return "left"
    } else {
      return "right"
    }
  }
}

GetScreenTop() {
  WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,,
  TaskbarEdge := GetTaskbarEdge()

  if (TaskbarEdge = "top") {
    return TH
  } else {
    return 0
  }
}

GetScreenLeft() {
  WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,,
  TaskbarEdge := GetTaskbarEdge()

  if (TaskbarEdge = "left") {
    return TW
  } else {
    return 0
  }
}

GetScreenWidth() {
  WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,,
  TaskbarEdge := GetTaskbarEdge()

  if (TaskbarEdge = "top" or TaskbarEdge = "bottom") {
    return A_ScreenWidth
  } else {
    return A_ScreenWidth - TW
  }
}

GetScreenHeight() {
  WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,,
  TaskbarEdge := GetTaskbarEdge()

  if (TaskbarEdge = "top" or TaskbarEdge = "bottom") {
    return A_ScreenHeight - TH
  } else {
    return A_ScreenHeight
  }
}

wizcas avatar Oct 19 '19 16:10 wizcas

I don't want to continue to take this feature request off track but I wanted to share the changes I made to the work @wizcas and @kimbirkelund have already done. Never really used AHK before so it's rather hackish but in short I added a menu and a settings file so you can change the following:

  • terminal height
  • terminal opacity
  • terminal font type and size
  • color scheme

All this without recompiling the file or opening up the JSON file and editing it manually. It saves the non profile.json settings (e.g. terminal size) in its own settings.ini file in the same dir. Happy to accept changes to it if anyone wants to contribute. I will also at some point add a theme creator here as it was a bit of a chore converting over a Monokai theme I am currently using (in my gists if anyone wants to suss it out). Here's a small preview of Settings Menu:

image

EDIT: Updated screenshot

You can get the code here: https://gist.github.com/alenbasic/004c5abeb4cc0e0b31b7681371d48898

alenbasic avatar Oct 22 '19 11:10 alenbasic

One of the linked duplicate issues mentioned including tmux control mode support, something that is currently only supported by iTerm on Mac OS. It is an incredibly powerful piece of functionality, but to my knowledge, all attempts to implement it in other terminals died a silent death of unmaintained forks. It would be awesome to have it outside of Mac OS.

pandasauce avatar Nov 11 '19 19:11 pandasauce

I went ahead and started a project, pretty much because of this feature. https://github.com/dotjosh/WinTermPlus

dotjosh avatar Nov 11 '19 22:11 dotjosh

@dotjosh That looks great! Is there any reason why you implemented that as a standalone tool and not a PR? How much effort would it be to merge it?

pandasauce avatar Nov 14 '19 15:11 pandasauce

@dotjosh That looks great! Is there any reason why you implemented that as a standalone tool and not a PR? How much effort would it be to merge it?

I'm strong in C#/WPF and I was able to get it done quickly. I'd be willing to help port it if we are happy with the behavior.

dotjosh avatar Nov 14 '19 15:11 dotjosh

Honestly I think that looks super cool. I'd definitely be happy to review that PR.

It might be a little tricky to port the taskbar tray bits to the more UWP-like model we have (you'll probably need to muck with the package.appxmanifest), this tutorial looked good though. It would also probably make more sense to put the settings for the size to open the window at within profiles.json, and have the binding defined in there as well (even if it doesn't actually do anything in the TerminalApp, since I presume the binding would need to be registered with the OS itself. I'm sure there's a way to do it in C++, though I don't know what it is 😄

Just quoting something I've said before:

I just want to re-iterate that while no one on the team is going to have the cycles to do this for 1.0, we'd pretty happily review a contribution from the community. Ideally someone in the community would be able to compile the suggestions and comments from this thread into the Spec Template and submit a PR for that spec. Once that spec is approved, we'd happily review a PR with the code change needed. Looks to me like ~~@flyingpie~~ @dotjosh has really got 90% of the basics down, it'd mostly be polishing the edge cases.

Honestly we don't really need everything in the spec template filled out, I'd just really like to make sure that whatever contribution we accept has thought out the edge cases here, and clearly defines the behavior for those cases. Namely:

  • What happens when the user doesn't yet have a Terminal instance open, and they press the global hotkey?
  • What happens when the user has multiple Terminal windows open? Which one opens? Does nothing happen in that case?
    • With multiple terminal windows open, and one terminal currently focused, does the global hotkey hide the active window, or summon a minimized one?
  • Can the user choose to have the window appear maximized? Fullscreen?

zadjii-msft avatar Nov 14 '19 16:11 zadjii-msft

  • What happens when the user doesn't yet have a Terminal instance open, and they press the global hotkey?

I think it depends on what Terminal instance is exactly. If Terminal is not running, then nothing should happen. I don't think there should be a service or something hooking that. If there are no shells left in Terminal, it should still be running, waiting for a new shell to open. Quitting Terminal would need to be more explicit.

  • What happens when the user has multiple Terminal windows open? Which one opens? Does nothing happen in that case?
  • With multiple terminal windows open, and one terminal currently focused, does the global hotkey hide the active window, or summon a minimized one?

I think the general assumption is this mode would only allow one terminal instance. Launching the executable a second time would merely focus the terminal, possibly launching a new default shell in it? (Much like UWP apps function. Open Settings, then focus something else, then open Settings again, only one instance.)

  • Can the user choose to have the window appear maximized? Fullscreen?

I don't see why not if both of those are supported currently. 👍 The hotkey would function roughly the same as minimizing/restoring from minimized in both of those cases.

rlabrecque avatar Nov 14 '19 19:11 rlabrecque

May I suggest starting with the user experience of other popular terminals and altering it from there if they are suboptimal?

  • What happens when the user doesn't yet have a Terminal instance open, and they press the global hotkey?

Nothing, because the terminal is not running. Moreover, the hotkey should be released for other programs to use in this case. This is how ConEmu and Terminator behave.

  • What happens when the user has multiple Terminal windows open? Which one opens? Does nothing happen in that case?

If single instance setting is active: there can be no multiple windows open.

If single instance setting is not active, Terminator sends the command to all instances and they all toggle states. This might be the simplest solution; it doesn't make much sense to use quake mode with multiple instances and this way terminals won't get permanently stuck in hidden state (terminator hides the window from the taskbar in hidden state).

ConEmu: enabling quake mode enforces single instance mode and grays out the check box. This makes more sense behavior-wise, but introduces more complexity.

I don't think the absence of single instance mode (#2227) should get in the way of implementing this functionality.

  • With multiple terminal windows open, and one terminal currently focused, does the global hotkey hide the active window, or summon a minimized one?

See above - both. It toggles their states.

  • Can the user choose to have the window appear maximized? Fullscreen?

In both ConEmu and Terminator this is not relevant to quake mode, the window gets restored into whatever state it was in before being toggled hidden. If it was full screen, it restores to full screen; same for maximized and non-maximized windows.

pandasauce avatar Nov 15 '19 20:11 pandasauce

just being a little nitpicky: none of popular terminals use actual (exclusive) fullscreen but can be rendered borderless

and I think it's much better for the usecase

zakius avatar Nov 15 '19 22:11 zakius

From user's viewpoint, the main difference between "fullscreen" and windowed maximized seems to be that "fullscreen" covers the taskbar. -------- Original message --------From: zakius [email protected] Date: 15/11/2019 22:38 (GMT+00:00) To: microsoft/terminal [email protected] Cc: Igroeg Okiob [email protected], Comment [email protected] Subject: Re: [microsoft/terminal] Feature request: hot key drop down ala   quake/guake/tilda (#653) just being a little nitpicky: none of popular terminals use actual (exclusive) fullscreen but can be rendered borderless and I think it's much better for the usecase

—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or unsubscribe. [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/microsoft/terminal/issues/653?email_source=notifications\u0026email_token=AB2TW7D3V347CBC62MCQ32TQT4QHVA5CNFSM4HL735C2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEG5YSA#issuecomment-554556488", "url": "https://github.com/microsoft/terminal/issues/653?email_source=notifications\u0026email_token=AB2TW7D3V347CBC62MCQ32TQT4QHVA5CNFSM4HL735C2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEG5YSA#issuecomment-554556488", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

pandasauce avatar Nov 15 '19 22:11 pandasauce

A Quake console style hotkey (ConEmu) is a must. Has anyone been able to attached Terminal to ConEmu?

bdwakefield avatar Jan 03 '20 19:01 bdwakefield

@dotjosh That looks great! Is there any reason why you implemented that as a standalone tool and not a PR? How much effort would it be to merge it?

I'm strong in C#/WPF and I was able to get it done quickly. I'd be willing to help port it if we are happy with the behavior.

We are! Can we have this a pull-request?

josefnorlin avatar Feb 21 '20 20:02 josefnorlin

For some people it's not important at all, for others it's a dealbreaker, though I'd be able to live without it thanks to some workarounds posted here so personally I'd prioritize things that can't be supplemented in any way like #574 (or likely many other, that's just my second dealbreaker)

zakius avatar Mar 22 '20 21:03 zakius

Right. You're talking about how we've failed to prioritize this appropriately, and I appreciate that this feature is important to you. I'd like to ask, however: with the four engineers on the core team, which of the features completed in the following milestones (scoped query, plus loose features) should we have cut to make room for custom window management?

  • Features marked Fix-Committed and closed
  • accessibility
  • tabs in the titlebar
  • panes
  • settings validation
  • profile detection
  • rationalized exit semantics
  • proper rendering for CJK ideographs
  • input support for non-US-ANSI keyboard users
  • resizing that doesn't delete your history
  • search
  • (i could continue to list features here)

I can commit engineering to one, maybe two features per dev per month. It's been 10 months, and in most of that time we've had a team of 2-3 instead of 4.

If you can identify which of those things that we decided were table stakes that we should have shipped without, I'm happy to have that discussion with you.

DHowett-MSFT avatar Mar 22 '20 21:03 DHowett-MSFT

If this is such a low-hanging fruit, then I'd be happy to review a PR from a community member to address this feature 😉. As it currently stands, the dev team is in a feature-freeze and bug-fix/polish sprint for the next couple months. We'll certainly be looking at our backlog for tasks to start on once 1.0 lands, and I want to make it clear that the team understands this one is a popular ask.

zadjii-msft avatar Mar 23 '20 13:03 zadjii-msft

pinning it to the taskbar and using Win+1 to access it is ok as a workaround (although I'm now using kimbirkelund autohotkey script from https://github.com/microsoft/terminal/issues/653#issuecomment-541408854). I don't think this should be a priority.

Perhaps someone could compile kimbirkelund or wizcas's script and provide a binary for those that don't want to instal autohotkey?

SamHasler avatar Mar 25 '20 21:03 SamHasler

there are much better workarounds than keeping it on Taskbar what is the exact thing we want to avoid, but as you said there are some so while it's important it's lower on the priority list than things that can't be supplemented with external tools

zakius avatar Mar 26 '20 08:03 zakius