Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I override alias set in .bash_aliases

Tags:

alias

bash

I like to use bash aliases to customize bash commands. Is there a way to override the bash alias settings, or should I rename the aliases to something different than the original command.

eg: my .bash_aliases includes

alias ls='ls -ltr' 

If I want to only retrieve the file name, do I need to rename the alias to something other than 'ls'? Or is there another way?

like image 365
David LeBauer Avatar asked Nov 03 '10 14:11

David LeBauer


People also ask

Does alias override path?

For the record: technically, aliases do not override any values in the PATH envar. Obligatory caution: In general, it is not good practice to rename common commands.

How do I undo an alias in bash?

How to unset (delete) a Bash Alias? You can unset (or delete) an existing Bash alias by using the Bash unalias builtin command. All the existing aliases would be removed when using the -a option.

Where do I put bash aliases?

bash_aliases is present under the user home directory and load it whenever you initiate a new terminal session. You can also create a custom alias file under any directory and add definition in either . bashrc or . profile to load it.


1 Answers

Add a \ (backslash) before the command to disable the alias, like this:

\ls

This will invoke the original (un-aliased) ls.

Example:

$ ls #will invoke the alias total 0 -rw-rw-r--    1 dogbane foo          0 Nov  3 16:04 c -rw-rw-r--    1 dogbane foo          0 Nov  3 16:04 b -rw-rw-r--    1 dogbane foo          0 Nov  3 16:04 a  $ \ls #will disable the alias a  b  c 
like image 125
dogbane Avatar answered Oct 04 '22 09:10

dogbane