Skip to main content
The 2024 Developer Survey results are live! See the results

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • Is there a reason you don't make this a shell function instead, with the directory as an argument (possibly with a default value)?
    – Kusalananda
    Commented Feb 17, 2023 at 18:33
  • The only reason would be aliases are easier to implement. Thanks for the suggestion. I'll try using a function instead.
    – JS.
    Commented Feb 17, 2023 at 18:35
  • I still don't understand what it is you want to do. Sorry.
    – Kusalananda
    Commented Feb 17, 2023 at 19:21
  • In your "Additional Example", you want to run the alias 50 times, each time with another TARGET_DIR value? That's literally what turning it into a function that takes the directory as an argument would allow you to do (see the end of my answer below). In fact, since the alias uses $TARGET_DIR unresolved, just changing this variable's value and calling the alias again would probably also work, although using a function would allow you to handle quoting better.
    – Kusalananda
    Commented Feb 17, 2023 at 19:37
  • No, $TARGET_DIR is just the repository I'm working out of at the time. It changes every few days or so. The directory name is a hash of the git branch name. The whole point is to avoid typing in the long directory name each time. I want to change it in the .bashrc every once in a while and have all my aliases working and copy/pastable on the fly. Displaying functions doesn't resolve substitutions any better than displaying aliases.
    – JS.
    Commented Feb 17, 2023 at 21:08