-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Press UP key will get last command from other tabs #2513
Comments
What kind of console window is being opened? I'll assume the default "Cmder" task, which uses Clink. What does The Clink documentation has information about Clink and how to configure it. |
Thank you very much. That is the reason. The switch is on in Cmder's initial config. |
Looks like set "shared history" doesn't fully fix the problem. Any suggestion? If I still want to persist history? |
What is it set to?
I don't understand what behavior is desired. Please explain. It almost sounds like you want each console window to save history and reload it in the future. But each new future console should only load its own history, not the history from other console windows. But how could that work? There is no way to associate a new console with a specific old console. Please explain in detail what is desired. |
Sorry for my delay. Thank you for your kind help. My previous comment only said one thing: After restart Cmder, every console window can obtain all the console's history of last run. I really mean "each console window to save history and reload it in the future" Yes, this is NO method can EXACTLY associate a new console with a specific old console. An obvious solution is don't save history. But IMHO, there is a middle ground. Cmder will save current directory for every console when exit, and restore it when restart. I think it can be a association. So maybe there is another solution:
I don't think it is a perfect solution. But I really think it is good enough. What is your option? |
Cmder does not save current directory on exit, nor does it restore anything on relaunch. Conemu a completely separate part of the Cmder package provides this functionality and it is also completely separate from Clink. Cmder is the config and init scripts that ties all this together. This is not a bug it is how it works. Nothing to fix. |
I see, you're exploring heuristics for how to approximate associating a new console with an old console. That is presupposing that Clink would keep track of many separate persisted histories, and somehow manage the storage space and lifetimes. That seems pretty complicated and expensive, and also very unpredictable and confusing. More on that below...
Which is
I think it can seem good at first look, but quickly runs into edge cases that are ambiguous and lead to complexity and confusion. Here is a major one: In that model, history is loaded from one source, and then saved to a different source. It inherently migrates history around, which leads to problems such as collisions and merging, predictability, "losing" all the history when the history "moves" to be associated with a different directory, and so on. Can you please describe the problem that it's intended to solve? I don't have a clear understanding yet of what is considered to be the problem. |
I don't think ConEmu does anything at all about history, so if you like how ConEmu works then maybe Or Again, please describe the problem, so that we have a shared understanding of what the problems and requirements are, before trying to produce an implementation. |
Thank you for your explaination. Now I think history.save=false and history.shared=false will be the final solution for me. Let me explain it. I have many console applications to run. Every application is in its own directory. Sometimes, I need to restart one of them. It's painful to look for one special console in many CMD. But Cmder can help me. At first, I open consoles in Cmder, execute CD in each console, run applications. Then Cmder will keep "current directory" for me after restarting my computer. Also, application's name is saved as history. So I can simply press UP to get command line after restart. When I have to restart one application, I switch to the tab, press CTRL-C to break it, then UP, and ENTER. Then I found all consoles share history. I thought it is a bug. With your help, I found history.shared is set to true in Cmder's initial config. After that, I found the history is still "shared" after restart. So I thought, it's better to separate each console's history. Since separating histories is hard to do, I think I can accept not to persist history. Because clink has another feature: filter exe file first when press TAB. That is also a big help. Thank you for your patience. |
@firstrose have you tried using the history search to find the command? |
Not yet. In my case, every application has its own fixed location/directory. Only one console is needed for each application, and the exe file names are also fixed. So each console's histroy should has only one item normally. Search is useless and UP for "last command" is what I need. Thank you. |
@firstrose ah! Thank you very much, that made everything clear now. I don't think that's a work environment that I would want to make Clink try to automatically deduce and support. But it would be pretty simple and safe to add an environment variable to override the name of the history file. Then it would be possible for a script to explicitly configure where each session stores its history, and it would even be possible to make multiple "Foo Task" consoles share history, and have multiple "Bar Task" consoles share different history. I think that might be significantly more flexible and powerful and more exactly fit the goals, while also being very simple to implement and also to configure. What do you think? |
Cmder provides a way to create task that runs a specific app/exe when it starts. Would that help? |
Yes. That could be used to set the history file name for the task (once Clink supports that). |
Thank you for the reply. Yes, it's a good idea. But IMHO it should be an command-line argument, not an environment variable. e.g. clink -history-file-location=.\hist.clink That will be more flexible. ======================================== There ia one more question: How to clear history ONLY for CURRENT Session? I read manual and find no clew. Thanks in advance. |
No:
This is an implementation suggestion without context. Can you describe the motivation? What problem is it trying to solve? There is not a way. Also, the question could mean several different things depending on intent and on config settings. If "session" is referring to when Please explain. Thanks! |
I found you added %CLINK_HISTORY_LABEL% But it confuses me. Because I really don't know how to enable multiple history lists by only one environment variable. Since it can be changed on fly, while all the consoles can get to know. I looked up your document and found no usage yet. Could you please give more detail in the document?
Please put it aside, before I get to know how %CLINK_HISTORY_LABEL% works. Maybe it isn't a question any more after that. Thank you very much. |
Start a console for project Foo. Start a console for project Bar. There is already something being used to launch the different consoles in different directories. Make that set the envvar, in addition to setting the directory. (Setting an environment variable in one console only affects that console, not other ones.) |
Aha! I get. No problems any more. Thank you very much. |
Just info for someone who found this issue and want to save separated histories for each console, it may help you:
|
Purpose of the issue
Version Information
210304
Win10 10.0.19042.867
Description of the issue
Open one console window in Cmder and execute some commands.
Then open one new window in Cmder, just press UP key.
You will get you last command in previous window, not this windown(new window has no history, so nothing loaded is expected).
Looks like all windows in Cmder share the same history.
This "last command" feature should not be "cross window".
I tested it on ConEmu, different window has their own history, that is right.
The text was updated successfully, but these errors were encountered: