Skip to content

Instantly share code, notes, and snippets.

@harilvfs
Last active April 3, 2025 17:38
Show Gist options
  • Save harilvfs/7ce5a5b2fd23a5a47ca4ba2fc7a5efb8 to your computer and use it in GitHub Desktop.
Save harilvfs/7ce5a5b2fd23a5a47ca4ba2fc7a5efb8 to your computer and use it in GitHub Desktop.

Revisions

  1. harilvfs revised this gist Apr 3, 2025. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions tmuxyank.md
    Original file line number Diff line number Diff line change
    @@ -18,13 +18,13 @@ Tmux needs **xclip** (and possibly **xsel**) to properly integrate with the syst
    > sudo pacman -S xclip xsel
    > ```
    >
    > ```sh
    > - **Ubuntu/Debian**:
    > ```sh
    > sudo apt install xclip xsel
    > ```
    >
    > ```
    > - **Fedora**:
    > ```sh
    > sudo dnf install xclip xsel
    > ```
  2. harilvfs created this gist Apr 3, 2025.
    55 changes: 55 additions & 0 deletions tmuxyank.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,55 @@
    # Fix: Tmux Yank Not Working

    I had the same problem—Tmux yanking suddenly stopped working for me. I didn’t change anything, yet it just broke.

    At first, I ignored it, thinking it was a temporary issue. But when it didn’t fix itself, I searched online and found that others were facing the same problem. I came across this discussion in the **tmux-yank** GitHub repository:

    🔗 **[Tmux Yank Issue #172](https://github.com/tmux-plugins/tmux-yank/issues/172)**

    After trying different solutions from the discussion, I finally got it working!

    ## 🔧 **Solution**

    ### 1️⃣ Install `xclip` and `xsel`
    Tmux needs **xclip** (and possibly **xsel**) to properly integrate with the system clipboard. Install them using your package manager:

    > - **Arch Linux**:
    > ```sh
    > sudo pacman -S xclip xsel
    > ```
    >
    > ```sh
    > - **Ubuntu/Debian**:
    > sudo apt install xclip xsel
    > ```
    >
    > ```
    > - **Fedora**:
    > sudo dnf install xclip xsel
    > ```
    ### 2️⃣ Update Your Tmux Config
    Edit your **Tmux configuration file**:
    - `~/.tmux.conf` **or**
    - `~/.config/tmux/tmux.conf` (depending on your setup)
    Add the following lines:
    ```sh
    # Enable clipboard
    set -g set-clipboard on
    set -g @override_copy_command 'xclip -i -sel p -f | xclip -i -sel c'
    set -g @yank_selection 'clipboard'
    set-option -sa terminal-features ',*:clipboard'
    ```
    ### 3️⃣ Reload Tmux Configuration
    After saving the file, reload Tmux:

    ```sh
    tmux source-file ~/.tmux.conf
    ```

    Now, try yanking text again. It worked for me, and many others—hopefully, it works for you too!

    💡 **Credit**: Huge thanks to the contributors in the [GitHub issue](https://github.com/tmux-plugins/tmux-yank/issues/172) who helped find this fix!