to customize Google cloud shell, modify on of the following files:
- $HOME/.customize_environment
- $HOME/.profile
- $HOME/.bashrc
notes
- .customize_environment runs once when google shell instance boots up,
- .profile, .bashrc run once for each shell login, i.e: when a new shell opened they will run, use to customise the shell prompt or to add environments.
- if .bash_profile exists .profile, .bashrc will not executed
- when .customize_environment runs, not all parts (like npm) are available yet or not installed yet.
- it outputs it's log to /var/log/customize_environment, and touches /google/devshell/customize_environment_done
- welcome message is located in /etc/profile.d/init_help.sh
- to customise the prompt modify
PS1
(in $HOME/.bashrc or $HOME/.profile for example), override the value in /google/devshell/bashrc.google - any file outside of $HOME will be reset every on restart https://stackoverflow.com/a/67155805/12577650
- start .customize_environment with
#!/bin/sh
more details:
equivilant to:
lineNumber:white -> userName: white,bold -> (projectId):green -> currentPath:yellow,bold
explanation:
color code: \e[0;37m{{VALUE}}\e[m
\e[ : start color code
0;37m : type & color (ex: 1=bold; 37=white)
{{value}}
\e[m :close color code
values:
#: line number
\u: username
${DEVSHELL_PROJECT_ID}: google cloud project id
\w: current path
about PS1: https://linoxide.com/change-bash-prompt-variable-ps1/
colors: https://linoxide.com/change-linux-shell-prompt-with-different-colors/