Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tmux and nano in console

398 views
Skip to first unread message

mick crane

unread,
Dec 22, 2021, 9:10:04 AM12/22/21
to
I'm trying to use the console to see if my editing problems go away.
Want to copy lines from one file into another.
Splitting the screen with tmux with the 2 files opened in nano the nano
buffer is not shared.
Seems can have more than one buffer in nano but the things I want are
not in the same file.
If use the mouse to select text in one file in one tmux window the
selection goes across both windows/files.
Is there a way in console to achieve copying lines from one file to
another ?

mick
--
Key ID 4BFEBB31

Markus Schönhaber

unread,
Dec 22, 2021, 10:40:05 AM12/22/21
to
22.12.21, 14:59, +0100, mick crane:
Since tmux knows how to cope with tmux' panes, what's wrong with using
the copy/paste functionality tmux provides?

--
Regards
mks

Alexander V. Makartsev

unread,
Dec 22, 2021, 1:10:05 PM12/22/21
to
'tmux' was made to let people work in console without using a mouse. Ideally, to do everything without even touching a mouse at all and always keep their fingers on 'A' 'S' 'D' 'F' and 'J' 'K' 'L' ';' keys.
Like when you use 'vim' (or 'nano' in your case), you just type and use memorized key combinations to perform actions on text, buffers, etc, and in case of 'tmux' , on text inside multiple panes.
Personally, I've failed to memorize all the commands of 'tmux' and 'vim' and "be efficient and fast without a mouse", as it says on a tin.
But I've managed to remember a few major ones and still enjoy working inside several consoles on a single screen and do that quite frequently.

AFAICR I had to personalize configurations for both 'tmux' and 'vim' , so they would use clipboard of X server instead of their own buffers.
I can use mouse to select and copy lines of text in linear or in rectangular fashion:
Rectangular fashion:
    Hold Shift + Hold Ctrl + Press and hold LMB at the beginning of the text you want to copy;
    Move mouse to select wanted text lines and release LMB;
    Click LMB on the selected text and then release Shift and Ctrl keys.

Linear fashion:
    Hold Shift + Press and hold LMB at the beginning of the text you want to copy;
    Move mouse to select wanted text lines and release LMB;
    Click LMB on the selected text and then release Shift key.

Linear fashion for a single 'tmux' pane:
    Press and hold LMB at the beginning of the text you want to copy;
    Move mouse to select wanted text lines and press 'y' key;
    Then release LMB.

To paste copied text press "Ctrl + v" or "Shift + Ctrl + v" or "Shift + Insert" or "Shift" + "p" (if you would use 'vim').
If my directions work differently for you, here I've tried to gather, hopefully, relevant config lines from my "~/.tmux.conf":

========8<============8<============8<============8<====
## Mouse mode enabled by default
set -g mouse on
## Use vi control scheme by default
set-window-option -g mode-keys vi
## Use system buffer for copy paste operations in tmux
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection
bind -T copy-mode-vi y send-keys -X copy-pipe "xclip -sel clip -i"
bind P paste-buffer
bind-key -T prefix PageUp copy-mode -eu
bind-key -T prefix PageDown copy-mode
========8<============8<============8<============8<====

Btw, keys 'v' (visual mode select) 'y' (copy text) and 'P' (paste text) are for the same actions in 'vim' , so they are easier to remember.
Also, I use Xfce and "xfce4-terminal" so my instructions may not work if your DE is different.


-- 
With kindest regards, Alexander.

⢀⣴⠾⠻⢶⣦⠀ 
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀⠀⠀⠀ 

mick crane

unread,
Dec 22, 2021, 3:20:04 PM12/22/21
to
On 2021-12-22 18:00, Alexander V. Makartsev wrote:

snipped lots of useful stuff.

> Also, I use Xfce and "xfce4-terminal" so my instructions may not work
> if your DE is different.

Thanks very much I'll use those tips. I just started using tmux today
and looks handy.
Seems may be like screen as well which I've not really used either.
I'm using because something doesn't seem to like something I've done and
so far not having problems in console so likely something in X.

cheers
0 new messages