8
I'm trying to write a simple alias on my Mac OS X terminal to copy the current working directory. I have this:
alias cpwd="echo \`pwd\` | pbcopy; echo \"Copied \`pwd\`\""
Then I can just run the following to copy it:
$ cpwd
Problem is that echo pwd
includes the newline at the end. So when I paste it, it executes immediately (if pasted in a terminal).
All I want to do is strip off the trialing newline, but nothing I find on the internet seems to work for me. Seen various solution involving sed
, awk
, and cut
, but I can't quite get it. Seems like it would be easy to do.
Side note for anyone who saw this post earlier, I had to escape the back ticks in the alias, because
pwd
was actually being run when the aliases were being initialized – Sean Adkinson – 2012-12-27T20:09:47.597