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

ZSH .gem/ruby/2.4.0/gems/colorls-1.0.9/lib/tab_complete.sh:4: command not found: complete #149

Closed
1 task done
disque-monde opened this issue Oct 30, 2017 · 10 comments
Closed
1 task done

Comments

@disque-monde
Copy link

disque-monde commented Oct 30, 2017

Description

  • Bug in existing feature

Zsh error after write
source $(dirname $(gem which colorls))/tab_complete.sh
in my .zshrc on Arch Linux

Thanks

@athityakumar
Copy link
Owner

Arch Linux doesn't offer complete function for tab completion. Rather, compadd is supported. (Source)

  # Sample tab completion script for Arch Linux

  zle -C colorls .complete-word colorls_completion 
  bindkey '^x^i' colorls
  
  # define the function that will be called
  colorls_completion() {
    compadd $(colorls --'*'-completion-bash="$2" )
  }

@avdv
Copy link
Collaborator

avdv commented Nov 7, 2017

You can use bash completion scripts with ZSH this way:

autoload bashcompinit
bashcompinit
source $(dirname $(gem which colorls))/tab_complete.sh

@avdv
Copy link
Collaborator

avdv commented Nov 8, 2017

Even better, you can have optparse generate a ZSH completion script for you:

colorls --'*'-completion-zsh=colorls >| $HOME/.completions/_colorls

Note: the $HOME/.completions directory needs to be added to the fpath array, like this:

# ~/.zshenv
fpath+=( $HOME/.completions )

This way, you get nice options completion looking like this:

% colorls -<TAB>
 -- option --
-1                                            -- list one file per line                                                                          
--all                      -a                 -- do not ignore entries starting with .                                                           
--almost-all               -A                 -- do not list . and ..                                                                            
--dark                                        -- use dark color scheme                                                                           
--dirs                     -d                 -- show only directories                                                                           
--files                    -f                 -- show only files                                                                                 
--git-status               --gs               -- show git status for each file                                                                   
--group-directories-first  --sort-dirs  --sd  -- sort directories first                                                                          
--help                     -h                 -- prints this help                                                                                
--light                                       -- use light color scheme                                                                          
--long                     -l                 -- use a long listing format                                                                       
--report                   -r                 -- show brief report                                                                               
--sort-files               --sf               -- sort files first                                                                                
--tree                     -t                 -- shows tree view of the directory                                                                
--version                                     -- show version                                                                                    

@avdv
Copy link
Collaborator

avdv commented Nov 9, 2017

@athityakumar Is it possible to generate the _colorls file automatically using the gemspec, ie. when running gem install colorls?

@athityakumar
Copy link
Owner

@avdv - Nope, rubygems doesn't have the feature of doing anything automatically upon gem install-ing a gem, except displaying the POST_INSTALL_MESSAGE. I think we could rather add support for colorls --setup command. Such a setup flag would also help in generating the man pages as required in issue #80.

@avdv
Copy link
Collaborator

avdv commented Nov 9, 2017

How about this:

  files = `git ls-files -z`.split("\x0").reject do |f|
    f.match(%r{^(test|spec|features)/})
  end

  File.open('lib/_colorls', 'w') { |f| f.puts `exe/colorls '--*-completion-zsh=colorls'` }

  spec.files         = files << 'lib/_colorls'

@athityakumar
Copy link
Owner

@avdv - I've merged PR #160, but I'm not able to get the ZSH auto-complete like you've posted above. I've updateded the fpath in the zshenv. Are there any missing intermediate steps?

Maybe describing this in the README would be better?

@avdv
Copy link
Collaborator

avdv commented Nov 23, 2017

You should add it to the .zshrc as the README says. And - as with any completion functions in Zsh - you need to add this line before calling compinit.

@avdv
Copy link
Collaborator

avdv commented Jan 31, 2018

Since #160 is merged and released in 1.1.0, this should be closed.

@athityakumar
Copy link
Owner

Gotcha! 👍

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

No branches or pull requests

3 participants