How can I select and copy to clipboard the output, for example, of the (n-2)th line, so that I can paste it later with CTRL+SHIFT+V? (without using the mouse, everything with keyboard only)
You could use fzf and xclip something like
ls -la | fzf | xclip -selection clipboard Some utility/program send the output to stderr it might need an additional redirect.
my_command 2>&1 | fzf | xclip -selection clipboard On a mac replace
xclipwithpbcopyfor wayland user use
wl-copy
Is it possible with arrow keys and a combination of keys?
Write a function , e.g.
my_funct(){ ls -la | fzf --height 40% --reverse | xclip -selection clipboard ; } bind it to a combination key e.g.
bind -x '"\C-k": my_funct' Call the function via: CTRL+k
As per comment suggestion one can use vim and use the stdin flag, e.g.
ls -la | vim - But that requires you to know how to use vim and configure/enable the clipboard feature.