dotly icon indicating copy to clipboard operation
dotly copied to clipboard

Use environment variables in aliases

Open fabriziofs opened this issue 3 years ago • 0 comments

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! <💚>

fabriziofs avatar Nov 30 '22 19:11 fabriziofs