Last active
January 17, 2025 17:31
-
-
Save nelhage/63ff290a7558ed3f89bb3d1cfe358522 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Create a temporary file to store the input | |
tempfile=$(mktemp) | |
trap 'rm -f "$tempfile"' EXIT | |
# Read from stdin into the temporary file | |
cat > "$tempfile" | |
# Get the preferred editor, defaulting to vim if none is set | |
editor=${VISUAL:-${EDITOR:-vim}} | |
# Open the temporary file in the editor | |
"$editor" "$tempfile" </dev/tty >/dev/tty | |
# Output the edited content to stdout | |
cat "$tempfile" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment