-
-
Notifications
You must be signed in to change notification settings - Fork 26k
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
history substring search plugin from fizsh #215
Conversation
I have found a very annoying bug. Newline, tab and other special characters are not escaped.
When I hit key up to go back in history, the output is wrong.
While this is a benign example, this behaviour can result in many syntax errors and head scratching. |
Thanks for your report! I forwarded it to Guido van Steen, the author of the history plugin. |
@sorin-ionescu did Guido van Steen respond to your bug report? |
Since he hasn't replied to this issue, I presume not. |
I have figured it out. I'll use the following code as an example.
It gets stored as is in
This plugin retrieves the line above using The solution to this bug is to use a different method to retrieve history. |
Good find! I noticed that Ctrl-R (bck-i-search) does not suffer from this problem. |
@sorin-ionescu, I changed the retrieval mechanism to index the |
I did that too about two hours ago. After I found the You can delete the comment on line 89. That said, I don't know what are |
I'm glad we arrived at the same solution. I also don't know why Guido chose |
Yes, I have noticed that he doesn't respond to email, which prompted me to read the code and fix the problem myself. I have not looked at the code in detail beyond the necessary lines to fix the history retrieval bug, but I have noticed that there is massive duplication that should be refactored. I have created a repository at zsh-history-substring-search for you to fork, make changes, and submit pull requests. I have already made a couple of changes. |
This seems to be working well for me. Any reason it's not getting pulled? |
Thanks guys for this pull request, just tested it and it is really nice, I like the zsh up-history but I was "dreaming" about something closer to ctrl+R, great! :) Would love to see that merged in master! |
@vguerci: I use vi key bindings. So, I'm not familiar with CTRL+R. Do you care to elaborate? @sunaku: Sync this pull request with zsh-history-substring-search please. |
@sorin-ionescu |
@sorin-ionescu I looked at your repo and pulled in the relevant changes in commit 5f9418363add4589d93c6729a8beeba026422985. I am refactoring the code duplication now. |
I'm finished with refactoring and am quite happy with the resulting code now. Enjoy! :] |
I'll look at your changes. One thing I did was to rename it to the more descriptive history-substring-search since ZSH already has history search. |
Done, renamed the plugin according to your preference. |
Merged on my local branch, looks like working perfectly, good job. Just found a small visual glitch, which I presume comes from original version, highlights stays even if command is deleted/edited, it reappears on newly entered command. |
@sunaku Can you do a pull request on my zsh-history-substring-search repository for me to test it? Thank you. |
@vguerci, fixed by always calling |
Alright Sorin, after a lot of work, I have a disjoint fork of your repository. (Note that I previously had my own repo with the same name so GitHub didn't let me fork yours until I deleted mine.) Cheers. |
Phew! Finally got this pull request synced with OMZ master and my disjoint fork created for Sorin. No more rebasing for today, I hope! :] |
You removed the symlink, which screwed the merge up. I merged it. I'll test it over the next few days. So far, I noticed that colour highlighting doesn't work. |
Sorin, I didn't remove the symlink: rather, the symlink never existed in my fork's history in the first place. That's what I meant by "disjoint". I don't see any issues with syntax coloring, everything seems normal. Try my OMZ fork's personal or history branch for example. |
You have renamed the variables, which were called |
It doesn't seem to be conflicting with zsh-syntax-highlighting. At the end of the |
That line applies a highlight (specified by |
I was saying that the variable |
Hmm, squashing all commits eh? That would create two copies of the code (one without adequate history, due to squashing) that could go out of sync. I wonder if we should keep this plugin separate from OMZ, just like the zsh-syntax-highlighting plugin is? |
Is the history relevant for the initial commit? It's up to you if you want it independent. Right now, it is independent. |
You're right. I think I would prefer it to be independent, because there is a long turn-around time for getting pull requests merged into OMZ and we wouldn't want to bother you guys every time there are changes in this plugin. So I'm going to close this pull request. Guido, do you approve? |
Independent development doesn't mean no pull requests. It just means that OMZ doesn't need to know the entire history of the plugin between pull requests, only that the version has been bumped in a squashed commit. |
Alright, I have prepared the single, giant squashed commit for merging into OMZ as you requested. |
If possible I would like to keep the history as well. I guess the previous commits can still be found in your upstream repository!? |
Yes, that is correct Guido. |
@robbyrussell, let's get this merged. |
This looks really great. But just a question, wouldn't it be more convenient to keep this plugin as a git submodule? This way the history is kept and it's easy to upgrade to any version/fork/branch of the module. |
@ColinHebert, no it would not be convenient. Submodules are complicated and @sunaku is |
LOL well said, sir! That made my day! :-) |
Why have you renamed the functions to |
@sorin-ionescu: This change has been discussed before. We have renamed |
I have thought about it one more time. @sorin-ionescu: You say that reverting the name change would make things consistent with oh-my-zsh. The argument that the name change makes the script inconsistent with the current state of zsh would have been more convincing to me. Also, please refrain from using blunt imperatives, when addressing other people. That is etiquette too! |
+1 |
I prefer the current up & down naming. It makes the implementation easier to understand. |
I have looked at the implementation. I agree with Sunaku: the names up and down make things easier to understand. IMO the up and down naming is quite defensible as well, because the widget is not exclusively intended for history-searches. |
I have done a listing of functions that contain the words backward/forward and up/down for reference.
|
history-substring-search is a compound widget. It performs both history-searching and line-editing. That is why it is impossible to apply Zsh's naming conventions in a consistent way anyway. The widget is modeled after Fish, where it is bound to |
history substring search plugin from fizsh
Merged this... let's update the Plugins wiki page accordingly. Am trusting @sorin-ionescu's judgement on this one |
@robbyrussell - It got put in the root of the oh-my-zsh project and not in the plugin directory |
@dreur is correct. That was my fault: when I squeezed all the commits together, I forgot to move the files into the plugins subdir. |
@@ -0,0 +1,12 @@ | |||
# This file integrates the history-substring-search script into oh-my-zsh. | |||
|
|||
source "$ZSH/plugins/history-substring-search/history-substring-search.zsh" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source "${0:h}/history-substring-search.zsh"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity: Is the version included in oh-my-zsh the same as the main one being developed at https://github.com/zsh-users/zsh-history-substring-search?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better:
source "${0:r:r}.zsh"
Memorise:
:e --> extension
:h --> head (dirname)
:t --> tail (basename)
:r --> rest (extension removed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Sorin, your change is applied at zsh-users/zsh-history-substring-search@9d3683b.
I'm having a lot of hard time going up a line in multi-line commands. Sometimes, it works, but the majority of time, it does not but goes back in history. |
I have not noticed any problems with editing multi-line commands On Sun, Sep 4, 2011 at 7:17 PM, sorin-ionescu
|
@sorin-ionescu maybe same issue : zsh-users/zsh-history-substring-search#2 |
This commit imports the history substring search script (which
adds Fish shell like history search to ZSH) from fizsh-1.0.1 as an oh-my-zsh plugin.