When I run in my terminal:
alias
a list with all my aliases (defined in ~/bashrc
and ~/.bash_aliases
files) will be displayed on my terminal. That's nice and as expected!
But when I run:
bash -c "alias"
there is no output, so no aliases. First I thought that ~/.bashrc
file is not sourced in the second case, so I ran:
bash -c ". ~/.bashrc && alias"
but, stupor, again there is no output...
Strangely enough, when I run:
bash -c ". ~/.bash_aliases && alias"
only the aliases defined in ~/.bash_aliases
will be displayed.
Can someone make some light and make me understand what exactly it is happening here?
bash -c ". ~/.bashrc && alias"
shows the aliases for me. Are you sure it does not work? – Bernhard Jul 16 '14 at 19:44.bashrc
file the following code somewhere at the beginning# If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac
. You don't have it? ...So Cyrus answer exactly to my Q. – Radu Rădeanu Jul 16 '14 at 20:19