Fix macos terminal issues and teach ssage it name #57
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tldr
cat |ssage oopsssage - a typo
We should add ssage to the prompt so that shell sage is confused when it sees ssage invoications.
Righ now:
After adding (ssage):
zsh session / macos messages
The zsh in macos likes to output additional information in interactive mode. Like:
This behavior can be disable by removing
TERM_PROGRAMfrom the environment, so the zsh doesn't assumes it runsunder a terminal emulator app.
removing TERM_PROGRAM makes the output clean again
zsh -i uses /dev/tty
There is one more issue. The
_aliasestries to access the /dev/tty (zsh -i). This crashes chains likecat|ssage hi. Even worse it takes down the whole process group and terminal vanish. Only apple terminal lets me catch what is really going on:I couldn't reproduce the problem in Jupyter, so I created a few examples in the
debugfolder.To see the issue in action, run
cat | python debug/aliases.pyin Apple Terminal -- it will crash the same way ssage does now.The fixed version
safe_aliases.py, starts a new session / process group which removes access to /dev/tty. I also closed the stdin and stderr for good measure.You can verify that the fix works with:
cat | python debug/safe_aliases.py.