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

For readability, can you set auto-complete to use left-align for flag descriptions rather than right-align? #2532

Open
OwenAR opened this issue Nov 8, 2015 · 11 comments

Comments

@OwenAR
Copy link
Contributor

OwenAR commented Nov 8, 2015

It's obviously pretty hard to see what description matches up to which flag in cases like this, where some of the descriptions are a lot longer:

$ ping -
-A                                                                                               (Adaptive ping)
-a                                                                                                (Audible ping)
-B                                                        (Do not allow ping to change source address of probes)
-b                                                                           (Allow pinging a broadcast address)
-c                                                         (Stop after specified number of ECHO_REQUEST packets)
-d                                                            (Set the SO_DEBUG option on the socket being used)
-F                                                  (Allocate and set 20 bit flow label on ECHO_REQUEST packets)
-f                                                                                                  (Flood ping)
-I                                                           (Set source address to specified interface address)
-i                                              (Wait specified interval of seconds between sending each packet)
-L                                                                      (Suppress loopback of multicast packets)
-l                                              (Send the specified number of packets without waiting for reply)
-M                                                                          (Select Path MTU Discovery strategy)
-n                                                                                         (Numeric output only)
-p                                                                                 (Pad packet with empty bytes)
-Q                                                      (Set Quality of Service -related bits in ICMP datagrams)
-q                                                                                                  (Quiet mode)
-R                                                                                                (Record route)
-r                       (Bypass the normal routing tables and send directly to a host on an attached interface)
-S                                                                                      (Set socket buffer size)
-s                                                               (Specifies the number of data bytes to be sent)
-T                                                                            (Set special IP timestamp options)
-t                                                                                     (Set the IP Time to Live)
-U                                                                             (Print full user-to-user latency)
-V                                                                                    (Display version and exit)
-v                                                                                                (Verbose mode)
-W                                                                     (Time to wait for a response, in seconds)
-w  (Specify a timeout, in seconds, before ping exits regardless of how many packets have been sent or received)

Is there a setting to make them left-align rather than right-align?

(Honestly, I hate invisible whitespace and always use visible whitespace in my editor. Visible whitespace would make this somewhat less of a problem, but I have no idea if you can even get a terminal to use visible whitespace.

Left-alignment is probably still better in this case, anyway, though, right?)

@OwenAR OwenAR changed the title For readability, can you set auto-complete to use left-align for flaf descriptions rather than right-align? For readability, can you set auto-complete to use left-align for flag descriptions rather than right-align? Nov 8, 2015
@pickfire
Copy link
Contributor

pickfire commented Nov 9, 2015

I don't think so. I think this is a feature request.

@OwenAR
Copy link
Contributor Author

OwenAR commented Nov 9, 2015

Is it?

Cuz, I'm thinking maybe the default behavior should be changed to left-alignment?

(I'm not sure if there are any cases where you would actually want right-alignment?)

What do you think?

I mean, I dunno if it looks different in your browser, but for me, the auto-completion output that I quoted above is cut off so it looks like this:

   $ ping -
-A                                                                                          
-a                                                                                          
-B                                                        (Do not allow ping to change sourc
-b                                                                           (Allow pinging 
-c                                                         (Stop after specified number of E
-d                                                            (Set the SO_DEBUG option on th
-F                                                  (Allocate and set 20 bit flow label on E
-f                                                                                          
-I                                                           (Set source address to specifie
-i                                              (Wait specified interval of seconds between 
-L                                                                      (Suppress loopback o
-l                                              (Send the specified number of packets withou
-M                                                                          (Select Path MTU
-n                                                                                         (
-p                                                                                 (Pad pack
-Q                                                      (Set Quality of Service -related bit
-q                                                                                          
-R                                                                                          
-r                       (Bypass the normal routing tables and send directly to a host on an
-S                                                                                      (Set
-s                                                               (Specifies the number of da
-T                                                                            (Set special I
-t                                                                                     (Set 
-U                                                                             (Print full u
-V                                                                                    (Displ
-v                                                                                          
-W                                                                     (Time to wait for a r
-w  (Specify a timeout, in seconds, before ping exits regardless of how many packets have be

xD

@pickfire
Copy link
Contributor

pickfire commented Nov 9, 2015

@OwenAR Actually, I am not very sure about completions. I think you need to ask @faho.

@OwenAR
Copy link
Contributor Author

OwenAR commented Nov 9, 2015

Yeah I dunno. I mean, maybe right-alignment generally does make sense and this is just a weird case.

I mean, I'm not super strongly arguing that it should be changed.

I just think someone who knows more about it than I do should consider it.

@ridiculousfish
Copy link
Member

It was like this in fish 1.x; I'm not sure if we've tried another layout.

@OwenAR
Copy link
Contributor Author

OwenAR commented Nov 11, 2015

@ridiculousfish So you haven't experienced the same kind of readability problems, then?

(I mean, I'm assuming the example I posted strikes you as bad, same as it does to me?)

@pickfire
Copy link
Contributor

@OwenAR It seems like left align is a good choice too, I tried it in my terminal and it seemed too far away, but sometimes right align is better than left align. (when your terminal is small)

@OwenAR
Copy link
Contributor Author

OwenAR commented Nov 13, 2015

@pickfire How did you try it? I mean, did you edit some function? Where is it?

@pickfire
Copy link
Contributor

@OwenAR I haven't tried it.

@pickfire
Copy link
Contributor

But maybe fish could add something like -c......(completion) to make it easier to see instead of -c (completion).

@krader1961 krader1961 added this to the fish-future milestone Mar 16, 2017
@cben
Copy link
Contributor

cben commented Apr 30, 2019

The catch is that right-align allows optimizing space given some lines with long options but short description and some with short options and long description:
completing ls -TAB on a very wide terminal:

--all  -a                                                         (Show hidden)  --dired  -D                                    (Generate dired output)  --ignore-backups  -B  (Ignore files ending with ~)  --scontext  (Display only security context and file name)  -1      (List one file per line)  -t  (Sort by modification time)
--almost-all  -A                                  (Show hidden except . and ..)  --escape  -b                (Octal escapes for non graphic characters)  --inode  -i          (Print inode number of files)  --show-control-chars                  (Non graphic as-is)  -C             (List by columns)  -U                (Do not sort)
--author                                                         (Print author)  --format                                                 (List format)  --lcontext              (Display security context)  --si               (Human readable sizes, powers of 1000)  -c      (Show and sort by ctime)  -u           (Show access time)
--block-size                                                   (Set block size)  --full-time                               (Long format, full-iso time)  --literal  -N              (Print raw entry names)  --size  -s                          (Print size of files)  -f                  (Don't sort)  -v            (Sort by version)
--classify  --file-type  --indicator-style  -F  -p  (Append filetype indicator)  --group-directories-first             (Group directories before files)  --no-group  -G     (Don't print group information)  --sort                                    (Sort criteria)  -g   (Long format without owner)  -X          (Sort by extension)
--color  --color=                                                  (Use colors)  --help                                         (Display help and exit)  --numeric-uid-gid  -n   (Long format, numeric IDs)  --tabsize  -T             (Assume tab stops at each COLS)  -k        (Set blocksize to 1kB)  -x      (List entries by lines)
--context  -Z            (Display security context so it fits on most displays)  --hide  (Do not list implied entries matching specified shell pattern)  --quote-name  -Q         (Enclose entry in quotes)  --time                                   (Show time type)  -l                 (Long format)  
--dereference  --dereference-command-line  -H  -L             (Follow symlinks)  --hide-control-chars  -q     (Replace non-graphic characters with '?')  --quoting-style             (Select quoting style)  --time-style                          (Select time style)  -m      (Comma separated format)  
--dereference-command-line-symlink-to-dir                                        --human-readable  -h                            (Human readable sizes)  --recursive  -R    (List subdirectory recursively)  --version                      (Display version and exit)  -o  (Long format without groups)  
--directory  -d                           (List directories, not their content)  --ignore  -I                           (Skip entries matching pattern)  --reverse  -r                 (Reverse sort order)  --width  -w                         (Assume screen width)  -S                (Sort by size)  

There is not a single column such that everything to the left is options and everything to the right is descriptions! Some long option parts like --classify --file-type --indicator-style -F -p protrude into columns occupied by long descriptions on other lines 👍

Same thing happens in 2nd, 3rd, and 4th columns.
5th and 6th columns consist only of single-letter options where indeed it looks silly.
So left-aligning all description to single column would require overall more horizontal space in many places.

It'd be possible to preserve horizontal space by tacking each description after its options without aligning to other lines:

--all  -a   (Show hidden)
--almost-all  -A   (Show hidden except . and ..)
--author   (Print author)
--block-size   (Set block size)
--classify  --file-type  --indicator-style  -F  -p   (Append filetype indicator)
--color  --color=   (Use colors)
--context  -Z   (Display security context so it fits on most displays)
--dereference  --dereference-command-line  -H  -L   (Follow symlinks)
--dereference-command-line-symlink-to-dir
--directory  -d   (List directories, not their content)

That's easier to read individually then wide gaps like

--all  -a                                                         (Show hidden)

but maybe less "pretty" and may be harder to take in the general layout at a sight?
I don't really know how to decide this.
(Remember though that options and descriptions differ by color, lost here.)

An easy way to experiment with how visible whitespace would look is passing current completion output through sed --regexp-extended -e 's/( +)\(/'(tput smul)'\1'(tput rmul)'(/g' (again, lost color):
Ekrankopio de 2019-04-30 13-07-57

Another time-honored way (in --help output and man pages) to align descriptions AND preserve horizontal space is let long options stand on their own line, paying with some vertical space:

  -h, --human-readable       with -l and -s, print sizes like 1K 234M 2G etc.
      --si                   likewise, but use powers of 1000 not 1024
  -H, --dereference-command-line
                             follow symbolic links listed on the command line
      --dereference-command-line-symlink-to-dir
                             follow each command line symbolic link
                               that points to a directory
      --hide=PATTERN         do not list implied entries matching shell PATTERN
                               (overridden by -a or -A)

I'm concerned though that in completion output, this style would be confusing between options that are simply undocumented and options that are documented on next line.

[BTW, --dereference-command-line-symlink-to-dir showing as undocumented in current completion output looks like a bug, caused by it being documented on next line in --help output?
If true, we're not seeing the full variance of option+description lengths due to worst cases losing the description.]

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

6 participants