Trim trailing newline in one-liner bash alias
I belive this should work :
alias cwd="echo -n `pwd` | pbcopy; echo \"Copied `pwd`\""
The -n
says "no new line". Either that or you can always pass the output through tr
and remove the new line character like that:
alias cwd="echo `pwd` | tr -d "\n" | pbcopy; echo \"Copied `pwd`\""
I'm not sure if you want to remove the trailing new line char from the first echo or from both - but i guess you can figure it out if it will work for the first one ;)