Three ways to add environment variables for Mac

Source: Internet
Author: User

Three methods for adding environment variables for Mac: sudo vi/etc/paths to edit paths and add environment variables to paths. Vim is an editor with several other features, such as Pico and Emacs. Hint: when entering environment variables, you don't need to input them one by one. You just need to drag the folder to Terminal. Method 2: 1. create a file: sudo touch/etc/paths. d/mysql2. use vim to open this file (if it is open-t, it cannot be edited): sudo vim/etc/paths. d/mysql
3. edit the file, type the path, and save the file (close the Terminal window and open a new one, you can use the mysql Command)/usr/local/mysql/bin is said, in this way, you can generate new files by yourself without storing all the variables in a paths file for convenient management. Method 3: 1. Create and open it as TextEdit ~ /. Bash_profile file touch ~ /. Bash_profile; open-t ~ /. Bash_profile2. added the environment variable export PATH = "$ HOME/. rbenv/bin: $ PATH" 3. Make the preceding configuration take effect. source ~ /. Bash_profile4. check whether it takes effect (sometimes you may need to close the current Terminal window and re-open one) echo $ PATH note (the colon is the separator of the environment variable): $ HOME /. $ PATH in rbenv/bin: $ PATH specifies/usr/bin:/usr/sbin: /usr/local/bin if you want to add multiple environment variables, you need to write as follows: export PATH = "$ PATH: /Applications/MacVim-snapshot-68 "export PATH =" $ HOME /. rbenv/bin: $ PATH "eval" $ (rbenv init-) "export PATH =" $ HOME /. rbenv/bin: $ PATH "eval" $ (rbenv init -)"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.