diff --git a/bash/rc b/bash/rc index 85234e4..264e271 100644 --- a/bash/rc +++ b/bash/rc @@ -1,5 +1,5 @@ #!/bin/bash -source "$HOME/.my_bash_env" +source "$HOME/.wryn/env/env.bash" RC_DIR="$DOTWRYN/bash" diff --git a/env/env.bash b/env/env.bash new file mode 100755 index 0000000..99ee338 --- /dev/null +++ b/env/env.bash @@ -0,0 +1,15 @@ +#!/bin/bash +# Default bash environment +RD_PATH="$HOME/RentDynamics" +SCHOOL_DIR="$HOME/School" +DOTWRYN="$HOME/.wryn" + + +LOCAL_OVERRIDES="$HOME/.config/wryn/env.bash" +[ -f "$LOCAL_OVERRIDES" ] \ + && source "$LOCAL_OVERRIDES" \ + || { + touch $LOCAL_OVERRIDES \ + && echo '#!/bin/bash' > $LOCAL_OVERRIDES \ + && echo '# Local overrides of .wryn environment variables' >> $LOCAL_OVERRIDES + } diff --git a/env/env.sh b/env/env.sh new file mode 100755 index 0000000..9274d6f --- /dev/null +++ b/env/env.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# Default shell environment +LOCAL_OVERRIDES="$HOME/.config/wryn/env.sh" +[ -f "$LOCAL_OVERRIDES" ] \ + && source "$LOCAL_OVERRIDES" \ + || { + touch $LOCAL_OVERRIDES \ + && echo '#!/bin/sh' > $LOCAL_OVERRIDES \ + && echo '# Local overrides of .wryn environment variables '>> $LOCAL_OVERRIDES + } diff --git a/env/env.vim b/env/env.vim new file mode 100644 index 0000000..4e3355d --- /dev/null +++ b/env/env.vim @@ -0,0 +1,8 @@ +let $RC_DIR=expand("$HOME/.wryn") +let $VIM_DIR=expand("$RC_DIR/vim") +let $WRYNVIMRC=expand("$VIM_DIR/rc.vim") +let $WRYNBASH=expand("$RC_DIR/bashrc") +let $MYBASHRC=expand("$HOME/.bashrc") + +" Local environment and environment overrides +source $HOME/.config/wryn/env.vim diff --git a/env/env.zsh b/env/env.zsh new file mode 100755 index 0000000..c619688 --- /dev/null +++ b/env/env.zsh @@ -0,0 +1,14 @@ +#!/bin/zsh +# Default zsh environment +RD_PATH="$HOME/RentDynamics" +SCHOOL_DIR="$HOME/School" +DOTWRYN="$HOME/.wryn" + +LOCAL_OVERRIDES="$HOME/.config/wryn/env.zsh" +[ -f "$LOCAL_OVERRIDES" ] \ + && source "$LOCAL_OVERRIDES" \ + || { + touch $LOCAL_OVERRIDES \ + && echo '#!/bin/zsh' > $LOCAL_OVERRIDES \ + && echo '# Local overrides of .wryn environment variables '>> $LOCAL_OVERRIDES + } diff --git a/setup b/setup index 726cfaf..98cb53a 100755 --- a/setup +++ b/setup @@ -1,54 +1,38 @@ #!/bin/bash -RC_DIR='$HOME/.wryn' - [ ! -f "$HOME/.bashrc" ] && touch "$HOME/.bashrc"; [ ! -f "$HOME/.vimrc" ] && touch "$HOME/.vimrc"; +[ ! -d "$HOME/.config" ] && mkdir "$HOME/.config"; +[ ! -d "$HOME/.config/wryn" ] && mkdir "$HOME/.config/wryn"; + +# Source RCs grep '.wryn' $HOME/.bashrc >/dev/null 2>/dev/null \ && echo already set up bash rc \ - || echo source $RC_DIR/bash/rc >> $HOME/.bashrc; + || echo source $HOME/.wryn/bash/rc >> $HOME/.bashrc; grep '.wryn' $HOME/.vimrc >/dev/null 2>/dev/null \ && echo already set up vim rc \ - || echo source $RC_DIR/vim/rc.vim >> $HOME/.vimrc; + || echo source $HOME/.wryn/vim/rc.vim >> $HOME/.vimrc; grep '.wryn' $HOME/.zshrc >/dev/null 2>/dev/null \ && echo already set up zsh rc \ - || echo source $RC_DIR/zsh/rc >> $HOME/.zshrc; - -LOCAL_DIR_SETUP="$HOME/.my_bash_env" -if [ ! -f "$LOCAL_DIR_SETUP" ]; then - touch "$LOCAL_DIR_SETUP"; - echo '#!/bin/bash' >> $LOCAL_DIR_SETUP - echo 'RD_PATH="$HOME/RentDynamics";' >> $LOCAL_DIR_SETUP - echo 'SCHOOL_DIR="$HOME/School";' >> $LOCAL_DIR_SETUP - echo 'DOTWRYN="$HOME/.wryn";' >> $LOCAL_DIR_SETUP -else - echo 'bash environment variables already set up' -fi - -LOCAL_ZSH_SETUP="$HOME/.my_zsh_env" -if [ ! -f "$LOCAL_ZSH_SETUP" ]; then - touch "$LOCAL_ZSH_SETUP"; - echo '#!/bin/zsh' >> $LOCAL_ZSH_SETUP - echo 'RD_PATH="$HOME/RentDynamics";' >> $LOCAL_ZSH_SETUP - echo 'SCHOOL_ZSH="$HOME/School";' >> $LOCAL_ZSH_SETUP - echo 'DOTWRYN="$HOME/.wryn";' >> $LOCAL_ZSH_SETUP -else - echo 'zsh environment already set up'; -fi + || echo source $HOME/.wryn/zsh/rc >> $HOME/.zshrc; -LOCAL_VIM_SETUP="$HOME/.my_vim_env" -if [ ! -f "$LOCAL_VIM_SETUP" ]; then - touch "$LOCAL_VIM_SETUP"; - echo 'let $RC_DIR=expand("$HOME/.wryn")' >> $LOCAL_VIM_SETUP - echo 'let $VIM_DIR=expand("$RC_DIR/vim")' >> $LOCAL_VIM_SETUP - echo 'let $WRYNVIMRC=expand("$VIM_DIR/rc.vim")' >> $LOCAL_VIM_SETUP - echo 'let $WRYNBASH=expand("$RC_DIR/bashrc")' >> $LOCAL_VIM_SETUP - echo 'let $MYBASHRC=expand("$HOME/.bashrc")' >> $LOCAL_VIM_SETUP - echo 'let $WEBBROWSER="' $(which google-chrome-stable) '"' >> $LOCAL_VIM_SETUP -else - echo 'vim environment variables already set up' -fi +# setup local environments +which sh >/dev/null && "$HOME/.wryn/env/env.sh"; +which bash >/dev/null && "$HOME/.wryn/env/env.bash"; +which zsh >/dev/null && "$HOME/.wryn/env/env.zsh"; + +LOCAL_VIM_ENV="$HOME/.config/wryn/env.vim" +[ ! -f "$LOCAL_VIM_ENV" ] \ + && { + touch "$LOCAL_VIM_ENV"; + which google-chrome-stable \ + && echo 'let $WEBBROWSER="'$(which google-chrome-stable)'"' >> $LOCAL_VIM_ENV\ + || echo 'let $WEBBROWSER=""' >> $LOCAL_VIM_ENV; + + } || { + echo 'vim environment variables already set up' + } diff --git a/vim/rc.vim b/vim/rc.vim index 30d77e5..a1e549c 100644 --- a/vim/rc.vim +++ b/vim/rc.vim @@ -1,5 +1,5 @@ " -- Environment Variables --------------------------------------- {{{ -source $HOME/.my_vim_env +source $HOME/.wryn/env/env.vim "sets the following variables: "$RC_DIR $VIM_DIR $WRYNVIMRC $WRYNBASH $MYBASHRC $WEBBROWSER diff --git a/zsh/rc b/zsh/rc index 2e05ab9..4e07fe5 100644 --- a/zsh/rc +++ b/zsh/rc @@ -1,5 +1,5 @@ #!/bin/zsh -source "$HOME/.my_zsh_env" +source "$HOME/.wryn/env/env.zsh" RC_DIR="$DOTWRYN/zsh"