Recent submissions

Comment · 5 years ago
AFAIK, you'll need to have at least `setw -g mode-keys vi` in your ~/.tmux.conf file to allow tmux to use vi keybindings in copy mode (`Ctrl+b ]`). Make sure to fully exit all tmux sessions and start a new session after making that change.

I have basically the same setup as you, and I think that's the only thing I've manually configured. I also run the oh-my-zsh tmux plugin, and iTerm2's tmux integration, which seemed to work out of the box for me.

Comment · 5 years ago
Comment · 5 years ago
That's a fair point! The kubernetes example I gave is somewhat contrived, but I will say that I prefer to have whatever resource id I'm working with in my clipboard vs. relying on myself to select the correct one in a tab completion menu.

Where I really like this tmux copy/paste workflow is for grabbing multiple lines of command output. From there I can paste that into some message on slack, or use it as the body of a PR message that describes some error or shows some output.

For the latter case, I have a zsh function that calls `hub` to open a PR, drops me off into vim, and once I `:wq`, it will send the API request to open the PR, and then open my browser up to it. This is the command I have in the function: `hub pull-request --push --file "$filename" --browse --draft`.

Comment · 5 years ago
I haven't tried it, but that looks pretty great! Kind of like a TUI version of something like Lens.
Comment · 5 years ago
This should work the same locally & on remote hosts. Tmux doesn't care that you're ssh'd into some host.

As long as your system & version of tmux supports copying to the local clipboard, you should have no problems pasting with either Ctrl/Cmd+v or `Ctrl+b ]`.

Otherwise, if the clipboard is broken for some reason, you can stick to using `Ctrl+b ]` to paste.

Comment · 5 years ago
Using the tmux vi keybindings to copy and paste between panes is great if you haven't tried it.

This copy/paste workflow is really nice for working with kubernetes on the command line.

E.g., imagine that you need to delete a kubernetes pod.

You'd run a few commands like this:

1. `kubectl get pods`

2. Find the pod id, and copy it using mouse & some shortcut

3. `kubectl delete pod <pasted-pod-id>`

Instead of this mouse workflow, you could do something like this in tmux:

1. `kubectl get pods`

2. Find pod id, `Ctrl+b [` to enter tmux's vi selection mode

3. Navigate to the section you'd like to copy; e.g. `k6ww` (up six lines and over two words, for example)

4. Press space bar to start selection, and use common vim movements to highlight what you'd like to copy (e.g. w or $)

5. Press return/enter to copy the selection

6. This text can be pasted with either Cmd/Ctrl+v (it gets copied to the system clipboard for me on macOS 11.2.1 with tmux 3.1c_1 from brew), or using the default tmux shortcut `Ctrl+b ]`. So that would allow you to type `kubectl delete pod Ctrl+b ]`.

So yeah, it's a few more steps, but it's a lot faster for me.

These are the relevant sections of my ~/.tmux.conf file:

  # Use vim keybindings in copy mode
  setw -g mode-keys vi

  # Use emacs keybindings in the status bar
  set -g status-keys emacs
(I mention the `set -g status-keys emacs` config line just as an FYI since it's been really helpful for me with tmux. I've never liked using readline-type inputs with vi-mode.)

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton