3

In spite of heavy tmux use and switching between panes, I still frequently find myself using shell job control. When something needs poking I'll background the tool I'm using with Ctrl+Z, poke the thing, then fg the tool again. The issue is sometimes the "poking" turns into using another tool and I want to go back and forth a couple times.

Would it be possible to bind another key that is trapped by the shell (i.e. not ever passed though to a foreground app) that backgrounds the current job and foregrounds whatever the most recent background job is?

ctrl-alt-delor
  • 27,473
  • 9
  • 58
  • 102
Caleb
  • 69,278
  • 18
  • 196
  • 226
  • 1
    You can't have a key that goes directly to the shell because it isn't reading from the terminal. You can have a tmux binding that sends a succession of keys but it might be tricky because tmux can't control who is reading from the terminal. A few keys are interpreted by the terminal and transmitted to the shell as a signal, e.g. Ctrl-z → SIGSTOP, but you can't define new signals. Are two keys acceptable? For example I've [set up my shell](https://unix.stackexchange.com/a10851) so that `C-z C-z` backgrounds the foreground program, with a stop that's as brief as my ability to press two keys. – Gilles 'SO- stop being evil' Oct 25 '19 at 16:03
  • @Gilles, I'd be happy with `C-z C-z` backgrounding one job and forgrounding the other, yes. I do wonder if any of the existing signals could be clobbered instead. There are a couple I don't care about, and even have disabled (`C-s` for example). – Caleb Oct 25 '19 at 16:21
  • `C-s` is a terminal action that doesn't send a signal. The only signals are `C-c` → SIGINT, `C-z` → SIGTSTP and `C-\` → SIGQUIT. If you're happy with `C-z C-z`, I suggest that you adapt my function to select whichever foreground job you want. – Gilles 'SO- stop being evil' Oct 25 '19 at 16:27
  • 1
    Giles you linked to a 404. – ctrl-alt-delor Oct 25 '19 at 17:05
  • 1
    I think the link should be https://unix.stackexchange.com/a/10851 – Mikel Oct 29 '19 at 02:43

0 Answers0