-
-
Save p1-olm/8257427dbe89633b2381044b8a39c099 to your computer and use it in GitHub Desktop.
Allow piping to Sublime Text on Linux. Doesn't interfere with normal use.
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 | |
# Allow piping to Sublime Text. Doesn't interfere with normal use. | |
# Is stdin a terminal? | |
if test -t 0; then | |
# Stdin is a terminal. | |
# Open sublime normally. | |
/opt/sublime_text/sublime_text "$@" | |
else | |
# Stdin is not a terminal, it must be a pipe. | |
# Pipe stdin to a temporary file, and open it in sublime. | |
FILENAME=$(mktemp) | |
cat >"$FILENAME" && /opt/sublime_text/sublime_text "$FILENAME" "$@" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment