How to include a file in my .zshrc?
Asked Answered
T

2

7

I normally use Github for my dotfiles. For a gem I am working on, I need to add some private keys to my .zshrc.

Is there a way for me to include another file in my .zshrc, where I can store my environment variables in that included file?

Troxler answered 20/3, 2017 at 14:18 Comment(0)
K
17

Yes, by using the source command:

# environment variables
source ~/.zsh_env_vars
Kolnick answered 20/3, 2017 at 14:43 Comment(1)
Note for newbies like myself: Syntax for ENVs in shell is different from using ENVs in Ruby or Rails projects: export MY_ENV_VARIABLE_NAME="xxxxxxxxxxxxxxxx".Troxler
P
0

You can add this to your .zshrc or .zshenv file to iterate through a directory. That makes it possible to seperate your variables. Maybe you want to have a specific file for $PATH and one for your ruby variables, ...

for file in ~/.zsh_variables/*; do if [ -f "$file" ]; then source "$file" fi done

Presa answered 29/12, 2023 at 20:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.