Skip to content

Instantly share code, notes, and snippets.

@ejke
Last active June 14, 2021 06:50
Show Gist options
  • Save ejke/070e84591e3ea44cb2c9c81ea725e4a8 to your computer and use it in GitHub Desktop.
Save ejke/070e84591e3ea44cb2c9c81ea725e4a8 to your computer and use it in GitHub Desktop.
Modify the ~/.bash_profile (mac) or ~/.bashrc (ubuntu) file to add some convenient shortcuts.
... other bash stuff
# ---------------
# Change bash prompt
# 1. find PS1 from file (line 60 or so)
# 2. swap it to just show current directory and $
PS1='\[\033[01;32m\]\W\[\033[00m\]\$ ' # for green text
PS1='\[\033[01;34m\]\W\[\033[00m\]\$ ' # for blue text
# ---------------
# Java APIs - shortcut to run from whereever.
# Modify based on your needs.
# Remember that there has to be no spaces around =, and to use singlequotes.
# Update the changes after save by calling `. ~/.bash_profile` in your command line.
# ---------------
# -- Name of a Java API
alias runapi='cd ~/Documents/github/JavaAPIName/webapp/ && sh gradlew -p . bootRepackage && cd ../ && java -jar webapp/build/libs/java-api-name.jar --spring.config.location=./config/ --spring.config.name=application.local --es.properties.location=file:./config/es.rest.local.properties'
# ---------------
# You can also use the aliases for anything else that needs a shortcut.
# ---------------
# -- Conda - commands I cannot remember
alias condalist='conda info --envs'
# ---------
# KILL port
alias port:='lsof -i tcp:'
alias kill='sudo kill -9 '
# --------------------------------------------------------------
# run . ~/.bash_profile to update the file and implement changes
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# Setting PATH for Python 3.8
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH
# ----------------------------------------------------------------
# Switch between java versions - needs a bit more work to get it work, find it
export JAVA_8_HOME=$(/usr/libexec/java_home -v1.8)
export JAVA_11_HOME=$(/usr/libexec/java_home -v11)
alias java8='export JAVA_HOME=$JAVA_8_HOME'
alias java11='export JAVA_HOME=$JAVA_11_HOME'
# default to Java 8
java8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment