[PATCH 4/4] dim: Introduce a new configuration file in .config/dim

Maxime Ripard maxime at cerno.tech
Thu Jan 13 08:43:52 UTC 2022


The dim configuration has been stored in ~/.dimrc so far, but using
XDG_CONFIG_HOME allows for a tidier home directory.

Introduce a new XDG_CONFIG_HOME/dim/dimrc path.

Signed-off-by: Maxime Ripard <maxime at cerno.tech>
---
 dim | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/dim b/dim
index a5aa182b2e24..0488d7666185 100755
--- a/dim
+++ b/dim
@@ -36,12 +36,18 @@ set -e
 #
 
 DIM_CACHE_DIR=${XDG_CACHE_HOME:-$HOME/.cache}/dim
+DIM_CONF_DIR=${XDG_CONFIG_HOME:-$HOME/.config}/dim
 
 # dim configuration file
-DIM_CONFIG=${DIM_CONFIG:-$HOME/.dimrc}
-if [ -r $DIM_CONFIG ]; then
+if [[ -n $DIM_CONFIG ]] && [ -r $DIM_CONFIG ]; then
 	# shellcheck source=/dev/null
 	. $DIM_CONFIG
+elif [ -r $DIM_CONF_DIR/dimrc ]; then
+	# shellcheck source=/dev/null
+	. $DIM_CONF_DIR/dimrc
+else
+	# shellcheck source=/dev/null
+	. $HOME/.dimrc
 fi
 
 # prefix for repo directories
-- 
2.34.1



More information about the dim-tools mailing list