Sublime Forum

Sublime Merge Pre-Commit Hook User Input



I have a pre-commit hook for my repository which runs some coding standard static analysis tooling, and if any errors are found prompts the user with a Y/n prompt asking if they would like to automatically fix the errors that were found. This works great on the console but it breaks in Sublime Merge (macOS build 2083). The error message is:

line 11: /dev/tty: Device not configured

Which is this line at the start of my script which is designed to redirect input by assigning standard input to the keyboard:

exec < /dev/tty

I worked around the issue by checking to see if TTY was available in my pre-commit script like so:

if tty >/dev/null 2>&1; then
  exec </dev/tty

This causes my pre-commit skip to not ask the user but take a default action. Ideally I’d like to have SM prompt me for the choice somehow… can SM work with pre-commit hooks that require input somehow?



Hi @coogle,

Thanks for reaching out!

Sublime Merge doesn’t currently support processing input from Git commit hooks.
The easiest approach would be to redirect to a graphical text editor to take input.
For example, using the Sublime Text CLI - subl:

subl [arguments] - >out          Edit stdin and write the edit to stdout

Hope this helps!

- Dylan