Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davidjray/1c449afa7aa380e287e9a488a4a0bdd4 to your computer and use it in GitHub Desktop.
Save davidjray/1c449afa7aa380e287e9a488a4a0bdd4 to your computer and use it in GitHub Desktop.
.zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
### Dev CCI on path
# export PATH=/Users/davidray/Library/Python/3.9/bin:$PATH
# export PATH=/Users/davidray/Library/Python/3.9/bin:$PATH
PATH=$PATH:/opt/homebrew/bin/pmd
fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src
fpath+=$HOME/.zsh/pure
alias brew='env PATH="${PATH//$(pyenv root)\/shims:/}" brew'
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
export DOCKER_DEFAULT_PLATFORM=linux/amd64
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled # disable automatic updates
# zstyle ':omz:update' mode auto # update automatically without asking
# zstyle ':omz:update' mode reminder # just remind me to update when it's time
# Uncomment the following line to change how often to auto-update (in days).
# zstyle ':omz:update' frequency 13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
brew
node
npm
nvm
zsh-syntax-highlighting
zsh-autosuggestions
zsh-completions
)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
alias cddev="cd ~/dev"
# Git Alias
alias gap="git add -p"
alias gs="git status"
alias gpull="git pull"
alias gpush="git push"
alias gc="git checkout"
alias gcb="git checkout -b"
alias gsw="git switch"
alias gswc="git switch -c"
alias gcm="git commit -m"
# gcm() {
# git commit -m $1
# }
alias scratch_limits="(echo -e \"Name\tMax\tRemaining\"; sf force limits api display -o DevHub --json | jq -r '.result[] | select(.name==\"ActiveScratchOrgs\" or .name==\"DailyScratchOrgs\") | [.name, .max, .remaining] | @tsv') | column -t -s $'\t'"
delete_flow() {
echo "You are about to delete $1 records from the PACKAGING ORG. Are you sure? (y/n)"
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
sf data query --use-tooling-api --result-format json --query "SELECT Id, MasterLabel, VersionNumber, Status FROM Flow WHERE MasterLabel = 'Incident 3 step wizard flow' AND Status = 'Obsolete' ORDER BY VersionNumber ASC LIMIT $1" --target-org mcim_packaging | jq -r '.result.records[].Id' | xargs -I {} sf data delete record -t -s Flow -i {} -o mcim_packaging
fi
}
delete_asset_monitors() {
echo "Enter the batch size (e.g., 500):"
read batch_size
if ! [[ "$batch_size" =~ ^[0-9]+$ ]] || [ "$batch_size" -le 0 ]; then
echo "Batch size must be a positive number."
return 1
fi
echo "Enter the total number of CFIM__Asset_Monitor__c records to delete (must be a multiple of $batch_size):"
read total_count
if ! [[ "$total_count" =~ ^[0-9]+$ ]] || [ $((total_count % batch_size)) -ne 0 ]; then
echo "Total count must be a valid number and a multiple of $batch_size."
return 1
fi
echo "You are about to bulk delete $total_count CFIM__Asset_Monitor__c records in batches of $batch_size from the PACKAGING ORG (records older than 1 year). Are you sure? (y/n)"
read confirm
if [ "$confirm" != "${confirm#[Yy]}" ]; then
batches=$((total_count / batch_size))
for ((i=1; i<=batches; i++)); do
echo ""
echo "β–Ά Preparing batch $i of $batches..."
# Temporary CSV file for this batch
csv_file=$(mktemp /tmp/delete_asset_monitors_batch_XXXX.csv)
# Write CSV header
echo "Id" > "$csv_file"
# Query records
sf data query --result-format json \
--query "SELECT Id FROM CFIM__Asset_Monitor__c WHERE CreatedDate < LAST_N_DAYS:100 ORDER BY CreatedDate ASC LIMIT $batch_size" \
--target-org mcim_packaging \
| jq -r '.result.records[].Id' >> "$csv_file"
# Check if any IDs were returned
if [ $(wc -l < "$csv_file") -le 1 ]; then
echo "⚠️ No more records found. Stopping."
rm "$csv_file"
break
fi
echo "πŸš€ Deleting batch $i..."
delete_output=$(sf data delete bulk --sobject CFIM__Asset_Monitor__c --file "$csv_file" --target-org mcim_packaging 2>&1)
# Show errors (if any)
if [[ "$delete_output" == *"ERROR"* || "$delete_output" == *"error"* ]]; then
echo "❌ Error during bulk delete in batch $i:"
echo "$delete_output"
else
echo "βœ… Batch $i deleted successfully."
fi
rm "$csv_file"
done
else
echo "Operation cancelled."
fi
}
delete_work_orders() {
echo "Enter the batch size (e.g., 500):"
read batch_size
if ! [[ "$batch_size" =~ ^[0-9]+$ ]] || [ "$batch_size" -le 0 ]; then
echo "Batch size must be a positive number."
return 1
fi
echo "Enter the total number of CFIM__Work_Order__c records to delete (must be a multiple of $batch_size):"
read total_count
if ! [[ "$total_count" =~ ^[0-9]+$ ]] || [ $((total_count % batch_size)) -ne 0 ]; then
echo "Total count must be a valid number and a multiple of $batch_size."
return 1
fi
echo "You are about to bulk delete $total_count CFIM__Work_Order__c records in batches of $batch_size from the PACKAGING ORG (records older than 100 days). Are you sure? (y/n)"
read confirm
if [ "$confirm" != "${confirm#[Yy]}" ]; then
batches=$((total_count / batch_size))
for ((i=1; i<=batches; i++)); do
echo ""
echo "β–Ά Preparing batch $i of $batches..."
# Temporary CSV file for this batch
csv_file=$(mktemp /tmp/delete_work_orders_batch_XXXX.csv)
# Write CSV header
echo "Id" > "$csv_file"
# Query records
ids=$(sf data query --result-format json \
--query "SELECT Id FROM CFIM__Work_Order__c WHERE CreatedDate < LAST_N_DAYS:100 ORDER BY CreatedDate ASC LIMIT $batch_size" \
--target-org mcim_packaging | jq -r '.result.records[].Id')
count=$(echo "$ids" | grep -c '^')
echo "πŸ”Ž Found $count record(s) to delete in this batch."
if [ "$count" -eq 0 ]; then
echo "⚠️ No more records found. Stopping early."
rm "$csv_file"
break
fi
# Write IDs to file
echo "$ids" >> "$csv_file"
echo "πŸš€ Deleting batch $i..."
delete_output=$(sf data delete bulk --sobject CFIM__Work_Order__c --file "$csv_file" --target-org mcim_packaging 2>&1)
# Show errors (if any)
if [[ "$delete_output" == *"ERROR"* || "$delete_output" == *"error"* ]]; then
echo "❌ Error during bulk delete in batch $i:"
echo "$delete_output"
else
echo "βœ… Batch $i deleted successfully."
fi
rm "$csv_file"
done
else
echo "Operation cancelled."
fi
}
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
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME=""
# oh-my-zsh overrides the prompt, so Pure must be activated after `source $ZSH/oh-my-zsh.sh`
autoload -Uz promptinit; promptinit
prompt pure
# eval $(ssh-agent)
{ eval `ssh-agent`; } &>/dev/null
# Pyenv init
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
### SFDX Workaround for Node heap size error
export NODE_OPTIONS=--max_old_space_size=8096
### Delete me once script is working
# export SFDX_CLIENT_ID="3MVG9yZ.WNe6byQA0.P73XgA8g9jdCQ1.mYdC79E.ZCbJ2gHpp0Kmw.U.jDPbzzUt9QnZOc8zappZawqm_..f"
# export SFDX_HUB_KEY=$(printf "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC3JXvFn/JOewGo\nM7pP09E5g3ngqngF3P4ORo9/UsAuaWXDk+TPDAnjPJmHbFPIb5ApGKdlhSyThZ5I\n11uHgdcZYNYR+WKDwQYjidhUMrG0GkJ5B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DIX243fy/OyWg\nS6Dmzf32MAfePyJX93oNPOcevV+KAedq9ORJSfD4uqIoC4WDtV/3U709AoGAQqaE\n7ky1CbAuZk8h8rIBbBCPGjr7rYmTh7Ri0T6kfuhS1JJxjHLm95wSKHh5J0IzQZgE\nfMjPL68Q/I7rICCOB1QlabtC/VWOAJe7SjV8bp6nFIxp2+9+23Dj8PI2uMrD3DEs\ndzpJUcyR6WEIdtO3DoeMbKleZLKJPLcyfowE6UECgYBy2gkW367nkVjNpx5sMsbI\nekWDgDGJ+E4mxM8CtiNMWuWXXNyefcFYfkATYE46MXOnibe9ZlSoY3fWVBglJ+Qg\nGnUUWqYTkaz8a8VmubER9D+kc+QXG4+8BDERTHqU+GFRTY+9dphx7hp2l9H65DL2\n2aBrsVyGO2HIVtSRqT90hQ==\n-----END PRIVATE KEY-----")
# export CUMULUSCI_ORG_trial_test="{\"username\":\"[email protected]\",\"instance_url\":\"https://mcimuser1732069010demoorg.my.salesforce.com\"}"
# export SFDX_AUDIENCE_URL="https://login.salesforce.com"
# export SF_ACCESS_TOKEN="00DfK000000YBaX!AQEAQDD_JgDiBj558KZu5KyNnPN6TXyQUw4Cu2NieirvPOs4k09ZYYbI_3CEgWzpYGHRdBz3MSBrdS_NLf88Hw8k9jvwI6Gq"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment