3 ms·
For those of you interested in making it a permanent replacement for cp, you can use this Python script: #!/usr/bin/env python from sys import argv
by w1ntermute 17y ago
For those of you interested in making it a permanent replacement for cp, you can use this Python script:
#!/usr/bin/env python
from sys import argv
from subprocess import Popen
copy_from = open(argv[-2],'r')
copy_to = open(argv[-1],'w')
Popen("pv", stdin=copy_from, stdout=copy_to)
copy_from.close()
copy_to.close()
Just alias cp to it in Bash.
- ajross 17y agoUm... in what universe would you want an interactive terminal gadget to become the default implementation of cp? Yikes. Still, nice pointer to the pv tool, which I hadn't heard of. Still still, the linked awk snipped is awfully clever and more fun to read.
- philjackson 17y agoWhat? I think the override is fine in an interactive environment. My team and I use a hack which overrides cd and as well as calling builtin cd it sources a script if it exists from cwd. This means you can get the exact enviroment you need for that working copy of a project.
- rntz 17y agoAlternatively, you could just write a shell function: cp() { pv < $1 > $2; } (Or name the function something else if you want regular cp still available.)
- olliesaunders 17y agoQuote the variables.
- rntz 17y agoAh, good point. I'm personally used to zsh, which doesn't have that particular misfeature.