croc icon indicating copy to clipboard operation
croc copied to clipboard

Truncated filenames in terminal output

Open arialdomartini opened this issue 1 year ago • 3 comments

Hey! I think croc is amazing!

A minor suggestion I have is about how it truncates file and folder names to 16 characters in the progress output when sending or receiving files, regardless of available terminal space. This can be inconvenient, particularly when transferring folders or files with names that differ only in their final characters (such as sequentially numbered files).

Upon reviewing issue #195, I incorrectly assumed that croc would utilize the maximum available terminal space to display file names.

image

It would be cool if the progress output could display more characters.

arialdomartini avatar Aug 26 '24 19:08 arialdomartini

Please submit pr!

schollz avatar Aug 26 '24 20:08 schollz

I found several places where truncation is performed:

  • https://github.com/schollz/croc/blob/main/src/utils/utils.go#L133
  • https://github.com/schollz/croc/blob/main/src/utils/utils.go#L167
  • https://github.com/schollz/croc/blob/main/src/croc/croc.go#L1731
  • https://github.com/schollz/croc/blob/main/src/croc/croc.go#L1910

I could just replace 20 with a larger number: would this work?

Alternatively, one could calculate the width of terminal with:

width, _, err := term.GetSize(int(os.Stdout.Fd()))

I'm not a Go programmer, so I'm just assuming.

arialdomartini avatar Aug 27 '24 06:08 arialdomartini

Let me know if it does work! Happy to have the PR

schollz avatar Aug 27 '24 06:08 schollz