less than 1 minute read

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 to the clipboard:

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.