I frequently find myself copying large directories and then thinking "darn, I should've used rsync instead of cp for this because I can get progress updates".

I'm considering adding this to my .profile:

alias cp='rsync -a --progress'
  1. In general, could aliasing over another command cause any problems? What about coreutil commands specifically?
  2. Are there any foreseeable problems that would arise from this particular alias?
  • my initial thought was that some shell scripts might assume any output from cp indicates a failure... but this alias wouldn't extend to shell scripts, would it? – Woodrow Barlow Jul 19 '16 at 20:28
  • 1
    This sort of thing is pretty common. Distros will often alias certain commands to automatically use certain options (for example on my system ls --color=auto is aliased to just ls. If you want to do this, you're free to do so, just realize what effect it's going to have on commands that you copy/paste and that cp is now no longer actually cp – Bratchley Jul 19 '16 at 20:30
  • It is subjective whether this is a bad idea, but I'd suggest most people would tell you it is, mostly because it is changing the behaviour of cp, as by default cp is not recursive, yet that rsync command is. – camh Jul 20 '16 at 2:35
  • Not answering the question, but if you often have this problem, just kill cp (^C) and run the rsync command. It won't copy anything already copied so there is no harm. – camh Jul 20 '16 at 2:36

Problems include motor memory if then on somebody else's system where that alias is not setup and then something bad happens as you were expecting rsync but cp happened instead (trailing slashes or lack thereof may be different between the two commands). Or you could get in the habit of passing rsync flags to something called cp, something again bad to memorize if cp ever is not-rsync and then who knows what happens when cp gets rsync flags? Probably easier to create a not-cp-nor-rsync alias and train yourself to use that instead, or to think about the command for a few seconds before hitting enter.

| improve this answer | |

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