Created
February 20, 2014 21:52
-
-
Save stormbrew/9124044 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this to get a default autocomplete that, if you press | |
# tab on an empty prompt it will expand to the first term of | |
# the last command you ran. | |
# | |
# Inspired by http://thechangelog.com/interactive-shell-git/ | |
# where I don't really want to have to go in and out of a mode | |
# when I don't necessarily know it'll be worth it, but being | |
# able to skip typing git every command would be nice. This way | |
# you can go (using their example): | |
# | |
# git status | |
# <t> add . | |
# <t> commit -m "Ship it!" | |
# <t> push | |
# | |
# This is actually fewer total keystrokes than the example given, | |
# and I didn't have to predict how many commands I'd run to decide | |
# whether or not to do it. | |
# | |
# Plus it works with any command. | |
function _auto_last_cmd() { | |
COMPREPLY=$(history -- -1 | awk '{ print $2 }') | |
} | |
complete -F _auto_last_cmd -E |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment