Skip to content
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

Space character in filename causes git files preview error #25

Open
vinhant opened this issue May 13, 2023 · 1 comment
Open

Space character in filename causes git files preview error #25

vinhant opened this issue May 13, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@vinhant
Copy link

vinhant commented May 13, 2023

The "git files" preview command uses {-1} which creates an issue if the filename has space characters in it. e.g. if filename is "two words" then {-1} will return words"

I tried fixing this by 1. using {2..} which skips the git status flag and 2. piping the output of "git ls-files" to sed 's/"\(.*\)"$/\1/' in order to remove the double-quotes from filenames. For example if git status is
M "two words" then the sed command will give M two words and then {2..} should give two words. Then the preview command should work because it adds its own single quote.

Other options I looked at is git ls-files -z but I don't know how to send that to fzf

@junegunn junegunn added the bug Something isn't working label Aug 9, 2023
@junegunn
Copy link
Owner

junegunn commented Apr 27, 2024

Using -z along with --read0 is the only option, but unfortunately, that disables colored output.

# Colors
git -c color.status=always status --short --no-branch | fzf --ansi

# No colors
git -c color.status=always status -z --short --no-branch | fzf --read0 --ansi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants