Skip to main content

quick copy with fish functions

·130 words·1 min
Author
David Hoenisch

I often find myself needing to get files from another directory into the one that I am currenly working. This could be after I downloaded a file and now need to get it from the $HOME/Downloads folder, or, I have an asset in another location that I need to copy to my $PWD. To solve this issue I have a fish function that I created called cpf (short for copy from).

function cpf
    set file_to_copy $(fd . /home/dhoenisch | fzf --preview 'cat {} | head -200')

    if test -n "$file_to_copy"
        cp $file_to_copy .
    end

end

This will pop open a fzf fuzzy finder where I can type in the name of the file that I need, hit return, and it will copy from the remote directory to my current one.