DEV Community

Discussion on: Quickly copy path to clipboard

Collapse
 
arnabsen1729 profile image
Arnab Sen

On the same topic I would like to add, sometimes we run a command and we want to copy the command we just ran onto clipboard. For that I have a solution. In the same way create another bash file and put this piece of code.

#!/usr/bin/bash

history | tail -2 | head -1 | awk '{print $2}' | xclip -selection clipboard

Make it executable in the same way as shown above. If you want to access the file anywhere from the terminal just put it in /bin/ directory.