In an interactive shell session, how do I copy to clipboard text that was cut with Ctrl+U? Without using the mouse, obviously. Thus making it available for other GUI applications, instead of pastable only with Ctrl+Y only in the terminal where the Ctrl+U was issued.
Update: added bash
tag to cover answers involving bash-only solutions.
xclip
or similar. – Ignacio Vazquez-Abrams Feb 09 '18 at 22:35^Y
does not remove text; it yanks what was last killed and "pastes" it. Did you mean^W
,^U
,^K
,M-D
, and the like? – DopeGhoti Feb 09 '18 at 22:40if [[ -n $DISPLAY ]]; then copy_line_to_x_clipboard() { printf %s "$READLINE_LINE" | xsel -ib; }; bind -x '"\C-u": copy_line_to_x_clipboard'; fi
doesn't work? – argle Feb 10 '18 at 22:49stty kill ''
beforebind -x "\C-u": …
. This could warrant a question of its own if it isn't a duplicate. – Gilles 'SO- stop being evil' Feb 11 '18 at 19:01