Colorize terminals even when home is overridden
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 |
|---|---|
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 |
|---|---|
Some thoughts after making this.
- Removing the
@hostnamefrom the prompt seemed reasonable, but I think it could be controversial - remove that change? - Trickery needs to be involved if the terminal title is to be retained as Terminal 1 etc, because its overridden by
/etc/skelfiles, so I think stripping those fromusername@hostname:makes sense to include in this PR. - To apply or not apply the
/etc/skel.bashrcstuff if a.bashrcfile was found or not isn't obvious. I can imagine users are happy with colors, and then unhappy after defining a.bashrcfile with some unrelated thing. Should it be applied no matter what? - Similarly as point 3, should we apply the /etc/skel stuff no matter what?
- Should we apply /etc/skel files conditionally based on some environment variable, allowing this behavior to be opt-out or opt-in?
- 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.
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'