2016년 2월 16일 화요일

[zsh, YADR, dotfiles] environment variable path / 환경변수 설정

[zsh, YADR(dotfiles)] environment variable path / 환경변수 설정




이 글은 여러분이 linux, mac에서의 환경 변수 설정을 할수 있다는 가정하에 진행됩니다.
만약 linux, mac 에서의 환경 변수 설정을 모른다면 아래 글을 참조하세요.
This article is based on the assumption that you can set the environment variable in linux, mac.
If you see the following articles if you do not know the environment variables set in the linux, mac.

[Linux, Mac] environment variable path / 환경변수 설정





1. zsh 유저 환경변수
1. zsh user environment variables


YADR 즉 dotfiles는 zsh기반으로 동작하며
zsh은 기존 linux, mac 시스템이 사용하는 ~/.bash_profile 파일의 설정을 따르지 않고
~/.zshrc 파일의 설정을 따릅니다.
따라서 기존 linux, mac 시스템에서 .bash_profile 파일에 등록한것과 같이 아래 형태로 환경변수를 정의하면 됩니다.
That YADR dotfiles operates as zsh-based
zsh existing linux, mac system does not follow the set of ~/.bash_profile file to use
Follow the settings in ~/.zshrc file.
Therefore, as registered in the .bash_profile file in the existing linux, mac system, you can define an environment variable in the form below.


export VARIABLE=DIR



2. zsh 전역 환경변수
2. zsh global environment variables



zsh의 환경 변수 설정 위치에 대해 stack overflow 검색을 할경우 
아래 세개의 파일이 언급됩니다.
When a stack overflow search for the location of the csh environment variable settings
The three files mentioned below.

~/.zshrc
~/.zshenv
~/.zprofile


~/.zshenv 파일을 열어보면 아래와 같이 환경변수들을 정의하라는 메시지와
쉘에 로그인하지 않은경우에 대해서 보장한다고 명시되어있습니다.
If you open the ~ /.zshenv file and prompts you to define the environment variable as follows: It stated that the guarantees for the shell if you are not logged in.


설치 방법, 운영체제에 따라 .zshenv파일의 위치는
~/.zshenv 또는 /etc/zsh/zshenv 에 있습니다.
만약 ~/.zshenv 가 없을경우 /etc/zsh/zshenv 파일을 수정하세요.
How to install, the location of the file, depending on which operating system is .zshenv
~/.zshenv or in /etc/zsh/zshenv 
If ~/.zshenv is not the case, edit the /etc/zsh/zshenv file.






3. 기존 linux, mac시스템 환경변수 include
3. The existing linux, mac system environment variables include



위에서 zsh에 유저 환경변수, 전역변수에 대해 언급하였지만
기존 시스템을 사용하던중에 zsh을 사용할경우
모든 변수들을 옮겨서 적어줘야 하는것은 매우 불편한 일입니다.
On the user environment variables in zsh, but referring to global variables
If you use zsh were used in the existing system
It is very inconvenient to have to write all the variables move.


이경우 .zshenv 파일하단에 아래와같이 추가하면 기존 .bash_profile에 설정된 환경변수를 모두 로딩합니다.
In this case, add the following to the bottom .zshenv file loads all existing environment variables set in the .bash_profile.



source "$HOME/.bash_profile"




만약 ~/.bash_profile이 아니라 전역 환경변수인 /etc/profile을 로드하고 싶다면
아래와 같이 작성하세요.
If ~/.bash_profile, not if you want to load a global environment variable in /etc/profile
Write below.


source "/etc/profile"





댓글 없음:

댓글 쓰기