support for multiple config files
kamiyaa opened this issue · 2 comments
kamiyaa commented
I usually like to have my aliases, exports, etc. separated into separate files so its easier to read.
And then inside .bashrc
or .bash_profile
I would import them in.
Currently, cicada does not work with multiple files I think, or am I doing this wrong?
Thanks!
My bash script for importing files:
SHELL=cicada
INCLUDE_FILES=( \
"$HOME/.config/$SHELL/dirs.sh" \
"$HOME/.config/$SHELL/alias.sh" \
"$HOME/.config/$SHELL/exports.sh" \
)
for FILE in ${INCLUDE_FILES[@]}; do
if [ -f "$FILE" ]; then
source "$FILE"
fi
done
mitnk commented
The scripting ability of cicada is very limited compared to bash. The following does not work in cicada, for example:
INCLUDE_FILES=( \
"$HOME/.config/$SHELL/dirs.sh" \
"$HOME/.config/$SHELL/alias.sh" \
"$HOME/.config/$SHELL/exports.sh" \
)
But you can importing multiple files for sure. The most reliable way to do this is like this:
source $HOME/.config/$SHELL/dirs.sh
source $HOME/.config/$SHELL/alias.sh
source $HOME/.config/$SHELL/exports.sh
If you want to check the exists of file before source, you can do things like this:
function source_if_exists() {
if [ -f "$1" ]; then
source "$1"
fi
}
source_if_exists "$HOME/.config/$SHELL/dirs.sh"
source_if_exists "$HOME/.config/$SHELL/alias.sh"
You can read docs for more details.
kamiyaa commented
Ohh I see, thanks!