1. 27
  1.  

  2. 8

    If anyone else was trying to follow along and couldn’t figure out how to actually copy the selected text, you press return

    1. 4

      Oh wow, thanks. I updated the post to include this – I didn’t realize tmux didn’t bind y by default. That’s crazy town.

    2. 3

      Author is clearly enlightened and has EDITOR or VISUAL set to vim but has therefore deluded himself into thinking tmux is of equally respectable comport - he suggests it is possible to manually opt into emacs keybindings for tmux, it that is actually the default unless a vim-compatible value is detected for one of those two variables.

      (It’s actually clever and I wish more software would detect default keybindings thusly, but obviously the the right choice would be to default to vim-compatible unless emacs were detected!)

      1. 3

        Well, the example config I was discussing has an explicit set -g mode-keys vi call, so if you’re starting with that config (as the paragraph in question presumed) you do have to opt into emacs keys. An earlier draft of this post explained tmux’s default behavior, but I decided it was too much noise since “most” people want vi keys and some people don’t set their EDITOR.

      2. 3

        One thing I find very useful especially if I want to copy longer output is dumping the scrollback to a file:

        bind-key S capture-pane -S- \; save-buffer tmux-scroll
        

        This will save the entire contents to tmux-scroll in the current directory.

        You can limit the number of lines with -E to capture-pane; but I find it’s usually easier to just fix it in Vim.

        I never really liked the “copy mode” in tmux; it’s too much work to really be smooth. I just use the mouse for shorter things.

        1. 3

          I prefer tmux to screen also, but in fairness, screen has been able to copy/paste since I started using it, which wasn’t even in the current millennium, so it’s not that much of a differentiator.

          1. 1

            Oh yeah, for sure. I definitely didn’t mean to imply that this is an advantage of tmux over screen, or a reason to switch to tmux. A surprising number of people got very defensive about screen on the Other Link-Sharing Site. I just mention that because I was genuinely surprised: the article never mentions screen, and I don’t think that saying nice things about tmux is an implicit put-down of screen, but a lot of people seemed to take it that way. I think 80% of developers I’ve worked with have never used either, and I wanted to encourage them to give it a shot.

            1. 2

              Agreed! I guess I took it as implicitly “use this instead of screen” because I assumed everyone is using one or the other, but you’re right, there are probably a lot of people these days who have never heard of either. :)

          2. 1

            One of my favorite Thinkpad+Linux niceties is that without leaving the home row I can use the trackpoint to select a previous command or output (double-click to select by word, triple-click to select by line) and then middle-click anywhere to paste the highlighted text into the prompt.

            It’s not that much faster than using a trackpad and Cmd-C / Cmd-V on a Mac, but faster enough to feel effortless instead of like I’m Doing Something

            1. 1

              What I really want with tmux is to go into a mode where I can interactively select one of the lines in my scrollback and then paste it. (Imagine that you’ve just run git status and you want to invoke your editor on one of the files that was listed.) It turns out that the OP wrote a separate blog post showing you how to do something similar, which I can probably adapt to get exactly the behavior I want. Awesome!

              1. 4

                You can get tmux to do that:

                bind -T copy-mode-vi Enter  if -F "#{selection_present}" { send -X copy-selection-and-cancel } { send -X copy-line }
                

                That will copy the selection if you have one, or copy the line your cursor is on if you don’t. So you enter copy-mode, move your cursor onto the line, and hit copy. It doesn’t highlight the entire line until you hit copy, but shrug.

                (This is similar to pressing V and then Enter with the default keybindings.)