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?
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 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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With