0

I can put aliases in my .bashrc (or files called from it) and they then work in my shell.

I can also then create other aliases at the command line, e.g.

alias aaa='ls'

and it works. aaa does an ls operation

But if I put that alias definitions in a file, say aaa_alias, make it executable and then try and use it, it is not recognized.

I call it with ./aaa_alias and get no error. But the aliases does not sem to have been defined in my shell.

Why not? What am I doing wrong? How can I have a small number of aliases ina separate file than I just use occasionally when I want and so I invoke it when I went them.

enter image description here

1 Answers1

5

In order to insert the contents of a file into your current session, you need to source the file, not execute it.

. my_file

When you were just executing the file, the aliases were being set in a subshell and therefore had no effect on your current session.

terdon
  • 242,166