Skip to content

Instantly share code, notes, and snippets.

@Mikulas
Created August 22, 2019 13:06
Show Gist options
  • Save Mikulas/bb28c7d4c76c1bcac7b39712b362c129 to your computer and use it in GitHub Desktop.
Save Mikulas/bb28c7d4c76c1bcac7b39712b362c129 to your computer and use it in GitHub Desktop.
bash dump
export PYTHONIOENCODING="UTF-8"
export VAULT_ADDR="https://vault.mgit.cz:8200"
export GO111MODULE=on
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
# git identities
if which karn > /dev/null; then eval "$(karn init)"; fi
# set iTerm tab name to dirname https://gist.github.com/phette23/5270658
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ';
fi
source <(kubectl completion bash)
alias p='cd ~/Projects'
alias ..='cd ..'
alias ls='ls -G'
alias reload='source ~/.bash_profile'
alias kubectl-repl="rlwrap /Users/mikulas/Projects/go/src/github.com/mikulas/kubectl-repl/kubectl-repl"
alias ka='/Users/mikulas/Projects/kubernetes/apply.sh'
alias drun='docker run -it --rm'
alias drunsh='docker run -it --rm --entrypoint sh'
alias root='cd "$(git rev-parse --show-toplevel)"'
alias flush-dns='sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache'
alias rmo='find . -name '*.orig' -delete'
alias ctx='kubectx'
alias k='kubectl'
alias cal='gcal --starting-day=1 --highlighting=yes'
alias gfrh='git fetch && git reset --hard'
__git_complete ga _git_reset
alias gce='git commit --allow-empty -m'
alias ga='git add'
__git_complete ga _git_add
alias gb='git branch'
__git_complete gb _git_branch
alias gbr='git-browse'
alias gc='git commit'
__git_complete gc _git_commit
alias gca='git commit -v --amend'
__git_complete gca _git_commit
alias gcd='git clone --depth=2'
__git_complete gcd _git_clone
alias gcl='git clean -df .'
__git_complete gcl _git_clean
alias gco='git checkout'
__git_complete gco _git_checkout
alias gcp='git cherry-pick'
__git_complete gcp _git_cherry_pick
alias gd='git diff'
__git_complete gd _git_diff
alias gfu='git-fixup'
__git_complete gfu _git_commit
alias gl='git lg'
__git_complete gl _git_log
alias gm='git merge --no-ff -X histogram'
__git_complete gm _git_merge
alias gmt='git mergetool'
__git_complete gmt _git_mergetool
alias gp='git push'
__git_complete gp _git_push
alias gpf='git push --force-with-lease'
__git_complete gp _git_push
alias gpnv='git-push-no-f --no-verify'
__git_complete gpnv _git_push
alias gpr='git pull --rebase --prune --autostash'
__git_complete gpr _git_pull
alias gr='git rebase --autostash -i -X histogram --autosquash'
__git_complete gr _git_rebase
alias grb='git rebase --autostash -i -X histogram $(git merge-base master HEAD)'
__git_complete grb _git_rebase
alias grc='git rebase --continue'
__git_complete grc _git_rebase
alias grh='git-reset-hard'
__git_complete grc _git_reset
alias grm='git rebase -i -X histogram master'
__git_complete grm _git_rebase
alias grs='git-rebase-stashed'
alias gs='git status --untracked-files=all -s'
__git_complete gs __git_main
alias gu='git update'
# https://unix.stackexchange.com/a/139121
set -o ignoreeof
function exit() {
echo 'Use "logout" to leave the shell.'
}
function present() {
export PS1='\[\033[34m\]\W\[\033[0m\]\[\033[33m\] \$\[\033[0m\] '
echo -e "\033]50;SetProfile=Presentation\a"
}
function present-off() {
echo -e "\033]50;SetProfile=Default\a"
reload
}
export GIT_PS1_SHOWDIRTYSTATE=1
export PS1='\[\033[34m\]\w\[\033[0m\]$(__git_ps1 " (%s)") $(kubectx-current)\[\033[33m\] \$\[\033[0m\] '
export PATH="$HOME/bin:$PATH:/usr/local/sbin:$GOPATH/bin"
export MAILCHECK=0
export EDITOR='nano'
LS_COLORS='di=1:fi=0:ln=31:pi=5:so=5:bd=5:cd=5:or=31:mi=0:ex=35:*.rpm=90'
export LS_COLORS
export HISTCONTROL=ignoreboth:erasedups
export HISTSIZE=100000
export HISTFILESIZE=100000
shopt -s histappend # overwrite
shopt -s globstar 2>/dev/null
ulimit -n 1280
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export PATH="/usr/local/opt/curl/bin:$PATH"
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
export TF_VAR_vault_token="$(vault-login)"
test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [[ $# -eq 0 ]]; then
echo "$0 stage"
exit 1
fi
STAGE="$1"
set -x
git push origin HEAD:deploy/$STAGE "${@:2}"
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
git commit --fixup "$1"
read -p "rebase? [Y] " -r CONFIRM
set -x
REF="$(git rev-parse "$1")"
git -c sequence.editor=true rebase --interactive --autosquash --autostash "$REF~1"
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
git reset head~1 "$@"
#!/usr/bin/env bash
set -eu
kubectl get "$@" --sort-by=.metadata.creationTimestamp
#!/usr/bin/env bash
set -eu
if [[ "$PWD" = "/Users/mikulas/Projects/mallgroup/infrastructure" ]]; then
INTERNAL_IP="$(kubectl get nodes "$1" -o json | jq -r '.status.addresses[] | select(.type == "InternalIP").address')"
ssh -i "$PWD/local-id_rsa" core@"$INTERNAL_IP"
exit $?
fi
PUBLIC_IP="$(kubectl get nodes "$1" -o json | jq -r '.status.addresses[] | select(.type == "ExternalIP").address')"
ssh -i "/Users/mikulas/Projects/kubernetes/keys/id_rsa" admin@"$PUBLIC_IP"
#!/usr/bin/env bash
set -eu
CMD="watch -n 2 -- kubectl get $@"
eval "${CMD/ sorted / --sort-by=.metadata.creationTimestamp }"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment