chrisant996 / clink

Bash's powerful command line editing in cmd.exe
https://chrisant996.github.io/clink/
GNU General Public License v3.0
3.44k stars 135 forks source link

clink_settings file and environment variables #629

Closed ArkadiuszMichalski closed 2 months ago

ArkadiuszMichalski commented 2 months ago

It is possible to use environment variables in the clink_settings file? I need to set up some additional folders for Lua scripts and .exe files, but I want to make it portable (without using absolute paths). Currently I use Cmder+Clink and variables like %CMDER_ROOT% or %CMDER_CONFIG_DIR% are not expanded.

More specifically, I'm trying to set values ​​for:

clink.path
fzf.exe_location
chrisant996 commented 2 months ago

No.

Instead, how about making a .Lua script that loads other scripts from whenever you want?

Use the loadfile() function in Lua.

chrisant996 commented 2 months ago

For the fzf path, I'm double checking something, before I make a suggestion...

chrisant996 commented 2 months ago

The fzf.exe_location DOES expand environment variables.

I think one of the following must have happened:

  1. Maybe you specified only a directory, without the exe name. The README.md file says it has to be the full path name of the exe. I'll update the fzf.lua file to try to make it even more clear and obvious by giving an example.
  2. Maybe you set it in a way that made the environment variable get expanded before it got written into the settings file.
ArkadiuszMichalski commented 2 months ago

Ahh right, for fzf.exe_location it works, sorry for the confusion.

Instead, how about making a .Lua script that loads other scripts from whenever you want? Use the loadfile() function in Lua.

I guess I have no other option and I have to do it (except that I don't know Lua at all). I tried with the CLINK_PATH variable (as suggested here https://chrisant996.github.io/clink/clink.html#lua-scripts-location), but apparently it didn't work with the default Cmder call:

"%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" inject --quiet --profile "%CMDER_CONFIG_DIR%" --scripts "%CMDER_ROOT%\vendor"

In general, it would be useful to have a quick way to indicate additional Lua script folders, without having to modify the current code (so as not to overwrite it when updating).

Edit: finally setting CLINK_PATH works, I must have written something wrong before.

If support for variables in clink.path is not planned, the topic can be closed.

chrisant996 commented 2 months ago

Yes, setting CLINK_PATH is an even better way.