Can you use export with an alias?

Let’s say I wanted to do this (assuming I’m in nano):

export alias src_bash="source ~/.bash_profile"

Can I?

Try it! See what happens :slight_smile:

It keeps saying command not found.

What happens if you just alias, or just export?

Well, if I use just alias, after I run source ~/.bash_profile~, I can use src_bash. I haven’t tried export let me see how that works. Ok so after trying it works the same if I were to just use alias.

Problem solved then, yea?

The answer is no right? What if I make an enviroment variable called src_bash and make an alias for that? Is that possible?

You’d have to go a bit further and search the differences between export and alias. You can’t do both at once. There’s plenty of discussion of that sort of stuff on stackoverflow if you search export vs alias.

1 Like