You need more escaping. You’ve correctly escaped the $; you need to do the same with the existing backslashes.

alias cpwd="echo \\"\$(pwd)\\" | xclip"

Alternatively, you can avoid all the escaping by using single quotes.

alias cpwd='echo \"$(pwd)\" | xclip'

Best of all, use a function instead of an alias. A function lets you write the command exactly as you would normally without any extra quotes or escaping.

cpwd() {
    echo \"$(pwd)\" | xclip
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top