On this page I explain what I've done to get a comfortable
environment for using the linux "screen" utility to connect from my
home Mac to a remote linux machine. For me it's a replacement for
VNC, though since screen
is text-based, one can't do
graphical things like open firefox
.
I mainly stay inside emacs. I've been surprised so far to find that a non-windowed emacs works well for me; thanks to Eric Smith for his help on this.
First of all, I downloaded iTerm2 onto my Mac, I think from https://www.iterm2.com. It's like the Mac's Terminal application, but seemed more promising (sorry, I forget why -- I did a lot of googling to get there). It was trivial to install on my Mac. Then after a lot of experimentation, I did the following.
screen
First I open iTerm2 and ssh to the remote linux machine. Very important: I supply a -e option when starting screen, telling it not to take over control-A, as shown below. Apparently that's what happens by default -- something to do with the Apple Command key. So I chose some useless key(s) for that, not that I really understand or even care to do so, and here's how I start:
screen -e '^||'
Better yet, create file ~/.screenrc
and put this line
in it, and then you can simply type screen
:
escape ^||
To suspend ("detach") the session (kind of like quitting VNC), issue the following command, which you can even run from inside your emacs shell:
screen -d
Then later, when you want to get back to your session in the state where you left it (e.g., inside emacs if you ran "screen -d" from inside an emacs shell), run the "resume" command:
screen -r
screen
After a DisconnectSuppose you get disconnected (say, your wireless connection disappears). To reconnect, you can first detach and then resume:
screen -d screen -r
screen
processI've been able to kill the screen process by issuing the
command, exit
, at the shell (not inside emacs)
where
Via drop-down menu, go to iTerm2 > Preferences; then:
Profiles > Colors Foreground: Black Background: White Profiles > Keys > Left option key acts as +Esc Keys > Left command key = Left option [Click "deny" in response to query; so, do not change in Mac system preferences > security-and-privacy > privacy
NOTE: I tried
Preferences > General > Applications in terminal may access clipboard
but that didn't seem to do anything. So copying and pasting can require use of the Edit drop-down menu.
~/.emacs
fileI added the following to the end of my .emacs file (your HOSTTYPE
might be different). To come up with the set-face-foreground
commands, I simply put the cursor on the offending text (which often
was invisible because the color was white on my white background), ran
meta-x set-face-foreground
, and looked at the default.
(when (equal (getenv "HOSTTYPE") "x86_64-linux") (require 'apropos) ; for apropos-symbol face, below (require 'message) ; for apropos-symbol face, below (require 'flyspell) ; for apropos-symbol face, below (require 'erc) ; for apropos-symbol face, below (require 'rmail) ; for apropos-symbol face, below (require 'font-latex) ; for apropos-symbol face, below (normal-erase-is-backspace-mode -1) (setq electric-indent-mode nil) (set-face-foreground 'comint-highlight-input "blue") (set-face-foreground 'apropos-symbol "blue") (set-face-foreground 'message-header-to "blue") (set-face-foreground 'flyspell-duplicate "blue") (set-face-foreground 'font-lock-string-face "blue") (set-face-foreground 'erc-nick-default-face "black") (set-face-foreground 'bold "blue") (set-face-foreground 'bold-italic "blue") (set-face-foreground 'buffer-menu-buffer "blue") (set-face-foreground 'rmail-highlight "black") (set-face-background 'rmail-highlight "yellow") (set-face-background 'region "yellow") (set-face-foreground 'font-latex-sedate-face "blue") (set-face-foreground 'font-latex-sectioning-2-face "blue") ;; (set-face-foreground 'font-latex-sectioning-4-face "OliveDrab") (set-face-foreground 'font-latex-sectioning-4-face "magenta") (set-face-foreground 'font-latex-bold-face "blue") (set-face-foreground 'font-latex-math-face "blue") (set-face-foreground 'font-latex-verbatim-face "purple") (set-face-background 'isearch "yellow") (set-face-foreground 'font-lock-type-face "green") ;; (set-face-foreground 'sh-heredoc "green") (set-face-foreground 'erc-button "blue") (set-face-foreground 'erc-bold-face "magenta") )
This is hardly a conclusion! I expect that this page will evolve over time. Dead-trivial suggestions are welcomed — but I don't want to spend any more time than I have to messing with this stuff!