Question

Is it possible to put comments in environment variables, like %PATH%, HOME, $PS1, etc., or part of them? I assume if this is possible it would be done in the same way as various scripting languages, for example in JavaScript we would use

// This is an empty line

to comment a whole line, or

This is JavaScript/*version 2.2*/. // "version 2.2" is commented out

I would like to mainly use this for the PATH variable, so if there is more than 1 file with the same name in different folders I can use 1 file sometimes and the other file other times.

Another use for this is sometimes I may not want to use a program's PATH variable but I don't want to completely uninstall it and I want to keep the PATH variable there in case I forget it later (and am too lazy to look it up). As an example, for Git Bash (msysgit) & Cygwin, if I don't want to use these programs all the time because I don't want to have my system feel like Linux all the time, one easy way to remove much of the Linux functionality is to remove that program's parts of the PATH variable, which removes the program's root folder as the system's pseudo-root folder.

I would like this to be a cross-platform solution, as I have a Windows 8.1 computer but have some Linux VM's.

Was it helpful?

Solution

I would like to mainly use this for the PATH variable, so if there is more than 1 file with the same name in different folders I can use 1 file sometimes and the other file other times.

Try putting what you want to use in front(to the left) of the old version, i.e. if you wish to use C:\current_folder instead of D:\old_folder, simply edit the path to be

C:\current_folder;D:\old_folder;

(note the order of the entries)

OTHER TIPS

You can't use * or // to comment out Environment Variables in Windows, but the above method of changing the order of paths works well. I use this method with Python variants (2 and 3).

I use a #. I am pretty that you can use anything you like which will make the path invalid!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top