diff-two-last-commands.sh 363 B

123456789101112131415161718192021
  1. #!/usr/bin/env bash
  2. set -euo pipefail # bash strict mode
  3. dl() {
  4. if [[ -z "${1:-}" ]]; then
  5. first="1"
  6. else
  7. first="$1"
  8. fi
  9. if [[ -z "${2:-}" ]]; then
  10. last="2"
  11. else
  12. last="$2"
  13. fi
  14. # shellcheck disable=SC2091
  15. diff --color <( $(fc -ln "-${first}" "-${first}") ) <( $(fc -ln "-${last}" "-${last}") )
  16. }
  17. dl