Last active
November 12, 2019 01:19
-
-
Save albertomurillo/f09eb3bc7d8c05aec0e33724d41ef11c to your computer and use it in GitHub Desktop.
zshrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configure Golang | |
export GOHOME=~/go | |
export GOBIN=$GOHOME/bin | |
export PATH=$PATH:$GOBIN | |
# Configure JAVA | |
# export JAVA_HOME=$(/usr/libexec/java_home) | |
# update: Updates brew formulaes and casks | |
function update() { | |
echo "Updating brew..." | |
brew update | |
echo "Updating brew apps..." | |
brew upgrade | |
echo "Updating cask apps..." | |
for cask in $(brew cask outdated --greedy --verbose | awk '$2 != "(latest)" {print $1}'); do | |
brew cask reinstall "$cask" | |
done | |
echo "Cleaning up brew..." | |
brew cleanup -s --prune=1 | |
rm -rf "$(brew --cache)" | |
} | |
# docker_cleanup: Deletes unused images and containers | |
function docker_cleanup() { | |
docker system prune -f | |
} | |
# git_cleanup_branch: Delete remote branches that have already been merged | |
function git_cleanup_branch() { | |
git branch -r --merged | grep -v master | sed 's/origin\//:/' | xargs -n 1 git push origin | |
} | |
# git_pull_all: Pull changes from master for all repositories in current directory | |
function git_pull_all() { | |
find . -maxdepth 1 -type d -execdir git -C {} checkout master \; -execdir git -C {} pull origin master \; | |
} | |
# Add zsh completion for kubectl | |
if [ -f /usr/local/bin/kubectl ]; then source <(kubectl completion zsh); fi | |
# Add zsh completion for helm | |
if [ -f /usr/local/bin/helm ]; then source <(helm completion zsh); fi | |
# kubesecret: Navigate kubernetes secrets easier | |
function kubesecret() { | |
if [[ $# == 0 ]]; then | |
kubectl get secrets | |
elif [[ $# == 1 ]]; then | |
kubectl get secrets "$1" -o json | jq -r .data | |
elif [[ $# == 2 ]]; then | |
output=$(kubectl get secrets "$1" -o json | jq -r .data.\""$2"\" | base64 -D) | |
echo "$output" | |
elif [[ $# == 3 ]]; then | |
if [[ $3 == "-" ]]; then | |
# If value is "-" delete the entry | |
json=$(kubectl get secrets "$1" -o json | jq "del(.data.\"$2\")") | |
else | |
# Otherwise update the entry with a new value | |
value=$(echo -n "$3" | base64) | |
json=$(kubectl get secrets "$1" -o json | jq ".data.\"$2\" = \"$value\"") | |
fi | |
printf "%s" "$json" | kubectl apply -f - | |
fi | |
} | |
# sslexp: Show expiration date for a ssl certificate | |
function sslexp() { | |
curl --insecure -v "https://$1" 2>&1 | awk 'BEGIN { cert=0 } /^\* SSL connection/ { cert=1 } /^\*/ { if (cert) print }' | |
} | |
# akcurl: Curl bypassing akamai cache | |
function akcurl() { | |
curl -i -D - -o /dev/null -s \ | |
-H "Pragma: X-Akamai-CacheTrack" \ | |
-H "Pragma: akamai-x-cache-on" \ | |
-H "Pragma: akamai-x-cache-remote-on" \ | |
-H "Pragma: akamai-x-check-cacheable" \ | |
-H "Pragma: akamai-x-feo-trace" \ | |
-H "Pragma: akamai-x-get-cache-key" \ | |
-H "Pragma: akamai-x-get-extracted-values" \ | |
-H "Pragma: akamai-x-get-nonces" \ | |
-H "Pragma: akamai-x-get-request-id" \ | |
-H "Pragma: akamai-x-get-ssl-client-session-id" \ | |
-H "Pragma: akamai-x-get-true-cache-key" \ | |
-H "Pragma: akamai-x-serial-no" | |
} | |
# ssldomains: Print hostnames for a ssl certificate | |
function ssldomains() { | |
nmap -p 443 --script ssl-cert "$1" | awk '/Alternative/ {print substr($0, index($0,$5))}' | tr "," \\n | tr -d " " | tr -d "DNS:" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment