
# For Battle School Workshop usage only, change the DEV_HOME
# to /opt/perforce/.dev/bin, to obsure teh .dev directory
# in the lab environment. This is because the 'dev' tree is
# part of the BSW lab infrastructure, not something that
# customers/students should expect to see in /opt/perforce
# in any real-world server.
if [[ "$HOSTNAME" == p4c-bos-01.p4demo.com ]]; then
   export DEV_HOME=/opt/perforce/.dev/bin
else
   export DEV_HOME=/opt/perforce/dev/bin
fi

export P4CONFIG=.p4config.local
export P4IGNORE=.p4ignore.local

[[ "$PATH" == *"$DEV_HOME"* ]] || export PATH="$DEV_HOME:$PATH"

# Deliberately NOT exporting P4PORT/P4USER here. Each of /opt/perforce/dev/bin
# and /opt/perforce/dev/sdp is its own 'p4 clone'-managed DVCS repo with its
# own .p4config.local (P4CONFIG, set above) carrying the right P4USER/P4PORT/
# P4CLIENT for whatever source it's currently cloned from -- via swap_source.sh,
# that source can vary per machine and change over time. P4CONFIG settings
# take precedence over shell environment variables, so hardcoding a value here
# wouldn't even take effect once inside either repo -- better to just not
# imply a fixed identity that isn't accurate for every setup.
export P4TICKETS=${DEV_HOME%/*}/.p4tickets

# Alias to Load Development Environment
alias lde='source $DEV_HOME/dev_env.sh'

alias cls=clear
alias md='mkdir -p'
alias o'=p4 opened ...'

alias cdd="cd $DEV_HOME"
alias cds="cd ${DEV_HOME%/bin}/sdp/Server/Unix/setup"
alias cdu="cd ${DEV_HOME%/bin}/sdp/Server/Unix/p4/common/sdp_upgrade"
alias cdb="cd ${DEV_HOME%/bin}/sdp/Server/Unix/p4/common/bin"
alias ec2id=/opt/perforce/dev/sdp/Server/Unix/p4/common/cloud/aws/bin/ec2id

# Alias to fetch latest from the Public Depot, check that we're clean with
# test_preflight.sh, and if so, run the full test suite.  If the
# test_preflight.sh isn't happy, don't kick off the test suite.
# 'uat' is short for "update and test."
alias uat='cds; p4 fetch; cdd; p4 fetch; ./test_preflight.sh && r'

# Enable VI command line editing.
set -o vi
if command -v nvim > /dev/null; then
   alias vi=nvim
elif command -v vim > /dev/null; then
   alias vi=vim
fi

[[ ! -d ~/.config/nvim ]] && mkdir -p ~/.config.nvim
[[ ! -r ~/.config/nvim/init.lua ]] && ( cd ~/.config/nvim; ln -s $DEV_HOME/nvim.init.lua init.lua; )

# Test Support

alias r="$DEV_HOME/r"
