out of time
-
Screentopia!
I’m a big fan of GNU Screen. Split-screen is indispensable for writing code, and it’s convenient to be able to run a bunch of interactive processes and switch between them really easily (control-A [0-9]). I like screen, so much, that I never want to use a terminal emulator without it.
So, to that end, I generally set up gnome-terminal to execute screen at startup. That way, when I exit my last screen window, the whole terminal exits, which is what I want. This generally works quite well, but one problem I’ve had is that, if I use screen to open a non-shell process (e.g. vim), it doesn’t carry the environment variables set in my
.bashrcover. This makes sense when you think about what is going on:gnome-terminalstartsgnome-terminalspawns ascreenprocessscreenspawns abashprocess, which inhabits window 0- From that
bashprocess, I typescreen vim ., which causesscreento spawn avimprocess.
Thus, the process ancestry for vim is:
vim>screen>gnome-terminal. At no point is there abashin there to load the.bashrcand set up the environment.I played with a few different solutions, but finally came up with a pretty simple one. Here are the steps.
- Create a
.bash_envfile in your home directory. Move your environment variable declarations to there. - Add the line
. ~/.bash_envto your.bashrc - Create the following script
startscreensomewhere (I keep my personal scripts in~/.local/bin):
#! /bin/bash . ~/.bash_env screen- Make your
startscreenscript executable. - Set your
gnome-terminalcustom command to~/.local/bin/startscreen(or wherever you put it).
And you’re set!