Session Environment Variables/uk: Difference between revisions

From KDE Wiki Sandbox
(Updating to match new version of source page)
(Updating to match new version of source page)
Line 3: Line 3:
== Встановлення змінних середовища сеансу ==
== Встановлення змінних середовища сеансу ==


It is simple to set environment variables that affect your whole session. KDE will execute any script it finds in <tt>$HOME/.config/plasma-workspace/env</tt> whose filename ends in <tt>.sh</tt>, and it will maintain all the environment variables set by them. It is important that any variable you want to set must be also <code>exported</code>. In the case of PATH, for instance, your system will be set up with certain likely directories as the likely places to find things. Now you are adding an extra possible search place.  You can see what is already set by opening [[Special:myLanguage/Konsole|Konsole]] and typing <code> echo $PATH</code>
It is simple to set environment variables that affect your whole session. Plasma will execute any script it finds in <tt>$HOME/.config/plasma-workspace/env</tt> whose filename ends in <tt>.sh</tt>, and it will maintain all the environment variables set by them. It is important that any variable you want to set must be also <code>exported</code>. In the case of PATH, for instance, your system will be set up with certain likely directories as the likely places to find things. Now you are adding an extra possible search place.  You can see what is already set by opening [[Special:myLanguage/Konsole|Konsole]] and typing <code> echo $PATH</code>


Щоб додати каталог до вашої змінної [http://en.wikipedia.org/wiki/Path_(computing) PATH], просто створіть файл з назвою <tt>$HOME/.kde/env/path.sh</tt> і вмістом, подібним до наведеного нижче:
To add paths to your [http://en.wikipedia.org/wiki/Path_(computing) PATH], simply create a file named <tt>$HOME/.config/plasma-workspace/env/path.sh</tt> with a contents similar to this:


{{Input|1=export PATH=$HOME/local/bin:$PATH
{{Input|1=export PATH=$HOME/local/bin:$PATH
Line 18: Line 18:
}}
}}


You can also check how KDE actually does it. It's done in your local <code>startkde</code>, which normally you can find in <tt>/usr/bin/startkde</tt>. If you are interested in reading the code, you can can view it [https://quickgit.kde.org/?p=plasma-workspace.git&a=blob&f=startkde%2Fstartkde.cmake online]. Just search the file for ''environment variables''.
You can also check how Plasma actually does it. It's done in your local <code>startkde</code>, which normally you can find in <tt>/usr/bin/startkde</tt>. If you are interested in reading the code, you can can view it [https://quickgit.kde.org/?p=plasma-workspace.git&a=blob&f=startkde%2Fstartkde.cmake online]. Just search the file for ''environment variables''.


[[Category:Система/uk]]
[[Category:Система/uk]]

Revision as of 19:50, 22 February 2017

Other languages:

Встановлення змінних середовища сеансу

It is simple to set environment variables that affect your whole session. Plasma will execute any script it finds in $HOME/.config/plasma-workspace/env whose filename ends in .sh, and it will maintain all the environment variables set by them. It is important that any variable you want to set must be also exported. In the case of PATH, for instance, your system will be set up with certain likely directories as the likely places to find things. Now you are adding an extra possible search place. You can see what is already set by opening Konsole and typing echo $PATH

To add paths to your PATH, simply create a file named $HOME/.config/plasma-workspace/env/path.sh with a contents similar to this:

export PATH=$HOME/local/bin:$PATH

Розгляньмо наш приклад докладніше. Команда export повідомляє системи, що визначається щось, що має бути збережено і використано для пошуку файлів. Далі ви маєте вказати повністю шлях до каталогу, який слід додати (у нашому прикладі ~/local/bin, тобто /home/ви/local/bin, знову ж таки, ви можете скористатися командою echo $HOME, щоб переглянути шлях до каталогу повністю). Нарешті, вказано саму змінну $PATH, щоб вказати, що ви хочете додати до неї новий каталог, а не замінити список вже вказаних каталогів.

Часто цього достатньо. Але якщо ви продовжите вивчення системи, ймовірно, у вас вам захочеться мати те саме середовище під час користування консоллю або доступу до вашої системи за допомогою ssh, вам доведеться додати наприкінці вашого файла .bashrc щось таке:

source $HOME/.config/plasma-workspace/env/path.sh

You can also check how Plasma actually does it. It's done in your local startkde, which normally you can find in /usr/bin/startkde. If you are interested in reading the code, you can can view it online. Just search the file for environment variables.