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

WIP: Generate fish completion file #179

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

avdv
Copy link
Collaborator

@avdv avdv commented Jan 24, 2018

Fixes #163.

Description

This is a work-in-progress PR, which generates a completion file for the fish shell. Currently, it generates the following output:

complete -c colorls -s a -l all -d do\ not\ ignore\ entries\ starting\ with\ .
complete -c colorls -s A -l almost-all -d do\ not\ list\ .\ and\ ..
complete -c colorls -s l -l long -d use\ a\ long\ listing\ format
complete -c colorls -l tree -d shows\ tree\ view\ of\ the\ directory
complete -c colorls -l report -d show\ brief\ report
complete -c colorls -s 1 -d list\ one\ file\ per\ line
complete -c colorls -s d -l dirs -d show\ only\ directories
complete -c colorls -s f -l files -d show\ only\ files
complete -c colorls -l gs -l git-status -d show\ git\ status\ for\ each\ file
complete -c colorls -l sd -l sort-dirs -l group-directories-first -d sort\ directories\ first
complete -c colorls -l sf -l sort-files -d sort\ files\ first
complete -c colorls -s t -d sort\ by\ modification\ time,\ newest\ first
complete -c colorls -s U -d do\ not\ sort\;\ list\ entries\ in\ directory\ order
complete -c colorls -s S -d sort\ by\ file\ size,\ largest\ first
complete -c colorls -l sort -d sort\ by\ WORD\ instead\ of\ name:\ none,\ size\ \(-S\),\ time\ \(-t\) -x -a none\ time\ size
complete -c colorls -s r -l reverse -d reverse\ order\ while\ sorting
complete -c colorls -l light -d use\ light\ color\ scheme
complete -c colorls -l dark -d use\ dark\ color\ scheme
complete -c colorls -s h -l help -d prints\ this\ help
complete -c colorls -l version -d show\ version

In the fish shell, you only need to run source colorls.fish.

  • Relevant Issues : (none)
  • Relevant PRs : (none)
  • Type of change :
    • New feature
    • Bug fix for existing feature
    • Code quality improvement
    • Addition or Improvement of tests
    • Addition or Improvement of documentation

@demartini
Copy link

Hey guys, any progress on this pull request?

@avdv
Copy link
Collaborator Author

avdv commented Nov 20, 2020

I am not sure whether this is still the right way to go. The big goal is to have full option compatibility with GNU ls (as far as possible), so you can just do

# inherit all options from ls
complete -c colorls -w ls

# add auxiliary options only colorls supports
complete -c colorls -l git-status -l gs -d 'show git status'
complete -c colorls -l tree -d shows\ tree\ view\ of\ the\ directory
complete -c colorls -l report -d show\ brief\ report
...

@demartini
Copy link

Hello @avdv thanks for the answer!

I managed to get it working by creating the colorls.fish file in the ~/.config/fish/completions folder with the following content:

complete -c colorls -s a -l all -d "do not ignore entries starting with ."
complete -c colorls -s A -l almost-all -d "do not list . and .."
complete -c colorls -s l -l long -d "use a long listing format"
complete -c colorls -l tree -d "shows tree view of the directory"
complete -c colorls -l report -d "show brief report"
complete -c colorls -s 1 -d "list one file per line"
complete -c colorls -s d -l dirs -d "show only directories"
complete -c colorls -s f -l files -d "show only files"
complete -c colorls -l gs -l git-status -d "show git status for each file"
complete -c colorls -l sd -l sort-dirs -l group-directories-first -d "sort directories first"
complete -c colorls -l sf -l sort-files -d "sort files first"
complete -c colorls -s t -d "sort by modification time, newest first"
complete -c colorls -s U -d "do not sort; list entries in directory order"
complete -c colorls -s S -d "sort by file size, largest first"
complete -c colorls -l sort -d "sort by WORD instead of name: none, size (-S), time (-t) -x -a none time size"
complete -c colorls -s r -l reverse -d "reverse order while sorting"
complete -c colorls -l light -d "use light color scheme"
complete -c colorls -l dark -d "use dark color scheme"
complete -c colorls -s h -l help -d "prints this help"
complete -c colorls -l version -d "show version"

image

By the way, the flag -d (--description) needs to be in quotes to work properly.

@adcpe adcpe mentioned this pull request Feb 9, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto-completion for fish shell
2 participants