I have the following code in my .bashrc
:
c() { cd "$@" && ls -a ; }
alias cdd="c ~/Downloads"
alias r=". ~/.bashrc"
When I load a new terminal, cdd
doesn't work before I do the r
command. But after doing so, it works as intended. Why is this?
I asked this same question on Stack Overflow a few months ago, but none of the responses were able to give me a working solution. Here is the link to my dotfiles if that will be of any use.
EDIT type -a c cdd r
produces:
c is aliased to `clear'
c is a function
c ()
{
cd "$@" && ls --color=auto -a
}
cdd is aliased to `c ~/Downloads'
r is aliased to `. ~/.bashrc'
Based on this information, I changed the c
function to d
, and it works. That being said, is there any way I could not map the clear function to c as I already have alias cs='printf "\033c"'
for that)? I looked in .bashrc
but couldn't find anything with the word "clear".
PS4=' ${BASH_SOURCE}:${LINENO} ' bash -lixc exit |& grep clear
and add the output, please. – muru Jan 30 '18 at 05:32unalias c
, that's it. To find where that is being defined use muru command and post output:PS4=' ${BASH_SOURCE}:${LINENO} ' bash -lixc exit |& grep clear
– Jan 30 '18 at 05:46