2

My task is to simply remove an alias and update s.t. the old alias does not work. Yes I know there are many source commands out there, however it does not seem to work for me this time. My setup is as follows; In my ~/.bash_aliases I made this alias:

alias gali='gedit ~/.bash_aliases;sort ~/.bash_aliases -o ~/.bash_aliases;sbash' Where sbash='source ~/.bashrc'.

For adding and updating, which works like a charm, but when I remove an alias using this command or manually step-by-step, the bash does not update. How can I make this happen? Thanks in advance.

  • source ~/.bashrc should work – George Udosen Mar 23 '17 at 15:28
  • Yes I know it should work, but it does'nt and I'm wondering why!:) – Thomas Mar 23 '17 at 15:32
  • @George does that unalias all aliases or just recreate the ali ases it sees and leave the removed aliases as is? I would believe Yaron is correct: unalias it. – Rinzwind Mar 23 '17 at 15:33
  • I use . <path-to-script-file> – Andrew Mar 30 '17 at 19:27
4

When you remove an alias from the .bash_aliases it isn't removed from the bash aliases.

If you want to have only the aliases in the .bash_aliases you will need to clean all bash shell aliases, and afterwards loads the aliases from the .bash_aliases

Clear all Linux / UNIX bash shell aliases

If the -a option is given, then remove all alias definitions.

$ unalias -a

Assuming that all your aliases exists in ~/.bash_aliases (I suspect that you are using aliases from other sources as well...) you should execute unalias -a follows by the command to source ~/.bash_alises

Your code should look like this:

alias gali='gedit ~/.bash_aliases;sort ~/.bash_aliases -o ~/.bash_aliases;unalias -a; source ~/.bash_aliases'
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.