Append paths to loadpath - gnuplot

Is it possible to append a path to the 'loadpath'? I know that I can do set loadpath "path1":"path2", but I want to be able to append paths in different config files.

If you want to append an existing set loadpath path1:path2:... you have to set the GNUPLOT_LIB environment variable which is always appended to the loadpath. As far as I know this is the only way to replicate the behavior you're looking for. You can debug with show loadpath.
See: http://gnuplot.sourceforge.net/gnuplot_cvs.pdf

Related

Is there a way to set "another" PATH variable?

I know that if I have a custom path CUSTOM_PATH=/some/custom/path/, then i just do export PATH=$PATH:$CUSTOM_PATH in order to have system-wide access to the executables in /some/custom/path.
But, for some complicated reasons, it would be great if I could define $CUSTOM_PATH, not append it to $PATH but still have its contents searched as if it were appended to $PATH.
This is what I mean by "another" PATH variable: a path which is searched like $PATH, but defined separately. Is there a way to do this?
Quick answer: No.
If this were possible, then it might be something like:
export CUSTOM_PATH=/usr/local/bin
export PATH='/usr/bin:/bin:$CUSTOM_PATH'
That would put the literal string "$CUSTOM_PATH" into your $PATH. You could then change the value of $CUSTOM_PATH, without touching $PATH, and implicitly update your system's search path.
But it doesn't work that way. The relevant library functions (execlp et al) treat the value of the $PATH environment variable as a colon-delimited sequence of literal directory names. It doesn't do any kind of expansion on those names.
You'll just have to update $PATH any time you want to change the system search path. (You can maintain the value of $PATH any way you like, including incorporating the values of other environment variables.)

Does anybody know where is LD_PRELOAD variable, in which file?

Just as the title said, I don't know where does this variable locate. I just know how to change it by typing:
$ export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libXpm.so.4
Then is it possible to change it in its file?
LD_PRELOAD is an environment variable (part of the "environment" defined by the C library and Unix conventions). That specific variable tells the dynamic linker how to behave.
It is probably not set to anything by default. If you want to give it a default value every time you log in or start up a shell, you can put that export statement in your .profile or .bashrc file (or whatever the equivalent is for your shell of choice). There's probably also a place you could set it in /etc that would apply to all logins or shells started on your system (if you need it to be set for other users too).
If you only need to set it for a specific program though, that may be overkill. Instead, you might want to write a short shell script to set the environment variable up first, then launch the program. E.G.:
#!/bin/bash
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libXpm.so.4
~/my_program_that_needs_a_special_library

How to store specific options for node.js CLI tool?

I'm looking for a good practice there. I need to store some global config options in my node.js command-line tool.
For example typing in bash:
$: mycommand set myGlobalOption=value
and then I can use myGlobalOption with another commands, is storing this value in environment variable a good solution?
Store this in a configuration file in the user's home directory like ~/.myprog.json. You can't store persistent data in environment variables because those ultimately come from shell configuration files like ~/.bash_profile which are not machine editable. Allowing these values to be set by environment variables is reasonable, but just have the user set them herself and don't bother trying to have a set command like you describe.
You could also just take these options as command line arguments like mycommand --myglobaloption=value and let users who want to always use the same value set up a shell alias like alias mc="mycommand --myglobaloption=value".

Can I create my own option variables

I intend to create a set of options in vimscript as flags that I can then set at runtime to change the behaviour of my script.
How can I create custom option variables, other plugins like NERDTree for example seem to be able to do it...
The set of Vim options (i.e. the stuff that you manipulate with :set) is fixed. But plugins use variables, usually named g:PluginName_OptionName or so, to get something very close to options. With the different variable scopes (g:, b:, w:), you can even achieve something like the buffer- or window-local options in Vim: This means that the plugin checks for the existence of the local variable first, and falls back to using the global variable if no local one exists.
Plugins should provide default values for their configuration variables, that can be overridden in the user's .vimrc. This is achieved by a test like this:
if ! exists('g:PluginName_ConfigItem')
let g:PluginName_ConfigItem = 'default value'
endif
If you plan to publish your plugin, be sure to document the variables and what values they can hold.

Setting Vim Options with Variables

I've a question that should be fairly simple, but I have yet to find a solution for. I'm editing my .vimrc and would like to set an option using results saved in a variable. For example, I would like to aggregate all my temporary files in ~/.vimetc. Here's what I would like to do,
let s:vimetc=$HOME.'/vimetc/'
set backupdir=s:vimetc.'backups/'
set directory=s:vimetc.'vimswap/'
set viewdir=s:vimetc.'vimswap/'
Of course, set doesn't resolve variables so I just end up with the literal |s:vimetc.'backups/'|, not at all what I would like. I tried using &s:vimetc with similar results. Does anyone know how to do this?
let &backupdir=s:vimetc.'backups/'
http://vimdoc.sourceforge.net/htmldoc/eval.html#:let-option

Resources