Decided today to write up a simple ignore file & ignore directory menu item.
Both menu items are implemented using a git alias which also allows command line usage if wanted:
- ignore file:
git smerge-ignore path/to/file
- ignore directory:
git smerge-fetch path/to/file dir
Notes/Caveats:
- duplicate entries are skipped when identified
- but no add/remove lines if the reverse logic is needed
- directories are always suffixed with
/
Steps:
-
add this git alias:
git config --global alias.smerge-ignore '!f() { local ignore_file="${1#"$PWD"}" local ignore_type="${2:-file}" local ignore_line case "$ignore_type" in dir*) ignore_line="$(dirname "$ignore_file")/" ;; *) ignore_line="$ignore_file" ;; esac if [ "" == "$(grep -Fx "$ignore_line" .gitignore)" ]; then echo "$ignore_line" >> .gitignore echo "added $ignore_type $ignore_file to .gitignore file" else echo "$ignore_type already exists, skipping" fi }; f'
-
add these menu items to
File.sublime-menu
:[ { "caption": "Add file to .gitignore", "command": "git", "args": { "argv": ["smerge-ignore", "$path", "file"] } }, { "caption": "Add this file's directory to .gitignore", "command": "git", "args": { "argv": ["smerge-ignore", "$path", "dir"] } } ]