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

bat - filename completion script issue with init_completion error #2066

Closed
maximillianus opened this issue Feb 8, 2022 · 7 comments
Closed
Labels
bug Something isn't working

Comments

@maximillianus
Copy link

maximillianus commented Feb 8, 2022

When I try to do autocomplete for the filename when using bat, I encounter init_completion issue. This happens in iTerm2. Strangely, in my regular terminal, it works fine. It happens the same to my regular terminal.

Let's say I am trying to use bat to check package.json.

This is what comes up after I click after typing bat pac

bat pac-bash: _init_completion: command not found

...

I would expect filename auto completion works fine in iTerm2 as it does in regular terminal.

...

I install bat using homebrew and using it on iTerm2.

iTerm version: iTerm2 Build 3.4.15


#### Software version

bat 0.19.0

#### Operating system

Mac OS X 10.15.7 (Darwin 19.6.0)

#### Command-line

```bash
bat -pp --diagnostic

Environment variables

SHELL=/bin/bash
PAGER=<not set>
LESS=<not set>
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
BAT_PAGER=<not set>
BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
XDG_CONFIG_HOME=<not set>
XDG_CACHE_HOME=<not set>
COLORTERM=truecolor
NO_COLOR=<not set>
MANPAGER=<not set>

Config file

Could not read contents of '/Users/apradana/.config/bat/config': No such file or directory (os error 2).

Compile time information

  • Profile: release
  • Target triple: x86_64-apple-darwin
  • Family: unix
  • OS: macos
  • Architecture: x86_64
  • Pointer width: 64
  • Endian: little
  • CPU features: fxsr,sse,sse2,sse3,ssse3
  • Host: x86_64-apple-darwin

Less version

> less --version
less 487 (POSIX regular expressions)
Copyright (C) 1984-2016  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Homepage: http://www.greenwoodsoftware.com/less
@maximillianus maximillianus added the bug Something isn't working label Feb 8, 2022
@myobie
Copy link

myobie commented Feb 16, 2022

Just in case anyone sees this and doesn't click through to the linked PR, I found out I had bash-completion version 1.3 installed and bat is expecting 2.

I use homebrew, so I uninstalled bash-completion installed the formula bash-completion@2 and that works fine. If you use another installation method, then maybe check your bash-completion version and upgrade if you can. If the linked PR lands, then it should work with both versions in the future.

@maximillianus
Copy link
Author

Thanks @myobie . This works for me. I uninstalled my bash-competion and installed bash-completion@2. Then I spawn a new terminal window and it works. It doesn't work when I immediately in the current terminal window, but that's minor.

@Enselic
Copy link
Collaborator

Enselic commented Mar 3, 2022

Closed by #2074

@Enselic Enselic closed this as completed Mar 3, 2022
@polarweasel
Copy link

polarweasel commented Mar 3, 2022

@Enselic Are you sure you wanted to close this one? I'm suddenly getting a very similar behaviour from bat 0.20.0 (homebrew install on macOS 12.2):

Attempting to show the contents of .bash_profile, hit tab after typing bat .bash_p and I get:

$ bat .bash_p-bash: _split_longopt: command not found
-bash: _filedir: command not found

(Edit to add: I already had bash-completion@2 installed.)

@Enselic
Copy link
Collaborator

Enselic commented Mar 4, 2022

Thank you for reporting. Why call it "very similar" though? Looks like a different issue.

Would be great if you or someone else can reproduce this on another machine. If so, it would be great if you could report it as a separate issue.

@polarweasel
Copy link

polarweasel commented Apr 5, 2022

Thank you for reporting. Why call it "very similar" though? Looks like a different issue.

Would be great if you or someone else can reproduce this on another machine. If so, it would be great if you could report it as a separate issue.

Filed #2147 for this related issue, as I believe it was the fix that introduced my issue.

@quinncomendant
Copy link

quinncomendant commented Nov 2, 2023

Just in case anyone sees this and doesn't click through to the linked PR, I found out I had bash-completion version 1.3 installed and bat is expecting 2.

For anyone else coming to this issue: replacing bash-completion with bash-completion@2 does solve the errors, but keep in mind bash-completion@2 requires bash version 4. If you use bash 3 (the default on even the latest macOS), you can't use bash-completion@2, which means you can't use bash completions at all for bat. So, just remove it (i.e., rm /opt/homebrew/etc/bash_completion.d/bat). (Yes, I know I can upgrade to bash 4 easily; I use bash 3 because I want to write and test scripts for use on other macOS computers that still use bash 3.)

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

5 participants