pangeo-data / jupyter-earth

Jupyter meets the Earth: combining research use cases in geosciences with technical developments within the Jupyter and Pangeo ecosystems.
https://jupytearth.org
Creative Commons Zero v1.0 Universal
28 stars 6 forks source link

Colorizing things in our terminals #91

Closed consideRatio closed 2 years ago

consideRatio commented 2 years ago

@whyjz asked about ls --color=auto and such. I'm creating this issue to represent the wish to get things colorized in our terminals. I figure perhaps I should try upstream this directly to the pangeo base stacks to solve it for all of us in one go.

fperez commented 2 years ago

Quick note - it's fine to have a .bashrc file in your home directory, it's perfectly persisted and lets you colorize things. I'm not sure which problem @whyjz is encountering here?

I have colors in my aliases and prompt, and it all works perfectly:

image

I don't really think anything else is needed on this front - I think this issue can be closed.

whyjz commented 2 years ago

@fperez I created a .bashrc file and added a line alias ls='ls --color=auto' there, but the setting does not automatically apply to the terminal when I start a new server. See this screenshot:

bashrc

Also, did you manually set up the main environment? I thought the default conda environment is called notebook?

fperez commented 2 years ago

@whyjz you need to have the following at the end of your ~/.bash_profile:

#############################################################################
# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

By default, the terminals started by JuptyerLab are non-login shells, so they don't read .bashrc. Or you can put all your configuration into .bash_profile, it's up to you...

Also - that's a branch name (main), not a conda env name. I don't have my prompt showing the conda env, only the branch name.

whyjz commented 2 years ago

@fperez okay it worked... So I was messing up with the wrong file! These two file .bash_profile and .bashrc always confuse me... Thanks a lot!

So I think my question is solved, but I'll keep this issue open for Erik in case he has some other thoughts. (I mean, maybe it's good to have a colorized things as a default JupyterLab shell setting?)

fperez commented 2 years ago

Doing that system-wide so it's a default for all users requires editing /etc/profile, as explained here. It would be fine to have a slightly nicer default, though users will find again the "bare" ones on any other non-customized image they encounter (most).

Instead, I think we should just explain to people (not here, but in the generic user-facing docs for jhub/2i2c hubs) how to configure their setup. The only point that really needs making is the above about the two files, that same issue happens in OSX and is explained here. JLab in that regard is like OSX that all shells it opens are login shells.

Let's close this issue for now, but mentioning the config explanation in any relevant user docs is probably a good idea.