I am testing the bash behavior on login (terminal 1), but I got confused about its interaction with alias:
I opened with vim .bashrc and add this line :
alias ls='ls -l'
and save it with :x
then I used source .bashrc to simulate a new login session and I found it in the aliases list
But I removed the alias from .bashrc and use source .bashrc again I saw that alias ls='ls -l' was still available. On the other hand, opening new shell terminal (terminal 2) the problem was solved.
Question: Why alias ls='ls -l' was not removed on the first terminal ?
sourcedoes not "simulate a new login" it just executes the operations in the file in the current shell. None of those operations removed the alias. - starksource .bashrcis basically the same as copy-pasting the contents.bashrcinto your shell. If you copy-pasteecho Hello; alias ls='ls -l'then you would expect Hello to be written and an alias to be defined. If you afterwards copy-pasteecho Hello, you would NOT expect thelsalias to disappear. Same thing here. - that other guy