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

Doesn't work for example input fd . or ls -1 #18

Open
psprint opened this issue Apr 13, 2023 · 5 comments
Open

Doesn't work for example input fd . or ls -1 #18

psprint opened this issue Apr 13, 2023 · 5 comments
Labels
good first issue Good for newcomers

Comments

@psprint
Copy link

psprint commented Apr 13, 2023

HI,
when I try to use the script it seems to ignore the options. E.g.:

ls -1 | src/column_ansi.sh -R2
_config.yml    
CONTRIBUTING.md
images/        
LICENSE        
README.md      
spec/          
src/           
tests/  

How to obtain any reaction from the script? What am I doing wrong?

@LukeSavefrogs
Copy link
Owner

LukeSavefrogs commented Apr 13, 2023

when I try to use the script it seems to ignore the options

Separate options from values with a space

ls -1 | src/column_ansi.sh -R 2

Same goes for multiple options: instead of src/column_ansi.sh -tR2 write src/column_ansi.sh -t -R 2


How to obtain any reaction from the script? What am I doing wrong?

What are you trying to achieve?

The output is the same of the column one:

lsalvarani@Desktop-Luca:/mnt/d/Progetti/column_ansi$ ls -1 | src/column_ansi.sh -t -R 2
_config.yml    
CONTRIBUTING.md
images
LICENSE
README.md
spec
src
tests

lsalvarani@Desktop-Luca:/mnt/d/Progetti/column_ansi$ ls -1 | column -t -R 2
_config.yml
CONTRIBUTING.md
images
LICENSE
README.md
spec
src
tests

@LukeSavefrogs LukeSavefrogs added the good first issue Good for newcomers label Apr 13, 2023
@psprint
Copy link
Author

psprint commented Apr 13, 2023 via email

@LukeSavefrogs
Copy link
Owner

Separating option and value doesn't help:

That's what i said in the second part of my response... You're using column (column_ansi is just another version) wrong... It should be used on at least two columns to see it in action.

Don't take me as a mean person but...
What are you trying to achieve?

@psprint
Copy link
Author

psprint commented Apr 14, 2023

I'm trying to get 2 or 3 column output from ls -1 --color=always. Currently, I've tried:

ls -1 --color | column -t -R 3 | src/column_ansi.sh -R 3
ls -1 --color | column | src/column_ansi.sh -R 2
ls -1 --color | command pr -T3 | src/column_ansi.sh -R 3

and I couldn't get the desired output…

@LukeSavefrogs
Copy link
Owner

LukeSavefrogs commented Apr 14, 2023

I'm trying to get 2 or 3 column output from ls -1 --color=always. Currently, I've tried:

ls -1 --color | column -t -R 3 | src/column_ansi.sh -R 3 ls -1 --color | column | src/column_ansi.sh -R 2 ls -1 --color | command pr -T3 | src/column_ansi.sh -R 3

and I couldn't get the desired output…

Maybe you have not clear what column_ansi is for...

column_ansi is a tool designed to be a nice substitute for the column command in those environments where column does not handle colors (from my experience some work, some don't... maybe depends on the version).

It can be considered as a subset of the original column command, because supports a subset of its options and works the same (while still correctly maintaining colors).

Now...
You wrote ls -1 --color | column -t -R 3 | src/column_ansi.sh -R 3, which is wrong since we just said that basically they're the same command. You should have written one of the following:

  • ls -1 --color | column -t -R 3 to use the original column command
  • ls -1 --color | src/column_ansi.sh -R 3 to use the column_ansi command

You can see that they both provide the same output:
image

You can see the difference when there are more columns...

lsalvarani@Desktop-Luca:/mnt/d/Progetti/column_ansi$ ls -l --color
total 20
-rwxrwxrwx 1 lsalvarani lsalvarani  133 Nov 17 17:23 _config.yml    
-rwxrwxrwx 1 lsalvarani lsalvarani 1795 Nov  8 18:20 CONTRIBUTING.md
drwxrwxrwx 1 lsalvarani lsalvarani 4096 Nov  8 18:15 images
-rwxrwxrwx 1 lsalvarani lsalvarani 1092 Oct  6  2022 LICENSE        
-rwxrwxrwx 1 lsalvarani lsalvarani 9856 Apr 13 18:29 README.md      
drwxrwxrwx 1 lsalvarani lsalvarani 4096 Nov 17 17:23 spec
drwxrwxrwx 1 lsalvarani lsalvarani 4096 Nov 17 17:23 src
drwxrwxrwx 1 lsalvarani lsalvarani 4096 Nov 17 17:23 tests

lsalvarani@Desktop-Luca:/mnt/d/Progetti/column_ansi$ ls -l --color | column -t
total       20
-rwxrwxrwx  1   lsalvarani  lsalvarani  133   Nov  17  17:23  _config.yml    
-rwxrwxrwx  1   lsalvarani  lsalvarani  1795  Nov  8   18:20  CONTRIBUTING.md
drwxrwxrwx  1   lsalvarani  lsalvarani  4096  Nov  8   18:15  images
-rwxrwxrwx  1   lsalvarani  lsalvarani  1092  Oct  6   2022   LICENSE        
-rwxrwxrwx  1   lsalvarani  lsalvarani  9856  Apr  13  18:29  README.md      
drwxrwxrwx  1   lsalvarani  lsalvarani  4096  Nov  17  17:23  spec
drwxrwxrwx  1   lsalvarani  lsalvarani  4096  Nov  17  17:23  src
drwxrwxrwx  1   lsalvarani  lsalvarani  4096  Nov  17  17:23  tests

See the difference?
In the second output every word is aligned with the one in the next line...


Side note: Is this a bug?

However, when running it through the column_ansi command the output is broken for the first lines...

lsalvarani@Desktop-Luca:/mnt/d/Progetti/column_ansi$ ls -l | src/column_ansi.sh -t
total       20
-rwxrwxrwx  1   lsalvarani  lsalvarani        133  Nov  17     17:23      _config.yml
-rwxrwxrwx  1   lsalvarani  lsalvarani  1795  Nov       8      18:20      CONTRIBUTING.md
drwxrwxrwx  1   lsalvarani  lsalvarani  4096  Nov       8      18:15      images
-rwxrwxrwx  1   lsalvarani  lsalvarani  1092  Oct       6                 2022             LICENSE     
-rwxrwxrwx  1   lsalvarani  lsalvarani  9856  Apr  13   18:29  README.md
drwxrwxrwx  1   lsalvarani  lsalvarani  4096  Nov  17   17:23  spec
drwxrwxrwx  1   lsalvarani  lsalvarani  4096  Nov  17   17:23  src
drwxrwxrwx  1   lsalvarani  lsalvarani  4096  Nov  17   17:23  tests

UPDATE: Opened separate issue #19.

Conclusion

As a rule of thumb, if you don't feel that anything is wrong with column, then use that.
If instead you find that it has a strange behaviour with colors or special characters, see this or other solutions like mine.

Remember: This is not a general replacement for column!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants