Skip to content

Instantly share code, notes, and snippets.

@preaction
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save preaction/9941797 to your computer and use it in GitHub Desktop.
Save preaction/9941797 to your computer and use it in GitHub Desktop.
Space too soon? Space too late? Don't let your over-zealous spacebar thumbing get in the way of Getting Work Done! Link these files as "space-too-soon -> gi" and "space-too-late -> gitp" to make "gi tpush" and "gitp ush" work correctly.
# Space too late. Run the command you wanted to run but you hit the space bar one
# character too late
#
# Usage:
# ln -s space-too-late gitp
# gitp ush
# gitc ommit
#
# Unlike its counterpart, space too soon, this one must be named differently based
# on which misspelling you frequently have
MISSPELLED=$(basename $0)
LETTER=${MISSPELLED: -1} # Space before '-1' is important!
COMMAND=${MISSPELLED:0:${#MISSPELLED}-1}
echo "!!! Space too late! Executing: $COMMAND ${LETTER}$@"
exec $COMMAND ${LETTER}$@
# Space too soon. Run the command you wanted to run but you hit the space bar one
# character too soon.
#
# Usage:
# ln -s space-too-soon gi
# gi tpush
# gi tcommit
MISSPELLED=$1
shift
LETTER=${MISSPELLED:0:1}
REST=${MISSPELLED:1}
# Use basename to ensure looking in PATH again
# $0 is the full path to this script
COMMAND="$(basename $0)$LETTER"
echo "!!! Space too soon! Executing: $COMMAND $REST $@"
exec $COMMAND $REST $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment