Skip to content

Instantly share code, notes, and snippets.

@theoperatore
Last active August 26, 2023 18:53
Show Gist options
  • Save theoperatore/d685b401e01629dded816bd2af45682e to your computer and use it in GitHub Desktop.
Save theoperatore/d685b401e01629dded816bd2af45682e to your computer and use it in GitHub Desktop.
bash_profile, zshrc, and some tips for starting a new computer and installing a good env
export GITAWAREPROMPT=~/.bash/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"
PS1='\[\033[01;35m\]\u\[\033[01;33m\]:\[\033[01;34m\]\W\[\033[00;31m\]:$git_branch \[\033[00m\]> '
parse_git_branch() {
local ref=$(git symbolic-ref --short HEAD 2> /dev/null)
if [ -n "${ref}" ]; then
if [ -n "$(git status --porcelain)" ]; then
local gitstatuscolor='%F{red}'
else
local gitstatuscolor='%F{green}'
fi
echo "${gitstatuscolor} (${ref})"
else
echo ""
fi
}
setopt PROMPT_SUBST
PROMPT='%F{magenta}%n%F{none}@%F{blue}%~$(parse_git_branch) %F{none}$ '
@theoperatore
Copy link
Author

theoperatore commented Aug 26, 2023

Setting up GCP:

# use brew to install gcloud commands
brew install --cask google-cloud-sdk

# initialize cli and set account to use, select project, no need to set default compute zone
gcloud init

# log in and set up default application creds
gcloud auth application-default login

# list config settings
gcloud config list

# if needed, change default project
gcloud config set core/project <new-project-id>

@theoperatore
Copy link
Author

Setting up IntelliJ

Update /etc/hosts to improve debugging speed

# hostname from: echo -n "`hostname`.local" | pbcopy
127.0.0.1 localhost <your-machine-hostname>.local

If you have memory to spare, can give IntelliJ more memory for java apps via flag: 2048m is a good amount

Open application and go to Project Structure. Ensure sdkman jdks are listed

Using the fmt-maven-plugin is nice! uses google-java-format-plugin.

To install:

Go to IntelliJ IDEA -> Settings
Select Plugins in the list on the left
Type google-java-format in the search box 3.1. If nothing appears you could be in the Installed tab. Click on Marketplace
You should see the plugin now and when you select it you should be able to install it. You may need to enable the plugin. To enable it by default in new projects, use File > New Projects Setup > Preferences for New Projects. In the popup, select Other Settings dropdown on the left and choose google-java-format Settings. Then check Enable google-java-format.

You also need to install the IntelliJ Java Google Style file to properly fix the import order as pointed out in IntelliJ Configuring Code Style page:

Download the IntelliJ Java Google Style file.
Open Settings -> Editor -> Code Style
Click the gear (⚙) icon at the top next to Scheme: Import Scheme -> IntelliJ IDEA code style xml.
Select the XML file you downloaded in the previous step.
Click OK to import the scheme
In the scheme dropdown, select GoogleStyle
Click Apply to apply the settings

Java 17 breaks the plugin, set some settings.

Upgrade your Intellij to be at least version 2022.2 or newer (Go to menu Intellij IDEA -> Check for updates)
Add extra JVM options to your Intellij by going to Help -> Edit Custom VM Options and add the following flags to it:

--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED

You should be able to run google-java-formatter again.

@theoperatore
Copy link
Author

Use Docker for Mac

If using GCP container registery, then allow docker to pull from GCR:

gcloud auth configure-docker

@theoperatore
Copy link
Author

Use nvm for managing NodeJs versions

Use yarn for package management

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment