0

Can you please tell me what I'm doing wrong? I open ~/.bashrc and I have added some aliases, like alias c=clear or alias h=history. These aliases are working.

Problem is here:

alias ls=ls -lhF --time-style=long-iso --color=auto

When I type ls in the terminal, it shows me different output than when I just type ls -lhF --time-style=long-iso --color=auto manually.


tried that aswell, its still not working. Also when i type alias ls , i get that answer alias ls='ls --color=auto' so when i type manual alias ls=ls -lhF --time-style=long-iso --color=auto its looking complete diffrent

3
  • You need to learn about quoting in the shell: grymoire.com/Unix/Quote.html Commented Apr 26, 2020 at 10:17
  • 1
    Where in you ~/.bashrc did you add the new alias? there is likely already an alias like alias ls='ls --color=auto' in the file, which will override yours if it occurs later Commented Apr 26, 2020 at 12:06
  • you were 100% right! in ~/.bashrc , there were already alias like ll=, la= l= and so on. Did not see it
    – boxerbobby
    Commented Apr 26, 2020 at 12:50

1 Answer 1

1

Edit your ~/.bashrc as follows :

Change alias ls='ls --color=auto' to alias ls='ls -lhF --time-style=long-iso --color=auto'

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls -lhF --time-style=long-iso --color=auto'
fi

single quote is missing, then run exec $SHELL.


Also you can put the new alias in your ~/.bash_aliases , changes will be applied after sourcing your ~/.bashrc through (present in ~/.bashrc) :

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

avoid adding duplicate aliases after the above lines allowing changes in ~/.bash_aliases to take effects.

1
  • @boxerbobby see my edit, please.
    – GAD3R
    Commented Apr 26, 2020 at 12:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .