Sunday, June 16, 2013

Terminal: set command line prompt and PATH variables in Bash ~/.profile

As a developer you will find yourself using Command Line (Terminal.app) every day, all the time, so it is worthwhile to set it up to behave just right for you...

Open Application > Utilities > Terminal.app (drag it to your toolbar for quick access)

My shell looks like that, it tells me a lot of info just as verification...

Last login: Mon Sep 15 11:56:15 on ttys000
edit ~/.profile
java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b05)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b05, mixed mode)
git version 1.9.0
/Applications/Android/SDK/android-sdk-macosx/platform-tools/adb
uki@ CNH_PROD $ vi ~/.profile


We can use vi editor, but on daily basis I just type "edit ~/.profile"

# ANDROID - updated: Sept 15, 2014
export ANDROID_HOME=/Applications/Android/SDK/android-sdk-macosx
export PATH=${PATH}:${ANDROID_HOME}/build-tools/19.0.3
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:${ANDROID_HOME}/tools

echo "edit ~/.profile"
# Adjust prompt.
# \d – Current date
# \t – Current time
# \h – Host name
# \# – Command number
# \u – User name
# \W – Current working directory (ie: Desktop/)
# \w – Current working directory, full path (ie: /Users/Admin/Desktop)
export PS1="\u@ \W $ "
java -version
git version
which adb


To EDIT hit "i" for insert
To Save and Quit you type ESC + :wq + Enter
I have MUCH MORE configurations in there, but it is specific to what you have on your computer.