refactor: modular .bashrc.d/ structure
- Rewrite .bashrc as minimal loader (34 lines → loads .bashrc.d/*.sh)
- Clean .bash_profile: single source, Apple Silicon/Intel brew path
- Add .bashrc.d/ with 7 topic modules:
00_env.sh PS1, OSTYPE, colors, pyenv
10_aliases.sh universal aliases
20_functions.sh proxy, dbash, git helpers
30_work.sh work-host detection, LDAP, AWX, Juniper tools
(+ unified-hub-login with env-var creds)
40_k8s.sh kubectl completion + aliases
50_ai_env.sh WORKSPACE/DATA_ROOT/MODEL_ROOT paths
60_dotfiles.sh dotfiles manager aliases, zet shortcuts
- Secrets (SN_PASSWORD, LDAP bind PWs, Unified Hub token) moved
to ~/.bashrc.local (gitignored, written by setup script)
- Update .dotfiles_manifest to track .bashrc.d directory
This commit is contained in:
588
.bashrc
588
.bashrc
@@ -1,558 +1,34 @@
|
||||
# Kenji's .bashrc file
|
||||
# Should be symlinked to DBX/projects/unix/.bashrc
|
||||
# Also should be synced to /homes/kenjim/.bashrc
|
||||
|
||||
if [ -f /etc/profile ]; then source /etc/profile; fi
|
||||
if [ -f /etc/bashrc ]; then source /etc/bashrc; fi
|
||||
|
||||
export PS1='\h:\w\$ '
|
||||
export PS2='> '
|
||||
export FTP_PASSIVE_MODE=YES
|
||||
export RSYNC_RSH=ssh
|
||||
|
||||
OSTYPE=$(uname -s)
|
||||
HOSTNAME=$(hostname -f)
|
||||
HOSTDOMAIN=$(hostname -d)
|
||||
EDITOR=vim
|
||||
set -o vi
|
||||
|
||||
alias gitresetpw='git config --global'
|
||||
alias giturl='git config --get remote.origin.url'
|
||||
|
||||
# OS specific ####################
|
||||
case $OSTYPE in
|
||||
Linux)
|
||||
alias ls='ls -F'
|
||||
alias pst='ps axjf'
|
||||
# specify default shell tools ###########
|
||||
if type $EDITOR >/dev/null 2>&1; then
|
||||
export EDITOR=$EDITOR
|
||||
alias vi=${EDITOR}
|
||||
else
|
||||
export EDITOR=vi
|
||||
fi
|
||||
|
||||
if type less >/dev/null 2>&1; then
|
||||
export PAGER='less'
|
||||
else
|
||||
export PAGER=more
|
||||
fi
|
||||
|
||||
function yaml2json {
|
||||
python -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin.read())))'
|
||||
}
|
||||
|
||||
;;
|
||||
Darwin)
|
||||
# pstree install with brew
|
||||
alias pst='pstree'
|
||||
;;
|
||||
FreeBSD)
|
||||
export CLICOLOR=1
|
||||
LSCOLORS=fxgxcxdxbxegedabagacad
|
||||
;;
|
||||
esac
|
||||
|
||||
# terminal specific ###############
|
||||
case $TERM in
|
||||
xterm*)
|
||||
export LS_COLORS='no=00:fi=00:di=00;35:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;31:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:*.pl=00;32:'
|
||||
alias ls='ls -F --color'
|
||||
#PROMPT_COMMAND='echo -ne "\033]0;${HOSTNAME}: ${PWD}\007"'
|
||||
#HOSTNAMESHORT="${HOSTNAME%%.*}"
|
||||
#export PROMPT_COMMAND='echo -ne "\033]0;${HOSTNAMESHORT}: ${PWD##*/}\007"'
|
||||
#export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND";
|
||||
;;
|
||||
esac
|
||||
|
||||
# Domain specific environment #################
|
||||
case $HOSTDOMAIN in
|
||||
juniper.net | jnpr.net)
|
||||
# juniper.net hosts
|
||||
export PATH=$PATH:/volume/labtools/bin
|
||||
export PGUSER=ddladmin
|
||||
export PGHOST=localhost
|
||||
|
||||
function setawx() {
|
||||
echo -n "AWX Host: "
|
||||
read TOWER_HOST
|
||||
echo -n "AWX Username: "
|
||||
read TOWER_USERNAME
|
||||
echo -n "AWX Password: "
|
||||
read TOWER_PASSWORD
|
||||
awx -k -f human login
|
||||
awx config -f human | grep base_url
|
||||
}
|
||||
|
||||
alias awxjobs='awx jobs list -f human --filter id,name,limit,failed --all'
|
||||
|
||||
alias j_proxy_on='proxy_on qcwebproxylb.juniper.net:3128'
|
||||
|
||||
case $OSTYPE in
|
||||
Linux)
|
||||
alias pstree='/usr/bin/pstree -c -l -a -n -p -u'
|
||||
;;
|
||||
FreeBSD) ;;
|
||||
esac
|
||||
|
||||
case $HOSTNAME in
|
||||
# Special configuration specific for Juniper hosts
|
||||
etqc-kenjim* | engtech-dev*)
|
||||
# applies to both workstations
|
||||
#export MAIL=${HOME}/Mail/mbox
|
||||
#export MAILCHECK=600
|
||||
PATH=${HOME}/bin:${PATH}
|
||||
alias awx='~/.local/bin/awx'
|
||||
|
||||
source /usr/share/bash-completion/bash_completion
|
||||
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
#alias realias='$EDITOR ~/.aliases; source ~/.aliases; PWDSAVE=${PWD}; cd ~/cvs/kenjim; cvs -d kenji@rad.kenjim.com:/home/cvs commit -m "updated" .aliases; cd ${PWDSAVE}'
|
||||
#alias rebash='$EDITOR ~/.bashrc; source ~/.bashrc; PWDSAVE=${PWD}; cd ~/cvs/kenjim; cvs -d kenji@rad.kenjim.com:/home/cvs commit -m "updated" .bashrc; cd ${PWDSAVE}'
|
||||
|
||||
# Host specific configurations
|
||||
case $HOSTNAME in
|
||||
kenjim-mbp | etqc-kenjim-* | engtech-dev-01*)
|
||||
# default aliases to override whatever is in .aliases
|
||||
source $HOME/k8configs/engtech_k8_env.sh
|
||||
|
||||
# Add RVM to PATH for scripting
|
||||
# /usr/texbin for MacTex/Latex stuff
|
||||
#PATH=$PATH:/usr/local/sbin:$HOME/bin:$HOME/.rvm/bin:/usr/texbin
|
||||
PATH=$HOME/bin:~/.local/bin:$PATH
|
||||
#PATH=/Users/kenjim/bin/Sencha/Cmd/5.1.2.52:$PATH
|
||||
#export SENCHA_CMD_3_0_0="/Users/kenjim/bin/Sencha/Cmd/5.1.2.52"
|
||||
export CLICOLOR=1
|
||||
|
||||
export RAILS_ENV=development
|
||||
#export TIM_SSH_USER_PASS='B3k1nD+'
|
||||
#export TIM_EK_R_LP='emccolganoansarikenjimjhayespsen'
|
||||
export SN_USERNAME='_integ-soap-read'
|
||||
export SN_PASSWORD='e3Qw&%b7'
|
||||
|
||||
#export PYENV_VERSION='3.8.1'
|
||||
#export ANSIBLE_CONFIG='/Users/kenjim/Juniper/git-m16/infra-ansible/ansible_cli.cfg'
|
||||
#export KUBECONFIG='/Users/kenjim/Juniper/K8_Configs/kenjim-k8-config'
|
||||
|
||||
# Personal Shortcuts
|
||||
alias l='less'
|
||||
alias t='tail -f'
|
||||
alias psg='pstree | grep'
|
||||
alias sl='screen -list'
|
||||
alias sr='screen -r'
|
||||
#alias conncount='netstat -ant | awk "{print $6}" | sort | uniq -c | sort -n'
|
||||
alias a='alias'
|
||||
alias h='history 25'
|
||||
alias la='ls -a'
|
||||
alias lf='ls -FA'
|
||||
alias ll='ls -lAh|more'
|
||||
alias lt='ls -tlAh|more'
|
||||
alias tl='tail -f /var/log/messages'
|
||||
alias sl='screen -list'
|
||||
alias sr='screen -r'
|
||||
alias ps-m='ps aux --sort -rss'
|
||||
|
||||
#alias sa='ssh-add /export/kenjim/.ssh/juniper_kenjim_rsa_id'
|
||||
#alias lair='ssh-keygen -f "/home/kenjim/.ssh/known_hosts" -R lair.kenjim.com; ssh -f -N -R 11322:localhost:22 lair'
|
||||
#alias bar='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ServerAliveInterval=540 -o Compression=no -f -N -R 11322:localhost:22 root@192.241.205.115'
|
||||
#alias sa='ssh-add /export/kenjim/.ssh/juniper_kenjim_rsa_id'
|
||||
|
||||
alias rvmi='source "$HOME/.rvm/scripts/rvm"; echo "rvm initialized..."'
|
||||
#alias psql='/Applications/Postgres.app/Contents/Versions/9.6/bin/psql'
|
||||
#alias ctags='/usr/local/bin/ctags'
|
||||
#alias rtags='/usr/local/bin/ctags -R -f .tags --languages=ruby --exclude=.git --exclude=log . $(bundle list --paths)'
|
||||
|
||||
alias pstat='passenger status'
|
||||
alias pstart='passenger start'
|
||||
alias pstop='passenger stop'
|
||||
alias prest='passenger stop; sleep 2; passenger start'
|
||||
alias renv='env|sort|egrep -i "(gem|ruby|rvm|rails|tim)"'
|
||||
|
||||
# Postgres Logins
|
||||
alias pgtimdev='psql -U tim_api tim_api_dev'
|
||||
alias pgtimqdev='psql -U tim_api -h ttqc-tim-mmonit-02 kenjim_devel'
|
||||
alias pgtimqdev2='psql -U tim_api -h ttqc-tim-mmonit-02 kenjim_devel2'
|
||||
alias pgtimtest='psql -U tim_api tim_api_test'
|
||||
alias pgtimint='psql -h ttqc-tim-mm-02.juniper.net -U tim_api tim_api_int'
|
||||
alias pgtimint2='psql -h ttsv-db-03.juniper.net -U tim_api tim_api_int2'
|
||||
alias pgtimprod='psql -h ttqc-tim-mm-02.juniper.net -p 5432 -U tim_api tim'
|
||||
alias pgtimloc='psql -U tim_api kenjim_tim'
|
||||
alias pgtimweekly='psql -h ttqc-testdb-01 -U tim_api weekly_systest_live'
|
||||
alias pgtimqmm='psql -h ttqc-tim-mmonit-02 -U mmonit mmonit'
|
||||
alias pgtimbmm='psql -h ttbg-tim-mmonit-01 -U mmonit mmonit'
|
||||
alias pgbdrqc='psql -h ttqc-bdr-db01.juniper.net -U tim_api systest_live'
|
||||
alias pgbdrbg='psql -h ttbg-bdr-db01.juniper.net -U tim_api systest_live'
|
||||
alias pgdlm='psql -h ttqc-dlm-db-ms.ttglb.juniper.net -U ddladmin systest_live'
|
||||
|
||||
alias jira='jira-cli --v2 view --oneline --search-jql "assignee=kenjim and status!=closed and status!=resolved order by priority desc, created asc"'
|
||||
|
||||
# retired
|
||||
#alias tim='GLI_DEBUG=true bundle exec bin/timcl'
|
||||
|
||||
#alias ap='ansible-playbook -i inventory/engtech-prod'
|
||||
#alias ai='ANSIBLE_CONFIG=/Users/kenjim/Juniper/git-m16/infra-ansible/ansible_cli.cfg ansible-inventory -i inventory/cmdb/now.py -i inventory/engtech_prod'
|
||||
|
||||
alias ai='ANSIBLE_CONFIG=/Users/kenjim/Juniper/git-m16/infra-ansible/ansible_cli.cfg ansible-inventory -i inventory/cmdb_rendered/engtech.yml'
|
||||
alias ans='ANSIBLE_CONFIG=/Users/kenjim/Juniper/git-m16/infra-ansible/ansible_cli.cfg ansible -i ~/ansible/inventory/cmdb/now.py -i ~/ansible/inventory/engtech_prod'
|
||||
#alias apy='rm ~/ansible.log ; ANSIBLE_CONFIG=/Users/kenjim/Juniper/git/infra-ansible/ansible_cli.cfg ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook -i inventory/cmdb/now.py -i inventory/engtech_prod'
|
||||
alias apy='rm ~/ansible.log ; ANSIBLE_CONFIG=/Users/kenjim/Juniper/git/infra-ansible/ansible_cli.cfg ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook -i inventory/cmdb_rendered/engtech.yml --vault-id vault_engtech_default'
|
||||
alias aps='rm ~/ansible.log ; ANSIBLE_CONFIG=/Users/kenjim/Juniper/git/infra-ansible/ansible_cli.cfg ANSIBLE_STDOUT_CALLBACK=selective ansible-playbook -i inventory/cmdb_rendered/engtech.yml --vault-id vault_engtech_default'
|
||||
alias apa='rm ~/ansible.log ; ANSIBLE_CONFIG=/Users/kenjim/Juniper/git/infra-ansible/ansible_cli.cfg ANSIBLE_STDOUT_CALLBACK=actionable ansible-playbook -i inventory/cmdb_rendered/engtech.yml --vault-id vault_engtech_default'
|
||||
alias apd='rm ~/ansible.log ; ANSIBLE_CONFIG=/Users/kenjim/Juniper/git/infra-ansible/ansible_cli.cfg ANSIBLE_STDOUT_CALLBACK=debug ansible-playbook -i inventory/cmdb/now.py -i inventory/engtech_prod'
|
||||
alias apj='rm ~/ansible.log ; ANSIBLE_CONFIG=/Users/kenjim/Juniper/git/infra-ansible/ansible_cli.cfg ANSIBLE_STDOUT_CALLBACK=json ansible-playbook -i inventory/cmdb/now.py -i inventory/engtech_prod'
|
||||
alias giturl='git config --get remote.origin.url'
|
||||
alias gitresetpw='git config --global credential.helper osxkeychain'
|
||||
|
||||
alias d='docker'
|
||||
alias di='docker images'
|
||||
alias dp='docker ps'
|
||||
alias dr='docker run'
|
||||
alias db='docker build'
|
||||
alias dbash='docker run -it --entrypoint /bin/bash'
|
||||
|
||||
function tmls { ssh $1 ls /etc/monit.d; }
|
||||
function tmlog { ssh $1 tail -f /var/log/monit.log; }
|
||||
|
||||
function tdiffstat { svn diff -x --ignore-eol-style -x -w https://tt-svn.juniper.net/svn/adp/projects/tim/tags/$1/rails-api https://tt-svn.juniper.net/svn/adp/projects/tim/trunk/rails-api | diffstat; }
|
||||
function tdiff { svn diff -x --ignore-eol-style -x -w https://tt-svn.juniper.net/svn/adp/projects/tim/tags/$1/rails-api https://tt-svn.juniper.net/svn/adp/projects/tim/trunk/rails-api; }
|
||||
|
||||
function timsvncopy { svn copy --parents https://tt-svn.juniper.net/svn/adp/projects/tim/trunk/rails-api https://tt-svn.juniper.net/svn/adp/projects/tim/tags/$1/rails-api -m "$1 new branch"; }
|
||||
|
||||
function curl_time { curl -w "@curl-format.txt" -o /dev/null -s "$1"; }
|
||||
|
||||
# copies my protected ssh pub key
|
||||
function copy_pub_key { cat ~/.ssh/authorized_keys.kenjim-protected | ssh $1 'umask 0077; mkdir -p .ssh; cat >> .ssh/authorized_keys && echo "Key copied"'; }
|
||||
|
||||
function ldaps() {
|
||||
ldapsearch -LLL -x -b 'dc=jnpr,dc=net' -h ldap-eqx-lb.jnpr.net -D 'CN=_eng_jira_bind_new,OU=Service Accounts,OU=Misc,OU=Common,DC=jnpr,DC=net' -w 'xqYzhL%lLe!FIr!67LJX%7a^PWOWY0' sAMAccountName=$1 | perl -p00e 's/\r?\n //g'
|
||||
}
|
||||
|
||||
function ldaps2() {
|
||||
ldapsearch -LLL -x -b 'dc=jnpr,dc=net' -h ldap-qnc-lb.jnpr.net -D 'CN=_eng_labrsrcmgr_bind,OU=Service Accounts,OU=Misc,OU=Common,DC=jnpr,DC=net' -w 'tF#w3St@nGqq36XZDym#857U)v4xKw' sAMAccountName=$1 | perl -p00e 's/\r?\n //g'
|
||||
}
|
||||
|
||||
function netseg() {
|
||||
curl -k https://netseg.juniper.net/api/find_ip?hostname=$1 | jq '.'
|
||||
}
|
||||
|
||||
function dbash() {
|
||||
docker exec -it $1 bash
|
||||
}
|
||||
|
||||
# Kubectl Autocomplete
|
||||
source <(kubectl completion bash)
|
||||
alias k=kubectl
|
||||
complete -o default -F __start_kubectl k
|
||||
|
||||
alias kc='kubectl config view'
|
||||
alias kd='kubectl describe'
|
||||
alias ke='kubectl explain'
|
||||
alias kg='kubectl get'
|
||||
alias kl='kubectl logs -f'
|
||||
alias kp='kubectl get pods -o wide'
|
||||
alias kq='kubectl describe quota'
|
||||
alias ks='kubectl get services'
|
||||
alias kuc='kubectl config use-context'
|
||||
alias kpl='kubectl get pods --show-labels'
|
||||
alias kdp='kubectl describe pod'
|
||||
alias kgs='kubectl get secrets'
|
||||
|
||||
# Kubectl aliases
|
||||
alias kx='f() { [ "$1" ] && kubectl config use-context $1 || kubectl config current-context ; } ; f'
|
||||
alias kn='f() { [ "$1" ] && kubectl config set-context --current --namespace $1 || kubectl config view --minify | grep namespace | cut -d" " -f6 ; } ; f'
|
||||
|
||||
#export NVM_DIR="$HOME/.nvm"
|
||||
#[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
#[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
||||
|
||||
#export COPYFILE_DISABLE=1
|
||||
#export GRAPHVIZ_DOT=/usr/local/bin/dot
|
||||
;;
|
||||
esac
|
||||
|
||||
case $HOSTNAME in
|
||||
################################################################################
|
||||
kenjim-mbp*)
|
||||
#export DOCKER_DEFAULT_PLATFORM=linux/amd64
|
||||
|
||||
# add MacTex Path, installer unable to add symlink in /usr/texbin
|
||||
#PATH=/usr/local/opt/libiconv/bin:/Library/TeX/texbin:$PATH
|
||||
#PATH=/usr/local/opt/libiconv/bin:/Library/TeX/texbin:$PATH
|
||||
#PATH=/opt/homebrew/bin:$PATH
|
||||
|
||||
#export LDFLAGS="-L/usr/local/opt/zlib/lib"
|
||||
#export CPPFLAGS="-I/usr/local/opt/zlib/include"
|
||||
#source ~/perl5/perlbrew/etc/bashrc
|
||||
|
||||
if command -v pyenv 1>/dev/null 2>&1; then
|
||||
export PYENV_ROOT="$HOME/.pyenv"
|
||||
export PATH="$PYENV_ROOT/bin:$PATH"
|
||||
eval "$(pyenv init --path)"
|
||||
eval "$(pyenv init -)"
|
||||
fi
|
||||
|
||||
export AWS_PROFILE=kenjim-qnc
|
||||
# make connection to k ssh config first localhost forward: LocalForward 8888 qnc-engdata5vs3.juniper.net:80
|
||||
#alias aws='aws --endpoint-url http://localhost:8888'
|
||||
alias aws-pgdb-qnc-du="aws --profile pgdb-qnc s3 ls s3://engtech-pgdb-s3-qnc/ --recursive | awk 'BEGIN {total=0}{total+=\$3}END{print total/1024/1024/1024\" GB\"}'"
|
||||
alias aws-pgdb-bng-du="aws --profile pgdb-bng s3 ls s3://engtech-pgdb-s3-bng/ --recursive | awk 'BEGIN {total=0}{total+=\$3}END{print total/1024/1024/1024\" GB\"}'"
|
||||
alias aws-pgdb-qnc-ls="aws --profile pgdb-qnc s3 ls s3://engtech-pgdb-s3-qnc/ --recursive"
|
||||
alias aws-pgdb-bng-ls="aws --profile pgdb-bng s3 ls s3://engtech-pgdb-s3-bng/ --recursive"
|
||||
export AWS_SDK_LOAD_CONFIG=1
|
||||
|
||||
#export KUBECONFIG='/Users/kenjim/.kube/config'
|
||||
|
||||
function k8proxy {
|
||||
export KUBECONFIG='/Users/kenjim/Juniper/K8_Configs/kenjim-k8-config'
|
||||
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
|
||||
export http_proxy="socks5://localhost:3133/"
|
||||
export https_proxy=$http_proxy
|
||||
export ftp_proxy=$http_proxy
|
||||
export rsync_proxy=$http_proxy
|
||||
}
|
||||
|
||||
function killcrashplan() {
|
||||
sudo launchctl unload /Library/LaunchDaemons/com.crashplan.engine.plist
|
||||
}
|
||||
;;
|
||||
|
||||
etqc-kenjim-* | engtech-dev-01*)
|
||||
# Make symlink git checkout location
|
||||
# ~k8configs -> ~/EngTech/Infra/k8configs
|
||||
source $HOME/k8configs/engtech_k8_env.sh
|
||||
export AWS_PROFILE=pgdb-qnc
|
||||
# make connection to k8dev ssh config first localhost forward: LocalForward 8888 qnc-engdata5vs3.juniper.net:80
|
||||
alias aws='aws --endpoint-url http://qnc-engdata5vs3.juniper.net'
|
||||
alias aws-pgdb-qnc-du="aws s3 ls s3://engtech-pgdb-s3-qnc/ --recursive | awk 'BEGIN {total=0}{total+=\$3}END{print total/1024/1024/1024\" GB\"}'"
|
||||
alias aws-pgdb-bng-du="aws s3 ls s3://engtech-pgdb-s3-bng/ --recursive | awk 'BEGIN {total=0}{total+=\$3}END{print total/1024/1024/1024\" GB\"}'"
|
||||
alias aws-pgdb-qnc-ls="aws s3 ls s3://engtech-pgdb-s3-qnc/ --recursive"
|
||||
alias aws-pgdb-bng-ls="aws s3 ls s3://engtech-pgdb-s3-bng/ --recursive"
|
||||
export AWS_SDK_LOAD_CONFIG=1
|
||||
;;
|
||||
|
||||
################################################################################
|
||||
# akira-mt*)
|
||||
# #export CVSROOT=ace.kenjim.com:/cvs
|
||||
# alias rvmi='source "$HOME/.rvm/scripts/rvm"; echo "rvm initialized..."'
|
||||
# alias kl='ssh kenjim-lnx-tun'
|
||||
# #dispwin -d1 -I ~/projects/monitor_calibration/GTX660_VP2770_C60_B29_D65.icm
|
||||
# #dispwin -d2 -I ~/projects/monitor_calibration/GTX660_HDMI_23EA63_C83_B26_D65.icm
|
||||
# export RAILS_ENV=kenjim_local
|
||||
|
||||
# ;;
|
||||
################################################################################
|
||||
esac
|
||||
|
||||
function proxy_on() {
|
||||
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
|
||||
|
||||
if (($# > 0)); then
|
||||
#valid=$(echo $@ | sed -n 's/\([0-9]\{1,3\}.\)\{4\}:\([0-9]\+\)/&/p')
|
||||
#if [[ $valid != $@ ]]; then
|
||||
# >&2 echo "Invalid address"
|
||||
# return 1
|
||||
#fi
|
||||
|
||||
export http_proxy="http://$1/"
|
||||
export https_proxy=$http_proxy
|
||||
export ftp_proxy=$http_proxy
|
||||
export rsync_proxy=$http_proxy
|
||||
echo "Proxy environment variable set."
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo -n "username: "
|
||||
read username
|
||||
if [[ $username != "" ]]; then
|
||||
echo -n "password: "
|
||||
read -es password
|
||||
local pre="$username:$password@"
|
||||
fi
|
||||
|
||||
echo -n "server: "
|
||||
read server
|
||||
echo -n "port: "
|
||||
read port
|
||||
|
||||
export http_proxy="http://$pre$server:$port/"
|
||||
export https_proxy=$http_proxy
|
||||
export ftp_proxy=$http_proxy
|
||||
export rsync_proxy=$http_proxy
|
||||
export HTTP_PROXY=$http_proxy
|
||||
export HTTPS_PROXY=$http_proxy
|
||||
export FTP_PROXY=$http_proxy
|
||||
export RSYNC_PROXY=$http_proxy
|
||||
}
|
||||
|
||||
function proxy_off() {
|
||||
unset http_proxy
|
||||
unset https_proxy
|
||||
unset ftp_proxy
|
||||
unset rsync_proxy
|
||||
echo -e "Proxy environment variable removed."
|
||||
}
|
||||
|
||||
function unified-hub-login() {
|
||||
UNIFIED_HUB_URL="unified-hub.juniper.net"
|
||||
UNIFIED_HUB_USERNAME="kenjim@juniper.net"
|
||||
UNIFIED_HUB_PASSWORD="cmVmdGtuOjAxOjE3NDA3ODI3NDk6OGt6WUJvcFJwa29RdEhKWWE1U1MzNkJnZXVE"
|
||||
echo $UNIFIED_HUB_PASSWORD | docker login -u "$UNIFIED_HUB_USERNAME" --password-stdin $UNIFIED_HUB_URL
|
||||
}
|
||||
|
||||
unified-hub-engtech-bin-upload() {
|
||||
local file="$1"
|
||||
local remote_path="$2"
|
||||
|
||||
# Validation
|
||||
if [[ -z "$file" ]] || [[ -z "$remote_path" ]]; then
|
||||
echo "Usage: unified-hub-engtech-bin-upload <local-file> <remote-path>"
|
||||
echo ""
|
||||
echo "Example:"
|
||||
echo " unified-hub-engtech-bin-upload kubectl dl.k8s.io/release/v1.28.4/bin/linux/amd64/kubectl"
|
||||
echo ""
|
||||
echo "Uploads to: https://unified-hub.juniper.net/artifactory/engtech-binaries/<remote-path>"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$file" ]]; then
|
||||
echo "Error: File '$file' not found in current directory"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Configuration
|
||||
local username="kenjim@juniper.net"
|
||||
local token="cmVmdGtuOjAxOjE3NzY5NzgzNDY6Nm4xZU9uOEZvUzVLM1RNQkxXY2ZVdThBOVFY"
|
||||
local base_url="https://unified-hub.juniper.net/artifactory/engtech-binaries"
|
||||
local full_url="${base_url}/${remote_path}"
|
||||
|
||||
echo "📦 Uploading: $file"
|
||||
echo "📍 To: $full_url"
|
||||
echo ""
|
||||
|
||||
# Upload with progress
|
||||
if curl -u "${username}:${token}" \
|
||||
-T "$file" \
|
||||
--progress-bar \
|
||||
"$full_url"; then
|
||||
echo ""
|
||||
echo "✅ Upload successful!"
|
||||
echo "🔗 URL: $full_url"
|
||||
else
|
||||
echo ""
|
||||
echo "❌ Upload failed!"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Add this to your ~/.bashrc or ~/.zshrc
|
||||
|
||||
git-prune-branches() {
|
||||
echo "🌿 Git Branch Cleanup"
|
||||
echo "===================="
|
||||
echo ""
|
||||
|
||||
# Check if we're in a git repo
|
||||
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
||||
echo "❌ Error: Not in a git repository"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Get main branch name (main or master)
|
||||
local main_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
|
||||
if [[ -z "$main_branch" ]]; then
|
||||
main_branch="main"
|
||||
fi
|
||||
|
||||
echo "📡 Fetching latest from remote and pruning..."
|
||||
git fetch --all --prune
|
||||
echo ""
|
||||
|
||||
# Show merged branches
|
||||
echo "🗑️ Local branches merged into $main_branch:"
|
||||
local merged_branches=$(git branch --merged "$main_branch" | grep -v "^\*" | grep -v "$main_branch" | grep -v "master")
|
||||
if [[ -z "$merged_branches" ]]; then
|
||||
echo " (none)"
|
||||
else
|
||||
echo "$merged_branches"
|
||||
echo ""
|
||||
read -p "Delete these merged local branches? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "$merged_branches" | xargs -n 1 git branch -d
|
||||
echo "✅ Merged branches deleted"
|
||||
else
|
||||
echo "⏭️ Skipped"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
# Show orphaned branches
|
||||
echo "🗑️ Local branches tracking deleted remotes:"
|
||||
local orphaned_branches=$(git branch -vv | grep ': gone]' | awk '{print $1}')
|
||||
if [[ -z "$orphaned_branches" ]]; then
|
||||
echo " (none)"
|
||||
else
|
||||
echo "$orphaned_branches"
|
||||
echo ""
|
||||
read -p "Delete these orphaned local branches? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "$orphaned_branches" | xargs -n 1 git branch -D
|
||||
echo "✅ Orphaned branches deleted"
|
||||
else
|
||||
echo "⏭️ Skipped"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "📊 Remaining local branches:"
|
||||
git branch -vv
|
||||
|
||||
echo ""
|
||||
echo "✨ Cleanup complete!"
|
||||
}
|
||||
|
||||
alias git-clean='git-prune-branches'
|
||||
|
||||
touch ~/.aliases
|
||||
source ~/.aliases
|
||||
|
||||
|
||||
### ENTERPRISE_AI_ENV ###
|
||||
export WORKSPACE="$HOME/workspace"
|
||||
export DATA_ROOT="$HOME/data"
|
||||
export MODEL_ROOT="$HOME/models"
|
||||
|
||||
# HuggingFace cache location
|
||||
export HF_HOME="$MODEL_ROOT/huggingface"
|
||||
|
||||
# Ollama model location
|
||||
export OLLAMA_MODELS="$MODEL_ROOT/ollama"
|
||||
|
||||
# Convenience aliases
|
||||
alias ws='cd $WORKSPACE'
|
||||
alias src='cd $WORKSPACE/src'
|
||||
alias data='cd $DATA_ROOT'
|
||||
alias models='cd $MODEL_ROOT'
|
||||
|
||||
# Machine-local overrides (cloud paths, work vs personal — not synced via dotfiles)
|
||||
# ~/.bashrc — Kenji's shell configuration loader
|
||||
# Managed via dotfiles repo: http://172.27.0.35:3000/kenjim/dotfiles
|
||||
#
|
||||
# Structure:
|
||||
# ~/.bashrc — this file: loader only (SHARED, tracked in dotfiles)
|
||||
# ~/.bashrc.d/*.sh — modular configs by topic (SHARED, tracked in dotfiles)
|
||||
# ~/.bashrc.local — machine secrets + profile overrides (NOT tracked)
|
||||
# ~/.aliases — legacy aliases file (optional, NOT tracked)
|
||||
#
|
||||
# Machines:
|
||||
# kenjim-mbp work Mac (MACHINE_PROFILE=work)
|
||||
# kenjim-mbm personal Mac (MACHINE_PROFILE=personal)
|
||||
# etqc-*, etbg-*, engtech-dev-* work servers (auto-detected by hostname)
|
||||
# zet local Gitea server
|
||||
# =============================================================================
|
||||
|
||||
# Source system-wide files first
|
||||
[ -f /etc/profile ] && source /etc/profile
|
||||
[ -f /etc/bashrc ] && source /etc/bashrc
|
||||
|
||||
# Load all modular configs (sorted: 00_ before 10_ etc.)
|
||||
if [ -d ~/.bashrc.d ]; then
|
||||
for _f in ~/.bashrc.d/*.sh; do
|
||||
[ -r "$_f" ] && source "$_f"
|
||||
done
|
||||
unset _f
|
||||
fi
|
||||
|
||||
# Machine-local overrides: MACHINE_PROFILE, CLOUD_ROOT, secrets
|
||||
# This file is written by setup_enterprise_ai_bash.sh — never committed
|
||||
[ -f ~/.bashrc.local ] && source ~/.bashrc.local
|
||||
|
||||
|
||||
### DOTFILES_ALIASES ###
|
||||
export DOTFILES_DIR="$HOME/dotfiles"
|
||||
export DOTFILES_REMOTE="http://172.27.0.35:3000/kenjim/dotfiles"
|
||||
|
||||
# Dotfiles manager shortcut
|
||||
alias dotfiles='bash $HOME/scripts/dotfiles_manager.sh'
|
||||
alias dot='bash $HOME/scripts/dotfiles_manager.sh'
|
||||
|
||||
# Quick sync alias
|
||||
alias dots-sync='bash $HOME/scripts/dotfiles_manager.sh sync'
|
||||
alias dots-push='bash $HOME/scripts/dotfiles_manager.sh push'
|
||||
alias dots-status='bash $HOME/scripts/dotfiles_manager.sh status'
|
||||
|
||||
# Legacy aliases file (kept for compatibility)
|
||||
[ -f ~/.aliases ] && source ~/.aliases
|
||||
|
||||
Reference in New Issue
Block a user