Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for multiple config files #31

Closed
kamiyaa opened this issue May 4, 2021 · 2 comments
Closed

support for multiple config files #31

kamiyaa opened this issue May 4, 2021 · 2 comments

Comments

@kamiyaa
Copy link

kamiyaa commented May 4, 2021

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
Copy link
Owner

mitnk commented May 5, 2021

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
Copy link
Author

kamiyaa commented May 5, 2021

Ohh I see, thanks!

@kamiyaa kamiyaa closed this as completed May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants