Thursday, February 26, 2015

my alias list

".bashrc"

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

if [ -f ~/.config/.localrc ]
then
   . ~/.config/.localrc
fi



set -o vi
unalias ls

==============================


".localrc"

######################################
# Set up data location by hostname
######################################
hnStr=`hostname`

declare -a hostArr
declare -a src_dirArr
declare -a data_dirArr
hostArr=('badger' 's4' 'cardinal' 'fe' 'jibb')
# Separate source and data into two locations
data_dirArr=("/data/${LOGNAME}"  \
             "/data/users/${LOGNAME}" \
             "/data/users/${LOGNAME}" \
             "/scratch2/portfolios/NESDIS/drt/noscrub/${LOGNAME}" \
             "/data/users/${LOGNAME}")
src_dirArr=("/data/${LOGNAME}"  \
             "/data/users/${LOGNAME}" \
             "/data/users/${LOGNAME}" \
             "/scratch2/portfolios/NESDIS/h-sandy/noscrub/${LOGNAME}" \
             "/data/users/${LOGNAME}")
iat_src_dirArr=("/data/${LOGNAME}"  \
             "/data/users/${LOGNAME}/iat" \
             "/data/users/${LOGNAME}/iat" \
             "/scratch2/portfolios/NESDIS/h-sandy/noscrub/${LOGNAME}" \
             "/data/users/${LOGNAME}")
iat_ws_dirArr=("/data/${LOGNAME}"  \
             "/data/users/${LOGNAME}/workspace" \
             "/data/users/${LOGNAME}/workspace" \
             "/scratch2/portfolios/NESDIS/drt/noscrub/${LOGNAME}/workspace" \
             "/data/users/${LOGNAME}")


SIZE=${#hostArr[@]}   # array size

emptyStr=""
notSupportStr="NOT_SUPPORTED_HOST"

searchStr="${emptyStr}"

for (( i=0; i<$SIZE; i++)); do
   searchStr=` echo $hnStr  |grep -e "${hostArr[${i}]}" `
   if [ "${searchStr}" != "${emptyStr}" ]
   then
      data_dir=${data_dirArr[i]}
      src_dir=${src_dirArr[i]}
      iat_src_dir=${iat_src_dirArr[i]}
      iat_ws_dir=${iat_ws_dirArr[i]}
      break
   fi
done

##############################################
# Now export data_dir for use by downstream
##############################################
export data_dir
export iat_src_dir
export iat_ws_dir
alias data=" cd ${data_dir} "
alias iat="  cd ${iat_src_dir} "
alias iatws="cd ${iat_ws_dir} "

###################################################
# Various configurations
###################################################
# 1. dir
if [ -f ~/.config/.dirrc ]
then
   . ~/.config/.dirrc
fi

# 2. iat
if [ -f ~/.config/.iatrc ]
then
   . ~/.config/.iatrc
fi

# 3. misc
if [ -f ~/.config/.miscrc ]
then
   . ~/.config/.miscrc
fi

# 4. module
if [ -f ~/.config/.modulerc ]
then
   . ~/.config/.modulerc
fi

# 5. ps
if [ -f ~/.config/.psrc ]
then
   . ~/.config/.psrc
fi

# 6. sftp
if [ -f ~/.config/.sftprc ]
then
   . ~/.config/.sftprc
fi

# 7. submit job
if [ -f ~/.config/.subjobrc ]
then
   . ~/.config/.subjobrc
fi

# 8. svn
if [ -f ~/.config/.svnrc ]
then
   . ~/.config/.svnrc
fi

# 9. my tool
if [ -f ~/.config/.toolrc ]
then
   . ~/.config/.toolrc
fi

# 10. gsi
if [ -f ~/.config/.gsirc ]
then
   . ~/.config/.gsirc
fi


====================================

".dirrc"

#
alias "gg=cd .."
alias "ggg=cd ../.."
alias g2="cd ../.."
alias g3="cd ../../.."
alias g4="cd ../../../.."
alias ff='fdir=`pwd`'
alias ff1='fdir1=`pwd`'
alias ff2='fdir2=`pwd`'
alias ff3='fdir3=`pwd`'
alias bb='cd ${fdir}  '
alias bb1='cd ${fdir1} '
alias bb2='cd ${fdir2} '
alias bb3='cd ${fdir3} '
alias lr="ls -ltr "
alias la="ls -a "
alias hn="hostname "
alias h="history "
alias tf="tail -f "

alias trf="tree -f "
alias trd="tree -d "

alias rf="rm -rf "

alias vhead="od -t a $1 | head -10 "

=================================

".miscrc"

# .bashrc
alias config="cd  ~/.config"
alias vb="vi ~/.bashrc"
alias rb=". ~/.bashrc"
alias showa="alias |sort |less "

# delete old files
alias d3="find -ctime 3 -type f   |xargs  rm -rf   "
alias d2="find -ctime 2 -type f   |xargs  rm -rf   "

# list directory
alias ldir="find -type d "

#shell
alias whichshell='echo $0 '   # or    ' ps -p $$ '

# rsync
alias rsynclocal="rsync   -zvh   "
alias rsyncremote="rsync -azvh  dxu@s4-gateway.ssec.wisc.edu:"

# matlab
alias mlonly="matlab -nosplash -nodesktop "

set -o vi


======================================

".modulerc"

# module command
alias mload="module add "    # add one module
alias munload="module unload "    # delete all modules
alias mpurge="module purge "  # unload all modules
alias mlist="module list "   # list LOADED modules
alias mavail="module avail " # list available modules
alias mspider="module spider " # get info about a module
alias mwhatis="module whatis " # get info about a module

MODULE_USE_STR="                           \n\
  module add     # add one module          \n\
  module unload  # delete all modules      \n\
  module purge   # unload all modules      \n\
  module list    # list LOADED modules     \n\
  module avail   # list available modules  \n\
  module spider  # get info about a module \n\
  module whatis  # get info about a module \n\
                                           \n\
                                           \n\
                                           \n\
"

alias module_info='printf "$MODULE_USE_STR "  '


==================================

".psrc"

# ps command
alias psef="ps -ef  |grep ${LOGNAME} "     # all the process
alias ptree="ps -ejH "   # process tree
alias pthread="ps -eLf " # thread info
alias pcmd="ps -fp "     # + PID#


======================================

".sftprc"

# sftp
alias tome=" mail -s 'from s4'  deyong.xu@noaa.gov  <  " # followed by a file

# ssh mode
alias s4=" ssh dxu@s4-gateway.ssec.wisc.edu  "
alias badger="ssh -X dxu@badger.ssec.wisc.edu "
alias cardinal="ssh -X dxu@s4-cardinal.ssec.wisc.edu  "

# sftp mode
alias ss4=" sftp dxu@s4-gateway.ssec.wisc.edu  "
alias sbadger=" sftp dxu@badger.ssec.wisc.edu  "
alias scardinal="sftp dxu@s4-cardinal.ssec.wisc.edu  "

alias hn="hostname "

alias sts="echo   /data/users/dxu/transferStation/  "
alias tosts="cd   /data/users/dxu/transferStation/  "

=============================================

".subjobrc"

####################
#1. slurm command
####################
slurm_usage=" \n\
# \n\
# slurm command list: \n\
# sbatch   : Handles serial jobs. Also used as a first step for MPI jobs. \n\
# srun     : MPI-capable job submission, usually run from within a script run via sbatch. \n\
# sinfo    : Displays nodes/and partitions. \n\
# squeue   : Shows you the list of jobs running and yet to be run. \n\
# scancel  : Delete a job \n\
# sstat    : Get the status of a job \n\
# scontrol : Manipulate or view details on a job. For example 'scontrol -dd show job <jobid>' \n\
# \n\
# \n\
"
alias slurm_info='printf "$slurm_usage" '

#######################
#2. qsub command
#######################
#
qsub_usage=" \n\
# \n\
# qsub                  # Small job,  followed by '-N MyJob  a.sh' \n\
# qsub -pe smp          # Medium job, followed by '48  -N MyJob  a.sh' \n\
# qsub -pe mpi2_mpd     # Big job,    followed by '192 -N MyJob  a.sh' \n\
# qstat -u  uid         # Check job status \n\
# showq -u  uid         # Show job queues \n\
# qstat -xml            # List job in xml format \n\
# qacct -j your_job_id  # Info about a completed jobs \n\
# qresub                # Resubmit a job \n\
# qdel                  # Delete a job \n\
# \n\
# \n\
"
alias qsub_info='printf "$qsub_usage" '
alias qstatme="   qstat | grep ${LOGNAME} "
alias rserial=" qsub "                 # small job, followed by "    -N MyJob  a.sh"
alias rsmp="    qsub -pe smp "         # medium job, followed by "48  -N MyJob  a.sh"
alias rmpi="    qsub -pe mpi2_mpd "    # big job, followed by "192 -N MyJob  a.sh"
alias jobstat=" qstat -u ${LOGNAME}  "
alias jobqueue="showq -u ${LOGNAME}  "

===========================================

".svnrc"

# svn commands
alias ss="cat .svn/entries | head  -5 | tail -1 ; echo"
alias sstatus="svn status "
alias sco="svn co --ignore-externals   "
alias sci="svn ci "
alias sadd="svn add "
alias supdate="svn update --ignore-externals  "
alias smove="svn move  "
alias sdelete="svn delete "
alias slog="svn log "
alias sinfo="svn info "
alias srevert="svn revert "
alias svndiff="svn diff "
alias svndiffprev="svn diff -r HEAD:PREV "
alias svncomp="svn diff -c "
alias svnreslvServer="svn resolve --accept=theirs-full  "
alias svnreslvLocal="svn resolve --accept=mine-full  "
alias sm='svn commit -m "" '


# Delete svn files
# alias rmsvn="find . -name '*svn*'   |xargs rm -rf  "
# alias rmelog="find . -name '*.e[0-9][0-9]*'   |xargs rm -rf  "