Created
March 7, 2018 02:49
-
-
Save iwconfig/a8dc8562d180540800ef5b048c205461 to your computer and use it in GitHub Desktop.
A replace function. Like "[CMD] !!" but replacing the previous command instead if prefixing.
This file contains 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
# A replace function. Like "[CMD] !!" but replacing the previous command instead if prefixing. | |
# Usage: __ [CMD] | |
function __() { | |
__=$(history -p \!\!) | |
[[ "$(echo '$__' | cut -d' ' -f1)" == "__" ]] && history -d $(history | tail -n1 | cut -d' ' -f2) | |
export __=${__/$(echo $__ | cut -d' ' -f1)/$1} | |
echo "$__" | |
$__ | |
history -s "$__" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment