Skip to content

Instantly share code, notes, and snippets.

@rhighs
Created October 13, 2024 20:50
Show Gist options
  • Select an option

  • Save rhighs/b5d004c78ee4a7b530c30c99fffd045c to your computer and use it in GitHub Desktop.

Select an option

Save rhighs/b5d004c78ee4a7b530c30c99fffd045c to your computer and use it in GitHub Desktop.
I forget :/
remind ()
{
if [ $1="-h" ] || [ $1="--help" ]; then
echo "usage: remind <command_prefix>"
return 0
fi
if [ -z "$1" ]; then
echo "usage: remind <command_prefix>">&2
return 1
fi
local cmd=$(history | grep "$1" | grep -v "remind" | tail -n 1 | sed 's/^[ ]*[0-9]*[ ]*//')
if [ -z "$cmd" ]; then
echo "no matching command">&2
return 1
fi
echo "$cmd"
eval "$cmd"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment