30

This is an admittedly silly question, but I honestly don't know if this is possible.

I often mistype "git stash pop" (never-mind why). Can I map/shortcut/alias my typo to what it's supposed to be?

3
  • 16
    I misspelled this today, I was wondering what I would find if i googled git stash poop
    – Emanuel
    Commented Aug 19, 2015 at 20:39
  • 1
    and then you find this: github.com/markhobson/git-stash-poop Commented Mar 19, 2021 at 6:53
  • 4
    9 years later and this is my greatest contribution to Stack Overflow. I'm so proud!
    – jgillman
    Commented Apr 9, 2021 at 16:59

3 Answers 3

18
git config --global alias.sp 'stash pop'

then git sp expands to git stash pop

0
17

Define a shell function:

git() {
  if [ "$1" == "stash" -a "$2" == "poop" ]; then
    shift; shift; command git stash pop "$@"
  else
    command git "$@"
  fi
}
1
  • 1
    Technically this is the correct answer, but I think using an alias to avoid the problem all together was a better overall solution.
    – jgillman
    Commented Jul 26, 2017 at 19:14
16

For those that need the properly generated output...

if [ "$1" == "stash" -a "$2" == "poop" ]
  then
      command git stash pop
      echo "
   )  )
  (   ) (
   ) _   )
    ( \_
  _(_\ \)__
 (____\___))"
  else
      command git "$@"
  fi;
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.