bash equivalent to csh alias that has arguments and pipes

Viewed 110

I'm a long-time Unix and csh user. I typically have this alias in my .cshrc file on my Mac OS computer. It does an ls with an argument and then pipes it through less.

alias   dir        "ls -laF -G \!* | less -rEX"

I'm using a new system with bash. How would I write the equivalent alias in bash to put into my .bashrc file?

I've read that I need to create a function(), but the arguments and piping are not clear to me.

Any help would be appreciated.

1 Answers

It is better to use a shell function in bash than alias which has many drawbacks. This function should work for you:

dir() {
    ls -laF -G "$@" | less -rEX
}
Related