Prechádzať zdrojové kódy

feat(SHELLRC_HOME): Add the possibility to change shellrc home

Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com>
Jeremy MAURO 2 rokov pred
rodič
commit
8b6e2ef602
7 zmenil súbory, kde vykonal 27 pridanie a 23 odobranie
  1. 7 5
      bash_profile
  2. 9 6
      bashrc
  3. 0 1
      bashrc.d/demo.bash
  4. 0 2
      login.d/empty.sh
  5. 0 1
      rc.d/demo.sh
  6. 4 2
      zlogin
  7. 7 6
      zshrc

+ 7 - 5
bash_profile

@@ -8,13 +8,15 @@
 # for ssh logins, install and configure the
 #umask 023
 
-if [ -f ${HOME}/.bashrc ]; then
-  source ${HOME}/.bashrc
-fi
+SHELLRC_HOME="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
 
 # load all files from .shell/login.d directory
-if [ -d ${HOME}/.shellrc/login.d ]; then
-  for file in ${HOME}/.shellrc/login.d/*.sh; do
+if [ -d ${SHELLRC_HOME}/login.d ]; then
+  for file in ${SHELLRC_HOME}/login.d/*.sh; do
     source ${file}
   done
 fi
+
+if [ -f ${HOME}/.bashrc ]; then
+  source ${HOME}/.bashrc
+fi

+ 9 - 6
bashrc

@@ -8,21 +8,24 @@
 # test for an interactive shell. there is no need to set anything
 # past this point for scp and rcp, and it's important to refrain from
 # outputting anything in those cases.
+
+SHELLRC_HOME="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
+
 if [[ $- != *i* ]] || [[ -z "$PS1" ]]; then
   # shell is non-interactive. be done now!
   return
 fi
 
-# load all files from .shell/bashrc.d directory
-if [ -d ${HOME}/.shellrc/bashrc.d ]; then
-  for file in ${HOME}/.shellrc/bashrc.d/*.bash; do
+# load all files from .shell/rc.d directory
+if [ -d ${SHELLRC_HOME}/rc.d ]; then
+  for file in ${SHELLRC_HOME}/rc.d/*.sh; do
     source ${file}
   done
 fi
 
-# load all files from .shell/rc.d directory
-if [ -d ${HOME}/.shellrc/rc.d ]; then
-  for file in ${HOME}/.shellrc/rc.d/*.sh; do
+# load all files from .shell/bashrc.d directory
+if [ -d ${SHELLRC_HOME}/bashrc.d ]; then
+  for file in ${SHELLRC_HOME}/bashrc.d/*.bash; do
     source ${file}
   done
 fi

+ 0 - 1
bashrc.d/demo.bash

@@ -1 +0,0 @@
-echo "This file is executed by bash"

+ 0 - 2
login.d/empty.sh

@@ -1,2 +0,0 @@
-# This is an empty file.
-# It prevents an error when no file is in this directory.

+ 0 - 1
rc.d/demo.sh

@@ -1 +0,0 @@
-echo "This file is executed by all shells"

+ 4 - 2
zlogin

@@ -1,6 +1,8 @@
 # load all files from .shell/login.d directory
-if [ -d ${HOME}/.shellrc/login.d ]; then
-  for file in ${HOME}/.shellrc/login.d/*.sh; do
+SHELLRC_HOME="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
+
+if [ -d ${SHELLRC_HOME}/login.d ]; then
+  for file in ${SHELLRC_HOME}/login.d/*.sh; do
     source ${file}
   done
 fi

+ 7 - 6
zshrc

@@ -1,15 +1,16 @@
 # ${HOME}/.zshrc
+SHELLRC_HOME="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
 
-# load all files from .shell/zshrc.d directory
-if [ -d ${HOME}/.shellrc/zshrc.d ]; then
-  for file in ${HOME}/.shellrc/zshrc.d/*.zsh; do
+# load all files from .shell/rc.d directory
+if [ -d ${SHELLRC_HOME}/rc.d ]; then
+  for file in ${SHELLRC_HOME}/rc.d/*.sh; do
     source ${file}
   done
 fi
 
-# load all files from .shell/rc.d directory
-if [ -d ${HOME}/.shellrc/rc.d ]; then
-  for file in ${HOME}/.shellrc/rc.d/*.sh; do
+# load all files from .shell/zshrc.d directory
+if [ -d ${SHELLRC_HOME}/zshrc.d ]; then
+  for file in ${SHELLRC_HOME}/zshrc.d/*.zsh; do
     source ${file}
   done
 fi