Skip to content

Instantly share code, notes, and snippets.

@blackknight36
Created July 29, 2026 02:41
Show Gist options
  • Select an option

  • Save blackknight36/1bbddbfa005c109d8ca9aadbc14fc50a to your computer and use it in GitHub Desktop.

Select an option

Save blackknight36/1bbddbfa005c109d8ca9aadbc14fc50a to your computer and use it in GitHub Desktop.
#!/usr/local/bin/bash
# export PATH="${PATH}:${GOPATH}/bin:${HOME}/bin:/opt/homebrew/bin:/opt/chef-workstation/bin:${HOME}/.gem/ruby/2.6.0/bin"
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
export CLICOLOR=1
export LSCOLORS=GxFxCxDxCxegedabagaced
export BASH_SILENCE_DEPRECATION_WARNING=1
export AUTHCLI_FASTPASS_ENABLED=t
export GPG_TTY=$(tty)
export GIT_PROMPT_ONLY_IN_REPO=1
export VISUAL=vim
export SYSTEMD_PAGER=''
if [ -f /usr/bin/most ]; then
export PAGER=most
else
export PAGER=less
fi
if [ -f "$(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh" ]; then
__GIT_PROMPT_DIR=$(brew --prefix)/opt/bash-git-prompt/share
GIT_PROMPT_ONLY_IN_REPO=1
source "$(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh"
fi
if [ -e /usr/share/terminfo/x/xterm-256color ]; then
export TERM='xterm-256color'
else
export TERM='xterm-color'
fi
# Avoid duplicate entries
HISTCONTROL=ignoredups:erasedups
# Store a large number of commands in the history file
HISTSIZE=1000000
HISTFILESIZE=2000000
# Ensure each command is timestamped
HISTTIMEFORMAT="%F %T "
# append to the history file, don't overwrite it
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
shopt -s histappend
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color*) color_prompt=yes;;
xterm-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=no
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
#if [ -f ~/.bash_aliases ]; then
# . ~/.bash_aliases
#fi
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
eval "$(dircolors -b)"
alias ls='ls --color=auto'
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
source /etc/bash_completion
fi
alias ll='ls -Gl'
alias dir='ls -l'
#alias start_tunnel='ssh -fND 2001 watters.ws'
#alias vnc_tunnel='ssh -f -N -L 5902:localhost:5901 root@mdct-3800-admin'
#alias run_herd='sudo docker run -w /root -e DISPLAY=$DISPLAY -v /pub:/pub -v herd_data:/root --net=host -v /tmp/.X11-unix:/tmp/.X11-unix -it 4c40f2dd60bc /bin/bash'
#alias run_herdpod='sudo podman run -w /root -e DISPLAY=$DISPLAY -v /pub:/pub -v herd_data:/root --net=host -v /tmp/.X11-unix:/tmp/.X11-unix -it flock_herder:latest /bin/bash'
#alias start_vpn='openconnect anyvpn1.dartcontainer.com --pfs -u ${USER} -c /etc/pki/tls/certs/DartCiscoAnyConnectV2.crt'
alias get_ea_nodes='knife search node "policy_group:eng_workstations_ea" -i | sort -V'
alias get_voc_nodes='knife search node "policy_group:voc_workstations_stable" -i | sort -V'
alias get_phx5_nodes="knife search node 'hostname:PHX5-VOC-DT-*' -i | sort -V"
alias sed='gsed'
# chef aliases
alias kd='knife config use chefdev'
alias kp='knife config use production'
# git aliases
function commit_with_changelog () {
message=$(tac CHANGELOG.md | grep -m 1 -B 99999 '^## ' | tac)
git commit -m "${message}"
}
function sign_hil_key() {
authcli vault
vault write -field=signed_key ssh/sign/hil-admin public_key=@"${HOME}"/.ssh/id_ecdsa.pub > "${HOME}"/.ssh/id_ecdsa-cert.pub
authcli vault ssh cert -ca infra-ssh-ca -role cbadmin -principals cbadmin,proxy
}
function sign_voc_key() {
authcli vault ssh cert -role it_voc_ssh --principals vocadmin
}
function signkeys() {
authcli vault ssh cert -ca it-ssh-ca -role it_endpoint_ssh --principals administrator
authcli vault ssh cert -role it_endpoint_ssh --principals administrator
}
function sign_ubuntu_key() {
authcli vault ssh cert -ca it-ssh-ca -role it_ops_ssh -principals itops
authcli vault ssh cert -ca it-ssh-ca -role it --principals ubuntu
authcli vault ssh cert -role it --principals ubuntu
authcli vault ssh cert -role it_ops_ssh -principals itops
}
function start_agent {
if ! pgrep -q ssh-agent; then
echo "Agent not running. Starting new SSH agent."
eval $(ssh-agent)
fi
# if ! ps -o pid,command | grep ssh-agent; then
# echo "Agent not running. Starting new SSH agent."
# /usr/bin/ssh-agent | head -2 > "${SSH_ENV}"
# chmod 0600 "${SSH_ENV}"
# source "${SSH_ENV}"
# fi
}
mkcd () {
mkdir -p "$1" && cd "$1" || return 1;
}
function set_proxy() {
#export {http,https,ftp}_proxy='http://10.8.0.1:8080'
#export {http,https,ftp}_proxy='http://localhost:19995'
#export {HTTP,HTTPS,FTP}_PROXY='http://localhost:19995'
export HTTP_PROXY='http://localhost:19995'
export http_proxy=$HTTP_PROXY
export HTTPS_PROXY='http://localhost:19995'
export https_proxy=$HTTPS_PROXY
}
function unset_proxy() {
unset {HTTP,HTTPS,FTP}_PROXY
unset {http,https,ftp}_proxy
}
#export LC_ALL=en_SE.UTF-8
#export GOPATH=/home/00/d861703/projects/golang
export CHEFPATH=/Users/michael.watters/.chefdk/gem/ruby/3.0.0/bin
export EDITOR=vim
export SYSTEMD_COLORS=0
function get_owner() {
if [ -z "$1" ]; then
echo "host name must be specified."
else
node=$(echo $1 | tr [a-z] [A-Z])
knife search node "hostname:${node}" -a cruise.owner -F text --profile=production 2>/dev/null | awk -F ': ' '/cruise.owner/ {print $2}'
fi
}
function get_hostname() {
if [ -z "$1" ]; then
echo "host name must be specified."
else
knife node attribute get "$1" hostname
fi
}
function get_ip() {
if [ -z "$1" ]; then
echo "host name must be specified."
else
knife node attribute get "$1" ipaddress
fi
}
function get_vpn_ip() {
if [ -z "$1" ]; then
echo "host name must be specified."
else
knife node show "$1" -a network.interfaces.cscotun0.addresses
fi
}
function upload_cruise_file {
if [ -z "$1" ] || [ -z "$2" ]; then
echo "file name and path must be specified."
exit 1
else
jf rt u "$1" "cpe-generic/$2/" --access-token AKCp8mZwDJtHWYiFcqF7k2WtEoFx9Kx7Guhhcm3iUikbjqJomZb8xjFVwzwfFhszYJ7VYRgEC --url https://artifactory.robot.car/artifactory --user michael.watters
fi
}
function get_ea_members {
knife search node "policy_group:eng_workstations_ea" -a cruise.owner | awk "/cruise.owner/ {print \$2}"
}
function get_vpn_ip {
knife node show $1 -a network.interfaces.cscotun0.addresses
}
#eval $(ssh-agent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment