Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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: http://i.stack.imgur.com/hDYbz.png

share|improve this question

2 Answers 2

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"
share|improve this answer

I added some folder patterns to the great (!) solution of thalesmello. Those folders were disturbing me on Windows 7. Now, my home-folder in git bash is completely empty. This is it!

# refers to http://superuser.com/questions/650322/ignore-ntuser-dat-files-when-ls-on-git-bash
LS_COMMON="-hG"
# --color : On Windows7 this produces permission errors, e.g. for Music folder:
# LS_COMMON="$LS_COMMON --color=auto"
LS_COMMON="$LS_COMMON -I NTUSER.DAT\* -I ntuser.dat\*"
LS_COMMON="$LS_COMMON -I AppData\*"
LS_COMMON="$LS_COMMON -I Music\*"
LS_COMMON="$LS_COMMON -I Pictures\*"
LS_COMMON="$LS_COMMON -I Start\ Menu\*"
LS_COMMON="$LS_COMMON -I Application\ Data\*"
LS_COMMON="$LS_COMMON -I Local\ Settings\*"
LS_COMMON="$LS_COMMON -I Cookies\*"
LS_COMMON="$LS_COMMON -I ntuser.ini"
LS_COMMON="$LS_COMMON -I ntuser.pol"
LS_COMMON="$LS_COMMON -I Thumbs.db"
LS_COMMON="$LS_COMMON -I Favorites\*"
LS_COMMON="$LS_COMMON -I Recent\*"
LS_COMMON="$LS_COMMON -I Searches\*"
LS_COMMON="$LS_COMMON -I Videos\*"
LS_COMMON="$LS_COMMON -I Desktop\*"
alias ls="command ls $LS_COMMON"
alias ll="ls -l"
alias la="ls -al"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.