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

Can't input non ascii characters #3799

Open
5 of 10 tasks
sledgehammer999 opened this issue May 16, 2024 · 6 comments
Open
5 of 10 tasks

Can't input non ascii characters #3799

sledgehammer999 opened this issue May 16, 2024 · 6 comments
Labels

Comments

@sledgehammer999
Copy link

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.52.1 (6432f00)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

Specifically I use bash from git for windows.
OS: Win 10
Terminal:

  1. Windows Terminal (1.20.11271.0)
  2. mintty 3.7.0 (shipped with git for windows)

When I hit CTRL+T and try to input greek characters they appear in the prompt either transliterated to their equivalent ascii (eg α becomes a) or printed as the ? character.
This happens with both terminals.

Both terminals are able to print greek characters (eg ls a folder with greek filenames) and are able to take greek input in their prompts. So the issue is with fzf's prompt.

@Konfekt
Copy link
Sponsor Contributor

Konfekt commented May 17, 2024

With the same setup, non-ascii characters make Fzf quit; it's intricate

@Konfekt
Copy link
Sponsor Contributor

Konfekt commented May 17, 2024

I found out that as soon as I removed the --height option from $FZF_DEFAULT_OPTS, fzf accepts non-ascii characters in Git Bash in Windows Terminal; however I could not make fzf work at all in Git bash.

Regarding the --height option, it's unfortunately set by almost all common commands, such as Ctrl-T.
The following lines, say in .bash_profile, remove it wherever possible:

  export FZF_DEFAULT_OPTS="${FZF_DEFAULT_OPTS//--height[=[:space:]][1-9][0-9]?/ }"
  export FZF_CTRL_T_OPTS="${FZF_CTRL_T_OPTS//--height[=[:space:]][1-9][0-9]?/ }"
  export FZF_CTRL_R_OPTS="${FZF_CTRL_R_OPTS//--height[=[:space:]][1-9][0-9]?/ }"

  export FZF_ALT_C_OPTS="${FZF_DEFAULT_OPTS} --preview='tree.com //F {} | tail +3 | head -\$LINES'"

Ideally, of course, the issue with setting --height in Fzf in Git Bash itself could be fixed.

@junegunn
Copy link
Owner

You can just append --no-height at the end, because the last one wins.

export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --no-height"

@Konfekt
Copy link
Sponsor Contributor

Konfekt commented May 17, 2024

Thank you, I was not aware of it. This is more robust. Ideally, since the provided bash scripts set their own custom parameters, add a check for Git Bash, say by [ -z ${MSYSTEM+x} ] || ..., and append --no-height.

@sledgehammer999
Copy link
Author

I can confirm that --no-height works for me too. In both Windows Terminal and mintty(from git bash).
BTW echo $FZF_DEFAULT_OPTS is empty so I suppose --height is the default, right?

@Konfekt
Copy link
Sponsor Contributor

Konfekt commented May 17, 2024

Yes, you can inspect here:

https://github.com/junegunn/fzf/blob/0994d9c881f8380997b96bb0a4a7416b50bc2b0d/shell/key-bindings.bash

__fzf_defaults() {
  # $1: Prepend to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS
  # $2: Append to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS
  echo "--height ${FZF_TMUX_HEIGHT:-40%} --bind=ctrl-z:ignore $1"
  command cat "${FZF_DEFAULT_OPTS_FILE-}" 2> /dev/null
  echo "${FZF_DEFAULT_OPTS-} $2"
}


__fzf_select__() {
  FZF_DEFAULT_COMMAND=${FZF_CTRL_T_COMMAND:-} \
  FZF_DEFAULT_OPTS=$(__fzf_defaults "--reverse --walker=file,dir,follow,hidden --scheme=path" "${FZF_CTRL_T_OPTS-} -m") \

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants