colorls icon indicating copy to clipboard operation
colorls copied to clipboard

WIP: Generate fish completion file

Open avdv opened this issue 7 years ago • 3 comments

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 :
    • [x] New feature
    • [ ] Bug fix for existing feature
    • [ ] Code quality improvement
    • [ ] Addition or Improvement of tests
    • [ ] Addition or Improvement of documentation

avdv avatar Jan 24 '18 15:01 avdv

Hey guys, any progress on this pull request?

demartini avatar Nov 20 '20 02:11 demartini

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
...

avdv avatar Nov 20 '20 08:11 avdv

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.

demartini avatar Nov 20 '20 09:11 demartini