From 1ee7adf1cf83eb84034b19f3ca51a9464e6a72c6 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Sun, 21 Apr 2019 18:59:02 +0300
Subject: [PATCH] Pre-commit checks for .bashrc.

Because .bashrc was identified as a plain text file (it's not a shell
script), the shell-lint and shellcheck hooks weren't checking it. Add an
explicit hook just for it. Also, fix or silence whatever shellcheck
found.
---
 .bashrc                 | 3 ++-
 .pre-commit-config.yaml | 9 ++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/.bashrc b/.bashrc
index a0ceaa8..223441a 100644
--- a/.bashrc
+++ b/.bashrc
@@ -112,6 +112,7 @@ alias detectproxy='w3m http://detectportal.firefox.com/success.txt'
 alias color='less --raw-control-chars -p'
 alias pip2='python2 -m pip'
 alias pip3='python3 -m pip'
+# shellcheck disable=SC2139
 alias rc_update="make --directory $HOME --always-make"
 alias gen-ssh-config="rc_update .ssh/config"
 alias bfg='java -jar $HOME/.local/share/bfg/bfg.jar'
@@ -268,7 +269,7 @@ then
     [ -f /etc/bash_completion ] && . /etc/bash_completion
 
     # shellcheck disable=SC1090
-    for sourcefile in $HOME/.bash_completion.d/*
+    for sourcefile in "$HOME"/.bash_completion.d/*
     do
         [ ! -f "$sourcefile" ] || . "$sourcefile"
     done
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 33236a9..68d2504 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -18,4 +18,11 @@ repos:
         exclude: &excluded_shellscripts \.bash_completion\.d/(docker-machine\.bash|fabric-completion.bash|docker-compose)|\.travis/travis\.sh
     -   id: shellcheck
         exclude: *excluded_shellscripts
-        include: .bashrc
+    -   id: shell-lint
+        alias: shell-lint .bashrc
+        files: \.bashrc
+        types: [text]
+    -   id: shellcheck
+        alias: Shellcheck .bashrc
+        files: \.bashrc
+        types: [text]
-- 
GitLab