Змінні середовища сеансу

From KDE UserBase Wiki
Revision as of 16:41, 7 August 2011 by FuzzyBot (talk | contribs) (Updating to match new version of source page)
Other languages:

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

Встановити змінні середовища, які діятимуть протягом всього сеансу роботи доволі просто. KDE виконає будь-які скрипти, назви файлів які зберігаються у $HOME/.kde/env і назви файлів яких завершуються на .sh, а отже використовуватиме всі змінні середовища, встановлені у цих скриптах. Важливо, також експортувати всі визначенні змінні. Наприклад, у випадку визначення змінної PATH систему буде проінформовано про список каталогів, у яких слід шукати дані. Нехай нам потрібно додати до списку ще один каталог. Перевірити, чи є цей каталог у поточному списку можна за допомогою відкриття вікна Konsole і віддавання команди echo $PATH

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

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

Let's explore that. The command export tells the system that this is something that should be saved and used when looking for files. Next you add the full name of the directory you want to add (in this case ~/local/bin, another way of writing /home/you/local/bin - again you can use echo $HOME to see how that works). Finally you see the $PATH variable itself - that's because you want to add your new path into it, not replace the existing path.

Often that will work well enough for you, but as you get more familiar with the system you will probably want to have the same environment when using a console or accessing your machine via ssh, you will need to add to the end of your .bashrc something like this:

source $HOME/.kde/env/path.sh

You can also check how KDE 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.