Monolune

How to open Edwin in a console

When Edwin, the text editor bundled with MIT Scheme, is started using mit-scheme -edit, Edwin opens in a window. I recently had the desire to open Edwin in the terminal, instead of in a window, and I've found two ways of achieving it.

Method 1

According to the MIT Scheme documentation on Edwin:

... Under unix, if X11 is not available or if the DISPLAY environment variable is undefined, Edwin will run on Scheme's console.

So, the solution is to undefine the DISPLAY environment variable when starting Edwin to make Edwin run in the console. To achieve this, run:

DISPLAY= scheme -edit

Playing with environment variables seems hacky, so a more respectable solution is needed.

Method 2

The key is to note that in the REPL, (edit 'console) starts Edwin in a console.

But how do we start Edwin immediately through the command line without entering the REPL? A clue: according to scheme --help on my machine:

--eval ARG ...

Evaluates the argument expressions as if in the REPL.

So, to start Edwin in console mode from the console, you can do:

mit-scheme -eval "(edit 'console)"

I prefer this method. It's less hacky.

Bonus

It is tiring to have to enter mit-scheme -eval "(edit 'console)" every time one wants start Edwin in console mode. A useful alias is alias edwin=$'mit-scheme -eval "(edit 'console)"'. This allows you to enter Edwin by just entering edwin in the terminal. Place the alias in ~/.bashrc if using bash, or in ~/.zshrc if using zsh. Additionally, I also like to define an alias for opening Edwin in a window: alias gedwin='scheme -edit'. The 'g' in 'gedwin' stands for 'graphical'. It helps me remember.