pcdshub / pcdshub/shared-dotfiles

Additional source of bashrc goodies from @zrylettc

Open
#15 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
3
Forks
15
Avg merge
7d 10h
Merged PRs (30d)
1

Description

Copy/paste ended up being a bit messy, but this includes some of his annotations - inline with the other code

Common stuff (except sample delivery), hopefully already integrated
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
  . /etc/bashrc
fi
# Shell environment variables are now all loaded from scripts located
# in /cds/group/pcds/setup
source /cds/group/pcds/setup/epicsenv-cur.sh
source /cds/group/pcds/engineering_tools/latest-released/rc/bashrc
source /cds/group/pcds/setup/sampleDeliveryShortcuts.sh
source /cds/group/pcds/setup/plcenv.sh

# Other SLAC environment variables
export SVNROOT=file:///afs/slac/g/pcds/vol2/svn/pcds
export SVNTRUNK=$SVNROOT/epics/trunk
export GIT_TOP=/afs/slac/g/cd/swe/git/repos
export GITTRUNK=$GIT_TOP/package/epics
GITTRUNK naming is kinda leftover from SVNTRUNK but having some variable with this value is probably useful
Also, common, (opr bins should be personally based on who though)
# SLAC PATH Additions
export PATH=$PATH:/reg/common/tools/bin
export PATH=$PATH:/reg/common/tools/bin/eco_tools
export PATH=$PATH:/afs/slac/g/lcls/tools/script
export PATH=$PATH:/cds/group/pcds/engineering_tools/latest-released/scripts/
export PATH=$PATH:/cds/home/opr/xcsopr/bin
export PATH=$PATH:/cds/home/opr/xppopr/bin
export PATH=$PATH:/cds/home/opr/cxiopr/bin
export PATH=$PATH:/cds/home/opr/mfxopr/bin
# User specific environment and startup programs
export PATH=$HOME/bin:$PATH
# Environment variables
# EDITOR is used by svn and other packages which need to invoke a text editor
# If you are not familiar with vi, vim, or emacs, nano is a simple gui editor.
export EDITOR=nano
export CLICOLOR=1
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
export GREP_OPTIONS='--color=auto'
### ALIASES
# always expand aliases
shopt -s expand_aliases
# list all files including hidden
alias la="ls -a"
# list all files with more information
alias ll="ls -al"
# list files backwards in time since last edit
alias lt='ls -cltrh'
# psbuild shortcuts
alias psb='ssh psbuild-rhel7'
alias psb5='ssh psbuild-rhel5'
# fix cd.. typo
alias cd..='cd ..'
# fix '0~ 1~' bug in copy/paste
alias fixcp='printf "\e[?2004l"'
# always show colors in less
alias less='less -R'
# always use --no-remote in firefox
alias firefox='firefox --no-remote'
# nano settings
alias nano='nano -EOiS'
# PLC programming node
alias plcprog='ssh psbuild-rhel7 -f "rdesktop -g 1440x850 -u ${USER} plcprog-console" 2> /dev/null'
# check redhat version
alias rh='cat /etc/redhat-release'
# search ps for processes related to me
alias whatamidoing='ps -aux | grep `whoami`'
# open the most-recently-changed subdirectory
alias newest='cd `ls -td */ | head -1`'
# show whitespace in less (pipe to ws)
alias ws='tr " " "*" | tr "\t" "&" | less'
# check enum state names
alias cagetenum='caget -d 31'
# grep for conda environment versions in the hutch env files
alias checkpythonversions="grep --color=auto CONDA_ENVNAME= /reg/g/pcds/pyps/apps/hutch-python/*/*env | grep -v \"#\" | sed -n 's/.*hutch-python\/\(.*\)\/.*\"\(.*\)\"/\1\t\2/p' | sort -k2"
# use my personal conda environments
alias tpconda='source ~/miniconda/etc/profile.d/conda.sh'
# personal PCDS shortcuts
alias ioc='cd /reg/g/pcds/epics/ioc'
alias dev='cd /reg/g/pcds/epics-dev'
alias jet='cd /reg/g/pcds/pyps/apps/hutch-python/cxi/dev/jet_tracking'
alias pcds='cd /reg/g/pcds'
alias pds='cd /reg/g/pcds/dist/pds'
alias pyps='cd /reg/g/pcds/pyps'
alias config='cd /reg/g/pcds/config'
alias condastart='source pcds_conda'
alias condastop='conda deactivate; conda deactivate'
alias pydev='source pydev_env'
alias anaenv='source /reg/g/psdm/etc/psconda.sh'
alias iocdata="pushd /reg/d/iocData"

### FUNCTIONS
# automatically ls upon cd-ing
function cd {
    FILE="$@"
    if [[ -f "$FILE" && -d `dirname "$FILE"` ]]; then
        FILE=`dirname "$FILE"`
    fi
    builtin cd "$FILE" && ls
}
# read the file called by argument
function readcmd {
    less `which "$@"`
}
# open the most recent hutch-python log for the current hutch
function newlog {
    HUTCH=${HUTCH:-`get_hutch_name`}
    HUTCH=${1:-$HUTCH}
    if [[ $HUTCH == 'unknown_hutch' ]]; then
        echo 'Unknown hutch. Exiting...' >&2
        return 1
    fi
    pushd /reg/g/pcds/pyps/apps/hutch-python/$HUTCH/logs > /dev/null
    builtin cd `ls -td */ | head -1`
    less `readlink -f $(ls -t | head -1)`
    popd > /dev/null
}
# list iocs that use the PV
function iocfpv {
    grep_pv $1 | sed -n 's/\/reg\/d\/iocData\/\(\S*\)\/iocInfo/\1/p'
}
# read the file for a PV
function rffpv { 
    iocname=$(iocfpv $1)
    echo $iocname
    rffioc $iocname
}
# read the file for an ioc
function rffioc { 
    iocname=$@
    for ioc in $iocname
    do
	iocpath=""
        iocpath=$(grep_ioc $ioc all | grep "id:'$ioc'" | sed -n "s/^.*dir: '\(\S*\)'.*$/\1/p");
        if [[ $iocpath == "" ]]; then
            echo "Did not find ${ioc} running anywhere. Exiting..."
            return 1
        fi
        if [[ ! $iocpath =~ ^/.* ]]; then
            iocpath=/reg/g/pcds/epics/${iocpath}
        fi 
        iocfile=${iocpath}/${ioc}.cfg;
        if [ -f "$iocfile" ]; then
            less $iocfile
        else
            iocfile=${iocpath}/iocBoot/${ioc}/st.cmd
	    if [ -f "$iocfile" ]; then
                less $iocfile
            else
                echo -e "Neither file found:\n${iocpath}/${ioc}.cfg\n$iocfile"
            fi 
        fi
    done
}
# open the edm screen for an ioc
function openscreen {
    iocname=$1
    filepath=$(grep_ioc $iocname all | grep "id:'$iocname'" | sed -n "s/^.*dir: '\(\S*\)'.*$/\1/p");
    if [[ ! $filepath =~ ^/.* ]]; then
        filepath=/reg/g/pcds/epics/${filepath}
    fi
    if [[ -d "${filepath}/build" ]]; then
        filepath=${filepath}/build
    fi
    ${filepath}/iocBoot/${iocname}/edm-${iocname}.cmd
}

# read a hutch's daq cnf file
function daqcnf {
    FILE=$1
    HUTCH=${FILE:=`get_hutch_name`}
    if [[ $FILE == 'cxi' ]]; then
        FILE='cxi_0'
    elif [[ $HUTCH =~ '_' ]]; then
        HUTCH=`echo $HUTCH | tr -dc '[a-zA-Z]\n\r'`
    fi
    less "/reg/g/pcds/dist/pds/$HUTCH/scripts/$FILE.cnf"
}

# measure the speed of a motor, eg. pass CXI:SC2:MND:01.RBV
function motorspeed {
POS=0
TIME=0

while true; do
OLDPOS=$POS
OLDTIME=$TIME
POS=`caget -t $1`
TIME=`date +%s.%3N`
bc <<< "($POS-$OLDPOS)/($TIME-$OLDTIME)"
done
}

### COMMAND PROMPT
#export PS1='\e[1;34m\h:\W \u\$ \e[m'
case $HOSTNAME in
  (psdev*) export PS1='\[\e[1;34m\]\h:\W \u\$ \[\e[m\]';;
  (psbuild-rhel*) export PS1='\[\e[7;34m\]\h:\W \u\$\[\e[m\] ';;
  (*) export PS1='\[\e[7;31m\]\h:\W \u\$\[\e[m\] '
esac

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the repository's shared .bashrc or other shell configuration entry point, then compare it with the annotated Bash content in this issue. Identify which environment variables, aliases, and functions belong in the shared configuration; done means the selected additions are integrated without including personal or incompatible settings.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash
Domain
cli, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.