On Fri, 29 Jan 2021, at 2:28 AM, Peng Yu wrote:
> The "Tmux Plugin Manager" instruction mentioned in the above webpage
> is confusing.
> 
> https://github.com/tmux-plugins/tpm
> 
> On the above page it says to add these to ~/.tmux.conf
> 
> set -g @plugin 'tmux-plugins/tpm'
> set -g @plugin 'tmux-plugins/tmux-sensible'
> 
> But the clone was only about the first line. How can I add the second
> line when it is not cloned?

You only need to clone Tmux Plugin Manager (tpm) itself. After that, Tmux 
Plugin Manager will clone the plugins (tmux-sensible, tmux-yank, etc) for you 
when you run `~/.tmux/plugins/tpm/bin/install_plugins`.

> $ git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
> 
> >
> > It uses the tmux-yank plugin to achieve the cross-platform behaviour.
> >
> > Also see my tmux config:
> >
> > https://github.com/seanh/tmux
> 
> Which approach do you recommend? Your approach or the approach on
> seanh.cc? What is their difference?

They're the same. Or nearly identical anyway. github.com/seanh/tmux is my 
actual current tmux config. The blog posts on seanh.cc are tutorials explaining 
how parts of my config work.

> > This doesn't bind command-c on mac. But this is the line that binds 
> > control-c on linux, you could add a similar line for mac but using 
> > command-c and pbcopy:
> >
> > bind -T copy-mode-vi C-c send -X copy-pipe-no-clear "xsel -i --clipboard"
> 
> So then this file will not be same anymore for both mac and Linux.
> Therefore, this solution does not address my original question?

A single config file could bind two different shortcuts, one for mac and one 
for linux. For example (you'd have to fill out the pbcopy command for mac, I 
don't have a mac so I can't test it):

    # Make Ctrl+c copy into the clipboard. This will only work on Linux.
    bind -T copy-mode C-c send -X copy-pipe-no-clear "xsel -i --clipboard"
    bind -T copy-mode-vi C-c send -X copy-pipe-no-clear "xsel -i --clipboard"

    # Make Alt+c copy into the clipboard. This will only work on mac.
    bind -T copy-mode M-c send -X copy-pipe-no-clear "pbcopy ..."
    bind -T copy-mode-vi M-c send -X copy-pipe-no-clear "pbcopy ..."

I don't have an example for how to make a single keyboard shortcut copy into 
the clipboard on both mac and linux. But I think it'd be easy enough to write a 
shell script that tries to call xsel and if that fails tries pbcopy. Then have 
a key binding in your tmux.conf call that script.

The tmux-yank plugin already does this: it uses "y" as the keyboard shortcut to 
copy into the clipboard and works on both mac and linux: 
https://github.com/tmux-plugins/tmux-yank

Note that you cannot bind the macOS command key in tmux. That's not possible. 
Tmux only supports Ctrl, Alt and Shift modifiers. I don't think this is tmux's 
fault--I think it's just a limitation of terminal apps.

I have a tutorial on binding keys in tmux you might find helpful: 
https://www.seanh.cc/2020/12/28/binding-keys-in-tmux/

-- 
You received this message because you are subscribed to the Google Groups 
"tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tmux-users+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/tmux-users/bdd6cb88-2884-419a-aceb-62c44ce18a9e%40www.fastmail.com.

Reply via email to