-
Notifications
You must be signed in to change notification settings - Fork 87
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
[Search git status] preview changed files #237
Conversation
Haven't tried out your code yet but there's already been two PRs for this that I didn't accept (yet) because I want something very specific for it. #138 I want the preview to show both the staged and non-staged changes. |
Just noticed that there were PRs here. |
Don't let the fact the other two PRs didn't get merged discourage you. It was more because the authors lost interest than this feature being impossible to work on (I hope).
|
Ok, i will check these two. |
Are you talking about being displayed together or separately? |
How about this? It preview untracked files/dirs as ordinary files/dirs, and diff new file with /dev/null, the others diff with HEAD. if string match -r '\?\?' {1} > /dev/null
_fzf_preview_file {2..}
else if string match -r 'A' {1} > /dev/null
git diff --color=always -- /dev/null {2..}
else
git diff --color=always HEAD -- {2..}
end Or split cached and uncached changes. ...
else
echo 'Unstaged'
git diff --color=always HEAD -- {2..}
echo -e '\nStaged'
git diff --color=always --cached HEAD -- {2..}
end |
If there are both staged and working tree changes, I want the preview to show both. Yeah the second one is along the lines of what I'm thinking. I guess you don't need the intermediate file to store them huh? |
Yes, no intermediate file, and add check with status (just simply string match, don't know other convenient way)? if string match -r '\?\?' {1} > /dev/null
_fzf_preview_file {2..}
else if string match -r 'A' {1} > /dev/null
git diff --color=always -- /dev/null {2..}
else
if string match -r '\S\s\S' > /dev/null
echo -e (set_color red)Unstaged
echo
git diff --color=always HEAD -- {2..}
echo
end
if string match -r '\s\s|\S\S\s' > /dev/null
echo (set_color green)Staged
echo
git diff --color=always --cached HEAD -- {2..}
end
end |
Not works with R(renamed), C(copied), T(type changed), and unmerged status. i will find out the way. |
maybe this is enough to preview |
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 for the great work so far!
git diff --color=always -- $path | ||
echo | ||
end | ||
if string match -r '\S\s\s\S|\S\S\s\S' $argv >/dev/null |
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.
sorry I know you tried to explain what you were doing but I'm still confused about this regex and the one above
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.
Maybe ^\S
also works.
No need to split |
Thanks for the updates. This week is really busy so it'll be a while before I can come back to review but just letting you know I won't forget about this |
It doesn't matter, I will always be here. |
1 similar comment
It doesn't matter, I will always be here. |
Don't worry I haven't forgotten about this, just thinking through what is the best way to make this feature simple and easy to use! |
@@ -0,0 +1,20 @@ | |||
function _fzf_preview_changed_file | |||
set -l path (string split ' ' $argv)[-1] | |||
if string match -r '^\?\?' $argv --quiet |
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.
Hi, I'm back! I've found a great way to extract the symbols without using regex--you can use git status --porcelain
. Can you update the code to use that instead? Afterwards, we'll be very close to merging
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.
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.
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.
but it still needs to regex with prefix to detect file status
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.
What I'd strongly prefer to see is something like this pattern
set file_status (command to grab the two letters of the file status)
if test file_status[0] = "A"
I think this'll be much more readable. Right now I still don't exactly know what your regexes are matching.
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.
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.
What I'd strongly prefer to see is something like this pattern
set file_status (command to grab the two letters of the file status) if test file_status[0] = "A"I think this'll be much more readable. Right now I still don't exactly know what your regexes are matching.
git status
shows with two character, when first not null, it means staged changes, while second, the unstaged.
So, \S\s\S
means unstaged and ^\S
means staged
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.
Got it, I get it now, thanks! I am fine with the logic as it is then.
And if there any other changes request? |
Nope, I'll take it from here and merge soon :) |
Thanks for working on this and especially our patience @NextAlone! Really appreciate it. You are the third person to try to PR this change in and it seems third time's the charm. Sorry I've been so busy. |
Also thanks for your work, this is such a wonderful plugin. |
1 similar comment
Also thanks for your work, this is such a wonderful plugin. |
Thank you both! This is an excellent addition to an excellent plugin |
@PatrickF1 And it is time to update |
I did update it. I'll add a gif later. Or did you mean something else? |
Just the gif,thanks for your work. |
Add a preview for the changed file