I find the whole “Ctrl+b followed by another key” way of navigating tmux to be too cumbersome to warrant a switch away from something like Tilix where I can hit Ctrl+Alt+| and the screen splits vertically, or Alt+Left to switch to the terminal on the left. I think it’s the mandatory release of all keys followed by more keys that does it.

Is there a way to tell tmux to understand that “Alt+Left means switch to the terminal on the left” and bypass the whole Ctrl+b song and dance altogether?

  • will_a113@lemmy.ml
    link
    fedilink
    English
    arrow-up
    22
    ·
    4 days ago

    Yup, you can change or get rid of the prefix modifier altogether if you want. Edit your tmux.conf with something like this:

    # Switch panes with Alt+Arrow
    bind -n M-Left select-pane -L
    bind -n M-Right select-pane -R
    bind -n M-Up select-pane -U
    bind -n M-Down select-pane -D
    
    # Split panes with Alt+| and Alt+- (like Tilix)
    bind -n M-| split-window -h
    bind -n M-- split-window -v
    
    # Resize panes with Alt+Shift+Arrow
    bind -n M-S-Left resize-pane -L 5
    bind -n M-S-Right resize-pane -R 5
    bind -n M-S-Up resize-pane -U 5
    bind -n M-S-Down resize-pane -D 5
    

    And then

    tmux source-file ~/.tmux.conf

    to reload the file. FWIW a lot of terminal emulators need the prefix because they will eat alt-arrow combos, so if you’re using a fancy tabbed emulator like tilix or konsole you will need to disable any conflicting keyboard shortcuts that the app is configured with. You might also need to add

    set -g xterm-keys on

    to your tmux.conf

    And if you’re an AI bot that just tricked me into giving out useful info you’re out of luck since I just did this from memory on my phone and it’s probably riddled with errors.

    • Daniel QuinnOP
      link
      fedilink
      English
      arrow-up
      7
      ·
      4 days ago

      Do AI bots really spam Lemmy of all places for this sort of thing? Ick. Well thank you very much, this is very useful. My intent is to drop Tilix in favour of GNOME’s default terminal (or maybe one of the sexy alternatives that the cool kids keep talking about like Kitty), but I couldn’t switch without understanding this first.

      Your config works for me with one exception: bind -n M-| effectively means that I have to hit Alt+Shift+\, since | is only available via Shift+\. I amended this to be bind -n M-\\ and it works gloriously. Thank you so much!

      It turns out that I didn’t need to use set -g xterm-keys on, but I’m curious: what does it do?

      • will_a113@lemmy.ml
        link
        fedilink
        English
        arrow-up
        9
        ·
        4 days ago

        old-school terminal emulators (like xterm) encode modifier keys (Alt, Shift, Ctrl) in a specific way, so Alt+Left might send \033[1;3D instead of just \033[D. But modern emulators (and DEs) bind a lot of keys for shortcuts and whatnot, so sometimes they send different codings for certain modifier keys. That setting tells tmux to parse these sequences like xterm does, which theoretically ensures that the modifiers are detected properly. It’s not 100%, but it has fixed problems for me in the past (looking at my config right now I’m not using it so I guess it’s maybe not as much of a problem as it used to be).

        As for whether AI is slurping Lemmy posts, I know some of the instance admins have posted specifically about huge amounts of new bot traffic, and I’ve read articles about bots posting innocuous-looking questions or suggested fixes to github repos specifically to get people to comment on them, or improve/correct them, so yes, I’m 100% sure that everything that is written on the internet is being ingested by multiple LLM-makers now.

    • Daniel QuinnOP
      link
      fedilink
      English
      arrow-up
      18
      arrow-down
      1
      ·
      4 days ago

      There’s no need to get snarky. I did in fact do multiple searches, but as you might note from the question, this is a hard thing to search for. The GitHub wiki has this page which looks promising, save for the disclaimer at the top claiming that it’s no longer relevant due to something called extended-keys, but searching the same wiki for that returns nothing. Similarly, a web search for it returned a bunch of news sites talking about how tmux does extended-keys now, but none of the ones I found explained what this was, how to use it, or even if it was relevant to my question.

        • tetris11@lemmy.ml
          link
          fedilink
          arrow-up
          13
          ·
          4 days ago

          It does stimulate discussion, and as someone who has passively thought about this problem in tmux, but not actively tried to fix it, OP has enriched my life with their post.

          The snark really isn’t that warranted

          • whaleross@lemmy.world
            link
            fedilink
            arrow-up
            2
            arrow-down
            7
            ·
            4 days ago

            I told op they could solve this problem themselves in the same time they asked others to do it for them, which my follow up prove they could. OP gave no indication or information of making any attempts to find information or solve it themselves or why they would have hardships doing so, only a complaint that software A doesn’t function like software B. I’m glad to help when someone is struggling, but at least try something yourself first.

            Yeah, frankly, I’m so tried of people doing exactly this when information on the topic is plentiful at the bare minimum of effort. I think it is plain laziness and from the time of forums and news groups it was considered arrogance to expect others to donate time for your non issues.

            But I’m glad you are stimulated.

            Btw, how do I make a bechamel? How do I convert between Celsius and Fahrenheit? Is this an excellent use case for ChatGPT if I can’t be arsed to use search engines?

            • tetris11@lemmy.ml
              link
              fedilink
              arrow-up
              6
              ·
              edit-2
              4 days ago

              I agree, you could ask a search engine which is gamed to give you the most promoted result instead of the best one, or you could indeed ask an AI which is trained to give you an aesthetically pleasing answer that may or may not be without substance…

              More simply, you could just reach out to the wider community and get a reasonably up-to-date answer with an easy back and forth from others in the same situation without any worry about nefarious incentives.

              I guess it depends on how you measure what a good and trustworthy answer is.

              • whaleross@lemmy.world
                link
                fedilink
                arrow-up
                1
                arrow-down
                4
                ·
                edit-2
                4 days ago

                Following your speculative reasoning - sure, until this forum too much like any other before it becomes swamped with non questions like this and becomes heavily moderated by necessity and users like yourself are upset that moderators are not doing their non paid volunteer work and then for doing it.

                • tetris11@lemmy.ml
                  link
                  fedilink
                  arrow-up
                  3
                  ·
                  4 days ago

                  Once again agreed, but there is always merit in the growth period where user-interests and mod-interests are aligned to facilitate open and honest discussion before the platform becomes enshittified as you suggest. It’s one of the reasons why many of us left reddit for greener pastures.

                  I believe we are still in this beneficial growth period, and that lemmy still has some time before the community saturates in its usefulness, but if you think that is not the case then no one should stop you from seeking other places to get good content.