Mac and configuration environment variable

Every developer environment variable is not open around the topic herein, this simply tells Mac in ~/.bash_profilerelevant environmental variables

Mac configuration environment variable in position

Mac and configuration environment variable positions mainly in the following three (see below several multi-load order):

  • / etc / profile (not recommended to modify this file)
    global (public) configuration, regardless of which user will log in to read the file

  • / etc / bashrc (generally added in this file system-level environment variables)
    global (public) configuration, when the bash shell execution, no matter how, will read this file

  • ~ / .bash_profile (generally added in this user-level file, environment variables used )
    for each user can input information for the file using the shell to their specific use, when a user logs in, the file is performed only once

OS X system environment variables, loading order:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/etc/profile
/etc/paths
~/.bash_profile
~/.bash_login
~/.profile
~/.bashrc

/ etc / profile and / etc / paths are system level, the system will start loading
the back of a few current user-level environment variable.

~ /.Bash_profile , ~ /.bash_login , ~ /.profile order reading from front to back,
if ~ /.bash_profile file exists, the latter will be ignored several files read,
if ~ /.bash_profile file does not exist, and so will read back the file.

~ /.Bashrc the absence of such rules, it is open when the bash shell loaded

View Mac use what shell

1
echo $SHELL

Types of shell are:

  • csh or tcsh; these types categorized as: C Shell (before the default Mac OS X 10.2)
  • bash, sh, zsh; these types categorized as: (default after Mac OS X 10.3) Bourne Shell

different languages will only shell is to use the rules there will be little difference, are interested in children's shoes which can further explore the difference; the text in a manner suitable for Bourne Shell

~ / .Bash_profile configuration

create

1
touch .bash_profile

turn on

1
2
3
open -e .bash_profile

NOTE: This editor is opened by an external editing tool, the advantage of a strong visual

After just close the edit box will be saved, saved can refresh

1
2
3
vi ~ / .bash_profile

Note: Use the vi editor, the advantage of no additional switching windows

vi commonly used commands:

command DEFINITIONS
:w Storage
:q Exit vim
:wq Save and Exit
:wq! (In the case of the conversion rights may) forced to save and exit
:q! Exit without saving
:w filename Save as filename
:n,m w filename The n-th row to the m-th row is saved filename
: Not set Show Line Numbers
:set nonu It does not display line numbers
:! command Temporarily leave vim, and execute command, executed after their entering vim
:r filename The read data file filename into the current file
:set all Display the current environment configuration of vim

According to the command editing, save;

Configuration

1
Export  the PATH = $ {} the PATH : Path 1: Path 2: $ the PATH (a ":" split)

Such as:

1
2
3
4
5
6
7
8
9
10
11
12
13
export xx1_HOME=/Library/xxx/xxx/xxx/Contents/Home
export xx2_HOME=/usr/local/xxx/xxx
export xx3__HOME=/Users/xxx/xxx

export PATH=${PATH}:xx1_HOME/bin: xx2_HOME/tools: xx2_HOME/tools/bin: xx3__HOME/bin:$PATH

Also can be configured directly

export PATH=$PATH:/usr/local/xxx/bin

or

export PATH=/usr/local/hbase/bin:"$PATH"

or:

1
2
3

export JAVA_HOME=/opt/module/jdk1.8.0_151
export PATH=$PATH:$JAVA_HOME/bin

Refresh

1
source ~/.bash_profile

These are some simple configuration environment variable, there are many interesting configurations, children's shoes can explore on their own, welcome to exchange and share

Original: Big Box  Mac configured environment variables


Guess you like

Origin www.cnblogs.com/petewell/p/11612109.html