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

Colorize terminals even when home is overridden #575

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

consideRatio
Copy link
Member

@consideRatio consideRatio commented Aug 21, 2024

Fixes #574.

The first commit accomplishes this when this image is used in for example JupyterHub deployments where the home folder is overridden and doesn't come with /etc/skel copied files .profile and .bashrc:

Before After
image image

This PR is also bundled with an opinionated change in another a second commit. It makes an opinionated adjustment of the terminal title and prompt. The title is set to the current working directory of the terminal, and the prompt is slimmed to not include the @hostname part.

Before After
image image

Copy link
Contributor

Binder 👈 Try on Mybinder.org!

@consideRatio
Copy link
Member Author

consideRatio commented Aug 22, 2024

Some thoughts after making this.

  1. Removing the @hostname from the prompt seemed reasonable, but I think it could be controversial - remove that change?
  2. Trickery needs to be involved if the terminal title is to be retained as Terminal 1 etc, because its overridden by /etc/skel files, so I think stripping those from username@hostname: makes sense to include in this PR.
  3. To apply or not apply the /etc/skel.bashrc stuff if a .bashrc file was found or not isn't obvious. I can imagine users are happy with colors, and then unhappy after defining a .bashrc file with some unrelated thing. Should it be applied no matter what?
  4. Similarly as point 3, should we apply the /etc/skel stuff no matter what?
  5. Should we apply /etc/skel files conditionally based on some environment variable, allowing this behavior to be opt-out or opt-in?
  6. The current form of changes is quite conservative, not doing stuff if files are found in the home dir - so maybe leaving things as the PR is ok as a starting point? At the same time... the colorizing of terminals becomes fragile, making people end up in a rabbit hole to figure out why its colored for one person but not another or similar.

@scottyhq
Copy link
Member

scottyhq commented Sep 5, 2024

Sorry to have missed this @consideRatio ! Agreed colors are nice and this is better than the default! I don't really have a strong preferences regarding your questions, but an alternative is maybe just pointing to 2i2c docs to customize the terminal (since hubs might use custom images not coming from here)?

For what it's worth I've gotten quite used to copy and paste from stack overflow into ~/.bashrc whenever I log into a jupyterhub and don't find it too onerous :)

# Colors and prompt customization
# https://unix.stackexchange.com/questions/148/colorizing-your-terminal-and-shell-environment
PS1='\e[34;1m\u@\h: \e[36m\W\e[0m\$ '

#export LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33'
LS_COLORS=$LS_COLORS:'di=1;35:' ; export LS_COLORS
export LS_OPTIONS='--color=auto'
alias ls='ls $LS_OPTIONS' 

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

Successfully merging this pull request may close these issues.

Terminal colors etc -- adjust to missing /etc/skel files in user's home dir (.profile, .bashrc, .bash_logout)?
2 participants