This is probably a very simple thing but I can’t find an answer, possibly because I don’t know what terms to use in search.

How do I use an alias of a path with mv or cp? Or even cd?

In /etc/bash.bashrc I have: alias docs=‘/media/docs

cd docs Gives “No such file or directory”

Yet: docs Gives “Is directory”

With alias docs=‘cd /media/docs’ and by typing docs I get into the directory. Obviously I can’t use that alias with mv or cp though.

Maybe this isn’t even an intended use of alias but still. Why doesn’t it work?

  • MolochHorridus@piefed.socialOP
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    15 hours ago

    Thanks for the tip, but escaping and unescaping sounds tedious, since I use spaces in both directory and file names.

    What I like about aliases here is that I have one central location to set them up and change them. If I ever were to forget what aliases I have it’s just about opening the file and looking.

    • TwistedTree@piefed.social
      link
      fedilink
      English
      arrow-up
      1
      ·
      14 hours ago

      eh, it’s mostly automagic but the first few times you encounter it makes for some fun debugging.

      Play around with the var=$(ls -A) construction a bit and see what is happening with your files.