my bash profile

April 04 2018 16:00:44.

My .bash_profile on a mac:


# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi

# ir root has been installed with brew
# if [ -f $(brew --prefix root)/libexec/thisroot.sh ]; then
# . $(brew --prefix root)/libexec/thisroot.sh
# fi

#export ROOTSYS=/Users/carlo/Software/root-v6-02-build
# export ROOTSYS=/Users/carlo/Software/root-install/
# . $ROOTSYS/bin/thisroot.sh
. /usr/local/opt/root/bin/thisroot.sh

if [ -f ~/.bash_completion ]; then
. ~/.bash_completion
fi
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

# set PATH so it includes user's private bin if it exists
if [ -d ~/.bin ] ; then
PATH=~/.bin:"${PATH}"
fi
#PATH=/opt/local/bin
export PATH=/usr/local/bin:/opt/X11/bin:$PATH

#export DYLD_LIBRARY_PATH=/usr/local/Cellar/gfortran/4.8.0/gfortran/lib/:$DYLD_LIBRARY_PATH
#export LIBRARY_PATH=/usr/local/Cellar/gfortran/4.8.0/gfortran/lib/

#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/Users/carlo/workdir/FileConverter

CUDA_HOME=/usr/local/cuda
if [ -d $CUDA_HOME ] ; then
# export PATH=/Developer/NVIDIA/CUDA-5.0/bin:$PATH
# export DYLD_LIBRARY_PATH=/Developer/NVIDIA/CUDA-5.0/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:$CUDA_HOME/lib"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CUDA_HOME/lib"
export PATH="$CUDA_HOME/bin:$PATH"
fi

if [ -d /Users/carlo/Software/flukagfor_mac_2015.1 ] ; then
# export FLUPRO=/Users/carlo/workdir/flukamacgfor
export FLUPRO=/Users/carlo/Software/flukagfor_mac_2015.1
export FLUKA=$FLUPRO
export FLUFOR=gfortran
fi

if [ -d ~/Software/flair ] ; then
export PATH=~/Software/flair:$PATH
fi

alias cd..='cd ..'
alias ls='ls -GF'
alias ll='ls -ltrh'
# alias emacs='emacs -nw'
alias gcc='gcc-7'
export PATH

function Emacs()
{
# se il numero di argomenti e' > 0
if [ "$#" -gt 0 ]
then
FILE=${!#}
#se il file non esiste
if [ ! -f "$FILE" ]
then
echo "The file $FILE doesn't exist. Do you want to create it? (y or n)"
read answer
if [[ "$answer" == "y" ]]
then
touch $FILE
else
return
fi
fi
echo "${@}"
# open -a /usr/local/opt/emacs/Emacs ${@}
/usr/local/opt/emacs/bin/emacs ${@} &
else
# open -a /usr/local/opt/emacs/Emacs
/usr/local/opt/emacs/bin/emacs ${@} &
fi
}
function gzless()
{
gzip -cd $1 | less ;
}

function vlc()
{
if [ -n "$1" ]
then
open -a 'Vlc' $1 ;
else
open -a 'Vlc' ;
fi
}
alias Rg='open -a R .'
export PS1='[\[\033[01;32m\]\u@\h:\[\033[34m\]\w\[\033[0m\]]\$ '
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups

export PATH=/opt/local/bin:/opt/local/sbin:$PATH

alias root='root -l'

alias ejectall='osascript -e ‘tell application “Finder” to eject (every disk whose ejectable is true)’'
if [ -d /opt/pgi ] ; then
PGI=/opt/pgi; export PGI
PATH=/opt/pgi/osx86-64/13.2/bin:$PATH; export PATH
MANPATH=$MANPATH:/opt/pgi/osx86-64/13.2/man; export MANPATH
LM_LICENSE_FILE=$LM_LICENSE_FILE:/opt/pgi/license.dat;export LM_LICENSE_FILE
fi

##
# Your previous /Users/carlo/.bash_profile file was backed up as /Users/carlo/.bash_profile.macports-saved_2013-04-29_at_18:18:51
##


# spotlight: Search for a file using MacOS Spotlight's metadata
# -----------------------------------------------------------
spotlight () { mdfind "kMDItemDisplayName == '$@'wc"; }

# ttop: Recommended 'top' invocation to minimize resources
# ------------------------------------------------------------
# Taken from this macosxhints article
# http://www.macosxhints.com/article.php?story=20060816123853639
# ------------------------------------------------------------
alias ttop="top -R -F -s 10 -o rsize"

# findPid: find out the pid of a specified process
# -----------------------------------------------------
# Note that the command name can be specified via a regex
# E.g. findPid '/d$/' finds pids of all processes with names ending in 'd'
# Without the 'sudo' it will only find processes of the current user
# -----------------------------------------------------
findPid () { lsof -t -c "$@" ; }

# extract: Extract most know archives with one command
# ---------------------------------------------------------
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}

# zipf: To create a ZIP archive of a folder
zipf () { zip -r "$1".zip "$1" ; }

# mans: Search manpage given in agument '1' for term given in argument '2' (case insensitive)
# displays paginated result with colored search terms and two lines surrounding each hit. Example: mans mplayer codec
# --------------------------------------------------------------------
mans () {
man $1 | grep -iC2 --color=always $2 | less
}

# lr: Full Recursive Directory Listing
# ------------------------------------------
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less'

# trash: Moves a file to the MacOS trash
trash () { command mv "$@" ~/.Trash ; }

alias myip='curl ip.appspot.com' # myIP: Public facing IP Address

# ii: display useful host related informaton
# -------------------------------------------------------------------
ii() {
echo -e "\nYou are logged on ${RED}$HOST"
echo -e "\nAdditionnal information:$NC " ; uname -a
echo -e "\n${RED}Users logged on:$NC " ; w -h
echo -e "\n${RED}Current date :$NC " ; date
echo -e "\n${RED}Machine stats :$NC " ; uptime
echo -e "\n${RED}Current network location :$NC " ; scselect
echo -e "\n${RED}Public facing IP Address :$NC " ;myip
#echo -e "\n${RED}DNS Configuration:$NC " ; scutil --dns
echo
}


#alias flushDNS='dscacheutil -flushcache; sudo killall -HUP mDNSResponder;'
alias flushDNS='sudo dscacheutil -flushcache'

alias apache_start='sudo apachectl start'
alias apache_stop='sudo apachectl stop'
alias apache_restart='sudo apachectl restart'

bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'

export HOMEBREW_EDITOR=/usr/bin/emacs

export PATH=/usr/local/opt/python/libexec/bin:$PATH
export PYTHONPATH=/usr/local/lib/python:$PYTHONPATH
export PATH=/usr/local/opt/python/bin:$PATH

export CFLAGS="-I/usr/local/lib/python2.7/site-packages/numpy/core/include"
eval $(/usr/libexec/path_helper -s)