Dotfiles & Shortcuts

March 8, 2021

I am pretty obsessed with optimizing my workflows. Here are a collection of aliases & functions which help to work fast and type less.

Scripts in package.json

Type scripts to see all the scripts in your package.json, helpful when jumping between projects.

function scripts() {
  jq '.scripts' package.json
}

Instant Shortcuts

Custom function I wrote to create a shortcut to a directory on the fly.

function createShortcut() {
    DIR=$(pwd)
    CMD=$1 # grab the current directory
    NEW_SHORTCUT="alias ${CMD}='cd ${DIR}'" #create alias string
    FILE=~/.profile
    if  grep -q "$NEW_SHORTCUT" "$FILE" ; then
          echo "> alias '${NEW_SHORTCUT}' already exists"
    else
          echo $NEW_SHORTCUT >> $FILE #add if it dosen't already exist!
          echo "> alias created: '${NEW_SHORTCUT}"
          source $FILE
    fi
}
# Example
> createShortcut components
> createShortcut frontend

Git Helpers

Making common git workflows easier

alias gpull='git pull origin $(git rev-parse --abbrev-ref HEAD)'
alias gpush='git push origin $(git rev-parse --abbrev-ref HEAD)'
alias b="git branch --sort=-committerdate"

Tmux

Making life easier working in Tmux

alias tn='tmux new -s'
alias ta='tmux attach -t'
alias tad='tmux attach -d -t'
alias tkss='tmux kill-session -t'
alias tksv='tmux kill-server'
alias tl='tmux list-sessions'

Kubernetes

Easy to forget kubectl commands

alias k="kubectl"
alias kvk='kubectl-vagrant -n kube-system'
alias kv='kubectl-vagrant'
alias whichcontext='kubectl config current-context'
alias kcc='kubectl config current-context'
alias kd='kubectl describe'
alias klogs='kubectl logs -f'
alias kfindpod='kubectl get pods'
alias kfinddep='kubectl get deployment --all-namespaces'
alias kdescribepod="kubectl -n research describe pod"