From d3a97ad7f6c86f1d47d7f7fffd0624cfdcebfd17 Mon Sep 17 00:00:00 2001 From: Christopher Degawa Date: Tue, 6 Aug 2019 01:49:56 +0000 Subject: [PATCH] STYLE.md: Add command to append nl to EOF Signed-off-by: Christopher Degawa --- STYLE.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/STYLE.md b/STYLE.md index a2e5feca4..509e7d880 100644 --- a/STYLE.md +++ b/STYLE.md @@ -132,6 +132,13 @@ sed -i 's/\t/ /g;s/[[:space:]]*$//g' Note: For macOS and BSD related distros, you may need to use `sed -i ''` inplace due to differences with GNU sed. +``` bash +git ls-files -z | while IFS= read -rd '' f; do tail -c1 < "$f" | read -r _ || echo >> "$f"; done +``` + +Use this to auto append a newline to the end of the file for any files that are under git. +Taken from [here](https://unix.stackexchange.com/a/161853) + ### For Powershell/pwsh ``` Powershell