Terminal setting mac os

Use environment variables in Terminal on Mac

The shell uses environment variables to store information, such as the name of the current user, the name of the host computer and the default paths to any commands. Environment variables are inherited by all commands executed in the shell’s context and some commands depend on environment variables.

You can create environment variables and use them to control the behaviour of a command without modifying the command itself. For example, you can use an environment variable to have a command print debug information to the console.

To set the value of an environment variable, use the appropriate shell command to associate a variable name with a value. For example, to set the variable PATH to the value /bin:/sbin:/user/bin:/user/sbin:/system/Library/ , you would enter the following command in a Terminal window:

To view all environment variables, enter:

When you launch an app from a shell, the app inherits much of the shell’s environment, including exported environment variables. This form of inheritance can be a useful way to configure the app dynamically. For example, your app can check for the presence (or value) of an environment variable and change its behaviour accordingly.

Different shells support different semantics for exporting environment variables. See your preferred shell’s man page.

Although child processes of a shell inherit the environment of that shell, shells are separate execution contexts that don’t share environment information with each other. Variables you set in one Terminal window aren’t set in other Terminal windows.

After you close a Terminal window, variables you set in that window are no longer available. If you want the value of a variable to persist across sessions and in all Terminal windows, you must set it in a shell startup script. For information about modifying your zsh shell startup script to keep variables and other settings across multiple sessions, see the “Invocation” section of the zsh man page.

Источник

Open or quit Terminal on Mac

Each window in Terminal represents an instance of a shell process. The window contains a prompt that indicates you can enter a command. The prompt you see depends on your Terminal and shell preferences, but it often includes the name of the host you’re logged in to, your current working folder, your username and a prompt symbol. For example, if a user named michael is using the default zsh shell, the prompt appears as:

Читайте также:  Удалены все файлы с рабочего стола windows 10

This indicates that the user named michael is logged in to a computer named MacBook-Pro, and the current folder is his home folder, indicated by the tilde (

Open Terminal

On your Mac, do one of the following:

Click the Launchpad icon in the Dock, type Terminal in the search field, then click Terminal.

In the Finder , open the /Applications/Utilities folder, then double-click Terminal.

Quit Terminal

In the Terminal app on your Mac, choose Terminal > Quit Terminal.

Quit a shell session

In the Terminal app on your Mac, in the window running the shell process you want to quit, type exit , then press Return.

This ensures that commands actively running in the shell are closed. If anything’s still in progress, a dialogue appears.

If you want to change the shell exit behaviour, see Change Profiles Shell preferences.

Источник

Use profiles to change the look of Terminal windows on Mac

Use profiles to customize the colors, font, cursor style, background, and other elements of Terminal windows. A profile is a collection of style and behavior settings for a Terminal window.

Terminal comes with a set of predefined profiles, and you can also create your own custom profiles.

Create a new profile or modify an existing profile

In the Terminal app on your Mac, choose Terminal > Preferences, then click Profiles.

Do one of the following:

Create a new profile: Click the Add button under the profiles list, then enter a name for the new profile.

Modify an existing profile: Select the profile you want to modify.

Choose settings for the profile:

Text: Change colors, fonts, text, backgrounds, and cursor style.

Window: Change window display settings including title, size, and scrollback.

Tab: Change tab display settings including title and process name.

Shell: Change settings for startup and exit behavior.

Keyboard: Change settings for function keys, the option key, and the alternate screen.

Advanced: Change settings for terminal type (terminfo), input, bell behavior, and international encodings.

Rename a profile

In the Terminal app on your Mac, choose Terminal > Preferences, then click Profiles.

Double-click the name of the profile you want to rename.

Enter a new name, then press Return.

Copy a profile

In the Terminal app on your Mac, choose Terminal > Preferences, then click Profiles.

Select the profile you want to copy.

Click the Action pop-up menu , then choose Duplicate Profile.

Enter a name for the copied profile, then press Return.

Читайте также:  Нет драйвера usb при установке windows

Remove a profile

In the Terminal app on your Mac, choose Terminal > Preferences, then click Profiles.

Select the profile you want to remove.

Click the Remove button under the profiles list.

Restore the predefined Terminal window profiles

If you removed or changed any of the predefined profiles that came with Terminal, you can add them back to the profiles list with their original settings. You can restore only the entire set of predefined profiles (that is, you can’t restore them individually).

If you customized one of the predefined profiles and want to save your customizations, you need to rename the profile before restoring the predefined profiles. The restore operation overwrites the settings for each of the predefined profiles.

In the Terminal app on your Mac, choose Terminal > Preferences, then click Profiles.

Click the Action pop-up menu , then choose Restore Default Profiles.

Источник

Как настроить Терминал в Mac (macOS) и сделать его более полезным

Приложение Терминал – ваш верный друг в мире командной строки macOS. Он предлагает интерфейс с оболочкой, которая интерпретирует ваши команды и затем воплощает их в жизнь.

Терминал – Основы

Когда вы открываете на Mac приложение Терминал, то видите практически пустое окно с двумя строчками текста. Первая содержит в себе дату и время вашего последнего логина.

Last login: Wed Apr 3 13:08:53 on console

Вторая строчка – это, собственно, и есть командная строка для работы. Прямоугольный бокс в конце – ваш курсор.

Вводить в Терминал команды нужно сразу после второй строчки, которая имеет вид:

Вот что означают эти элементы:

Первая часть (до двоеточия) – это имя вашего Mac. Двоеточие – просто визуальный разделитель.
Вторая часть начинается с тильды (

). Она указывает на то, что вы находитесь в домашней директории, и использует краткое имя пользователя.
Наконец, знак доллара уведомляет о том, что вы вошли в систему как пользователь без рут-прав.

Как изменить размеры окна Терминала по умолчанию

Терминал не идеален. Текст команд набирается мелким шрифтом, его трудно анализировать, а курсор порой нелегко найти. Да, размер окна можно увеличить – но macOS «забудет» ваши настройки сразу после того, как вы закроете приложение.

Для того, чтобы сделать окно Терминала более удобным, нажмите ⌘Cmd + I – откроется Инспектор (или в строке меню вверху при открытом терминале выберите Shell → Показать Инспектор). В секции Свойства укажите более удобные для вас значения в пунктах Столбцы и Строки, а затем подтвердите выбор клавишей Return (Enter).

Как изменить фон в окне Терминала

В том же Инспекторе, во вкладке Профиль будут указаны доступные темы оформления – ими можно изменить внешний вид Терминала до неузнаваемости.

Например, попробуйте вариант Homebrew – и почувствуйте себя Windows-хакером! :).

Предпросмотр всех тем оформления есть в настройках. Для перехода к ним выберите в строке меню Терминал → Настройки → Профили.

Как изменить текст в Терминале

Создатели Терминала встроили в приложение необходимые инструменты для настройки системного текста «под себя».

Читайте также:  Caesar 4 runtime error windows 10

Например, для смены шрифта и – что самое главное! – его размера достаточно нажать кнопку Изменить в разделе настроек Текст.

Есть и опции для того, чтобы включить или выключить жирный шрифт, использовать сглаженные шрифты, сменить цвет (!) текста.

Да что там – можно изменить даже курсор! Доступные варианты – блок, подчеркивание или вертикальная полоса. Также в вашей власти – решить, должен ли мигать курсор, и какого цвета ему быть.

Наконец, при желании меняется и прозрачность окна Терминала. В результате очень легко «повесить» прозрачное окно прямо над веб-страницей и вводить команды по мере того, как вы читаете какую-нибудь инструкцию.

Атрибуты окна Терминала

Они включают в себя название, размер, лимит на скроллинг и тому подобные параметры. Помните о том, что выбранные вами настройки применяются только к профилю, а не ко всему Терминалу в целом. Для того, чтобы изменить название окна, просто введите нужный текст в соответствующей строке (Настройки → Окно → Заголовок).

Атрибуты оболочки (Shell)

Здесь происходит тонкая настройка Терминала. Вы можете выбрать команду для запуска сразу после старта (например, запускать «автоматом» стороннюю оболочку).

Полезная опция – попросить Терминал выдавать предупреждения перед закрытием. Для этого откройте Профили → Shell, и в пункте Спрашивать перед закрытием выберите вариант Всегда.

Работа с группами окон в Терминале

А вы знали, что в Терминале можно открывать сразу несколько рабочих окон, размещать их на десктопе так, как вам удобно, а затем никогда не терять эту сессию? За это отвечает специальная функция Группы окон. С её помощью каждое «окошко» получает свой собственный процесс, атрибуты и позицию на рабочем столе.

Перед тем, как создать группу окон, потребуется:

  • Расставить нужные окна на рабочем столе так, как вам хочется.
  • Настроить «под себя» атрибуты, размер и форму каждого окна.
  • Запустить все нужные команды.

Всё готово? Теперь открывайте Окно → Сохранить окна как группу. Далее введите название новой группы, поставьте галочку напротив надписи Использ. группу окон при запуске Терминала и нажмите Сохранить.

Для восстановления вашей группы выберите всё тот же раздел Окно → Открывать группу окон. Чтобы импортировать или экспортировать такие группы, выберите Настройки → Группы окон и нажмите на иконку-шестеренку в нижней части экрана.

Настройка оболочки по умолчанию

Изначально в macOS работает bash. Но есть и другие – bin/bash, /bin/csh, /bin/zsh, /bin/ksh и т.п.

Unix-энтузиасты любят работать с zsh (или Z), т.к. в ней есть много функций и поддержка десятков самых разных плагинов.

Если вы новичок, установленной по умолчанию оболочку bash будет более чем достаточно.

Источник

Оцените статью