git rev-parse --abbrev-ref HEAD | xclip -i -sel clip
Tag: xclip
How to copy from console/terminal/file to X clipboard in Linux
We need to use xclip
package which is command line interface to X selections.
Install:
sudo apt-get update
sudo apt-get install -y xclip
We can copy file contents to clipboard, for example:
xclip -i < .ssh/id_rsa.pub
Now file contents are in system clipboard and we can use Ctrl + V to paste it anywhere.