aboutsummaryrefslogtreecommitdiffstats
path: root/.zprofile
diff options
context:
space:
mode:
authorkatherine <shmibs@shmibbles.me>2016-10-01 13:58:31 -0700
committerkatherine <shmibs@shmibbles.me>2016-10-01 13:58:31 -0700
commitbacc4127b7da22c61671fe3ce0cef6db103884dd (patch)
treee631d8a0f5609c5137afade0a8b36589997d8346 /.zprofile
parent4a879cb286f97f317b1109d8d07be4508c76e5f8 (diff)
downloaddotfiles-bacc4127b7da22c61671fe3ce0cef6db103884dd.tar.gz
overhaul init system
gen files now kept in gen directory. funcs now included in $PATH only if their funcreqs are successfully passed at login, making things cleaner and more system-independent
Diffstat (limited to '.zprofile')
-rw-r--r--.zprofile33
1 files changed, 31 insertions, 2 deletions
diff --git a/.zprofile b/.zprofile
index 75606b2..5607a06 100644
--- a/.zprofile
+++ b/.zprofile
@@ -7,8 +7,37 @@ export QT_STYLE_OVERRIDE=gtk
PATH=$PATH:~/.cabal/bin
########## MAKE USER FUNCS AVAILABLE ##########
-[[ -d ~/.config/init/funcs/ ]] && \
- PATH="$PATH:$HOME/.config/init/funcs"
+func_init_checkreq() {
+ local func_init_state=0
+ for e in "$@"; do
+ if [[ $func_init_state -eq 0 ]]; then
+ if [[ "$e" == ',' ]]; then
+ func_init_state=1
+ else
+ whence $e >/dev/null
+ [[ $? -eq 0 ]] || return 1
+ fi
+ else
+ local cmd
+ echo "$e" | read -A cmd
+ $cmd 2>/dev/null 1>&2
+ [[ $? -eq 0 ]] || return 1
+ fi
+ done
+ return 0
+}
+
+if [[ -d ~/.config/init/funcs/ && -d ~/.config/init/funcreqs ]]; then
+ rm -r /tmp/funcs
+ mkdir -p /tmp/funcs
+ PATH=$PATH:/tmp/funcs
+ for f in $HOME/.config/init/funcreqs/*; do
+ source "$f"
+ func_init_checkreq $func_init_prereqs , $func_init_checks
+ [[ $? -eq 0 ]] && \
+ ln -s $HOME/.config/init/funcs/${f:t} /tmp/funcs/${f:t}
+ done
+fi
############# CONNECTING OVER SSH #############
[[ -f ~/.zprofile-dtach ]] && \