dotfiles

Cross platform dotfiles for linux, mac and windows

commit c32a7b30a558442a0b00b0444e4651540ae98529
parent 209665698c953ad0afcc8407bcb60573e28346b6
Author: Bharatvaj <bharatvaj@yahoo.com>
Date: Tue, 5 Jul 2022 00:06:02 +0530

Allow passing custom XDG root path

This change is done to allow sourcing the dotfiles in a portable
manner
2 files changed, 9 insertions(+), 7 deletions(-)
M
.bash_profile
|
8
++++----
M
.profile
|
8
+++++---
diff --git a/.bash_profile b/.bash_profile
@@ -1,9 +1,9 @@
 # If not running interactively, don't do anything
 [[ $- != *i* ]] && return
 
+[ -n "$1" ] && XDG_ROOT="$1" || XDG_ROOT="$HOME"
 
-[ -f ~/.profile ] && . ~/.profile
-[ -f "${XDG_CONFIG_HOME}/bash/bashrc" ] && . "${XDG_CONFIG_HOME}"/bash/bashrc
+export XDG_CONFIG_HOME="$XDG_ROOT/.config"
 
-# Zoho
-[ -f ~/.zoho/zoho ] && . ~/.zoho/zoho
+[ -f "${XDG_CONFIG_HOME}"/.profile ] && . "${XDG_CONFIG_HOME}"/.profile
+[ -f "${XDG_CONFIG_HOME}"/bash/bashrc ] && . "${XDG_CONFIG_HOME}"/bash/bashrc
diff --git a/.profile b/.profile
@@ -1,10 +1,12 @@
 #!/bin/sh
 export GREP_COLOR='1;35;40'
 
+[ -n "$1" ] && XDG_ROOT="$1" || XDG_ROOT="$HOME"
+
 # XDG
-export XDG_CONFIG_HOME="$HOME/.config"
-export XDG_DATA_HOME="$HOME/.local/share"
-export XDG_CACHE_HOME="$HOME/.cache"
+export XDG_CONFIG_HOME="$XDG_ROOT/.config"
+export XDG_DATA_HOME="$XDG_ROOT/.local/share"
+export XDG_CACHE_HOME="$XDG_ROOT/.cache"
 
 # Global programs
 export VIMINIT="if !has('nvim')