Comment

Comment by jcard

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.)
parent jcard 5 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton