Windows – Ignore NTUSER.DAT files when ls on Git Bash

bashgitlswindows

I use Git Bash as my terminal on Windows. When I ls in my Home directory, I see some NTUSER.DAT entries, which I assume are system files. They don't appear when I run dir in the default Windows Prompt.

What can I do so the ls command ignore these entries in the Git Bash as well?

Screenshot:

enter image description here

Best Answer

After some digging, I found a way around it. I put the script below in my .bashrc file, so these settings load automatically with Git Bash. This piece of code was based on a dotfiles project.

LS_COMMON="-hG"
LS_COMMON="$LS_COMMON --color=auto"
LS_COMMON="$LS_COMMON -I NTUSER.DAT\* -I ntuser.dat\*"

test -n "$LS_COMMON" &&
alias ls="command ls $LS_COMMON"
alias ll="ls -l"
alias la="ls -a"
alias lal="ll -a"