[Mac OS X] Creating a .bash_profile on your Mac Terminal

Look & Feel of the Terminal window can be modified in two ways:

First by opening the Preferences option available under Terminal Menu --> Preferences and make modifications to the layout settings of my choice.
Other option is using a .bash_profile. When you want to run functions from your command line, this is a must-have. Following steps will create a .bash_profile under the home directory.
  1. Start up Terminal
  2. Type "cd ~/" to go to your home folder
  3. Type "touch .bash_profile" to create your new file.
  4. Edit .bash_profile with your favorite editor (or you can just type "open -e .bash_profile" to open it in TextEdit.
  5. Type d following in my .bash_profile file:

    # Make ls use colors
    export CLICOLOR=1
    alias ls='ls -Fa'

    # define colors
    C_DEFAULT="\[\033[m\]"
    C_WHITE="\[\033[1m\]"
    C_BLACK="\[\033[30m\]"
    C_RED="\[\033[31m\]"
    C_GREEN="\[\033[32m\]"
    C_YELLOW="\[\033[33m\]"
    C_BLUE="\[\033[34m\]"
    C_PURPLE="\[\033[35m\]"
    C_CYAN="\[\033[36m\]"
    C_LIGHTGRAY="\[\033[37m\]"
    C_DARKGRAY="\[\033[1;30m\]"
    C_LIGHTRED="\[\033[1;31m\]"
    C_LIGHTGREEN="\[\033[1;32m\]"
    C_LIGHTYELLOW="\[\033[1;33m\]"
    C_LIGHTBLUE="\[\033[1;34m\]"
    C_LIGHTPURPLE="\[\033[1;35m\]"
    C_LIGHTCYAN="\[\033[1;36m\]"
    C_BG_BLACK="\[\033[40m\]"
    C_BG_RED="\[\033[41m\]"
    C_BG_GREEN="\[\033[42m\]"
    C_BG_YELLOW="\[\033[43m\]"
    C_BG_BLUE="\[\033[44m\]"
    C_BG_PURPLE="\[\033[45m\]"
    C_BG_CYAN="\[\033[46m\]"
    C_BG_LIGHTGRAY="\[\033[47m\]"


    # set your prompt
    export PS1="\n$C_LIGHTGREEN\u$C_DARKGRAY@$C_BLUE\h $C_DARKGRAY: $C_LIGHTYELLOW\w\n$C_DARKGRAY\$$C_DEFAULT "
  6. Quit the terminal window, if its already open and re-launch it by clicking the "Terminal" icon in the dock.

Comments

Popular posts from this blog

How to Choose a Technology Stack for Web Application Development

[Advance Java] Difference Between Apache and Tomcat

Setting ESLint on a React Typescript project