Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to copy path of one file, but the directory isn't open in Finder, it is opened in terminal. Is it possible by invocation <utility> filename to copy full file path string to the Mac OS clipboard? Like copying the output of the following command there.

`pwd`/filename

Added the following line to my .zshrc

function cn { echo -n $(pwd)/$1 | pbcopy }

Just aliasing don't work because of arguments. Exact same string should work in bash too.

share|improve this question

1 Answer 1

up vote 3 down vote accepted
echo $(pwd)/filename | pbcopy

This will give you a non-quoted and non-escaped string, which, depending on your use case, may not work properly when pasted elsewhere.

share|improve this answer
    
pbcopy is just what I need, will accept this answer as soon it will become possible, thank you. –  eiennohito Jul 29 '13 at 14:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.