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

Use environment variables in aliases #228

Open
fabriziofs opened this issue Nov 30, 2022 · 0 comments
Open

Use environment variables in aliases #228

fabriziofs opened this issue Nov 30, 2022 · 0 comments

Comments

@fabriziofs
Copy link

Hello! 👋

I wanted to use node inside docker, to achieve that I created an alias like this inside shell/aliases.sh:

alias node='docker run -it --rm --name my-running-script -u "node" -v "$PWD":/usr/src/app -w /usr/src/app $node_args node:$NODE_VERSION'

The $NODE_VERSION variable is declared in shell/exports.sh, but currently in the shell/init.sh file the loading order is:

source "$DOTFILES_PATH/shell/aliases.sh"
source "$DOTFILES_PATH/shell/exports.sh"
source "$DOTFILES_PATH/shell/functions.sh"

Because aliases.sh is declared before exports.sh the $NODE_VERSION variable can't be used in my alias 😓

I've solved this problem changing the order those files are loaded, like this:

source "$DOTFILES_PATH/shell/exports.sh"
source "$DOTFILES_PATH/shell/aliases.sh"
source "$DOTFILES_PATH/shell/functions.sh"

This change can be included in the main project? This can cause any problems?

Thanks! <💚>

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

1 participant