Linux bash shell copy previous lines (not history) with keyboard
Solution 1:
As far as I know, neither of the "big three" terminal emulators can do that, but both screen
and tmux
offer a scrollback buffer you can access via keyboard.
GNU screen
screen
's Prefix key is Ctrl+A per default, but all of that is customizable, so with a default config:
Enter copy mode with Ctrl+A[.
Move cursor around with
vi
motions: h, j, k, l, 0, ^, $, H, M, L, w, b, e, /, ?, g and G all work (seeman screen
undercopy
for more info on key bindings).Start selecting with Space, move around, and stop selecting with Space again. This will leave copy mode.
Paste the selected text with Ctrl+A].
tmux
tmux
behaves pretty much the same, except it uses some different keys per default:
Enter copy mode with Ctrl+B[.
Move cursor around with ←, ↓, ↑, →, PgUp, PgDown etc. (see
man tmux | less -p '^WINDOWS AND PANES'
for the list of copy-mode bindings).Start selecting with Ctrl+Space, move around, and stop selecting with Meta+w. This will leave copy mode.
Paste the selected text with Ctrl+B].
Solution 2:
Depends on the terminal you use. It is possible in shell mode in emacs
.