Closed dddeveloperrr closed 5 years ago
Isn't the default theme set to simple
which does not use colors at all? 🤔 Just bold
& underline
?
@vladimyr I changed simple to "ocean", but it didn't make a difference, everything remained white
What is TERM
set to?
@vladimyr Sorry bro, what do you mean by TERM??
this is the content of .tldrrc file in my home directory
{
"pagesRepository": "https://github.com/tldr-pages/tldr",
"repository": "https://tldr-pages.github.io/assets/tldr.zip",
"themes": {
"simple": {
"commandName": "bold, underline",
"mainDescription": "bold",
"exampleDescription": "",
"exampleCode": "",
"exampleToken": "underline"
},
"base16": {
"commandName": "bold",
"mainDescription": "",
"exampleDescription": "green",
"exampleCode": "red",
"exampleToken": "cyan"
},
"ocean": {
"commandName": "bold, cyan",
"mainDescription": "",
"exampleDescription": "green",
"exampleCode": "cyan",
"exampleToken": "dim"
},
"inverse": {
"commandName": "bold, inverse",
"mainDescription": "inverse",
"exampleDescription": "black",
"exampleCode": "inverse",
"exampleToken": "green, bgBlack, inverse"
},
"matrix": {
"commandName": "bold",
"mainDescription": "underline",
"exampleDescription": "green, bgBlack",
"exampleCode": "green, bgBlack",
"exampleToken": "green, bold, bgBlack"
}
},
"theme": "ocean"
}
TERM
is an environment variable declaring terminal capabilities. You can check it using:
$ echo $TERM
@vladimyr this is the output of echo $TERM
xterm-256color
That is just about right, meaning that your terminal supports 256 colors. tldr-node-client
uses chalk
for terminal styling which means that either chalk
fails to detect colors are supported and prints out plain text (without color escape sequences) or your terminal emulator does not show colors for some obscure reason. In order to find out please run this command:
$ FORCE_COLOR=2 tldr tar
Using FORCE_COLOR=2
forces chalk to use 256 colors (as your terminal advertises using TERM
) and if all goes well you should see colored output.
If you still don't see any colors try this one:
$ FORCE_COLOR=2 tldr tar | cat -v
This will make cat
show color escape sequences and you should see tldr page content littered with ^[[
sequences.
@vladimyr
I used FORCE_COLOR=2 tldr tar. Didn't work. Still white output. Used FORCE_COLOR=2 tldr tar | cat -v. Got following output in white color.
^[[1m^[[4mtar^[[24m^[[22m
^[[1mArchiving utility.^[[22m
^[[1m Often combined with a compression method, such as gzip or bzip.^[[22m
^[[1m More information: .^[[22m
- Create an archive from files:
tar cf ^[[4mtarget.tar^[[24m ^[[4mfile1 file2 file3^[[24m
- Create a gzipped archive:
tar czf ^[[4mtarget.tar.gz^[[24m ^[[4mfile1 file2 file3^[[24m
- Extract a (compressed) archive into the current directory:
tar xf ^[[4msource.tar[.gz|.bz2|.xz]^[[24m
- Extract an archive into a target directory:
tar xf ^[[4msource.tar^[[24m -C ^[[4mdirectory^[[24m
- Create a compressed archive, using archive suffix to determine the compression program:
tar caf ^[[4mtarget.tar.xz^[[24m ^[[4mfile1 file2 file3^[[24m
- List the contents of a tar file:
tar tvf ^[[4msource.tar^[[24m
- Extract files matching a pattern:
tar xf ^[[4msource.tar^[[24m --wildcards ^[[4m"*.html"^[[24m
Well that is great! 🎉
It doesn't solve your problem but at least now we know for sure what is happening.
tldr
works as expected i.e. gives you colored output using chalk
but your terminal emulator for some reason refuses to render it properly. We know that because those ^[[
numberm
sequences that you got printed are terminal codes for changing background/foreground color.
With that being said I've never personally run xfce so I can't help you there apart from pointing you to their issue tracker 🤷♂
In conclusion this isn't really a problem with tldr-node-client
so I'm kindly asking you to close this issue.
PS When you paste logs and terminal outputs you should use code fences :bowtie:
Thanks bro. So I'm going to post a topic on Manjaro forum ;)
@vladimyr Hi bro, sorry for opening this issu again
I posted a topic for this problem in Manjaro forum, a guy in the forum said to me that he also gets white output when using tldr via snap. now I'm almost sure that there should be something wrong specific to snap package. ( I installed tldr from Manjaro repository and it works fine and output is colorful in xfce4-terminal)
here is my topic on majaro forum : https://forum.manjaro.org/t/tldr-doesnt-show-color-in-xfce4-terminal/108912
I think snap package of tldr needs more evaluation from your side to find out what exactly is wrong.
Peace ;)
No worries but I can't help you with snap configuration because I simply don't have required knowledge so I'm leaving it to others to chime in.
@vladimyr OK bro, thanks
Please mention the tldr-node-client version and your node version. And please provide a screenshot of what you see when you set the theme as simple/or something else.
Hello @agnivade I installed tldr via snap (sudo snap install tldr) from stable channel. its version is 3.1.0 two sceenshot is attached.
I guess there should be some issue with snap package somehow snap couldn't read the content of .tldrrc file in home directory ( sandboxing stuff). Im not sure.
@agnivade
Our snap
relies on plugin: nodejs
as stated here: https://github.com/tldr-pages/tldr-node-client/blob/master/snapcraft.yaml#L18 and because exact version of node hasn't been specified it will fallback to current LTS release: https://github.com/snapcore/snapcraft/blob/3.8/snapcraft/plugins/nodejs.py#L28-L32
Right now - that would be: https://nodejs.org/dist/latest-erbium/ i.e. v12.13.0
I don't really get how releasing to snapstore works but our stable release (which users gonna get if they don't pick edge) points to v3.1.0
as @dddeveloperrr wrote earlier.
Also kudos for @dddeveloperrr for figuring out what actually happened here. :medal_sports:
I guess there should be some issue with snap package somehow snap couldn't read the content of .tldrrc file in home directory ( sandboxing stuff). Im not sure.
I tried it using Linux Mint and GNOME Terminal and can verify that this is exact cause of described issue. If you invoke it using --theme
flag like:
$ tldr --theme=ocean tar
you'll actually get coloured output however it can't read your .tldrrc
so you can't set ocean
or any other theme as default theme.
As @dddeveloperrr said snap sandboxing gives us headaches here and in order to read config file we would need to do something along these lines: https://snapcraft.io/docs/personal-files-interface
I'm not an expert on snaps by any means but if I read this correctly this would still require users to explicitly allow that plug using this snap connect
command? :thinking:
I took a look on aws-cli
snap for example because I know they read configuration from ~/.aws/
folder.
classic
confinement which according to docs (https://snapcraft.io/docs/snap-confinement) allows apps to access home folder without explicit whitelist required by end users but also forces users to use --classic
flag when installing and resulting snap needs to be manually verified before published on snapstore.So we should probably change our confinement to classic
or stop officially supporting snap which I personally think is better decision but that is just my subjective take on it.
If you invoke it using --theme flag like:
$ tldr --theme=ocean tar
you'll actually get coloured output
Exactly ;)
Thanks @vladimyr. I have changed the confinement mode and added a note in the README.
@dddeveloperrr - Please update your snap and let us know if that fixes the issue for you. If it doesn't, you have a workaround anyways.
@agnivade 👍 but you also need to explicitly push new version to snapstore in order to propagate this change. See Publishing process section of https://snapcraft.io/docs/releasing-your-app
Oh boy, it's worse than that -
(NEEDS REVIEW) confinement 'classic' not allowed. If your snap needs classic confinement to function, please make a request for this snap to use classic by creating a new topic in the forum using the 'store-requests' category and detail the technical reasons why classic is required.
Looks like we need to revert. The README note still remains though.
Yeah it sucks but it is actually understandable from end user perspective. I'm curious did you go through whole process and got rejected or simply give up? 😀
No I got a mail when the commit was pushed saying that it failed. I opened the build dashboard and the failure reason mentioned this.
How do you feel about trying to champion it on given forum?
I don't feel interested. But please feel free to pursue it if you want.
Well I'll pass too because I'm not thrilled by whole snap thing and I'm not snap owner anyway but at least there is newly added notice in the readme that clarifies things.
@dddeveloperrr Can you help us bit more? What is it the output of following command?
$ tldr.env | grep SNAP
You should see something along these lines: https://forum.snapcraft.io/t/use-of-home-and-network-plugs/2587/11
Personally I'm of no help either, since I've executed sudo apt purge snapd
on my machine.
Personally I'm of no help either, since I've executed
sudo apt purge snapd
on my machine.
I know this is not a proper channel for having that conversation but now you made me curious 😁 You moved to flatpak or something else? Back to good old deb/rpm/pkg?
@vladimyr I use apt
. I've never liked the snap system personally, so I've removed it. Don't forget to sudo apt-mark hold snapd
too, in order to prevent it from being installed again on upgrade.
99% of Ubuntu is provided and managed via apt already, and I really don't see the benefit of having 2 package managers, amongst other reasons. apt
works perfectly fine, so why use something else?
@agnivade I installed tldr from edge channel, still white output :(
So I think I have to install tldr from Manjaro repository instead of snap.
@vladimyr this is the output of tldr.env | grep SNAP
bash: tldr.env: command not found
Yes, as you can see from this comment of mine, the classic mode is not allowed any more. So I reverted that change. You will need to install tldr using npm or use the workaround that you currently have.
@vladimyr this is the output of
tldr.env | grep SNAP
bash: tldr.env: command not found
Makes sense. How about:
# this starts `tldr` specific shell
$ snap run --shell tldr
# we need output of this one
$ env
# exit this newly started shell afterwards
$ exit
@vladimyr
LC_PAPER=en_US.UTF-8
XDG_VTNR=7
XDG_SESSION_ID=2
SSH_AGENT_PID=1455
LC_ADDRESS=en_US.UTF-8
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/farhad
LC_MONETARY=en_US.UTF-8
SNAP_USER_COMMON=/home/farhad/snap/tldr/common
VTE_VERSION=5603
TERM=xterm-256color
XDG_MENU_PREFIX=xfce-
SHELL=/bin/bash
SNAP_CONTEXT=Fm65wWGcVFtr1Tl4Cr0bDBBPtyy9lXGnj7YtVjKQP40T
TMPDIR=/tmp
GTK2_RC_FILES=/home/farhad/.gtkrc-2.0
LC_NUMERIC=en_US.UTF-8
WINDOWID=62914563
GTK_MODULES=canberra-gtk-module:canberra-gtk-module
SNAP_REEXEC=
XDG_SESSION_CLASS=user
USER=farhad
LC_TELEPHONE=en_US.UTF-8
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.pdf=00;32:*.ps=00;32:*.txt=00;32:*.patch=00;32:*.diff=00;32:*.log=00;32:*.tex=00;32:*.doc=00;32:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
PANEL_GDK_CORE_DEVICE_EVENTS=0
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
QT_AUTO_SCREEN_SCALE_FACTOR=0
SSH_AUTH_SOCK=/tmp/ssh-IHN6IsHSQzIe/agent.1454
SNAP_LIBRARY_PATH=/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void
SNAP_COMMON=/var/snap/tldr/common
SNAP_INSTANCE_NAME=tldr
SESSION_MANAGER=local/farhad-pc:@/tmp/.ICE-unix/1378,unix/farhad-pc:/tmp/.ICE-unix/1378
SNAP_USER_DATA=/home/farhad/snap/tldr/435
MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins
XDG_CONFIG_DIRS=/etc/xdg
SNAP_DATA=/var/snap/tldr/435
DESKTOP_SESSION=xfce
MAIL=/var/spool/mail/farhad
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
TEMPDIR=/tmp
QT_QPA_PLATFORMTHEME=qt5ct
LC_IDENTIFICATION=en_US.UTF-8
PWD=/home/farhad
XDG_SESSION_TYPE=x11
JAVA_HOME=/jdk-13.0.1
EDITOR=/usr/bin/nano
LANG=en_US.utf8
LC_MEASUREMENT=en_US.UTF-8
GDMSESSION=xfce
SNAP_REVISION=435
XDG_SEAT=seat0
HOME=/home/farhad/snap/tldr/435
SHLVL=2
SNAP_NAME=tldr
SNAP_COOKIE=Fm65wWGcVFtr1Tl4Cr0bDBBPtyy9lXGnj7YtVjKQP40T
XDG_SESSION_DESKTOP=xfce
LOGNAME=farhad
CLASSPATH=:/jdk-13.0.1/lib
XDG_DATA_DIRS=/home/farhad/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/usr/share
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
SNAP_ARCH=amd64
SNAP_VERSION=master
XDG_RUNTIME_DIR=/run/user/1000/snap.tldr
DISPLAY=:0.0
SNAP=/snap/tldr/435
XDG_CURRENT_DESKTOP=XFCE
LC_TIME=en_US.UTF-8
SNAP_INSTANCE_KEY=
LC_NAME=en_US.UTF-8
COLORTERM=truecolor
XAUTHORITY=/home/farhad/.Xauthority
_=/usr/bin/env
@dddeveloperrr Thanks 👍
Try creating .tldrrc
file inside SNAP_USER_DATA
directory (in your case it points to /home/farhad/snap/tldr/435
) and see if tldr
picks it up 💡
@vladimyr Oh man, unbelievable :) You made my day :) It works :)
tldr picked up color config from .tldrrc file in /home/farhad/snap/tldr/435
:)
@agnivade Hi bro, you should update readme file. @vladimyr found a workaround for this and no need to classic confinement :) @vladimyr excellent bro :+1:
Would you be willing to submit a PR for it ? :wink:
Would you be willing to submit a PR for it ? wink
@vladimyr You do this bro :)
@dddeveloperrr just curious, why do you prefer not submitting the PR yourself?
@waldyrious Because i want to give @vladimyr this honor :)) and reason number 2 is that Im not familiar with git and pull request stuff.honestly
Thanks for explaining. I think it would be a good learning experience for you, and I suspect you might find out it's not as complex as it sounds :)
If you want to give it a try, we'd be happy to guide you along the way, either here or in the Gitter chat at https://gitter.im/tldr-pages/tldr. Think about it! 😉
tldr picked up color config from .tldrrc file in
/home/farhad/snap/tldr/435
:)@agnivade Hi bro, you should update readme file. @vladimyr found a workaround for this and no need to classic confinement :)
This is snap
specific and also snap revision specific (in this case revision is 435
). If you are a snap user it is expected that you are aware of this already or you could consult snap docs instead. I'm bit reluctant of converting tldr-node-client
readme into snap
how to.
Compromise solution would be to implement --config
flag that would list config location (in this case it would point to user's snap data directory) and parsed/used key-values so users can quickly figure out where they need to put their .tldrrc
. 💡
@waldyrious Because i want to give @vladimyr this honor :)) and reason number 2 is that Im not familiar with git and pull request stuff.honestly
Well, thank you for that but list of my honors is long enough 😁 As @waldyrious already said start your own adventure if you have time. I think you'll find it fun and you'll certainly benefit from that experience.
@vladimyr @waldyrious @agnivade Please help me with the same issue all details are mentioned here. https://github.com/tldr-pages/tldr/issues/1262#issuecomment-641408820
Environment
Hello, I installed tldr via snap (sudo snap install tldr) then created a .tldrrc file in my home directory and copied content of config.json file ( from repository) into it. But it doesn't change the color of the output. everything remained in white color.
my terminal ==> xfce4-terminal
how can i fix this? thanks