Duplicated installations of Clink causes profile overriding #2856
Replies: 16 comments 15 replies
-
Hi @pmsobrado I believe @chrisant996 may be able to better answer these questions, but here's my take: Firstly, as you have already seen, Cmder uses Clink and store its configuration profile in If you already have Clink running from before, injecting it again while passing the paths of Cmder profile will override your running Clink with the profile that is in the Cmder directory. In the other way around, if you completely remove the line that injects Clink, whatever you were running from before will be inherited, which as you said, contains both old history, and also doesn't include the lua script files in Cmder that sets the lambada prompt. When you only set your I should point out that we need to implement a method to detect if Clink is already injected, and if the user wants, entirely bypass our own version of Clink -- although this has not implemented yet, so you can for now do this by commenting/uncommenting the line in Now, in my opinion, you have a dilemma on your hands. Do you actually want to have separate Clink profiles, or not? Personally, I'm against having installed multiple versions of the same thing on my machine, and tend to re-use components in other projects. For example, do you really need to set vanilla Clink as startup so that it opens all the time, and only run Cmder from time to time you need? Or would you prefer to set the Clink inside Cmder as your startup, so you don't have duplicate settings & history files? Or maybe you'd prefer to set Cmder itself as AutoRun (I mean the https://github.com/cmderdev/cmder/wiki/Cmder's-shell-in-other-terminals I can understand if you want or need separate profiles. You can have multiple Cmder installations or multiple Clink installations, or a combination of both, each with their separate profile directories. I know some colleagues of mine do this to separate their work environment from their hobby environment, but I personally prefer to have a unified profile and one installation of Clink, the one inside Cmder. I personally don't use ConEmu that much. So whenever I need a shell, the So, you have two options.
In option 1, you need to either copy scripts & configurations between your profiles, or use the In option 2, you need to remove all but one Clink directory, and set that as your AutoRun. I suggest the one that resides in Cmder. If you'd like to go with option 2, please first un-set the other Clink as your AutoRun, back its configuration up, and remove/uninstall it. Then open the configuration directory of your primary Clink installation and merge your settings with it. Now, set that as your startup, while also updating other references to Clink to use the new path. I also suggest adding the installation directory of Clink to your path. For example, if you'd like to keep your existing installation of Clink, please edit I personally suggest the othe way around. Remove your existing Clink installation while moving your history to Cmder, and merging your old Clink settings file with the Cmder one found in the Personally, me and @chrisant996 are against using AutoRun, but this surely works. I don't know your particular use case, but maybe instead of AutoRun, this alternative might satisfy you: Wiki page: https://github.com/cmderdev/cmder/wiki/Seamless-Windows-Terminal-Integration |
Beta Was this translation helpful? Give feedback.
-
Cmder.demonstration.all.mp4 |
Beta Was this translation helpful? Give feedback.
-
We should be able to detect if clink is already injected and use its profile folder in place of I am looking at that now in my |
Beta Was this translation helpful? Give feedback.
-
@daxgames maybe looking at the registry key where clink writes the autorun injection? @DRSDavidSoft Thanks for the explanations! It is much more clear to me now. But for now, I think I'm gonna go with the global clink and the modified profile path in Cmder. I have clink installed and injected on the system, and for me, right now it makes more sense for cmder to use that installation, that to uninstall clink from the system and inject (in the system) a clink that is not really installed and inside a folder inside another app/program that it's also not actually installed. Probably it's a bad approach but for now, it works for me. I use both cmd and cmder depending on the task, and I don't know anything about the clink scripts functionality so for me, everything is in place now. I actually only use cmder for the looks (it's cooler than cmd) and the multiple consoles feature, since I already have "Windows subsystem for Linux" and Cygwin 😅 sorry about that! Great app anyway xD |
Beta Was this translation helpful? Give feedback.
-
@pmsobrado That's great, it's recommended to use programs that are installed globally, rather than what's inside essentially portable ones, such is Cmder. Many people use Cmder because of its looks! 😄 Besides, you should use what works best for you, for your use case. My only suggestion is to go with option 1, use your global Clink profile (that enables you to retain your global settings & history) and only use the scripts in Cmder for the added prompt when you launch it. Essentially, what you described in your original comment, when you changed the clink profile path to your global one's. Cheers! |
Beta Was this translation helpful? Give feedback.
-
There's a lot to unpack. Re: lambda prompt@pmsobrado, I'm pretty sure here is why you're experiencing the issue "no lambda prompt when I use
So, using
That is not a bug -- that is exactly how the prompt filters are meant to work, so that e.g. you can supersede the lambda prompt with clink-flex-prompt if you choose to. But, it doesn't take into account the case where someone wants Cmder's prompt filter to take precedence even though another prompt such as clink-flex-prompt is also installed (otherwise, Cmder's prompt filter would append to clink-flex-prompt, making a mess of things). The simplest thing to do as a quick solution is for @pmsobrado to change the priority number of the Cmder prompt. @DRSDavidSoft please do not make that change in the main Cmder, as that would create other problems. I'll think about how to make everything coexist in a configurable manner, and reply here again later. E.g. for now you could change the EDIT: Nope, just changing the priority numbers won't be enough. @pmsobrado, what other prompt are you using outside of Cmder? re: sharing Clink profile (history and settings) between Cmder and non-Cmder windows@pmsobrado, I think in the current versions of Cmder the simplest way to get your normal profile to be used is set the You could set it in the ConEmu environment variables section, or in the System control panel. EDIT: That might work ... but it will still load scripts from Cmder's config directory, not from your Clink profile directory. See here for details. So, depending on exactly how you have your Clink profile(s) set up, it may or may not do quite you want expect. re: clink not working in a batch script
@daxgames The only reason re: detecting whether Clink is injected
It can be approximated like this, but that will be a bit slow and I wouldn't recommend it for Cmder. Instead, if Cmder wants to make it optional whether to use the Cmder Clink profile directory or a user's own Clink profile directory, then I would suggest having a flag such as I can help with those change in Cmder if needed; if that's desired then @daxgames @DRSDavidSoft please open a separate issue/discussion for that. re: overriding
|
Beta Was this translation helpful? Give feedback.
-
@chrisant996 I was going at it in a VERY rudimentary way I was just going to:
But even that does not work because even if clink is notr injewcted it reports a value for |
Beta Was this translation helpful? Give feedback.
-
@pmsobrado just to be clear: there is currently no way to get Cmder to work entirely correctly with a non-Cmder profile for Clink. But you can get close, in a number of different ways. Here is the simplest way:NOTE: This will only work as expected if you don't have any Lua scripts in your Clink profile directory. Set
Then all cmd windows will use that profile directory. Cmder should use history and settings from there. But Cmder will still forcibly load Lua scripts from its own internal Clink profile directory at There is a bug in
|
Beta Was this translation helpful? Give feedback.
-
@chrisant996 Thank you for looking at this and I understand you have looked at this a lot today but take a look at the below and tell me if it makes sense. I believe the code in The Users can then launch The To be clear there is no lua code in Cmder that loads the scripts from the profile folder it appears that Clink does this loading entirely by itself. I have confirmed that lua code is indeed being loaded from both locations in the correct order by setting differing settings in the If I comment ALL code in the user private Edit - The below prompt was acheived by setting some settings in both files:
If the above does not make sense please let me know. |
Beta Was this translation helpful? Give feedback.
-
@chrisant996 No big hurry. I added more to the previous comment to show more of wat I was talking about. |
Beta Was this translation helpful? Give feedback.
-
@daxgames Ah, I see, thanks for investigating and explaining. I indeed inaccurately reverse-engineered the intent of the code. I would recommend adding a comment in the vendor\clink.lua code: @@ -669,3 +669,6 @@
+-- Clink loads scripts from the profile directory given to it. If there's a
+-- user config dir then Clink won't know about the default config dir, so we
+-- need to load scripts from there manually.
if clink.get_env('CMDER_USER_CONFIG') then
local cmder_config_dir = clink.get_env('CMDER_ROOT')..'/config/'
for _,lua_module in ipairs(clink.find_files(cmder_config_dir..'*.lua')) do What was particularly misleading for me was the (It would likely help readability, searchability, and maintainability if there were also a variable that meant "default config dir". If the three variables were initialized nearby each other then their purposes would be self-documenting, and then the places that repeatedly explicitly construct the default config dir could just refer to a variable. It would also help if there were a comment explaining that the intent is to use some things from the default config dir even if the user overrides it with a custom user config dir -- or if there is such a comment, then maybe I just wasn't able to find it.)
You're right, I was remembering the details incorrectly about that. What happens is Cmder uses Also, with Clink v1.0.0 and higher those lines do nothing -- everything from the external clink.lua file has been moved to happen inside the clink_dll_*.dll files, and Clink loads from both the |
Beta Was this translation helpful? Give feedback.
-
Thanks for explaining how the config dirs are meant to work in Cmder. That actually presents a further complication for trying to unify Clink profile usage inside/outside of Cmder:
To me, it looks like the way that Cmder has merged its own config dir with Clink's profile dir makes it difficult to separate them cleanly anymore, at least not without a breaking change that requires some users to rewrite how their configs work. |
Beta Was this translation helpful? Give feedback.
-
@chrisant996 Couldn't @pmsobrado just add a If not using |
Beta Was this translation helpful? Give feedback.
-
I tried setting CMDER_CONFIG_DIR in the settings like this: but it had no effect, as you can see. Maybe is because of this line on init.bat? For now, I can only make my clink history to work by manually changing the profile in the user_init.cmd, as I said before. |
Beta Was this translation helpful? Give feedback.
-
@daxgames Ah, I see. I was using Cmder 1.3.20 and 1.3.21.
@pmsobrado The
@pmsobrado Do you mean that your user_init.cmd runs (And it's safe to use |
Beta Was this translation helpful? Give feedback.
-
It wasn't as bad as it looked at first, since it loads the git config directly instead of invoking |
Beta Was this translation helpful? Give feedback.
-
Originally posted by @pmsobrado in #2800 (comment)
Beta Was this translation helpful? Give feedback.
All reactions