Sample Header Ad - 728x90

Short command or alias to copy last command to clipboard

2 votes
2 answers
544 views
Often I'd like the command I just typed to put into the clipboard, and I'd like to do it from the command line. I came up with: alias cl="fc -ln -1 | sed 's/^\s*//' | xsel -b" To alias cl to that pipeline which seems to achieve the desired effect, but it seems complicated and has a trailing newline that I don't want. Any obvious and simpler way which doesn't have a trailing newline?
Asked by BeeOnRope (559 rep)
May 4, 2019, 02:07 AM
Last activity: May 1, 2022, 08:53 PM