How to copy text from command line to clipboard without using the mouse?

If using xterm or a derivative you can setup key bindings to start and end a text selection, and save it as the X11 primary selection or a cutbuffer. See man xterm. For example, add to your ~/.Xdefaults:

XTerm*VT100.Translations: #override\n\
    <Key>KP_1: select-cursor-start() \
            select-cursor-end(PRIMARY, CUT_BUFFER0)\n\
    <Key>KP_2: start-cursor-extend() \
            select-cursor-end(PRIMARY, CUT_BUFFER0)\n

You can only have one XTerm*VT100.Translations entry. Update the X11 server with the new file contents with xrdb -merge ~/.Xdefaults. Start a new xterm.

Now when you have some input at the command prompt, typing 1 on the numeric keypad will start selecting text at the current text cursor position, much like button 1 down on the mouse does. Move the cursor with the arrow keys then hit 2 on the numeric keypad and the intervening text is highlighted and copied to the primary selection and cutbuffer0. Obviously other more suitable keys and actions can be chosen. You can similarly paste the selection with bindings like insert-selection(PRIMARY).