I'm trying to add a custom function to my bashrc file to modify the behavior of the 'ls' command. Here's what I'm trying to add:
```bash
ls () {
if [[ "$*" == *"--no-details"* ]]; then
local args=("${@/--no-details/}" )
eza -l --no-permissions --no-filesize --no-user --no-time "${args[@]}"
else
eza -l "$@"
fi
}
```
However, when I save the file and source it, I encounter this error:
```bash
bash: /home/vrin/.bashrc: line 19: syntax error near unexpected token `('
bash: /home/vrin/.bashrc: line 19: `ls () {'
```
Does anyone know why this is happening? I've seen similar functions online that use the same syntax. Any tips would be really helpful, thanks in advance!
1 Answer
It looks like you might have an alias for `ls` that’s being picked up while trying to redefine it as a function. When you define a function with the same name as an existing alias, it can mess up the syntax. You can check if there's an alias for `ls` by running `type -a ls`. If there is, make sure to run `unalias ls` before sourcing your bashrc to clear it out.
I remember removing that color_auto alias while tweaking my bashrc, but I didn't unalias it. That explains the issue! Thanks for the help!