Session Environment Variables/da: Difference between revisions

From KDE UserBase Wiki
(Importing a new version from external source)
(Importing a new version from external source)
Line 3: Line 3:
== Sætning af sessionsmiljøvariable ==
== Sætning af sessionsmiljøvariable ==


It is simple to set environment variables that affect your whole session. KDE will execute any script it finds in <tt>$HOME/.kde/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>
Det er enkelt at sætte miljøvariable, som påvirker hele din session. KDE vil udføre ethvert script med filendelse <tt>.sh</tt>, som den finder i <tt>$HOME/.kde/env</tt> og vil vedligeholde alle de miljøvariable, som sættes heri. Det er vigtigt, at enhver variabel, som du vil sætte også bliver ''eksporteret''. Som eksempel er PATH en miljøvariabel, som dit system har sat op med stien til de mapper, som mest sandsynligt indeholder ting, som systemet skal finde. Nu vil du tilføje endnu en mappe. Du kan se, hvad der allerede er i variablen ved at åbne [[Special:myLanguage/Konsole|Konsole]] og skrive <code> echo $PATH</code>


To add paths to your [http://en.wikipedia.org/wiki/Path_(computing) PATH], simply create a file named <tt>$HOME/.kde/env/path.sh</tt> with a contents similar to this:
To add paths to your [http://en.wikipedia.org/wiki/Path_(computing) PATH], simply create a file named <tt>$HOME/.kde/env/path.sh</tt> with a contents similar to this:

Revision as of 07:11, 8 August 2011

Sætning af sessionsmiljøvariable

Det er enkelt at sætte miljøvariable, som påvirker hele din session. KDE vil udføre ethvert script med filendelse .sh, som den finder i $HOME/.kde/env og vil vedligeholde alle de miljøvariable, som sættes heri. Det er vigtigt, at enhver variabel, som du vil sætte også bliver eksporteret. Som eksempel er PATH en miljøvariabel, som dit system har sat op med stien til de mapper, som mest sandsynligt indeholder ting, som systemet skal finde. Nu vil du tilføje endnu en mappe. Du kan se, hvad der allerede er i variablen ved at åbne Konsole og skrive 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.