Command line path copy to clipboard
Two functions to be included in your .zshrc
to copy the current path to the clipboard. These use xlcip
, I’m sure there are alternatives or other tools for your setup.
pwcc - Copy current path to clipboard:
function pwdcc() {
pwd | tr -d "\n" | xclip -selection clipboard
}
filecc - Copy the full path of
function filecc() {
if [ -z $1 ] || [ ! -f $1 ]
then
echo Give me a file you dummy
return 1
fi
readlink -f $1 | tr -d "\n" | xclip -selection clipboard
}
These should easily be convertable to other shells.