pimterry / notes

:pencil: Simple delightful note taking, with more unix and less lock-in.
https://github.com/pimterry/notes
MIT License
1.24k stars 82 forks source link

Make `ls` ignore vim backup files #76

Closed eshapard closed 4 years ago

eshapard commented 4 years ago

Fixes

Checklist

Short description of what this PR does:

In case user has vim set up to create backup files in the current directory, make the ls command ignore backup files (ending in '~' by default).

I find this helpful with my setup, but it obviously won't be of benefit to everyone. Probably won't cause any problems, though. I don't imagine anyone uses '~' at the end of a filename for any other purpose (and for some reason, also stores them in the notes directory).

Yeah, take it or leave it. :-)

pimterry commented 4 years ago

Nice! I'm definitely on board with the goal, good suggestion.

Unfortunately it will break things though, because it looks like the default version of ls on a Mac doesn't support --ignore (or -I): https://stackoverflow.com/questions/11213849/how-to-ls-ignore-on-osx.

I think this would work everywhere if implemented with grep -v instead. Would that work for you? AFAIK that should do the same thing. Any downsides you're aware of?

eshapard commented 4 years ago

Ah, yes, I was worried that -I might not be supported everywhere. I had originally planned on using grep -v before I discovered that ls had its own --ignore option.

As far as I know, grep -v is standard and should be supported on all *nix platforms, so that's probably the way to do it. :-)

Excerpts from Tim Perry's message of April 1, 2020 5:46 am:

Nice! I'm definitely on board with the goal, good suggestion.

Unfortunately it will break things though, because it looks like the default version of ls on a Mac doesn't support --ignore (or -I): https://stackoverflow.com/questions/11213849/how-to-ls-ignore-on-osx.

I think this would work everywhere if implemented with grep -v instead. Would that work for you? AFAIK that should do the same thing. Any downsides you're aware of?

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/pimterry/notes/pull/76#issuecomment-607228112

rmNULL commented 4 years ago

@pimterry as excluding files are popping up often. what's your opinion on having .notesignore file like .gitignore and maybe a flag called --ignore-file to provide ignore file with other name.

Additionally, It will be good if notes respected the .gitignore file and ignore all files defined in there.

pimterry commented 4 years ago

I've now updated this to use grep -v instead, added a quick test, and merged it. Thanks @eshapard! Nice improvement :+1:.


@rmNULL I'm open to some kind of ignore config, if you or others would find that useful. I'd be surprised if we needed a special command line argument for it, I expect it's very nearly always the same set of patterns, and for one-off ignoring you can just pipe to grep -v.

I think we should still ignore some standard things (like this) by default either way. We already have the config file, so I expect we'd either want to extend that somehow, or link out from that, maybe with an IGNORE_FILE param that points to a gitignore-formatted file, so users can point to .gitignore or .notesignore or wherever. I'm probably not going to jump on that any time soon, but feel free if it'd be useful to you.