Feature Request: global hotkey to re-run last command #3942

Open
opened 2026-01-30 23:33:55 +00:00 by claunia · 5 comments
Owner

Originally created by @Christilut on GitHub (Sep 19, 2019).

Description of the new feature/enhancement

I would really like to see the ability to bind a global hotkey to repeat the last command in the visible terminal. In essence all it does is: up arrow and enter on the terminal that is visible. Should work even when terminal has no focus since I'm pressing this global hotkey when I'm not in the terminal.

Global hotkeys should be bindable to any key, including special keys such as Scroll Lock, Pause/Break and the Context Menu (the button next to the right CTRL).

iTerm2 has this functionality and no other terminal emulator I've tried has this, on Linux or Windows. I'm sure this is achievable with AutoHotkey but I'd prefer native functionality.

Use case for me:
When testing or running experimental scripts, it is common to rerun your script every time you make a change. It is very productive for me if I don't need to take my hands off the keyboard for this. Personally I would bind this functionality to the "context menu" key (between CTRL and Windows), since I never use that button anyway.

Originally created by @Christilut on GitHub (Sep 19, 2019). # Description of the new feature/enhancement I would really like to see the ability to bind a global hotkey to repeat the last command in the visible terminal. In essence all it does is: `up arrow` and `enter` on the terminal that is visible. Should work even when terminal has no focus since I'm pressing this global hotkey when I'm not in the terminal. Global hotkeys should be bindable to any key, including special keys such as Scroll Lock, Pause/Break and the Context Menu (the button next to the right CTRL). iTerm2 has this functionality and no other terminal emulator I've tried has this, on Linux or Windows. I'm sure this is achievable with AutoHotkey but I'd prefer native functionality. Use case for me: When testing or running experimental scripts, it is common to rerun your script every time you make a change. It is very productive for me if I don't need to take my hands off the keyboard for this. Personally I would bind this functionality to the "context menu" key (between CTRL and Windows), since I never use that button anyway.
claunia added the Issue-FeatureHelp WantedProduct-TerminalArea-UserInterface labels 2026-01-30 23:33:55 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Sep 19, 2019):

Okay so what you're actually asking for is two things:

  • Global hotkeys that can be bound to Keybindings/ShortcutActions
  • A ShortcutAction that can send input to the terminal

The second part I've already discussed as a part of #2046, so I'm not gonna delve into that too far. I think that's a fine idea, and I'm totally on board. Might need some modification to support VKEYs as input, not just characters, but we can work that out.

The first part might be trickier. It certainly plays into discussion being had in #653. My real question is this: if you have multiple Terminal windows open, which one should the hotkey activate? Do they all get the hotkey's activation?

I'd be worried that this is dependent upon having #2080 and it's associated work finished, as we'll need to have a single manager process to be able to send global hotkeys to, that can then dispatch them to the appropriate Terminal instance.

@zadjii-msft commented on GitHub (Sep 19, 2019): Okay so what you're actually asking for is two things: * Global hotkeys that can be bound to Keybindings/ShortcutActions * A ShortcutAction that can send input to the terminal The second part I've already discussed as a part of #2046, so I'm not gonna delve into that too far. I think that's a fine idea, and I'm totally on board. Might need some modification to support VKEYs as input, not just characters, but we can work that out. The first part might be trickier. It certainly plays into discussion being had in #653. My real question is this: if you have multiple Terminal windows open, which one should the hotkey activate? Do they all get the hotkey's activation? I'd be worried that this is dependent upon having #2080 and it's associated work finished, as we'll need to have a single manager process to be able to send global hotkeys to, that can then dispatch them to the appropriate Terminal instance.
Author
Owner

@Christilut commented on GitHub (Sep 19, 2019):

Yes that sounds exactly right.

To answer your question: I'd expect the terminal that was last focused to receive the signal.

There might be use cases for sending the signal to all terminals, perhaps this can be a setting. But I think it would be intuitive to send it to the last focused terminal by default.

@Christilut commented on GitHub (Sep 19, 2019): Yes that sounds exactly right. To answer your question: I'd expect the terminal that was last focused to receive the signal. There might be use cases for sending the signal to all terminals, perhaps this can be a setting. But I think it would be intuitive to send it to the last focused terminal by default.
Author
Owner

@nofunatall commented on GitHub (Sep 30, 2019):

How would this work if you have a heavily modified bash profile?
i.e you've changed what up arrow does

@nofunatall commented on GitHub (Sep 30, 2019): How would this work if you have a heavily modified bash profile? i.e you've changed what up arrow does
Author
Owner

@Christilut commented on GitHub (Sep 30, 2019):

If the terminal can just send in the up arrow key command then it's up to bash to decide what to do with it.
I think if a user modifies their bash like this then they would expect this global hotkey to execute whatever normally happens when they physically press the up arrow button.

But this would be configurable in whatever way the user requires with #2046

@Christilut commented on GitHub (Sep 30, 2019): If the terminal can just send in the up arrow key command then it's up to bash to decide what to do with it. I think if a user modifies their bash like this then they would expect this global hotkey to execute whatever normally happens when they physically press the up arrow button. But this would be configurable in whatever way the user requires with #2046
Author
Owner

@fishzle commented on GitHub (Feb 15, 2020):

Are there any concerns with input-stealing? Or focus-stealing?
I'm thinking about how this feature sounds similar to the magic sysrq key in linux.
Another thought is that in a single-user environment, it's possibly safe, but in a multi-user/VM/docker environment, could this be unsafe?

@fishzle commented on GitHub (Feb 15, 2020): Are there any concerns with input-stealing? Or focus-stealing? I'm thinking about how this feature sounds similar to the magic sysrq key in linux. Another thought is that in a single-user environment, it's possibly safe, but in a multi-user/VM/docker environment, could this be unsafe?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#3942