Main.BashStartupScripts


Description of Bash startup and configurations files for GNU/Linux

A list of the key startup files of the bash shell:

/etc/profile

Global shell environment profile. Executed when using an interactive login shell.

/etc/bashrc

Global shell resource program. Can contain useful customizations for all logins. Source from personal .bashrc files.

/home/USERNAME/bash_profile

Personal bash environment profile for individual users. Can source local .bashrc if there is one

Example:

# .bash_profile

if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

/home/USERNAME/bashrc

Personal bash resource file for individual customizations. Should source a global /etc/bashrc if their is one, then override with specific customizations.

A large example found online, illustrating various possibilities for shell customization?:

# .bashrc

shopt -s histverify

alias ?='history'  # DISPLAYS HISTORY

# JUMP TO DIRECTORIES WITHIN MY HOME DIRECTORY
alias 0='clear;cd ~/ARCHIVES/'
alias 1='clear;cd ~/AGENDA/'
alias 2='clear;cd ~/EVENTS/'
alias 3='clear;cd ~/CORRESPONDENCE/'
alias 4='clear;cd ~/CONTACTS/'
alias 5='clear;cd ~/TEXTS/'
alias 6='clear;cd ~/IMAGES/'
alias 7='clear;cd ~/VIDEO/'
alias 8='clear;cd ~/AUDIO/'
alias 9='clear;cd ~/TRANSACTIONS/'
alias X='clear;cd ~/CODE/'

alias c='clear'  # CLEARSCREEN

alias COMPILE='gcc -W -Wall -ansi -pedantic -O3 -o'

alias EB='nano ~/.bashrc'
alias EBP='nano ~/.bash_profile'

alias h='clear; cd ~; ls -F -G'  # GOTO HOME & LIST CONTENTS

alias l='clear; ls -F -G -h -l'
alias la='clear; ls -F -G -a'
alias ll='clear; ls -@ -A -F -G -h -l'

alias p='clear; ps -a'
alias pa='clear; ps -A -a'
alias pl='clear; ps -A -l'

alias r='clear; cd /; ls -F -G'  # GOTO ROOT & LIST CONTENTS

alias u='clear; cd ..; ls -F -G'  # GO UP ONE LEVEL & LIST CONTENTS

fn_prompt_command() {

    local default="\[\033[0m\]"
    local green="\[\033[0;32m\]"
    local red="\[\033[1;31m\]"

    PS1="\[\n\]"
    PS1+="$green TIMESTAMP ::$default \[\@ \d\n\]"
    [[ $EUID == 0 ]] && PS1+="$red     LOGON :: \[\\u@\\H\n\]"  # ROOT PROMPT
    [[ $EUID != 0 ]] && PS1+="$green     LOGON ::$default \[\\u@\\H\n\]"  # DEFAULT PROMPT   
    PS1+="$green  LOCATION ::$default \[\\w\n\]"
    PS1+="$green  ARGUMENT ::$default\[ \]"
}

PROMPT_COMMAND=fn_prompt_command

export PATH="/opt/local/bin:/opt/local/sbin:${PATH}"

export MANPATH="/opt/local/share/man:${MANPATH}"

Links