Closed mcmikemn closed 4 weeks ago
Here's the ls -al
for comparison`:
-rw-r--r-- 1 mike mike 43 Nov 20 2023 .smbcredentials
drwxr-xr-x 3 mike mike 4096 Feb 26 2018 Steam
lrwxrwxrwx 1 mike mike 29 Jun 28 2023 .steampath -> /home/mike/.steam/sdk32/steam
No, you did nothing wrong. This is a limitation of the way I am replacing the variables. The way I handle it is very simple text replacement, which can be problematic with some variables "inside" other variables. Meaning the color codes in {.isdir:{red}{name}{/color}}
are not handled properly. To avoid this problem, you either do not use colors or you can define them outside, like in {red}{.isdir:{name}}{/color}
.
I'm not sure how to handle that better without making it too complicated and introduce more edge cases that do not work. EDIT: I could look into the regular expressions that are used in the source code or in the order when stuff is replaced. Until a better way is found, the only solution for you right now would be to just use the color codes outside of the variable.
Another EDIT: The updated command would look like this:
\ls -a1 | fpath -a -s blue -F'{red}{.mode}{/color}{white}\t{owner} / {group}\t{.size}\t{.mtime:%Y-%m-%d}\t{.isreg:{name}}{red}{.islink:{name}}{/color}{blue}{.isdir:{name}}{/color}'
The backslash in front of \ls
tells Bash to run the original ls command, not an alias. I trapped into it, as my ls is aliased to eza
, which is not 100% compatible. Also generally speaking parsing out ls command is not the most secure way. Maybe use find
instead (however it lists "." as well):
find -maxdepth 1 | sort | fpath -a -s blue -F'{red}{.mode}{/color}{white}\t{owner} / {group}\t{.size}\t{.mtime:%Y-%m-%d}\t{.isreg:{name}}{red}{.islink:{name}}{/color}{blue}{.isdir:{name}}{/color}'
That makes sense. Thanks, @thingsiplay.
Closing as not planned, because this is a limitation of the system I am using.
When I run
ls -a1 | fpath -a -s blue -F'{red}{.mode}{/color}{white}\t{owner} / {group}\t{.size}\t{.mtime:%Y-%m-%d}\t{.isreg:{name}}{.islink:{red}{name}{/color}}{.isdir:{blue}{name}{/color}}'
I get:The result is colored appropriately and the
{.isreg}
command seems to work, but the{.islink}
and{.isdir}
commands are being displayed and their contents, which should only be conditionally displayed, are always displayed.Do I have the syntax wrong?