Меню Рубрики

Mac os add path

Bash: Как в macOS добавить новую переменную $PATH?

Сегодня рассказываем вам как добавить новую переменную $PATH в операционной системе macOS (OS X).

Если вам надоело в «Терминале» macOS каждый раз вводить определенные команды через ./команда , тогда необходимо добавить переменную окружения. То есть вам необходимо вам необходимо внести путь полный к команде утилиты в файл .bash_profile .

Как узнать полный путь к команде?

Есть два варианта узнать полный путь, где находиться утилиты с соответствующей командой.

С помощью доп.меню

Сделайте «правый клик» по папке, где находится команда и при появлении контекстного меню нажмите кнопку ALT (OPTION) и «Скопируйте путь до».

С помощью терминала

Перетяните папку с командой в «Терминал» после чего вы сможете скопировать полный путь.

Как добавить переменную окружения в macOS?

Есть также 4 варианта — первый, это открытие файла .bash_profile с помощью Finder и внесение пути, второй и третий и четвертый с помощью терминала:

Добавить переменную в файл .bash_profile

Откройте ваш домашний каталог:

Редактируем .bash_profile :

Добавьте в файл такую запись:

Закройте текстовый файл, все готово!

У вас остались еще дополнительные вопросы? Пишите их в комментариях, о том что у вас получилось или наоборот!

Вот и все! Больше полезных статей и инструкций читайте в разделе Статьи и Хаки IOS и macOS. Оставайтесь вместе с сайтом Android +1, дальше будет еще интересней!

Источник

editing PATH variable on mac [closed]

Want to improve this question? Update the question so it’s on-topic for Stack Overflow.

Closed 7 years ago .

How to edit PATH variable on mac (Lion). I cannot find any file where I can add paths. can someone guide me about it?

Whats the file name? .profile or .bash_profile.

and where I can find it? I have tried

5 Answers 5

Edit /etc/paths . Then close the terminal and reopen it.

Note: each entry is seperated by line breaks.

Based on my own experiences and internet search, I find these places work:

Note that you should open a new terminal window to see the changes.

You may also refer to this this question

You could try this:

  1. Open the Terminal application. It can be found in the Utilities directory inside the Applications directory.
  2. Type the following: echo ‘export PATH=YOURPATHHERE:$PATH’ >>

/.profile, replacing «YOURPATHHERE» with the name of the directory you want to add. Make certain that you use «>>» instead of one «>».

  • Hit Enter.
  • Close the Terminal and reopen. Your new Terminal session should now use the new PATH.
  • Источник

    How to Add a New Path to PATH at Command Line the Right Way

    The user path is the series of directories that command line programs are searched in order to run. For example, if you type ‘iostat’ into the terminal, then iostat will be run from /usr/sbin because “/usr/sbin” is part of your $PATH. Accordingly, users who frequently use the command line may need to adjust or add new paths to their terminal so that commands can execute properly.

    Perhaps obvious by now, modifying the PATH is aimed at more advanced users and developers who are using the Terminal and spending a lot of time at the command line. Average Mac users typically have no need to change, add, or otherwise adjust this in Mac OS X. Speaking of Mac OS X, while this is obviously Mac centric, you can use this same trick to add a PATH to your shell in Linux too, as well as most other unix flavors.

    Before getting started, you might want to see the existing $PATH just in case you mess something up, that way you can easily restore to it by exporting using the same commands. To check the current $PATH simply type: “echo $PATH”

    Adding a Directory to PATH

    The easiest way to add a new path to $PATH (the environment variable) is with the export command. In this example we’ll add “

    /opt/bin” to the user PATH with export:

    You can run that directly from the command line, then check the $PATH with echo to show that it has been added like so:

    This should return something like the following, note the newly added

    /opt/bin directory at the end:

    How to Add Multiple Paths to PATH

    Just as multiple paths can be stored and strung together in $PATH in accordance to their search priority, you can also add new paths this way as well. We’ll use the same example as before, but this time also add the

    Setting PATH in Shell Profile

    Keep in mind that for changes to PATH to persist, you’ll want to add them into

    /.bash_profile, depending on which shell you use. Use your favorite text editor to do that, whether it’s nano, emacs, or vim. If you’re getting complicated, it’s a good idea to add comments to the .profile to keep things easily scannable:

    #Adding opt bin and dev bin to PATH for fun
    export PATH=$PATH:

    Bash is the default shell in many versions of Mac OS X, but zsh is the default in later modern releases, and of course there are other shells like sh, ksh, and tcsh are also bundled with the Mac. Changing the Mac OS X shell is a very easy process either with chsh, or within Terminal and/or iTerm2 preferences.

    Источник

    Добавить переменную в $PATH macOS

    Если скитание по интернету не дают вам ответа, как добавить переменную в $PATH macOS, то на сайте Я Знаю! Вы найдете простое решение!

    Новая переменная $PATH macOS
    для текущего пользователя

    Для того чтобы раз и навсегда добавить новую переменную в $PATH macOS для текущего пользователя необходимо выполнить несложные действия в терминале.

    Найдите в меню Launchpad приложение «Терминал» и запустите его. Введите команду для перехода в домашний каталог:

    • После чего приступите к редактированию файла .bash_profile:
    • Добавьте ваш путь к команде или скрипту:
    • Сохраните изменения с помощью нескольких комбинации клавиш
      • CTRL O
      • CTRL X

    Полностью закройте приложение Терминал и снова запустите его, проверьте добавилась ли ваша новая переменная в $PATH:

    Новая переменная $PATH macOS
    для всех пользователей

    Найдите в меню Launchpad приложение «Терминал» и запустите его, введите команду:

    Добавьте путь к команде или скрипту:

    • Сохраните изменения с помощью нескольких комбинации клавиш
      • CTRL O
      • CTRL X
    • Проверьте наличие новой переменной:

    Вот и все! Теперь вы знаете как добавить переменную в $PATH macOS!

    Источник

    Yesterday once more

    add to the PATH on MAC

    Here are some way to add to the path.

    Why i do this?

    In the process of testing mitmproxy, I installed mitmproxy. After the mitmproxy installer finished, it recommended The scripts mitmdump, mitmproxy, mitmweb, pathoc and pathod are installed in ‘/Users/dc/Library/Python/3.7/bin’ which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use —no-warn-script-location. . It turns out there is avery neat way to do this in OSX, the /etc/paths file. The file contains a list of paths that are added to the $PATH variable in the shell. Here are some way to add to the path:

    • Open up Terminal.
    • Run the following command:
    • Enter your password, when prompted.
    • Enter the path you want to add on the bottom of the file.
    • Hit control-x to quit
    • Enter Y to save the modified buffer.
    • Then, open new terminal window, type:
    • You should see something similar to this(including the path you’ve added!):

    Источник

    Setting PATH environment variable in OSX permanently

    I have read several answers on how to set environmental variables on OSX as permanently.

    First, I tried this, How to permanently set $PATH on Linux/Unix? but I had an error message saying no such file and directory , so I thought I could try

    /.bash_profile instead of

    /.profile but it did not work.

    Second, I found this solution How to set the $PATH as used by applications in os x , which advices to make changes in

    but again I had no such file and directory error.

    I need a way to set these variables such that it won’t require to set them again and again each time I open a new terminal session.

    /.profile most *nix systems recognize the file and use it if it exists. you might need a reboot though – trve.fa7ad Jun 6 ’16 at 12:02

    /.MacOSX/environment.plist is deprecated. – Pierre ALBARÈDE Apr 8 ’18 at 17:46

    6 Answers 6

    You have to add it to /etc/paths .

    Reference (which works for me) : Here

    I’ve found that there are some files that may affect the $PATH variable in macOS (works for me, 10.11 El Capitan), listed below:

    As the top voted answer said, vi /etc/paths , which is recommended from my point of view.

    Also don’t forget the /etc/paths.d directory, which contains files may affect the $PATH variable, set the git and mono-command path in my case. You can ls -l /etc/paths.d to list items and rm /etc/paths.d/path_you_dislike to remove items.

    If you’re using a «bash» environment (the default Terminal.app , for example), you should check out

    /.bashrc . There may be not that file yet, but these two files have effects on the $PATH .

    If you’re using a «zsh» environment (Oh-My-Zsh, for example), you should check out

    And don’t forget to restart all the terminal windows, then echo $PATH . The $PATH string will be PATH_SET_IN_3&4:PATH_SET_IN_1:PATH_SET_IN_2 .

    Noticed that the first two ways ( /etc/paths and /etc/path.d ) is in / directory which will affect all the accounts in your computer while the last two ways (

    / directory (aka, /Users/yourusername/ ) which will only affect your account settings.

    Источник

    Добавить комментарий

    Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Mac os active directory
  • Mac os acid pro
  • Mac os acer aspire 5315
  • Mac os 2560 1080
  • Mac os 777 chmod