mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
Added dot-env plugin
Dot-env is a cross-platform, cascading Zsh environment system for those who work on different hardware and OS environments. See: https://github.com/midwire/.env
This commit is contained in:
parent
f4944d5a95
commit
ae2db75f3e
20 changed files with 629 additions and 0 deletions
53
plugins/dot-env/dot-env.plugin.zsh
Normal file
53
plugins/dot-env/dot-env.plugin.zsh
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# Skip all this for non-interactive shells
|
||||
[[ -z "$PS1" ]] && return
|
||||
|
||||
export DOT_ENV_PATH="$( cd "$( dirname "${0}" )" && pwd )"
|
||||
|
||||
OS=`uname`
|
||||
if [[ $OS == 'Darwin' ]]; then
|
||||
x=1
|
||||
elif [[ $OS == 'SunOS' ]]; then
|
||||
x=1
|
||||
elif [[ $OS == 'Linux' ]]; then
|
||||
x=1
|
||||
else
|
||||
echo "Sorry, no portable environment support for your platform: '$OS'"
|
||||
exit 1
|
||||
fi
|
||||
OS_DIR=$DOT_ENV_PATH/os/$OS
|
||||
|
||||
# Make sure globals are sourced before OS specifics
|
||||
if [[ "$SHLVL" == "1" ]]; then
|
||||
echo "Sourcing Global Environment"
|
||||
fi
|
||||
for i in $DOT_ENV_PATH/global/global_*.sh ; do
|
||||
if [ -r "$i" ]; then
|
||||
. $i
|
||||
fi
|
||||
done
|
||||
|
||||
# Now source OS specifics
|
||||
if [[ "$SHLVL" == "1" ]]; then
|
||||
echo "Sourcing $OS Environment"
|
||||
fi
|
||||
for i in $OS_DIR/*.sh ; do
|
||||
if [ -r "$i" ]; then
|
||||
. $i
|
||||
fi
|
||||
done
|
||||
|
||||
# Source Host specifics if there are any for the current host
|
||||
if [[ ! -z "$HOST" ]]; then
|
||||
HOST_DIR=$DOT_ENV_PATH/host/`hostname`
|
||||
if [[ "$SHLVL" == "1" ]]; then
|
||||
echo "Sourcing '$HOST' Environment"
|
||||
fi
|
||||
for i in $HOST_DIR/*.sh ; do
|
||||
if [ -r "$i" ]; then
|
||||
. $i
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
unset i
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue