Skip to content
Snippets Groups Projects
Commit ed24e9ad authored by Sven Mäder's avatar Sven Mäder :speech_balloon:
Browse files

Merge envrcd and envrcd_main to .envrcd

parent 98fe06ab
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
# ~/.envrcd/.envrcd: this file should be symllinked to ~/.bashrc
# if not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
ENVRCD_NAME="envrcd"
ENVRCD_PATH="${HOME}/.${ENVRCD_NAME}"
if [ ${ENVRCD_SET_NOENVRCD} ]; then
return
fi
if [ ${ENVRCD_SET_DEBUG} ]; then
ENVRCD_DEBUG="true"
fi
# prints messages when in debug mode
function debug {
......@@ -21,11 +39,11 @@ function source_if_exists {
}
# source common files from a directory (${ENVRCD_NAME}, ${ENVRCD_NAME}.d, .bashrc)
function source_dir_if_exists {
source_if_exists "${1}/${ENVRCD_NAME}"
source_if_exists "${1}/${ENVRCD_NAME}.d/*"
source_if_exists "${1}/.bashrc"
function source_profile_if_exists {
source_if_exists "${ENVRCD_PATH}/profile/${1}/${ENVRCD_NAME}"
source_if_exists "${ENVRCD_PATH}/profile/${1}/${ENVRCD_NAME}.d/*"
source_if_exists "${ENVRCD_PATH}/profile/${1}/.bashrc"
}
# source envrcd files
# source envrcd code
source_if_exists "${ENVRCD_PATH}/${ENVRCD_NAME}.d/*"
#!/bin/bash
# set default profile
export ENVRCD_DEFAULT_PROFILE="default"
# set ENVRCD_COLOR_OFF if we do not want colors
case "$TERM" in
linux|xterm|xterm-color|*-256color) unset ENVRCD_COLOR_OFF;;
......
......@@ -3,14 +3,14 @@
# load defaults or profile specific config
if [ -z "${ENVRCD_PROFILE}" ]; then
debug 'ENVRCD_PROFILE is unset or empty.'
source_dir_if_exists "${ENVRCD_PATH}/profile/default"
source_profile_if_exists "${ENVRCD_DEFAULT_PROFILE}"
else
debug "ENVRCD_PROFILE is set: ${ENVRCD_PROFILE}"
if [ -d "${ENVRCD_PATH}/profile/${ENVRCD_PROFILE}" ]; then
debug "profile directory exists ${ENVRCD_PATH}/profile/${ENVRCD_PROFILE}"
source_dir_if_exists "${ENVRCD_PATH}/profile/${ENVRCD_PROFILE}"
source_profile_if_exists "${ENVRCD_PROFILE}"
else
debug "profile directory not found ${ENVRCD_PATH}/profile/${ENVRCD_PROFILE}"
source_dir_if_exists "${ENVRCD_PATH}/profile/default"
source_profile_if_exists "${ENVRCD_DEFAULT_PROFILE}"
fi
fi
#!/bin/bash
# ~/.envrcd/envrcd_main: this file should be symllinked to ~/.bashrc
# if not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# minimal fallback config for history
shopt -s histappend
export HISTCONTROL=ignoreboth
export HISTSIZE=4000
export HISTFILESIZE=4000
ENVRCD_PATH="${HOME}/.envrcd"
ENVRCD_NAME="envrcd"
if [ ${ENVRCD_SET_NOENVRCD} ]; then
return
fi
if [ ${ENVRCD_SET_DEBUG} ]; then
ENVRCD_DEBUG="true"
fi
# load advanced envrcd config
if [ -f "${ENVRCD_PATH}/${ENVRCD_NAME}" ]; then
if [ ${ENVRCD_DEBUG} ]; then
echo "sourcing ${ENVRCD_PATH}/${ENVRCD_NAME}"
fi
source "${ENVRCD_PATH}/${ENVRCD_NAME}"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment